diff options
author | Caolán McNamara <caolanm@redhat.com> | 2020-02-07 10:39:52 +0000 |
---|---|---|
committer | Szymon Kłos <szymon.klos@collabora.com> | 2020-06-24 12:04:39 +0200 |
commit | 3d5b6e2c165e42503187ab3f80478f9bb3e90d35 (patch) | |
tree | 965094ae15a776dfde1b1a9e9121e76dfbccd86a /sc | |
parent | 272efec844e37ec8a37872d6bed0f5b4a6d59d42 (diff) |
weld ScNumberFormat ItemWindow
Change-Id: Ib019912e91be617edbbcdf2fafb92d6685487b98
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/88174
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97015
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Szymon Kłos <szymon.klos@collabora.com>
Diffstat (limited to 'sc')
-rw-r--r-- | sc/UIConfig_scalc.mk | 1 | ||||
-rw-r--r-- | sc/source/ui/cctrl/cbnumberformat.cxx | 63 | ||||
-rw-r--r-- | sc/source/ui/inc/cbnumberformat.hxx | 15 | ||||
-rw-r--r-- | sc/source/ui/sidebar/NumberFormatControl.cxx | 7 | ||||
-rw-r--r-- | sc/uiconfig/scalc/ui/numberbox.ui | 23 |
5 files changed, 82 insertions, 27 deletions
diff --git a/sc/UIConfig_scalc.mk b/sc/UIConfig_scalc.mk index 29131d219c60..bf1798cd5275 100644 --- a/sc/UIConfig_scalc.mk +++ b/sc/UIConfig_scalc.mk @@ -156,6 +156,7 @@ $(eval $(call gb_UIConfig_add_uifiles,modules/scalc,\ sc/uiconfig/scalc/ui/notebookbar_groups \ sc/uiconfig/scalc/ui/notebookbar_groupedbar_full \ sc/uiconfig/scalc/ui/notebookbar_groupedbar_compact \ + sc/uiconfig/scalc/ui/numberbox \ sc/uiconfig/scalc/ui/managenamesdialog \ sc/uiconfig/scalc/ui/mergecellsdialog \ sc/uiconfig/scalc/ui/mergecolumnentry \ diff --git a/sc/source/ui/cctrl/cbnumberformat.cxx b/sc/source/ui/cctrl/cbnumberformat.cxx index 2e08b0256378..830e24761d08 100644 --- a/sc/source/ui/cctrl/cbnumberformat.cxx +++ b/sc/source/ui/cctrl/cbnumberformat.cxx @@ -22,40 +22,63 @@ #include <scresid.hxx> #include <sfx2/dispatch.hxx> #include <sfx2/viewfrm.hxx> +#include <sfx2/viewsh.hxx> #include <svl/intitem.hxx> #include <sc.hrc> -ScNumberFormat::ScNumberFormat(vcl::Window* pParent, WinBits nStyle) : - ListBox(pParent, nStyle | WB_DROPDOWN|WB_LEFT|WB_VCENTER|WB_BORDER|WB_3DLOOK) +ScNumberFormat::ScNumberFormat(vcl::Window* pParent) + : InterimItemWindow(pParent, "modules/scalc/ui/numberbox.ui", "NumberBox") + , m_xWidget(m_xBuilder->weld_combo_box("numbertype")) { - SetSelectHdl(LINK(this, ScNumberFormat, NumFormatSelectHdl)); - AdaptDropDownLineCountToMaximum(); - - InsertEntry(ScResId(STR_GENERAL)); - InsertEntry(ScResId(STR_NUMBER)); - InsertEntry(ScResId(STR_PERCENT)); - InsertEntry(ScResId(STR_CURRENCY)); - InsertEntry(ScResId(STR_DATE)); - InsertEntry(ScResId(STR_TIME)); - InsertEntry(ScResId(STR_SCIENTIFIC)); - InsertEntry(ScResId(STR_FRACTION)); - InsertEntry(ScResId(STR_BOOLEAN_VALUE)); - InsertEntry(ScResId(STR_TEXT)); + m_xWidget->append_text(ScResId(STR_GENERAL)); + m_xWidget->append_text(ScResId(STR_NUMBER)); + m_xWidget->append_text(ScResId(STR_PERCENT)); + m_xWidget->append_text(ScResId(STR_CURRENCY)); + m_xWidget->append_text(ScResId(STR_DATE)); + m_xWidget->append_text(ScResId(STR_TIME)); + m_xWidget->append_text(ScResId(STR_SCIENTIFIC)); + m_xWidget->append_text(ScResId(STR_FRACTION)); + m_xWidget->append_text(ScResId(STR_BOOLEAN_VALUE)); + m_xWidget->append_text(ScResId(STR_TEXT)); + + m_xWidget->connect_changed(LINK(this, ScNumberFormat, NumFormatSelectHdl)); + m_xWidget->connect_key_press(LINK(this, ScNumberFormat, KeyInputHdl)); + + SetSizePixel(m_xWidget->get_preferred_size()); +} + +void ScNumberFormat::dispose() +{ + m_xWidget.reset(); + InterimItemWindow::dispose(); +} + +ScNumberFormat::~ScNumberFormat() +{ + disposeOnce(); } -IMPL_STATIC_LINK(ScNumberFormat, NumFormatSelectHdl, ListBox&, rBox, void) +IMPL_STATIC_LINK(ScNumberFormat, NumFormatSelectHdl, weld::ComboBox&, rBox, void) { - if(SfxViewFrame::Current()) + auto* pCurSh = SfxViewFrame::Current(); + if (pCurSh) { - SfxDispatcher* pDisp = SfxViewFrame::Current()->GetBindings().GetDispatcher(); - if(pDisp) + SfxDispatcher* pDisp = pCurSh->GetBindings().GetDispatcher(); + if (pDisp) { - const sal_Int32 nVal = rBox.GetSelectedEntryPos(); + const sal_Int32 nVal = rBox.get_active(); SfxUInt16Item aItem(SID_NUMBER_TYPE_FORMAT, nVal); pDisp->ExecuteList(SID_NUMBER_TYPE_FORMAT, SfxCallMode::RECORD, {&aItem}); + + pCurSh->GetWindow().GrabFocus(); } } } +IMPL_LINK(ScNumberFormat, KeyInputHdl, const KeyEvent&, rKEvt, bool) +{ + return ChildKeyInput(rKEvt); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/cbnumberformat.hxx b/sc/source/ui/inc/cbnumberformat.hxx index 9773fd9b34cc..2cfde85cde48 100644 --- a/sc/source/ui/inc/cbnumberformat.hxx +++ b/sc/source/ui/inc/cbnumberformat.hxx @@ -20,15 +20,22 @@ #ifndef INCLUDED_SC_SOURCE_UI_INC_CBNUMBERFORMAT_HXX #define INCLUDED_SC_SOURCE_UI_INC_CBNUMBERFORMAT_HXX -#include <vcl/lstbox.hxx> +#include <vcl/InterimItemWindow.hxx> -class ScNumberFormat : public ListBox +class ScNumberFormat final : public InterimItemWindow { public: - explicit ScNumberFormat(vcl::Window* pParent, WinBits nStyle); + explicit ScNumberFormat(vcl::Window* pParent); + virtual void dispose() override; + virtual ~ScNumberFormat() override; + + void set_active(int nPos) { m_xWidget->set_active(nPos); } private: - DECL_STATIC_LINK(ScNumberFormat, NumFormatSelectHdl, ListBox&, void); + std::unique_ptr<weld::ComboBox> m_xWidget; + + DECL_STATIC_LINK(ScNumberFormat, NumFormatSelectHdl, weld::ComboBox&, void); + DECL_LINK(KeyInputHdl, const KeyEvent&, bool); }; #endif diff --git a/sc/source/ui/sidebar/NumberFormatControl.cxx b/sc/source/ui/sidebar/NumberFormatControl.cxx index 9e05fcc5a545..dbfc7debf8b5 100644 --- a/sc/source/ui/sidebar/NumberFormatControl.cxx +++ b/sc/source/ui/sidebar/NumberFormatControl.cxx @@ -57,7 +57,7 @@ void ScNumberFormatControl::StateChanged(sal_uInt16, SfxItemState eState, { const SfxUInt16Item* pItem = static_cast<const SfxUInt16Item*>(pState); sal_uInt16 nVal = pItem->GetValue(); - pComboBox->SelectEntryPos(nVal); + pComboBox->set_active(nVal); break; } @@ -68,8 +68,9 @@ void ScNumberFormatControl::StateChanged(sal_uInt16, SfxItemState eState, VclPtr<vcl::Window> ScNumberFormatControl::CreateItemWindow( vcl::Window *pParent ) { - VclPtr<ScNumberFormat> pControl = VclPtr<ScNumberFormat>::Create(pParent, WB_DROPDOWN); - pControl->SetSizePixel(pControl->GetOptimalSize()); + VclPtr<ScNumberFormat> pControl = VclPtr<ScNumberFormat>::Create(pParent); + pControl->Show(); + return pControl; } diff --git a/sc/uiconfig/scalc/ui/numberbox.ui b/sc/uiconfig/scalc/ui/numberbox.ui new file mode 100644 index 000000000000..d728ada83761 --- /dev/null +++ b/sc/uiconfig/scalc/ui/numberbox.ui @@ -0,0 +1,23 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- Generated with glade 3.22.1 --> +<interface domain="sc"> + <requires lib="gtk+" version="3.18"/> + <object class="GtkBox" id="NumberBox"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="hexpand">True</property> + <property name="spacing">6</property> + <child> + <object class="GtkComboBoxText" id="numbertype"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="hexpand">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + </object> +</interface> |