summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSzymon Kłos <szymon.klos@collabora.com>2020-03-04 16:05:10 +0100
committerSzymon Kłos <szymon.klos@collabora.com>2020-05-20 14:31:37 +0200
commit8099c7363c6ddee8390a02389a7dedf7ab9c72b6 (patch)
tree89dbd44eab6dbeee5d97e180a4e0894a3abe3d53
parentfe0176fa4776afb5a2a0a8dc82b8265fb2b2cf31 (diff)
jsdialog: refresh on notebook changes
Change-Id: I81159d043add3d8bdd1b81f26f642f99c1430f73 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94183 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Szymon Kłos <szymon.klos@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94558 Tested-by: Jenkins
-rw-r--r--vcl/inc/jsdialog/jsdialogbuilder.hxx17
-rw-r--r--vcl/inc/salvtables.hxx2
-rw-r--r--vcl/jsdialog/jsdialogbuilder.cxx40
-rw-r--r--vcl/source/app/salvtables.cxx2
4 files changed, 59 insertions, 2 deletions
diff --git a/vcl/inc/jsdialog/jsdialogbuilder.hxx b/vcl/inc/jsdialog/jsdialogbuilder.hxx
index 24b1ef7808c1..ae8261871ee7 100644
--- a/vcl/inc/jsdialog/jsdialogbuilder.hxx
+++ b/vcl/inc/jsdialog/jsdialogbuilder.hxx
@@ -37,6 +37,8 @@ public:
bool bTakeOwnership = false) override;
virtual std::unique_ptr<weld::ComboBox> weld_combo_box(const OString& id,
bool bTakeOwnership = false) override;
+ virtual std::unique_ptr<weld::Notebook> weld_notebook(const OString& id,
+ bool bTakeOwnership = false) override;
};
template <class BaseInstanceClass, class VclClass>
@@ -113,4 +115,19 @@ public:
virtual void set_entry_text(const OUString& rText) override;
};
+class VCL_DLLPUBLIC JSNotebook : public JSWidget<SalInstanceNotebook, ::TabControl>
+{
+public:
+ JSNotebook(VclPtr<vcl::Window> aOwnedToplevel, ::TabControl* pControl,
+ SalInstanceBuilder* pBuilder, bool bTakeOwnership);
+
+ virtual void set_current_page(int nPage) override;
+
+ virtual void set_current_page(const OString& rIdent) override;
+
+ virtual void remove_page(const OString& rIdent) override;
+
+ virtual void insert_page(const OString& rIdent, const OUString& rLabel, int nPos) override;
+};
+
#endif \ No newline at end of file
diff --git a/vcl/inc/salvtables.hxx b/vcl/inc/salvtables.hxx
index ad41e5707218..b42440f4b477 100644
--- a/vcl/inc/salvtables.hxx
+++ b/vcl/inc/salvtables.hxx
@@ -1028,7 +1028,7 @@ class SalInstanceNotebook : public SalInstanceContainer, public virtual weld::No
{
private:
VclPtr<TabControl> m_xNotebook;
- mutable std::vector<std::unique_ptr<SalInstanceContainer>> m_aPages;
+ mutable std::vector<std::shared_ptr<SalInstanceContainer>> m_aPages;
std::map<OString, std::pair<VclPtr<TabPage>, VclPtr<VclGrid>>> m_aAddedPages;
DECL_LINK(DeactivatePageHdl, TabControl*, bool);
diff --git a/vcl/jsdialog/jsdialogbuilder.cxx b/vcl/jsdialog/jsdialogbuilder.cxx
index dc6951105763..facd3991746a 100644
--- a/vcl/jsdialog/jsdialogbuilder.cxx
+++ b/vcl/jsdialog/jsdialogbuilder.cxx
@@ -89,6 +89,15 @@ std::unique_ptr<weld::ComboBox> JSInstanceBuilder::weld_combo_box(const OString&
: nullptr;
}
+std::unique_ptr<weld::Notebook> JSInstanceBuilder::weld_notebook(const OString& id,
+ bool bTakeOwnership)
+{
+ TabControl* pNotebook = m_xBuilder->get<TabControl>(id);
+ return pNotebook
+ ? std::make_unique<JSNotebook>(m_aOwnedToplevel, pNotebook, this, bTakeOwnership)
+ : nullptr;
+}
+
JSLabel::JSLabel(VclPtr<vcl::Window> aOwnedToplevel, FixedText* pLabel,
SalInstanceBuilder* pBuilder, bool bTakeOwnership)
: JSWidget<SalInstanceLabel, FixedText>(aOwnedToplevel, pLabel, pBuilder, bTakeOwnership)
@@ -164,3 +173,34 @@ void JSComboBox::set_entry_text(const OUString& rText)
SalInstanceComboBoxWithEdit::set_entry_text(rText);
notifyDialogState();
}
+
+JSNotebook::JSNotebook(VclPtr<vcl::Window> aOwnedToplevel, ::TabControl* pControl,
+ SalInstanceBuilder* pBuilder, bool bTakeOwnership)
+ : JSWidget<SalInstanceNotebook, ::TabControl>(aOwnedToplevel, pControl, pBuilder,
+ bTakeOwnership)
+{
+}
+
+void JSNotebook::set_current_page(int nPage)
+{
+ SalInstanceNotebook::set_current_page(nPage);
+ notifyDialogState();
+}
+
+void JSNotebook::set_current_page(const OString& rIdent)
+{
+ SalInstanceNotebook::set_current_page(rIdent);
+ notifyDialogState();
+}
+
+void JSNotebook::remove_page(const OString& rIdent)
+{
+ SalInstanceNotebook::remove_page(rIdent);
+ notifyDialogState();
+}
+
+void JSNotebook::insert_page(const OString& rIdent, const OUString& rLabel, int nPos)
+{
+ SalInstanceNotebook::insert_page(rIdent, rLabel, nPos);
+ notifyDialogState();
+}
diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx
index 82b813a819b8..c53c7603a8c4 100644
--- a/vcl/source/app/salvtables.cxx
+++ b/vcl/source/app/salvtables.cxx
@@ -2157,7 +2157,7 @@ weld::Container* SalInstanceNotebook::get_page(const OString& rIdent) const
if (m_aPages.size() < nPageIndex + 1U)
m_aPages.resize(nPageIndex + 1U);
if (!m_aPages[nPageIndex])
- m_aPages[nPageIndex].reset(new SalInstanceContainer(pChild, m_pBuilder, false));
+ m_aPages[nPageIndex] = std::make_shared<SalInstanceContainer>(pChild, m_pBuilder, false);
return m_aPages[nPageIndex].get();
}