summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2020-02-07 10:39:52 +0000
committerCaolán McNamara <caolanm@redhat.com>2020-02-07 13:29:55 +0100
commit43697b00a21a796c449348470564e525da861c51 (patch)
treee755f10e42586e8ed6a18d80c8abce08d629a850
parentd74487ec716378e2160ad3538a5fcc787ad9fd2f (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>
-rw-r--r--sc/UIConfig_scalc.mk1
-rw-r--r--sc/source/ui/cctrl/cbnumberformat.cxx63
-rw-r--r--sc/source/ui/inc/cbnumberformat.hxx15
-rw-r--r--sc/source/ui/sidebar/NumberFormatControl.cxx7
-rw-r--r--sc/uiconfig/scalc/ui/numberbox.ui23
5 files changed, 82 insertions, 27 deletions
diff --git a/sc/UIConfig_scalc.mk b/sc/UIConfig_scalc.mk
index 323e8775caeb..f6b5d62d1620 100644
--- a/sc/UIConfig_scalc.mk
+++ b/sc/UIConfig_scalc.mk
@@ -155,6 +155,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..c2e2f40366bc 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 <sfx2/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>