sfx2/inc/sfx2/thumbnailview.hxx | 27 +-------- sfx2/inc/sfx2/thumbnailviewitem.hxx | 26 ++++++++- sfx2/inc/templatedlg.hxx | 5 + sfx2/source/control/thumbnailview.cxx | 86 +++++++++++++----------------- sfx2/source/control/thumbnailviewacc.cxx | 4 - sfx2/source/control/thumbnailviewitem.cxx | 46 +++++++++++++++- sfx2/source/doc/templatedlg.cxx | 10 +++ sfx2/source/doc/templatedlg.hrc | 3 - sfx2/source/doc/templatedlg.src | 12 ++++ 9 files changed, 143 insertions(+), 76 deletions(-)
New commits: commit 7fdb04011c1cc4c078af6b20dadd88bfa09ed3e0 Author: Rafael Dominguez <[email protected]> Date: Sat Jun 16 17:40:04 2012 -0430 Redraw item if we (un)select an item when clicking the selection box. Change-Id: Ide3c116500e315db7280ad25029ae68180036618 diff --git a/sfx2/inc/sfx2/thumbnailview.hxx b/sfx2/inc/sfx2/thumbnailview.hxx index 356f0e4..8b32122 100644 --- a/sfx2/inc/sfx2/thumbnailview.hxx +++ b/sfx2/inc/sfx2/thumbnailview.hxx @@ -295,6 +295,8 @@ private: DECL_DLLPRIVATE_LINK( ImplScrollHdl, ScrollBar* ); DECL_DLLPRIVATE_LINK( ImplTimerHdl, void* ); + DECL_LINK(OnFolderSelected, ThumbnailViewItem*); + protected: Timer maTimer; diff --git a/sfx2/inc/sfx2/thumbnailviewitem.hxx b/sfx2/inc/sfx2/thumbnailviewitem.hxx index f122ec5..30eb42e 100644 --- a/sfx2/inc/sfx2/thumbnailviewitem.hxx +++ b/sfx2/inc/sfx2/thumbnailviewitem.hxx @@ -69,12 +69,15 @@ struct ThumbnailViewItem void setSelectionBoxPos (const Point &pos); + void setSelectClickHdl (const Link &link); + private: DECL_LINK (OnClick, CheckBox *); private: + Link maClickHdl; CheckBox *mpSelectBox; }; diff --git a/sfx2/source/control/thumbnailview.cxx b/sfx2/source/control/thumbnailview.cxx index 33578a1..05386f3 100644 --- a/sfx2/source/control/thumbnailview.cxx +++ b/sfx2/source/control/thumbnailview.cxx @@ -587,6 +587,12 @@ void ThumbnailView::ImplEndTracking( const Point& rPos, bool bCancel ) { } +IMPL_LINK (ThumbnailView, OnFolderSelected, ThumbnailViewItem*, pItem) +{ + DrawItem(pItem,GetItemRect(pItem->mnId)); + return 0; +} + void ThumbnailView::MouseButtonDown( const MouseEvent& rMEvt ) { if ( rMEvt.IsLeft() ) @@ -1156,6 +1162,7 @@ void ThumbnailView::Populate () ThumbnailViewItem* pItem = new ThumbnailViewItem( *this, this ); pItem->mnId = i+1; pItem->maText = aRegionName; + pItem->setSelectClickHdl(LINK(this,ThumbnailView,OnFolderSelected)); /// Preview first 2 thumbnails for folder pItem->maPreview1 = lcl_fetchThumbnail(pTemplates->GetPath(i,0),128,128); @@ -1178,6 +1185,7 @@ void ThumbnailView::InsertItem( sal_uInt16 nItemId, const BitmapEx& rImage, pItem->mnId = nItemId; pItem->maPreview1 = rImage; pItem->maText = rText; + pItem->setSelectClickHdl(LINK(this,ThumbnailView,OnFolderSelected)); ImplInsertItem( pItem, nPos ); } diff --git a/sfx2/source/control/thumbnailviewitem.cxx b/sfx2/source/control/thumbnailviewitem.cxx index 4a6ad84..bb47118 100644 --- a/sfx2/source/control/thumbnailviewitem.cxx +++ b/sfx2/source/control/thumbnailviewitem.cxx @@ -89,9 +89,16 @@ void ThumbnailViewItem::setSelectionBoxPos (const Point &pos) mpSelectBox->SetPosPixel(pos); } +void ThumbnailViewItem::setSelectClickHdl (const Link &link) +{ + maClickHdl = link; +} + IMPL_LINK (ThumbnailViewItem, OnClick, CheckBox*, ) { mbSelected = mpSelectBox->GetState() == STATE_CHECK; + mpSelectBox->Invalidate(); + maClickHdl.Call(this); return 0; } commit 71702696eba6053f37798c33e608bdd97bdf116d Author: Rafael Dominguez <[email protected]> Date: Sat Jun 16 12:33:34 2012 -0430 Add button to activate/deactivate template view selection mode. Change-Id: Ib58503e30d589eb5c02a29c1fec4be3a8011ba31 diff --git a/sfx2/inc/templatedlg.hxx b/sfx2/inc/templatedlg.hxx index b1b7598..d475ef8 100644 --- a/sfx2/inc/templatedlg.hxx +++ b/sfx2/inc/templatedlg.hxx @@ -31,11 +31,16 @@ public: private: + DECL_LINK(OnClickSelectionMode, ImageButton*); + +private: + PushButton aButtonAll; PushButton aButtonDocs; PushButton aButtonPresents; PushButton aButtonSheets; PushButton aButtonDraws; + ImageButton maButtonSelMode; ThumbnailView *maView; }; diff --git a/sfx2/source/doc/templatedlg.cxx b/sfx2/source/doc/templatedlg.cxx index b9a2918..48600d5 100644 --- a/sfx2/source/doc/templatedlg.cxx +++ b/sfx2/source/doc/templatedlg.cxx @@ -25,14 +25,18 @@ SfxTemplateManagerDlg::SfxTemplateManagerDlg (Window *parent) aButtonPresents(this,SfxResId(BTN_SELECT_PRESENTATIONS)), aButtonSheets(this,SfxResId(BTN_SELECT_SHEETS)), aButtonDraws(this,SfxResId(BTN_SELECT_DRAWS)), + maButtonSelMode(this,SfxResId(BTN_SELECTION_MODE)), maView(new ThumbnailView(this,SfxResId(TEMPLATE_VIEW))) { + maButtonSelMode.SetStyle(maButtonSelMode.GetStyle() | WB_TOGGLE); + maView->SetStyle(WB_TABSTOP | WB_VSCROLL); maView->SetColCount(MAX_COLUMN_COUNT); maView->SetLineCount(MAX_LINE_COUNT); aButtonAll.SetClickHdl(LINK(this,SfxTemplateManagerDlg,ViewAllHdl)); aButtonDocs.SetClickHdl(LINK(this,SfxTemplateManagerDlg,ViewDocsHdl)); + maButtonSelMode.SetClickHdl(LINK(this,SfxTemplateManagerDlg,OnClickSelectionMode)); maView->Populate(); maView->Show(); @@ -65,4 +69,10 @@ IMPL_LINK_NOARG(SfxTemplateManagerDlg,ViewDrawsHdl) return 0; } +IMPL_LINK (SfxTemplateManagerDlg, OnClickSelectionMode, ImageButton*, pButton) +{ + maView->setSelectionMode(pButton->GetState() == STATE_CHECK); + return 0; +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sfx2/source/doc/templatedlg.hrc b/sfx2/source/doc/templatedlg.hrc index cd48687..d596a41 100644 --- a/sfx2/source/doc/templatedlg.hrc +++ b/sfx2/source/doc/templatedlg.hrc @@ -11,7 +11,8 @@ #define BTN_SELECT_PRESENTATIONS 3 #define BTN_SELECT_SHEETS 4 #define BTN_SELECT_DRAWS 5 +#define BTN_SELECTION_MODE 6 -#define TEMPLATE_VIEW 6 +#define TEMPLATE_VIEW 7 #define IMG_ONLINE_REPOSITORY 100 diff --git a/sfx2/source/doc/templatedlg.src b/sfx2/source/doc/templatedlg.src index 1fb3e73..fa23895 100644 --- a/sfx2/source/doc/templatedlg.src +++ b/sfx2/source/doc/templatedlg.src @@ -62,6 +62,18 @@ ModalDialog DLG_TEMPLATE_MANAGER Text [en-US] = "Drawings"; }; + ImageButton BTN_SELECTION_MODE + { + Pos = MAP_APPFONT(265,5); + Size = MAP_APPFONT(14,14); + TabStop = TRUE; + + ButtonImage = Image + { + ImageBitmap = Bitmap { File = "signet.png" ; }; + }; + }; + Control TEMPLATE_VIEW { Pos = MAP_APPFONT(5,30); commit e3200a761e896ccdb1a052f1a9911f3674844f91 Author: Rafael Dominguez <[email protected]> Date: Sat Jun 16 10:53:10 2012 -0430 Add support for selection modes. While selection mode is disabled, to select a template using a mouse, click within the checkbox that appears on hover. Clicking the checkbox of another template causes it to be added to the selection. To unselect a template, click its checkbox again. Alternatively, under selection mode, the user can simply click a template's thumbnail or title to select it. Change-Id: I456936fb713dd43200d9b468a0fb8d82944625d4 diff --git a/sfx2/inc/sfx2/thumbnailview.hxx b/sfx2/inc/sfx2/thumbnailview.hxx index 266d42d..356f0e4 100644 --- a/sfx2/inc/sfx2/thumbnailview.hxx +++ b/sfx2/inc/sfx2/thumbnailview.hxx @@ -229,6 +229,8 @@ public: long GetScrollWidth() const; + void setSelectionMode (bool mode); + protected: virtual void MouseButtonDown( const MouseEvent& rMEvt ); @@ -324,6 +326,7 @@ protected: bool mbScroll : 1; bool mbIsTransientChildrenDisabled : 1; bool mbHasVisibleItems : 1; + bool mbSelectionMode; Color maColor; }; diff --git a/sfx2/source/control/thumbnailview.cxx b/sfx2/source/control/thumbnailview.cxx index dea3d42..33578a1 100644 --- a/sfx2/source/control/thumbnailview.cxx +++ b/sfx2/source/control/thumbnailview.cxx @@ -244,6 +244,7 @@ void ThumbnailView::ImplInit() mbDoubleSel = false; mbScroll = false; mbHasVisibleItems = false; + mbSelectionMode = false; ImplInitSettings( true, true, true ); } @@ -598,12 +599,17 @@ void ThumbnailView::MouseButtonDown( const MouseEvent& rMEvt ) { if ( rMEvt.GetClicks() == 1 ) { - pItem->setSelection(!pItem->isSelected()); - - if (!pItem->isHighlighted()) - DrawItem(pItem,GetItemRect(pItem->mnId)); + if (mbSelectionMode) + { + pItem->setSelection(!pItem->isSelected()); - //StartTracking( STARTTRACK_SCROLLREPEAT ); + if (!pItem->isHighlighted()) + DrawItem(pItem,GetItemRect(pItem->mnId)); + } + else + { + //StartTracking( STARTTRACK_SCROLLREPEAT ); + } } else if ( rMEvt.GetClicks() == 2 ) ; @@ -1601,6 +1607,11 @@ long ThumbnailView::GetScrollWidth() const return 0; } +void ThumbnailView::setSelectionMode (bool mode) +{ + mbSelectionMode = mode; +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ commit c473daadabc57200a68fe6a4ebd430250be7e217 Author: Rafael Dominguez <[email protected]> Date: Sat Jun 16 10:25:52 2012 -0430 Remove NoSelection related functions and attributes. Change-Id: Ieab1bd81986663e0ff6f2074b59b863ebe9be4a8 diff --git a/sfx2/inc/sfx2/thumbnailview.hxx b/sfx2/inc/sfx2/thumbnailview.hxx index 31e664c..266d42d 100644 --- a/sfx2/inc/sfx2/thumbnailview.hxx +++ b/sfx2/inc/sfx2/thumbnailview.hxx @@ -205,11 +205,7 @@ public: sal_uInt16 GetSelectItemId() const { return mnSelItemId; } bool IsItemSelected( sal_uInt16 nItemId ) const - { return !mbNoSelection && (nItemId == mnSelItemId); } - - void SetNoSelection(); - - bool IsNoSelection() const { return mbNoSelection; } + { return nItemId == mnSelItemId; } void SetItemText( sal_uInt16 nItemId, const rtl::OUString &rStr ); @@ -322,7 +318,6 @@ protected: sal_uInt16 mnFrameStyle; bool mbHighlight : 1; bool mbSelection : 1; - bool mbNoSelection : 1; bool mbDrawSelection : 1; bool mbBlackSel : 1; bool mbDoubleSel : 1; diff --git a/sfx2/source/control/thumbnailview.cxx b/sfx2/source/control/thumbnailview.cxx index 5d1f3cc..dea3d42 100644 --- a/sfx2/source/control/thumbnailview.cxx +++ b/sfx2/source/control/thumbnailview.cxx @@ -239,7 +239,6 @@ void ThumbnailView::ImplInit() mnFrameStyle = 0; mbHighlight = false; mbSelection = false; - mbNoSelection = true; mbDrawSelection = true; mbBlackSel = false; mbDoubleSel = false; @@ -1233,7 +1232,6 @@ void ThumbnailView::RemoveItem( sal_uInt16 nItemId ) mnCurCol = 0; mnHighItemId = 0; mnSelItemId = 0; - mbNoSelection = true; } if ( IsReallyVisible() && IsUpdateMode() ) @@ -1249,7 +1247,6 @@ void ThumbnailView::Clear() mnCurCol = 0; mnHighItemId = 0; mnSelItemId = 0; - mbNoSelection = true; if ( IsReallyVisible() && IsUpdateMode() ) Invalidate(); @@ -1345,11 +1342,10 @@ void ThumbnailView::SelectItem( sal_uInt16 nItemId ) return; } - if ( (mnSelItemId != nItemId) || mbNoSelection ) + if ( mnSelItemId != nItemId) { sal_uInt16 nOldItem = mnSelItemId ? mnSelItemId : 1; mnSelItemId = nItemId; - mbNoSelection = false; bool bNewOut = IsReallyVisible() && IsUpdateMode(); bool bNewLine = false; @@ -1440,16 +1436,6 @@ void ThumbnailView::SelectItem( sal_uInt16 nItemId ) } } -void ThumbnailView::SetNoSelection() -{ - mbNoSelection = true; - mbHighlight = false; - mbSelection = false; - - if ( IsReallyVisible() && IsUpdateMode() ) - Invalidate(); -} - void ThumbnailView::SetItemText( sal_uInt16 nItemId, const rtl::OUString& rText ) { size_t nPos = GetItemPos( nItemId ); diff --git a/sfx2/source/control/thumbnailviewacc.cxx b/sfx2/source/control/thumbnailviewacc.cxx index e738a54..8534b5e 100644 --- a/sfx2/source/control/thumbnailviewacc.cxx +++ b/sfx2/source/control/thumbnailviewacc.cxx @@ -491,7 +491,6 @@ void SAL_CALL ThumbnailViewAcc::clearAccessibleSelection() { ThrowIfDisposed(); const SolarMutexGuard aSolarGuard; - mpParent->SetNoSelection(); } void SAL_CALL ThumbnailViewAcc::selectAllAccessibleChildren() @@ -545,7 +544,7 @@ void SAL_CALL ThumbnailViewAcc::deselectAccessibleChild( sal_Int32 nChildIndex ) // Because of the single selection we can reset the whole selection when // the specified child is currently selected. if (isAccessibleChildSelected(nChildIndex)) - mpParent->SetNoSelection(); + ; } sal_Int64 SAL_CALL ThumbnailViewAcc::getSomething( const uno::Sequence< sal_Int8 >& rId ) throw( uno::RuntimeException ) commit c0e293eb466e11e6be09b73e36f417bf4fe669ab Author: Rafael Dominguez <[email protected]> Date: Sat Jun 16 10:20:15 2012 -0430 Remove doubleclick, highlight and select handlers. Change-Id: I6eef0d9eb4bfe3dc0e1cd9b212f3be4c286f017f diff --git a/sfx2/inc/sfx2/thumbnailview.hxx b/sfx2/inc/sfx2/thumbnailview.hxx index bd8b3c0..31e664c 100644 --- a/sfx2/inc/sfx2/thumbnailview.hxx +++ b/sfx2/inc/sfx2/thumbnailview.hxx @@ -161,10 +161,6 @@ public: virtual ~ThumbnailView (); - virtual void Select(); - - virtual void DoubleClick(); - // Fill view with template thumbnails void Populate (); @@ -237,16 +233,6 @@ public: long GetScrollWidth() const; - void SetSelectHdl( const Link& rLink ) { maSelectHdl = rLink; } - - const Link& GetSelectHdl() const { return maSelectHdl; } - - void SetDoubleClickHdl( const Link& rLink ) { maDoubleClickHdl = rLink; } - - const Link& GetDoubleClickHdl() const { return maDoubleClickHdl; } - - void SetHighlightHdl( const Link& rLink ); - protected: virtual void MouseButtonDown( const MouseEvent& rMEvt ); @@ -344,9 +330,6 @@ protected: bool mbIsTransientChildrenDisabled : 1; bool mbHasVisibleItems : 1; Color maColor; - Link maDoubleClickHdl; - Link maSelectHdl; - Link maHighlightHdl; }; #endif // THUMBNAILVIEW_HXX diff --git a/sfx2/source/control/thumbnailview.cxx b/sfx2/source/control/thumbnailview.cxx index 88a807f..5d1f3cc 100644 --- a/sfx2/source/control/thumbnailview.cxx +++ b/sfx2/source/control/thumbnailview.cxx @@ -607,7 +607,7 @@ void ThumbnailView::MouseButtonDown( const MouseEvent& rMEvt ) //StartTracking( STARTTRACK_SCROLLREPEAT ); } else if ( rMEvt.GetClicks() == 2 ) - DoubleClick(); + ; } return; @@ -803,7 +803,6 @@ void ThumbnailView::KeyInput( const KeyEvent& rKEvt ) if ( nItemId != mnSelItemId ) { SelectItem( nItemId ); - Select(); } } } @@ -1136,16 +1135,6 @@ void ThumbnailView::DataChanged( const DataChangedEvent& rDCEvt ) } } -void ThumbnailView::Select() -{ - maSelectHdl.Call( this ); -} - -void ThumbnailView::DoubleClick() -{ - maDoubleClickHdl.Call( this ); -} - void ThumbnailView::Populate () { const SfxDocumentTemplates* pTemplates = mpMgr->GetTemplates(); @@ -1448,7 +1437,6 @@ void ThumbnailView::SelectItem( sal_uInt16 nItemId ) ::com::sun::star::uno::Any aOldAny, aNewAny; ImplFireAccessibleEvent( ::com::sun::star::accessibility::AccessibleEventId::SELECTION_CHANGED, aOldAny, aNewAny ); } - maHighlightHdl.Call(this); } } @@ -1563,7 +1551,6 @@ bool ThumbnailView::StartDrag( const CommandEvent& rCEvt, Region& rRegion ) { SelectItem( nSelId ); Update(); - Select(); } Region aRegion; @@ -1628,11 +1615,6 @@ long ThumbnailView::GetScrollWidth() const return 0; } -void ThumbnailView::SetHighlightHdl( const Link& rLink ) -{ - maHighlightHdl = rLink; -} - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sfx2/source/control/thumbnailviewacc.cxx b/sfx2/source/control/thumbnailviewacc.cxx index cb03405..e738a54 100644 --- a/sfx2/source/control/thumbnailviewacc.cxx +++ b/sfx2/source/control/thumbnailviewacc.cxx @@ -465,7 +465,6 @@ void SAL_CALL ThumbnailViewAcc::selectAccessibleChild( sal_Int32 nChildIndex ) if(pItem != NULL) { mpParent->SelectItem( pItem->mnId ); - mpParent->Select (); } else throw lang::IndexOutOfBoundsException(); commit 410828289f2bffa9cd9cc8d35ca426d815d79382 Author: Rafael Dominguez <[email protected]> Date: Sat Jun 16 09:28:25 2012 -0430 Sync item state when clicking directly on the checkbox. Change-Id: I35e3ff973fe3a48bc9c0ffd105d22b40d660af7a diff --git a/sfx2/inc/sfx2/thumbnailviewitem.hxx b/sfx2/inc/sfx2/thumbnailviewitem.hxx index 625e5c4..f122ec5 100644 --- a/sfx2/inc/sfx2/thumbnailviewitem.hxx +++ b/sfx2/inc/sfx2/thumbnailviewitem.hxx @@ -71,6 +71,10 @@ struct ThumbnailViewItem private: + DECL_LINK (OnClick, CheckBox *); + +private: + CheckBox *mpSelectBox; }; diff --git a/sfx2/source/control/thumbnailviewitem.cxx b/sfx2/source/control/thumbnailviewitem.cxx index cd9ec8e..4a6ad84 100644 --- a/sfx2/source/control/thumbnailviewitem.cxx +++ b/sfx2/source/control/thumbnailviewitem.cxx @@ -41,10 +41,11 @@ ThumbnailViewItem::ThumbnailViewItem(ThumbnailView &rView, Window *pParent) , mbSelected(false) , mbHover(false) , mpxAcc(NULL) - , mpSelectBox(new CheckBox(pParent,WB_HIDE)) + , mpSelectBox(new CheckBox(pParent,WB_HIDE | WB_NOPOINTERFOCUS)) { mpSelectBox->SetPosPixel(Point(0,0)); mpSelectBox->SetSizePixel(Size(20,20)); + mpSelectBox->SetClickHdl(LINK(this,ThumbnailViewItem,OnClick)); } ThumbnailViewItem::~ThumbnailViewItem() @@ -88,6 +89,12 @@ void ThumbnailViewItem::setSelectionBoxPos (const Point &pos) mpSelectBox->SetPosPixel(pos); } +IMPL_LINK (ThumbnailViewItem, OnClick, CheckBox*, ) +{ + mbSelected = mpSelectBox->GetState() == STATE_CHECK; + return 0; +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ commit 05c74f9e6aada15f398c666dd7d5ede3fa23288b Author: Rafael Dominguez <[email protected]> Date: Sat Jun 16 08:14:42 2012 -0430 Add a checkbox to display selected items. Change-Id: I2072efabdbd45ede10160e481dde27584b15e867 diff --git a/sfx2/inc/sfx2/thumbnailviewitem.hxx b/sfx2/inc/sfx2/thumbnailviewitem.hxx index f90ac58..625e5c4 100644 --- a/sfx2/inc/sfx2/thumbnailviewitem.hxx +++ b/sfx2/inc/sfx2/thumbnailviewitem.hxx @@ -36,6 +36,8 @@ #define THUMBNAILVIEW_ITEM_NONEITEM 0xFFFE +class CheckBox; +class Window; class ThumbnailView; struct ThumbnailViewItem @@ -50,7 +52,8 @@ struct ThumbnailViewItem rtl::OUString maText; ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >* mpxAcc; - ThumbnailViewItem ( ThumbnailView& rParent ); + ThumbnailViewItem (ThumbnailView &rView, Window *pParent); + ~ThumbnailViewItem (); bool isSelected () const { return mbSelected; } @@ -63,6 +66,12 @@ struct ThumbnailViewItem ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > GetAccessible( bool bIsTransientChildrenDisabled ); + + void setSelectionBoxPos (const Point &pos); + +private: + + CheckBox *mpSelectBox; }; #endif // THUMBNAILVIEWITEM_HXX diff --git a/sfx2/source/control/thumbnailview.cxx b/sfx2/source/control/thumbnailview.cxx index bcd28c5..88a807f 100644 --- a/sfx2/source/control/thumbnailview.cxx +++ b/sfx2/source/control/thumbnailview.cxx @@ -409,6 +409,11 @@ void ThumbnailView::DrawItem (ThumbnailViewItem *pItem, const Rectangle &aRect) *this, aNewViewInfos ); pProcessor->process(aSeq); + + aPos.Y() -= GetTextHeight(); + aPos.X() = aRect.Left() + 15; + + pItem->setSelectionBoxPos(aPos); } } @@ -1154,7 +1159,7 @@ void ThumbnailView::Populate () if (nEntries) { - ThumbnailViewItem* pItem = new ThumbnailViewItem( *this ); + ThumbnailViewItem* pItem = new ThumbnailViewItem( *this, this ); pItem->mnId = i+1; pItem->maText = aRegionName; @@ -1175,7 +1180,7 @@ void ThumbnailView::Populate () void ThumbnailView::InsertItem( sal_uInt16 nItemId, const BitmapEx& rImage, const rtl::OUString& rText, size_t nPos ) { - ThumbnailViewItem* pItem = new ThumbnailViewItem( *this ); + ThumbnailViewItem* pItem = new ThumbnailViewItem( *this, this ); pItem->mnId = nItemId; pItem->maPreview1 = rImage; pItem->maText = rText; diff --git a/sfx2/source/control/thumbnailviewitem.cxx b/sfx2/source/control/thumbnailviewitem.cxx index d7d9643..cd9ec8e 100644 --- a/sfx2/source/control/thumbnailviewitem.cxx +++ b/sfx2/source/control/thumbnailviewitem.cxx @@ -29,18 +29,22 @@ #include "thumbnailviewacc.hxx" #include <sfx2/thumbnailviewitem.hxx> +#include <vcl/button.hxx> #include <vcl/svapp.hxx> using namespace ::com::sun::star; -ThumbnailViewItem::ThumbnailViewItem( ThumbnailView& rParent ) - : mrParent(rParent) +ThumbnailViewItem::ThumbnailViewItem(ThumbnailView &rView, Window *pParent) + : mrParent(rView) , mnId(0) , mbVisible(true) , mbSelected(false) , mbHover(false) , mpxAcc(NULL) + , mpSelectBox(new CheckBox(pParent,WB_HIDE)) { + mpSelectBox->SetPosPixel(Point(0,0)); + mpSelectBox->SetSizePixel(Size(20,20)); } ThumbnailViewItem::~ThumbnailViewItem() @@ -50,16 +54,25 @@ ThumbnailViewItem::~ThumbnailViewItem() static_cast< ThumbnailViewItemAcc* >( mpxAcc->get() )->ParentDestroyed(); delete mpxAcc; } + + delete mpSelectBox; } void ThumbnailViewItem::setSelection (bool state) { mbSelected = state; + mpSelectBox->SetState(state ? STATE_CHECK : STATE_NOCHECK); + + if (!isHighlighted()) + mpSelectBox->Show(state); } void ThumbnailViewItem::setHighlight (bool state) { mbHover = state; + + if (!isSelected()) + mpSelectBox->Show(state); } uno::Reference< accessibility::XAccessible > ThumbnailViewItem::GetAccessible( bool bIsTransientChildrenDisabled ) @@ -70,6 +83,11 @@ uno::Reference< accessibility::XAccessible > ThumbnailViewItem::GetAccessible( b return *mpxAcc; } +void ThumbnailViewItem::setSelectionBoxPos (const Point &pos) +{ + mpSelectBox->SetPosPixel(pos); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ commit 86f6fd0c4e9a2f63d60cba9622eecc3ab4cd00ca Author: Rafael Dominguez <[email protected]> Date: Sat Jun 16 07:35:57 2012 -0430 Add isSelected, setSelection, isHighlighted, setHighlight methods. - These functions are to control the state of the thumbnailviewitem state. Change-Id: Id1f645832e7bd63df326db2da6f28c5b3c935c14 diff --git a/sfx2/inc/sfx2/thumbnailviewitem.hxx b/sfx2/inc/sfx2/thumbnailviewitem.hxx index 1cedb9e..f90ac58 100644 --- a/sfx2/inc/sfx2/thumbnailviewitem.hxx +++ b/sfx2/inc/sfx2/thumbnailviewitem.hxx @@ -53,6 +53,14 @@ struct ThumbnailViewItem ThumbnailViewItem ( ThumbnailView& rParent ); ~ThumbnailViewItem (); + bool isSelected () const { return mbSelected; } + + void setSelection (bool state); + + bool isHighlighted () const { return mbHover; } + + void setHighlight (bool state); + ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > GetAccessible( bool bIsTransientChildrenDisabled ); }; diff --git a/sfx2/source/control/thumbnailview.cxx b/sfx2/source/control/thumbnailview.cxx index 6430e86..bcd28c5 100644 --- a/sfx2/source/control/thumbnailview.cxx +++ b/sfx2/source/control/thumbnailview.cxx @@ -340,7 +340,7 @@ void ThumbnailView::DrawItem (ThumbnailViewItem *pItem, const Rectangle &aRect) // Draw item background BColor aFillColor = maColor.getBColor(); - if ( pItem->mbSelected || pItem->mbHover ) + if ( pItem->isSelected() || pItem->isHighlighted() ) aFillColor = rStyleSettings.GetHighlightColor().getBColor(); aSeq[nCount++] = Primitive2DReference( new PolyPolygonColorPrimitive2D( @@ -594,9 +594,9 @@ void ThumbnailView::MouseButtonDown( const MouseEvent& rMEvt ) { if ( rMEvt.GetClicks() == 1 ) { - pItem->mbSelected = !pItem->mbSelected; + pItem->setSelection(!pItem->isSelected()); - if (!pItem->mbHover) + if (!pItem->isHighlighted()) DrawItem(pItem,GetItemRect(pItem->mnId)); //StartTracking( STARTTRACK_SCROLLREPEAT ); @@ -631,16 +631,16 @@ void ThumbnailView::MouseMove( const MouseEvent& rMEvt ) { ThumbnailViewItem *pOld = mItemList[nPos]; - pOld->mbHover = false; + pOld->setHighlight(false); - if (!pOld->mbSelected) + if (!pOld->isSelected()) DrawItem(pOld,GetItemRect(pOld->mnId)); } mnHighItemId = pItem->mnId; - pItem->mbHover = true; + pItem->setHighlight(true); - if (!pItem->mbSelected) + if (!pItem->isSelected()) DrawItem(pItem,GetItemRect(pItem->mnId)); } } @@ -654,9 +654,9 @@ void ThumbnailView::MouseMove( const MouseEvent& rMEvt ) { ThumbnailViewItem *pOld = mItemList[nPos]; - pOld->mbHover = false; + pOld->setHighlight(false); - if (!pOld->mbSelected) + if (!pOld->isSelected()) DrawItem(pOld,GetItemRect(pOld->mnId)); } @@ -1052,9 +1052,9 @@ void ThumbnailView::LoseFocus() { ThumbnailViewItem *pOld = mItemList[nPos]; - pOld->mbHover = false; + pOld->setHighlight(false); - if (!pOld->mbSelected) + if (!pOld->isSelected()) DrawItem(pOld,GetItemRect(pOld->mnId)); } diff --git a/sfx2/source/control/thumbnailviewitem.cxx b/sfx2/source/control/thumbnailviewitem.cxx index 915ee5a..d7d9643 100644 --- a/sfx2/source/control/thumbnailviewitem.cxx +++ b/sfx2/source/control/thumbnailviewitem.cxx @@ -52,6 +52,16 @@ ThumbnailViewItem::~ThumbnailViewItem() } } +void ThumbnailViewItem::setSelection (bool state) +{ + mbSelected = state; +} + +void ThumbnailViewItem::setHighlight (bool state) +{ + mbHover = state; +} + uno::Reference< accessibility::XAccessible > ThumbnailViewItem::GetAccessible( bool bIsTransientChildrenDisabled ) { if( !mpxAcc ) _______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
