Wrap thumbnail item name text inside its assigned area.
Change-Id: I4b3d57c7d2fa1a8cffb35345ea46390f6eff3cb1
This commit is contained in:
parent
05156817f7
commit
bfb8b04829
8 changed files with 34 additions and 10 deletions
|
@ -23,7 +23,7 @@ struct TemplateFolderViewItem : public ThumbnailViewItem
|
|||
|
||||
virtual ~TemplateFolderViewItem ();
|
||||
|
||||
virtual void calculateItemsPosition ();
|
||||
virtual void calculateItemsPosition (sal_uInt32 nMaxTextLenght);
|
||||
|
||||
const Point& getPrev2Pos () const { return maPrev2Pos; }
|
||||
|
||||
|
|
|
@ -207,6 +207,8 @@ public:
|
|||
|
||||
long GetItemHeight() const { return mnItemHeight; }
|
||||
|
||||
void setItemMaxTextLength (sal_uInt32 nLength);
|
||||
|
||||
void setItemDimensions (long ItemWidth, long ThumbnailHeight,
|
||||
long DisplayHeight, int itemPadding);
|
||||
|
||||
|
|
|
@ -51,6 +51,7 @@ namespace drawinglayer {
|
|||
|
||||
struct ThumbnailItemAttributes
|
||||
{
|
||||
sal_uInt32 nMaxTextLenght;
|
||||
basegfx::BColor aFillColor;
|
||||
basegfx::BColor aHighlightColor;
|
||||
basegfx::B2DVector aFontSize;
|
||||
|
@ -91,7 +92,7 @@ struct ThumbnailViewItem
|
|||
|
||||
const Rectangle& getDrawArea () const { return maDrawArea; }
|
||||
|
||||
virtual void calculateItemsPosition ();
|
||||
virtual void calculateItemsPosition (sal_uInt32 nMaxTextLenght);
|
||||
|
||||
const Point& getTextPos () const { return maTextPos; }
|
||||
|
||||
|
|
|
@ -277,6 +277,12 @@ void TemplateFolderView::Populate ()
|
|||
{
|
||||
rtl::OUString aRegionName(mpDocTemplates->GetFullRegionName(i));
|
||||
|
||||
if (aRegionName.getLength() > mpItemAttrs->nMaxTextLenght)
|
||||
{
|
||||
aRegionName = aRegionName.copy(0,mpItemAttrs->nMaxTextLenght-3);
|
||||
aRegionName += "...";
|
||||
}
|
||||
|
||||
sal_uInt16 nEntries = mpDocTemplates->GetCount(i);
|
||||
|
||||
if (nEntries)
|
||||
|
@ -298,12 +304,19 @@ void TemplateFolderView::Populate ()
|
|||
|
||||
for (sal_uInt16 j = 0; j < nEntries; ++j)
|
||||
{
|
||||
rtl::OUString aName = mpDocTemplates->GetName(i,j);
|
||||
rtl::OUString aURL = mpDocTemplates->GetPath(i,j);
|
||||
rtl::OUString aType = SvFileInformationManager::GetDescription(INetURLObject(aURL));
|
||||
|
||||
if (aName.getLength() > mpItemAttrs->nMaxTextLenght)
|
||||
{
|
||||
aName = aName.copy(0,mpItemAttrs->nMaxTextLenght-3);
|
||||
aName += "...";
|
||||
}
|
||||
|
||||
TemplateViewItem *pTemplateItem = new TemplateViewItem(*mpItemView,mpItemView);
|
||||
pTemplateItem->mnId = j+1;
|
||||
pTemplateItem->maText = mpDocTemplates->GetName(i,j);
|
||||
pTemplateItem->maText = aName;
|
||||
pTemplateItem->setPath(aURL);
|
||||
pTemplateItem->setFileType(aType);
|
||||
pTemplateItem->maPreview1 = lcl_fetchThumbnail(aURL,THUMBNAIL_MAX_WIDTH,THUMBNAIL_MAX_HEIGHT);
|
||||
|
|
|
@ -36,9 +36,9 @@ TemplateFolderViewItem::~TemplateFolderViewItem ()
|
|||
delete maTemplates[i];
|
||||
}
|
||||
|
||||
void TemplateFolderViewItem::calculateItemsPosition ()
|
||||
void TemplateFolderViewItem::calculateItemsPosition (sal_uInt32 nMaxTextLenght)
|
||||
{
|
||||
ThumbnailViewItem::calculateItemsPosition();
|
||||
ThumbnailViewItem::calculateItemsPosition(nMaxTextLenght);
|
||||
}
|
||||
|
||||
void TemplateFolderViewItem::Paint (drawinglayer::processor2d::BaseProcessor2D *pProcessor,
|
||||
|
|
|
@ -172,6 +172,7 @@ void ThumbnailView::ImplInitSettings( bool bFont, bool bForeground, bool bBackgr
|
|||
mpItemAttrs->aFillColor = maColor.getBColor();
|
||||
mpItemAttrs->aHighlightColor = rStyleSettings.GetHighlightColor().getBColor();
|
||||
mpItemAttrs->aFontAttr = getFontAttributeFromVclFont(mpItemAttrs->aFontSize,GetFont(),false,true);
|
||||
mpItemAttrs->nMaxTextLenght = -1;
|
||||
}
|
||||
|
||||
void ThumbnailView::ImplInitScrollBar()
|
||||
|
@ -328,7 +329,7 @@ void ThumbnailView::CalculateItemPositions ()
|
|||
|
||||
pItem->show(true);
|
||||
pItem->setDrawArea(Rectangle( Point(x,y), Size(mnItemWidth, mnItemHeight) ));
|
||||
pItem->calculateItemsPosition();
|
||||
pItem->calculateItemsPosition(mpItemAttrs->nMaxTextLenght);
|
||||
|
||||
if ( !((nCurCount+1) % mnCols) )
|
||||
{
|
||||
|
@ -530,7 +531,7 @@ IMPL_LINK( ThumbnailView,ImplScrollHdl, ScrollBar*, pScrollBar )
|
|||
|
||||
pItem->show(true);
|
||||
pItem->setDrawArea(Rectangle( Point(x,y), Size(mnItemWidth, mnItemHeight) ));
|
||||
pItem->calculateItemsPosition();
|
||||
pItem->calculateItemsPosition(mpItemAttrs->nMaxTextLenght);
|
||||
|
||||
if ( !((i+1) % mnCols) )
|
||||
{
|
||||
|
@ -1085,6 +1086,11 @@ void ThumbnailView::SetLineCount( sal_uInt16 nNewLines )
|
|||
}
|
||||
}
|
||||
|
||||
void ThumbnailView::setItemMaxTextLength(sal_uInt32 nLength)
|
||||
{
|
||||
mpItemAttrs->nMaxTextLenght = nLength;
|
||||
}
|
||||
|
||||
void ThumbnailView::setItemDimensions(long itemWidth, long thumbnailHeight, long displayHeight, int itemPadding)
|
||||
{
|
||||
mnItemWidth = itemWidth + 2*itemPadding;
|
||||
|
|
|
@ -116,7 +116,7 @@ void ThumbnailViewItem::setDrawArea (const Rectangle &area)
|
|||
maDrawArea = area;
|
||||
}
|
||||
|
||||
void ThumbnailViewItem::calculateItemsPosition ()
|
||||
void ThumbnailViewItem::calculateItemsPosition (sal_uInt32 nMaxTextLenght)
|
||||
{
|
||||
drawinglayer::primitive2d::TextLayouterDevice aTextDev;
|
||||
|
||||
|
@ -132,7 +132,7 @@ void ThumbnailViewItem::calculateItemsPosition ()
|
|||
// Calculate text position
|
||||
aPos.Y() += aImageSize.Height();
|
||||
aPos.Y() = aPos.Y() + aTextDev.getTextHeight() + (maDrawArea.Bottom() - aPos.Y() - aTextDev.getTextHeight())/2;
|
||||
aPos.X() = maDrawArea.Left() + (aRectSize.Width() - aTextDev.getTextWidth(maText,0,maText.getLength()))/2;
|
||||
aPos.X() = maDrawArea.Left() + (aRectSize.Width() - aTextDev.getTextWidth(maText,0,nMaxTextLenght))/2;
|
||||
maTextPos = aPos;
|
||||
|
||||
// Calculate checkbox position
|
||||
|
@ -199,7 +199,7 @@ void ThumbnailViewItem::Paint (drawinglayer::processor2d::BaseProcessor2D *pProc
|
|||
|
||||
aSeq[2] = Primitive2DReference(
|
||||
new TextSimplePortionPrimitive2D(aTextMatrix,
|
||||
maText,0,maText.getLength(),
|
||||
maText,0,pAttrs->nMaxTextLenght,
|
||||
std::vector< double >( ),
|
||||
pAttrs->aFontAttr,
|
||||
com::sun::star::lang::Locale(),
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
#define ITEM_MAX_HEIGHT 192
|
||||
#define ITEM_PADDING 5
|
||||
#define ITEM_SPACE 20
|
||||
#define ITEM_MAX_TEXT_LENGTH 20
|
||||
#define THUMBNAIL_MAX_HEIGHT 128
|
||||
|
||||
#define INIT_FOLDER_COLS 3
|
||||
|
@ -149,6 +150,7 @@ SfxTemplateManagerDlg::SfxTemplateManagerDlg (Window *parent)
|
|||
maView->SetStyle(WB_TABSTOP | WB_VSCROLL);
|
||||
maView->SetColor(GetBackground().GetColor());
|
||||
maView->SetSizePixel(aThumbSize);
|
||||
maView->setItemMaxTextLength(ITEM_MAX_TEXT_LENGTH);
|
||||
|
||||
maView->setItemDimensions(ITEM_MAX_WIDTH,THUMBNAIL_MAX_HEIGHT,
|
||||
ITEM_MAX_HEIGHT-THUMBNAIL_MAX_HEIGHT,
|
||||
|
|
Loading…
Reference in a new issue