diff options
author | Szymon Kłos <szymon.klos@collabora.com> | 2020-03-10 17:10:38 +0100 |
---|---|---|
committer | Szymon Kłos <szymon.klos@collabora.com> | 2020-05-19 10:11:36 +0200 |
commit | e1afc5ace91f9d46660ee4aa541defc908f39dfb (patch) | |
tree | a2ff5008fdf7a4c7079ef0b49f67ab8ce1bcb358 | |
parent | 98c696e0b8ac10fb43616db625d57278f4dbb851 (diff) |
jsdialog: weld SpinButton and CheckButton
Change-Id: I0dfa163b8a52594cde9e3529df8f433dc93bc459
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94432
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Szymon Kłos <szymon.klos@collabora.com>
-rw-r--r-- | include/vcl/jsdialog/jsdialogbuilder.hxx | 23 | ||||
-rw-r--r-- | vcl/jsdialog/jsdialogbuilder.cxx | 56 |
2 files changed, 79 insertions, 0 deletions
diff --git a/include/vcl/jsdialog/jsdialogbuilder.hxx b/include/vcl/jsdialog/jsdialogbuilder.hxx index 660be3ea75d3..32b279dea66d 100644 --- a/include/vcl/jsdialog/jsdialogbuilder.hxx +++ b/include/vcl/jsdialog/jsdialogbuilder.hxx @@ -9,6 +9,7 @@ #include <vcl/salvtables.hxx> #include <vcl/combobox.hxx> #include <vcl/button.hxx> +#include <vcl/fmtfield.hxx> typedef std::map<OString, weld::Widget*> WidgetMap; @@ -51,6 +52,10 @@ public: bool bTakeOwnership = false) override; virtual std::unique_ptr<weld::Notebook> weld_notebook(const OString& id, bool bTakeOwnership = false) override; + virtual std::unique_ptr<weld::SpinButton> + weld_spin_button(const OString& id, bool bTakeOwnership = false) override; + virtual std::unique_ptr<weld::CheckButton> + weld_check_button(const OString& id, bool bTakeOwnership = false) override; static weld::MessageDialog* CreateMessageDialog(weld::Widget* pParent, VclMessageType eMessageType, @@ -150,6 +155,15 @@ public: virtual void append_page(const OString& rIdent, const OUString& rLabel) override; }; +class VCL_DLLPUBLIC JSSpinButton : public JSWidget<SalInstanceSpinButton, ::FormattedField> +{ +public: + JSSpinButton(VclPtr<vcl::Window> aOwnedToplevel, ::FormattedField* pSpin, + SalInstanceBuilder* pBuilder, bool bTakeOwnership); + + virtual void set_value(int value) override; +}; + class VCL_DLLPUBLIC JSMessageDialog : public SalInstanceMessageDialog, public JSDialogSender { public: @@ -160,4 +174,13 @@ public: virtual void set_secondary_text(const OUString& rText) override; }; +class VCL_DLLPUBLIC JSCheckButton : public JSWidget<SalInstanceCheckButton, ::CheckBox> +{ +public: + JSCheckButton(VclPtr<vcl::Window> aOwnedToplevel, ::CheckBox* pCheckBox, + SalInstanceBuilder* pBuilder, bool bTakeOwnership); + + virtual void set_active(bool active) override; +}; + #endif diff --git a/vcl/jsdialog/jsdialogbuilder.cxx b/vcl/jsdialog/jsdialogbuilder.cxx index 15a482e0ac48..9246bda13b86 100644 --- a/vcl/jsdialog/jsdialogbuilder.cxx +++ b/vcl/jsdialog/jsdialogbuilder.cxx @@ -204,6 +204,36 @@ std::unique_ptr<weld::Notebook> JSInstanceBuilder::weld_notebook(const OString& return pWeldWidget; } +std::unique_ptr<weld::SpinButton> JSInstanceBuilder::weld_spin_button(const OString& id, + bool bTakeOwnership) +{ + FormattedField* pSpinButton = m_xBuilder->get<FormattedField>(id); + auto pWeldWidget = pSpinButton ? std::make_unique<JSSpinButton>( + m_bHasTopLevelDialog ? m_aOwnedToplevel : m_aParentDialog, + pSpinButton, this, bTakeOwnership) + : nullptr; + + if (pWeldWidget) + RememberWidget(id, pWeldWidget.get()); + + return pWeldWidget; +} + +std::unique_ptr<weld::CheckButton> JSInstanceBuilder::weld_check_button(const OString& id, + bool bTakeOwnership) +{ + CheckBox* pCheckButton = m_xBuilder->get<CheckBox>(id); + auto pWeldWidget = pCheckButton ? std::make_unique<JSCheckButton>( + m_bHasTopLevelDialog ? m_aOwnedToplevel : m_aParentDialog, + pCheckButton, this, bTakeOwnership) + : nullptr; + + if (pWeldWidget) + RememberWidget(id, pWeldWidget.get()); + + return pWeldWidget; +} + weld::MessageDialog* JSInstanceBuilder::CreateMessageDialog(weld::Widget* pParent, VclMessageType eMessageType, VclButtonsType eButtonType, @@ -347,6 +377,19 @@ void JSNotebook::append_page(const OString& rIdent, const OUString& rLabel) notifyDialogState(); } +JSSpinButton::JSSpinButton(VclPtr<vcl::Window> aOwnedToplevel, ::FormattedField* pSpin, + SalInstanceBuilder* pBuilder, bool bTakeOwnership) + : JSWidget<SalInstanceSpinButton, ::FormattedField>(aOwnedToplevel, pSpin, pBuilder, + bTakeOwnership) +{ +} + +void JSSpinButton::set_value(int value) +{ + SalInstanceSpinButton::set_value(value); + notifyDialogState(); +} + JSMessageDialog::JSMessageDialog(::MessageDialog* pDialog, SalInstanceBuilder* pBuilder, bool bTakeOwnership) : SalInstanceMessageDialog(pDialog, pBuilder, bTakeOwnership) @@ -365,3 +408,16 @@ void JSMessageDialog::set_secondary_text(const OUString& rText) SalInstanceMessageDialog::set_secondary_text(rText); notifyDialogState(); } + +JSCheckButton::JSCheckButton(VclPtr<vcl::Window> aOwnedToplevel, ::CheckBox* pCheckBox, + SalInstanceBuilder* pBuilder, bool bTakeOwnership) + : JSWidget<SalInstanceCheckButton, ::CheckBox>(aOwnedToplevel, pCheckBox, pBuilder, + bTakeOwnership) +{ +} + +void JSCheckButton::set_active(bool active) +{ + SalInstanceCheckButton::set_active(active); + notifyDialogState(); +} |