sfx2/AllLangResTarget_sfx2.mk | 1 sfx2/Library_sfx.mk | 2 sfx2/Package_inc.mk | 2 sfx2/inc/sfx2/templatefolderview.hxx | 32 ++++++ sfx2/inc/sfx2/templatefolderviewitem.hxx | 36 +++++++ sfx2/inc/sfx2/templateview.hxx | 47 +++++++++ sfx2/inc/sfx2/thumbnailview.hxx | 29 +++--- sfx2/inc/sfx2/thumbnailviewitem.hxx | 15 --- sfx2/source/control/templatefolderview.cxx | 61 +++++++++--- sfx2/source/control/templatefolderviewitem.cxx | 114 ++++++++++++++++++++++++ sfx2/source/control/templateview.cxx | 118 +++++++++++++++++++++++++ sfx2/source/control/templateview.hrc | 9 + sfx2/source/control/templateview.src | 17 +++ sfx2/source/control/thumbnailview.cxx | 113 +++++++++-------------- sfx2/source/control/thumbnailviewitem.cxx | 48 +--------- 15 files changed, 491 insertions(+), 153 deletions(-)
New commits: commit 472b4b8d3889587e67538aa41e178377acf1a271 Author: Rafael Dominguez <venccsra...@gmail.com> Date: Tue Jun 19 18:05:00 2012 -0430 Create a filter class to display items by generated app. Change-Id: Ia412fe70746674672bc2f1c8cb3e2cedd947e645 diff --git a/sfx2/inc/sfx2/templatefolderview.hxx b/sfx2/inc/sfx2/templatefolderview.hxx index 84cd003..d75d679 100644 --- a/sfx2/inc/sfx2/templatefolderview.hxx +++ b/sfx2/inc/sfx2/templatefolderview.hxx @@ -15,6 +15,29 @@ class SfxDocumentTemplates; class TemplateView; +// Display template items depending on the generator application +class ViewFilter_Application +{ +public: + + enum APP_GENERATOR + { + APP_WRITER, + APP_CALC, + APP_IMPRESS, + APP_DRAW + }; + + ViewFilter_Application (SfxDocumentTemplates *pDocTemplates, APP_GENERATOR App); + + bool operator () (const ThumbnailViewItem *pItem); + +private: + + APP_GENERATOR mApp; + SfxDocumentTemplates *mpDocTemplates; +}; + class TemplateFolderView : public ThumbnailView { public: diff --git a/sfx2/source/control/templatefolderview.cxx b/sfx2/source/control/templatefolderview.cxx index 26d757f..e000b5b 100644 --- a/sfx2/source/control/templatefolderview.cxx +++ b/sfx2/source/control/templatefolderview.cxx @@ -136,6 +136,17 @@ BitmapEx lcl_fetchThumbnail (const rtl::OUString &msURL, int width, int height) return aThumbnail; } +ViewFilter_Application::ViewFilter_Application (SfxDocumentTemplates *pDocTemplates, + ViewFilter_Application::APP_GENERATOR App) + : mApp(App), mpDocTemplates(pDocTemplates) +{ +} + +bool ViewFilter_Application::operator () (const ThumbnailViewItem *pItem) +{ + return true; +} + TemplateFolderView::TemplateFolderView ( Window* pParent, const ResId& rResId, bool bDisableTransientChildren) : ThumbnailView(pParent,rResId,bDisableTransientChildren), mpDocTemplates(new SfxDocumentTemplates), commit f822c18c546d6262c46d30b532a1f2b4186ccfa5 Author: Rafael Dominguez <venccsra...@gmail.com> Date: Tue Jun 19 16:04:54 2012 -0430 Subclass ThumbnailViewItem for TemplateFolderView specific. - Let ThumbnailViewItem a basic structure for displaying a thumbnail, name and a selection box. Change-Id: I00fffcb0c1cb17017cfe7adfde152e640ee01c82 diff --git a/sfx2/Library_sfx.mk b/sfx2/Library_sfx.mk index 872a107..5f2dd61 100644 --- a/sfx2/Library_sfx.mk +++ b/sfx2/Library_sfx.mk @@ -150,6 +150,7 @@ $(eval $(call gb_Library_add_exception_objects,sfx,\ sfx2/source/control/statcach \ sfx2/source/control/templateview \ sfx2/source/control/templatefolderview \ + sfx2/source/control/templatefolderviewitem \ sfx2/source/control/thumbnailviewitem \ sfx2/source/control/thumbnailviewacc \ sfx2/source/control/thumbnailview \ diff --git a/sfx2/Package_inc.mk b/sfx2/Package_inc.mk index c66ce44..ed7a7f2 100644 --- a/sfx2/Package_inc.mk +++ b/sfx2/Package_inc.mk @@ -129,6 +129,7 @@ $(eval $(call gb_Package_add_file,sfx2_inc,inc/sfx2/templdlg.hxx,sfx2/templdlg.h $(eval $(call gb_Package_add_file,sfx2_inc,inc/sfx2/templatelocnames.hrc,sfx2/templatelocnames.hrc)) $(eval $(call gb_Package_add_file,sfx2_inc,inc/sfx2/templateview.hxx,sfx2/templateview.hxx)) $(eval $(call gb_Package_add_file,sfx2_inc,inc/sfx2/templatefolderview.hxx,sfx2/templatefolderview.hxx)) +$(eval $(call gb_Package_add_file,sfx2_inc,inc/sfx2/templatefolderviewitem.hxx,sfx2/templatefolderviewitem.hxx)) $(eval $(call gb_Package_add_file,sfx2_inc,inc/sfx2/thumbnailview.hxx,sfx2/thumbnailview.hxx)) $(eval $(call gb_Package_add_file,sfx2_inc,inc/sfx2/thumbnailviewitem.hxx,sfx2/thumbnailviewitem.hxx)) $(eval $(call gb_Package_add_file,sfx2_inc,inc/sfx2/titledockwin.hxx,sfx2/titledockwin.hxx)) diff --git a/sfx2/inc/sfx2/templatefolderviewitem.hxx b/sfx2/inc/sfx2/templatefolderviewitem.hxx new file mode 100644 index 0000000..d0ebfe1 --- /dev/null +++ b/sfx2/inc/sfx2/templatefolderviewitem.hxx @@ -0,0 +1,36 @@ +/* -*- 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/. + */ + +#ifndef TEMPLATEFOLDERVIEWITEM_HXX +#define TEMPLATEFOLDERVIEWITEM_HXX + +#include <sfx2/thumbnailviewitem.hxx> + +struct TemplateFolderViewItem : public ThumbnailViewItem +{ + BitmapEx maPreview2; + + TemplateFolderViewItem (ThumbnailView &rView, Window *pParent); + + virtual ~TemplateFolderViewItem (); + + virtual void calculateItemsPosition (); + + const Point& getPrev2Pos () const { return maPrev2Pos; } + + virtual void Paint (drawinglayer::processor2d::BaseProcessor2D *pProcessor, + const ThumbnailItemAttributes *pAttrs); +private: + + Point maPrev2Pos; +}; + +#endif // TEMPLATEFOLDERVIEWITEM_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sfx2/inc/sfx2/thumbnailviewitem.hxx b/sfx2/inc/sfx2/thumbnailviewitem.hxx index 16652ed..0d9fbd4 100644 --- a/sfx2/inc/sfx2/thumbnailviewitem.hxx +++ b/sfx2/inc/sfx2/thumbnailviewitem.hxx @@ -65,7 +65,6 @@ struct ThumbnailViewItem bool mbSelected; bool mbHover; BitmapEx maPreview1; - BitmapEx maPreview2; rtl::OUString maText; ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >* mpxAcc; @@ -92,33 +91,30 @@ struct ThumbnailViewItem const Rectangle& getDrawArea () const { return maDrawArea; } - void calculateItemsPosition (); + virtual void calculateItemsPosition (); const Point& getTextPos () const { return maTextPos; } const Point& getPrev1Pos () const { return maPrev1Pos; } - const Point& getPrev2Pos () const { return maPrev2Pos; } - void setSelectionMode (bool mode); void setSelectClickHdl (const Link &link); bool isInsideTitle (const Point &pt) const; - void Paint (drawinglayer::processor2d::BaseProcessor2D *pProcessor, - const ThumbnailItemAttributes *pAttrs); + virtual void Paint (drawinglayer::processor2d::BaseProcessor2D *pProcessor, + const ThumbnailItemAttributes *pAttrs); private: DECL_LINK (OnClick, CheckBox *); -private: +protected: bool mbMode; Point maTextPos; Point maPrev1Pos; - Point maPrev2Pos; Rectangle maDrawArea; Link maClickHdl; CheckBox *mpSelectBox; diff --git a/sfx2/source/control/templatefolderview.cxx b/sfx2/source/control/templatefolderview.cxx index 800380e..26d757f 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 0000000..2486560 --- /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 76d3bb2..a23fcb2 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 >( ), commit 9b8a9a7d116ac06b7f8a402e17546460fcde641e Author: Rafael Dominguez <venccsra...@gmail.com> Date: Tue Jun 19 14:45:22 2012 -0430 Dont display item controls or execute any action while they are hidden. Change-Id: If43c7b3615f8f2deb8851c50b0514da2ee77044a diff --git a/sfx2/source/control/thumbnailview.cxx b/sfx2/source/control/thumbnailview.cxx index d6ae188..626828c 100644 --- a/sfx2/source/control/thumbnailview.cxx +++ b/sfx2/source/control/thumbnailview.cxx @@ -636,7 +636,7 @@ void ThumbnailView::MouseButtonDown( const MouseEvent& rMEvt ) { ThumbnailViewItem* pItem = ImplGetItem( ImplGetItem( rMEvt.GetPosPixel() ) ); - if (pItem) + if (pItem && pItem->isVisible()) { if ( !rMEvt.IsMod2() ) { @@ -684,7 +684,7 @@ void ThumbnailView::MouseMove( const MouseEvent& rMEvt ) if (pItem) { - if (mnHighItemId != pItem->mnId) + if (mnHighItemId != pItem->mnId && pItem->isVisible()) { size_t nPos = GetItemPos(mnHighItemId); diff --git a/sfx2/source/control/thumbnailviewitem.cxx b/sfx2/source/control/thumbnailviewitem.cxx index fde678c..76d3bb2 100644 --- a/sfx2/source/control/thumbnailviewitem.cxx +++ b/sfx2/source/control/thumbnailviewitem.cxx @@ -146,7 +146,7 @@ void ThumbnailViewItem::setSelectionMode (bool mode) { mbMode = mode; - if (!mbHover && !mbSelected) + if (!mbHover && !mbSelected && mbVisible) mpSelectBox->Show(mode); } commit d640ca4c9463fe24515426ab77cee93e2a003349 Author: Rafael Dominguez <venccsra...@gmail.com> Date: Tue Jun 19 14:36:33 2012 -0430 Implement filtering thumbnail items by a user defined function. - Created a default filter function to display all the items in the thumbnail. Change-Id: I5bd901d6c9a896a149241f7ad13207e774ba3e2f diff --git a/sfx2/inc/sfx2/thumbnailview.hxx b/sfx2/inc/sfx2/thumbnailview.hxx index 2f1e513..613a30e 100644 --- a/sfx2/inc/sfx2/thumbnailview.hxx +++ b/sfx2/inc/sfx2/thumbnailview.hxx @@ -13,6 +13,7 @@ #include "svtools/svtdllapi.h" #include <vector> +#include <boost/function.hpp> #include <vcl/ctrl.hxx> #include <vcl/timer.hxx> @@ -151,6 +152,17 @@ namespace drawinglayer { #define THUMBNAILVIEW_APPEND ((sal_uInt16)-1) #define THUMBNAILVIEW_ITEM_NOTFOUND ((sal_uInt16)-1) +// Display all the available items in the thumbnail. +class ViewFilterAll +{ +public: + + bool operator () (const ThumbnailViewItem*) const + { + return true; + } +}; + /** * * Class to display thumbnails with their names below their respective icons @@ -226,6 +238,8 @@ public: void setSelectionMode (bool mode); + void filterItems (const boost::function<bool (const ThumbnailViewItem*) > &func); + protected: virtual void MouseButtonDown( const MouseEvent& rMEvt ); @@ -326,6 +340,7 @@ protected: ThumbnailItemAttributes *mpItemAttrs; drawinglayer::processor2d::BaseProcessor2D *mpProcessor; + boost::function<bool (const ThumbnailViewItem*) > maFilterFunc; }; #endif // THUMBNAILVIEW_HXX diff --git a/sfx2/source/control/thumbnailview.cxx b/sfx2/source/control/thumbnailview.cxx index 3a82ca7..d6ae188 100644 --- a/sfx2/source/control/thumbnailview.cxx +++ b/sfx2/source/control/thumbnailview.cxx @@ -104,6 +104,7 @@ void ThumbnailView::ImplInit() mbScroll = false; mbHasVisibleItems = false; mbSelectionMode = false; + maFilterFunc = ViewFilterAll(); // Create the processor and process the primitives const drawinglayer::geometry::ViewInformation2D aNewViewInfos; @@ -340,8 +341,7 @@ void ThumbnailView::CalculateItemPositions () long y = nStartY; // draw items - sal_uLong nFirstItem = mnFirstLine * mnCols; - sal_uLong nLastItem = nFirstItem + (mnVisLines * mnCols); + size_t nTotalItems = mnFirstLine*mnCols + mnVisLines*mnCols; maItemListRect.Left() = x; maItemListRect.Top() = y + mnHeaderHeight; @@ -352,14 +352,15 @@ void ThumbnailView::CalculateItemPositions () // then we add one more line if parts of these line are // visible if ( y+(mnVisLines*(mnItemHeight+mnSpacing)) < aWinSize.Height() ) - nLastItem += mnCols; + nTotalItems += mnCols; maItemListRect.Bottom() = aWinSize.Height() - y; + size_t nCurCount = 0; for ( size_t i = 0; i < nItemCount; i++ ) { ThumbnailViewItem *const pItem = mItemList[i]; - if ( (i >= nFirstItem) && (i < nLastItem) ) + if (maFilterFunc(pItem) && nCurCount < nTotalItems) { if( !pItem->isVisible() && ImplHasAccessibleListeners() ) { @@ -380,6 +381,8 @@ void ThumbnailView::CalculateItemPositions () } else x += mnItemWidth+mnSpacing; + + ++nCurCount; } else { @@ -1402,6 +1405,15 @@ void ThumbnailView::setSelectionMode (bool mode) OnSelectionMode(mode); } +void ThumbnailView::filterItems (const boost::function<bool (const ThumbnailViewItem*) > &func) +{ + maFilterFunc = func; + + CalculateItemPositions(); + + Invalidate(); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ commit 590f39c6104ad62a043b9ccba305f595632a57c0 Author: Rafael Dominguez <venccsra...@gmail.com> Date: Tue Jun 19 13:04:10 2012 -0430 Remove unused functions and attributes in ThumbnailView. Change-Id: I2013303c8d7d569672d24fcd4702085af7bef438 diff --git a/sfx2/inc/sfx2/thumbnailview.hxx b/sfx2/inc/sfx2/thumbnailview.hxx index ebd4b51..2f1e513 100644 --- a/sfx2/inc/sfx2/thumbnailview.hxx +++ b/sfx2/inc/sfx2/thumbnailview.hxx @@ -218,10 +218,6 @@ public: bool IsColor() const { return maColor.GetTransparency() == 0; } - void StartSelection(); - - void EndSelection(); - Size CalcWindowSizePixel( const Size& rItemSize, sal_uInt16 nCalcCols = 0, sal_uInt16 nCalcLines = 0 ); @@ -306,7 +302,6 @@ protected: Timer maTimer; ValueItemList mItemList; ScrollBar* mpScrBar; - Rectangle maNoneItemRect; Rectangle maItemListRect; long mnHeaderHeight; long mnItemWidth; @@ -323,12 +318,6 @@ protected: sal_uInt16 mnUserVisLines; sal_uInt16 mnFirstLine; sal_uInt16 mnSpacing; - sal_uInt16 mnFrameStyle; - bool mbHighlight : 1; - bool mbSelection : 1; - bool mbDrawSelection : 1; - bool mbBlackSel : 1; - bool mbDoubleSel : 1; bool mbScroll : 1; bool mbIsTransientChildrenDisabled : 1; bool mbHasVisibleItems : 1; diff --git a/sfx2/source/control/thumbnailview.cxx b/sfx2/source/control/thumbnailview.cxx index 73c0abf..3a82ca7 100644 --- a/sfx2/source/control/thumbnailview.cxx +++ b/sfx2/source/control/thumbnailview.cxx @@ -101,12 +101,6 @@ void ThumbnailView::ImplInit() mnUserCols = 0; mnUserVisLines = 0; mnSpacing = 0; - mnFrameStyle = 0; - mbHighlight = false; - mbSelection = false; - mbDrawSelection = true; - mbBlackSel = false; - mbDoubleSel = false; mbScroll = false; mbHasVisibleItems = false; mbSelectionMode = false; @@ -337,25 +331,6 @@ void ThumbnailView::CalculateItemPositions () { mbHasVisibleItems = true; - // determine Frame-Style - mnFrameStyle = FRAME_DRAW_IN; - - // determine selected color and width - // if necessary change the colors, to make the selection - // better detectable - const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings(); - Color aHighColor( rStyleSettings.GetHighlightColor() ); - if ( ((aHighColor.GetRed() > 0x80) || (aHighColor.GetGreen() > 0x80) || - (aHighColor.GetBlue() > 0x80)) || - ((aHighColor.GetRed() == 0x80) && (aHighColor.GetGreen() == 0x80) && - (aHighColor.GetBlue() == 0x80)) ) - mbBlackSel = true; - else - mbBlackSel = false; - - // draw the selection with double width if the items are bigger - mbDoubleSel = false; - // calculate offsets long nStartX = 0; long nStartY = mnHeaderHeight; @@ -634,16 +609,10 @@ IMPL_LINK_NOARG(ThumbnailView, ImplTimerHdl) void ThumbnailView::ImplTracking( const Point& rPos, bool bRepeat ) { - if ( bRepeat || mbSelection ) + if ( bRepeat ) { if ( ImplScroll( rPos ) ) { - if ( mbSelection ) - { - maTimer.SetTimeoutHdl( LINK( this, ThumbnailView, ImplTimerHdl ) ); - maTimer.SetTimeout( GetSettings().GetMouseSettings().GetScrollRepeat() ); - maTimer.Start(); - } } } } @@ -873,7 +842,6 @@ void ThumbnailView::KeyInput( const KeyEvent& rKEvt ) // This point is reached only if key travelling was used, // in which case selection mode should be switched off - EndSelection(); if ( nItemPos != THUMBNAILVIEW_ITEM_NOTFOUND ) { @@ -1337,32 +1305,12 @@ void ThumbnailView::SetColor( const Color& rColor ) Invalidate(); } -void ThumbnailView::StartSelection() -{ - mbHighlight = true; - mbSelection = true; - mnHighItemId = mnSelItemId; -} - -void ThumbnailView::EndSelection() -{ - if ( mbHighlight ) - { - if ( IsTracking() ) - EndTracking( ENDTRACK_CANCEL ); - - mbHighlight = false; - } - mbSelection = false; -} - bool ThumbnailView::StartDrag( const CommandEvent& rCEvt, Region& rRegion ) { if ( rCEvt.GetCommand() != COMMAND_STARTDRAG ) return false; // if necessary abort an existing action - EndSelection(); // Check out if the the clicked on page is selected. If this is not the // case set it as the current item. We only check mouse actions since commit a3097516c9ea73137b83cbbdeb2328bdc0c067b0 Author: Rafael Dominguez <venccsra...@gmail.com> Date: Tue Jun 19 12:47:04 2012 -0430 Use SfxDocumentTemplates directly instead of SfxOrganizeMgr. - Make sure we delete first the folder overlay and then the SfxDocumentTemplates variable. Change-Id: I6c0edd320d8b83b1a1489eb7ff886b03e055212b diff --git a/sfx2/inc/sfx2/templatefolderview.hxx b/sfx2/inc/sfx2/templatefolderview.hxx index 8491ad6..84cd003 100644 --- a/sfx2/inc/sfx2/templatefolderview.hxx +++ b/sfx2/inc/sfx2/templatefolderview.hxx @@ -12,7 +12,7 @@ #include <sfx2/thumbnailview.hxx> -class SfxOrganizeMgr; +class SfxDocumentTemplates; class TemplateView; class TemplateFolderView : public ThumbnailView @@ -39,7 +39,7 @@ private: private: - SfxOrganizeMgr *mpMgr; + SfxDocumentTemplates *mpDocTemplates; TemplateView *mpItemView; }; diff --git a/sfx2/source/control/templatefolderview.cxx b/sfx2/source/control/templatefolderview.cxx index e825a3e..800380e 100644 --- a/sfx2/source/control/templatefolderview.cxx +++ b/sfx2/source/control/templatefolderview.cxx @@ -22,8 +22,6 @@ #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/lang/XSingleServiceFactory.hpp> -#include "orgmgr.hxx" - BitmapEx lcl_fetchThumbnail (const rtl::OUString &msURL, int width, int height) { using namespace ::com::sun::star; @@ -140,8 +138,8 @@ BitmapEx lcl_fetchThumbnail (const rtl::OUString &msURL, int width, int height) TemplateFolderView::TemplateFolderView ( Window* pParent, const ResId& rResId, bool bDisableTransientChildren) : ThumbnailView(pParent,rResId,bDisableTransientChildren), - mpMgr(new SfxOrganizeMgr(NULL,NULL)), - mpItemView(new TemplateView(this,(SfxDocumentTemplates*)mpMgr->GetTemplates())) + mpDocTemplates(new SfxDocumentTemplates), + mpItemView(new TemplateView(this,mpDocTemplates)) { mpItemView->SetColor(Color(COL_WHITE)); mpItemView->SetPosPixel(Point(0,0)); @@ -152,20 +150,18 @@ TemplateFolderView::TemplateFolderView ( Window* pParent, const ResId& rResId, b TemplateFolderView::~TemplateFolderView() { - delete mpMgr; delete mpItemView; + delete mpDocTemplates; } void TemplateFolderView::Populate () { - const SfxDocumentTemplates* pTemplates = mpMgr->GetTemplates(); - - sal_uInt16 nCount = pTemplates->GetRegionCount(); + sal_uInt16 nCount = mpDocTemplates->GetRegionCount(); for (sal_uInt16 i = 0; i < nCount; ++i) { - rtl::OUString aRegionName(pTemplates->GetFullRegionName(i)); + rtl::OUString aRegionName(mpDocTemplates->GetFullRegionName(i)); - sal_uInt16 nEntries = pTemplates->GetCount(i); + sal_uInt16 nEntries = mpDocTemplates->GetCount(i); if (nEntries) { @@ -175,10 +171,10 @@ void TemplateFolderView::Populate () pItem->setSelectClickHdl(LINK(this,ThumbnailView,OnFolderSelected)); /// Preview first 2 thumbnails for folder - pItem->maPreview1 = lcl_fetchThumbnail(pTemplates->GetPath(i,0),128,128); + pItem->maPreview1 = lcl_fetchThumbnail(mpDocTemplates->GetPath(i,0),128,128); if ( nEntries > 2 ) - pItem->maPreview2 = lcl_fetchThumbnail(pTemplates->GetPath(i,1),128,128); + pItem->maPreview2 = lcl_fetchThumbnail(mpDocTemplates->GetPath(i,1),128,128); mItemList.push_back(pItem); } @@ -221,15 +217,14 @@ void TemplateFolderView::OnItemDblClicked (ThumbnailViewItem *pRegionItem) { // Fill templates sal_uInt16 nRegionId = pRegionItem->mnId-1; - const SfxDocumentTemplates* pTemplates = mpMgr->GetTemplates(); mpItemView->setRegionId(nRegionId); - sal_uInt16 nEntries = pTemplates->GetCount(nRegionId); + sal_uInt16 nEntries = mpDocTemplates->GetCount(nRegionId); for (sal_uInt16 i = 0; i < nEntries; ++i) { - mpItemView->InsertItem(i+1,lcl_fetchThumbnail(pTemplates->GetPath(nRegionId,i),128,128), - pTemplates->GetName(nRegionId,i)); + mpItemView->InsertItem(i+1,lcl_fetchThumbnail(mpDocTemplates->GetPath(nRegionId,i),128,128), + mpDocTemplates->GetName(nRegionId,i)); } if (mbSelectionMode) commit 5d89e41a758a8f86c536c42d99eef28608bd5708 Author: Rafael Dominguez <venccsra...@gmail.com> Date: Tue Jun 19 12:30:47 2012 -0430 Close the folder overlay when clicking the close icon. Change-Id: I7ac53d7e9455a3d03008534f18ee7866777ecab7 diff --git a/sfx2/inc/sfx2/templateview.hxx b/sfx2/inc/sfx2/templateview.hxx index e9ea241..300a95f 100644 --- a/sfx2/inc/sfx2/templateview.hxx +++ b/sfx2/inc/sfx2/templateview.hxx @@ -29,6 +29,10 @@ public: virtual void Paint (const Rectangle &rRect); +protected: + + virtual void MouseButtonDown (const MouseEvent &rMEvt); + private: Image maCloseImg; diff --git a/sfx2/source/control/templateview.cxx b/sfx2/source/control/templateview.cxx index 63fec5d..8ef3be4 100644 --- a/sfx2/source/control/templateview.cxx +++ b/sfx2/source/control/templateview.cxx @@ -90,6 +90,29 @@ void TemplateView::Paint (const Rectangle &rRect) mpProcessor->process(aSeq); } +void TemplateView::MouseButtonDown (const MouseEvent &rMEvt) +{ + if (rMEvt.IsLeft()) + { + Size aWinSize = GetOutputSizePixel(); + Size aImageSize = maCloseImg.GetSizePixel(); + + Point aPos; + aPos.Y() = (mnHeaderHeight - aImageSize.Height())/2; + aPos.X() = aWinSize.Width() - aImageSize.Width() - aPos.Y(); + + Rectangle aImgRect(aPos,aImageSize); + + if (aImgRect.IsInside(rMEvt.GetPosPixel())) + { + Show(false); + Clear(); + } + } + + ThumbnailView::MouseButtonDown(rMEvt); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ commit c6aa6cf65bd6c8daa84c2b89cc19b489229543ec Author: Rafael Dominguez <venccsra...@gmail.com> Date: Tue Jun 19 12:16:08 2012 -0430 Remove unused function Rect2Polygon. Change-Id: Icb2fbf593006ba765a57c3cad145531c95f9e4ef diff --git a/sfx2/inc/sfx2/thumbnailviewitem.hxx b/sfx2/inc/sfx2/thumbnailviewitem.hxx index 81d4bdd..16652ed 100644 --- a/sfx2/inc/sfx2/thumbnailviewitem.hxx +++ b/sfx2/inc/sfx2/thumbnailviewitem.hxx @@ -124,9 +124,6 @@ private: CheckBox *mpSelectBox; }; -// Helper function to convert a rectangle to a polygon. -basegfx::B2DPolygon Rect2Polygon (const Rectangle &aRect); - #endif // THUMBNAILVIEWITEM_HXX /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sfx2/source/control/thumbnailviewitem.cxx b/sfx2/source/control/thumbnailviewitem.cxx index 1d09aa5..fde678c 100644 --- a/sfx2/source/control/thumbnailviewitem.cxx +++ b/sfx2/source/control/thumbnailviewitem.cxx @@ -242,17 +242,6 @@ IMPL_LINK (ThumbnailViewItem, OnClick, CheckBox*, ) return 0; } -basegfx::B2DPolygon Rect2Polygon (const Rectangle &aRect) -{ - basegfx::B2DPolygon aPolygon; - aPolygon.append(basegfx::B2DPoint(aRect.Left(),aRect.Top())); - aPolygon.append(basegfx::B2DPoint(aRect.Left(),aRect.Bottom())); - aPolygon.append(basegfx::B2DPoint(aRect.Right(),aRect.Bottom())); - aPolygon.append(basegfx::B2DPoint(aRect.Right(),aRect.Top())); - - return aPolygon; -} - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ commit 7048a2547b942d2217267bb17d934efa9efa2248 Author: Rafael Dominguez <venccsra...@gmail.com> Date: Tue Jun 19 12:14:33 2012 -0430 Draw thumbnail item background as a rectangle with rounded corners. Change-Id: Ieab135c6357820afe863a28e70dc72fa2dad6327 diff --git a/sfx2/source/control/thumbnailviewitem.cxx b/sfx2/source/control/thumbnailviewitem.cxx index b9f4ad0..1d09aa5 100644 --- a/sfx2/source/control/thumbnailviewitem.cxx +++ b/sfx2/source/control/thumbnailviewitem.cxx @@ -180,7 +180,7 @@ void ThumbnailViewItem::Paint (drawinglayer::processor2d::BaseProcessor2D *pProc aFillColor = pAttrs->aHighlightColor; aSeq[nCount++] = Primitive2DReference( new PolyPolygonColorPrimitive2D( - B2DPolyPolygon(Rect2Polygon(maDrawArea)), + B2DPolyPolygon(Polygon(maDrawArea,5,5).getB2DPolygon()), aFillColor)); // Draw thumbnail commit bb2d381661fe591f342703dc654c2fc6121a2d46 Author: Rafael Dominguez <venccsra...@gmail.com> Date: Tue Jun 19 12:11:43 2012 -0430 Paint thumbnail view area with fill color. Change-Id: I1a910b52e6b187a61dd171d33d74203947ddaa0c diff --git a/sfx2/source/control/thumbnailview.cxx b/sfx2/source/control/thumbnailview.cxx index ca4c99c..73c0abf 100644 --- a/sfx2/source/control/thumbnailview.cxx +++ b/sfx2/source/control/thumbnailview.cxx @@ -15,6 +15,7 @@ #include <basegfx/color/bcolortools.hxx> #include <basegfx/matrix/b2dhommatrixtools.hxx> #include <basegfx/range/b2drectangle.hxx> +#include <basegfx/polygon/b2dpolygon.hxx> #include <basegfx/vector/b2dsize.hxx> #include <basegfx/vector/b2dvector.hxx> #include <drawinglayer/attribute/fillbitmapattribute.hxx> @@ -903,7 +904,7 @@ void ThumbnailView::Command( const CommandEvent& rCEvt ) Control::Command( rCEvt ); } -void ThumbnailView::Paint( const Rectangle& ) +void ThumbnailView::Paint( const Rectangle &aRect) { Size aWinSize = GetOutputSizePixel(); size_t nItemCount = mItemList.size(); @@ -926,6 +927,14 @@ void ThumbnailView::Paint( const Rectangle& ) if ( y+(mnVisLines*(mnItemHeight+mnSpacing)) < aWinSize.Height() ) nLastItem += mnCols; + // Draw background + Primitive2DSequence aSeq(1); + aSeq[0] = Primitive2DReference( new PolyPolygonColorPrimitive2D( + B2DPolyPolygon(Polygon(aRect,5,5).getB2DPolygon()), + maColor.getBColor())); + + mpProcessor->process(aSeq); + for ( size_t i = 0; i < nItemCount; i++ ) { ThumbnailViewItem *const pItem = mItemList[i]; commit 20374eac8afbc583471fc8ad48c973c0f8c966db Author: Rafael Dominguez <venccsra...@gmail.com> Date: Tue Jun 19 11:46:46 2012 -0430 Load and draw close image for folder overlay. Change-Id: I5d603187f09a727616133c3c626507d080e889f6 diff --git a/sfx2/AllLangResTarget_sfx2.mk b/sfx2/AllLangResTarget_sfx2.mk index 4019fb2..418b710 100644 --- a/sfx2/AllLangResTarget_sfx2.mk +++ b/sfx2/AllLangResTarget_sfx2.mk @@ -57,6 +57,7 @@ $(eval $(call gb_SrsTarget_add_files,sfx/res,\ sfx2/source/appl/sfx.src \ sfx2/source/bastyp/bastyp.src \ sfx2/source/bastyp/fltfnc.src \ + sfx2/source/control/templateview.src \ sfx2/source/dialog/alienwarn.src \ sfx2/source/dialog/dialog.src \ sfx2/source/dialog/dinfdlg.src \ diff --git a/sfx2/inc/sfx2/templateview.hxx b/sfx2/inc/sfx2/templateview.hxx index a6fbeaa..e9ea241 100644 --- a/sfx2/inc/sfx2/templateview.hxx +++ b/sfx2/inc/sfx2/templateview.hxx @@ -11,6 +11,7 @@ #define TEMPLATEVIEW_HXX #include <sfx2/thumbnailview.hxx> +#include <vcl/image.hxx> class SfxDocumentTemplates; @@ -30,6 +31,7 @@ public: private: + Image maCloseImg; sal_uInt16 mnRegionId; rtl::OUString maFolderName; SfxDocumentTemplates *mpDocTemplates; diff --git a/sfx2/source/control/templateview.cxx b/sfx2/source/control/templateview.cxx index 48d778d..63fec5d 100644 --- a/sfx2/source/control/templateview.cxx +++ b/sfx2/source/control/templateview.cxx @@ -10,17 +10,27 @@ #include <sfx2/templateview.hxx> #include <basegfx/matrix/b2dhommatrixtools.hxx> +#include <basegfx/point/b2dpoint.hxx> +#include <basegfx/vector/b2dvector.hxx> +#include <drawinglayer/attribute/fillbitmapattribute.hxx> +#include <drawinglayer/primitive2d/fillbitmapprimitive2d.hxx> #include <drawinglayer/primitive2d/textlayoutdevice.hxx> #include <drawinglayer/primitive2d/textprimitive2d.hxx> #include <drawinglayer/processor2d/baseprocessor2d.hxx> #include <sfx2/doctempl.hxx> +#include <sfx2/sfxresid.hxx> #include <sfx2/thumbnailviewitem.hxx> +#include "templateview.hrc" + +using namespace basegfx; using namespace basegfx::tools; +using namespace drawinglayer::attribute; using namespace drawinglayer::primitive2d; TemplateView::TemplateView (Window *pParent, SfxDocumentTemplates *pTemplates) : ThumbnailView(pParent), + maCloseImg(SfxResId(IMG_TEMPLATE_VIEW_CLOSE)), mnRegionId(0), mpDocTemplates(pTemplates) { @@ -41,7 +51,7 @@ void TemplateView::Paint (const Rectangle &rRect) { ThumbnailView::Paint(rRect); - Primitive2DSequence aSeq(1); + Primitive2DSequence aSeq(2); TextLayouterDevice aTextDev; // Draw centered region name @@ -63,6 +73,20 @@ void TemplateView::Paint (const Rectangle &rRect) com::sun::star::lang::Locale(), Color(COL_BLACK).getBColor() ) ); + // Draw close icon + Size aImageSize = maCloseImg.GetSizePixel(); + + aPos.Y() = (mnHeaderHeight - aImageSize.Height())/2; + aPos.X() = aWinSize.Width() - aImageSize.Width() - aPos.Y(); + + aSeq[1] = Primitive2DReference( new FillBitmapPrimitive2D( + createTranslateB2DHomMatrix(aPos.X(),aPos.Y()), + FillBitmapAttribute(maCloseImg.GetBitmapEx(), + B2DPoint(0,0), + B2DVector(aImageSize.Width(),aImageSize.Height()), + false) + )); + mpProcessor->process(aSeq); } diff --git a/sfx2/source/control/templateview.hrc b/sfx2/source/control/templateview.hrc new file mode 100644 index 0000000..cc26a18 --- /dev/null +++ b/sfx2/source/control/templateview.hrc @@ -0,0 +1,9 @@ +/* + * 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/. + */ + +#define IMG_TEMPLATE_VIEW_CLOSE 1 diff --git a/sfx2/source/control/templateview.src b/sfx2/source/control/templateview.src new file mode 100644 index 0000000..8252ee9 --- /dev/null +++ b/sfx2/source/control/templateview.src @@ -0,0 +1,17 @@ +/* + * 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 "templateview.hrc" + +Image IMG_TEMPLATE_VIEW_CLOSE +{ + ImageBitmap = Bitmap + { + File = "closedoc.png"; + }; +}; commit d0854f964170cc10346c829f46903061a837dfa0 Author: Rafael Dominguez <venccsra...@gmail.com> Date: Tue Jun 19 09:59:29 2012 -0430 Draw region name when displaying a folder overlay. Change-Id: Id24c0ad799ba8af397e78830c636e4d647c14e7f diff --git a/sfx2/inc/sfx2/templateview.hxx b/sfx2/inc/sfx2/templateview.hxx index baf7e8b..a6fbeaa 100644 --- a/sfx2/inc/sfx2/templateview.hxx +++ b/sfx2/inc/sfx2/templateview.hxx @@ -26,6 +26,8 @@ public: sal_uInt16 getRegionId () const { return mnRegionId; } + virtual void Paint (const Rectangle &rRect); + private: sal_uInt16 mnRegionId; diff --git a/sfx2/source/control/templateview.cxx b/sfx2/source/control/templateview.cxx index e4541a4..48d778d 100644 --- a/sfx2/source/control/templateview.cxx +++ b/sfx2/source/control/templateview.cxx @@ -9,13 +9,22 @@ #include <sfx2/templateview.hxx> +#include <basegfx/matrix/b2dhommatrixtools.hxx> +#include <drawinglayer/primitive2d/textlayoutdevice.hxx> +#include <drawinglayer/primitive2d/textprimitive2d.hxx> +#include <drawinglayer/processor2d/baseprocessor2d.hxx> #include <sfx2/doctempl.hxx> +#include <sfx2/thumbnailviewitem.hxx> + +using namespace basegfx::tools; +using namespace drawinglayer::primitive2d; TemplateView::TemplateView (Window *pParent, SfxDocumentTemplates *pTemplates) : ThumbnailView(pParent), mnRegionId(0), mpDocTemplates(pTemplates) { + mnHeaderHeight = 30; } TemplateView::~TemplateView () @@ -28,6 +37,35 @@ void TemplateView::setRegionId (const sal_uInt16 nRegionId) maFolderName = mpDocTemplates->GetRegionName(nRegionId); } +void TemplateView::Paint (const Rectangle &rRect) +{ + ThumbnailView::Paint(rRect); + + Primitive2DSequence aSeq(1); + TextLayouterDevice aTextDev; + + // Draw centered region name + Point aPos; + Size aWinSize = GetOutputSizePixel(); + + aPos.X() = (aWinSize.getWidth() - aTextDev.getTextWidth(maFolderName,0,maFolderName.getLength()))/2; + aPos.Y() = aTextDev.getTextHeight() + (mnHeaderHeight - aTextDev.getTextHeight())/2; + + basegfx::B2DHomMatrix aTextMatrix( createScaleTranslateB2DHomMatrix( + mpItemAttrs->aFontSize.getX(), mpItemAttrs->aFontSize.getY(), + double( aPos.X() ), double( aPos.Y() ) ) ); + + aSeq[0] = Primitive2DReference( + new TextSimplePortionPrimitive2D(aTextMatrix, + maFolderName,0,maFolderName.getLength(), + std::vector< double >( ), + mpItemAttrs->aFontAttr, + com::sun::star::lang::Locale(), + Color(COL_BLACK).getBColor() ) ); + + mpProcessor->process(aSeq); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ commit cd5d366c78748cbe6551ccefa2fbfe619687ad5f Author: Rafael Dominguez <venccsra...@gmail.com> Date: Tue Jun 19 09:41:31 2012 -0430 Store region id in TemplateView and add set/get methods. Change-Id: I1300cbc0278368021276c220c2ec6e9ef8f16382 diff --git a/sfx2/inc/sfx2/templateview.hxx b/sfx2/inc/sfx2/templateview.hxx index 3fa1524..baf7e8b 100644 --- a/sfx2/inc/sfx2/templateview.hxx +++ b/sfx2/inc/sfx2/templateview.hxx @@ -22,9 +22,15 @@ public: virtual ~TemplateView (); + void setRegionId (const sal_uInt16 nRegionId); + + sal_uInt16 getRegionId () const { return mnRegionId; } + private: - SfxDocumentTemplates *mpDocTemplates; + sal_uInt16 mnRegionId; + rtl::OUString maFolderName; + SfxDocumentTemplates *mpDocTemplates; }; #endif // TEMPLATEVIEW_HXX diff --git a/sfx2/source/control/templatefolderview.cxx b/sfx2/source/control/templatefolderview.cxx index 92cff7c..e825a3e 100644 --- a/sfx2/source/control/templatefolderview.cxx +++ b/sfx2/source/control/templatefolderview.cxx @@ -223,6 +223,8 @@ void TemplateFolderView::OnItemDblClicked (ThumbnailViewItem *pRegionItem) sal_uInt16 nRegionId = pRegionItem->mnId-1; const SfxDocumentTemplates* pTemplates = mpMgr->GetTemplates(); + mpItemView->setRegionId(nRegionId); + sal_uInt16 nEntries = pTemplates->GetCount(nRegionId); for (sal_uInt16 i = 0; i < nEntries; ++i) { diff --git a/sfx2/source/control/templateview.cxx b/sfx2/source/control/templateview.cxx index 4e3282b..e4541a4 100644 --- a/sfx2/source/control/templateview.cxx +++ b/sfx2/source/control/templateview.cxx @@ -9,8 +9,11 @@ #include <sfx2/templateview.hxx> +#include <sfx2/doctempl.hxx> + TemplateView::TemplateView (Window *pParent, SfxDocumentTemplates *pTemplates) : ThumbnailView(pParent), + mnRegionId(0), mpDocTemplates(pTemplates) { } @@ -19,6 +22,12 @@ TemplateView::~TemplateView () { } +void TemplateView::setRegionId (const sal_uInt16 nRegionId) +{ + mnRegionId = nRegionId; + maFolderName = mpDocTemplates->GetRegionName(nRegionId); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ commit 05bee67cccee622deaec1bb6b090249b7933c56c Author: Rafael Dominguez <venccsra...@gmail.com> Date: Tue Jun 19 09:03:45 2012 -0430 Add a variable to reserve a header space if wanted. Change-Id: I1dce6c7120d50dc87b994980e8014b941fa100d8 diff --git a/sfx2/inc/sfx2/thumbnailview.hxx b/sfx2/inc/sfx2/thumbnailview.hxx index 502ffd8..ebd4b51 100644 --- a/sfx2/inc/sfx2/thumbnailview.hxx +++ b/sfx2/inc/sfx2/thumbnailview.hxx @@ -308,6 +308,7 @@ protected: ScrollBar* mpScrBar; Rectangle maNoneItemRect; Rectangle maItemListRect; + long mnHeaderHeight; long mnItemWidth; long mnItemHeight; long mnVisLines; diff --git a/sfx2/source/control/thumbnailview.cxx b/sfx2/source/control/thumbnailview.cxx index 23f40fc..ca4c99c 100644 --- a/sfx2/source/control/thumbnailview.cxx +++ b/sfx2/source/control/thumbnailview.cxx @@ -85,6 +85,7 @@ ThumbnailView::~ThumbnailView() void ThumbnailView::ImplInit() { mpScrBar = NULL; + mnHeaderHeight = 0; mnItemWidth = 0; mnItemHeight = 0; mnVisLines = 0; @@ -356,7 +357,7 @@ void ThumbnailView::CalculateItemPositions () // calculate offsets long nStartX = 0; - long nStartY = 0; + long nStartY = mnHeaderHeight; // calculate and draw items long x = nStartX; @@ -367,7 +368,7 @@ void ThumbnailView::CalculateItemPositions () sal_uLong nLastItem = nFirstItem + (mnVisLines * mnCols); maItemListRect.Left() = x; - maItemListRect.Top() = y; + maItemListRect.Top() = y + mnHeaderHeight; maItemListRect.Right() = x + mnCols*(mnItemWidth+mnSpacing) - mnSpacing - 1; maItemListRect.Bottom() = y + mnVisLines*(mnItemHeight+mnSpacing) - mnSpacing - 1; @@ -909,7 +910,7 @@ void ThumbnailView::Paint( const Rectangle& ) // calculate offsets long nStartX = 0; - long nStartY = 0; + long nStartY = mnHeaderHeight; // calculate and draw items long x = nStartX; commit ec13ac5594627d7e36ba984b6b6c267bbaa35aac Author: Rafael Dominguez <venccsra...@gmail.com> Date: Tue Jun 19 08:45:29 2012 -0430 Create a thumbnail view for template documents. Change-Id: I768a3c21fec15356678ece790e3fd05299c55f48 diff --git a/sfx2/Library_sfx.mk b/sfx2/Library_sfx.mk index 9fbcee3..872a107 100644 --- a/sfx2/Library_sfx.mk +++ b/sfx2/Library_sfx.mk @@ -148,6 +148,7 @@ $(eval $(call gb_Library_add_exception_objects,sfx,\ sfx2/source/control/shell \ sfx2/source/control/sorgitm \ sfx2/source/control/statcach \ + sfx2/source/control/templateview \ sfx2/source/control/templatefolderview \ sfx2/source/control/thumbnailviewitem \ sfx2/source/control/thumbnailviewacc \ diff --git a/sfx2/Package_inc.mk b/sfx2/Package_inc.mk index aef6ea4..c66ce44 100644 --- a/sfx2/Package_inc.mk +++ b/sfx2/Package_inc.mk @@ -127,6 +127,7 @@ $(eval $(call gb_Package_add_file,sfx2_inc,inc/sfx2/taskpane.hxx,sfx2/taskpane.h $(eval $(call gb_Package_add_file,sfx2_inc,inc/sfx2/tbxctrl.hxx,sfx2/tbxctrl.hxx)) $(eval $(call gb_Package_add_file,sfx2_inc,inc/sfx2/templdlg.hxx,sfx2/templdlg.hxx)) $(eval $(call gb_Package_add_file,sfx2_inc,inc/sfx2/templatelocnames.hrc,sfx2/templatelocnames.hrc)) +$(eval $(call gb_Package_add_file,sfx2_inc,inc/sfx2/templateview.hxx,sfx2/templateview.hxx)) $(eval $(call gb_Package_add_file,sfx2_inc,inc/sfx2/templatefolderview.hxx,sfx2/templatefolderview.hxx)) $(eval $(call gb_Package_add_file,sfx2_inc,inc/sfx2/thumbnailview.hxx,sfx2/thumbnailview.hxx)) $(eval $(call gb_Package_add_file,sfx2_inc,inc/sfx2/thumbnailviewitem.hxx,sfx2/thumbnailviewitem.hxx)) diff --git a/sfx2/inc/sfx2/templatefolderview.hxx b/sfx2/inc/sfx2/templatefolderview.hxx index 1ac4dcb..8491ad6 100644 --- a/sfx2/inc/sfx2/templatefolderview.hxx +++ b/sfx2/inc/sfx2/templatefolderview.hxx @@ -13,6 +13,7 @@ #include <sfx2/thumbnailview.hxx> class SfxOrganizeMgr; +class TemplateView; class TemplateFolderView : public ThumbnailView { @@ -39,7 +40,7 @@ private: private: SfxOrganizeMgr *mpMgr; - ThumbnailView *mpItemView; + TemplateView *mpItemView; }; #endif // TEMPLATEFOLDERVIEW_HXX diff --git a/sfx2/inc/sfx2/templateview.hxx b/sfx2/inc/sfx2/templateview.hxx new file mode 100644 index 0000000..3fa1524 --- /dev/null +++ b/sfx2/inc/sfx2/templateview.hxx @@ -0,0 +1,33 @@ +/* -*- 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/. + */ + +#ifndef TEMPLATEVIEW_HXX +#define TEMPLATEVIEW_HXX + +#include <sfx2/thumbnailview.hxx> + +class SfxDocumentTemplates; + +class TemplateView : public ThumbnailView +{ +public: + + TemplateView (Window *pParent, SfxDocumentTemplates *pTemplates); + + virtual ~TemplateView (); + +private: + + SfxDocumentTemplates *mpDocTemplates; +}; + +#endif // TEMPLATEVIEW_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ + diff --git a/sfx2/source/control/templatefolderview.cxx b/sfx2/source/control/templatefolderview.cxx index 8a254e2..92cff7c 100644 --- a/sfx2/source/control/templatefolderview.cxx +++ b/sfx2/source/control/templatefolderview.cxx @@ -11,6 +11,7 @@ #include <comphelper/processfactory.hxx> #include <sfx2/doctempl.hxx> +#include <sfx2/templateview.hxx> #include <sfx2/thumbnailviewitem.hxx> #include <unotools/ucbstreamhelper.hxx> #include <vcl/pngread.hxx> @@ -140,7 +141,7 @@ BitmapEx lcl_fetchThumbnail (const rtl::OUString &msURL, int width, int height) TemplateFolderView::TemplateFolderView ( Window* pParent, const ResId& rResId, bool bDisableTransientChildren) : ThumbnailView(pParent,rResId,bDisableTransientChildren), mpMgr(new SfxOrganizeMgr(NULL,NULL)), - mpItemView(new ThumbnailView(this,WB_VSCROLL)) + mpItemView(new TemplateView(this,(SfxDocumentTemplates*)mpMgr->GetTemplates())) { mpItemView->SetColor(Color(COL_WHITE)); mpItemView->SetPosPixel(Point(0,0)); diff --git a/sfx2/source/control/templateview.cxx b/sfx2/source/control/templateview.cxx new file mode 100644 index 0000000..4e3282b --- /dev/null +++ b/sfx2/source/control/templateview.cxx @@ -0,0 +1,24 @@ +/* -*- 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/templateview.hxx> + +TemplateView::TemplateView (Window *pParent, SfxDocumentTemplates *pTemplates) + : ThumbnailView(pParent), + mpDocTemplates(pTemplates) +{ +} + +TemplateView::~TemplateView () +{ +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ + + commit 4c270c4da4135012aa2712cc8b0a17595a1c97be Author: Rafael Dominguez <venccsra...@gmail.com> Date: Tue Jun 19 00:00:54 2012 -0430 Set the selection mode to the overlay if its visible. Change-Id: I2d0badc0cb0f4ea3e05f22e4b1ed4759ab7a4d85 diff --git a/sfx2/inc/sfx2/templatefolderview.hxx b/sfx2/inc/sfx2/templatefolderview.hxx index b5b967f..1ac4dcb 100644 --- a/sfx2/inc/sfx2/templatefolderview.hxx +++ b/sfx2/inc/sfx2/templatefolderview.hxx @@ -32,6 +32,8 @@ public: private: + virtual void OnSelectionMode (bool bMode); + virtual void OnItemDblClicked (ThumbnailViewItem *pRegionItem); private: diff --git a/sfx2/source/control/templatefolderview.cxx b/sfx2/source/control/templatefolderview.cxx index c2165f5..8a254e2 100644 --- a/sfx2/source/control/templatefolderview.cxx +++ b/sfx2/source/control/templatefolderview.cxx @@ -203,6 +203,19 @@ void TemplateFolderView::showOverlay (bool bVisible) mpItemView->Clear(); } +void TemplateFolderView::OnSelectionMode (bool bMode) +{ + if (mpItemView->IsVisible()) + { + mpItemView->setSelectionMode(bMode); + + for (size_t i = 0, n = mItemList.size(); i < n; ++i) + mItemList[i]->setSelectionMode(bMode); + } + else + ThumbnailView::OnSelectionMode(bMode); +} + void TemplateFolderView::OnItemDblClicked (ThumbnailViewItem *pRegionItem) { // Fill templates @@ -216,6 +229,9 @@ void TemplateFolderView::OnItemDblClicked (ThumbnailViewItem *pRegionItem) pTemplates->GetName(nRegionId,i)); } + if (mbSelectionMode) + mpItemView->setSelectionMode(true); + mpItemView->Show(); } commit fde2c0e1a5bb4d009513424a82662e3f64e0db56 Author: Rafael Dominguez <venccsra...@gmail.com> Date: Mon Jun 18 23:55:44 2012 -0430 Add a handler when changing selection mode and default action. Change-Id: I276665497d3b026d438a379ce0ad2683431055ae diff --git a/sfx2/inc/sfx2/thumbnailview.hxx b/sfx2/inc/sfx2/thumbnailview.hxx index a1db106..502ffd8 100644 --- a/sfx2/inc/sfx2/thumbnailview.hxx +++ b/sfx2/inc/sfx2/thumbnailview.hxx @@ -266,6 +266,8 @@ protected: virtual void DrawItem (ThumbnailViewItem *pItem); + virtual void OnSelectionMode (bool bMode); + virtual void OnItemDblClicked (ThumbnailViewItem *pItem); protected: diff --git a/sfx2/source/control/thumbnailview.cxx b/sfx2/source/control/thumbnailview.cxx index e9d3e27..23f40fc 100644 --- a/sfx2/source/control/thumbnailview.cxx +++ b/sfx2/source/control/thumbnailview.cxx @@ -203,6 +203,17 @@ void ThumbnailView::DrawItem (ThumbnailViewItem *pItem) pItem->Paint(mpProcessor,mpItemAttrs); } +void ThumbnailView::OnSelectionMode (bool bMode) +{ + for (size_t i = 0, n = mItemList.size(); i < n; ++i) + { + mItemList[i]->setSelectionMode(bMode); + + if (mItemList[i]->isVisible()) + DrawItem(mItemList[i]); + } +} + void ThumbnailView::OnItemDblClicked (ThumbnailViewItem*) { } @@ -1430,13 +1441,7 @@ void ThumbnailView::setSelectionMode (bool mode) { mbSelectionMode = mode; - for (size_t i = 0, n = mItemList.size(); i < n; ++i) - { - mItemList[i]->setSelectionMode(mode); - - if (mItemList[i]->isVisible()) - DrawItem(mItemList[i]); - } + OnSelectionMode(mode); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits