diff options
author | Krisztian Pinter <pin.terminator@gmail.com> | 2014-07-08 19:08:38 +0200 |
---|---|---|
committer | Krisztian Pinter <pin.terminator@gmail.com> | 2014-07-25 17:16:38 +0200 |
commit | ba8b80f996bd2022a1ff072b93df823bbbae73cc (patch) | |
tree | 2a45a5d281f01a3f8ac7f6b130dd56ec4fdd7f63 /svx/source | |
parent | 6ad7cd500108adb452ada83ecf59dbd4a4f58ff5 (diff) |
Add color picker to color palette
Change-Id: I651f485598ee57af815780e234031f101b63fa24
Diffstat (limited to 'svx/source')
-rw-r--r-- | svx/source/tbxctrls/PaletteManager.cxx | 31 | ||||
-rw-r--r-- | svx/source/tbxctrls/colorwindow.hxx | 2 | ||||
-rw-r--r-- | svx/source/tbxctrls/tbcontrl.cxx | 52 |
3 files changed, 67 insertions, 18 deletions
diff --git a/svx/source/tbxctrls/PaletteManager.cxx b/svx/source/tbxctrls/PaletteManager.cxx index 88916ee85fc7..e9933d4eff96 100644 --- a/svx/source/tbxctrls/PaletteManager.cxx +++ b/svx/source/tbxctrls/PaletteManager.cxx @@ -23,11 +23,13 @@ #include <sfx2/objsh.hxx> #include "svx/drawitem.hxx" #include <svx/dialogs.hrc> +#include <svtools/colrdlg.hxx> PaletteManager::PaletteManager() : mnNumOfPalettes(2), mnCurrentPalette(0), - mnColorCount(0) + mnColorCount(0), + mLastColor(COL_AUTO) { LoadPalettes(); mnNumOfPalettes += maPalettes.size(); @@ -127,4 +129,31 @@ OUString PaletteManager::GetPaletteName() return OStringToOUString(maPalettes[mnCurrentPalette - 1].GetPaletteName(), RTL_TEXTENCODING_ASCII_US); } +const Color& PaletteManager::GetLastColor() +{ + return mLastColor; +} + +void PaletteManager::SetLastColor(const Color& rLastColor) +{ + mLastColor = rLastColor; +} + +void PaletteManager::SetBtnUpdater(svx::ToolboxButtonColorUpdater* pBtnUpdater) +{ + mpBtnUpdater = pBtnUpdater; +} + +void PaletteManager::PopupColorPicker() +{ + SvColorDialog aColorDlg( 0 ); + aColorDlg.SetColor ( mLastColor ); + aColorDlg.SetMode( svtools::ColorPickerMode_MODIFY ); + if( aColorDlg.Execute() == RET_OK ) + { + mpBtnUpdater->Update( aColorDlg.GetColor() ); + mLastColor = aColorDlg.GetColor(); + } +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/tbxctrls/colorwindow.hxx b/svx/source/tbxctrls/colorwindow.hxx index 3e19796ad8af..fe8fe8d27e33 100644 --- a/svx/source/tbxctrls/colorwindow.hxx +++ b/svx/source/tbxctrls/colorwindow.hxx @@ -44,6 +44,7 @@ private: SvxColorValueSet aColorSet; PushButton aButtonLeft; PushButton aButtonRight; + PushButton aButtonPicker; FixedText aPaletteName; OUString maCommand; Link maSelectedLink; @@ -57,6 +58,7 @@ private: DECL_LINK( SelectHdl, void * ); DECL_LINK( StepLeftClickHdl, void * ); DECL_LINK( StepRightClickHdl, void * ); + DECL_LINK( OpenPickerClickHdl, void * ); protected: virtual void Resize() SAL_OVERRIDE; diff --git a/svx/source/tbxctrls/tbcontrl.cxx b/svx/source/tbxctrls/tbcontrl.cxx index e41370c49e17..b3360a545d88 100644 --- a/svx/source/tbxctrls/tbcontrl.cxx +++ b/svx/source/tbxctrls/tbcontrl.cxx @@ -1027,6 +1027,7 @@ SvxColorWindow_Impl::SvxColorWindow_Impl( const OUString& rCommand, aColorSet ( this, WinBits( WB_ITEMBORDER | WB_NAMEFIELD | WB_3DLOOK | WB_NO_DIRECTSELECT) ), aButtonLeft ( this ), aButtonRight( this ), + aButtonPicker( this ), aPaletteName( this ), maCommand( rCommand ), nNavButtonWidth ( 20 ), @@ -1066,18 +1067,27 @@ SvxColorWindow_Impl::SvxColorWindow_Impl( const OUString& rCommand, } aButtonLeft.SetText("<"); + aButtonLeft.SetSizePixel(Size(nNavButtonWidth, nNavButtonHeight)); aButtonLeft.SetClickHdl( LINK( this, SvxColorWindow_Impl, StepLeftClickHdl ) ); aButtonLeft.Show(); aButtonRight.SetText(">"); + aButtonRight.SetSizePixel(Size(nNavButtonWidth, nNavButtonHeight)); aButtonRight.SetClickHdl( LINK( this, SvxColorWindow_Impl, StepRightClickHdl ) ); aButtonRight.Show(); + aButtonPicker.SetText("P"); + aButtonPicker.SetSizePixel(Size(nNavButtonWidth, nNavButtonHeight)); + aButtonPicker.SetClickHdl( LINK( this, SvxColorWindow_Impl, OpenPickerClickHdl ) ); + aButtonPicker.Show(); + + aPaletteName.SetSizePixel(Size(150, nNavButtonHeight)); + aColorSet.Show(); + aColorSet.SetSelectHdl( LINK( this, SvxColorWindow_Impl, SelectHdl ) ); SetHelpId( HID_POPUP_COLOR ); aColorSet.SetHelpId( HID_POPUP_COLOR_CTRL ); SetText( rWndTitle ); - aColorSet.Show(); aPaletteName.Show(); @@ -1099,13 +1109,12 @@ void SvxColorWindow_Impl::UpdateGUI() //TODO: Move left/right buttons above the colors SetOutputSizePixel(Size(aNewSize.Width() + nAdd, aNewSize.Height() + nAdd + nNavButtonHeight)); - aButtonLeft.SetSizePixel(Size(nNavButtonWidth, nNavButtonHeight)); aButtonLeft.SetPosPixel(Point(0, aNewSize.Height() + nAdd + 1)); - aButtonRight.SetSizePixel(Size(nNavButtonWidth, nNavButtonHeight)); aButtonRight.SetPosPixel(Point(aNewSize.Width() + nAdd - nNavButtonWidth, aNewSize.Height() + nAdd + 1)); - aPaletteName.SetSizePixel(Size(150, nNavButtonHeight)); + aButtonPicker.SetPosPixel(Point(aNewSize.Width() + nAdd - 2 * nNavButtonWidth, aNewSize.Height() + nAdd + 1)); + aPaletteName.SetPosPixel(Point(nNavButtonWidth, aNewSize.Height() + nAdd + 1)); aPaletteName.SetText(mrPaletteManager.GetPaletteName()); } @@ -1175,6 +1184,12 @@ IMPL_LINK_NOARG(SvxColorWindow_Impl, StepRightClickHdl) return 0; } +IMPL_LINK_NOARG(SvxColorWindow_Impl, OpenPickerClickHdl) +{ + mrPaletteManager.PopupColorPicker(); + return 0; +} + void SvxColorWindow_Impl::Resize() { lcl_ResizeValueSet( *this, aColorSet, nNavButtonHeight + 2); @@ -2199,8 +2214,7 @@ SvxColorToolBoxControl::SvxColorToolBoxControl( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx ) : - SfxToolBoxControl( nSlotId, nId, rTbx ), - mLastColor( COL_AUTO ) + SfxToolBoxControl( nSlotId, nId, rTbx ) { rTbx.SetItemBits( nId, TIB_DROPDOWN | rTbx.GetItemBits( nId ) ); @@ -2209,27 +2223,27 @@ SvxColorToolBoxControl::SvxColorToolBoxControl( { case SID_ATTR_CHAR_COLOR: addStatusListener( OUString( ".uno:Color" )); - mLastColor = COL_RED; + mPaletteManager.SetLastColor( COL_RED ); break; case SID_ATTR_CHAR_COLOR2: addStatusListener( OUString( ".uno:CharColorExt" )); - mLastColor = COL_RED; + mPaletteManager.SetLastColor( COL_RED ); break; case SID_BACKGROUND_COLOR: addStatusListener( OUString( ".uno:BackgroundColor" )); - mLastColor = COL_YELLOW; + mPaletteManager.SetLastColor( COL_YELLOW ); break; case SID_ATTR_CHAR_COLOR_BACKGROUND: addStatusListener( OUString( ".uno:CharBackgroundExt" )); - mLastColor = COL_YELLOW; + mPaletteManager.SetLastColor( COL_YELLOW ); break; case SID_FRAME_LINECOLOR: addStatusListener( OUString( ".uno:FrameLineColor" )); - mLastColor = COL_BLUE; + mPaletteManager.SetLastColor( COL_BLUE ); break; case SID_EXTRUSION_3D_COLOR: @@ -2238,6 +2252,7 @@ SvxColorToolBoxControl::SvxColorToolBoxControl( } pBtnUpdater.reset( new ::svx::ToolboxButtonColorUpdater( nSlotId, nId, &GetToolBox() ) ); + mPaletteManager.SetBtnUpdater( pBtnUpdater.get() ); } SvxColorToolBoxControl::~SvxColorToolBoxControl() @@ -2290,7 +2305,7 @@ SfxPopupWindow* SvxColorToolBoxControl::CreatePopupWindow() IMPL_LINK(SvxColorToolBoxControl, SelectedHdl, Color*, pColor) { pBtnUpdater->Update( *pColor ); - mLastColor = *pColor; + mPaletteManager.SetLastColor( *pColor ); return 0; } @@ -2352,21 +2367,24 @@ void SvxColorToolBoxControl::Select(sal_uInt16 /*nSelectModifier*/) Sequence< PropertyValue > aArgs( 1 ); aArgs[0].Name = aParamName; - aArgs[0].Value = makeAny( (sal_uInt32)( mLastColor.GetColor() )); + aArgs[0].Value = makeAny( (sal_uInt32)( mPaletteManager.GetLastColor().GetColor() )); Dispatch( aCommand, aArgs ); } +// class SvxLineColorToolBoxControl ---------------------------------------- + SvxLineColorToolBoxControl::SvxLineColorToolBoxControl( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx ) : - SfxToolBoxControl( nSlotId, nId, rTbx ), - mLastColor( COL_BLACK ) + SfxToolBoxControl( nSlotId, nId, rTbx ) { rTbx.SetItemBits( nId, TIB_DROPDOWN | rTbx.GetItemBits( nId ) ); addStatusListener( OUString( ".uno:XLineColor" ) ); pBtnUpdater.reset( new ::svx::ToolboxButtonColorUpdater( nSlotId, nId, &GetToolBox() ) ); + mPaletteManager.SetLastColor( COL_BLACK ); + mPaletteManager.SetBtnUpdater( pBtnUpdater.get() ); } SvxLineColorToolBoxControl::~SvxLineColorToolBoxControl() @@ -2400,7 +2418,7 @@ SfxPopupWindow* SvxLineColorToolBoxControl::CreatePopupWindow() IMPL_LINK(SvxLineColorToolBoxControl, SelectedHdl, Color*, pColor) { pBtnUpdater->Update( *pColor ); - mLastColor = *pColor; + mPaletteManager.SetLastColor( *pColor ); return 0; } @@ -2417,7 +2435,7 @@ void SvxLineColorToolBoxControl::Select(sal_uInt16 /*nSelectModifier*/) { Sequence< PropertyValue > aArgs( 1 ); aArgs[0].Name = "XLineColor"; - aArgs[0].Value = makeAny( (sal_uInt32)( mLastColor.GetColor() )); + aArgs[0].Value = makeAny( (sal_uInt32)( mPaletteManager.GetLastColor().GetColor() )); Dispatch( OUString( ".uno:XLineColor" ), aArgs ); } |