diff options
author | Rafael Dominguez <venccsralph@gmail.com> | 2012-06-19 16:04:54 -0430 |
---|---|---|
committer | Rafael Dominguez <venccsralph@gmail.com> | 2012-06-19 16:04:54 -0430 |
commit | f822c18c546d6262c46d30b532a1f2b4186ccfa5 (patch) | |
tree | 97fbc4cc9a638233aad8df26a09f743f4bc08ec3 /sfx2/source/control | |
parent | 9b8a9a7d116ac06b7f8a402e17546460fcde641e (diff) |
Subclass ThumbnailViewItem for TemplateFolderView specific.
- Let ThumbnailViewItem a basic structure for displaying a thumbnail,
name and a selection box.
Change-Id: I00fffcb0c1cb17017cfe7adfde152e640ee01c82
Diffstat (limited to 'sfx2/source/control')
-rw-r--r-- | sfx2/source/control/templatefolderview.cxx | 4 | ||||
-rw-r--r-- | sfx2/source/control/templatefolderviewitem.cxx | 114 | ||||
-rw-r--r-- | sfx2/source/control/thumbnailviewitem.cxx | 33 |
3 files changed, 121 insertions, 30 deletions
diff --git a/sfx2/source/control/templatefolderview.cxx b/sfx2/source/control/templatefolderview.cxx index 800380e42973..26d757f280da 100644 --- a/sfx2/source/control/templatefolderview.cxx +++ b/sfx2/source/control/templatefolderview.cxx @@ -12,7 +12,7 @@ #include <comphelper/processfactory.hxx> #include <sfx2/doctempl.hxx> #include <sfx2/templateview.hxx> -#include <sfx2/thumbnailviewitem.hxx> +#include <sfx2/templatefolderviewitem.hxx> #include <unotools/ucbstreamhelper.hxx> #include <vcl/pngread.hxx> @@ -165,7 +165,7 @@ void TemplateFolderView::Populate () if (nEntries) { - ThumbnailViewItem* pItem = new ThumbnailViewItem( *this, this ); + TemplateFolderViewItem* pItem = new TemplateFolderViewItem( *this, this ); pItem->mnId = i+1; pItem->maText = aRegionName; pItem->setSelectClickHdl(LINK(this,ThumbnailView,OnFolderSelected)); diff --git a/sfx2/source/control/templatefolderviewitem.cxx b/sfx2/source/control/templatefolderviewitem.cxx new file mode 100644 index 000000000000..2486560bfc51 --- /dev/null +++ b/sfx2/source/control/templatefolderviewitem.cxx @@ -0,0 +1,114 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * Copyright 2012 LibreOffice contributors. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include <sfx2/templatefolderviewitem.hxx> + +#include <basegfx/matrix/b2dhommatrixtools.hxx> +#include <basegfx/polygon/b2dpolygon.hxx> +#include <drawinglayer/attribute/fillbitmapattribute.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 <vcl/button.hxx> + +using namespace basegfx; +using namespace basegfx::tools; +using namespace drawinglayer::attribute; +using namespace drawinglayer::primitive2d; + +TemplateFolderViewItem::TemplateFolderViewItem (ThumbnailView &rView, Window *pParent) + : ThumbnailViewItem(rView,pParent) +{ +} + +TemplateFolderViewItem::~TemplateFolderViewItem () +{ +} + +void TemplateFolderViewItem::calculateItemsPosition () +{ + ThumbnailViewItem::calculateItemsPosition(); +} + +void TemplateFolderViewItem::Paint (drawinglayer::processor2d::BaseProcessor2D *pProcessor, + const ThumbnailItemAttributes *pAttrs) +{ + int nCount = 0; + int nSeqSize = 3; + + if (!maPreview2.IsEmpty()) + ++nSeqSize; + + BColor aFillColor = pAttrs->aFillColor; + Primitive2DSequence aSeq(nSeqSize); + + // Draw background + if ( mbSelected || mbHover ) + aFillColor = pAttrs->aHighlightColor; + + aSeq[nCount++] = Primitive2DReference( new PolyPolygonColorPrimitive2D( + B2DPolyPolygon(Polygon(maDrawArea,5,5).getB2DPolygon()), + aFillColor)); + + // Draw thumbnail + Point aPos = maPrev1Pos; + Size aImageSize = maPreview1.GetSizePixel(); + + float fScaleX = 1.0f; + float fScaleY = 1.0f; + + if (!maPreview2.IsEmpty()) + { + fScaleX = 0.8; + fScaleY = 0.8; + + aSeq[nCount++] = Primitive2DReference( new FillBitmapPrimitive2D( + createScaleTranslateB2DHomMatrix(fScaleX,fScaleY,aPos.X(),aPos.Y()), + FillBitmapAttribute(maPreview2, + B2DPoint(35,20), + B2DVector(aImageSize.Width(),aImageSize.Height()), + false) + )); + } + + aSeq[nCount++] = Primitive2DReference( new FillBitmapPrimitive2D( + createScaleTranslateB2DHomMatrix(fScaleX,fScaleY,aPos.X(),aPos.Y()), + FillBitmapAttribute(maPreview1, + B2DPoint(0,0), + B2DVector(aImageSize.Width(),aImageSize.Height()), + false) + )); + + // Draw centered text below thumbnail + aPos = maTextPos; + + // Create the text primitive + basegfx::B2DHomMatrix aTextMatrix( createScaleTranslateB2DHomMatrix( + pAttrs->aFontSize.getX(), pAttrs->aFontSize.getY(), + double( aPos.X() ), double( aPos.Y() ) ) ); + + aSeq[nCount++] = Primitive2DReference( + new TextSimplePortionPrimitive2D(aTextMatrix, + maText,0,maText.getLength(), + std::vector< double >( ), + pAttrs->aFontAttr, + com::sun::star::lang::Locale(), + Color(COL_BLACK).getBColor() ) ); + + pProcessor->process(aSeq); + + if (mbMode || mbHover || mbSelected) + mpSelectBox->Paint(maDrawArea); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ + + diff --git a/sfx2/source/control/thumbnailviewitem.cxx b/sfx2/source/control/thumbnailviewitem.cxx index 76d3bb2b6aaa..a23fcb203e17 100644 --- a/sfx2/source/control/thumbnailviewitem.cxx +++ b/sfx2/source/control/thumbnailviewitem.cxx @@ -166,20 +166,14 @@ bool ThumbnailViewItem::isInsideTitle (const Point &pt) const void ThumbnailViewItem::Paint (drawinglayer::processor2d::BaseProcessor2D *pProcessor, const ThumbnailItemAttributes *pAttrs) { - int nCount = 0; - int nSeqSize = 3; - - if (!maPreview2.IsEmpty()) - ++nSeqSize; - BColor aFillColor = pAttrs->aFillColor; - Primitive2DSequence aSeq(nSeqSize); + Primitive2DSequence aSeq(3); // Draw background if ( mbSelected || mbHover ) aFillColor = pAttrs->aHighlightColor; - aSeq[nCount++] = Primitive2DReference( new PolyPolygonColorPrimitive2D( + aSeq[0] = Primitive2DReference( new PolyPolygonColorPrimitive2D( B2DPolyPolygon(Polygon(maDrawArea,5,5).getB2DPolygon()), aFillColor)); @@ -187,25 +181,8 @@ void ThumbnailViewItem::Paint (drawinglayer::processor2d::BaseProcessor2D *pProc Point aPos = maPrev1Pos; Size aImageSize = maPreview1.GetSizePixel(); - float fScaleX = 1.0f; - float fScaleY = 1.0f; - - if (!maPreview2.IsEmpty()) - { - fScaleX = 0.8; - fScaleY = 0.8; - - aSeq[nCount++] = Primitive2DReference( new FillBitmapPrimitive2D( - createScaleTranslateB2DHomMatrix(fScaleX,fScaleY,aPos.X(),aPos.Y()), - FillBitmapAttribute(maPreview2, - B2DPoint(35,20), - B2DVector(aImageSize.Width(),aImageSize.Height()), - false) - )); - } - - aSeq[nCount++] = Primitive2DReference( new FillBitmapPrimitive2D( - createScaleTranslateB2DHomMatrix(fScaleX,fScaleY,aPos.X(),aPos.Y()), + aSeq[1] = Primitive2DReference( new FillBitmapPrimitive2D( + createTranslateB2DHomMatrix(aPos.X(),aPos.Y()), FillBitmapAttribute(maPreview1, B2DPoint(0,0), B2DVector(aImageSize.Width(),aImageSize.Height()), @@ -220,7 +197,7 @@ void ThumbnailViewItem::Paint (drawinglayer::processor2d::BaseProcessor2D *pProc pAttrs->aFontSize.getX(), pAttrs->aFontSize.getY(), double( aPos.X() ), double( aPos.Y() ) ) ); - aSeq[nCount++] = Primitive2DReference( + aSeq[2] = Primitive2DReference( new TextSimplePortionPrimitive2D(aTextMatrix, maText,0,maText.getLength(), std::vector< double >( ), |