Kaydet (Commit) ff17738a authored tarafından Krisztian Pinter's avatar Krisztian Pinter Kaydeden (comit) Tomaž Vajngerl

Add color picker to color palette

Change-Id: I651f485598ee57af815780e234031f101b63fa24
üst 9ab1a4a0
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include <svx/SvxColorValueSet.hxx> #include <svx/SvxColorValueSet.hxx>
#include <rtl/ustring.hxx> #include <rtl/ustring.hxx>
#include <svx/tbxcolorupdate.hxx>
class PaletteManager class PaletteManager
{ {
...@@ -28,7 +29,9 @@ class PaletteManager ...@@ -28,7 +29,9 @@ class PaletteManager
sal_uInt16 mnCurrentPalette; sal_uInt16 mnCurrentPalette;
long mnColorCount; long mnColorCount;
svx::ToolboxButtonColorUpdater* mpBtnUpdater;
Color mLastColor;
std::vector<Palette> maPalettes; std::vector<Palette> maPalettes;
public: public:
PaletteManager(); PaletteManager();
...@@ -38,6 +41,10 @@ public: ...@@ -38,6 +41,10 @@ public:
void NextPalette(); void NextPalette();
long GetColorCount(); long GetColorCount();
OUString GetPaletteName(); OUString GetPaletteName();
const Color& GetLastColor();
void SetLastColor(const Color& rLastColor);
void SetBtnUpdater(svx::ToolboxButtonColorUpdater* pBtnUpdater);
void PopupColorPicker();
}; };
#endif // INCLUDED_SVX_PALETTEMANAGER_HXX #endif // INCLUDED_SVX_PALETTEMANAGER_HXX
......
...@@ -221,7 +221,6 @@ class SVX_DLLPUBLIC SvxColorToolBoxControl : public SfxToolBoxControl ...@@ -221,7 +221,6 @@ class SVX_DLLPUBLIC SvxColorToolBoxControl : public SfxToolBoxControl
using SfxToolBoxControl::StateChanged; using SfxToolBoxControl::StateChanged;
::boost::scoped_ptr< ::svx::ToolboxButtonColorUpdater > pBtnUpdater; ::boost::scoped_ptr< ::svx::ToolboxButtonColorUpdater > pBtnUpdater;
Color mLastColor;
PaletteManager mPaletteManager; PaletteManager mPaletteManager;
DECL_LINK( SelectedHdl, Color* ); DECL_LINK( SelectedHdl, Color* );
public: public:
...@@ -242,7 +241,6 @@ public: ...@@ -242,7 +241,6 @@ public:
class SVX_DLLPUBLIC SvxLineColorToolBoxControl : public SfxToolBoxControl class SVX_DLLPUBLIC SvxLineColorToolBoxControl : public SfxToolBoxControl
{ {
::boost::scoped_ptr< ::svx::ToolboxButtonColorUpdater > pBtnUpdater; ::boost::scoped_ptr< ::svx::ToolboxButtonColorUpdater > pBtnUpdater;
Color mLastColor;
PaletteManager mPaletteManager; PaletteManager mPaletteManager;
DECL_LINK( SelectedHdl, Color* ); DECL_LINK( SelectedHdl, Color* );
public: public:
......
...@@ -23,11 +23,13 @@ ...@@ -23,11 +23,13 @@
#include <sfx2/objsh.hxx> #include <sfx2/objsh.hxx>
#include "svx/drawitem.hxx" #include "svx/drawitem.hxx"
#include <svx/dialogs.hrc> #include <svx/dialogs.hrc>
#include <svtools/colrdlg.hxx>
PaletteManager::PaletteManager() : PaletteManager::PaletteManager() :
mnNumOfPalettes(2), mnNumOfPalettes(2),
mnCurrentPalette(0), mnCurrentPalette(0),
mnColorCount(0) mnColorCount(0),
mLastColor(COL_AUTO)
{ {
LoadPalettes(); LoadPalettes();
mnNumOfPalettes += maPalettes.size(); mnNumOfPalettes += maPalettes.size();
...@@ -127,4 +129,31 @@ OUString PaletteManager::GetPaletteName() ...@@ -127,4 +129,31 @@ OUString PaletteManager::GetPaletteName()
return OStringToOUString(maPalettes[mnCurrentPalette - 1].GetPaletteName(), RTL_TEXTENCODING_ASCII_US); 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: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -37,6 +37,7 @@ private: ...@@ -37,6 +37,7 @@ private:
SvxColorValueSet aColorSet; SvxColorValueSet aColorSet;
PushButton aButtonLeft; PushButton aButtonLeft;
PushButton aButtonRight; PushButton aButtonRight;
PushButton aButtonPicker;
FixedText aPaletteName; FixedText aPaletteName;
OUString maCommand; OUString maCommand;
Link maSelectedLink; Link maSelectedLink;
...@@ -50,6 +51,7 @@ private: ...@@ -50,6 +51,7 @@ private:
DECL_LINK( SelectHdl, void * ); DECL_LINK( SelectHdl, void * );
DECL_LINK( StepLeftClickHdl, void * ); DECL_LINK( StepLeftClickHdl, void * );
DECL_LINK( StepRightClickHdl, void * ); DECL_LINK( StepRightClickHdl, void * );
DECL_LINK( OpenPickerClickHdl, void * );
protected: protected:
virtual void Resize() SAL_OVERRIDE; virtual void Resize() SAL_OVERRIDE;
......
...@@ -1011,6 +1011,7 @@ SvxColorWindow_Impl::SvxColorWindow_Impl( const OUString& rCommand, ...@@ -1011,6 +1011,7 @@ SvxColorWindow_Impl::SvxColorWindow_Impl( const OUString& rCommand,
aColorSet ( this, WinBits( WB_ITEMBORDER | WB_NAMEFIELD | WB_3DLOOK | WB_NO_DIRECTSELECT) ), aColorSet ( this, WinBits( WB_ITEMBORDER | WB_NAMEFIELD | WB_3DLOOK | WB_NO_DIRECTSELECT) ),
aButtonLeft ( this ), aButtonLeft ( this ),
aButtonRight( this ), aButtonRight( this ),
aButtonPicker( this ),
aPaletteName( this ), aPaletteName( this ),
maCommand( rCommand ), maCommand( rCommand ),
nNavButtonWidth ( 20 ), nNavButtonWidth ( 20 ),
...@@ -1050,18 +1051,27 @@ SvxColorWindow_Impl::SvxColorWindow_Impl( const OUString& rCommand, ...@@ -1050,18 +1051,27 @@ SvxColorWindow_Impl::SvxColorWindow_Impl( const OUString& rCommand,
} }
aButtonLeft.SetText("<"); aButtonLeft.SetText("<");
aButtonLeft.SetSizePixel(Size(nNavButtonWidth, nNavButtonHeight));
aButtonLeft.SetClickHdl( LINK( this, SvxColorWindow_Impl, StepLeftClickHdl ) ); aButtonLeft.SetClickHdl( LINK( this, SvxColorWindow_Impl, StepLeftClickHdl ) );
aButtonLeft.Show(); aButtonLeft.Show();
aButtonRight.SetText(">"); aButtonRight.SetText(">");
aButtonRight.SetSizePixel(Size(nNavButtonWidth, nNavButtonHeight));
aButtonRight.SetClickHdl( LINK( this, SvxColorWindow_Impl, StepRightClickHdl ) ); aButtonRight.SetClickHdl( LINK( this, SvxColorWindow_Impl, StepRightClickHdl ) );
aButtonRight.Show(); 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 ) ); aColorSet.SetSelectHdl( LINK( this, SvxColorWindow_Impl, SelectHdl ) );
SetHelpId( HID_POPUP_COLOR ); SetHelpId( HID_POPUP_COLOR );
aColorSet.SetHelpId( HID_POPUP_COLOR_CTRL ); aColorSet.SetHelpId( HID_POPUP_COLOR_CTRL );
SetText( rWndTitle ); SetText( rWndTitle );
aColorSet.Show();
aPaletteName.Show(); aPaletteName.Show();
...@@ -1083,13 +1093,12 @@ void SvxColorWindow_Impl::UpdateGUI() ...@@ -1083,13 +1093,12 @@ void SvxColorWindow_Impl::UpdateGUI()
//TODO: Move left/right buttons above the colors //TODO: Move left/right buttons above the colors
SetOutputSizePixel(Size(aNewSize.Width() + nAdd, aNewSize.Height() + nAdd + nNavButtonHeight)); SetOutputSizePixel(Size(aNewSize.Width() + nAdd, aNewSize.Height() + nAdd + nNavButtonHeight));
aButtonLeft.SetSizePixel(Size(nNavButtonWidth, nNavButtonHeight));
aButtonLeft.SetPosPixel(Point(0, aNewSize.Height() + nAdd + 1)); aButtonLeft.SetPosPixel(Point(0, aNewSize.Height() + nAdd + 1));
aButtonRight.SetSizePixel(Size(nNavButtonWidth, nNavButtonHeight));
aButtonRight.SetPosPixel(Point(aNewSize.Width() + nAdd - nNavButtonWidth, aNewSize.Height() + nAdd + 1)); 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.SetPosPixel(Point(nNavButtonWidth, aNewSize.Height() + nAdd + 1));
aPaletteName.SetText(mrPaletteManager.GetPaletteName()); aPaletteName.SetText(mrPaletteManager.GetPaletteName());
} }
...@@ -1159,6 +1168,12 @@ IMPL_LINK_NOARG(SvxColorWindow_Impl, StepRightClickHdl) ...@@ -1159,6 +1168,12 @@ IMPL_LINK_NOARG(SvxColorWindow_Impl, StepRightClickHdl)
return 0; return 0;
} }
IMPL_LINK_NOARG(SvxColorWindow_Impl, OpenPickerClickHdl)
{
mrPaletteManager.PopupColorPicker();
return 0;
}
void SvxColorWindow_Impl::Resize() void SvxColorWindow_Impl::Resize()
{ {
lcl_ResizeValueSet( *this, aColorSet, nNavButtonHeight + 2); lcl_ResizeValueSet( *this, aColorSet, nNavButtonHeight + 2);
...@@ -2183,8 +2198,7 @@ SvxColorToolBoxControl::SvxColorToolBoxControl( ...@@ -2183,8 +2198,7 @@ SvxColorToolBoxControl::SvxColorToolBoxControl(
sal_uInt16 nSlotId, sal_uInt16 nSlotId,
sal_uInt16 nId, sal_uInt16 nId,
ToolBox& rTbx ) : ToolBox& rTbx ) :
SfxToolBoxControl( nSlotId, nId, rTbx ), SfxToolBoxControl( nSlotId, nId, rTbx )
mLastColor( COL_AUTO )
{ {
rTbx.SetItemBits( nId, TIB_DROPDOWN | rTbx.GetItemBits( nId ) ); rTbx.SetItemBits( nId, TIB_DROPDOWN | rTbx.GetItemBits( nId ) );
...@@ -2193,27 +2207,27 @@ SvxColorToolBoxControl::SvxColorToolBoxControl( ...@@ -2193,27 +2207,27 @@ SvxColorToolBoxControl::SvxColorToolBoxControl(
{ {
case SID_ATTR_CHAR_COLOR: case SID_ATTR_CHAR_COLOR:
addStatusListener( OUString( ".uno:Color" )); addStatusListener( OUString( ".uno:Color" ));
mLastColor = COL_RED; mPaletteManager.SetLastColor( COL_RED );
break; break;
case SID_ATTR_CHAR_COLOR2: case SID_ATTR_CHAR_COLOR2:
addStatusListener( OUString( ".uno:CharColorExt" )); addStatusListener( OUString( ".uno:CharColorExt" ));
mLastColor = COL_RED; mPaletteManager.SetLastColor( COL_RED );
break; break;
case SID_BACKGROUND_COLOR: case SID_BACKGROUND_COLOR:
addStatusListener( OUString( ".uno:BackgroundColor" )); addStatusListener( OUString( ".uno:BackgroundColor" ));
mLastColor = COL_YELLOW; mPaletteManager.SetLastColor( COL_YELLOW );
break; break;
case SID_ATTR_CHAR_COLOR_BACKGROUND: case SID_ATTR_CHAR_COLOR_BACKGROUND:
addStatusListener( OUString( ".uno:CharBackgroundExt" )); addStatusListener( OUString( ".uno:CharBackgroundExt" ));
mLastColor = COL_YELLOW; mPaletteManager.SetLastColor( COL_YELLOW );
break; break;
case SID_FRAME_LINECOLOR: case SID_FRAME_LINECOLOR:
addStatusListener( OUString( ".uno:FrameLineColor" )); addStatusListener( OUString( ".uno:FrameLineColor" ));
mLastColor = COL_BLUE; mPaletteManager.SetLastColor( COL_BLUE );
break; break;
case SID_EXTRUSION_3D_COLOR: case SID_EXTRUSION_3D_COLOR:
...@@ -2222,6 +2236,7 @@ SvxColorToolBoxControl::SvxColorToolBoxControl( ...@@ -2222,6 +2236,7 @@ SvxColorToolBoxControl::SvxColorToolBoxControl(
} }
pBtnUpdater.reset( new ::svx::ToolboxButtonColorUpdater( nSlotId, nId, &GetToolBox() ) ); pBtnUpdater.reset( new ::svx::ToolboxButtonColorUpdater( nSlotId, nId, &GetToolBox() ) );
mPaletteManager.SetBtnUpdater( pBtnUpdater.get() );
} }
SvxColorToolBoxControl::~SvxColorToolBoxControl() SvxColorToolBoxControl::~SvxColorToolBoxControl()
...@@ -2274,7 +2289,7 @@ SfxPopupWindow* SvxColorToolBoxControl::CreatePopupWindow() ...@@ -2274,7 +2289,7 @@ SfxPopupWindow* SvxColorToolBoxControl::CreatePopupWindow()
IMPL_LINK(SvxColorToolBoxControl, SelectedHdl, Color*, pColor) IMPL_LINK(SvxColorToolBoxControl, SelectedHdl, Color*, pColor)
{ {
pBtnUpdater->Update( *pColor ); pBtnUpdater->Update( *pColor );
mLastColor = *pColor; mPaletteManager.SetLastColor( *pColor );
return 0; return 0;
} }
...@@ -2336,21 +2351,24 @@ void SvxColorToolBoxControl::Select(sal_uInt16 /*nSelectModifier*/) ...@@ -2336,21 +2351,24 @@ void SvxColorToolBoxControl::Select(sal_uInt16 /*nSelectModifier*/)
Sequence< PropertyValue > aArgs( 1 ); Sequence< PropertyValue > aArgs( 1 );
aArgs[0].Name = aParamName; aArgs[0].Name = aParamName;
aArgs[0].Value = makeAny( (sal_uInt32)( mLastColor.GetColor() )); aArgs[0].Value = makeAny( (sal_uInt32)( mPaletteManager.GetLastColor().GetColor() ));
Dispatch( aCommand, aArgs ); Dispatch( aCommand, aArgs );
} }
// class SvxLineColorToolBoxControl ----------------------------------------
SvxLineColorToolBoxControl::SvxLineColorToolBoxControl( SvxLineColorToolBoxControl::SvxLineColorToolBoxControl(
sal_uInt16 nSlotId, sal_uInt16 nSlotId,
sal_uInt16 nId, sal_uInt16 nId,
ToolBox& rTbx ) : ToolBox& rTbx ) :
SfxToolBoxControl( nSlotId, nId, rTbx ), SfxToolBoxControl( nSlotId, nId, rTbx )
mLastColor( COL_BLACK )
{ {
rTbx.SetItemBits( nId, TIB_DROPDOWN | rTbx.GetItemBits( nId ) ); rTbx.SetItemBits( nId, TIB_DROPDOWN | rTbx.GetItemBits( nId ) );
addStatusListener( OUString( ".uno:XLineColor" ) ); addStatusListener( OUString( ".uno:XLineColor" ) );
pBtnUpdater.reset( new ::svx::ToolboxButtonColorUpdater( nSlotId, nId, &GetToolBox() ) ); pBtnUpdater.reset( new ::svx::ToolboxButtonColorUpdater( nSlotId, nId, &GetToolBox() ) );
mPaletteManager.SetLastColor( COL_BLACK );
mPaletteManager.SetBtnUpdater( pBtnUpdater.get() );
} }
SvxLineColorToolBoxControl::~SvxLineColorToolBoxControl() SvxLineColorToolBoxControl::~SvxLineColorToolBoxControl()
...@@ -2384,7 +2402,7 @@ SfxPopupWindow* SvxLineColorToolBoxControl::CreatePopupWindow() ...@@ -2384,7 +2402,7 @@ SfxPopupWindow* SvxLineColorToolBoxControl::CreatePopupWindow()
IMPL_LINK(SvxLineColorToolBoxControl, SelectedHdl, Color*, pColor) IMPL_LINK(SvxLineColorToolBoxControl, SelectedHdl, Color*, pColor)
{ {
pBtnUpdater->Update( *pColor ); pBtnUpdater->Update( *pColor );
mLastColor = *pColor; mPaletteManager.SetLastColor( *pColor );
return 0; return 0;
} }
...@@ -2401,7 +2419,7 @@ void SvxLineColorToolBoxControl::Select(sal_uInt16 /*nSelectModifier*/) ...@@ -2401,7 +2419,7 @@ void SvxLineColorToolBoxControl::Select(sal_uInt16 /*nSelectModifier*/)
{ {
Sequence< PropertyValue > aArgs( 1 ); Sequence< PropertyValue > aArgs( 1 );
aArgs[0].Name = "XLineColor"; 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 ); Dispatch( OUString( ".uno:XLineColor" ), aArgs );
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment