diff options
author | Armin Le Grand <alg@apache.org> | 2013-04-16 08:41:07 +0000 |
---|---|---|
committer | Michael Meeks <michael.meeks@suse.com> | 2013-05-20 11:33:13 +0100 |
commit | 35aa48d80b4b800d408d26bd72fbdfd711abbb6f (patch) | |
tree | 2756d4aa78cd67be7d1597b4222f0da0657c770d /svx | |
parent | 05038d1bd0a7bc9ecb6676ba1309576ac74f849f (diff) |
Resolves: #i122041# Unified and centralized control for Color ValueSets
(cherry picked from commit 68e707bbc6fe23881b822e6efab8a2933343dc1a)
Conflicts:
cui/source/inc/backgrnd.hxx
cui/source/inc/cuitabarea.hxx
cui/source/tabpages/backgrnd.cxx
cui/source/tabpages/tpcolor.cxx
sd/source/ui/view/drviews6.cxx
svx/Package_inc.mk
svx/inc/svx/colrctrl.hxx
svx/source/sidebar/tools/ColorControl.cxx
svx/source/tbxctrls/colorwindow.hxx
svx/source/tbxctrls/colrctrl.cxx
svx/source/tbxctrls/tbcontrl.cxx
Change-Id: Ie06fe355846b737ec8aae9aade4d408232c83193
Related: #i122041# Add a11y values for defining behaviour of ColorValueSets
(cherry picked from commit 401e8f2db607081e62eaaa1f08a8cd8971a3f637)
Conflicts:
cui/source/tabpages/backgrnd.cxx
officecfg/registry/schema/org/openoffice/Office/Common.xcs
sc/source/ui/miscdlgs/tabbgcolordlg.cxx
svtools/inc/svtools/accessibilityoptions.hxx
svtools/source/inc/configitems/accessibilityoptions_const.hxx
vcl/inc/vcl/bitmap.hxx
vcl/source/gdi/bitmap4.cxx
Change-Id: If9d0db5f22974cad1ac886eca3719ca92ca7f240
Diffstat (limited to 'svx')
-rw-r--r-- | svx/Library_svx.mk | 1 | ||||
-rw-r--r-- | svx/Library_svxcore.mk | 1 | ||||
-rw-r--r-- | svx/inc/svx/sidebar/ColorControl.hxx | 3 | ||||
-rw-r--r-- | svx/source/sidebar/tools/ColorControl.cxx | 46 | ||||
-rw-r--r-- | svx/source/tbxctrls/SvxColorChildWindow.cxx | 47 | ||||
-rw-r--r-- | svx/source/tbxctrls/SvxColorValueSet.cxx | 149 | ||||
-rw-r--r-- | svx/source/tbxctrls/colorwindow.hxx | 3 | ||||
-rw-r--r-- | svx/source/tbxctrls/colrctrl.cxx | 94 | ||||
-rw-r--r-- | svx/source/tbxctrls/tbcontrl.cxx | 77 |
9 files changed, 272 insertions, 149 deletions
diff --git a/svx/Library_svx.mk b/svx/Library_svx.mk index 3089cdebd440..420bb635df4e 100644 --- a/svx/Library_svx.mk +++ b/svx/Library_svx.mk @@ -214,6 +214,7 @@ $(eval $(call gb_Library_add_exception_objects,svx,\ svx/source/table/tablertfexporter \ svx/source/table/tablertfimporter \ svx/source/tbxctrls/colrctrl \ + svx/source/tbxctrls/SvxColorChildWindow \ svx/source/tbxctrls/fillctrl \ svx/source/tbxctrls/formatpaintbrushctrl \ svx/source/tbxctrls/grafctrl \ diff --git a/svx/Library_svxcore.mk b/svx/Library_svxcore.mk index 2f3eaf9eaffe..94fbf167f8fd 100644 --- a/svx/Library_svxcore.mk +++ b/svx/Library_svxcore.mk @@ -334,6 +334,7 @@ $(eval $(call gb_Library_add_exception_objects,svxcore,\ svx/source/tbxctrls/fontworkgallery \ svx/source/tbxctrls/tbcontrl \ svx/source/tbxctrls/tbxcolorupdate \ + svx/source/tbxctrls/SvxColorValueSet \ svx/source/toolbars/extrusionbar \ svx/source/toolbars/fontworkbar \ svx/source/unodraw/gluepts \ diff --git a/svx/inc/svx/sidebar/ColorControl.hxx b/svx/inc/svx/sidebar/ColorControl.hxx index 58ab534c1aa1..606a906eccdb 100644 --- a/svx/inc/svx/sidebar/ColorControl.hxx +++ b/svx/inc/svx/sidebar/ColorControl.hxx @@ -19,6 +19,7 @@ #include <svtools/valueset.hxx> #include <boost/function.hpp> +#include <svx/SvxColorValueSet.hxx> class Window; class SfxBindings; @@ -69,7 +70,7 @@ public: private: SfxBindings* mpBindings; - ValueSet maVSColor; + SvxColorValueSet maVSColor; FloatingWindow* mpFloatingWindow; const String msNoColorString; ::boost::function<Color(void)> maNoColorGetter; diff --git a/svx/source/sidebar/tools/ColorControl.cxx b/svx/source/sidebar/tools/ColorControl.cxx index 85d3f3539fcf..3a517b9fa05f 100644 --- a/svx/source/sidebar/tools/ColorControl.cxx +++ b/svx/source/sidebar/tools/ColorControl.cxx @@ -104,6 +104,7 @@ ColorControl::ColorControl ( maColorSetter(rColorSetter) { FreeResource(); + FillColors(); } @@ -121,40 +122,37 @@ void ColorControl::FillColors (void) if (xColorTable.is()) { - const long nColorCount (xColorTable->Count()); + const long nColorCount(xColorTable->Count()); if (nColorCount <= 0) return; - const sal_Int32 nColumnCount (ceil(sqrt(double(nColorCount)))); - const sal_Int32 nRowCount (ceil(double(nColorCount)/nColumnCount)); - maVSColor.SetColCount(nColumnCount); - maVSColor.SetLineCount(nRowCount); - const sal_Int32 nItemSize (15*12 / ::std::max<sal_Int32>(nColumnCount, nRowCount)); - maVSColor.CalcWindowSizePixel(Size(nItemSize,nItemSize)); - Link aLink = LINK(this, ColorControl, VSSelectHdl); - maVSColor.SetSelectHdl(aLink); - maVSColor.SetStyle( - (maVSColor.GetStyle() - | WB_TABSTOP | WB_ITEMBORDER | WB_NAMEFIELD// | WB_FLATVALUESET - | WB_NO_DIRECTSELECT | WB_MENUSTYLEVALUESET | WB_NO_DIRECTSELECT) - & ~WB_VSCROLL); - if (msNoColorString.Len() > 0) + const WinBits aWinBits(maVSColor.GetStyle() | WB_TABSTOP | WB_ITEMBORDER | WB_NAMEFIELD | + WB_NO_DIRECTSELECT | WB_MENUSTYLEVALUESET | WB_NO_DIRECTSELECT); + + maVSColor.SetStyle(aWinBits); + + // neds to be done *before* layouting + if(msNoColorString.Len() > 0) { maVSColor.SetStyle(maVSColor.GetStyle() | WB_NONEFIELD); maVSColor.SetText(msNoColorString); } + const Size aNewSize(maVSColor.layoutAllVisible(nColorCount)); + maVSColor.SetOutputSizePixel(aNewSize); + static sal_Int32 nAdd = 4; + + SetOutputSizePixel(Size(aNewSize.Width() + nAdd, aNewSize.Height() + nAdd)); + Link aLink = LINK(this, ColorControl, VSSelectHdl); + maVSColor.SetSelectHdl(aLink); + // Now, after all calls to SetStyle, we can change the // background color. maVSColor.SetBackground(Theme::GetWallpaper(Theme::Paint_DropDownBackground)); + // add entrties maVSColor.Clear(); - XColorEntry* pEntry = NULL; - for (sal_Int32 nIndex=0; nIndex<nColorCount; ++nIndex) - { - pEntry = xColorTable->GetColor(nIndex); - maVSColor.InsertItem(nIndex+1, pEntry->GetColor(), pEntry->GetName() ); - } + maVSColor.addEntriesForXColorList(*xColorTable); } maVSColor.Show(); @@ -173,7 +171,7 @@ void ColorControl::GetFocus (void) void ColorControl::SetCurColorSelect (Color aCol, bool bAvailable) { - FillColors(); +// FillColors(); short nCol = GetItemId_Imp( maVSColor, aCol ); if(! bAvailable) { @@ -188,7 +186,9 @@ void ColorControl::SetCurColorSelect (Color aCol, bool bAvailable) } else { - maVSColor.SelectItem( nCol ); + // remove selection first to force evtl. scroll when scroll is needed + maVSColor.SetNoSelection(); + maVSColor.SelectItem(nCol); } } diff --git a/svx/source/tbxctrls/SvxColorChildWindow.cxx b/svx/source/tbxctrls/SvxColorChildWindow.cxx new file mode 100644 index 000000000000..1ce729e90024 --- /dev/null +++ b/svx/source/tbxctrls/SvxColorChildWindow.cxx @@ -0,0 +1,47 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include <svx/SvxColorChildWindow.hxx> +#include <sfx2/dockwin.hxx> +#include <svx/svxids.hrc> +#include <svx/dialogs.hrc> +#include <svx/colrctrl.hxx> +#include <svx/dialmgr.hxx> + +SFX_IMPL_DOCKINGWINDOW_WITHID( SvxColorChildWindow, SID_COLOR_CONTROL ) + +/************************************************************************* +|* +|* Ableitung vom SfxChildWindow als "Behaelter" fuer Animator +|* +\************************************************************************/ + +SvxColorChildWindow::SvxColorChildWindow( Window* _pParent, + sal_uInt16 nId, + SfxBindings* pBindings, + SfxChildWinInfo* pInfo ) : + SfxChildWindow( _pParent, nId ) +{ + SvxColorDockingWindow* pWin = new SvxColorDockingWindow( pBindings, this, + _pParent, SVX_RES( RID_SVXCTRL_COLOR ) ); + pWindow = pWin; + + eChildAlignment = SFX_ALIGN_BOTTOM; + + pWin->Initialize( pInfo ); +} diff --git a/svx/source/tbxctrls/SvxColorValueSet.cxx b/svx/source/tbxctrls/SvxColorValueSet.cxx new file mode 100644 index 000000000000..34dfa6c07224 --- /dev/null +++ b/svx/source/tbxctrls/SvxColorValueSet.cxx @@ -0,0 +1,149 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include <svx/SvxColorValueSet.hxx> +#include <svx/xtable.hxx> +#include <svtools/accessibilityoptions.hxx> + +////////////////////////////////////////////////////////////////////////////// + +SvxColorValueSet::SvxColorValueSet(Window* _pParent, WinBits nWinStyle) +: ValueSet(_pParent, nWinStyle) +{ +} + +SvxColorValueSet::SvxColorValueSet(Window* _pParent, const ResId& rResId) +: ValueSet(_pParent, rResId) +{ +} + +sal_uInt32 SvxColorValueSet::getMaxRowCount() const +{ + const SvtAccessibilityOptions aOptions; + + return aOptions.GetColorValueSetMaximumRowCount(); +} + +sal_uInt32 SvxColorValueSet::getEntryEdgeLength() const +{ + const SvtAccessibilityOptions aOptions; + + return aOptions.GetColorValueSetEntryEdgeLength(); +} + +sal_uInt32 SvxColorValueSet::getColumnCount() const +{ + const SvtAccessibilityOptions aOptions; + + return aOptions.GetColorValueSetColumnCount(); +} + +void SvxColorValueSet::addEntriesForXColorList(const XColorList& rXColorList, sal_uInt32 nStartIndex) +{ + const sal_uInt32 nColorCount(rXColorList.Count()); + + for(sal_uInt32 nIndex(0); nIndex < nColorCount; nIndex++, nStartIndex++) + { + const XColorEntry* pEntry = rXColorList.GetColor(nIndex); + + if(pEntry) + { + InsertItem(nStartIndex, pEntry->GetColor(), pEntry->GetName()); + } + else + { + OSL_ENSURE(false, "OOps, XColorList with empty entries (!)"); + } + } +} + +Size SvxColorValueSet::layoutAllVisible(sal_uInt32 nEntryCount) +{ + if(!nEntryCount) + { + nEntryCount++; + } + + const sal_uInt32 nRowCount(ceil(double(nEntryCount)/getColumnCount())); + const Size aItemSize(getEntryEdgeLength() - 2, getEntryEdgeLength() - 2); + const WinBits aWinBits(GetStyle() & ~WB_VSCROLL); + + if(nRowCount > getMaxRowCount()) + { + SetStyle(aWinBits|WB_VSCROLL); + } + else + { + SetStyle(aWinBits); + } + + SetColCount(getColumnCount()); + SetLineCount(std::min(nRowCount, getMaxRowCount())); + SetItemWidth(aItemSize.Width()); + SetItemHeight(aItemSize.Height()); + + return CalcWindowSizePixel(aItemSize); +} + +Size SvxColorValueSet::layoutToGivenHeight(sal_uInt32 nHeight, sal_uInt32 nEntryCount) +{ + if(!nEntryCount) + { + nEntryCount++; + } + + const Size aItemSize(getEntryEdgeLength(), getEntryEdgeLength()); + const WinBits aWinBits(GetStyle() & ~WB_VSCROLL); + + // get size whith all fields disabled + const WinBits aWinBitsNoScrollNoFields(GetStyle() & ~(WB_VSCROLL|WB_NAMEFIELD|WB_NONEFIELD)); + SetStyle(aWinBitsNoScrollNoFields); + const Size aSizeNoScrollNoFields(CalcWindowSizePixel(aItemSize, getColumnCount())); + + // get size with all needed fields + SetStyle(aWinBits); + Size aNewSize(CalcWindowSizePixel(aItemSize, getColumnCount())); + + // evtl. activate vertical scroll + const bool bAdaptHeight(static_cast< sal_uInt32 >(aNewSize.Height()) > nHeight); + + if(bAdaptHeight) + { + SetStyle(aWinBits|WB_VSCROLL); + aNewSize = CalcWindowSizePixel(aItemSize, getColumnCount()); + } + + // calculate field height and available height for requested height + const sal_uInt32 nFieldHeight(aNewSize.Height() - aSizeNoScrollNoFields.Height()); + const sal_uInt32 nAvailableHeight(nHeight >= nFieldHeight ? nHeight - nFieldHeight : 0); + + // calculate how many lines can be shown there + const Size aItemSizePixel(CalcItemSizePixel(aItemSize)); + const sal_uInt32 nLineCount((nAvailableHeight + aItemSizePixel.Height() - 1) / aItemSizePixel.Height()); + + // set height to wanted height + aNewSize.Height() = nHeight; + + SetItemWidth(aItemSize.Width()); + SetItemHeight(aItemSize.Height()); + SetColCount(getColumnCount()); + SetLineCount(nLineCount); + + return aNewSize; +} + diff --git a/svx/source/tbxctrls/colorwindow.hxx b/svx/source/tbxctrls/colorwindow.hxx index 42516081e956..1a0bf5f146e9 100644 --- a/svx/source/tbxctrls/colorwindow.hxx +++ b/svx/source/tbxctrls/colorwindow.hxx @@ -28,6 +28,7 @@ #include <svl/lstner.hxx> #include <rtl/ustring.hxx> #include <com/sun/star/frame/XFrame.hpp> +#include <svx/SvxColorValueSet.hxx> //======================================================================== // class SvxColorWindow_Impl -------------------------------------------------- @@ -39,7 +40,7 @@ class SvxColorWindow_Impl : public SfxPopupWindow private: const sal_uInt16 theSlotId; - ValueSet aColorSet; + SvxColorValueSet aColorSet; OUString maCommand; const Color mLastColor; diff --git a/svx/source/tbxctrls/colrctrl.cxx b/svx/source/tbxctrls/colrctrl.cxx index aec84efc13b4..9f9e89deda82 100644 --- a/svx/source/tbxctrls/colrctrl.cxx +++ b/svx/source/tbxctrls/colrctrl.cxx @@ -36,8 +36,6 @@ #include "svx/xexch.hxx" #include <vcl/svapp.hxx> -SFX_IMPL_DOCKINGWINDOW_WITHID( SvxColorChildWindow, SID_COLOR_CONTROL ) - // ------------------------ // - SvxColorValueSetData - // ------------------------ @@ -92,41 +90,41 @@ sal_Bool SvxColorValueSetData::WriteObject( SotStorageStreamRef& rxOStm, void*, /************************************************************************* |* -|* SvxColorValueSet: Ctor +|* SvxColorValueSet_docking: Ctor |* \************************************************************************/ -SvxColorValueSet::SvxColorValueSet( Window* _pParent, const ResId& rResId ) : - ValueSet( _pParent, rResId ), +SvxColorValueSet_docking::SvxColorValueSet_docking( Window* _pParent, const ResId& rResId ) : + SvxColorValueSet( _pParent, rResId ), DragSourceHelper( this ), - bLeft (sal_True) + mbLeftButton(true) { SetAccessibleName(String( SVX_RES( STR_COLORTABLE ) )); } /************************************************************************* |* -|* SvxColorValueSet: MouseButtonDown +|* SvxColorValueSet_docking: MouseButtonDown |* \************************************************************************/ -void SvxColorValueSet::MouseButtonDown( const MouseEvent& rMEvt ) +void SvxColorValueSet_docking::MouseButtonDown( const MouseEvent& rMEvt ) { // Fuer Mac noch anders handlen ! if( rMEvt.IsLeft() ) { - bLeft = sal_True; - ValueSet::MouseButtonDown( rMEvt ); + mbLeftButton = true; + SvxColorValueSet::MouseButtonDown( rMEvt ); } else { - bLeft = sal_False; + mbLeftButton = false; MouseEvent aMEvt( rMEvt.GetPosPixel(), rMEvt.GetClicks(), rMEvt.GetMode(), MOUSE_LEFT, rMEvt.GetModifier() ); - ValueSet::MouseButtonDown( aMEvt ); + SvxColorValueSet::MouseButtonDown( aMEvt ); } aDragPosPixel = GetPointerPosPixel(); @@ -134,27 +132,27 @@ void SvxColorValueSet::MouseButtonDown( const MouseEvent& rMEvt ) /************************************************************************* |* -|* SvxColorValueSet: MouseButtonUp +|* SvxColorValueSet_docking: MouseButtonUp |* \************************************************************************/ -void SvxColorValueSet::MouseButtonUp( const MouseEvent& rMEvt ) +void SvxColorValueSet_docking::MouseButtonUp( const MouseEvent& rMEvt ) { // Fuer Mac noch anders handlen ! if( rMEvt.IsLeft() ) { - bLeft = sal_True; - ValueSet::MouseButtonUp( rMEvt ); + mbLeftButton = true; + SvxColorValueSet::MouseButtonUp( rMEvt ); } else { - bLeft = sal_False; + mbLeftButton = false; MouseEvent aMEvt( rMEvt.GetPosPixel(), rMEvt.GetClicks(), rMEvt.GetMode(), MOUSE_LEFT, rMEvt.GetModifier() ); - ValueSet::MouseButtonUp( aMEvt ); + SvxColorValueSet::MouseButtonUp( aMEvt ); } SetNoSelection(); } @@ -165,10 +163,10 @@ void SvxColorValueSet::MouseButtonUp( const MouseEvent& rMEvt ) |* \************************************************************************/ -void SvxColorValueSet::Command(const CommandEvent& rCEvt) +void SvxColorValueSet_docking::Command(const CommandEvent& rCEvt) { // Basisklasse - ValueSet::Command(rCEvt); + SvxColorValueSet::Command(rCEvt); } /************************************************************************* @@ -177,9 +175,9 @@ void SvxColorValueSet::Command(const CommandEvent& rCEvt) |* \************************************************************************/ -void SvxColorValueSet::StartDrag( sal_Int8 , const Point& ) +void SvxColorValueSet_docking::StartDrag( sal_Int8 , const Point& ) { - Application::PostUserEvent(STATIC_LINK(this, SvxColorValueSet, ExecDragHdl)); + Application::PostUserEvent(STATIC_LINK(this, SvxColorValueSet_docking, ExecDragHdl)); } /************************************************************************* @@ -188,7 +186,7 @@ void SvxColorValueSet::StartDrag( sal_Int8 , const Point& ) |* \************************************************************************/ -void SvxColorValueSet::DoDrag() +void SvxColorValueSet_docking::DoDrag() { SfxObjectShell* pDocSh = SfxObjectShell::Current(); sal_uInt16 nItemId = GetItemId( aDragPosPixel ); @@ -207,7 +205,7 @@ void SvxColorValueSet::DoDrag() } } -IMPL_STATIC_LINK(SvxColorValueSet, ExecDragHdl, void*, EMPTYARG) +IMPL_STATIC_LINK(SvxColorValueSet_docking, ExecDragHdl, void*, EMPTYARG) { // Als Link, damit asynchron ohne ImpMouseMoveMsg auf dem Stack auch die // Farbleiste geloescht werden darf @@ -217,29 +215,6 @@ IMPL_STATIC_LINK(SvxColorValueSet, ExecDragHdl, void*, EMPTYARG) /************************************************************************* |* -|* Ableitung vom SfxChildWindow als "Behaelter" fuer Animator -|* -\************************************************************************/ - -SvxColorChildWindow::SvxColorChildWindow( Window* _pParent, - sal_uInt16 nId, - SfxBindings* pBindings, - SfxChildWinInfo* pInfo ) : - SfxChildWindow( _pParent, nId ) -{ - SvxColorDockingWindow* pWin = new SvxColorDockingWindow( pBindings, this, - _pParent, SVX_RES( RID_SVXCTRL_COLOR ) ); - pWindow = pWin; - - eChildAlignment = SFX_ALIGN_BOTTOM; - - pWin->Initialize( pInfo ); -} - - - -/************************************************************************* -|* |* Ctor: SvxColorDockingWindow |* \************************************************************************/ @@ -258,8 +233,7 @@ SvxColorDockingWindow::SvxColorDockingWindow nLeftSlot ( SID_ATTR_FILL_COLOR ), nRightSlot ( SID_ATTR_LINE_COLOR ), nCols ( 20 ), - nLines ( 1 ), - aColorSize ( 14, 14 ) + nLines ( 1 ) { FreeResource(); @@ -294,10 +268,11 @@ SvxColorDockingWindow::SvxColorDockingWindow FillValueSet(); } } - aItemSize = aColorSet.CalcItemSizePixel( aColorSize ); - aItemSize.Width() = aItemSize.Width() + aColorSize.Width(); + + aItemSize = aColorSet.CalcItemSizePixel(Size(aColorSet.getEntryEdgeLength(), aColorSet.getEntryEdgeLength())); + aItemSize.Width() = aItemSize.Width() + aColorSet.getEntryEdgeLength(); aItemSize.Width() /= 2; - aItemSize.Height() = aItemSize.Height() + aColorSize.Height(); + aItemSize.Height() = aItemSize.Height() + aColorSet.getEntryEdgeLength(); aItemSize.Height() /= 2; SetSize(); @@ -345,12 +320,15 @@ void SvxColorDockingWindow::FillValueSet() { if( pColorList.is() ) { + nCount = pColorList->Count(); aColorSet.Clear(); - // Erster Eintrag: unsichtbar + // create the first entry for 'invisible/none' + const Size aColorSize(aColorSet.getEntryEdgeLength(), aColorSet.getEntryEdgeLength()); long nPtX = aColorSize.Width() - 1; long nPtY = aColorSize.Height() - 1; VirtualDevice aVD; + aVD.SetOutputSizePixel( aColorSize ); aVD.SetLineColor( Color( COL_BLACK ) ); aVD.SetBackground( Wallpaper( Color( COL_WHITE ) ) ); @@ -361,15 +339,7 @@ void SvxColorDockingWindow::FillValueSet() aColorSet.InsertItem( (sal_uInt16)1, Image(aBmp), SVX_RESSTR( RID_SVXSTR_INVISIBLE ) ); - XColorEntry* pEntry; - nCount = pColorList->Count(); - - for( long i = 0; i < nCount; i++ ) - { - pEntry = pColorList->GetColor( i ); - aColorSet.InsertItem( (sal_uInt16)i+2, - pEntry->GetColor(), pEntry->GetName() ); - } + aColorSet.addEntriesForXColorList(*pColorList, 2); } } diff --git a/svx/source/tbxctrls/tbcontrl.cxx b/svx/source/tbxctrls/tbcontrl.cxx index 981e9fbdc1df..e58ddaef6e8f 100644 --- a/svx/source/tbxctrls/tbcontrl.cxx +++ b/svx/source/tbxctrls/tbcontrl.cxx @@ -1065,10 +1065,6 @@ void SvxFontNameBox_Impl::Select() #define WB_NO_DIRECTSELECT ((WinBits)0x04000000) #endif -#define PALETTE_X 8 -#define PALETTE_Y 13 -#define PALETTE_SIZE (PALETTE_X * PALETTE_Y) - SvxColorWindow_Impl::SvxColorWindow_Impl( const OUString& rCommand, sal_uInt16 nSlotId, const Reference< XFrame >& rFrame, @@ -1087,7 +1083,6 @@ SvxColorWindow_Impl::SvxColorWindow_Impl( const OUString& rCommand, SfxObjectShell* pDocSh = SfxObjectShell::Current(); const SfxPoolItem* pItem = NULL; XColorListRef pColorList; - const Size aSize12( 13, 13 ); if ( pDocSh ) if ( 0 != ( pItem = pDocSh->GetItem( SID_COLOR_TABLE ) ) ) @@ -1125,41 +1120,19 @@ SvxColorWindow_Impl::SvxColorWindow_Impl( const OUString& rCommand, if ( pColorList.is() ) { - short i = 0; - long nCount = pColorList->Count(); - XColorEntry* pEntry = NULL; - ::Color aColWhite( COL_WHITE ); - String aStrWhite( EditResId(RID_SVXITEMS_COLOR_WHITE) ); - - if ( nCount > PALETTE_SIZE ) - // Show scrollbar if more than PALLETTE_SIZE colors are available - aColorSet.SetStyle( aColorSet.GetStyle() | WB_VSCROLL ); - - for ( i = 0; i < nCount; i++ ) - { - pEntry = pColorList->GetColor(i); - aColorSet.InsertItem( i+1, pEntry->GetColor(), pEntry->GetName() ); - if( pEntry->GetColor() == mLastColor ) - aColorSet.SelectItem( i+1 ); - } + const long nColorCount(pColorList->Count()); + const Size aNewSize(aColorSet.layoutAllVisible(nColorCount)); + aColorSet.SetOutputSizePixel(aNewSize); + static sal_Int32 nAdd = 4; - while ( i < PALETTE_SIZE ) - { - // fill empty elements if less then PALLETTE_SIZE colors are available - aColorSet.InsertItem( i+1, aColWhite, aStrWhite ); - i++; - } + SetOutputSizePixel(Size(aNewSize.Width() + nAdd, aNewSize.Height() + nAdd)); + aColorSet.Clear(); + aColorSet.addEntriesForXColorList(*pColorList); } aColorSet.SetSelectHdl( LINK( this, SvxColorWindow_Impl, SelectHdl ) ); - aColorSet.SetColCount( PALETTE_X ); - aColorSet.SetLineCount( PALETTE_Y ); - - lcl_CalcSizeValueSet( *this, aColorSet, aSize12 ); - SetHelpId( HID_POPUP_COLOR ); aColorSet.SetHelpId( HID_POPUP_COLOR_CTRL ); - SetText( rWndTitle ); aColorSet.Show(); @@ -1264,34 +1237,14 @@ void SvxColorWindow_Impl::StateChanged( sal_uInt16 nSID, SfxItemState eState, co if ( pState ) { XColorListRef pColorList = ((SvxColorListItem *)pState)->GetColorList(); - - short i = 0; - long nCount = pColorList->Count(); - XColorEntry* pEntry = NULL; - ::Color aColWhite( COL_WHITE ); - String aStrWhite( EditResId(RID_SVXITEMS_COLOR_WHITE) ); - - // ScrollBar on or off - WinBits nBits = aColorSet.GetStyle(); - if ( nCount > PALETTE_SIZE ) - nBits &= ~WB_VSCROLL; - else - nBits |= WB_VSCROLL; - aColorSet.SetStyle( nBits ); - - for ( i = 0; i < nCount; ++i ) - { - pEntry = pColorList->GetColor(i); - aColorSet.SetItemColor( i + 1, pEntry->GetColor() ); - aColorSet.SetItemText ( i + 1, pEntry->GetName() ); - } - - while ( i < PALETTE_SIZE ) - { - aColorSet.SetItemColor( i + 1, aColWhite ); - aColorSet.SetItemText ( i + 1, aStrWhite ); - i++; - } + const long nColorCount(pColorList->Count()); + const Size aNewSize(aColorSet.layoutAllVisible(nColorCount)); + aColorSet.SetOutputSizePixel(aNewSize); + static sal_Int32 nAdd = 4; + + SetOutputSizePixel(Size(aNewSize.Width() + nAdd, aNewSize.Height() + nAdd)); + aColorSet.Clear(); + aColorSet.addEntriesForXColorList(*pColorList); } } } |