From 81963b5c68b492f6a75dd17fb0bec80e5dad9955 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Thu, 1 Aug 2019 13:27:29 +0100 Subject: weld SvxDefaultColorOptPage MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I5741ee4d0df724e9f1df72ce668f9f2e53541280 Reviewed-on: https://gerrit.libreoffice.org/76802 Tested-by: Jenkins Reviewed-by: Caolán McNamara Tested-by: Caolán McNamara --- cui/source/options/optchart.cxx | 159 +++++++++++++++------------------- cui/source/options/optchart.hxx | 32 +++---- cui/uiconfig/ui/optchartcolorspage.ui | 76 ++++++++++++++-- 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(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(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 SvxDefaultColorOptPage::Create( TabPageParent pParent, const SfxItemSet* rAttrs ) { - return VclPtr::Create( pParent.pParent, *rAttrs ); + return VclPtr::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 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 xBuilder(Application::CreateBuilder(GetFrameWeld(), "cui/ui/querydeletechartcolordialog.ui")); + std::unique_ptr xBuilder(Application::CreateBuilder(GetDialogFrameWeld(), "cui/ui/querydeletechartcolordialog.ui")); std::unique_ptr 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 #include -#include -#include #include #include +#include #include "cfgchart.hxx" @@ -34,13 +33,6 @@ typedef std::vector ImpColorList; class SvxDefaultColorOptPage : public SfxTabPage { private: - VclPtr m_pLbChartColors; - VclPtr m_pLbPaletteSelector; - VclPtr m_pValSetColorBox; - VclPtr m_pPBDefault; - VclPtr m_pPBAdd; - VclPtr m_pPBRemove; - std::unique_ptr 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 m_xLbChartColors; + std::unique_ptr m_xLbPaletteSelector; + std::unique_ptr m_xPBDefault; + std::unique_ptr m_xPBAdd; + std::unique_ptr m_xPBRemove; + std::unique_ptr m_xValSetColorBox; + std::unique_ptr 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 @@ - + - + + + + + + + + + + True False @@ -27,14 +36,49 @@ 6 12 - + True True True True - False - - + in + + + True + True + True + True + True + liststore1 + False + 0 + False + + + + + + + + + 0 + + + + + + + True + 6 + + + + 1 + + + + + @@ -146,11 +190,29 @@ - + True True True True + never + never + in + + + True + False + + + True + True + GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | GDK_STRUCTURE_MASK + True + True + + + + 0 -- cgit v1.2.3