diff options
author | Caolán McNamara <caolanm@redhat.com> | 2016-11-04 14:53:11 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2016-11-04 17:14:27 +0000 |
commit | df738e0f8ceedb4bad756960be14d9c41adc165d (patch) | |
tree | b7cff2a21e0ae3857b312e780025e29e585c6c8e /cui | |
parent | 08d6cd788f2584ce10ab8fa10665245e953c59d9 (diff) |
replace user draw with an Image of the color
Change-Id: I0d301ba4082a45e7030c6956c18aa76e52bce216
Diffstat (limited to 'cui')
-rw-r--r-- | cui/source/options/optchart.cxx | 63 |
1 files changed, 11 insertions, 52 deletions
diff --git a/cui/source/options/optchart.cxx b/cui/source/options/optchart.cxx index cd92f14c6325..ddc3e0658ce5 100644 --- a/cui/source/options/optchart.cxx +++ b/cui/source/options/optchart.cxx @@ -40,8 +40,6 @@ public: virtual ~ColorLB() override; virtual void dispose() override; - virtual void UserDraw( const UserDrawEvent& rUDEvt ) override; - using ListBox::InsertEntry; sal_Int32 InsertEntry( const Color& rColor, const OUString& rStr, sal_Int32 nPos = LISTBOX_APPEND ); @@ -94,8 +92,6 @@ void ColorLB::ImplInit() const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings(); aImageSize = rStyleSettings.GetListBoxPreviewDefaultPixelSize(); - EnableUserDraw( true ); - SetUserItemSize( aImageSize ); } void ColorLB::ImplDestroyColorEntries() @@ -131,7 +127,17 @@ void ColorLB::dispose() sal_Int32 ColorLB::InsertEntry( const Color& rColor, const OUString& rStr, sal_Int32 nPos ) { - nPos = ListBox::InsertEntry( rStr, nPos ); + const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings(); + + VclPtr<VirtualDevice> xDevice = VclPtr<VirtualDevice>::Create(); + xDevice->SetOutputSize(aImageSize); + const Rectangle aRect(Point(0, 0), aImageSize); + xDevice->SetFillColor(rColor); + xDevice->SetLineColor(rStyleSettings.GetDisableColor()); + xDevice->DrawRect(aRect); + Bitmap aBitmap(xDevice->GetBitmap(Point(0, 0), xDevice->GetOutputSize())); + + nPos = ListBox::InsertEntry(rStr, Image(aBitmap), nPos); if ( nPos != LISTBOX_ERROR ) { ImplColorListData* pData = new ImplColorListData( rColor ); @@ -178,53 +184,6 @@ Color ColorLB::GetEntryColor( sal_Int32 nPos ) const return aColor; } -void ColorLB::UserDraw( const UserDrawEvent& rUDEvt ) -{ - size_t nPos = rUDEvt.GetItemId(); - ImplColorListData* pData = ( nPos < pColorList->size() ) ? (*pColorList)[ nPos ] : nullptr; - if ( pData ) - { - if ( pData->bColor ) - { - Point aPos( rUDEvt.GetRect().TopLeft() ); - - aPos.X() += 2; - aPos.Y() += ( rUDEvt.GetRect().GetHeight() - aImageSize.Height() ) / 2; - - const Rectangle aRect(aPos, aImageSize); - - vcl::RenderContext* pRenderContext = rUDEvt.GetRenderContext(); - pRenderContext->Push(); - pRenderContext->SetFillColor(pData->aColor); - pRenderContext->SetLineColor(pRenderContext->GetTextColor()); - pRenderContext->DrawRect(aRect); - pRenderContext->Pop(); - - const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings(); - const sal_uInt16 nEdgeBlendingPercent(GetEdgeBlending() ? rStyleSettings.GetEdgeBlending() : 0); - - if(nEdgeBlendingPercent) - { - const Color& rTopLeft(rStyleSettings.GetEdgeBlendingTopLeftColor()); - const Color& rBottomRight(rStyleSettings.GetEdgeBlendingBottomRightColor()); - const sal_uInt8 nAlpha((nEdgeBlendingPercent * 255) / 100); - const BitmapEx aBlendFrame(createBlendFrame(aRect.GetSize(), nAlpha, rTopLeft, rBottomRight)); - - if(!aBlendFrame.IsEmpty()) - { - pRenderContext->DrawBitmapEx(aRect.TopLeft(), aBlendFrame); - } - } - - ListBox::DrawEntry( rUDEvt, false, false ); - } - else - ListBox::DrawEntry( rUDEvt, false, true ); - } - else - ListBox::DrawEntry( rUDEvt, true, false ); -} - void ColorLB::Append( const XColorEntry& rEntry ) { InsertEntry( rEntry.GetColor(), rEntry.GetName() ); |