From 2658b0e5ffdff795d910f373feb5c55ad01b7d09 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Sun, 16 Feb 2020 20:09:04 +0000 Subject: weld InputEdit Item Window MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I33e4fb378897289b7b54c80b9cb3d7e868381f96 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/88822 Tested-by: Jenkins Reviewed-by: Caolán McNamara --- sw/source/uibase/inc/inputwin.hxx | 75 +++++++++++++++++++++++++++++++++------ 1 file changed, 65 insertions(+), 10 deletions(-) (limited to 'sw/source/uibase/inc') diff --git a/sw/source/uibase/inc/inputwin.hxx b/sw/source/uibase/inc/inputwin.hxx index a8a0123a6e5d..00735215eb74 100644 --- a/sw/source/uibase/inc/inputwin.hxx +++ b/sw/source/uibase/inc/inputwin.hxx @@ -20,7 +20,6 @@ #define INCLUDED_SW_SOURCE_UIBASE_INC_INPUTWIN_HXX #include -#include #include #include @@ -31,19 +30,75 @@ class SwWrtShell; class SwView; class SfxDispatcher; -class InputEdit : public Edit +class InputEdit final : public InterimItemWindow { +private: + std::unique_ptr m_xWidget; + + DECL_LINK(KeyInputHdl, const KeyEvent&, bool); + DECL_LINK(ActivateHdl, weld::Entry&, bool); public: - InputEdit(vcl::Window* pParent, WinBits nStyle) : - Edit(pParent , nStyle){} + InputEdit(vcl::Window* pParent) + : InterimItemWindow(pParent, "modules/swriter/ui/inputeditbox.ui", "InputEditBox") + , m_xWidget(m_xBuilder->weld_entry("entry")) + { + m_xWidget->connect_key_press(LINK(this, InputEdit, KeyInputHdl)); + m_xWidget->connect_activate(LINK(this, InputEdit, ActivateHdl)); + SetSizePixel(m_xWidget->get_preferred_size()); + } + + void UpdateRange(const OUString& rSel, const OUString& rTableName); + + virtual void dispose() override + { + m_xWidget.reset(); + InterimItemWindow::dispose(); + } - void UpdateRange(const OUString& aSel, - const OUString& aTableName ); + virtual void GetFocus() override + { + if (m_xWidget) + m_xWidget->grab_focus(); + InterimItemWindow::GetFocus(); + } -protected: - virtual void KeyInput( const KeyEvent& ) override; + void set_text(const OUString& rText) + { + m_xWidget->set_text(rText); + } + + OUString get_text() const + { + return m_xWidget->get_text(); + } + + void set_accessible_name(const OUString& rName) + { + m_xWidget->set_accessible_name(rName); + } + + void replace_selection(const OUString& rText) + { + m_xWidget->replace_selection(rText); + } + + void select_region(int nStartPos, int nEndPos) + { + m_xWidget->select_region(nStartPos, nEndPos); + } + + void connect_changed(const Link& rLink) + { + m_xWidget->connect_changed(rLink); + } + + virtual ~InputEdit() override + { + disposeOnce(); + } }; + class PosEdit final : public InterimItemWindow { private: @@ -93,7 +148,7 @@ class SwInputWindow final : public ToolBox friend class InputEdit; VclPtr mxPos; - VclPtr aEdit; + VclPtr mxEdit; std::unique_ptr pMgr; SwWrtShell* pWrtShell; SwView* pView; @@ -109,7 +164,7 @@ friend class InputEdit; void CleanupUglyHackWithUndo(); void DelBoxContent(); - DECL_LINK( ModifyHdl, Edit&, void ); + DECL_LINK(ModifyHdl, weld::Entry&, void); using Window::IsActive; -- cgit