diff options
author | Caolán McNamara <caolanm@redhat.com> | 2020-07-01 17:00:44 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2020-07-02 20:22:05 +0200 |
commit | a751d9c414fc63f36ae4b54b8adbaba042b31f60 (patch) | |
tree | 14b16f3580b140e0e45da81bb93712ff321b6218 /include/svtools | |
parent | 4582ac7de8291a81c867492aad770206fbaca224 (diff) |
weld FormattedControl
by using the newly split out Formatter to do the number formatting
but input/output to/from a weld::Entry
Change-Id: Ic9e619dc5d1ed2fae87e2d89a40dc51f3881468f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97660
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'include/svtools')
-rw-r--r-- | include/svtools/editbrowsebox.hxx | 95 | ||||
-rw-r--r-- | include/svtools/editimplementation.hxx | 18 |
2 files changed, 100 insertions, 13 deletions
diff --git a/include/svtools/editbrowsebox.hxx b/include/svtools/editbrowsebox.hxx index 73f12c5c50d7..d2cbbaa5271d 100644 --- a/include/svtools/editbrowsebox.hxx +++ b/include/svtools/editbrowsebox.hxx @@ -32,6 +32,7 @@ #include <tools/lineend.hxx> #include <vcl/InterimItemWindow.hxx> #include <vcl/vclmedit.hxx> +#include <vcl/weldutils.hxx> #include <o3tl/typed_flags_set.hxx> class Button; @@ -143,6 +144,10 @@ namespace svt virtual bool IsValueChangedFromSaved() const = 0; virtual void SaveValue() = 0; virtual void SetModifyHdl( const Link<LinkParamNone*,void>& _rLink ) = 0; + + virtual void Cut() = 0; + virtual void Copy() = 0; + virtual void Paste() = 0; }; @@ -179,43 +184,68 @@ namespace svt virtual bool IsValueChangedFromSaved() const override; virtual void SaveValue() override; virtual void SetModifyHdl( const Link<LinkParamNone*,void>& _rLink ) override; + + virtual void Cut() override; + virtual void Copy() override; + virtual void Paste() override; }; - class SVT_DLLPUBLIC EditControl final : public InterimItemWindow + class SVT_DLLPUBLIC EditControlBase : public InterimItemWindow { public: - EditControl(vcl::Window* pParent); + EditControlBase(vcl::Window* pParent); virtual void dispose() override; virtual void GetFocus() override { - if (m_xWidget) - m_xWidget->grab_focus(); + if (m_pEntry) + m_pEntry->grab_focus(); InterimItemWindow::GetFocus(); } - weld::Entry& get_widget() { return *m_xWidget; } + weld::Entry& get_widget() { return *m_pEntry; } + + virtual void connect_changed(const Link<weld::Entry&, void>& rLink) = 0; + + protected: + void init(weld::Entry* pEntry); private: - std::unique_ptr<weld::Entry> m_xWidget; + weld::Entry* m_pEntry; DECL_LINK(KeyInputHdl, const KeyEvent&, bool); }; + class SVT_DLLPUBLIC EditControl final : public EditControlBase + { + public: + EditControl(vcl::Window* pParent); + + virtual void dispose() override; + + virtual void connect_changed(const Link<weld::Entry&, void>& rLink) override + { + m_xWidget->connect_changed(rLink); + } + + private: + std::unique_ptr<weld::Entry> m_xWidget; + }; + class SVT_DLLPUBLIC EntryImplementation : public IEditImplementation { - EditControl& m_rEdit; + EditControlBase& m_rEdit; int m_nMaxTextLen; Link<LinkParamNone*,void> m_aModifyHdl; DECL_LINK(ModifyHdl, weld::Entry&, void); public: - EntryImplementation(EditControl& rEdit) + EntryImplementation(EditControlBase& rEdit) : m_rEdit(rEdit) , m_nMaxTextLen(EDIT_NOLIMIT) { - m_rEdit.get_widget().connect_changed(LINK(this, EntryImplementation, ModifyHdl)); + m_rEdit.connect_changed(LINK(this, EntryImplementation, ModifyHdl)); } virtual Control& GetControl() override @@ -264,7 +294,9 @@ namespace svt virtual void SetSelection( const Selection& rSelection ) override { - m_rEdit.get_widget().select_region(rSelection.Min(), rSelection.Max()); + auto nMin = rSelection.Min(); + auto nMax = rSelection.Max(); + m_rEdit.get_widget().select_region(nMin < 0 ? 0 : nMin, nMax == SELECTION_MAX ? -1 : nMax); } virtual void ReplaceSelected( const OUString& rStr ) override @@ -295,6 +327,21 @@ namespace svt { m_aModifyHdl = rLink; } + + virtual void Cut() override + { + m_rEdit.get_widget().cut_clipboard(); + } + + virtual void Copy() override + { + m_rEdit.get_widget().copy_clipboard(); + } + + virtual void Paste() override + { + m_rEdit.get_widget().paste_clipboard(); + } }; #include <svtools/editimplementation.hxx> @@ -358,7 +405,7 @@ namespace svt public: EditCellController( Edit* _pEdit ); - EditCellController( EditControl* _pEdit ); + EditCellController( EditControlBase* _pEdit ); EditCellController( IEditImplementation* _pImplementation ); virtual ~EditCellController( ) override; @@ -368,6 +415,11 @@ namespace svt virtual bool IsValueChangedFromSaved() const override; virtual void SaveValue() override; + void Modify() + { + ModifyHdl(nullptr); + } + protected: virtual bool MoveAllowed(const KeyEvent& rEvt) const override; private: @@ -519,16 +571,33 @@ namespace svt DECL_LINK(ListBoxSelectHdl, weld::ComboBox&, void); }; + class SVT_DLLPUBLIC FormattedControl : public EditControlBase + { + public: + FormattedControl(vcl::Window* pParent); + + virtual void dispose() override; + + virtual void connect_changed(const Link<weld::Entry&, void>& rLink) override + { + m_xFormattedEntry->connect_changed(rLink); + } + + weld::FormattedEntry& get_formatter() { return *m_xFormattedEntry; } + + private: + std::unique_ptr<weld::FormattedEntry> m_xFormattedEntry; + }; + //= FormattedFieldCellController class SVT_DLLPUBLIC FormattedFieldCellController final : public EditCellController { public: - FormattedFieldCellController( FormattedField* _pFormatted ); + FormattedFieldCellController( FormattedControl* _pFormatted ); virtual void CommitModifications() override; }; - //= EditBrowserHeader class SVT_DLLPUBLIC EditBrowserHeader : public BrowserHeader { diff --git a/include/svtools/editimplementation.hxx b/include/svtools/editimplementation.hxx index 9797009b2369..04bc287ab06e 100644 --- a/include/svtools/editimplementation.hxx +++ b/include/svtools/editimplementation.hxx @@ -120,4 +120,22 @@ void GenericEditImplementation< EDIT >::SetModifyHdl( const Link<LinkParamNone*, m_aModifyHdl = _rLink; } +template <class EDIT> +void GenericEditImplementation< EDIT >::Cut() +{ + m_rEdit.Cut(); +} + +template <class EDIT> +void GenericEditImplementation< EDIT >::Copy() +{ + m_rEdit.Copy(); +} + +template <class EDIT> +void GenericEditImplementation< EDIT >::Paste() +{ + m_rEdit.Paste(); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |