sfx2/Library_sfx.mk | 2 sfx2/inc/sfx2/thumbnailview.hxx | 15 sfx2/source/control/thumbnailview.cxx | 886 ++++++++++++---------------------- 3 files changed, 334 insertions(+), 569 deletions(-)
New commits: commit 8a65fffe1d5e0a01ac42291ece8331e32c418f69 Author: Rafael Dominguez <venccsra...@gmail.com> Date: Thu Jun 14 17:53:47 2012 -0430 Dont use another VirtualDevice for rendering. Change-Id: I923958a54157ac28dee03d99cee1b3368fcb5954 diff --git a/sfx2/inc/sfx2/thumbnailview.hxx b/sfx2/inc/sfx2/thumbnailview.hxx index 94ea49c..540f9f5 100644 --- a/sfx2/inc/sfx2/thumbnailview.hxx +++ b/sfx2/inc/sfx2/thumbnailview.hxx @@ -16,7 +16,6 @@ #include <vcl/ctrl.hxx> #include <vcl/image.hxx> -#include <vcl/virdev.hxx> #include <vcl/timer.hxx> class MouseEvent; @@ -314,7 +313,6 @@ private: protected: - VirtualDevice maVirDev; Timer maTimer; ValueItemList mItemList; SfxOrganizeMgr *mpMgr; diff --git a/sfx2/source/control/thumbnailview.cxx b/sfx2/source/control/thumbnailview.cxx index 5ef9237..84e3cfd 100644 --- a/sfx2/source/control/thumbnailview.cxx +++ b/sfx2/source/control/thumbnailview.cxx @@ -189,7 +189,6 @@ Image lcl_fetchThumbnail (const rtl::OUString &msURL, int width, int height) ThumbnailView::ThumbnailView (Window *pParent, WinBits nWinStyle, bool bDisableTransientChildren) : Control( pParent, nWinStyle ), - maVirDev( *this ), maColor( COL_TRANSPARENT ) { ImplInit(); @@ -198,7 +197,6 @@ ThumbnailView::ThumbnailView (Window *pParent, WinBits nWinStyle, bool bDisableT ThumbnailView::ThumbnailView (Window *pParent, const ResId &rResId, bool bDisableTransientChildren) : Control( pParent, rResId ), - maVirDev( *this ), maColor( COL_TRANSPARENT ) { ImplInit(); @@ -248,9 +246,6 @@ void ThumbnailView::ImplInit() mbScroll = false; mbHasVisibleItems = false; - // #106446#, #106601# force mirroring of virtual device - maVirDev.EnableRTL( GetParent()->IsRTLEnabled() ); - ImplInitSettings( true, true, true ); } @@ -363,7 +358,7 @@ void ThumbnailView::DrawItem (ThumbnailViewItem *pItem, const Rectangle &aRect) // Draw centered text below thumbnail aPos.Y() += 20 + aImageSize.Height(); - aPos.X() = aRect.Left() + (aRectSize.Width() - maVirDev.GetTextWidth(pItem->maText))/2; + aPos.X() = aRect.Left() + (aRectSize.Width() - GetTextWidth(pItem->maText))/2; // Create the text primitive B2DVector aFontSize; @@ -890,11 +885,6 @@ void ThumbnailView::Paint( const Rectangle& ) mnItemHeight = nCalcHeight / mnVisLines; } - // Init VirDev - maVirDev.SetSettings( GetSettings() ); - maVirDev.SetBackground( GetBackground() ); - maVirDev.SetOutputSizePixel( aWinSize, sal_True ); - // nothing is changed in case of too small items if ( (mnItemWidth <= 0) || (mnItemHeight <= 2) || @@ -938,7 +928,6 @@ void ThumbnailView::Paint( const Rectangle& ) long nStartY = 0; // calculate and draw items - maVirDev.SetLineColor(); long x = nStartX; long y = nStartY; commit 62020a34cccd778be6f4052c31299ed085a48d00 Author: Rafael Dominguez <venccsra...@gmail.com> Date: Thu Jun 14 17:51:25 2012 -0430 Remove ImplHideSelect function. Change-Id: Ia3d90409cfcd148e304b4fcc7f3a7aafd4e9604f diff --git a/sfx2/inc/sfx2/thumbnailview.hxx b/sfx2/inc/sfx2/thumbnailview.hxx index 839378d..94ea49c 100644 --- a/sfx2/inc/sfx2/thumbnailview.hxx +++ b/sfx2/inc/sfx2/thumbnailview.hxx @@ -295,7 +295,6 @@ private: SVT_DLLPRIVATE void ImplInitSettings( bool bFont, bool bForeground, bool bBackground ); SVT_DLLPRIVATE void ImplInitScrollBar(); SVT_DLLPRIVATE void ImplDeleteItems(); - SVT_DLLPRIVATE void ImplHideSelect( sal_uInt16 nItemId ); SVT_DLLPRIVATE void ImplDraw(); using Window::ImplScroll; SVT_DLLPRIVATE bool ImplScroll( const Point& rPos ); diff --git a/sfx2/source/control/thumbnailview.cxx b/sfx2/source/control/thumbnailview.cxx index 64b75ed..5ef9237 100644 --- a/sfx2/source/control/thumbnailview.cxx +++ b/sfx2/source/control/thumbnailview.cxx @@ -398,22 +398,6 @@ void ThumbnailView::DrawItem (ThumbnailViewItem *pItem, const Rectangle &aRect) return new ThumbnailViewAcc( this, mbIsTransientChildrenDisabled ); } -void ThumbnailView::ImplHideSelect( sal_uInt16 nItemId ) -{ - Rectangle aRect; - - const size_t nItemPos = GetItemPos( nItemId ); - if ( nItemPos != THUMBNAILVIEW_ITEM_NOTFOUND && mItemList[nItemPos]->mbVisible ) - { - aRect = ImplGetItemRect(nItemPos); - - HideFocus(); - const Point aPos = aRect.TopLeft(); - const Size aSize = aRect.GetSize(); - DrawOutDev( aPos, aSize, aPos, aSize, maVirDev ); - } -} - bool ThumbnailView::ImplScroll( const Point& rPos ) { if ( !mbScroll || !maItemListRect.IsInside(rPos) ) commit 210ba7a5078429b665957db32caab174413c3667 Author: Rafael Dominguez <venccsra...@gmail.com> Date: Thu Jun 14 17:44:36 2012 -0430 Remove DrawSelect and DrawSelectedItem functions. Change-Id: Ifd4682b644025aecbfea0f3f2c57ba854a7e1d3b diff --git a/sfx2/inc/sfx2/thumbnailview.hxx b/sfx2/inc/sfx2/thumbnailview.hxx index 3ae61ab..839378d 100644 --- a/sfx2/inc/sfx2/thumbnailview.hxx +++ b/sfx2/inc/sfx2/thumbnailview.hxx @@ -284,8 +284,6 @@ protected: virtual void DrawItem (ThumbnailViewItem *pItem, const Rectangle &aRect); - virtual void DrawSelectedItem (const sal_uInt16 nItemId, const bool bFocus, const bool bDrawSel); - private: friend class ThumbnailViewAcc; @@ -297,7 +295,6 @@ private: SVT_DLLPRIVATE void ImplInitSettings( bool bFont, bool bForeground, bool bBackground ); SVT_DLLPRIVATE void ImplInitScrollBar(); SVT_DLLPRIVATE void ImplDeleteItems(); - SVT_DLLPRIVATE void ImplDrawSelect(); SVT_DLLPRIVATE void ImplHideSelect( sal_uInt16 nItemId ); SVT_DLLPRIVATE void ImplDraw(); using Window::ImplScroll; diff --git a/sfx2/source/control/thumbnailview.cxx b/sfx2/source/control/thumbnailview.cxx index 7652d68..64b75ed 100644 --- a/sfx2/source/control/thumbnailview.cxx +++ b/sfx2/source/control/thumbnailview.cxx @@ -398,96 +398,6 @@ void ThumbnailView::DrawItem (ThumbnailViewItem *pItem, const Rectangle &aRect) return new ThumbnailViewAcc( this, mbIsTransientChildrenDisabled ); } -void ThumbnailView::ImplDrawSelect() -{ - if ( !IsReallyVisible() ) - return; - - const bool bFocus = HasFocus(); - const bool bDrawSel = !( (mbNoSelection && !mbHighlight) || (!mbDrawSelection && mbHighlight) ); - - if ( !bFocus && !bDrawSel ) - return; - - DrawSelectedItem( mnSelItemId, bFocus, bDrawSel ); - if (mbHighlight) - { - DrawSelectedItem( mnHighItemId, bFocus, bDrawSel ); - } -} - -void ThumbnailView::DrawSelectedItem( const sal_uInt16 nItemId, const bool bFocus, const bool bDrawSel ) -{ - ThumbnailViewItem* pItem; - Rectangle aRect; - if ( nItemId ) - { - const size_t nPos = GetItemPos( nItemId ); - pItem = mItemList[ nPos ]; - aRect = ImplGetItemRect( nPos ); - } - else if ( bFocus && (pItem = ImplGetFirstItem()) ) - { - aRect = ImplGetItemRect( 0 ); - } - else - { - return; - } - - if ( pItem->mbVisible ) - { - // draw selection - const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings(); - Control::SetFillColor(); - - Color aDoubleColor( rStyleSettings.GetHighlightColor() ); - Color aSingleColor( rStyleSettings.GetHighlightTextColor() ); - if( !mbDoubleSel ) - { - /* - * #99777# contrast enhancement for thin mode - */ - const Wallpaper& rWall = GetDisplayBackground(); - if( ! rWall.IsBitmap() && ! rWall.IsGradient() ) - { - const Color& rBack = rWall.GetColor(); - if( rBack.IsDark() && ! aDoubleColor.IsBright() ) - { - aDoubleColor = Color( COL_WHITE ); - aSingleColor = Color( COL_BLACK ); - } - else if( rBack.IsBright() && ! aDoubleColor.IsDark() ) - { - aDoubleColor = Color( COL_BLACK ); - aSingleColor = Color( COL_WHITE ); - } - } - } - - // specify selection output - aRect.Left() += 4; - aRect.Top() += 4; - aRect.Right() -= 4; - aRect.Bottom() -= 4; - - if ( bDrawSel ) - { - SetLineColor( aDoubleColor ); - aRect.Left()++; - aRect.Top()++; - aRect.Right()--; - aRect.Bottom()--; - DrawRect( aRect ); - aRect.Left()++; - aRect.Top()++; - aRect.Right()--; - aRect.Bottom()--; - DrawRect( aRect ); - } - } -} - void ThumbnailView::ImplHideSelect( sal_uInt16 nItemId ) { Rectangle aRect; commit 2be7e06f707523ce6528ac4b6a6aac7611b12039 Author: Rafael Dominguez <venccsra...@gmail.com> Date: Thu Jun 14 17:20:19 2012 -0430 Dont hightlight an item when the mouse leave the view. Change-Id: I90d11e15e00e3baf3477679588de0dd06e10ceed diff --git a/sfx2/source/control/thumbnailview.cxx b/sfx2/source/control/thumbnailview.cxx index 44026aa..7652d68 100644 --- a/sfx2/source/control/thumbnailview.cxx +++ b/sfx2/source/control/thumbnailview.cxx @@ -731,6 +731,25 @@ void ThumbnailView::MouseMove( const MouseEvent& rMEvt ) DrawItem(pItem,GetItemRect(pItem->mnId)); } } + else + { + if (mnHighItemId) + { + size_t nPos = GetItemPos(mnHighItemId); + + if (nPos != THUMBNAILVIEW_ITEM_NOTFOUND) + { + ThumbnailViewItem *pOld = mItemList[nPos]; + + pOld->mbHover = false; + + if (!pOld->mbSelected) + DrawItem(pOld,GetItemRect(pOld->mnId)); + } + + mnHighItemId = 0; + } + } Control::MouseMove( rMEvt ); } commit 97a6815c3452189c3ff2861bdafbebecb97f6a76 Author: Rafael Dominguez <venccsra...@gmail.com> Date: Thu Jun 14 16:25:40 2012 -0430 Remove FullItemMode related functions and attribute. Change-Id: I91d47dc30c4463c26663fc697ae4ccffe3d25a3b diff --git a/sfx2/inc/sfx2/thumbnailview.hxx b/sfx2/inc/sfx2/thumbnailview.hxx index a714e17..3ae61ab 100644 --- a/sfx2/inc/sfx2/thumbnailview.hxx +++ b/sfx2/inc/sfx2/thumbnailview.hxx @@ -187,10 +187,6 @@ public: Rectangle GetItemRect( sal_uInt16 nItemId ) const; - void EnableFullItemMode( bool bFullMode = true ); - - bool IsFullItemModeEnabled() const { return mbFullMode; } - void SetColCount( sal_uInt16 nNewCols = 1 ); sal_uInt16 GetColCount() const { return mnUserCols; } @@ -351,7 +347,6 @@ protected: bool mbBlackSel : 1; bool mbDoubleSel : 1; bool mbScroll : 1; - bool mbFullMode : 1; bool mbIsTransientChildrenDisabled : 1; bool mbHasVisibleItems : 1; Color maColor; diff --git a/sfx2/source/control/thumbnailview.cxx b/sfx2/source/control/thumbnailview.cxx index a220bde..44026aa 100644 --- a/sfx2/source/control/thumbnailview.cxx +++ b/sfx2/source/control/thumbnailview.cxx @@ -246,7 +246,6 @@ void ThumbnailView::ImplInit() mbBlackSel = false; mbDoubleSel = false; mbScroll = false; - mbFullMode = true; mbHasVisibleItems = false; // #106446#, #106601# force mirroring of virtual device @@ -1022,20 +1021,8 @@ void ThumbnailView::Paint( const Rectangle& ) mbDoubleSel = false; // calculate offsets - long nStartX; - long nStartY; - if ( mbFullMode ) - { - long nAllItemWidth = (mnItemWidth*mnCols)+nColSpace; - long nAllItemHeight = (mnItemHeight*mnVisLines)+nNoneHeight+nLineSpace; - nStartX = (aWinSize.Width()-nScrBarWidth-nAllItemWidth)/2; - nStartY = (aWinSize.Height()-nAllItemHeight)/2; - } - else - { - nStartX = 0; - nStartY = 0; - } + long nStartX = 0; + long nStartY = 0; // calculate and draw items maVirDev.SetLineColor(); @@ -1051,15 +1038,13 @@ void ThumbnailView::Paint( const Rectangle& ) maItemListRect.Right() = x + mnCols*(mnItemWidth+mnSpacing) - mnSpacing - 1; maItemListRect.Bottom() = y + mnVisLines*(mnItemHeight+mnSpacing) - mnSpacing - 1; - if ( !mbFullMode ) - { - // If want also draw parts of items in the last line, - // then we add one more line if parts of these line are - // visible - if ( y+(mnVisLines*(mnItemHeight+mnSpacing)) < aWinSize.Height() ) - nLastItem += mnCols; - maItemListRect.Bottom() = aWinSize.Height() - y; - } + // If want also draw parts of items in the last line, + // then we add one more line if parts of these line are + // visible + if ( y+(mnVisLines*(mnItemHeight+mnSpacing)) < aWinSize.Height() ) + nLastItem += mnCols; + maItemListRect.Bottom() = aWinSize.Height() - y; + for ( size_t i = 0; i < nItemCount; i++ ) { ThumbnailViewItem *const pItem = mItemList[i]; @@ -1397,11 +1382,6 @@ Rectangle ThumbnailView::GetItemRect( sal_uInt16 nItemId ) const return Rectangle(); } -void ThumbnailView::EnableFullItemMode( bool bFullMode ) -{ - mbFullMode = bFullMode; -} - void ThumbnailView::SetColCount( sal_uInt16 nNewCols ) { if ( mnUserCols != nNewCols ) commit 5c7f64cfd12a4cd5f013cca0047645d72d4902c7 Author: Rafael Dominguez <venccsra...@gmail.com> Date: Thu Jun 14 15:53:27 2012 -0430 Do only drawing operations in paint handler. - Do drawing operations directly to the control instead of another VirtualDevice. - Remove DrawImpl and Format functions. - Every time and item state change redraw. Change-Id: I3a12415653f1c2b05c1be998016ed5a364a6baf5 diff --git a/sfx2/inc/sfx2/thumbnailview.hxx b/sfx2/inc/sfx2/thumbnailview.hxx index ca59ef9..a714e17 100644 --- a/sfx2/inc/sfx2/thumbnailview.hxx +++ b/sfx2/inc/sfx2/thumbnailview.hxx @@ -232,8 +232,6 @@ public: bool IsColor() const { return maColor.GetTransparency() == 0; } - void Format(); - void StartSelection(); void EndSelection(); @@ -346,7 +344,6 @@ protected: sal_uInt16 mnFirstLine; sal_uInt16 mnSpacing; sal_uInt16 mnFrameStyle; - bool mbFormat : 1; bool mbHighlight : 1; bool mbSelection : 1; bool mbNoSelection : 1; diff --git a/sfx2/source/control/thumbnailview.cxx b/sfx2/source/control/thumbnailview.cxx index c7be3fd..a220bde 100644 --- a/sfx2/source/control/thumbnailview.cxx +++ b/sfx2/source/control/thumbnailview.cxx @@ -239,7 +239,6 @@ void ThumbnailView::ImplInit() mnUserVisLines = 0; mnSpacing = 0; mnFrameStyle = 0; - mbFormat = true; mbHighlight = false; mbSelection = false; mbNoSelection = true; @@ -400,245 +399,6 @@ void ThumbnailView::DrawItem (ThumbnailViewItem *pItem, const Rectangle &aRect) return new ThumbnailViewAcc( this, mbIsTransientChildrenDisabled ); } -void ThumbnailView::Format() -{ - Size aWinSize = GetOutputSizePixel(); - size_t nItemCount = mItemList.size(); - WinBits nStyle = GetStyle(); - long nNoneHeight = 0; - long nNoneSpace = 0; - ScrollBar* pDelScrBar = NULL; - - // consider the scrolling - if ( nStyle & WB_VSCROLL ) - ImplInitScrollBar(); - else - { - if ( mpScrBar ) - { - // delete ScrollBar not until later, to prevent recursive calls - pDelScrBar = mpScrBar; - mpScrBar = NULL; - } - } - - // calculate ScrollBar width - long nScrBarWidth = 0; - if ( mpScrBar ) - nScrBarWidth = mpScrBar->GetSizePixel().Width()+SCRBAR_OFFSET; - - // calculate number of columns - if ( !mnUserCols ) - { - if ( mnUserItemWidth ) - { - mnCols = (sal_uInt16)((aWinSize.Width()-nScrBarWidth+mnSpacing) / (mnUserItemWidth+mnSpacing)); - if ( !mnCols ) - mnCols = 1; - } - else - mnCols = 1; - } - else - mnCols = mnUserCols; - - // calculate number of rows - mbScroll = false; - // Floor( (M+N-1)/N )==Ceiling( M/N ) - mnLines = (static_cast<long>(nItemCount)+mnCols-1) / mnCols; - if ( !mnLines ) - mnLines = 1; - - long nCalcHeight = aWinSize.Height()-nNoneHeight; - if ( mnUserVisLines ) - mnVisLines = mnUserVisLines; - else if ( mnUserItemHeight ) - { - mnVisLines = (nCalcHeight-nNoneSpace+mnSpacing) / (mnUserItemHeight+mnSpacing); - if ( !mnVisLines ) - mnVisLines = 1; - } - else - mnVisLines = mnLines; - if ( mnLines > mnVisLines ) - mbScroll = true; - if ( mnLines <= mnVisLines ) - mnFirstLine = 0; - else - { - if ( mnFirstLine > (sal_uInt16)(mnLines-mnVisLines) ) - mnFirstLine = (sal_uInt16)(mnLines-mnVisLines); - } - - // calculate item size - const long nColSpace = (mnCols-1)*mnSpacing; - const long nLineSpace = ((mnVisLines-1)*mnSpacing)+nNoneSpace; - if ( mnUserItemWidth && !mnUserCols ) - { - mnItemWidth = mnUserItemWidth; - if ( mnItemWidth > aWinSize.Width()-nScrBarWidth-nColSpace ) - mnItemWidth = aWinSize.Width()-nScrBarWidth-nColSpace; - } - else - mnItemWidth = (aWinSize.Width()-nScrBarWidth-nColSpace) / mnCols; - if ( mnUserItemHeight && !mnUserVisLines ) - { - mnItemHeight = mnUserItemHeight; - if ( mnItemHeight > nCalcHeight-nNoneSpace ) - mnItemHeight = nCalcHeight-nNoneSpace; - } - else - { - nCalcHeight -= nLineSpace; - mnItemHeight = nCalcHeight / mnVisLines; - } - - // Init VirDev - maVirDev.SetSettings( GetSettings() ); - maVirDev.SetBackground( GetBackground() ); - maVirDev.SetOutputSizePixel( aWinSize, sal_True ); - - // nothing is changed in case of too small items - if ( (mnItemWidth <= 0) || - (mnItemHeight <= 2) || - !nItemCount ) - { - mbHasVisibleItems = false; - - for ( size_t i = 0; i < nItemCount; i++ ) - { - mItemList[i]->mbVisible = false; - } - - if ( mpScrBar ) - mpScrBar->Hide(); - } - else - { - 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; - long nStartY; - if ( mbFullMode ) - { - long nAllItemWidth = (mnItemWidth*mnCols)+nColSpace; - long nAllItemHeight = (mnItemHeight*mnVisLines)+nNoneHeight+nLineSpace; - nStartX = (aWinSize.Width()-nScrBarWidth-nAllItemWidth)/2; - nStartY = (aWinSize.Height()-nAllItemHeight)/2; - } - else - { - nStartX = 0; - nStartY = 0; - } - - // calculate and draw items - maVirDev.SetLineColor(); - long x = nStartX; - long y = nStartY; - - // draw items - sal_uLong nFirstItem = mnFirstLine * mnCols; - sal_uLong nLastItem = nFirstItem + (mnVisLines * mnCols); - - maItemListRect.Left() = x; - maItemListRect.Top() = y; - maItemListRect.Right() = x + mnCols*(mnItemWidth+mnSpacing) - mnSpacing - 1; - maItemListRect.Bottom() = y + mnVisLines*(mnItemHeight+mnSpacing) - mnSpacing - 1; - - if ( !mbFullMode ) - { - // If want also draw parts of items in the last line, - // then we add one more line if parts of these line are - // visible - if ( y+(mnVisLines*(mnItemHeight+mnSpacing)) < aWinSize.Height() ) - nLastItem += mnCols; - maItemListRect.Bottom() = aWinSize.Height() - y; - } - for ( size_t i = 0; i < nItemCount; i++ ) - { - ThumbnailViewItem *const pItem = mItemList[i]; - - if ( (i >= nFirstItem) && (i < nLastItem) ) - { - if( !pItem->mbVisible && ImplHasAccessibleListeners() ) - { - ::com::sun::star::uno::Any aOldAny, aNewAny; - - aNewAny <<= pItem->GetAccessible( mbIsTransientChildrenDisabled ); - ImplFireAccessibleEvent( ::com::sun::star::accessibility::AccessibleEventId::CHILD, aOldAny, aNewAny ); - } - - pItem->mbVisible = true; - DrawItem( pItem, Rectangle( Point(x,y), Size(mnItemWidth, mnItemHeight) ) ); - - if ( !((i+1) % mnCols) ) - { - x = nStartX; - y += mnItemHeight+mnSpacing; - } - else - x += mnItemWidth+mnSpacing; - } - else - { - if( pItem->mbVisible && ImplHasAccessibleListeners() ) - { - ::com::sun::star::uno::Any aOldAny, aNewAny; - - aOldAny <<= pItem->GetAccessible( mbIsTransientChildrenDisabled ); - ImplFireAccessibleEvent( ::com::sun::star::accessibility::AccessibleEventId::CHILD, aOldAny, aNewAny ); - } - - pItem->mbVisible = false; - } - } - - // arrange ScrollBar, set values and show it - if ( mpScrBar ) - { - Point aPos( aWinSize.Width()-nScrBarWidth+SCRBAR_OFFSET, 0 ); - Size aSize( nScrBarWidth-SCRBAR_OFFSET, aWinSize.Height() ); - - mpScrBar->SetPosSizePixel( aPos, aSize ); - mpScrBar->SetRangeMax( mnLines ); - mpScrBar->SetVisibleSize( mnVisLines ); - mpScrBar->SetThumbPos( (long)mnFirstLine ); - long nPageSize = mnVisLines; - if ( nPageSize < 1 ) - nPageSize = 1; - mpScrBar->SetPageSize( nPageSize ); - mpScrBar->Show(); - } - } - - // waiting for the next since the formatting is finished - mbFormat = false; - - // delete ScrollBar - delete pDelScrBar; -} - void ThumbnailView::ImplDrawSelect() { if ( !IsReallyVisible() ) @@ -745,38 +505,6 @@ void ThumbnailView::ImplHideSelect( sal_uInt16 nItemId ) } } -void ThumbnailView::ImplDraw() -{ - if ( mbFormat ) - Format(); - - HideFocus(); - - Point aDefPos; - Size aSize = maVirDev.GetOutputSizePixel(); - - if ( mpScrBar && mpScrBar->IsVisible() ) - { - Point aScrPos = mpScrBar->GetPosPixel(); - Size aScrSize = mpScrBar->GetSizePixel(); - Point aTempPos( 0, aScrPos.Y() ); - Size aTempSize( aSize.Width(), aScrPos.Y() ); - - DrawOutDev( aDefPos, aTempSize, aDefPos, aTempSize, maVirDev ); - aTempSize.Width() = aScrPos.X()-1; - aTempSize.Height() = aScrSize.Height(); - DrawOutDev( aTempPos, aTempSize, aTempPos, aTempSize, maVirDev ); - aTempPos.Y() = aScrPos.Y()+aScrSize.Height(); - aTempSize.Width() = aSize.Width(); - aTempSize.Height() = aSize.Height()-aTempPos.Y(); - DrawOutDev( aTempPos, aTempSize, aTempPos, aTempSize, maVirDev ); - } - else - DrawOutDev( aDefPos, aSize, aDefPos, aSize, maVirDev ); - - ImplDrawSelect(); -} - bool ThumbnailView::ImplScroll( const Point& rPos ) { if ( !mbScroll || !maItemListRect.IsInside(rPos) ) @@ -805,8 +533,9 @@ bool ThumbnailView::ImplScroll( const Point& rPos ) if ( !bScroll ) return false; - mbFormat = true; - ImplDraw(); + if ( IsReallyVisible() && IsUpdateMode() ) + Invalidate(); + return true; } @@ -908,8 +637,9 @@ IMPL_LINK( ThumbnailView,ImplScrollHdl, ScrollBar*, pScrollBar ) if ( nNewFirstLine != mnFirstLine ) { mnFirstLine = nNewFirstLine; - mbFormat = true; - ImplDraw(); + + if ( IsReallyVisible() && IsUpdateMode() ) + Invalidate(); } return 0; } @@ -1157,7 +887,238 @@ void ThumbnailView::Command( const CommandEvent& rCEvt ) void ThumbnailView::Paint( const Rectangle& ) { - ImplDraw(); + Size aWinSize = GetOutputSizePixel(); + size_t nItemCount = mItemList.size(); + WinBits nStyle = GetStyle(); + long nNoneHeight = 0; + long nNoneSpace = 0; + ScrollBar* pDelScrBar = NULL; + + // consider the scrolling + if ( nStyle & WB_VSCROLL ) + ImplInitScrollBar(); + else + { + if ( mpScrBar ) + { + // delete ScrollBar not until later, to prevent recursive calls + pDelScrBar = mpScrBar; + mpScrBar = NULL; + } + } + + // calculate ScrollBar width + long nScrBarWidth = 0; + if ( mpScrBar ) + nScrBarWidth = mpScrBar->GetSizePixel().Width()+SCRBAR_OFFSET; + + // calculate number of columns + if ( !mnUserCols ) + { + if ( mnUserItemWidth ) + { + mnCols = (sal_uInt16)((aWinSize.Width()-nScrBarWidth+mnSpacing) / (mnUserItemWidth+mnSpacing)); + if ( !mnCols ) + mnCols = 1; + } + else + mnCols = 1; + } + else + mnCols = mnUserCols; + + // calculate number of rows + mbScroll = false; + // Floor( (M+N-1)/N )==Ceiling( M/N ) + mnLines = (static_cast<long>(nItemCount)+mnCols-1) / mnCols; + if ( !mnLines ) + mnLines = 1; + + long nCalcHeight = aWinSize.Height()-nNoneHeight; + if ( mnUserVisLines ) + mnVisLines = mnUserVisLines; + else if ( mnUserItemHeight ) + { + mnVisLines = (nCalcHeight-nNoneSpace+mnSpacing) / (mnUserItemHeight+mnSpacing); + if ( !mnVisLines ) + mnVisLines = 1; + } + else + mnVisLines = mnLines; + if ( mnLines > mnVisLines ) + mbScroll = true; + if ( mnLines <= mnVisLines ) + mnFirstLine = 0; + else + { + if ( mnFirstLine > (sal_uInt16)(mnLines-mnVisLines) ) + mnFirstLine = (sal_uInt16)(mnLines-mnVisLines); + } + + // calculate item size + const long nColSpace = (mnCols-1)*mnSpacing; + const long nLineSpace = ((mnVisLines-1)*mnSpacing)+nNoneSpace; + if ( mnUserItemWidth && !mnUserCols ) + { + mnItemWidth = mnUserItemWidth; + if ( mnItemWidth > aWinSize.Width()-nScrBarWidth-nColSpace ) + mnItemWidth = aWinSize.Width()-nScrBarWidth-nColSpace; + } + else + mnItemWidth = (aWinSize.Width()-nScrBarWidth-nColSpace) / mnCols; + if ( mnUserItemHeight && !mnUserVisLines ) + { + mnItemHeight = mnUserItemHeight; + if ( mnItemHeight > nCalcHeight-nNoneSpace ) + mnItemHeight = nCalcHeight-nNoneSpace; + } + else + { + nCalcHeight -= nLineSpace; + mnItemHeight = nCalcHeight / mnVisLines; + } + + // Init VirDev + maVirDev.SetSettings( GetSettings() ); + maVirDev.SetBackground( GetBackground() ); + maVirDev.SetOutputSizePixel( aWinSize, sal_True ); + + // nothing is changed in case of too small items + if ( (mnItemWidth <= 0) || + (mnItemHeight <= 2) || + !nItemCount ) + { + mbHasVisibleItems = false; + + for ( size_t i = 0; i < nItemCount; i++ ) + { + mItemList[i]->mbVisible = false; + } + + if ( mpScrBar ) + mpScrBar->Hide(); + } + else + { + 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; + long nStartY; + if ( mbFullMode ) + { + long nAllItemWidth = (mnItemWidth*mnCols)+nColSpace; + long nAllItemHeight = (mnItemHeight*mnVisLines)+nNoneHeight+nLineSpace; + nStartX = (aWinSize.Width()-nScrBarWidth-nAllItemWidth)/2; + nStartY = (aWinSize.Height()-nAllItemHeight)/2; + } + else + { + nStartX = 0; + nStartY = 0; + } + + // calculate and draw items + maVirDev.SetLineColor(); + long x = nStartX; + long y = nStartY; + + // draw items + sal_uLong nFirstItem = mnFirstLine * mnCols; + sal_uLong nLastItem = nFirstItem + (mnVisLines * mnCols); + + maItemListRect.Left() = x; + maItemListRect.Top() = y; + maItemListRect.Right() = x + mnCols*(mnItemWidth+mnSpacing) - mnSpacing - 1; + maItemListRect.Bottom() = y + mnVisLines*(mnItemHeight+mnSpacing) - mnSpacing - 1; + + if ( !mbFullMode ) + { + // If want also draw parts of items in the last line, + // then we add one more line if parts of these line are + // visible + if ( y+(mnVisLines*(mnItemHeight+mnSpacing)) < aWinSize.Height() ) + nLastItem += mnCols; + maItemListRect.Bottom() = aWinSize.Height() - y; + } + for ( size_t i = 0; i < nItemCount; i++ ) + { + ThumbnailViewItem *const pItem = mItemList[i]; + + if ( (i >= nFirstItem) && (i < nLastItem) ) + { + if( !pItem->mbVisible && ImplHasAccessibleListeners() ) + { + ::com::sun::star::uno::Any aOldAny, aNewAny; + + aNewAny <<= pItem->GetAccessible( mbIsTransientChildrenDisabled ); + ImplFireAccessibleEvent( ::com::sun::star::accessibility::AccessibleEventId::CHILD, aOldAny, aNewAny ); + } + + pItem->mbVisible = true; + DrawItem( pItem, Rectangle( Point(x,y), Size(mnItemWidth, mnItemHeight) ) ); + + if ( !((i+1) % mnCols) ) + { + x = nStartX; + y += mnItemHeight+mnSpacing; + } + else + x += mnItemWidth+mnSpacing; + } + else + { + if( pItem->mbVisible && ImplHasAccessibleListeners() ) + { + ::com::sun::star::uno::Any aOldAny, aNewAny; + + aOldAny <<= pItem->GetAccessible( mbIsTransientChildrenDisabled ); + ImplFireAccessibleEvent( ::com::sun::star::accessibility::AccessibleEventId::CHILD, aOldAny, aNewAny ); + } + + pItem->mbVisible = false; + } + } + + // arrange ScrollBar, set values and show it + if ( mpScrBar ) + { + Point aPos( aWinSize.Width()-nScrBarWidth+SCRBAR_OFFSET, 0 ); + Size aSize( nScrBarWidth-SCRBAR_OFFSET, aWinSize.Height() ); + + mpScrBar->SetPosSizePixel( aPos, aSize ); + mpScrBar->SetRangeMax( mnLines ); + mpScrBar->SetVisibleSize( mnVisLines ); + mpScrBar->SetThumbPos( (long)mnFirstLine ); + long nPageSize = mnVisLines; + if ( nPageSize < 1 ) + nPageSize = 1; + mpScrBar->SetPageSize( nPageSize ); + mpScrBar->Show(); + } + } + + // delete ScrollBar + delete pDelScrBar; } void ThumbnailView::GetFocus() @@ -1199,7 +1160,6 @@ void ThumbnailView::LoseFocus() void ThumbnailView::Resize() { - mbFormat = true; if ( IsReallyVisible() && IsUpdateMode() ) Invalidate(); Control::Resize(); @@ -1211,8 +1171,8 @@ void ThumbnailView::StateChanged( StateChangedType nType ) if ( nType == STATE_CHANGE_INITSHOW ) { - if ( mbFormat ) - Format(); + if ( IsReallyVisible() && IsUpdateMode() ) + Invalidate(); } else if ( nType == STATE_CHANGE_UPDATEMODE ) { @@ -1240,7 +1200,6 @@ void ThumbnailView::StateChanged( StateChangedType nType ) } else if ( (nType == STATE_CHANGE_STYLE) || (nType == STATE_CHANGE_ENABLE) ) { - mbFormat = true; ImplInitSettings( false, false, true ); Invalidate(); } @@ -1256,7 +1215,6 @@ void ThumbnailView::DataChanged( const DataChangedEvent& rDCEvt ) ((rDCEvt.GetType() == DATACHANGED_SETTINGS) && (rDCEvt.GetFlags() & SETTINGS_STYLE)) ) { - mbFormat = true; ImplInitSettings( true, true, true ); Invalidate(); } @@ -1334,7 +1292,6 @@ void ThumbnailView::ImplInsertItem( ThumbnailViewItem *const pItem, const size_t mItemList.push_back( pItem ); } - mbFormat = true; if ( IsReallyVisible() && IsUpdateMode() ) Invalidate(); } @@ -1382,7 +1339,6 @@ void ThumbnailView::RemoveItem( sal_uInt16 nItemId ) mbNoSelection = true; } - mbFormat = true; if ( IsReallyVisible() && IsUpdateMode() ) Invalidate(); } @@ -1398,7 +1354,6 @@ void ThumbnailView::Clear() mnSelItemId = 0; mbNoSelection = true; - mbFormat = true; if ( IsReallyVisible() && IsUpdateMode() ) Invalidate(); } @@ -1452,7 +1407,6 @@ void ThumbnailView::SetColCount( sal_uInt16 nNewCols ) if ( mnUserCols != nNewCols ) { mnUserCols = nNewCols; - mbFormat = true; if ( IsReallyVisible() && IsUpdateMode() ) Invalidate(); } @@ -1463,7 +1417,6 @@ void ThumbnailView::SetLineCount( sal_uInt16 nNewLines ) if ( mnUserVisLines != nNewLines ) { mnUserVisLines = nNewLines; - mbFormat = true; if ( IsReallyVisible() && IsUpdateMode() ) Invalidate(); } @@ -1474,7 +1427,6 @@ void ThumbnailView::SetItemWidth( long nNewItemWidth ) if ( mnUserItemWidth != nNewItemWidth ) { mnUserItemWidth = nNewItemWidth; - mbFormat = true; if ( IsReallyVisible() && IsUpdateMode() ) Invalidate(); } @@ -1485,7 +1437,6 @@ void ThumbnailView::SetItemHeight( long nNewItemHeight ) if ( mnUserItemHeight != nNewItemHeight ) { mnUserItemHeight = nNewItemHeight; - mbFormat = true; if ( IsReallyVisible() && IsUpdateMode() ) Invalidate(); } @@ -1508,7 +1459,7 @@ void ThumbnailView::SelectItem( sal_uInt16 nItemId ) mnSelItemId = nItemId; mbNoSelection = false; - bool bNewOut = !mbFormat && IsReallyVisible() && IsUpdateMode(); + bool bNewOut = IsReallyVisible() && IsUpdateMode(); bool bNewLine = false; // if necessary scroll to the visible area @@ -1529,18 +1480,8 @@ void ThumbnailView::SelectItem( sal_uInt16 nItemId ) if ( bNewOut ) { - if ( bNewLine ) - { - // redraw everything if the visible area has changed - mbFormat = true; - ImplDraw(); - } - else - { - // remove old selection and draw the new one - ImplHideSelect( nOldItem ); - ImplDrawSelect(); - } + if ( IsReallyVisible() && IsUpdateMode() ) + Invalidate(); } if( ImplHasAccessibleListeners() ) @@ -1615,7 +1556,7 @@ void ThumbnailView::SetNoSelection() mbSelection = false; if ( IsReallyVisible() && IsUpdateMode() ) - ImplDraw(); + Invalidate(); } void ThumbnailView::SetItemText( sal_uInt16 nItemId, const rtl::OUString& rText ) @@ -1637,7 +1578,7 @@ void ThumbnailView::SetItemText( sal_uInt16 nItemId, const rtl::OUString& rText pItem->maText = rText; - if ( !mbFormat && IsReallyVisible() && IsUpdateMode() ) + if ( IsReallyVisible() && IsUpdateMode() ) { sal_uInt16 nTempId = mnSelItemId; @@ -1669,9 +1610,8 @@ rtl::OUString ThumbnailView::GetItemText( sal_uInt16 nItemId ) const void ThumbnailView::SetColor( const Color& rColor ) { maColor = rColor; - mbFormat = true; if ( IsReallyVisible() && IsUpdateMode() ) - ImplDraw(); + Invalidate(); } void ThumbnailView::StartSelection() @@ -1749,17 +1689,14 @@ Size ThumbnailView::CalcWindowSizePixel( const Size& rItemSize, sal_uInt16 nDesi { nCalcLines = mnVisLines; - if ( mbFormat ) + if ( mnUserVisLines ) + nCalcLines = mnUserVisLines; + else { - if ( mnUserVisLines ) - nCalcLines = mnUserVisLines; - else - { - // Floor( (M+N-1)/N )==Ceiling( M/N ) - nCalcLines = (mItemList.size()+nCalcCols-1) / nCalcCols; - if ( !nCalcLines ) - nCalcLines = 1; - } + // Floor( (M+N-1)/N )==Ceiling( M/N ) + nCalcLines = (mItemList.size()+nCalcCols-1) / nCalcCols; + if ( !nCalcLines ) + nCalcLines = 1; } } commit 643f30de35d26e7e50ef3ea39a476733dbf38251 Author: Rafael Dominguez <venccsra...@gmail.com> Date: Thu Jun 14 15:10:20 2012 -0430 Update paint code to use drawinglayer API. Change-Id: Iacb8b1a8447d8fb54cbb72b7a5a8f25cadb1267d diff --git a/sfx2/Library_sfx.mk b/sfx2/Library_sfx.mk index a516bb3..9009ede 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 4285149..c7be3fd 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); } } commit f88c608f482f1b682d06e4945026e826877f2c2a Author: Rafael Dominguez <venccsra...@gmail.com> Date: Thu Jun 14 10:57:06 2012 -0430 Remove ImplHighlightItem function. Change-Id: I040780c93778d72ebb07d0638049450dc29e4e30 diff --git a/sfx2/inc/sfx2/thumbnailview.hxx b/sfx2/inc/sfx2/thumbnailview.hxx index 95b2ea9..ca59ef9 100644 --- a/sfx2/inc/sfx2/thumbnailview.hxx +++ b/sfx2/inc/sfx2/thumbnailview.hxx @@ -305,7 +305,6 @@ private: SVT_DLLPRIVATE void ImplDeleteItems(); SVT_DLLPRIVATE void ImplDrawSelect(); SVT_DLLPRIVATE void ImplHideSelect( sal_uInt16 nItemId ); - SVT_DLLPRIVATE void ImplHighlightItem( sal_uInt16 nItemId, bool bIsSelection = true ); SVT_DLLPRIVATE void ImplDraw(); using Window::ImplScroll; SVT_DLLPRIVATE bool ImplScroll( const Point& rPos ); diff --git a/sfx2/source/control/thumbnailview.cxx b/sfx2/source/control/thumbnailview.cxx index 0184701..4285149 100644 --- a/sfx2/source/control/thumbnailview.cxx +++ b/sfx2/source/control/thumbnailview.cxx @@ -724,25 +724,6 @@ void ThumbnailView::ImplHideSelect( sal_uInt16 nItemId ) } } -void ThumbnailView::ImplHighlightItem( sal_uInt16 nItemId, bool bIsSelection ) -{ - if ( mnHighItemId != nItemId ) - { - // remember the old item to delete the previous selection - sal_uInt16 nOldItem = mnHighItemId; - mnHighItemId = nItemId; - - // don't draw the selection if nothing is selected - if ( !bIsSelection && mbNoSelection ) - mbDrawSelection = false; - - // remove the old selection and draw the new one - ImplHideSelect( nOldItem ); - ImplDrawSelect(); - mbDrawSelection = true; - } -} - void ThumbnailView::ImplDraw() { if ( mbFormat ) @@ -946,28 +927,19 @@ void ThumbnailView::MouseButtonDown( const MouseEvent& rMEvt ) if (pItem) { - if ( mbSelection ) - { - mbHighlight = true; - mnHighItemId = mnSelItemId; - ImplHighlightItem( pItem->mnId ); - } - else + if ( !rMEvt.IsMod2() ) { - if ( !rMEvt.IsMod2() ) + if ( rMEvt.GetClicks() == 1 ) { - if ( rMEvt.GetClicks() == 1 ) - { - pItem->mbSelected = !pItem->mbSelected; + pItem->mbSelected = !pItem->mbSelected; - if (!pItem->mbHover) - DrawItem(pItem,GetItemRect(pItem->mnId)); + if (!pItem->mbHover) + DrawItem(pItem,GetItemRect(pItem->mnId)); - //StartTracking( STARTTRACK_SCROLLREPEAT ); - } - else if ( rMEvt.GetClicks() == 2 ) - DoubleClick(); + //StartTracking( STARTTRACK_SCROLLREPEAT ); } + else if ( rMEvt.GetClicks() == 2 ) + DoubleClick(); } return; @@ -1695,7 +1667,6 @@ void ThumbnailView::EndSelection() if ( IsTracking() ) EndTracking( ENDTRACK_CANCEL ); - ImplHighlightItem( mnSelItemId ); mbHighlight = false; } mbSelection = false; commit 70929122b60c2448230e05f58d69856ce21b34b4 Author: Rafael Dominguez <venccsra...@gmail.com> Date: Thu Jun 14 10:09:48 2012 -0430 Clear Tracking handling code. Change-Id: Icfeba7191d337c3c812db32b845289a01a699cf7 diff --git a/sfx2/source/control/thumbnailview.cxx b/sfx2/source/control/thumbnailview.cxx index 3fcba83..0184701 100644 --- a/sfx2/source/control/thumbnailview.cxx +++ b/sfx2/source/control/thumbnailview.cxx @@ -932,43 +932,10 @@ void ThumbnailView::ImplTracking( const Point& rPos, bool bRepeat ) } } } - - ThumbnailViewItem* pItem = ImplGetItem( ImplGetItem( rPos ) ); - if ( pItem ) - { - ImplHighlightItem( pItem->mnId ); - } - else - { - ImplHighlightItem( mnSelItemId, false ); - } } void ThumbnailView::ImplEndTracking( const Point& rPos, bool bCancel ) { - ThumbnailViewItem* pItem; - - // restore the old status in case of termination - if ( bCancel ) - pItem = NULL; - else - pItem = ImplGetItem( ImplGetItem( rPos ) ); - - if ( pItem ) - { - SelectItem( pItem->mnId ); - if ( !mbSelection ) - GrabFocus(); - mbHighlight = false; - mbSelection = false; - Select(); - } - else - { - ImplHighlightItem( mnSelItemId, false ); - mbHighlight = false; - mbSelection = false; - } } void ThumbnailView::MouseButtonDown( const MouseEvent& rMEvt ) _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits