summaryrefslogtreecommitdiff
path: root/svx
diff options
context:
space:
mode:
Diffstat (limited to 'svx')
-rw-r--r--svx/source/tbxctrls/Palette.cxx3
-rw-r--r--svx/source/tbxctrls/PaletteManager.cxx32
-rw-r--r--svx/source/tbxctrls/colorwindow.hxx6
-rw-r--r--svx/source/tbxctrls/tbcontrl.cxx71
-rw-r--r--svx/uiconfig/ui/colorwindow.ui116
5 files changed, 190 insertions, 38 deletions
diff --git a/svx/source/tbxctrls/Palette.cxx b/svx/source/tbxctrls/Palette.cxx
index 496e0fcc678e..ba5bdbd908f4 100644
--- a/svx/source/tbxctrls/Palette.cxx
+++ b/svx/source/tbxctrls/Palette.cxx
@@ -52,10 +52,9 @@ void PaletteGPL::LoadColorSet( SvxColorValueSet& rColorSet )
rColorSet.Clear();
int nIx = 1;
- for(ColorList::const_iterator it = maColors.begin();
+ for(typename ColorList::const_iterator it = maColors.begin();
it != maColors.end(); ++it)
{
- // TODO make it->second OUString
rColorSet.InsertItem(nIx, it->first, it->second);
++nIx;
}
diff --git a/svx/source/tbxctrls/PaletteManager.cxx b/svx/source/tbxctrls/PaletteManager.cxx
index 98ae0b2dea29..101c00244fe3 100644
--- a/svx/source/tbxctrls/PaletteManager.cxx
+++ b/svx/source/tbxctrls/PaletteManager.cxx
@@ -30,6 +30,7 @@
#define STR_DOC_COLOR_PREFIX "Document Color "
PaletteManager::PaletteManager() :
+ mnMaxRecentColors(10),
mnNumOfPalettes(2),
mnCurrentPalette(0),
mnColorCount(0),
@@ -115,6 +116,18 @@ void PaletteManager::ReloadColorSet(SvxColorValueSet &rColorSet)
}
}
+void PaletteManager::ReloadRecentColorSet(SvxColorValueSet& rColorSet)
+{
+ rColorSet.Clear();
+ int nIx = 1;
+ for(std::deque<Color>::const_iterator it = maRecentColors.begin();
+ it != maRecentColors.end(); ++it)
+ {
+ rColorSet.InsertItem(nIx, *it, "");
+ ++nIx;
+ }
+}
+
std::vector<OUString> PaletteManager::GetPaletteList()
{
std::vector<OUString> aPaletteNames;
@@ -148,6 +161,11 @@ long PaletteManager::GetColorCount()
return mnColorCount;
}
+long PaletteManager::GetRecentColorCount()
+{
+ return maRecentColors.size();
+}
+
OUString PaletteManager::GetPaletteName()
{
if( mnCurrentPalette == 0 )
@@ -168,6 +186,19 @@ void PaletteManager::SetLastColor(const Color& rLastColor)
mLastColor = rLastColor;
}
+void PaletteManager::AddRecentColor(const Color& rRecentColor)
+{
+ std::deque<Color>::iterator itColor =
+ std::find(maRecentColors.begin(), maRecentColors.end(), rRecentColor);
+ // if recent color to be added is already in list, remove it
+ if( itColor != maRecentColors.end() )
+ maRecentColors.erase( itColor );
+
+ maRecentColors.push_front( rRecentColor );
+ if( maRecentColors.size() > mnMaxRecentColors )
+ maRecentColors.pop_back();
+}
+
void PaletteManager::SetBtnUpdater(svx::ToolboxButtonColorUpdater* pBtnUpdater)
{
mpBtnUpdater = pBtnUpdater;
@@ -182,6 +213,7 @@ void PaletteManager::PopupColorPicker(const OUString aCommand)
{
mpBtnUpdater->Update( aColorDlg.GetColor() );
mLastColor = aColorDlg.GetColor();
+ AddRecentColor( mLastColor );
DispatchColorCommand(aCommand, mLastColor);
}
}
diff --git a/svx/source/tbxctrls/colorwindow.hxx b/svx/source/tbxctrls/colorwindow.hxx
index 70db254f9de2..58073f282b9f 100644
--- a/svx/source/tbxctrls/colorwindow.hxx
+++ b/svx/source/tbxctrls/colorwindow.hxx
@@ -43,16 +43,22 @@ class SvxColorWindow_Impl : public SfxPopupWindow
private:
const sal_uInt16 theSlotId;
SvxColorValueSet* mpColorSet;
+ SvxColorValueSet* mpRecentColorSet;
Size maWindowSize;
ListBox* mpPaletteListBox;
+ PushButton* mpButtonAutoColor;
PushButton* mpButtonPicker;
OUString maCommand;
Link maSelectedLink;
PaletteManager& mrPaletteManager;
+ const sal_uInt16 mnColorSetCols;
+
DECL_LINK( SelectHdl, void * );
+ DECL_LINK( SelectRecentHdl, void * );
DECL_LINK( SelectPaletteHdl, void *);
+ DECL_LINK( AutoColorClickHdl, void * );
DECL_LINK( OpenPickerClickHdl, void * );
protected:
diff --git a/svx/source/tbxctrls/tbcontrl.cxx b/svx/source/tbxctrls/tbcontrl.cxx
index 446fb1e55830..e01af4a6b3dc 100644
--- a/svx/source/tbxctrls/tbcontrl.cxx
+++ b/svx/source/tbxctrls/tbcontrl.cxx
@@ -1027,18 +1027,27 @@ SvxColorWindow_Impl::SvxColorWindow_Impl( const OUString& rCommand,
theSlotId( nSlotId ),
maWindowSize( 250, 350 ),
maCommand( rCommand ),
- mrPaletteManager( rPaletteManager )
+ mrPaletteManager( rPaletteManager ),
+ mnColorSetCols( 10 )
{
get(mpPaletteListBox, "palette_listbox");
+ get(mpButtonAutoColor, "auto_color_button");
get(mpButtonPicker, "color_picker_button");
get(mpColorSet, "colorset");
+ get(mpRecentColorSet, "recent_colorset");
+
+ mpColorSet->SetStyle( WinBits(WB_FLATVALUESET | WB_ITEMBORDER | WB_3DLOOK | WB_NO_DIRECTSELECT) );
+ mpRecentColorSet->SetStyle( WinBits(WB_FLATVALUESET | WB_ITEMBORDER | WB_3DLOOK | WB_NO_DIRECTSELECT) );
+
+ mpColorSet->SetColCount( mnColorSetCols );
+ mpColorSet->layoutAllVisible(mrPaletteManager.GetColorCount());
+ mpRecentColorSet->SetColCount( mnColorSetCols );
+ mpRecentColorSet->SetLineCount( 1 );
+ mpRecentColorSet->layoutAllVisible(mrPaletteManager.GetRecentColorCount());
- mpColorSet->SetStyle( WinBits(WB_ITEMBORDER | WB_NAMEFIELD | WB_3DLOOK | WB_NO_DIRECTSELECT) );
- mpColorSet->SetEdgeBlending( false );
if ( SID_ATTR_CHAR_COLOR_BACKGROUND == theSlotId || SID_BACKGROUND_COLOR == theSlotId )
{
- mpColorSet->SetStyle( mpColorSet->GetStyle() | WB_NONEFIELD );
mpColorSet->SetText( SVX_RESSTR( RID_SVXSTR_TRANSPARENT ) );
mpColorSet->SetAccessibleName( SVX_RESSTR( RID_SVXSTR_BACKGROUND ) );
}
@@ -1053,7 +1062,6 @@ SvxColorWindow_Impl::SvxColorWindow_Impl( const OUString& rCommand,
SfxItemState eState = aQueryStatus.QueryState( pDummy );
if( (SFX_ITEM_DEFAULT > eState) || ( SID_EXTRUSION_3D_COLOR == theSlotId ) )
{
- mpColorSet->SetStyle( mpColorSet->GetStyle() | WB_NONEFIELD );
mpColorSet->SetText( SVX_RESSTR( RID_SVXSTR_AUTOMATIC ) );
mpColorSet->SetAccessibleName( SVX_RESSTR( RID_SVXSTR_TEXTCOLOR ) );
}
@@ -1077,9 +1085,11 @@ SvxColorWindow_Impl::SvxColorWindow_Impl( const OUString& rCommand,
}
mpPaletteListBox->SelectEntryPos(mrPaletteManager.GetPalette(), true);
+ mpButtonAutoColor->SetClickHdl( LINK( this, SvxColorWindow_Impl, AutoColorClickHdl ) );
mpButtonPicker->SetClickHdl( LINK( this, SvxColorWindow_Impl, OpenPickerClickHdl ) );
mpColorSet->SetSelectHdl( LINK( this, SvxColorWindow_Impl, SelectHdl ) );
+ mpRecentColorSet->SetSelectHdl( LINK( this, SvxColorWindow_Impl, SelectRecentHdl ) );
SetHelpId( HID_POPUP_COLOR );
mpColorSet->SetHelpId( HID_POPUP_COLOR_CTRL );
SetText( rWndTitle );
@@ -1087,9 +1097,7 @@ SvxColorWindow_Impl::SvxColorWindow_Impl( const OUString& rCommand,
AddStatusListener( maCommand );
mrPaletteManager.ReloadColorSet(*mpColorSet);
- mpPaletteListBox->Show();
- mpButtonPicker->Show();
- mpColorSet->Show();
+ mrPaletteManager.ReloadRecentColorSet(*mpRecentColorSet);
}
SvxColorWindow_Impl::~SvxColorWindow_Impl()
@@ -1129,6 +1137,28 @@ IMPL_LINK_NOARG(SvxColorWindow_Impl, SelectHdl)
maSelectedLink.Call(&aColor);
PaletteManager::DispatchColorCommand(maCommand, aColor);
+ mrPaletteManager.AddRecentColor(aColor);
+ return 0;
+}
+
+IMPL_LINK_NOARG(SvxColorWindow_Impl, SelectRecentHdl)
+{
+ sal_uInt16 nItemId = mpRecentColorSet->GetSelectItemId();
+ Color aColor;
+ aColor = mpRecentColorSet->GetItemColor( nItemId );
+
+ /* #i33380# DR 2004-09-03 Moved the following line above the Dispatch() calls.
+ This instance may be deleted in the meantime (i.e. when a dialog is opened
+ while in Dispatch()), accessing members will crash in this case. */
+ mpRecentColorSet->SetNoSelection();
+
+ if ( IsInPopupMode() )
+ EndPopupMode();
+
+ if ( maSelectedLink.IsSet() )
+ maSelectedLink.Call(&aColor);
+
+ PaletteManager::DispatchColorCommand(maCommand, aColor);
return 0;
}
@@ -1140,6 +1170,26 @@ IMPL_LINK_NOARG(SvxColorWindow_Impl, SelectPaletteHdl)
return 0;
}
+IMPL_LINK_NOARG(SvxColorWindow_Impl, AutoColorClickHdl)
+{
+ Color aColor;
+ if (SID_ATTR_CHAR_COLOR_BACKGROUND == theSlotId || SID_BACKGROUND_COLOR == theSlotId)
+ aColor = COL_TRANSPARENT;
+ else if (SID_ATTR_CHAR_COLOR == theSlotId || SID_ATTR_CHAR_COLOR2 == theSlotId || SID_EXTRUSION_3D_COLOR == theSlotId)
+ aColor = COL_AUTO;
+
+ mpRecentColorSet->SetNoSelection();
+
+ if ( IsInPopupMode() )
+ EndPopupMode();
+
+ if ( maSelectedLink.IsSet() )
+ maSelectedLink.Call(&aColor);
+
+ PaletteManager::DispatchColorCommand(maCommand, aColor);
+ return 0;
+}
+
IMPL_LINK_NOARG(SvxColorWindow_Impl, OpenPickerClickHdl)
{
if ( IsInPopupMode() )
@@ -1151,6 +1201,7 @@ IMPL_LINK_NOARG(SvxColorWindow_Impl, OpenPickerClickHdl)
void SvxColorWindow_Impl::Resize()
{
mpColorSet->SetSizePixel( this->GetOutputSizePixel() );
+ mpRecentColorSet->SetSizePixel( this->GetOutputSizePixel() );
SetOutputSizePixel(maWindowSize);
}
@@ -1171,6 +1222,10 @@ void SvxColorWindow_Impl::StateChanged( sal_uInt16 nSID, SfxItemState eState, co
if (( nSID == SID_COLOR_TABLE ) && ( pState->ISA( SvxColorListItem )))
{
mrPaletteManager.ReloadColorSet(*mpColorSet);
+ mrPaletteManager.ReloadRecentColorSet(*mpRecentColorSet);
+
+ mpColorSet->layoutAllVisible(mrPaletteManager.GetColorCount());
+ mpRecentColorSet->layoutAllVisible(mrPaletteManager.GetRecentColorCount());
}
else if ( SFX_ITEM_DEFAULT <= eState )
{
diff --git a/svx/uiconfig/ui/colorwindow.ui b/svx/uiconfig/ui/colorwindow.ui
index 0527e78c7294..f33366a03b0c 100644
--- a/svx/uiconfig/ui/colorwindow.ui
+++ b/svx/uiconfig/ui/colorwindow.ui
@@ -10,33 +10,11 @@
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
- <object class="GtkBox" id="box2">
+ <object class="GtkButton" id="auto_color_button">
+ <property name="label" translatable="yes">Automatic</property>
<property name="visible">True</property>
- <property name="can_focus">False</property>
- <child>
- <object class="GtkComboBox" id="palette_listbox">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- </object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkButton" id="color_picker_button">
- <property name="label">Color picker</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">1</property>
- </packing>
- </child>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
</object>
<packing>
<property name="expand">False</property>
@@ -45,6 +23,28 @@
</packing>
</child>
<child>
+ <object class="GtkSeparator" id="separator4">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkComboBox" id="palette_listbox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <child>
<object class="svxlo-SvxColorValueSet" id="colorset">
<property name="visible">True</property>
<property name="can_focus">True</property>
@@ -53,7 +53,7 @@
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
- <property name="position">1</property>
+ <property name="position">3</property>
</packing>
</child>
<child>
@@ -64,7 +64,67 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
- <property name="position">2</property>
+ <property name="position">4</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0.019999999552965164</property>
+ <property name="label" translatable="yes">Recent</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">5</property>
+ </packing>
+ </child>
+ <child>
+ <object class="svxlo-SvxColorValueSet" id="recent_colorset">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">7</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkSeparator" id="separator3">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">8</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="color_picker_button">
+ <property name="label">Color picker</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">9</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkSeparator" id="separator2">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">10</property>
</packing>
</child>
</object>