From d148e5c5db3f3ea32abd6f7bed30665a3931e937 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Mon, 18 Jun 2018 21:30:10 +0100 Subject: weld SvxColorTabPage MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I5dc6f949edcb34aa110dfa9415e2ac886d0dfa4c Reviewed-on: https://gerrit.libreoffice.org/56155 Tested-by: Jenkins Reviewed-by: Caolán McNamara Tested-by: Caolán McNamara --- cui/source/inc/cuitabarea.hxx | 94 ++++----- cui/source/tabpages/tpcolor.cxx | 419 +++++++++++++++++++--------------------- cui/uiconfig/ui/colorpage.ui | 242 +++++++++++------------ 3 files changed, 359 insertions(+), 396 deletions(-) (limited to 'cui') diff --git a/cui/source/inc/cuitabarea.hxx b/cui/source/inc/cuitabarea.hxx index 7a72431bb9a5..2c8e55234fe9 100644 --- a/cui/source/inc/cuitabarea.hxx +++ b/cui/source/inc/cuitabarea.hxx @@ -654,43 +654,6 @@ class SvxColorTabPage : public SfxTabPage private: VclPtr mpTopDlg; - PaletteManager maPaletteManager; - VclPtr m_pSelectPalette; - VclPtr m_pValSetColorList; - VclPtr m_pValSetRecentList; - - VclPtr m_pCtlPreviewOld; - VclPtr m_pCtlPreviewNew; - - VclPtr m_pRbRGB; - VclPtr m_pRbCMYK; - - VclPtr m_pRGBcustom; - VclPtr m_pRGBpreset; - VclPtr m_pRcustom; - VclPtr m_pRpreset; - VclPtr m_pGcustom; - VclPtr m_pGpreset; - VclPtr m_pBcustom; - VclPtr m_pBpreset; - VclPtr m_pHexpreset; - VclPtr m_pHexcustom; - - VclPtr m_pCMYKcustom; - VclPtr m_pCMYKpreset; - VclPtr m_pCcustom; - VclPtr m_pCpreset; - VclPtr m_pYcustom; - VclPtr m_pYpreset; - VclPtr m_pMcustom; - VclPtr m_pMpreset; - VclPtr m_pKcustom; - VclPtr m_pKpreset; - - VclPtr m_pBtnAdd; - VclPtr m_pBtnDelete; - VclPtr m_pBtnWorkOn; - const SfxItemSet& rOutAttrs; XColorListRef pColorList; @@ -705,6 +668,44 @@ private: Color aPreviousColor; Color aCurrentColor; + css::uno::Reference< css::uno::XComponentContext > m_context; + + PaletteManager maPaletteManager; + XRectPreview m_aCtlPreviewOld; + XRectPreview m_aCtlPreviewNew; + std::unique_ptr m_xValSetColorList; + std::unique_ptr m_xValSetRecentList; + std::unique_ptr m_xSelectPalette; + std::unique_ptr m_xRbRGB; + std::unique_ptr m_xRbCMYK; + std::unique_ptr m_xRGBcustom; + std::unique_ptr m_xRGBpreset; + std::unique_ptr m_xRpreset; + std::unique_ptr m_xGpreset; + std::unique_ptr m_xBpreset; + std::unique_ptr m_xRcustom; + std::unique_ptr m_xGcustom; + std::unique_ptr m_xBcustom; + std::unique_ptr m_xHexpreset; + std::unique_ptr m_xHexcustom; + std::unique_ptr m_xCMYKcustom; + std::unique_ptr m_xCMYKpreset; + std::unique_ptr m_xCpreset; + std::unique_ptr m_xYpreset; + std::unique_ptr m_xMpreset; + std::unique_ptr m_xKpreset; + std::unique_ptr m_xCcustom; + std::unique_ptr m_xYcustom; + std::unique_ptr m_xMcustom; + std::unique_ptr m_xKcustom; + std::unique_ptr m_xBtnAdd; + std::unique_ptr m_xBtnDelete; + std::unique_ptr m_xBtnWorkOn; + std::unique_ptr m_xCtlPreviewOld; + std::unique_ptr m_xCtlPreviewNew; + std::unique_ptr m_xValSetColorListWin; + std::unique_ptr m_xValSetRecentListWin; + static void ConvertColorValues (Color& rColor, ColorModel eModell); static void RgbToCmyk_Impl( Color& rColor, sal_uInt16& rK ); static void CmykToRgb_Impl( Color& rColor, const sal_uInt16 nKey ); @@ -714,27 +715,28 @@ private: void ImpColorCountChanged(); void FillPaletteLB(); - DECL_LINK( ClickAddHdl_Impl, Button*, void ); - DECL_LINK( ClickWorkOnHdl_Impl, Button*, void ); - DECL_LINK( ClickDeleteHdl_Impl, Button*, void ); + DECL_LINK(ClickAddHdl_Impl, weld::Button&, void); + DECL_LINK(ClickWorkOnHdl_Impl, weld::Button&, void); + DECL_LINK(ClickDeleteHdl_Impl, weld::Button&, void); - DECL_LINK( SelectPaletteLBHdl, ListBox&, void ); - DECL_LINK( SelectValSetHdl_Impl, ValueSet*, void ); - DECL_LINK( SelectColorModeHdl_Impl, RadioButton&, void ); + DECL_LINK(SelectPaletteLBHdl, weld::ComboBoxText&, void); + DECL_LINK( SelectValSetHdl_Impl, SvtValueSet*, void ); + DECL_LINK( SelectColorModeHdl_Impl, weld::ToggleButton&, void ); void ChangeColor(const Color &rNewColor, bool bUpdatePreset = true); void SetColorModel(ColorModel eModel); void ChangeColorModel(); void UpdateColorValues( bool bUpdatePreset = true ); - DECL_LINK( ModifiedHdl_Impl, Edit&, void ); + DECL_LINK(SpinValueHdl_Impl, weld::SpinButton&, void); + DECL_LINK(MetricSpinValueHdl_Impl, weld::MetricSpinButton&, void); + DECL_LINK(ModifiedHdl_Impl, weld::Entry&, void); void UpdateModified(); - css::uno::Reference< css::uno::XComponentContext > m_context; static sal_Int32 FindInCustomColors( OUString const & aColorName ); sal_Int32 FindInPalette( const Color& rColor ); public: - SvxColorTabPage( vcl::Window* pParent, const SfxItemSet& rInAttrs ); + SvxColorTabPage(TabPageParent pParent, const SfxItemSet& rInAttrs); virtual ~SvxColorTabPage() override; virtual void dispose() override; diff --git a/cui/source/tabpages/tpcolor.cxx b/cui/source/tabpages/tpcolor.cxx index f73359468cbe..113d1f9fb8a8 100644 --- a/cui/source/tabpages/tpcolor.cxx +++ b/cui/source/tabpages/tpcolor.cxx @@ -18,6 +18,7 @@ */ #include +#include #include #include #include @@ -53,8 +54,8 @@ using namespace com::sun::star; -SvxColorTabPage::SvxColorTabPage(vcl::Window* pParent, const SfxItemSet& rInAttrs) - : SfxTabPage(pParent, "ColorPage", "cui/ui/colorpage.ui", &rInAttrs) +SvxColorTabPage::SvxColorTabPage(TabPageParent pParent, const SfxItemSet& rInAttrs) + : SfxTabPage(pParent, "cui/ui/colorpage.ui", "ColorPage", &rInAttrs) , mpTopDlg( GetParentDialog() ) , rOutAttrs ( rInAttrs ) // All the horrific pointers we store and should not @@ -63,99 +64,98 @@ SvxColorTabPage::SvxColorTabPage(vcl::Window* pParent, const SfxItemSet& rInAttr , rXFSet( aXFillAttr.GetItemSet() ) , eCM( ColorModel::RGB ) , m_context(comphelper::getProcessComponentContext()) + , m_xValSetColorList(new ColorValueSet(m_xBuilder->weld_scrolled_window("colorsetwin"))) + , m_xValSetRecentList(new ColorValueSet(nullptr)) + , m_xSelectPalette(m_xBuilder->weld_combo_box_text("paletteselector")) + , m_xRbRGB(m_xBuilder->weld_radio_button("RGB")) + , m_xRbCMYK(m_xBuilder->weld_radio_button("CMYK")) + , m_xRGBcustom(m_xBuilder->weld_widget("rgbcustom")) + , m_xRGBpreset(m_xBuilder->weld_widget("rgbpreset")) + , m_xRpreset(m_xBuilder->weld_entry("R_preset")) + , m_xGpreset(m_xBuilder->weld_entry("G_preset")) + , m_xBpreset(m_xBuilder->weld_entry("B_preset")) + , m_xRcustom(m_xBuilder->weld_spin_button("R_custom")) + , m_xGcustom(m_xBuilder->weld_spin_button("G_custom")) + , m_xBcustom(m_xBuilder->weld_spin_button("B_custom")) + , m_xHexpreset(new weld::HexColorControl(m_xBuilder->weld_entry("hex_preset"))) + , m_xHexcustom(new weld::HexColorControl(m_xBuilder->weld_entry("hex_custom"))) + , m_xCMYKcustom(m_xBuilder->weld_widget("cmykcustom")) + , m_xCMYKpreset(m_xBuilder->weld_widget("cmykpreset")) + , m_xCpreset(m_xBuilder->weld_entry("C_preset")) + , m_xYpreset(m_xBuilder->weld_entry("Y_preset")) + , m_xMpreset(m_xBuilder->weld_entry("M_preset")) + , m_xKpreset(m_xBuilder->weld_entry("K_preset")) + , m_xCcustom(m_xBuilder->weld_metric_spin_button("C_custom", FUNIT_PERCENT)) + , m_xYcustom(m_xBuilder->weld_metric_spin_button("Y_custom", FUNIT_PERCENT)) + , m_xMcustom(m_xBuilder->weld_metric_spin_button("M_custom", FUNIT_PERCENT)) + , m_xKcustom(m_xBuilder->weld_metric_spin_button("K_custom", FUNIT_PERCENT)) + , m_xBtnAdd(m_xBuilder->weld_button("add")) + , m_xBtnDelete(m_xBuilder->weld_button("delete")) + , m_xBtnWorkOn(m_xBuilder->weld_button("edit")) + , m_xCtlPreviewOld(new weld::CustomWeld(*m_xBuilder, "oldpreview", m_aCtlPreviewOld)) + , m_xCtlPreviewNew(new weld::CustomWeld(*m_xBuilder, "newpreview", m_aCtlPreviewNew)) + , m_xValSetColorListWin(new weld::CustomWeld(*m_xBuilder, "colorset", *m_xValSetColorList)) + , m_xValSetRecentListWin(new weld::CustomWeld(*m_xBuilder, "recentcolorset", *m_xValSetRecentList)) { - get(m_pSelectPalette, "paletteselector"); - get(m_pValSetColorList, "colorset"); Size aSize = LogicToPixel(Size(100 , 120), MapMode(MapUnit::MapAppFont)); - m_pValSetColorList->set_width_request(aSize.Width()); - m_pValSetColorList->set_height_request(aSize.Height()); - get(m_pValSetRecentList, "recentcolorset"); - get(m_pCtlPreviewOld, "oldpreview"); - get(m_pCtlPreviewNew, "newpreview"); + m_xValSetColorList->set_size_request(aSize.Width(), aSize.Height()); aSize = LogicToPixel(Size(34 , 25), MapMode(MapUnit::MapAppFont)); - m_pCtlPreviewOld->set_width_request(aSize.Width()); - m_pCtlPreviewOld->set_height_request(aSize.Height()); - m_pCtlPreviewNew->set_width_request(aSize.Width()); - m_pCtlPreviewNew->set_height_request(aSize.Height()); - get(m_pRbRGB, "RGB"); - get(m_pRbCMYK, "CMYK"); - get(m_pRGBcustom, "rgbcustom"); - get(m_pRGBpreset, "rgbpreset"); - get(m_pRcustom, "R_custom"); - get(m_pRpreset, "R_preset-nospin"); - get(m_pGcustom, "G_custom"); - get(m_pGpreset, "G_preset-nospin"); - get(m_pBcustom, "B_custom"); - get(m_pBpreset, "B_preset-nospin"); - get(m_pHexpreset, "hex_preset"); - get(m_pHexcustom, "hex_custom"); - get(m_pCMYKcustom, "cmykcustom"); - get(m_pCMYKpreset, "cmykpreset"); - get(m_pCcustom, "C_custom"); - get(m_pCpreset, "C_preset-nospin"); - get(m_pYcustom, "Y_custom"); - get(m_pYpreset, "Y_preset-nospin"); - get(m_pMcustom, "M_custom"); - get(m_pMpreset, "M_preset-nospin"); - get(m_pKcustom, "K_custom"); - get(m_pKpreset, "K_preset-nospin"); - get(m_pBtnAdd, "add"); - get(m_pBtnDelete, "delete"); - get(m_pBtnWorkOn, "edit"); - + m_aCtlPreviewOld.set_size_request(aSize.Width(), aSize.Height()); + m_aCtlPreviewNew.set_size_request(aSize.Width(), aSize.Height()); // this page needs ExchangeSupport SetExchangeSupport(); // setting the output device rXFSet.Put( XFillStyleItem(drawing::FillStyle_SOLID) ); rXFSet.Put( XFillColorItem(OUString(), COL_BLACK) ); - m_pCtlPreviewOld->SetAttributes( aXFillAttr.GetItemSet() ); - m_pCtlPreviewNew->SetAttributes( aXFillAttr.GetItemSet() ); + m_aCtlPreviewOld.SetAttributes( aXFillAttr.GetItemSet() ); + m_aCtlPreviewNew.SetAttributes( aXFillAttr.GetItemSet() ); // set handler - m_pSelectPalette->SetSelectHdl( LINK(this, SvxColorTabPage, SelectPaletteLBHdl) ); - Link aValSelectLink = LINK( this, SvxColorTabPage, SelectValSetHdl_Impl ); - m_pValSetColorList->SetSelectHdl( aValSelectLink ); - m_pValSetRecentList->SetSelectHdl( aValSelectLink ); - - Link aLink = LINK( this, SvxColorTabPage, ModifiedHdl_Impl ); - m_pRcustom->SetModifyHdl( aLink ); - m_pGcustom->SetModifyHdl( aLink ); - m_pBcustom->SetModifyHdl( aLink ); - m_pHexpreset->SetModifyHdl( aLink ); - m_pHexcustom->SetModifyHdl( aLink ); - m_pCcustom->SetModifyHdl( aLink ); - m_pYcustom->SetModifyHdl( aLink ); - m_pMcustom->SetModifyHdl( aLink ); - m_pKcustom->SetModifyHdl( aLink ); - - Link aLink2 = LINK( this, SvxColorTabPage, SelectColorModeHdl_Impl ); - m_pRbRGB->SetToggleHdl( aLink2 ); - m_pRbCMYK->SetToggleHdl( aLink2 ); + m_xSelectPalette->connect_changed(LINK(this, SvxColorTabPage, SelectPaletteLBHdl)); + Link aValSelectLink = LINK(this, SvxColorTabPage, SelectValSetHdl_Impl); + m_xValSetColorList->SetSelectHdl(aValSelectLink); + m_xValSetRecentList->SetSelectHdl(aValSelectLink); + + Link aSpinLink = LINK(this, SvxColorTabPage, SpinValueHdl_Impl); + m_xRcustom->connect_value_changed(aSpinLink); + m_xGcustom->connect_value_changed(aSpinLink); + m_xBcustom->connect_value_changed(aSpinLink); + Link aEntryLink = LINK(this, SvxColorTabPage, ModifiedHdl_Impl); + m_xHexcustom->connect_changed(aEntryLink); + Link aMetricSpinLink = LINK(this, SvxColorTabPage, MetricSpinValueHdl_Impl); + m_xCcustom->connect_value_changed(aMetricSpinLink); + m_xYcustom->connect_value_changed(aMetricSpinLink); + m_xMcustom->connect_value_changed(aMetricSpinLink); + m_xKcustom->connect_value_changed(aMetricSpinLink); + + Link aLink2 = LINK( this, SvxColorTabPage, SelectColorModeHdl_Impl ); + m_xRbRGB->connect_toggled(aLink2); + m_xRbCMYK->connect_toggled(aLink2); SetColorModel( eCM ); ChangeColorModel(); - m_pBtnAdd->SetClickHdl( LINK( this, SvxColorTabPage, ClickAddHdl_Impl ) ); - m_pBtnWorkOn->SetClickHdl( LINK( this, SvxColorTabPage, ClickWorkOnHdl_Impl ) ); - m_pBtnDelete->SetClickHdl( LINK( this, SvxColorTabPage, ClickDeleteHdl_Impl ) ); + m_xBtnAdd->connect_clicked( LINK( this, SvxColorTabPage, ClickAddHdl_Impl ) ); + m_xBtnWorkOn->connect_clicked( LINK( this, SvxColorTabPage, ClickWorkOnHdl_Impl ) ); + m_xBtnDelete->connect_clicked( LINK( this, SvxColorTabPage, ClickDeleteHdl_Impl ) ); // disable modify buttons // Color palettes can't be modified - m_pBtnDelete->Disable(); + m_xBtnDelete->set_sensitive(false); // disable preset color values - m_pRGBpreset->Disable(); - m_pCMYKpreset->Disable(); + m_xRGBpreset->set_sensitive(false); + m_xCMYKpreset->set_sensitive(false); // ValueSet - m_pValSetColorList->SetStyle( m_pValSetColorList->GetStyle() | WB_ITEMBORDER ); - m_pValSetColorList->Show(); + m_xValSetColorList->SetStyle(m_xValSetColorList->GetStyle() | WB_ITEMBORDER); + m_xValSetColorList->Show(); + + m_xValSetRecentList->SetStyle(m_xValSetRecentList->GetStyle() | WB_ITEMBORDER); + m_xValSetRecentList->Show(); - m_pValSetRecentList->SetStyle( m_pValSetColorList->GetStyle() | WB_ITEMBORDER ); - m_pValSetRecentList->Show(); - maPaletteManager.ReloadRecentColorSet( *m_pValSetRecentList ); - aSize = m_pValSetRecentList->layoutAllVisible(maPaletteManager.GetRecentColorCount()); - m_pValSetRecentList->set_height_request(aSize.Height()); - m_pValSetRecentList->set_width_request(aSize.Width()); + maPaletteManager.ReloadRecentColorSet(*m_xValSetRecentList); + aSize = m_xValSetRecentList->layoutAllVisible(maPaletteManager.GetRecentColorCount()); + m_xValSetRecentList->set_size_request(aSize.Width(), aSize.Height()); } SvxColorTabPage::~SvxColorTabPage() @@ -166,36 +166,8 @@ SvxColorTabPage::~SvxColorTabPage() void SvxColorTabPage::dispose() { mpTopDlg.clear(); - m_pSelectPalette.clear(); - m_pValSetColorList.clear(); - m_pValSetRecentList.clear(); - m_pCtlPreviewOld.clear(); - m_pCtlPreviewNew.clear(); - m_pRbRGB.clear(); - m_pRbCMYK.clear(); - m_pRGBcustom.clear(); - m_pRGBpreset.clear(); - m_pRcustom.clear(); - m_pRpreset.clear(); - m_pGcustom.clear(); - m_pGpreset.clear(); - m_pBcustom.clear(); - m_pBpreset.clear(); - m_pHexpreset.clear(); - m_pHexcustom.clear(); - m_pCMYKcustom.clear(); - m_pCMYKpreset.clear(); - m_pCcustom.clear(); - m_pCpreset.clear(); - m_pYcustom.clear(); - m_pYpreset.clear(); - m_pMcustom.clear(); - m_pMpreset.clear(); - m_pKcustom.clear(); - m_pKpreset.clear(); - m_pBtnAdd.clear(); - m_pBtnDelete.clear(); - m_pBtnWorkOn.clear(); + m_xValSetRecentList.reset(); + m_xValSetColorList.reset(); SfxTabPage::dispose(); } @@ -203,23 +175,23 @@ void SvxColorTabPage::ImpColorCountChanged() { if (!pColorList.is()) return; - m_pValSetColorList->SetColCount(SvxColorValueSet::getColumnCount()); - m_pValSetRecentList->SetColCount(SvxColorValueSet::getColumnCount()); + m_xValSetColorList->SetColCount(SvxColorValueSet::getColumnCount()); + m_xValSetRecentList->SetColCount(SvxColorValueSet::getColumnCount()); } void SvxColorTabPage::FillPaletteLB() { - m_pSelectPalette->Clear(); + m_xSelectPalette->clear(); std::vector aPaletteList = maPaletteManager.GetPaletteList(); for (auto const& palette : aPaletteList) { - m_pSelectPalette->InsertEntry(palette); + m_xSelectPalette->append_text(palette); } OUString aPaletteName( officecfg::Office::Common::UserColors::PaletteName::get() ); - m_pSelectPalette->SelectEntry(aPaletteName); - if (m_pSelectPalette->GetSelectedEntryPos() != LISTBOX_ENTRY_NOTFOUND) + m_xSelectPalette->set_active_text(aPaletteName); + if (m_xSelectPalette->get_active() != -1) { - SelectPaletteLBHdl( *m_pSelectPalette ); + SelectPaletteLBHdl(*m_xSelectPalette); } } @@ -247,15 +219,15 @@ void SvxColorTabPage::ActivatePage( const SfxItemSet& ) sal_Int32 nPos = FindInPalette( aColor ); if ( nPos != -1 ) - m_pValSetColorList->SelectItem( m_pValSetColorList->GetItemId( nPos ) ); + m_xValSetColorList->SelectItem(m_xValSetColorList->GetItemId(nPos)); // else search in other palettes? } - m_pCtlPreviewOld->SetAttributes( aXFillAttr.GetItemSet() ); - m_pCtlPreviewOld->Invalidate(); + m_aCtlPreviewOld.SetAttributes(aXFillAttr.GetItemSet()); + m_aCtlPreviewOld.Invalidate(); - SelectValSetHdl_Impl( m_pValSetColorList ); + SelectValSetHdl_Impl(m_xValSetColorList.get()); } } @@ -267,7 +239,6 @@ DeactivateRC SvxColorTabPage::DeactivatePage( SfxItemSet* _pSet ) return DeactivateRC::LeavePage; } - bool SvxColorTabPage::FillItemSet( SfxItemSet* rSet ) { maPaletteManager.AddRecentColor( aCurrentColor, OUString() ); @@ -279,7 +250,7 @@ bool SvxColorTabPage::FillItemSet( SfxItemSet* rSet ) void SvxColorTabPage::UpdateModified() { bool bEnable = pColorList.is() && pColorList->Count(); - m_pBtnWorkOn->Enable( bEnable ); + m_xBtnWorkOn->set_sensitive(bEnable); } void SvxColorTabPage::Reset( const SfxItemSet* rSet ) @@ -306,48 +277,53 @@ void SvxColorTabPage::Reset( const SfxItemSet* rSet ) UpdateModified(); } - -VclPtr SvxColorTabPage::Create( TabPageParent pWindow, - const SfxItemSet* rOutAttrs ) +VclPtr SvxColorTabPage::Create(TabPageParent pParent, const SfxItemSet* rOutAttrs) { - return VclPtr::Create( pWindow.pParent, *rOutAttrs ); + return VclPtr::Create(pParent, *rOutAttrs); } // is called when the content of the MtrFields is changed for color values -IMPL_LINK(SvxColorTabPage, ModifiedHdl_Impl, Edit&, rEdit, void) +IMPL_LINK_NOARG(SvxColorTabPage, SpinValueHdl_Impl, weld::SpinButton&, void) { - if (eCM == ColorModel::RGB) - { - // read current MtrFields, if cmyk, then k-value as transparency - if(&rEdit == m_pHexcustom) - aCurrentColor = m_pHexcustom->GetColor(); - else - { - aCurrentColor = Color( static_cast(PercentToColor_Impl( static_cast(m_pRcustom->GetValue()) )), - static_cast(PercentToColor_Impl( static_cast(m_pGcustom->GetValue()) )), - static_cast(PercentToColor_Impl( static_cast(m_pBcustom->GetValue()) )) ); + // read current MtrFields, if cmyk, then k-value as transparency + aCurrentColor = Color(static_cast(PercentToColor_Impl(m_xRcustom->get_value())), + static_cast(PercentToColor_Impl(m_xGcustom->get_value())), + static_cast(PercentToColor_Impl(m_xBcustom->get_value()))); + UpdateColorValues(); - } - UpdateColorValues(); - } - else - { - // read current MtrFields, if cmyk, then k-value as transparency - aCurrentColor = Color( static_cast(PercentToColor_Impl( static_cast(m_pKcustom->GetValue()) )), - static_cast(PercentToColor_Impl( static_cast(m_pCcustom->GetValue()) )), - static_cast(PercentToColor_Impl( static_cast(m_pYcustom->GetValue()) )), - static_cast(PercentToColor_Impl( static_cast(m_pMcustom->GetValue()) )) ); - ConvertColorValues (aCurrentColor, ColorModel::RGB); - } + rXFSet.Put( XFillColorItem( OUString(), aCurrentColor ) ); + m_aCtlPreviewNew.SetAttributes( aXFillAttr.GetItemSet() ); + + m_aCtlPreviewNew.Invalidate(); +} + +IMPL_LINK_NOARG(SvxColorTabPage, MetricSpinValueHdl_Impl, weld::MetricSpinButton&, void) +{ + // read current MtrFields, if cmyk, then k-value as transparency + aCurrentColor = Color(static_cast(PercentToColor_Impl(m_xKcustom->get_value(FUNIT_NONE))), + static_cast(PercentToColor_Impl(m_xCcustom->get_value(FUNIT_NONE))), + static_cast(PercentToColor_Impl(m_xYcustom->get_value(FUNIT_NONE))), + static_cast(PercentToColor_Impl(m_xMcustom->get_value(FUNIT_NONE)))); + ConvertColorValues (aCurrentColor, ColorModel::RGB); rXFSet.Put( XFillColorItem( OUString(), aCurrentColor ) ); - m_pCtlPreviewNew->SetAttributes( aXFillAttr.GetItemSet() ); + m_aCtlPreviewNew.SetAttributes( aXFillAttr.GetItemSet() ); - m_pCtlPreviewNew->Invalidate(); + m_aCtlPreviewNew.Invalidate(); } +IMPL_LINK_NOARG(SvxColorTabPage, ModifiedHdl_Impl, weld::Entry&, void) +{ + aCurrentColor = m_xHexcustom->GetColor(); + UpdateColorValues(); + + rXFSet.Put( XFillColorItem( OUString(), aCurrentColor ) ); + m_aCtlPreviewNew.SetAttributes( aXFillAttr.GetItemSet() ); -IMPL_LINK_NOARG(SvxColorTabPage, ClickAddHdl_Impl, Button*, void) + m_aCtlPreviewNew.Invalidate(); +} + +IMPL_LINK_NOARG(SvxColorTabPage, ClickAddHdl_Impl, weld::Button&, void) { OUString aNewName( SvxResId( RID_SVXSTR_COLOR ) ); OUString aDesc( CuiResId( RID_SVXSTR_DESC_COLOR ) ); @@ -387,8 +363,8 @@ IMPL_LINK_NOARG(SvxColorTabPage, ClickAddHdl_Impl, Button*, void) if (!nError) { - m_pSelectPalette->SelectEntryPos(0); - SelectPaletteLBHdl( *m_pSelectPalette ); + m_xSelectPalette->set_active(0); + SelectPaletteLBHdl(*m_xSelectPalette); std::shared_ptr batch(comphelper::ConfigurationChanges::create(m_context)); css::uno::Sequence< sal_Int32 > aCustomColorList(officecfg::Office::Common::UserColors::CustomColor::get()); css::uno::Sequence< OUString > aCustomColorNameList(officecfg::Office::Common::UserColors::CustomColorName::get()); @@ -400,17 +376,17 @@ IMPL_LINK_NOARG(SvxColorTabPage, ClickAddHdl_Impl, Button*, void) officecfg::Office::Common::UserColors::CustomColor::set(aCustomColorList, batch); officecfg::Office::Common::UserColors::CustomColorName::set(aCustomColorNameList, batch); batch->commit(); - sal_uInt16 nId = m_pValSetColorList->GetItemId(nSize - 1); - m_pValSetColorList->InsertItem( nId + 1 , aCurrentColor, aName ); - m_pValSetColorList->SelectItem( nId + 1 ); - m_pBtnDelete->Enable(); + sal_uInt16 nId = m_xValSetColorList->GetItemId(nSize - 1); + m_xValSetColorList->InsertItem( nId + 1 , aCurrentColor, aName ); + m_xValSetColorList->SelectItem( nId + 1 ); + m_xBtnDelete->set_sensitive(false); ImpColorCountChanged(); } UpdateModified(); } -IMPL_LINK_NOARG(SvxColorTabPage, ClickWorkOnHdl_Impl, Button*, void) +IMPL_LINK_NOARG(SvxColorTabPage, ClickWorkOnHdl_Impl, weld::Button&, void) { std::unique_ptr pColorDlg(new SvColorDialog( GetParentDialog() )); @@ -424,18 +400,18 @@ IMPL_LINK_NOARG(SvxColorTabPage, ClickWorkOnHdl_Impl, Button*, void) UpdateColorValues( false ); // fill ItemSet and pass it on to XOut rXFSet.Put( XFillColorItem( OUString(), aPreviewColor ) ); - //m_pCtlPreviewOld->SetAttributes( aXFillAttr ); - m_pCtlPreviewNew->SetAttributes( aXFillAttr.GetItemSet() ); + //m_aCtlPreviewOld.SetAttributes( aXFillAttr ); + m_aCtlPreviewNew.SetAttributes( aXFillAttr.GetItemSet() ); - m_pCtlPreviewNew->Invalidate(); + m_aCtlPreviewNew.Invalidate(); } } -IMPL_LINK_NOARG(SvxColorTabPage, ClickDeleteHdl_Impl, Button*, void) +IMPL_LINK_NOARG(SvxColorTabPage, ClickDeleteHdl_Impl, weld::Button&, void) { - sal_uInt16 nId = m_pValSetColorList->GetSelectedItemId(); - size_t nPos = m_pValSetColorList->GetSelectItemPos(); - if(m_pSelectPalette->GetSelectedEntryPos() == 0 && nPos != VALUESET_ITEM_NOTFOUND ) + sal_uInt16 nId = m_xValSetColorList->GetSelectedItemId(); + size_t nPos = m_xValSetColorList->GetSelectItemPos(); + if (m_xSelectPalette->get_active() == 0 && nPos != VALUESET_ITEM_NOTFOUND ) { std::shared_ptr batch(comphelper::ConfigurationChanges::create(m_context)); css::uno::Sequence< sal_Int32 > aCustomColorList(officecfg::Office::Common::UserColors::CustomColor::get()); @@ -451,24 +427,24 @@ IMPL_LINK_NOARG(SvxColorTabPage, ClickDeleteHdl_Impl, Button*, void) officecfg::Office::Common::UserColors::CustomColor::set(aCustomColorList, batch); officecfg::Office::Common::UserColors::CustomColorName::set(aCustomColorNameList, batch); batch->commit(); - m_pValSetColorList->RemoveItem(nId); - if(m_pValSetColorList->GetItemCount() != 0) + m_xValSetColorList->RemoveItem(nId); + if (m_xValSetColorList->GetItemCount() != 0) { - nId = m_pValSetColorList->GetItemId(0); - m_pValSetColorList->SelectItem(nId); - SelectValSetHdl_Impl( m_pValSetColorList ); + nId = m_xValSetColorList->GetItemId(0); + m_xValSetColorList->SelectItem(nId); + SelectValSetHdl_Impl(m_xValSetColorList.get()); } else - m_pBtnDelete->Disable(); + m_xBtnDelete->set_sensitive(false); } } -IMPL_LINK_NOARG(SvxColorTabPage, SelectPaletteLBHdl, ListBox&, void) +IMPL_LINK_NOARG(SvxColorTabPage, SelectPaletteLBHdl, weld::ComboBoxText&, void) { - m_pValSetColorList->Clear(); - sal_Int32 nPos = m_pSelectPalette->GetSelectedEntryPos(); + m_xValSetColorList->Clear(); + sal_Int32 nPos = m_xSelectPalette->get_active(); maPaletteManager.SetPalette( nPos ); - maPaletteManager.ReloadColorSet( *m_pValSetColorList ); + maPaletteManager.ReloadColorSet(*m_xValSetColorList); if(nPos != maPaletteManager.GetPaletteCount() - 1 && nPos != 0) { @@ -491,13 +467,13 @@ IMPL_LINK_NOARG(SvxColorTabPage, SelectPaletteLBHdl, ListBox&, void) *pnColorListState &= ~ChangeType::MODIFIED; } } - if(nPos != 0) - m_pBtnDelete->Disable(); + if (nPos != 0) + m_xBtnDelete->set_sensitive(false); - m_pValSetColorList->Resize(); + m_xValSetColorList->Resize(); } -IMPL_LINK(SvxColorTabPage, SelectValSetHdl_Impl, ValueSet*, pValSet, void) +IMPL_LINK(SvxColorTabPage, SelectValSetHdl_Impl, SvtValueSet*, pValSet, void) { sal_Int32 nPos = pValSet->GetSelectedItemId(); if( nPos != 0 ) @@ -505,22 +481,22 @@ IMPL_LINK(SvxColorTabPage, SelectValSetHdl_Impl, ValueSet*, pValSet, void) Color aColor = pValSet->GetItemColor( nPos ); rXFSet.Put( XFillColorItem( OUString(), aColor ) ); - m_pCtlPreviewNew->SetAttributes( aXFillAttr.GetItemSet() ); - m_pCtlPreviewNew->Invalidate(); + m_aCtlPreviewNew.SetAttributes( aXFillAttr.GetItemSet() ); + m_aCtlPreviewNew.Invalidate(); ChangeColor(aColor, false); - if(pValSet == m_pValSetColorList) + if (pValSet == m_xValSetColorList.get()) { - m_pValSetRecentList->SetNoSelection(); - if(m_pSelectPalette->GetSelectedEntryPos() == 0 && m_pValSetColorList->GetSelectedItemId() != 0) - m_pBtnDelete->Enable(); + m_xValSetRecentList->SetNoSelection(); + if (m_xSelectPalette->get_active() == 0 && m_xValSetColorList->GetSelectedItemId() != 0) + m_xBtnDelete->set_sensitive(true); else - m_pBtnDelete->Disable(); + m_xBtnDelete->set_sensitive(false); } - if(pValSet == m_pValSetRecentList) + if (pValSet == m_xValSetRecentList.get()) { - m_pValSetColorList->SetNoSelection(); - m_pBtnDelete->Disable(); + m_xValSetColorList->SetNoSelection(); + m_xBtnDelete->set_sensitive(false); } } } @@ -545,11 +521,12 @@ void SvxColorTabPage::ConvertColorValues (Color& rColor, ColorModel eModell) break; } } -IMPL_LINK(SvxColorTabPage, SelectColorModeHdl_Impl, RadioButton&, rRadioButton, void) + +IMPL_LINK_NOARG(SvxColorTabPage, SelectColorModeHdl_Impl, weld::ToggleButton&, void) { - if( &rRadioButton == m_pRbRGB ) + if (m_xRbRGB->get_active()) eCM = ColorModel::RGB; - if( &rRadioButton == m_pRbCMYK ) + else if (m_xRbCMYK->get_active()) eCM = ColorModel::CMYK; ChangeColorModel(); UpdateColorValues(); @@ -562,18 +539,16 @@ void SvxColorTabPage::ChangeColor(const Color &rNewColor, bool bUpdatePreset ) UpdateColorValues( bUpdatePreset ); // fill ItemSet and pass it on to XOut rXFSet.Put( XFillColorItem( OUString(), aCurrentColor ) ); - m_pCtlPreviewNew->SetAttributes( aXFillAttr.GetItemSet() ); - m_pCtlPreviewNew->Invalidate(); + m_aCtlPreviewNew.SetAttributes(aXFillAttr.GetItemSet()); + m_aCtlPreviewNew.Invalidate(); } void SvxColorTabPage::SetColorModel( ColorModel eModel ) { - m_pRbRGB->SetState(false); - m_pRbCMYK->SetState(false); - if(eModel == ColorModel::RGB) - m_pRbRGB->SetState(true); - if(eModel == ColorModel::CMYK) - m_pRbCMYK->SetState(true); + if (eModel == ColorModel::RGB) + m_xRbRGB->set_active(true); + else if (eModel == ColorModel::CMYK) + m_xRbCMYK->set_active(true); } void SvxColorTabPage::ChangeColorModel() @@ -582,19 +557,19 @@ void SvxColorTabPage::ChangeColorModel() { case ColorModel::RGB: { - m_pRGBcustom->Show(); - m_pRGBpreset->Show(); - m_pCMYKcustom->Hide(); - m_pCMYKpreset->Hide(); + m_xRGBcustom->show(); + m_xRGBpreset->show(); + m_xCMYKcustom->hide(); + m_xCMYKpreset->hide(); } break; case ColorModel::CMYK: { - m_pCMYKcustom->Show(); - m_pCMYKpreset->Show(); - m_pRGBcustom->Hide(); - m_pRGBpreset->Hide(); + m_xCMYKcustom->show(); + m_xCMYKpreset->show(); + m_xRGBcustom->hide(); + m_xRGBpreset->hide(); } break; } @@ -607,17 +582,21 @@ void SvxColorTabPage::UpdateColorValues( bool bUpdatePreset ) ConvertColorValues (aPreviousColor, eCM ); ConvertColorValues (aCurrentColor, eCM); - m_pCcustom->SetValue( ColorToPercent_Impl( aCurrentColor.GetRed() ) ); - m_pMcustom->SetValue( ColorToPercent_Impl( aCurrentColor.GetBlue() ) ); - m_pYcustom->SetValue( ColorToPercent_Impl( aCurrentColor.GetGreen() ) ); - m_pKcustom->SetValue( ColorToPercent_Impl( aCurrentColor.GetTransparency() ) ); + m_xCcustom->set_value( ColorToPercent_Impl( aCurrentColor.GetRed() ), FUNIT_PERCENT ); + m_xMcustom->set_value( ColorToPercent_Impl( aCurrentColor.GetBlue() ), FUNIT_PERCENT ); + m_xYcustom->set_value( ColorToPercent_Impl( aCurrentColor.GetGreen() ), FUNIT_PERCENT ); + m_xKcustom->set_value( ColorToPercent_Impl( aCurrentColor.GetTransparency() ), FUNIT_PERCENT ); if( bUpdatePreset ) { - m_pCpreset->SetValue( ColorToPercent_Impl( aPreviousColor.GetRed() ) ); - m_pMpreset->SetValue( ColorToPercent_Impl( aPreviousColor.GetBlue() ) ); - m_pYpreset->SetValue( ColorToPercent_Impl( aPreviousColor.GetGreen() ) ); - m_pKpreset->SetValue( ColorToPercent_Impl( aPreviousColor.GetTransparency() ) ); + m_xCpreset->set_text(unicode::formatPercent(ColorToPercent_Impl(aPreviousColor.GetRed()), + Application::GetSettings().GetUILanguageTag())); + m_xMpreset->set_text(unicode::formatPercent(ColorToPercent_Impl(aPreviousColor.GetBlue()), + Application::GetSettings().GetUILanguageTag())); + m_xYpreset->set_text(unicode::formatPercent(ColorToPercent_Impl(aPreviousColor.GetGreen()), + Application::GetSettings().GetUILanguageTag())); + m_xKpreset->set_text(unicode::formatPercent(ColorToPercent_Impl(aPreviousColor.GetTransparency()), + Application::GetSettings().GetUILanguageTag())); } ConvertColorValues (aPreviousColor, ColorModel::RGB); @@ -625,17 +604,17 @@ void SvxColorTabPage::UpdateColorValues( bool bUpdatePreset ) } else { - m_pRcustom->SetValue( ColorToPercent_Impl( aCurrentColor.GetRed() ) ); - m_pGcustom->SetValue( ColorToPercent_Impl( aCurrentColor.GetGreen() ) ); - m_pBcustom->SetValue( ColorToPercent_Impl( aCurrentColor.GetBlue() ) ); - m_pHexcustom->SetColor( aCurrentColor ); + m_xRcustom->set_value( ColorToPercent_Impl( aCurrentColor.GetRed() ) ); + m_xGcustom->set_value( ColorToPercent_Impl( aCurrentColor.GetGreen() ) ); + m_xBcustom->set_value( ColorToPercent_Impl( aCurrentColor.GetBlue() ) ); + m_xHexcustom->SetColor( aCurrentColor ); if( bUpdatePreset ) { - m_pRpreset->SetValue( ColorToPercent_Impl( aPreviousColor.GetRed() ) ); - m_pGpreset->SetValue( ColorToPercent_Impl( aPreviousColor.GetGreen() ) ); - m_pBpreset->SetValue( ColorToPercent_Impl( aPreviousColor.GetBlue() ) ); - m_pHexpreset->SetColor( aPreviousColor ); + m_xRpreset->set_text(OUString::number(ColorToPercent_Impl(aPreviousColor.GetRed()))); + m_xGpreset->set_text(OUString::number(ColorToPercent_Impl(aPreviousColor.GetGreen()))); + m_xBpreset->set_text(OUString::number(ColorToPercent_Impl(aPreviousColor.GetBlue()))); + m_xHexpreset->SetColor( aPreviousColor ); } } } diff --git a/cui/uiconfig/ui/colorpage.ui b/cui/uiconfig/ui/colorpage.ui index 915092fe3c89..f563456cf7e5 100644 --- a/cui/uiconfig/ui/colorpage.ui +++ b/cui/uiconfig/ui/colorpage.ui @@ -1,8 +1,7 @@ - + - 100 1 @@ -13,6 +12,31 @@ 1 10 + + 100 + 1 + 10 + + + 100 + 1 + 10 + + + 100 + 1 + 10 + + + 255 + 1 + 10 + + + 255 + 1 + 10 + True False @@ -55,11 +79,11 @@ True False center - 0 - 0 Palette: True paletteselector + 0 + 0 False @@ -68,7 +92,7 @@ - + True False @@ -82,8 +106,6 @@ 0 0 - 1 - 1 @@ -97,10 +119,10 @@ True False - 0 Recent Colors True recentcolorset + 0 False @@ -109,7 +131,7 @@ - + True True True @@ -125,8 +147,6 @@ 0 2 - 1 - 1 @@ -147,8 +167,6 @@ 0 1 - 1 - 1 @@ -164,8 +182,6 @@ 0 2 - 1 - 1 @@ -175,14 +191,12 @@ False True 0 - True True + RGB 1 2 - 1 - 1 @@ -195,8 +209,6 @@ 1 1 - 1 - 1 @@ -204,22 +216,19 @@ True False 3 - 0 Custom Palette + 0 0 0 2 - 1 0 3 - 1 - 1 @@ -229,11 +238,25 @@ start vertical - + True True - True - True + never + in + + + True + False + + + True + True + True + True + + + + False @@ -245,8 +268,6 @@ 0 1 - 1 - 1 @@ -295,7 +316,7 @@ False vertical - + True False True @@ -334,13 +355,11 @@ False B True - B_custom + B_preset 0 2 - 1 - 1 @@ -349,13 +368,11 @@ False G True - G_custom + G_preset 0 1 - 1 - 1 @@ -364,13 +381,11 @@ False R True - R_custom + R_preset 0 0 - 1 - 1 @@ -378,64 +393,60 @@ True False Hex + True + hex_preset 0 3 - 1 - 1 - + 6 True True + False 1 3 - 1 - 1 - + True True - adjustment2 + False + 3 1 0 - 1 - 1 - + True True - adjustment2 + False + 3 1 1 - 1 - 1 - + True True - adjustment2 + False + 3 1 2 - 1 - 1 @@ -459,13 +470,11 @@ False _C True - C_custom:0% + C_preset 0 0 - 1 - 1 @@ -474,13 +483,11 @@ False _K True - K_custom:0% + K_preset 0 3 - 1 - 1 @@ -489,64 +496,59 @@ False _Y True + Y_preset 0 2 - 1 - 1 - + True True - adjustment1 + False + 3 1 0 - 1 - 1 - + True True - adjustment1 + False + 3 1 1 - 1 - 1 - + True True - adjustment1 + False + 3 1 2 - 1 - 1 - + True True - adjustment1 + False + 3 1 3 - 1 - 1 @@ -555,12 +557,11 @@ False _M True + M_preset 0 1 - 1 - 1 @@ -617,7 +618,7 @@ False vertical - + True False True @@ -654,28 +655,26 @@ True True + True Blue - adjustment2 + adjustment7 1 2 - 1 - 1 True True + True Red adjustment2 1 0 - 1 - 1 @@ -684,12 +683,11 @@ False _B True + B_custom 0 2 - 1 - 1 @@ -698,12 +696,11 @@ False _G True + G_custom 0 1 - 1 - 1 @@ -712,26 +709,24 @@ False _R True + R_custom 0 0 - 1 - 1 True True + True Green - adjustment2 + adjustment6 1 1 - 1 - 1 @@ -745,21 +740,18 @@ 0 3 - 1 - 1 - + 6 True True + True 1 3 - 1 - 1 @@ -784,13 +776,11 @@ False _C True - C_custom:0% + C_custom 0 0 - 1 - 1 @@ -799,12 +789,11 @@ False _M True + M_custom 0 1 - 1 - 1 @@ -813,39 +802,35 @@ False _K True - K_custom:0% + K_custom 0 3 - 1 - 1 - + True True + True adjustment1 1 0 - 1 - 1 - + True True - adjustment1 + True + adjustment5 1 3 - 1 - 1 @@ -854,38 +839,35 @@ False _Y True + Y_custom 0 2 - 1 - 1 - + True True - adjustment1 + True + adjustment4 1 2 - 1 - 1 - + True True - adjustment1 + True + adjustment3 1 1 - 1 - 1 @@ -937,10 +919,10 @@ - - + + - + -- cgit