From bccb6b744378fc4f5f1dbab143c8da59fc5dc7aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Szymon=20K=C5=82os?= Date: Fri, 28 Feb 2020 13:47:22 +0100 Subject: jsdialog: Common weld::Widget implementation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Iab21652c6abaf143fb421d6030f6acc394733bcb Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94073 Tested-by: Jenkins CollaboraOffice Reviewed-by: Szymon Kłos --- vcl/inc/jsdialog/jsdialogbuilder.hxx | 32 ++++++++++++++++++++++++++++---- vcl/jsdialog/jsdialogbuilder.cxx | 14 ++++++-------- 2 files changed, 34 insertions(+), 12 deletions(-) diff --git a/vcl/inc/jsdialog/jsdialogbuilder.hxx b/vcl/inc/jsdialog/jsdialogbuilder.hxx index a82732d05f5a..98126bfcc12f 100644 --- a/vcl/inc/jsdialog/jsdialogbuilder.hxx +++ b/vcl/inc/jsdialog/jsdialogbuilder.hxx @@ -36,7 +36,31 @@ public: bool bTakeOwnership = false) override; }; -class VCL_DLLPUBLIC JSLabel : public SalInstanceLabel, public JSDialogSender +template +class JSWidget : public BaseInstanceClass, public JSDialogSender +{ +public: + JSWidget(VclPtr aOwnedToplevel, VclClass* pObject, SalInstanceBuilder* pBuilder, + bool bTakeOwnership) + : BaseInstanceClass(pObject, pBuilder, bTakeOwnership) + , JSDialogSender(aOwnedToplevel) + { + } + + virtual void show() override + { + BaseInstanceClass::show(); + notifyDialogState(); + } + + virtual void hide() override + { + BaseInstanceClass::hide(); + notifyDialogState(); + } +}; + +class VCL_DLLPUBLIC JSLabel : public JSWidget { public: JSLabel(VclPtr aOwnedToplevel, FixedText* pLabel, SalInstanceBuilder* pBuilder, @@ -44,7 +68,7 @@ public: virtual void set_label(const OUString& rText) override; }; -class VCL_DLLPUBLIC JSEntry : public SalInstanceEntry, public JSDialogSender +class VCL_DLLPUBLIC JSEntry : public JSWidget { public: JSEntry(VclPtr aOwnedToplevel, ::Edit* pEntry, SalInstanceBuilder* pBuilder, @@ -52,7 +76,7 @@ public: virtual void set_text(const OUString& rText) override; }; -class VCL_DLLPUBLIC JSListBox : public SalInstanceComboBoxWithoutEdit, public JSDialogSender +class VCL_DLLPUBLIC JSListBox : public JSWidget { public: JSListBox(VclPtr aOwnedToplevel, ::ListBox* pListBox, SalInstanceBuilder* pBuilder, @@ -62,7 +86,7 @@ public: virtual void remove(int pos) override; }; -class VCL_DLLPUBLIC JSComboBox : public SalInstanceComboBoxWithEdit, public JSDialogSender +class VCL_DLLPUBLIC JSComboBox : public JSWidget { public: JSComboBox(VclPtr aOwnedToplevel, ::ComboBox* pComboBox, diff --git a/vcl/jsdialog/jsdialogbuilder.cxx b/vcl/jsdialog/jsdialogbuilder.cxx index 62fd9e16b24a..52fa6a19a8e1 100644 --- a/vcl/jsdialog/jsdialogbuilder.cxx +++ b/vcl/jsdialog/jsdialogbuilder.cxx @@ -86,8 +86,7 @@ std::unique_ptr JSInstanceBuilder::weld_combo_box(const OString& JSLabel::JSLabel(VclPtr aOwnedToplevel, FixedText* pLabel, SalInstanceBuilder* pBuilder, bool bTakeOwnership) - : SalInstanceLabel(pLabel, pBuilder, bTakeOwnership) - , JSDialogSender(aOwnedToplevel) + : JSWidget(aOwnedToplevel, pLabel, pBuilder, bTakeOwnership) { } @@ -99,8 +98,7 @@ void JSLabel::set_label(const OUString& rText) JSEntry::JSEntry(VclPtr aOwnedToplevel, ::Edit* pEntry, SalInstanceBuilder* pBuilder, bool bTakeOwnership) - : SalInstanceEntry(pEntry, pBuilder, bTakeOwnership) - , JSDialogSender(aOwnedToplevel) + : JSWidget(aOwnedToplevel, pEntry, pBuilder, bTakeOwnership) { } @@ -112,8 +110,8 @@ void JSEntry::set_text(const OUString& rText) JSListBox::JSListBox(VclPtr aOwnedToplevel, ::ListBox* pListBox, SalInstanceBuilder* pBuilder, bool bTakeOwnership) - : SalInstanceComboBoxWithoutEdit(pListBox, pBuilder, bTakeOwnership) - , JSDialogSender(aOwnedToplevel) + : JSWidget(aOwnedToplevel, pListBox, pBuilder, + bTakeOwnership) { } @@ -132,8 +130,8 @@ void JSListBox::remove(int pos) JSComboBox::JSComboBox(VclPtr aOwnedToplevel, ::ComboBox* pComboBox, SalInstanceBuilder* pBuilder, bool bTakeOwnership) - : SalInstanceComboBoxWithEdit(pComboBox, pBuilder, bTakeOwnership) - , JSDialogSender(aOwnedToplevel) + : JSWidget(aOwnedToplevel, pComboBox, pBuilder, + bTakeOwnership) { } -- cgit v1.2.1