summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorSzymon Kłos <szymon.klos@collabora.com>2020-02-25 13:03:34 +0100
committerSzymon Kłos <szymon.klos@collabora.com>2020-05-19 16:59:34 +0200
commitc529dd9b964e4176fed67d3c1594978c7d26ad7b (patch)
tree99d168d92dae686d4eb09076587cc4a2e2823d73 /vcl
parent5ea36f5975728fcd1fb2f92fccdfdeaeec4e028e (diff)
jsdialog: weld::ComboBox
Change-Id: I672d2fd170e94e0b3e05384461983e5ae4a0ab35 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94072 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Szymon Kłos <szymon.klos@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94488 Tested-by: Jenkins
Diffstat (limited to 'vcl')
-rw-r--r--vcl/inc/jsdialog/jsdialogbuilder.hxx24
-rw-r--r--vcl/inc/salvtables.hxx2
-rw-r--r--vcl/jsdialog/jsdialogbuilder.cxx58
3 files changed, 83 insertions, 1 deletions
diff --git a/vcl/inc/jsdialog/jsdialogbuilder.hxx b/vcl/inc/jsdialog/jsdialogbuilder.hxx
index 956c3001fc22..a82732d05f5a 100644
--- a/vcl/inc/jsdialog/jsdialogbuilder.hxx
+++ b/vcl/inc/jsdialog/jsdialogbuilder.hxx
@@ -7,6 +7,7 @@
#include <vcl/virdev.hxx>
#include <vcl/builder.hxx>
#include <salvtables.hxx>
+#include <vcl/combobox.hxx>
class JSDialogSender
{
@@ -31,6 +32,8 @@ public:
bool bTakeOwnership = false) override;
virtual std::unique_ptr<weld::Entry> weld_entry(const OString& id,
bool bTakeOwnership = false) override;
+ virtual std::unique_ptr<weld::ComboBox> weld_combo_box(const OString& id,
+ bool bTakeOwnership = false) override;
};
class VCL_DLLPUBLIC JSLabel : public SalInstanceLabel, public JSDialogSender
@@ -49,4 +52,25 @@ public:
virtual void set_text(const OUString& rText) override;
};
+class VCL_DLLPUBLIC JSListBox : public SalInstanceComboBoxWithoutEdit, public JSDialogSender
+{
+public:
+ JSListBox(VclPtr<vcl::Window> aOwnedToplevel, ::ListBox* pListBox, SalInstanceBuilder* pBuilder,
+ bool bTakeOwnership);
+ virtual void insert(int pos, const OUString& rStr, const OUString* pId,
+ const OUString* pIconName, VirtualDevice* pImageSurface) override;
+ virtual void remove(int pos) override;
+};
+
+class VCL_DLLPUBLIC JSComboBox : public SalInstanceComboBoxWithEdit, public JSDialogSender
+{
+public:
+ JSComboBox(VclPtr<vcl::Window> aOwnedToplevel, ::ComboBox* pComboBox,
+ SalInstanceBuilder* pBuilder, bool bTakeOwnership);
+ virtual void insert(int pos, const OUString& rStr, const OUString* pId,
+ const OUString* pIconName, VirtualDevice* pImageSurface) override;
+ virtual void remove(int pos) override;
+ virtual void set_entry_text(const OUString& rText) override;
+};
+
#endif \ No newline at end of file
diff --git a/vcl/inc/salvtables.hxx b/vcl/inc/salvtables.hxx
index 9aa01bcd81c9..2d6acb6d38c1 100644
--- a/vcl/inc/salvtables.hxx
+++ b/vcl/inc/salvtables.hxx
@@ -666,7 +666,7 @@ class SalInstanceComboBox : public SalInstanceContainer, public virtual weld::Co
{
protected:
// owner for ListBox/ComboBox UserData
- std::vector<std::unique_ptr<OUString>> m_aUserData;
+ std::vector<std::shared_ptr<OUString>> m_aUserData;
VclPtr<vcl_type> m_xComboBox;
ScopedVclPtr<::MenuButton> m_xMenuButton;
OUString m_sMenuButtonRow;
diff --git a/vcl/jsdialog/jsdialogbuilder.cxx b/vcl/jsdialog/jsdialogbuilder.cxx
index 8429eae74e11..a3a8457b3145 100644
--- a/vcl/jsdialog/jsdialogbuilder.cxx
+++ b/vcl/jsdialog/jsdialogbuilder.cxx
@@ -70,6 +70,18 @@ std::unique_ptr<weld::Entry> JSInstanceBuilder::weld_entry(const OString& id, bo
: nullptr;
}
+std::unique_ptr<weld::ComboBox> JSInstanceBuilder::weld_combo_box(const OString& id,
+ bool bTakeOwnership)
+{
+ vcl::Window* pWidget = m_xBuilder->get<vcl::Window>(id);
+ ::ComboBox* pComboBox = dynamic_cast<::ComboBox*>(pWidget);
+ if (pComboBox)
+ return std::make_unique<JSComboBox>(m_aOwnedToplevel, pComboBox, this, bTakeOwnership);
+ ListBox* pListBox = dynamic_cast<ListBox*>(pWidget);
+ return pListBox ? std::make_unique<JSListBox>(m_aOwnedToplevel, pListBox, this, bTakeOwnership)
+ : nullptr;
+}
+
JSLabel::JSLabel(VclPtr<vcl::Window> aOwnedToplevel, FixedText* pLabel,
SalInstanceBuilder* pBuilder, bool bTakeOwnership)
: SalInstanceLabel(pLabel, pBuilder, bTakeOwnership)
@@ -95,3 +107,49 @@ void JSEntry::set_text(const OUString& rText)
SalInstanceEntry::set_text(rText);
notifyDialogState();
}
+
+JSListBox::JSListBox(VclPtr<vcl::Window> aOwnedToplevel, ::ListBox* pListBox,
+ SalInstanceBuilder* pBuilder, bool bTakeOwnership)
+ : SalInstanceComboBoxWithoutEdit(pListBox, pBuilder, bTakeOwnership)
+ , JSDialogSender(aOwnedToplevel)
+{
+}
+
+void JSListBox::insert(int pos, const OUString& rStr, const OUString* pId,
+ const OUString* pIconName, VirtualDevice* pImageSurface)
+{
+ SalInstanceComboBoxWithoutEdit::insert(pos, rStr, pId, pIconName, pImageSurface);
+ notifyDialogState();
+}
+
+void JSListBox::remove(int pos)
+{
+ SalInstanceComboBoxWithoutEdit::remove(pos);
+ notifyDialogState();
+}
+
+JSComboBox::JSComboBox(VclPtr<vcl::Window> aOwnedToplevel, ::ComboBox* pComboBox,
+ SalInstanceBuilder* pBuilder, bool bTakeOwnership)
+ : SalInstanceComboBoxWithEdit(pComboBox, pBuilder, bTakeOwnership)
+ , JSDialogSender(aOwnedToplevel)
+{
+}
+
+void JSComboBox::insert(int pos, const OUString& rStr, const OUString* pId,
+ const OUString* pIconName, VirtualDevice* pImageSurface)
+{
+ SalInstanceComboBoxWithEdit::insert(pos, rStr, pId, pIconName, pImageSurface);
+ notifyDialogState();
+}
+
+void JSComboBox::remove(int pos)
+{
+ SalInstanceComboBoxWithEdit::remove(pos);
+ notifyDialogState();
+}
+
+void JSComboBox::set_entry_text(const OUString& rText)
+{
+ SalInstanceComboBoxWithEdit::set_entry_text(rText);
+ notifyDialogState();
+}