diff options
author | Caolán McNamara <caolanm@redhat.com> | 2016-11-04 14:19:44 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2016-11-04 17:14:27 +0000 |
commit | a19b18ad7c9eb0197c10e6d7e451ec4542e4bc9e (patch) | |
tree | 5c7c440cdd8e279c51681a5119beef21246b4ca9 /svx/source | |
parent | a989a0b1f2b425f05b58d0e44ce2de31c842ed65 (diff) |
move now combined ColorLB to location of last user
Change-Id: I5dc1204c28b65d5dca993bf38aea217bbb49e913
Diffstat (limited to 'svx/source')
-rw-r--r-- | svx/source/dialog/dlgctrl.cxx | 253 |
1 files changed, 0 insertions, 253 deletions
diff --git a/svx/source/dialog/dlgctrl.cxx b/svx/source/dialog/dlgctrl.cxx index 3751903e077e..d8f312bda281 100644 --- a/svx/source/dialog/dlgctrl.cxx +++ b/svx/source/dialog/dlgctrl.cxx @@ -1103,259 +1103,6 @@ void SvxPixelCtl::Reset() Invalidate(); } -VCL_BUILDER_DECL_FACTORY(ColorLB) -{ - bool bDropdown = VclBuilder::extractDropdown(rMap); - WinBits nWinBits = WB_LEFT|WB_VCENTER|WB_3DLOOK|WB_SIMPLEMODE|WB_TABSTOP; - if (bDropdown) - nWinBits |= WB_DROPDOWN; - OString sBorder = VclBuilder::extractCustomProperty(rMap); - if (!sBorder.isEmpty()) - nWinBits |= WB_BORDER; - VclPtrInstance<ColorLB> pListBox(pParent, nWinBits); - pListBox->EnableAutoSize(true); - rRet = pListBox; -} - -class ImplColorListData -{ -public: - Color aColor; - bool bColor; - - ImplColorListData() : aColor( COL_BLACK ) { bColor = false; } - explicit ImplColorListData( const Color& rColor ) : aColor( rColor ) { bColor = true; } -}; - -void ColorLB::ImplInit() -{ - pColorList = new ImpColorList(); - - const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings(); - aImageSize = rStyleSettings.GetListBoxPreviewDefaultPixelSize(); - EnableUserDraw( true ); - SetUserItemSize( aImageSize ); -} - -void ColorLB::ImplDestroyColorEntries() -{ - for ( size_t n = pColorList->size(); n; ) - delete (*pColorList)[ --n ]; - pColorList->clear(); -} - -ColorLB::ColorLB( vcl::Window* pParent, WinBits nWinStyle ) : - ListBox( pParent, nWinStyle ) -{ - ImplInit(); - SetEdgeBlending(true); -} - -ColorLB::~ColorLB() -{ - disposeOnce(); -} - -void ColorLB::dispose() -{ - if ( pColorList ) - { - ImplDestroyColorEntries(); - delete pColorList; - pColorList = nullptr; - } - ListBox::dispose(); -} - -sal_Int32 ColorLB::InsertEntry( const OUString& rStr, sal_Int32 nPos ) -{ - nPos = ListBox::InsertEntry( rStr, nPos ); - if ( nPos != LISTBOX_ERROR ) - { - ImplColorListData* pData = new ImplColorListData; - if ( static_cast<size_t>(nPos) < pColorList->size() ) - { - ImpColorList::iterator it = pColorList->begin(); - ::std::advance( it, nPos ); - pColorList->insert( it, pData ); - } - else - { - pColorList->push_back( pData ); - nPos = pColorList->size() - 1; - } - } - return nPos; -} - -sal_Int32 ColorLB::InsertEntry( const Color& rColor, const OUString& rStr, - sal_Int32 nPos ) -{ - nPos = ListBox::InsertEntry( rStr, nPos ); - if ( nPos != LISTBOX_ERROR ) - { - ImplColorListData* pData = new ImplColorListData( rColor ); - if ( static_cast<size_t>(nPos) < pColorList->size() ) - { - ImpColorList::iterator it = pColorList->begin(); - ::std::advance( it, nPos ); - pColorList->insert( it, pData ); - } - else - { - pColorList->push_back( pData ); - nPos = pColorList->size() - 1; - } - } - return nPos; -} - -void ColorLB::RemoveEntry( sal_Int32 nPos ) -{ - ListBox::RemoveEntry( nPos ); - if ( 0 <= nPos && static_cast<size_t>(nPos) < pColorList->size() ) - { - ImpColorList::iterator it = pColorList->begin(); - ::std::advance( it, nPos ); - delete *it; - pColorList->erase( it ); - } -} - -void ColorLB::Clear() -{ - ImplDestroyColorEntries(); - ListBox::Clear(); -} - -void ColorLB::CopyEntries( const ColorLB& rBox ) -{ - // Liste leeren - ImplDestroyColorEntries(); - - // Daten kopieren - size_t nCount = rBox.pColorList->size(); - for ( size_t n = 0; n < nCount; n++ ) - { - ImplColorListData* pData = (*rBox.pColorList)[ n ]; - sal_Int32 nPos = InsertEntry( rBox.GetEntry( n ) ); - if ( nPos != LISTBOX_ERROR ) - { - if ( static_cast<size_t>(nPos) < pColorList->size() ) - { - ImpColorList::iterator it = pColorList->begin(); - ::std::advance( it, nPos ); - pColorList->insert( it, new ImplColorListData( *pData ) ); - } - else - { - pColorList->push_back( new ImplColorListData( *pData ) ); - } - } - } -} - -sal_Int32 ColorLB::GetEntryPos( const Color& rColor ) const -{ - for( sal_Int32 n = (sal_Int32) pColorList->size(); n; ) - { - ImplColorListData* pData = (*pColorList)[ --n ]; - if ( pData->bColor && ( pData->aColor == rColor ) ) - return n; - } - return LISTBOX_ENTRY_NOTFOUND; -} - -Color ColorLB::GetEntryColor( sal_Int32 nPos ) const -{ - Color aColor; - ImplColorListData* pData = ( 0 <= nPos && static_cast<size_t>(nPos) < pColorList->size() ) ? - (*pColorList)[ nPos ] : nullptr; - if ( pData && pData->bColor ) - aColor = pData->aColor; - 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 ); -} - - -// Fills the Listbox with color and strings - -void ColorLB::Fill( const XColorListRef &pColorTab ) -{ - if( !pColorTab.is() ) - return; - - long nCount = pColorTab->Count(); - SetUpdateMode( false ); - - for( long i = 0; i < nCount; i++ ) - { - const XColorEntry* pEntry = pColorTab->GetColor(i); - InsertEntry( pEntry->GetColor(), pEntry->GetName() ); - } - - AdaptDropDownLineCountToMaximum(); - SetUpdateMode( true ); -} - -void ColorLB::Append( const XColorEntry& rEntry ) -{ - InsertEntry( rEntry.GetColor(), rEntry.GetName() ); - AdaptDropDownLineCountToMaximum(); -} - -void ColorLB::Modify( const XColorEntry& rEntry, sal_Int32 nPos ) -{ - RemoveEntry( nPos ); - InsertEntry( rEntry.GetColor(), rEntry.GetName(), nPos ); -} - // Fills the listbox (provisional) with strings HatchingLB::HatchingLB( vcl::Window* pParent, WinBits nWinStyle) |