diff options
-rw-r--r-- | include/vcl/toolbox.hxx | 1 | ||||
-rw-r--r-- | svx/source/tbxctrls/tbxcolorupdate.cxx | 7 | ||||
-rw-r--r-- | vcl/inc/toolbox.h | 1 | ||||
-rw-r--r-- | vcl/source/window/toolbox2.cxx | 59 |
4 files changed, 38 insertions, 30 deletions
diff --git a/include/vcl/toolbox.hxx b/include/vcl/toolbox.hxx index 44b4b8c046a7..c72c59f25862 100644 --- a/include/vcl/toolbox.hxx +++ b/include/vcl/toolbox.hxx @@ -401,6 +401,7 @@ public: void* GetItemData( sal_uInt16 nItemId ) const; void SetItemImage( sal_uInt16 nItemId, const Image& rImage ); Image GetItemImage( sal_uInt16 nItemId ) const; + Image GetItemImageOriginal( sal_uInt16 nItemId ) const; void SetItemImageAngle( sal_uInt16 nItemId, long nAngle10 ); void SetItemImageMirrorMode( sal_uInt16 nItemId, bool bMirror ); void SetItemText( sal_uInt16 nItemId, const OUString& rText ); diff --git a/svx/source/tbxctrls/tbxcolorupdate.cxx b/svx/source/tbxctrls/tbxcolorupdate.cxx index 3c9a1efc21ed..27f9de9fedb2 100644 --- a/svx/source/tbxctrls/tbxcolorupdate.cxx +++ b/svx/source/tbxctrls/tbxcolorupdate.cxx @@ -78,8 +78,9 @@ namespace svx void ToolboxButtonColorUpdater::Update(const Color& rColor) { - Image aImage(mpTbx->GetItemImage(mnBtnId)); - Size aItemSize(mpTbx->GetItemContentSize(mnBtnId)); + Image aImage(mpTbx->GetItemImageOriginal(mnBtnId)); + BitmapEx aSource(aImage.GetBitmapEx()); + Size aItemSize = aSource.GetSizePixel(); const bool bSizeChanged = (maBmpSize != aItemSize); const bool bDisplayModeChanged = (mbWasHiContrastMode != mpTbx->GetSettings().GetStyleSettings().GetHighContrastMode()); @@ -99,7 +100,7 @@ namespace svx // (so that it grows in case the original bitmap was smaller) sal_uInt8 nAlpha = 255; BitmapEx aBmpEx(Bitmap(aItemSize, 24), AlphaMask(aItemSize, &nAlpha)); - BitmapEx aSource(aImage.GetBitmapEx()); + long nWidth = std::min(aItemSize.Width(), aSource.GetSizePixel().Width()); long nHeight = std::min(aItemSize.Height(), aSource.GetSizePixel().Height()); diff --git a/vcl/inc/toolbox.h b/vcl/inc/toolbox.h index 2b23c53eddb9..935d1184e81c 100644 --- a/vcl/inc/toolbox.h +++ b/vcl/inc/toolbox.h @@ -40,6 +40,7 @@ struct ImplToolItem vcl::Window* mpWindow; void* mpUserData; Image maImage; + Image maImageOriginal; long mnImageAngle; bool mbMirrorMode; OUString maText; diff --git a/vcl/source/window/toolbox2.cxx b/vcl/source/window/toolbox2.cxx index dd675dc3fa38..17588506d021 100644 --- a/vcl/source/window/toolbox2.cxx +++ b/vcl/source/window/toolbox2.cxx @@ -1125,7 +1125,12 @@ void ToolBox::SetItemImage( sal_uInt16 nItemId, const Image& rImage ) { Image aImage(rImage); - if ( GetDPIScaleFactor() > 1) + ImplToolItem* pItem = &mpData->m_aItems[nPos]; + Size aOldSize = pItem->maImage.GetSizePixel(); + + pItem->maImageOriginal = aImage; + + if (GetDPIScaleFactor() > 1) { BitmapEx aBitmap(aImage.GetBitmapEx()); @@ -1138,19 +1143,16 @@ void ToolBox::SetItemImage( sal_uInt16 nItemId, const Image& rImage ) } } - ImplToolItem* pItem = &mpData->m_aItems[nPos]; + pItem->maImage = aImage; + // only once all is calculated, do extra work - if ( !mbCalc ) + if (!mbCalc) { - Size aOldSize = pItem->maImage.GetSizePixel(); - pItem->maImage = aImage; - if ( aOldSize != pItem->maImage.GetSizePixel() ) + if (aOldSize != pItem->maImage.GetSizePixel()) ImplInvalidate( true ); else ImplUpdateItem( nPos ); } - else - pItem->maImage = aImage; } } @@ -1196,14 +1198,15 @@ void ToolBox::SetItemImageAngle( sal_uInt16 nItemId, long nAngle10 ) if( nDeltaAngle && !!pItem->maImage ) { pItem->maImage = ImplRotImage( pItem->maImage, nDeltaAngle ); + pItem->maImageOriginal = ImplRotImage( pItem->maImageOriginal, nDeltaAngle ); } - if ( !mbCalc ) + if (!mbCalc) { - if ( aOldSize != pItem->maImage.GetSizePixel() ) - ImplInvalidate( true ); + if (aOldSize != pItem->maImage.GetSizePixel()) + ImplInvalidate(true); else - ImplUpdateItem( nPos ); + ImplUpdateItem(nPos); } } } @@ -1226,30 +1229,32 @@ void ToolBox::SetItemImageMirrorMode( sal_uInt16 nItemId, bool bMirror ) { ImplToolItem* pItem = &mpData->m_aItems[nPos]; - if( ( pItem->mbMirrorMode && ! bMirror ) || - ( ! pItem->mbMirrorMode && bMirror ) - ) + if ((pItem->mbMirrorMode && !bMirror) || + (!pItem->mbMirrorMode && bMirror)) { pItem->mbMirrorMode = bMirror; - if( !!pItem->maImage ) + if (!!pItem->maImage) { - pItem->maImage = ImplMirrorImage( pItem->maImage ); + pItem->maImage = ImplMirrorImage(pItem->maImage); + pItem->maImageOriginal = ImplMirrorImage(pItem->maImageOriginal); } - if ( !mbCalc ) - ImplUpdateItem( nPos ); + if (!mbCalc) + ImplUpdateItem(nPos); } } } -Image ToolBox::GetItemImage( sal_uInt16 nItemId ) const +Image ToolBox::GetItemImage(sal_uInt16 nItemId) const { - ImplToolItem* pItem = ImplGetItem( nItemId ); + ImplToolItem* pItem = ImplGetItem(nItemId); + return pItem ? pItem->maImage : Image(); +} - if ( pItem ) - return pItem->maImage; - else - return Image(); +Image ToolBox::GetItemImageOriginal(sal_uInt16 nItemId) const +{ + ImplToolItem* pItem = ImplGetItem(nItemId); + return pItem ? pItem->maImageOriginal : Image(); } void ToolBox::SetItemText( sal_uInt16 nItemId, const OUString& rText ) @@ -1830,7 +1835,7 @@ void ToolBox::UpdateCustomMenu() if( it->IsClipped() ) { sal_uInt16 id = it->mnId + TOOLBOX_MENUITEM_START; - pMenu->InsertItem( id, it->maText, it->maImage, MenuItemBits::NONE, OString()); + pMenu->InsertItem( id, it->maText, it->maImageOriginal, MenuItemBits::NONE, OString()); pMenu->EnableItem( id, it->mbEnabled ); pMenu->CheckItem ( id, it->meState == TRISTATE_TRUE ); } @@ -1846,7 +1851,7 @@ void ToolBox::UpdateCustomMenu() if( it->IsItemHidden() ) { sal_uInt16 id = it->mnId + TOOLBOX_MENUITEM_START; - pMenu->InsertItem( id, it->maText, it->maImage, MenuItemBits::NONE, OString() ); + pMenu->InsertItem( id, it->maText, it->maImageOriginal, MenuItemBits::NONE, OString() ); pMenu->EnableItem( id, it->mbEnabled ); pMenu->CheckItem( id, it->meState == TRISTATE_TRUE ); } |