summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2020-02-06 20:25:12 +0000
committerCaolán McNamara <caolanm@redhat.com>2020-02-07 12:47:35 +0100
commited87f7e96b7f4f9201fa17bc573d4ef8ba9ab4e4 (patch)
treed906a223d533f92715e228f108ed5fc3a0529980 /sw
parentdbcdc5cd98df5756a96559e467cad95c629343ca (diff)
weld SwJumpToSpecificBox_Impl
Change-Id: I4c140bccf821b6ee0ce0e734cebae722267f5430 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/88140 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sw')
-rw-r--r--sw/UIConfig_swriter.mk1
-rw-r--r--sw/source/uibase/ribbar/workctrl.cxx45
-rw-r--r--sw/uiconfig/swriter/ui/jumpposbox.ui24
3 files changed, 54 insertions, 16 deletions
diff --git a/sw/UIConfig_swriter.mk b/sw/UIConfig_swriter.mk
index 339c7774d528..6431d1063cb3 100644
--- a/sw/UIConfig_swriter.mk
+++ b/sw/UIConfig_swriter.mk
@@ -172,6 +172,7 @@ $(eval $(call gb_UIConfig_add_uifiles,modules/swriter,\
sw/uiconfig/swriter/ui/insertsectiondialog \
sw/uiconfig/swriter/ui/insertscript \
sw/uiconfig/swriter/ui/inserttable \
+ sw/uiconfig/swriter/ui/jumpposbox \
sw/uiconfig/swriter/ui/labeldialog \
sw/uiconfig/swriter/ui/labelformatpage \
sw/uiconfig/swriter/ui/labeloptionspage \
diff --git a/sw/source/uibase/ribbar/workctrl.cxx b/sw/source/uibase/ribbar/workctrl.cxx
index 87bf21e93725..08d569a01811 100644
--- a/sw/source/uibase/ribbar/workctrl.cxx
+++ b/sw/source/uibase/ribbar/workctrl.cxx
@@ -18,6 +18,7 @@
*/
#include <i18nutil/unicode.hxx>
+#include <sfx2/InterimItemWindow.hxx>
#include <sfx2/dispatch.hxx>
#include <sfx2/bindings.hxx>
#include <sfx2/viewfrm.hxx>
@@ -700,42 +701,54 @@ VclPtr<vcl::Window> SwPreviewZoomControl::CreateItemWindow( vcl::Window *pParent
namespace {
-class SwJumpToSpecificBox_Impl : public NumericField
+class SwJumpToSpecificBox_Impl final : public InterimItemWindow
{
+ std::unique_ptr<weld::Entry> m_xWidget;
+
sal_uInt16 const nSlotId;
+ DECL_LINK(KeyInputHdl, const KeyEvent&, bool);
+ DECL_LINK(SelectHdl, weld::Entry&, bool);
public:
SwJumpToSpecificBox_Impl(vcl::Window* pParent, sal_uInt16 nSlot);
-
-protected:
- void Select();
- virtual bool EventNotify( NotifyEvent& rNEvt ) override;
+ virtual void dispose() override
+ {
+ m_xWidget.reset();
+ InterimItemWindow::dispose();
+ }
+ virtual ~SwJumpToSpecificBox_Impl() override
+ {
+ disposeOnce();
+ }
};
}
+IMPL_LINK(SwJumpToSpecificBox_Impl, KeyInputHdl, const KeyEvent&, rKEvt, bool)
+{
+ return ChildKeyInput(rKEvt);
+}
+
SwJumpToSpecificBox_Impl::SwJumpToSpecificBox_Impl(vcl::Window* pParent, sal_uInt16 nSlot)
- : NumericField(pParent, WB_HIDE | WB_BORDER)
+ : InterimItemWindow(pParent, "modules/swriter/ui/jumpposbox.ui", "JumpPosBox")
+ , m_xWidget(m_xBuilder->weld_entry("jumppos"))
, nSlotId(nSlot)
{
- SetSizePixel(LogicToPixel(Size(16, 12), MapMode(MapUnit::MapAppFont)));
+ m_xWidget->connect_key_press(LINK(this, SwJumpToSpecificBox_Impl, KeyInputHdl));
+ m_xWidget->connect_activate(LINK(this, SwJumpToSpecificBox_Impl, SelectHdl));
+
+ SetSizePixel(m_xWidget->get_preferred_size());
}
-void SwJumpToSpecificBox_Impl::Select()
+IMPL_LINK_NOARG(SwJumpToSpecificBox_Impl, SelectHdl, weld::Entry&, bool)
{
- OUString sEntry(GetText());
+ OUString sEntry(m_xWidget->get_text());
SfxUInt16Item aPageNum(nSlotId);
aPageNum.SetValue(static_cast<sal_uInt16>(sEntry.toInt32()));
SfxObjectShell* pCurrentShell = SfxObjectShell::Current();
pCurrentShell->GetDispatcher()->ExecuteList(nSlotId, SfxCallMode::ASYNCHRON,
{ &aPageNum });
-}
-
-bool SwJumpToSpecificBox_Impl::EventNotify( NotifyEvent& rNEvt )
-{
- if ( rNEvt.GetType() == MouseNotifyEvent::KEYINPUT )
- Select();
- return NumericField::EventNotify(rNEvt);
+ return true;
}
SFX_IMPL_TOOLBOX_CONTROL( SwJumpToSpecificPageControl, SfxUInt16Item);
diff --git a/sw/uiconfig/swriter/ui/jumpposbox.ui b/sw/uiconfig/swriter/ui/jumpposbox.ui
new file mode 100644
index 000000000000..bfde35793952
--- /dev/null
+++ b/sw/uiconfig/swriter/ui/jumpposbox.ui
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.22.1 -->
+<interface domain="sw">
+ <requires lib="gtk+" version="3.18"/>
+ <object class="GtkBox" id="JumpPosBox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="hexpand">True</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkEntry" id="jumppos">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="hexpand">True</property>
+ <property name="width_chars">3</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ </object>
+</interface>