From 8328d84a0ce8c1b9592ce0dbab17dbbecc423b3c Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Thu, 9 Jul 2020 20:16:22 +0100 Subject: weld CheckBoxControl MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Iea057189ab17c1fdaf6663f1c328b9d288d97a18 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/98532 Tested-by: Jenkins Reviewed-by: Caolán McNamara --- include/svtools/editbrowsebox.hxx | 53 ++++++++++++++++++++++++--------------- 1 file changed, 33 insertions(+), 20 deletions(-) (limited to 'include/svtools') diff --git a/include/svtools/editbrowsebox.hxx b/include/svtools/editbrowsebox.hxx index cbeb152c15d1..3b21aaea53c4 100644 --- a/include/svtools/editbrowsebox.hxx +++ b/include/svtools/editbrowsebox.hxx @@ -37,7 +37,6 @@ class BrowserDataWin; class Button; -class CheckBox; class SpinField; // EditBrowseBoxFlags (EBBF) @@ -219,11 +218,10 @@ namespace svt virtual bool ProcessKey(const KeyEvent& rKEvt); + virtual void Draw(OutputDevice* pDevice, const Point& rPos, DrawFlags nFlags) override; protected: void InitControlBase(weld::Widget* pWidget); - virtual void Draw(OutputDevice* pDevice, const Point& rPos, DrawFlags nFlags) override; - DECL_LINK(KeyInputHdl, const KeyEvent&, bool); private: weld::Widget* m_pWidget; @@ -580,33 +578,48 @@ namespace svt }; //= CheckBoxControl - class SVT_DLLPUBLIC CheckBoxControl final : public Control + class SVT_DLLPUBLIC CheckBoxControl final : public ControlBase { - VclPtr pBox; - Link,void> m_aClickLink; - Link m_aModifyLink; + std::unique_ptr m_xBox; + Link m_aClickLink; + Link m_aModify1Hdl; + Link m_aModify2Hdl; + bool m_bTriState; public: - CheckBoxControl(vcl::Window* pParent); + CheckBoxControl(BrowserDataWin* pParent); virtual ~CheckBoxControl() override; virtual void dispose() override; - virtual void GetFocus() override; - virtual bool PreNotify(NotifyEvent& rEvt) override; - virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rClientRect) override; - virtual void Draw( OutputDevice* pDev, const Point& rPos, DrawFlags nFlags ) override; - virtual void StateChanged( StateChangedType nStateChange ) override; - virtual void DataChanged( const DataChangedEvent& _rEvent ) override; - virtual void Resize() override; + void SetClickHdl(const Link& rHdl) {m_aClickLink = rHdl;} - void SetClickHdl(const Link,void>& rHdl) {m_aClickLink = rHdl;} + // sets a link to call when the text is changed by the user + void SetModifyHdl(const Link& rHdl) + { + m_aModify1Hdl = rHdl; + } - void SetModifyHdl(const Link& rHdl) {m_aModifyLink = rHdl;} + // sets an additional link to call when the text is changed by the user + void SetAuxModifyHdl(const Link& rLink) + { + m_aModify2Hdl = rLink; + } - CheckBox& GetBox() {return *pBox;}; + void SetState(TriState eState); + TriState GetState() const { return m_xBox->get_state(); } + + void EnableTriState(bool bTriState); + + weld::CheckButton& GetBox() {return *m_xBox;}; private: - DECL_LINK( OnClick, Button*, void ); + DECL_LINK(OnClick, weld::Button&, void); + + void CallModifyHdls() + { + m_aModify1Hdl.Call(nullptr); + m_aModify2Hdl.Call(nullptr); + } }; //= CheckBoxCellController @@ -615,7 +628,7 @@ namespace svt public: CheckBoxCellController(CheckBoxControl* pWin); - CheckBox& GetCheckBox() const; + weld::CheckButton& GetCheckBox() const; virtual bool IsValueChangedFromSaved() const override; virtual void SaveValue() override; -- cgit