summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cui/source/options/optchart.cxx159
-rw-r--r--cui/source/options/optchart.hxx32
-rw-r--r--cui/uiconfig/ui/optchartcolorspage.ui76
3 files changed, 154 insertions, 113 deletions
diff --git a/cui/source/options/optchart.cxx b/cui/source/options/optchart.cxx
index f53e30f1b40d..e41c12ed0844 100644
--- a/cui/source/options/optchart.cxx
+++ b/cui/source/options/optchart.cxx
@@ -42,37 +42,32 @@ void SvxDefaultColorOptPage::InsertColorEntry(const XColorEntry& rEntry, sal_Int
xDevice->SetFillColor(rColor);
xDevice->SetLineColor(rStyleSettings.GetDisableColor());
xDevice->DrawRect(aRect);
- BitmapEx aBitmap(xDevice->GetBitmapEx(Point(0, 0), xDevice->GetOutputSize()));
- nPos = m_pLbChartColors->InsertEntry(rStr, Image(aBitmap), nPos);
+ m_xLbChartColors->insert(nullptr, nPos, &rStr, nullptr,
+ nullptr, xDevice.get(), nullptr, false, nullptr);
- if ( static_cast<size_t>(nPos) < aColorList.size() )
+ if (nPos == -1)
+ aColorList.push_back( rColor );
+ else
{
ImpColorList::iterator it = aColorList.begin();
std::advance( it, nPos );
aColorList.insert( it, rColor );
}
- else
- {
- aColorList.push_back( rColor );
- }
}
void SvxDefaultColorOptPage::RemoveColorEntry(sal_Int32 nPos)
{
- m_pLbChartColors->RemoveEntry(nPos);
- if ( 0 <= nPos && static_cast<size_t>(nPos) < aColorList.size() )
- {
- ImpColorList::iterator it = aColorList.begin();
- std::advance(it, nPos);
- aColorList.erase(it);
- }
+ m_xLbChartColors->remove(nPos);
+ ImpColorList::iterator it = aColorList.begin();
+ std::advance(it, nPos);
+ aColorList.erase(it);
}
void SvxDefaultColorOptPage::ClearColorEntries()
{
aColorList.clear();
- m_pLbChartColors->Clear();
+ m_xLbChartColors->clear();
}
void SvxDefaultColorOptPage::ModifyColorEntry(const XColorEntry& rEntry, sal_Int32 nPos)
@@ -86,32 +81,33 @@ void SvxDefaultColorOptPage::FillBoxChartColorLB()
if (!m_SvxChartColorTableUniquePtr)
return;
- m_pLbChartColors->SetUpdateMode(false);
+ m_xLbChartColors->freeze();
ClearColorEntries();
const long nCount(m_SvxChartColorTableUniquePtr->size());
for (long i = 0; i < nCount; ++i)
InsertColorEntry((*m_SvxChartColorTableUniquePtr)[i]);
- m_pLbChartColors->SetUpdateMode(true);
+ m_xLbChartColors->thaw();
}
-SvxDefaultColorOptPage::SvxDefaultColorOptPage(vcl::Window* pParent, const SfxItemSet& rInAttrs)
- : SfxTabPage(pParent, "OptChartColorsPage","cui/ui/optchartcolorspage.ui", &rInAttrs)
+SvxDefaultColorOptPage::SvxDefaultColorOptPage(TabPageParent pParent, const SfxItemSet& rInAttrs)
+ : SfxTabPage(pParent, "cui/ui/optchartcolorspage.ui", "OptChartColorsPage", &rInAttrs)
+ , m_xLbChartColors(m_xBuilder->weld_tree_view("colors"))
+ , m_xLbPaletteSelector(m_xBuilder->weld_combo_box("paletteselector"))
+ , m_xPBDefault(m_xBuilder->weld_button("default"))
+ , m_xPBAdd(m_xBuilder->weld_button("add"))
+ , m_xPBRemove(m_xBuilder->weld_button("delete"))
+ , m_xValSetColorBox(new ColorValueSet(m_xBuilder->weld_scrolled_window("tablewin")))
+ , m_xValSetColorBoxWin(new weld::CustomWeld(*m_xBuilder, "table", *m_xValSetColorBox))
{
- get(m_pPBRemove, "delete");
- get(m_pPBAdd, "add");
- get(m_pPBDefault, "default");
- get(m_pLbPaletteSelector, "paletteselector");
- get(m_pValSetColorBox, "table");
- get(m_pLbChartColors, "colors");
- m_pLbChartColors->set_height_request(m_pLbChartColors->GetTextHeight()*16);
-
- m_pPBDefault->SetClickHdl( LINK( this, SvxDefaultColorOptPage, ResetToDefaults ) );
- m_pPBAdd->SetClickHdl( LINK( this, SvxDefaultColorOptPage, AddChartColor ) );
- m_pPBRemove->SetClickHdl( LINK( this, SvxDefaultColorOptPage, RemoveChartColor ) );
- m_pValSetColorBox->SetSelectHdl( LINK( this, SvxDefaultColorOptPage, BoxClickedHdl ) );
- m_pLbPaletteSelector->SetSelectHdl( LINK( this, SvxDefaultColorOptPage, SelectPaletteLbHdl ) );
-
- m_pValSetColorBox->SetStyle( m_pValSetColorBox->GetStyle()
+ m_xLbChartColors->set_size_request(-1, m_xLbChartColors->get_height_rows(16));
+
+ m_xPBDefault->connect_clicked( LINK( this, SvxDefaultColorOptPage, ResetToDefaults ) );
+ m_xPBAdd->connect_clicked( LINK( this, SvxDefaultColorOptPage, AddChartColor ) );
+ m_xPBRemove->connect_clicked( LINK( this, SvxDefaultColorOptPage, RemoveChartColor ) );
+ m_xValSetColorBox->SetSelectHdl( LINK( this, SvxDefaultColorOptPage, BoxClickedHdl ) );
+ m_xLbPaletteSelector->connect_changed( LINK( this, SvxDefaultColorOptPage, SelectPaletteLbHdl ) );
+
+ m_xValSetColorBox->SetStyle( m_xValSetColorBox->GetStyle()
| WB_ITEMBORDER | WB_NAMEFIELD | WB_VSCROLL );
m_SvxChartOptionsUniquePtr.reset(new SvxChartOptions);
@@ -139,14 +135,8 @@ SvxDefaultColorOptPage::~SvxDefaultColorOptPage()
void SvxDefaultColorOptPage::dispose()
{
- m_SvxChartColorTableUniquePtr.reset();
- m_SvxChartOptionsUniquePtr.reset();
- m_pLbChartColors.clear();
- m_pValSetColorBox.clear();
- m_pPBDefault.clear();
- m_pLbPaletteSelector.clear();
- m_pPBAdd.clear();
- m_pPBRemove.clear();
+ m_xValSetColorBoxWin.reset();
+ m_xValSetColorBox.reset();
SfxTabPage::dispose();
}
@@ -155,13 +145,12 @@ void SvxDefaultColorOptPage::Construct()
FillBoxChartColorLB();
FillPaletteLB();
- m_pLbChartColors->SelectEntryPos( 0 );
+ m_xLbChartColors->select( 0 );
}
-
VclPtr<SfxTabPage> SvxDefaultColorOptPage::Create( TabPageParent pParent, const SfxItemSet* rAttrs )
{
- return VclPtr<SvxDefaultColorOptPage>::Create( pParent.pParent, *rAttrs );
+ return VclPtr<SvxDefaultColorOptPage>::Create( pParent, *rAttrs );
}
bool SvxDefaultColorOptPage::FillItemSet( SfxItemSet* rOutAttrs )
@@ -176,23 +165,20 @@ bool SvxDefaultColorOptPage::FillItemSet( SfxItemSet* rOutAttrs )
void SvxDefaultColorOptPage::Reset( const SfxItemSet* )
{
- m_pLbChartColors->SelectEntryPos( 0 );
+ m_xLbChartColors->select( 0 );
}
void SvxDefaultColorOptPage::FillPaletteLB()
{
- m_pLbPaletteSelector->Clear();
+ m_xLbPaletteSelector->clear();
std::vector<OUString> aPaletteList = aPaletteManager.GetPaletteList();
for (auto const& palette : aPaletteList)
- {
- m_pLbPaletteSelector->InsertEntry(palette);
- }
- OUString aPaletteName( officecfg::Office::Common::UserColors::PaletteName::get() );
- m_pLbPaletteSelector->SelectEntry(aPaletteName);
- if (m_pLbPaletteSelector->GetSelectedEntryPos() != LISTBOX_ENTRY_NOTFOUND)
- {
- SelectPaletteLbHdl( *m_pLbPaletteSelector );
- }
+ m_xLbPaletteSelector->append_text(palette);
+
+ OUString aPaletteName(officecfg::Office::Common::UserColors::PaletteName::get());
+ m_xLbPaletteSelector->set_active_text(aPaletteName);
+ if (m_xLbPaletteSelector->get_active() != -1)
+ SelectPaletteLbHdl( *m_xLbPaletteSelector );
}
void SvxDefaultColorOptPage::SaveChartOptions()
@@ -208,9 +194,7 @@ void SvxDefaultColorOptPage::SaveChartOptions()
// ResetToDefaults
-
-
-IMPL_LINK_NOARG(SvxDefaultColorOptPage, ResetToDefaults, Button*, void)
+IMPL_LINK_NOARG(SvxDefaultColorOptPage, ResetToDefaults, weld::Button&, void)
{
if( m_SvxChartColorTableUniquePtr )
{
@@ -218,16 +202,14 @@ IMPL_LINK_NOARG(SvxDefaultColorOptPage, ResetToDefaults, Button*, void)
FillBoxChartColorLB();
- m_pLbChartColors->GetFocus();
- m_pLbChartColors->SelectEntryPos( 0 );
- m_pPBRemove->Enable();
+ m_xLbChartColors->grab_focus();
+ m_xLbChartColors->select( 0 );
+ m_xPBRemove->set_sensitive(true);
}
}
// AddChartColor
-
-
-IMPL_LINK_NOARG(SvxDefaultColorOptPage, AddChartColor, Button*, void)
+IMPL_LINK_NOARG(SvxDefaultColorOptPage, AddChartColor, weld::Button&, void)
{
if( m_SvxChartColorTableUniquePtr )
{
@@ -237,27 +219,24 @@ IMPL_LINK_NOARG(SvxDefaultColorOptPage, AddChartColor, Button*, void)
XColorEntry(black, SvxChartColorTable::getDefaultName(m_SvxChartColorTableUniquePtr->size())));
FillBoxChartColorLB();
- m_pLbChartColors->GetFocus();
- m_pLbChartColors->SelectEntryPos(m_SvxChartColorTableUniquePtr->size() - 1);
- m_pPBRemove->Enable();
+ m_xLbChartColors->grab_focus();
+ m_xLbChartColors->select(m_SvxChartColorTableUniquePtr->size() - 1);
+ m_xPBRemove->set_sensitive(true);
}
}
// RemoveChartColor
-
-
-IMPL_LINK_NOARG( SvxDefaultColorOptPage, RemoveChartColor, Button*, void )
+IMPL_LINK_NOARG( SvxDefaultColorOptPage, RemoveChartColor, weld::Button&, void )
{
- sal_Int32 nIndex = m_pLbChartColors->GetSelectedEntryPos();
-
- if (m_pLbChartColors->GetSelectedEntryCount() == 0)
+ sal_Int32 nIndex = m_xLbChartColors->get_selected_index();
+ if (nIndex == -1)
return;
if( m_SvxChartColorTableUniquePtr )
{
OSL_ENSURE(m_SvxChartColorTableUniquePtr->size() > 1, "don't delete the last chart color");
- std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(GetFrameWeld(), "cui/ui/querydeletechartcolordialog.ui"));
+ std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(GetDialogFrameWeld(), "cui/ui/querydeletechartcolordialog.ui"));
std::unique_ptr<weld::MessageDialog> xQuery(xBuilder->weld_message_dialog("QueryDeleteChartColorDialog"));
if (RET_YES == xQuery->run())
@@ -266,37 +245,37 @@ IMPL_LINK_NOARG( SvxDefaultColorOptPage, RemoveChartColor, Button*, void )
FillBoxChartColorLB();
- m_pLbChartColors->GetFocus();
+ m_xLbChartColors->grab_focus();
- if (nIndex == m_pLbChartColors->GetEntryCount() && m_pLbChartColors->GetEntryCount() > 0)
- m_pLbChartColors->SelectEntryPos(m_SvxChartColorTableUniquePtr->size() - 1);
- else if (m_pLbChartColors->GetEntryCount() > 0)
- m_pLbChartColors->SelectEntryPos( nIndex );
+ if (nIndex == m_xLbChartColors->n_children() && m_xLbChartColors->n_children() > 0)
+ m_xLbChartColors->select(m_SvxChartColorTableUniquePtr->size() - 1);
+ else if (m_xLbChartColors->n_children() > 0)
+ m_xLbChartColors->select( nIndex );
else
- m_pPBRemove->Enable();
+ m_xPBRemove->set_sensitive(true);
}
}
}
-IMPL_LINK_NOARG( SvxDefaultColorOptPage, SelectPaletteLbHdl, ListBox&, void)
+IMPL_LINK_NOARG( SvxDefaultColorOptPage, SelectPaletteLbHdl, weld::ComboBox&, void)
{
- sal_Int32 nPos = m_pLbPaletteSelector->GetSelectedEntryPos();
+ sal_Int32 nPos = m_xLbPaletteSelector->get_active();
aPaletteManager.SetPalette( nPos );
- aPaletteManager.ReloadColorSet( *m_pValSetColorBox );
- m_pValSetColorBox->Resize();
+ aPaletteManager.ReloadColorSet( *m_xValSetColorBox );
+ m_xValSetColorBox->Resize();
}
-IMPL_LINK_NOARG(SvxDefaultColorOptPage, BoxClickedHdl, ValueSet*, void)
+IMPL_LINK_NOARG(SvxDefaultColorOptPage, BoxClickedHdl, SvtValueSet*, void)
{
- sal_Int32 nIdx = m_pLbChartColors->GetSelectedEntryPos();
- if( nIdx != LISTBOX_ENTRY_NOTFOUND )
+ sal_Int32 nIdx = m_xLbChartColors->get_selected_index();
+ if (nIdx != -1)
{
- const XColorEntry aEntry( m_pValSetColorBox->GetItemColor( m_pValSetColorBox->GetSelectedItemId() ), m_pLbChartColors->GetSelectedEntry() );
+ const XColorEntry aEntry(m_xValSetColorBox->GetItemColor(m_xValSetColorBox->GetSelectedItemId()), m_xLbChartColors->get_selected_text());
ModifyColorEntry(aEntry, nIdx);
m_SvxChartColorTableUniquePtr->replace(nIdx, aEntry);
- m_pLbChartColors->SelectEntryPos( nIdx ); // reselect entry
+ m_xLbChartColors->select(nIdx); // reselect entry
}
}
diff --git a/cui/source/options/optchart.hxx b/cui/source/options/optchart.hxx
index ec3e8afef96b..fca6bec2be5e 100644
--- a/cui/source/options/optchart.hxx
+++ b/cui/source/options/optchart.hxx
@@ -22,10 +22,9 @@
#include <sfx2/tabdlg.hxx>
#include <svtools/valueset.hxx>
-#include <vcl/button.hxx>
-#include <vcl/lstbox.hxx>
#include <svx/xtable.hxx>
#include <svx/PaletteManager.hxx>
+#include <vcl/customweld.hxx>
#include "cfgchart.hxx"
@@ -34,13 +33,6 @@ typedef std::vector<Color> ImpColorList;
class SvxDefaultColorOptPage : public SfxTabPage
{
private:
- VclPtr<ListBox> m_pLbChartColors;
- VclPtr<ListBox> m_pLbPaletteSelector;
- VclPtr<SvxColorValueSet> m_pValSetColorBox;
- VclPtr<PushButton> m_pPBDefault;
- VclPtr<PushButton> m_pPBAdd;
- VclPtr<PushButton> m_pPBRemove;
-
std::unique_ptr<SvxChartOptions> m_SvxChartOptionsUniquePtr;
// no reason to use a cloned SfxItem here (SvxChartColorTableItem)
// that just leads to non-const SfxItem and potential trouble
@@ -49,23 +41,31 @@ private:
ImpColorList aColorList;
PaletteManager aPaletteManager;
- DECL_LINK( ResetToDefaults, Button *, void );
- DECL_LINK( AddChartColor, Button *, void );
- DECL_LINK( RemoveChartColor, Button *, void );
- DECL_LINK(BoxClickedHdl, ValueSet*, void);
- DECL_LINK( SelectPaletteLbHdl, ListBox&, void );
+ std::unique_ptr<weld::TreeView> m_xLbChartColors;
+ std::unique_ptr<weld::ComboBox> m_xLbPaletteSelector;
+ std::unique_ptr<weld::Button> m_xPBDefault;
+ std::unique_ptr<weld::Button> m_xPBAdd;
+ std::unique_ptr<weld::Button> m_xPBRemove;
+ std::unique_ptr<ColorValueSet> m_xValSetColorBox;
+ std::unique_ptr<weld::CustomWeld> m_xValSetColorBoxWin;
+
+ DECL_LINK(ResetToDefaults, weld::Button&, void);
+ DECL_LINK(AddChartColor, weld::Button&, void);
+ DECL_LINK(RemoveChartColor, weld::Button&, void);
+ DECL_LINK(BoxClickedHdl, SvtValueSet*, void);
+ DECL_LINK(SelectPaletteLbHdl, weld::ComboBox&, void);
void FillPaletteLB();
private:
- void InsertColorEntry(const XColorEntry& rEntry, sal_Int32 nPos = LISTBOX_APPEND);
+ void InsertColorEntry(const XColorEntry& rEntry, sal_Int32 nPos = -1);
void RemoveColorEntry(sal_Int32 nPos);
void ModifyColorEntry(const XColorEntry& rEntry, sal_Int32 nPos);
void ClearColorEntries();
void FillBoxChartColorLB();
public:
- SvxDefaultColorOptPage( vcl::Window* pParent, const SfxItemSet& rInAttrs );
+ SvxDefaultColorOptPage(TabPageParent pParent, const SfxItemSet& rInAttrs);
virtual ~SvxDefaultColorOptPage() override;
virtual void dispose() override;
diff --git a/cui/uiconfig/ui/optchartcolorspage.ui b/cui/uiconfig/ui/optchartcolorspage.ui
index ee23c1cc7450..253a765a258d 100644
--- a/cui/uiconfig/ui/optchartcolorspage.ui
+++ b/cui/uiconfig/ui/optchartcolorspage.ui
@@ -1,8 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.18.3 -->
+<!-- Generated with glade 3.22.1 -->
<interface domain="cui">
<requires lib="gtk+" version="3.18"/>
- <requires lib="LibreOffice" version="1.0"/>
+ <object class="GtkTreeStore" id="liststore1">
+ <columns>
+ <!-- column-name image -->
+ <column type="GdkPixbuf"/>
+ <!-- column-name text -->
+ <column type="gchararray"/>
+ <!-- column-name id -->
+ <column type="gchararray"/>
+ </columns>
+ </object>
<object class="GtkBox" id="OptChartColorsPage">
<property name="visible">True</property>
<property name="can_focus">False</property>
@@ -27,14 +36,49 @@
<property name="top_padding">6</property>
<property name="left_padding">12</property>
<child>
- <object class="GtkTreeView" id="colors:border">
+ <object class="GtkScrolledWindow" id="colorswin">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
- <property name="show_expanders">False</property>
- <child internal-child="selection">
- <object class="GtkTreeSelection" id="treeview-selection1"/>
+ <property name="shadow_type">in</property>
+ <child>
+ <object class="GtkTreeView" id="colors">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="hexpand">True</property>
+ <property name="vexpand">True</property>
+ <property name="model">liststore1</property>
+ <property name="headers_visible">False</property>
+ <property name="search_column">0</property>
+ <property name="show_expanders">False</property>
+ <child internal-child="selection">
+ <object class="GtkTreeSelection" id="Macro Library List-selection2"/>
+ </child>
+ <child>
+ <object class="GtkTreeViewColumn" id="treeviewcolumn1">
+ <child>
+ <object class="GtkCellRendererPixbuf" id="cellrenderertext1"/>
+ <attributes>
+ <attribute name="pixbuf">0</attribute>
+ </attributes>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkTreeViewColumn" id="treeviewcolumn5">
+ <property name="resizable">True</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkCellRendererText" id="cellrenderer4"/>
+ <attributes>
+ <attribute name="text">1</attribute>
+ </attributes>
+ </child>
+ </object>
+ </child>
+ </object>
</child>
</object>
</child>
@@ -146,11 +190,29 @@
</packing>
</child>
<child>
- <object class="svxcorelo-SvxColorValueSet" id="table:border">
+ <object class="GtkScrolledWindow" id="tablewin">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
+ <property name="hscrollbar_policy">never</property>
+ <property name="vscrollbar_policy">never</property>
+ <property name="shadow_type">in</property>
+ <child>
+ <object class="GtkViewport">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkDrawingArea" id="table">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="events">GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | GDK_STRUCTURE_MASK</property>
+ <property name="hexpand">True</property>
+ <property name="vexpand">True</property>
+ </object>
+ </child>
+ </object>
+ </child>
</object>
<packing>
<property name="left_attach">0</property>