From 6050dad25fb34d6c7bf4feb0d850e9277d92c91e Mon Sep 17 00:00:00 2001 From: Rafael Dominguez Date: Sun, 12 Aug 2012 23:33:20 -0430 Subject: [PATCH] Draw borders arounds thumbnail. Change-Id: Icaf9485d20c8e747d08371a1db5f4d7bee2d37bb --- sfx2/inc/sfx2/thumbnailviewitem.hxx | 11 ++++++ sfx2/source/control/templatelocalviewitem.cxx | 35 +++++++++++++++++-- sfx2/source/control/templateviewitem.cxx | 22 ++++++++++-- sfx2/source/control/thumbnailviewitem.cxx | 28 +++++++++++++-- 4 files changed, 89 insertions(+), 7 deletions(-) diff --git a/sfx2/inc/sfx2/thumbnailviewitem.hxx b/sfx2/inc/sfx2/thumbnailviewitem.hxx index 3b1aa95eb00c..aab7fe3d260d 100644 --- a/sfx2/inc/sfx2/thumbnailviewitem.hxx +++ b/sfx2/inc/sfx2/thumbnailviewitem.hxx @@ -44,10 +44,18 @@ class Font; class Window; class ThumbnailView; +namespace basegfx { + class B2DPoint; +} + namespace drawinglayer { namespace processor2d { class BaseProcessor2D; } + + namespace primitive2d { + class BorderLinePrimitive2D; + } } struct ThumbnailItemAttributes @@ -109,6 +117,9 @@ public: virtual void Paint (drawinglayer::processor2d::BaseProcessor2D *pProcessor, const ThumbnailItemAttributes *pAttrs); + static drawinglayer::primitive2d::BorderLinePrimitive2D* + createBorderLine (const basegfx::B2DPoint &rStart, const basegfx::B2DPoint &rEnd); + private: DECL_LINK (OnClick, CheckBox *); diff --git a/sfx2/source/control/templatelocalviewitem.cxx b/sfx2/source/control/templatelocalviewitem.cxx index 765b54436695..f337df8cb3dc 100644 --- a/sfx2/source/control/templatelocalviewitem.cxx +++ b/sfx2/source/control/templatelocalviewitem.cxx @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -38,10 +39,10 @@ void TemplateLocalViewItem::Paint (drawinglayer::processor2d::BaseProcessor2D *p const ThumbnailItemAttributes *pAttrs) { int nCount = 0; - int nSeqSize = 3; + int nSeqSize = 7; if (!maPreview2.IsEmpty()) - ++nSeqSize; + nSeqSize += 5; BColor aFillColor = pAttrs->aFillColor; Primitive2DSequence aSeq(nSeqSize); @@ -73,6 +74,21 @@ void TemplateLocalViewItem::Paint (drawinglayer::processor2d::BaseProcessor2D *p B2DVector(aImageSize.Width(),aImageSize.Height()), false) )); + + // draw thumbnail borders + float fWidth = aImageSize.Width()*fScaleX; + float fHeight = aImageSize.Height()*fScaleY; + float fPosX = aPos.getX()+35*fScaleX; + float fPosY = aPos.getY()+20*fScaleY; + + aSeq[nCount++] = Primitive2DReference(createBorderLine(B2DPoint(fPosX,fPosY), + B2DPoint(fPosX+fWidth,fPosY))); + aSeq[nCount++] = Primitive2DReference(createBorderLine(B2DPoint(fPosX+fWidth,fPosY), + B2DPoint(fPosX+fWidth,fPosY+fHeight))); + aSeq[nCount++] = Primitive2DReference(createBorderLine(B2DPoint(fPosX+fWidth,fPosY+fHeight), + B2DPoint(fPosX,fPosY+fHeight))); + aSeq[nCount++] = Primitive2DReference(createBorderLine(B2DPoint(fPosX,fPosY+fHeight), + B2DPoint(fPosX,fPosY))); } aSeq[nCount++] = Primitive2DReference( new FillBitmapPrimitive2D( @@ -83,6 +99,21 @@ void TemplateLocalViewItem::Paint (drawinglayer::processor2d::BaseProcessor2D *p false) )); + // draw thumbnail borders + float fWidth = aImageSize.Width()*fScaleX; + float fHeight = aImageSize.Height()*fScaleY; + float fPosX = aPos.getX(); + float fPosY = aPos.getY(); + + aSeq[nCount++] = Primitive2DReference(createBorderLine(B2DPoint(fPosX,fPosY), + B2DPoint(fPosX+fWidth,fPosY))); + aSeq[nCount++] = Primitive2DReference(createBorderLine(B2DPoint(fPosX+fWidth,fPosY), + B2DPoint(fPosX+fWidth,fPosY+fHeight))); + aSeq[nCount++] = Primitive2DReference(createBorderLine(B2DPoint(fPosX+fWidth,fPosY+fHeight), + B2DPoint(fPosX,fPosY+fHeight))); + aSeq[nCount++] = Primitive2DReference(createBorderLine(B2DPoint(fPosX,fPosY+fHeight), + B2DPoint(fPosX,fPosY))); + // Draw centered text below thumbnail aPos = maTextPos; diff --git a/sfx2/source/control/templateviewitem.cxx b/sfx2/source/control/templateviewitem.cxx index a3f835e12f14..2b2b4abbcead 100644 --- a/sfx2/source/control/templateviewitem.cxx +++ b/sfx2/source/control/templateviewitem.cxx @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -63,7 +64,7 @@ void TemplateViewItem::Paint(drawinglayer::processor2d::BaseProcessor2D *pProces { BColor aFillColor = pAttrs->aFillColor; - int nCount = maSubTitle.isEmpty() ? 3 : 4; + int nCount = maSubTitle.isEmpty() ? 7 : 8; Primitive2DSequence aSeq(nCount); // Draw background @@ -85,6 +86,21 @@ void TemplateViewItem::Paint(drawinglayer::processor2d::BaseProcessor2D *pProces false) )); + // draw thumbnail borders + float fWidth = aImageSize.Width(); + float fHeight = aImageSize.Height(); + float fPosX = maPrev1Pos.getX(); + float fPosY = maPrev1Pos.getY(); + + aSeq[2] = Primitive2DReference(createBorderLine(B2DPoint(fPosX,fPosY), + B2DPoint(fPosX+fWidth,fPosY))); + aSeq[3] = Primitive2DReference(createBorderLine(B2DPoint(fPosX+fWidth,fPosY), + B2DPoint(fPosX+fWidth,fPosY+fHeight))); + aSeq[4] = Primitive2DReference(createBorderLine(B2DPoint(fPosX+fWidth,fPosY+fHeight), + B2DPoint(fPosX,fPosY+fHeight))); + aSeq[5] = Primitive2DReference(createBorderLine(B2DPoint(fPosX,fPosY+fHeight), + B2DPoint(fPosX,fPosY))); + // Draw centered text below thumbnail // Create the text primitive @@ -92,7 +108,7 @@ void TemplateViewItem::Paint(drawinglayer::processor2d::BaseProcessor2D *pProces pAttrs->aFontSize.getX(), pAttrs->aFontSize.getY(), double( maTextPos.X() ), double( maTextPos.Y() ) ) ); - aSeq[2] = Primitive2DReference( + aSeq[6] = Primitive2DReference( new TextSimplePortionPrimitive2D(aTitleMatrix, maTitle,0,pAttrs->nMaxTextLenght, std::vector< double >( ), @@ -106,7 +122,7 @@ void TemplateViewItem::Paint(drawinglayer::processor2d::BaseProcessor2D *pProces pAttrs->aFontSize.getX()*SUBTITLE_SCALE_FACTOR, pAttrs->aFontSize.getY()*SUBTITLE_SCALE_FACTOR, double( maSubTitlePos.X() ), double( maSubTitlePos.Y() ) ) ); - aSeq[3] = Primitive2DReference( + aSeq[8] = Primitive2DReference( new TextSimplePortionPrimitive2D(aSubTitleMatrix, maSubTitle,0,pAttrs->nMaxTextLenght, std::vector< double >( ), diff --git a/sfx2/source/control/thumbnailviewitem.cxx b/sfx2/source/control/thumbnailviewitem.cxx index 9db5cbd9c74f..6eb68320e8ad 100644 --- a/sfx2/source/control/thumbnailviewitem.cxx +++ b/sfx2/source/control/thumbnailviewitem.cxx @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -160,7 +161,7 @@ void ThumbnailViewItem::Paint (drawinglayer::processor2d::BaseProcessor2D *pProc const ThumbnailItemAttributes *pAttrs) { BColor aFillColor = pAttrs->aFillColor; - Primitive2DSequence aSeq(3); + Primitive2DSequence aSeq(7); // Draw background if ( mbSelected || mbHover ) @@ -182,6 +183,21 @@ void ThumbnailViewItem::Paint (drawinglayer::processor2d::BaseProcessor2D *pProc false) )); + // draw thumbnail borders + float fWidth = aImageSize.Width(); + float fHeight = aImageSize.Height(); + float fPosX = maPrev1Pos.getX(); + float fPosY = maPrev1Pos.getY(); + + aSeq[2] = Primitive2DReference(createBorderLine(B2DPoint(fPosX,fPosY), + B2DPoint(fPosX+fWidth,fPosY))); + aSeq[3] = Primitive2DReference(createBorderLine(B2DPoint(fPosX+fWidth,fPosY), + B2DPoint(fPosX+fWidth,fPosY+fHeight))); + aSeq[4] = Primitive2DReference(createBorderLine(B2DPoint(fPosX+fWidth,fPosY+fHeight), + B2DPoint(fPosX,fPosY+fHeight))); + aSeq[5] = Primitive2DReference(createBorderLine(B2DPoint(fPosX,fPosY+fHeight), + B2DPoint(fPosX,fPosY))); + // Draw centered text below thumbnail aPos = maTextPos; @@ -190,7 +206,7 @@ void ThumbnailViewItem::Paint (drawinglayer::processor2d::BaseProcessor2D *pProc pAttrs->aFontSize.getX(), pAttrs->aFontSize.getY(), double( aPos.X() ), double( aPos.Y() ) ) ); - aSeq[2] = Primitive2DReference( + aSeq[6] = Primitive2DReference( new TextSimplePortionPrimitive2D(aTextMatrix, maTitle,0,pAttrs->nMaxTextLenght, std::vector< double >( ), @@ -204,6 +220,14 @@ void ThumbnailViewItem::Paint (drawinglayer::processor2d::BaseProcessor2D *pProc mpSelectBox->Paint(maDrawArea); } +drawinglayer::primitive2d::BorderLinePrimitive2D* +ThumbnailViewItem::createBorderLine (const basegfx::B2DPoint &rStart, const basegfx::B2DPoint &rEnd) +{ + return new BorderLinePrimitive2D(rStart,rEnd,0.5,0,0,0,0,0,0, + BColor(),Color(COL_BLACK).getBColor(),BColor(), + false,STYLE_SOLID); +} + IMPL_LINK (ThumbnailViewItem, OnClick, CheckBox*, ) { mbSelected = mpSelectBox->GetState() == STATE_CHECK;