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 @@
#include <svx/SvxColorValueSet.hxx>
#include <rtl/ustring.hxx>
#include <svx/tbxcolorupdate.hxx>
class PaletteManager
{
......@@ -28,7 +29,9 @@ class PaletteManager
sal_uInt16 mnCurrentPalette;
long mnColorCount;
svx::ToolboxButtonColorUpdater* mpBtnUpdater;
Color mLastColor;
std::vector<Palette> maPalettes;
public:
PaletteManager();
......@@ -38,6 +41,10 @@ public:
void NextPalette();
long GetColorCount();
OUString GetPaletteName();
const Color& GetLastColor();
void SetLastColor(const Color& rLastColor);
void SetBtnUpdater(svx::ToolboxButtonColorUpdater* pBtnUpdater);
void PopupColorPicker();
};
#endif // INCLUDED_SVX_PALETTEMANAGER_HXX
......
......@@ -221,7 +221,6 @@ class SVX_DLLPUBLIC SvxColorToolBoxControl : public SfxToolBoxControl
using SfxToolBoxControl::StateChanged;
::boost::scoped_ptr< ::svx::ToolboxButtonColorUpdater > pBtnUpdater;
Color mLastColor;
PaletteManager mPaletteManager;
DECL_LINK( SelectedHdl, Color* );
public:
......@@ -242,7 +241,6 @@ public:
class SVX_DLLPUBLIC SvxLineColorToolBoxControl : public SfxToolBoxControl
{
::boost::scoped_ptr< ::svx::ToolboxButtonColorUpdater > pBtnUpdater;
Color mLastColor;
PaletteManager mPaletteManager;
DECL_LINK( SelectedHdl, Color* );
public:
......
......@@ -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: */
......@@ -37,6 +37,7 @@ private:
SvxColorValueSet aColorSet;
PushButton aButtonLeft;
PushButton aButtonRight;
PushButton aButtonPicker;
FixedText aPaletteName;
OUString maCommand;
Link maSelectedLink;
......@@ -50,6 +51,7 @@ private:
DECL_LINK( SelectHdl, void * );
DECL_LINK( StepLeftClickHdl, void * );
DECL_LINK( StepRightClickHdl, void * );
DECL_LINK( OpenPickerClickHdl, void * );
protected:
virtual void Resize() SAL_OVERRIDE;
......
......@@ -1011,6 +1011,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 ),
......@@ -1050,18 +1051,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();
......@@ -1083,13 +1093,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());
}
......@@ -1159,6 +1168,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);
......@@ -2183,8 +2198,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 ) );
......@@ -2193,27 +2207,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:
......@@ -2222,6 +2236,7 @@ SvxColorToolBoxControl::SvxColorToolBoxControl(
}
pBtnUpdater.reset( new ::svx::ToolboxButtonColorUpdater( nSlotId, nId, &GetToolBox() ) );
mPaletteManager.SetBtnUpdater( pBtnUpdater.get() );
}
SvxColorToolBoxControl::~SvxColorToolBoxControl()
......@@ -2274,7 +2289,7 @@ SfxPopupWindow* SvxColorToolBoxControl::CreatePopupWindow()
IMPL_LINK(SvxColorToolBoxControl, SelectedHdl, Color*, pColor)
{
pBtnUpdater->Update( *pColor );
mLastColor = *pColor;
mPaletteManager.SetLastColor( *pColor );
return 0;
}
......@@ -2336,21 +2351,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()
......@@ -2384,7 +2402,7 @@ SfxPopupWindow* SvxLineColorToolBoxControl::CreatePopupWindow()
IMPL_LINK(SvxLineColorToolBoxControl, SelectedHdl, Color*, pColor)
{
pBtnUpdater->Update( *pColor );
mLastColor = *pColor;
mPaletteManager.SetLastColor( *pColor );
return 0;
}
......@@ -2401,7 +2419,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 );
}
......
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