summaryrefslogtreecommitdiff
path: root/sfx2
diff options
context:
space:
mode:
authorRafael Dominguez <venccsralph@gmail.com>2012-06-14 15:10:20 -0430
committerRafael Dominguez <venccsralph@gmail.com>2012-06-14 15:10:20 -0430
commit643f30de35d26e7e50ef3ea39a476733dbf38251 (patch)
tree8759154388aedd7e7266161d450cf1acae5f41c9 /sfx2
parentf88c608f482f1b682d06e4945026e826877f2c2a (diff)
Update paint code to use drawinglayer API.
Change-Id: Iacb8b1a8447d8fb54cbb72b7a5a8f25cadb1267d
Diffstat (limited to 'sfx2')
-rw-r--r--sfx2/Library_sfx.mk2
-rw-r--r--sfx2/source/control/thumbnailview.cxx125
2 files changed, 75 insertions, 52 deletions
diff --git a/sfx2/Library_sfx.mk b/sfx2/Library_sfx.mk
index a516bb34db33..9009edec68fc 100644
--- a/sfx2/Library_sfx.mk
+++ b/sfx2/Library_sfx.mk
@@ -63,9 +63,11 @@ $(eval $(call gb_Library_add_defs,sfx,\
endif
$(eval $(call gb_Library_use_libraries,sfx,\
+ basegfx \
comphelper \
cppu \
cppuhelper \
+ drawinglayer \
fwe \
i18nisolang1 \
sal \
diff --git a/sfx2/source/control/thumbnailview.cxx b/sfx2/source/control/thumbnailview.cxx
index 428514977393..c7be3fd1718d 100644
--- a/sfx2/source/control/thumbnailview.cxx
+++ b/sfx2/source/control/thumbnailview.cxx
@@ -14,7 +14,21 @@
#include "orgmgr.hxx"
#include "thumbnailviewacc.hxx"
+#include <basegfx/color/bcolortools.hxx>
+#include <basegfx/matrix/b2dhommatrixtools.hxx>
+#include <basegfx/polygon/b2dpolygon.hxx>
+#include <basegfx/range/b2drectangle.hxx>
+#include <basegfx/vector/b2dsize.hxx>
+#include <basegfx/vector/b2dvector.hxx>
#include <comphelper/processfactory.hxx>
+#include <drawinglayer/attribute/fillbitmapattribute.hxx>
+#include <drawinglayer/attribute/fontattribute.hxx>
+#include <drawinglayer/primitive2d/fillbitmapprimitive2d.hxx>
+#include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx>
+#include <drawinglayer/primitive2d/textlayoutdevice.hxx>
+#include <drawinglayer/primitive2d/textprimitive2d.hxx>
+#include <drawinglayer/processor2d/baseprocessor2d.hxx>
+#include <drawinglayer/processor2d/processorfromoutputdevice.hxx>
#include <rtl/ustring.hxx>
#include <unotools/ucbstreamhelper.hxx>
#include <vcl/decoview.hxx>
@@ -31,6 +45,10 @@
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/lang/XSingleServiceFactory.hpp>
+using namespace basegfx;
+using namespace basegfx::tools;
+using namespace drawinglayer::attribute;
+using namespace drawinglayer::primitive2d;
enum
{
@@ -44,6 +62,17 @@ enum
SCROLL_OFFSET = 4
};
+B2DPolygon lcl_Rect2Polygon (const Rectangle &aRect)
+{
+ B2DPolygon aPolygon;
+ aPolygon.append(B2DPoint(aRect.Left(),aRect.Top()));
+ aPolygon.append(B2DPoint(aRect.Left(),aRect.Bottom()));
+ aPolygon.append(B2DPoint(aRect.Right(),aRect.Bottom()));
+ aPolygon.append(B2DPoint(aRect.Right(),aRect.Top()));
+
+ return aPolygon;
+}
+
Image lcl_fetchThumbnail (const rtl::OUString &msURL, int width, int height)
{
using namespace ::com::sun::star;
@@ -305,72 +334,64 @@ void ThumbnailView::DrawItem (ThumbnailViewItem *pItem, const Rectangle &aRect)
{
if ( (aRect.GetHeight() > 0) && (aRect.GetWidth() > 0) )
{
- const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
-
- Point aPos = aRect.TopLeft();
- const Size aSize = aRect.GetSize();
- DrawOutDev( aPos, aSize, aPos, aSize, maVirDev );
-
- Control::SetFillColor();
+ Primitive2DSequence aSeq(3);
- if ( IsColor() )
- maVirDev.SetFillColor( maColor );
- else if ( IsEnabled() )
- maVirDev.SetFillColor( rStyleSettings.GetWindowColor() );
- else
- maVirDev.SetFillColor( rStyleSettings.GetFaceColor() );
+ const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
- maVirDev.DrawRect( aRect );
+ // Draw item background
+ BColor aFillColor = maColor.getBColor();
if ( pItem->mbSelected || pItem->mbHover )
- {
- Rectangle aSelRect = aRect;
- Color aDoubleColor( rStyleSettings.GetHighlightColor() );
+ aFillColor = rStyleSettings.GetHighlightColor().getBColor();
- // specify selection output
- aSelRect.Left() += 4;
- aSelRect.Top() += 4;
- aSelRect.Right() -= 4;
- aSelRect.Bottom() -= 4;
-
- SetLineColor( aDoubleColor );
- aSelRect.Left()++;
- aSelRect.Top()++;
- aSelRect.Right()--;
- aSelRect.Bottom()--;
- DrawRect( aSelRect );
- aSelRect.Left()++;
- aSelRect.Top()++;
- aSelRect.Right()--;
- aSelRect.Bottom()--;
- DrawRect( aSelRect );
- }
+ aSeq[0] = Primitive2DReference( new PolyPolygonColorPrimitive2D(
+ B2DPolyPolygon(lcl_Rect2Polygon(aRect)),
+ aFillColor));
// Draw thumbnail
- Size aImageSize = pItem->maImage.GetSizePixel();
- Size aRectSize = aRect.GetSize();
+ Point aPos = aRect.TopLeft();
+ Size aImageSize = pItem->maImage.GetSizePixel();
+ Size aRectSize = aRect.GetSize();
aPos.X() = aRect.Left() + (aRectSize.Width()-aImageSize.Width())/2;
aPos.Y() = aRect.Top() + (aRectSize.Height()-aImageSize.Height())/2;
- sal_uInt16 nImageStyle = 0;
- if( !IsEnabled() )
- nImageStyle |= IMAGE_DRAW_DISABLE;
-
- if ( (aImageSize.Width() > aRectSize.Width()) ||
- (aImageSize.Height() > aRectSize.Height()) )
- {
- maVirDev.SetClipRegion( Region( aRect ) );
- maVirDev.DrawImage( aPos, pItem->maImage, nImageStyle);
- maVirDev.SetClipRegion();
- }
- else
- maVirDev.DrawImage( aPos, pItem->maImage, nImageStyle );
+ aSeq[1] = Primitive2DReference( new FillBitmapPrimitive2D(
+ B2DHomMatrix(),
+ FillBitmapAttribute(pItem->maImage.GetBitmapEx(),
+ B2DPoint(aPos.X(),aPos.Y()),
+ B2DVector(aImageSize.Width(),aImageSize.Height()),
+ false)
+ ));
// Draw centered text below thumbnail
- aPos.Y() += 5 + aImageSize.Height();
+ aPos.Y() += 20 + aImageSize.Height();
aPos.X() = aRect.Left() + (aRectSize.Width() - maVirDev.GetTextWidth(pItem->maText))/2;
- maVirDev.DrawText(aPos,pItem->maText);
+ // Create the text primitive
+ B2DVector aFontSize;
+ FontAttribute aFontAttr = getFontAttributeFromVclFont(
+ aFontSize, GetFont(), false, true );
+
+
+ basegfx::B2DHomMatrix aTextMatrix( createScaleTranslateB2DHomMatrix(
+ aFontSize.getX(), aFontSize.getY(),
+ double( aPos.X() ), double( aPos.Y() ) ) );
+
+ aSeq[2] = Primitive2DReference(
+ new TextSimplePortionPrimitive2D(aTextMatrix,
+ pItem->maText,0,pItem->maText.getLength(),
+ std::vector< double >( ),
+ aFontAttr,
+ com::sun::star::lang::Locale(),
+ Color(COL_BLACK).getBColor() ) );
+
+ // Create the processor and process the primitives
+ const drawinglayer::geometry::ViewInformation2D aNewViewInfos;
+ drawinglayer::processor2d::BaseProcessor2D * pProcessor =
+ drawinglayer::processor2d::createBaseProcessor2DFromOutputDevice(
+ *this, aNewViewInfos );
+
+ pProcessor->process(aSeq);
}
}