diff options
author | Caolán McNamara <caolanm@redhat.com> | 2019-12-27 17:18:44 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2020-01-01 13:19:28 +0100 |
commit | b199e335c01f265ba2604c020928b63356b42d15 (patch) | |
tree | 1015423b1bb5b45ce28e8a4a47ea6e20188b8795 /sc | |
parent | f0fc4ac88d0d82ee81e0a55bdc54421f955705f0 (diff) |
weld NumberFormatPropertyPanel
including GtkMenuToolButton hackery to support a toggled state
Change-Id: Ia1cf5fd7d56c2e475194cd2d0431611f278f5a33
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/85873
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/ui/sidebar/NumberFormatPropertyPanel.cxx | 194 | ||||
-rw-r--r-- | sc/source/ui/sidebar/NumberFormatPropertyPanel.hxx | 35 | ||||
-rw-r--r-- | sc/uiconfig/scalc/ui/sidebarnumberformat.ui | 59 |
3 files changed, 143 insertions, 145 deletions
diff --git a/sc/source/ui/sidebar/NumberFormatPropertyPanel.cxx b/sc/source/ui/sidebar/NumberFormatPropertyPanel.cxx index 7d8a8401ac84..a1d3c4eb7461 100644 --- a/sc/source/ui/sidebar/NumberFormatPropertyPanel.cxx +++ b/sc/source/ui/sidebar/NumberFormatPropertyPanel.cxx @@ -38,26 +38,25 @@ NumberFormatPropertyPanel::NumberFormatPropertyPanel( vcl::Window* pParent, const css::uno::Reference<css::frame::XFrame>& rxFrame, SfxBindings* pBindings) - : PanelLayout(pParent,"NumberFormatPropertyPanel", "modules/scalc/ui/sidebarnumberformat.ui", rxFrame), - maNumFormatControl(SID_NUMBER_TYPE_FORMAT, *pBindings, *this), - maFormatControl(SID_NUMBER_FORMAT, *pBindings, *this), - - mnCategorySelected(0), - maContext(), - mpBindings(pBindings) + : PanelLayout(pParent,"NumberFormatPropertyPanel", "modules/scalc/ui/sidebarnumberformat.ui", rxFrame, true) + , mxLbCategory(m_xBuilder->weld_combo_box("category")) + , mxTBCategory(m_xBuilder->weld_toolbar("numberformat")) + , mxCatagoryDispatch(new ToolbarUnoDispatcher(*mxTBCategory, rxFrame)) + , mxFtDecimals(m_xBuilder->weld_label("decimalplaceslabel")) + , mxEdDecimals(m_xBuilder->weld_spin_button("decimalplaces")) + , mxFtDenominator(m_xBuilder->weld_label("denominatorplaceslabel")) + , mxEdDenominator(m_xBuilder->weld_spin_button("denominatorplaces")) + , mxFtLeadZeroes(m_xBuilder->weld_label("leadingzeroeslabel")) + , mxEdLeadZeroes(m_xBuilder->weld_spin_button("leadingzeroes")) + , mxBtnNegRed(m_xBuilder->weld_check_button("negativenumbersred")) + , mxBtnThousand(m_xBuilder->weld_check_button("thousandseparator")) + , mxBtnEngineering(m_xBuilder->weld_check_button("engineeringnotation")) + , maNumFormatControl(SID_NUMBER_TYPE_FORMAT, *pBindings, *this) + , maFormatControl(SID_NUMBER_FORMAT, *pBindings, *this) + , mnCategorySelected(0) + , maContext() + , mpBindings(pBindings) { - get(mpLbCategory, "category"); - get(mpTBCategory, "numberformat"); - get(mpFtDecimals, "decimalplaceslabel"); - get(mpEdDecimals, "decimalplaces"); - get(mpFtDenominator, "denominatorplaceslabel"); - get(mpEdDenominator, "denominatorplaces"); - get(mpFtLeadZeroes, "leadingzeroeslabel"); - get(mpEdLeadZeroes, "leadingzeroes"); - get(mpBtnNegRed, "negativenumbersred"); - get(mpBtnThousand, "thousandseparator"); - get(mpBtnEngineering, "engineeringnotation"); - Initialize(); } @@ -68,17 +67,18 @@ NumberFormatPropertyPanel::~NumberFormatPropertyPanel() void NumberFormatPropertyPanel::dispose() { - mpLbCategory.clear(); - mpTBCategory.clear(); - mpFtDecimals.clear(); - mpEdDecimals.clear(); - mpFtDenominator.clear(); - mpEdDenominator.clear(); - mpFtLeadZeroes.clear(); - mpEdLeadZeroes.clear(); - mpBtnNegRed.clear(); - mpBtnThousand.clear(); - mpBtnEngineering.clear(); + mxLbCategory.reset(); + mxCatagoryDispatch.reset(); + mxTBCategory.reset(); + mxFtDecimals.reset(); + mxEdDecimals.reset(); + mxFtDenominator.reset(); + mxEdDenominator.reset(); + mxFtLeadZeroes.reset(); + mxEdLeadZeroes.reset(); + mxBtnNegRed.reset(); + mxBtnThousand.reset(); + mxBtnEngineering.reset(); maNumFormatControl.dispose(); maFormatControl.dispose(); @@ -88,24 +88,23 @@ void NumberFormatPropertyPanel::dispose() void NumberFormatPropertyPanel::Initialize() { - mpLbCategory->SetSelectHdl ( LINK(this, NumberFormatPropertyPanel, NumFormatSelectHdl) ); - mpLbCategory->SelectEntryPos(0); - mpLbCategory->SetDropDownLineCount(mpLbCategory->GetEntryCount()); + mxLbCategory->connect_changed( LINK(this, NumberFormatPropertyPanel, NumFormatSelectHdl) ); + mxLbCategory->set_active(0); - Link<Edit&,void> aLink = LINK(this, NumberFormatPropertyPanel, NumFormatValueHdl); + Link<weld::SpinButton&,void> aLink = LINK(this, NumberFormatPropertyPanel, NumFormatValueHdl); - mpEdDecimals->SetModifyHdl( aLink ); - mpEdDenominator->SetModifyHdl( aLink ); - mpEdLeadZeroes->SetModifyHdl( aLink ); + mxEdDecimals->connect_value_changed( aLink ); + mxEdDenominator->connect_value_changed( aLink ); + mxEdLeadZeroes->connect_value_changed( aLink ); - mpBtnNegRed->SetClickHdl( LINK(this, NumberFormatPropertyPanel, NumFormatValueClickHdl) ); - mpBtnThousand->SetClickHdl( LINK(this, NumberFormatPropertyPanel, NumFormatValueClickHdl) ); - mpBtnEngineering->SetClickHdl( LINK(this, NumberFormatPropertyPanel, NumFormatValueClickHdl) ); + mxBtnNegRed->connect_toggled( LINK(this, NumberFormatPropertyPanel, NumFormatValueClickHdl) ); + mxBtnThousand->connect_toggled( LINK(this, NumberFormatPropertyPanel, NumFormatValueClickHdl) ); + mxBtnEngineering->connect_toggled( LINK(this, NumberFormatPropertyPanel, NumFormatValueClickHdl) ); } -IMPL_LINK( NumberFormatPropertyPanel, NumFormatSelectHdl, ListBox&, rBox, void ) +IMPL_LINK( NumberFormatPropertyPanel, NumFormatSelectHdl, weld::ComboBox&, rBox, void ) { - const sal_Int32 nVal = rBox.GetSelectedEntryPos(); + const sal_Int32 nVal = rBox.get_active(); if( nVal != mnCategorySelected ) { SfxUInt16Item aItem( SID_NUMBER_TYPE_FORMAT, nVal ); @@ -115,24 +114,25 @@ IMPL_LINK( NumberFormatPropertyPanel, NumFormatSelectHdl, ListBox&, rBox, void ) } } -IMPL_LINK_NOARG( NumberFormatPropertyPanel, NumFormatValueClickHdl, Button*, void ) +IMPL_LINK_NOARG( NumberFormatPropertyPanel, NumFormatValueClickHdl, weld::ToggleButton&, void ) { - NumFormatValueHdl(*mpEdDecimals); + NumFormatValueHdl(*mxEdDecimals); } -IMPL_LINK_NOARG( NumberFormatPropertyPanel, NumFormatValueHdl, Edit&, void ) + +IMPL_LINK_NOARG( NumberFormatPropertyPanel, NumFormatValueHdl, weld::SpinButton&, void ) { OUString aFormat; OUString sBreak = ","; - bool bThousand = ( mpBtnThousand->IsVisible() && mpBtnThousand->IsEnabled() && mpBtnThousand->IsChecked() ) - || ( mpBtnEngineering->IsVisible() && mpBtnEngineering->IsEnabled() && mpBtnEngineering->IsChecked() ); - bool bNegRed = mpBtnNegRed->IsEnabled() && mpBtnNegRed->IsChecked(); - sal_uInt16 nPrecision = (mpEdDecimals->IsEnabled() && mpEdDecimals->IsVisible()) - ? static_cast<sal_uInt16>(mpEdDecimals->GetValue()) - : (mpEdDenominator->IsEnabled() && mpEdDenominator->IsVisible()) - ? static_cast<sal_uInt16>(mpEdDenominator->GetValue()) + bool bThousand = ( mxBtnThousand->get_visible() && mxBtnThousand->get_sensitive() && mxBtnThousand->get_active() ) + || ( mxBtnEngineering->get_visible() && mxBtnEngineering->get_sensitive() && mxBtnEngineering->get_active() ); + bool bNegRed = mxBtnNegRed->get_sensitive() && mxBtnNegRed->get_active(); + sal_uInt16 nPrecision = (mxEdDecimals->get_sensitive() && mxEdDecimals->get_visible()) + ? static_cast<sal_uInt16>(mxEdDecimals->get_value()) + : (mxEdDenominator->get_sensitive() && mxEdDenominator->get_visible()) + ? static_cast<sal_uInt16>(mxEdDenominator->get_value()) : sal_uInt16(0); - sal_uInt16 nLeadZeroes = (mpEdLeadZeroes->IsEnabled()) - ? static_cast<sal_uInt16>(mpEdLeadZeroes->GetValue()) + sal_uInt16 nLeadZeroes = (mxEdLeadZeroes->get_sensitive()) + ? static_cast<sal_uInt16>(mxEdLeadZeroes->get_value()) : sal_uInt16(0); OUString sThousand = OUString::number(static_cast<sal_Int32>(bThousand)); @@ -200,30 +200,30 @@ void NumberFormatPropertyPanel::NotifyItemUpdate( const SfxInt16Item* pItem = static_cast<const SfxInt16Item*>(pState); sal_uInt16 nVal = pItem->GetValue(); mnCategorySelected = nVal; - mpLbCategory->SelectEntryPos(nVal); + mxLbCategory->set_active(nVal); if( nVal < 4 || // General, Number, Percent and Currency nVal == 6 || // scientific also nVal == 7 ) // fraction { bool bIsScientific ( nVal == 6 );// For scientific, Thousand separator is replaced by Engineering notation bool bIsFraction ( nVal == 7 ); // For fraction, Decimal places is replaced by Denominator places - mpBtnThousand->Show(!bIsScientific); - mpBtnThousand->Enable(!bIsScientific); - mpBtnThousand->Check(false); - mpBtnEngineering->Show(bIsScientific); - mpBtnEngineering->Enable(bIsScientific); - mpBtnEngineering->Check(false); - mpBtnNegRed->Enable(); - mpFtDenominator->Show(bIsFraction); - mpEdDenominator->Show(bIsFraction); - mpFtDenominator->Enable(bIsFraction); - mpEdDenominator->Enable(bIsFraction); - mpFtDecimals->Show(!bIsFraction); - mpEdDecimals->Show(!bIsFraction); - mpFtDecimals->Enable(!bIsFraction); - mpEdDecimals->Enable(!bIsFraction); - mpFtLeadZeroes->Enable(); - mpEdLeadZeroes->Enable(); + mxBtnThousand->set_visible(!bIsScientific); + mxBtnThousand->set_sensitive(!bIsScientific); + mxBtnThousand->set_active(false); + mxBtnEngineering->set_visible(bIsScientific); + mxBtnEngineering->set_sensitive(bIsScientific); + mxBtnEngineering->set_active(false); + mxBtnNegRed->set_sensitive(true); + mxFtDenominator->set_visible(bIsFraction); + mxEdDenominator->set_visible(bIsFraction); + mxFtDenominator->set_sensitive(bIsFraction); + mxEdDenominator->set_sensitive(bIsFraction); + mxFtDecimals->set_visible(!bIsFraction); + mxEdDecimals->set_visible(!bIsFraction); + mxFtDecimals->set_sensitive(!bIsFraction); + mxEdDecimals->set_sensitive(!bIsFraction); + mxFtLeadZeroes->set_sensitive(true); + mxEdLeadZeroes->set_sensitive(true); } else DisableControls(); @@ -231,7 +231,7 @@ void NumberFormatPropertyPanel::NotifyItemUpdate( else { DisableControls(); - mpLbCategory->SetNoSelection(); + mxLbCategory->set_active(-1); mnCategorySelected = 0; } } @@ -266,18 +266,18 @@ void NumberFormatPropertyPanel::NotifyItemUpdate( nPrecision = 0; nLeadZeroes = 1; } - if ( mpBtnThousand->IsVisible() ) - mpBtnThousand->Check(bThousand); - else if ( mpBtnEngineering->IsVisible() ) - mpBtnEngineering->Check(bThousand); - mpBtnNegRed->Check(bNegRed); - if ( mpLbCategory->GetSelectedEntryPos() == 0 ) - mpEdDecimals->SetText(""); // tdf#44399 - else if ( mpEdDecimals->IsVisible() ) - mpEdDecimals->SetValue(nPrecision); - else if ( mpEdDenominator->IsVisible() ) - mpEdDenominator->SetValue(nPrecision); - mpEdLeadZeroes->SetValue(nLeadZeroes); + if ( mxBtnThousand->get_visible() ) + mxBtnThousand->set_active(bThousand); + else if ( mxBtnEngineering->get_visible() ) + mxBtnEngineering->set_active(bThousand); + mxBtnNegRed->set_active(bNegRed); + if ( mxLbCategory->get_active() == 0 ) + mxEdDecimals->set_text(""); // tdf#44399 + else if ( mxEdDecimals->get_visible() ) + mxEdDecimals->set_value(nPrecision); + else if ( mxEdDenominator->get_visible() ) + mxEdDenominator->set_value(nPrecision); + mxEdLeadZeroes->set_value(nLeadZeroes); } break; default: @@ -287,18 +287,18 @@ void NumberFormatPropertyPanel::NotifyItemUpdate( void NumberFormatPropertyPanel::DisableControls() { - mpBtnEngineering->Hide(); - mpBtnThousand->Show(); - mpBtnThousand->Disable(); - mpBtnNegRed->Disable(); - mpFtDenominator->Hide(); - mpEdDenominator->Hide(); - mpFtDecimals->Show(); - mpEdDecimals->Show(); - mpFtDecimals->Disable(); - mpEdDecimals->Disable(); - mpFtLeadZeroes->Disable(); - mpEdLeadZeroes->Disable(); + mxBtnEngineering->hide(); + mxBtnThousand->show(); + mxBtnThousand->set_sensitive(false); + mxBtnNegRed->set_sensitive(false); + mxFtDenominator->hide(); + mxEdDenominator->hide(); + mxFtDecimals->show(); + mxEdDecimals->show(); + mxFtDecimals->set_sensitive(false); + mxEdDecimals->set_sensitive(false); + mxFtLeadZeroes->set_sensitive(false); + mxEdLeadZeroes->set_sensitive(false); } }} // end of namespace ::sc::sidebar diff --git a/sc/source/ui/sidebar/NumberFormatPropertyPanel.hxx b/sc/source/ui/sidebar/NumberFormatPropertyPanel.hxx index 0406f3384381..74eaa1f37a86 100644 --- a/sc/source/ui/sidebar/NumberFormatPropertyPanel.hxx +++ b/sc/source/ui/sidebar/NumberFormatPropertyPanel.hxx @@ -21,12 +21,8 @@ #include <sfx2/sidebar/ControllerItem.hxx> #include <sfx2/sidebar/IContextChangeReceiver.hxx> +#include <sfx2/weldutils.hxx> #include <svx/sidebar/PanelLayout.hxx> -#include <vcl/fixed.hxx> -#include <vcl/lstbox.hxx> -#include <vcl/field.hxx> -#include <vcl/button.hxx> -#include <vcl/toolbox.hxx> class Edit; @@ -66,17 +62,18 @@ public: virtual void dispose() override; private: //ui controls - VclPtr<ListBox> mpLbCategory; - VclPtr<ToolBox> mpTBCategory; - VclPtr<FixedText> mpFtDecimals; - VclPtr<NumericField> mpEdDecimals; - VclPtr<FixedText> mpFtDenominator; - VclPtr<NumericField> mpEdDenominator; - VclPtr<FixedText> mpFtLeadZeroes; - VclPtr<NumericField> mpEdLeadZeroes; - VclPtr<CheckBox> mpBtnNegRed; - VclPtr<CheckBox> mpBtnThousand; - VclPtr<CheckBox> mpBtnEngineering; + std::unique_ptr<weld::ComboBox> mxLbCategory; + std::unique_ptr<weld::Toolbar> mxTBCategory; + std::unique_ptr<ToolbarUnoDispatcher> mxCatagoryDispatch; + std::unique_ptr<weld::Label> mxFtDecimals; + std::unique_ptr<weld::SpinButton> mxEdDecimals; + std::unique_ptr<weld::Label> mxFtDenominator; + std::unique_ptr<weld::SpinButton> mxEdDenominator; + std::unique_ptr<weld::Label> mxFtLeadZeroes; + std::unique_ptr<weld::SpinButton> mxEdLeadZeroes; + std::unique_ptr<weld::CheckButton> mxBtnNegRed; + std::unique_ptr<weld::CheckButton> mxBtnThousand; + std::unique_ptr<weld::CheckButton> mxBtnEngineering; ::sfx2::sidebar::ControllerItem maNumFormatControl; ::sfx2::sidebar::ControllerItem maFormatControl; @@ -86,9 +83,9 @@ private: vcl::EnumContext maContext; SfxBindings* const mpBindings; - DECL_LINK(NumFormatSelectHdl, ListBox&, void); - DECL_LINK(NumFormatValueHdl, Edit&, void); - DECL_LINK(NumFormatValueClickHdl, Button*, void); + DECL_LINK(NumFormatSelectHdl, weld::ComboBox&, void); + DECL_LINK(NumFormatValueHdl, weld::SpinButton&, void); + DECL_LINK(NumFormatValueClickHdl, weld::ToggleButton&, void); void Initialize(); void DisableControls(); diff --git a/sc/uiconfig/scalc/ui/sidebarnumberformat.ui b/sc/uiconfig/scalc/ui/sidebarnumberformat.ui index 21857e404bf1..291d5b6f4c5c 100644 --- a/sc/uiconfig/scalc/ui/sidebarnumberformat.ui +++ b/sc/uiconfig/scalc/ui/sidebarnumberformat.ui @@ -1,8 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> -<!-- Generated with glade 3.20.0 --> +<!-- Generated with glade 3.22.1 --> <interface domain="sc"> <requires lib="gtk+" version="3.18"/> - <requires lib="LibreOffice" version="1.0"/> <object class="GtkAdjustment" id="adjustment1"> <property name="upper">20</property> <property name="step_increment">1</property> @@ -13,6 +12,11 @@ <property name="step_increment">1</property> <property name="page_increment">1</property> </object> + <object class="GtkAdjustment" id="adjustment3"> + <property name="upper">20</property> + <property name="step_increment">1</property> + <property name="page_increment">10</property> + </object> <object class="GtkGrid" id="NumberFormatPropertyPanel"> <property name="visible">True</property> <property name="can_focus">False</property> @@ -36,6 +40,7 @@ <property name="can_focus">True</property> <property name="has_tooltip">True</property> <property name="tooltip_text" translatable="yes" context="sidebarnumberformat|category|tooltip_text">Select a category of contents.</property> + <property name="valign">center</property> <property name="hexpand">True</property> <items> <item translatable="yes" context="sidebarnumberformat|category">General</item> @@ -61,44 +66,43 @@ </packing> </child> <child> - <object class="sfxlo-SidebarToolBox" id="numberformat"> + <object class="GtkToolbar" id="numberformat"> <property name="visible">True</property> <property name="can_focus">True</property> + <property name="toolbar_style">icons</property> <property name="show_arrow">False</property> + <property name="icon_size">2</property> <child> - <object class="GtkToolButton" id="currency"> + <object class="GtkMenuToolButton" id=".uno:NumberFormatCurrency"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="action_name">.uno:NumberFormatCurrency</property> <property name="use_underline">True</property> </object> <packing> <property name="expand">False</property> - <property name="homogeneous">True</property> + <property name="homogeneous">False</property> </packing> </child> <child> - <object class="GtkToolButton" id="percent"> + <object class="GtkToggleToolButton" id=".uno:NumberFormatPercent"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="action_name">.uno:NumberFormatPercent</property> <property name="use_underline">True</property> </object> <packing> <property name="expand">False</property> - <property name="homogeneous">True</property> + <property name="homogeneous">False</property> </packing> </child> <child> - <object class="GtkToolButton" id="numericfield"> + <object class="GtkToggleToolButton" id=".uno:NumberFormatDecimal"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="action_name">.uno:NumberFormatDecimal</property> <property name="use_underline">True</property> </object> <packing> <property name="expand">False</property> - <property name="homogeneous">True</property> + <property name="homogeneous">False</property> </packing> </child> </object> @@ -126,6 +130,19 @@ <property name="orientation">vertical</property> <property name="spacing">6</property> <child> + <object class="GtkLabel" id="denominatorplaceslabel"> + <property name="can_focus">False</property> + <property name="label" translatable="yes" context="sidebarnumberformat|denominatorplaceslabel">Den_ominator places:</property> + <property name="use_underline">True</property> + <property name="mnemonic_widget">denominatorplaces</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> <object class="GtkLabel" id="decimalplaceslabel"> <property name="visible">True</property> <property name="can_focus">False</property> @@ -145,7 +162,7 @@ <property name="can_focus">True</property> <property name="has_tooltip">True</property> <property name="tooltip_text" translatable="yes" context="sidebarnumberformat|decimalplaces|tooltip_text">Enter the number of decimal places that you want to display.</property> - <property name="adjustment">adjustment1</property> + <property name="adjustment">adjustment3</property> <child internal-child="accessible"> <object class="AtkObject" id="decimalplaces-atkobject"> <property name="AtkObject::accessible-name" translatable="yes" context="sidebarnumberformat|decimalplaces-atkobject">Decimal Places</property> @@ -159,22 +176,7 @@ </packing> </child> <child> - <object class="GtkLabel" id="denominatorplaceslabel"> - <property name="visible">False</property> - <property name="can_focus">False</property> - <property name="label" translatable="yes" context="sidebarnumberformat|denominatorplaceslabel">Den_ominator places:</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">denominatorplaces</property> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">0</property> - </packing> - </child> - <child> <object class="GtkSpinButton" id="denominatorplaces"> - <property name="visible">False</property> <property name="can_focus">True</property> <property name="has_tooltip">True</property> <property name="tooltip_text" translatable="yes" context="sidebarnumberformat|denominatorplaces|tooltip_text">Enter the number of places for the denominator that you want to display.</property> @@ -292,7 +294,6 @@ <child> <object class="GtkCheckButton" id="engineeringnotation"> <property name="label" translatable="yes" context="sidebarnumberformat|engineeringnotation">_Engineering notation</property> - <property name="visible">False</property> <property name="can_focus">True</property> <property name="receives_default">False</property> <property name="has_tooltip">True</property> |