include/vcl/jsdialog/executor.hxx | 10 ++++++ include/vcl/weld.hxx | 2 + vcl/inc/jsdialog/jsdialogbuilder.hxx | 26 +++++++++++++++++ vcl/jsdialog/executor.cxx | 21 ++++++++++++++ vcl/jsdialog/jsdialogbuilder.cxx | 51 +++++++++++++++++++++++++++++++++++ 5 files changed, 110 insertions(+)
New commits: commit b77dc3cbd9b16277a6bce0db4105405de0223156 Author: Szymon Kłos <szymon.k...@collabora.com> AuthorDate: Fri Mar 10 10:03:49 2023 +0100 Commit: Szymon Kłos <szymon.k...@collabora.com> CommitDate: Fri Mar 10 13:15:04 2023 +0000 jsdialog: add wrapper for ScrolledWindow Change-Id: I59489e4cf1e5fb492272108e3a19afb4212753f5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148610 Tested-by: Szymon Kłos <szymon.k...@collabora.com> Reviewed-by: Szymon Kłos <szymon.k...@collabora.com> diff --git a/include/vcl/jsdialog/executor.hxx b/include/vcl/jsdialog/executor.hxx index 9bccad3f1865..50f71272bb61 100644 --- a/include/vcl/jsdialog/executor.hxx +++ b/include/vcl/jsdialog/executor.hxx @@ -27,6 +27,16 @@ public: static void trigger_changed(weld::IconView& rIconView) { rIconView.signal_selection_changed(); } + static void trigger_scrollv(weld::ScrolledWindow& rScrolledWindow) + { + rScrolledWindow.signal_vadjustment_changed(); + } + + static void trigger_scrollh(weld::ScrolledWindow& rScrolledWindow) + { + rScrolledWindow.signal_hadjustment_changed(); + } + static void trigger_toggled(weld::Toggleable& rButton) { rButton.signal_toggled(); } static void trigger_row_activated(weld::TreeView& rTreeView) diff --git a/include/vcl/weld.hxx b/include/vcl/weld.hxx index e352c2e357f7..1960bf1ffd06 100644 --- a/include/vcl/weld.hxx +++ b/include/vcl/weld.hxx @@ -397,6 +397,8 @@ public: class VCL_DLLPUBLIC ScrolledWindow : virtual public Container { + friend class ::LOKTrigger; + Link<ScrolledWindow&, void> m_aVChangeHdl; Link<ScrolledWindow&, void> m_aHChangeHdl; diff --git a/vcl/inc/jsdialog/jsdialogbuilder.hxx b/vcl/inc/jsdialog/jsdialogbuilder.hxx index 0c6cbaa48080..783aeaacfff7 100644 --- a/vcl/inc/jsdialog/jsdialogbuilder.hxx +++ b/vcl/inc/jsdialog/jsdialogbuilder.hxx @@ -40,6 +40,7 @@ class ComboBox; class VclMultiLineEdit; class SvTabListBox; class IconView; +class VclScrolledWindow; namespace vcl { @@ -304,6 +305,8 @@ public: virtual std::unique_ptr<weld::TreeView> weld_tree_view(const OString& id) override; virtual std::unique_ptr<weld::Expander> weld_expander(const OString& id) override; virtual std::unique_ptr<weld::IconView> weld_icon_view(const OString& id) override; + virtual std::unique_ptr<weld::ScrolledWindow> + weld_scrolled_window(const OString& id, bool bUserManagedScrolling = false) override; virtual std::unique_ptr<weld::RadioButton> weld_radio_button(const OString& id) override; virtual std::unique_ptr<weld::Frame> weld_frame(const OString& id) override; virtual std::unique_ptr<weld::MenuButton> weld_menu_button(const OString& id) override; @@ -368,6 +371,14 @@ public: { } + JSWidget(JSDialogSender* pSender, VclClass* pObject, SalInstanceBuilder* pBuilder, + bool bTakeOwnership, bool bUserManagedScrolling) + : BaseInstanceClass(pObject, pBuilder, bTakeOwnership, bUserManagedScrolling) + , m_bIsFreezed(false) + , m_pSender(pSender) + { + } + JSWidget(JSDialogSender* pSender, VclClass* pObject, SalInstanceBuilder* pBuilder, const a11yref& rAlly, FactoryFunction pUITestFactoryFunction, void* pUserData, bool bTakeOwnership) @@ -510,6 +521,21 @@ public: bool bTakeOwnership); }; +class JSScrolledWindow final : public JSWidget<SalInstanceScrolledWindow, ::VclScrolledWindow> +{ +public: + JSScrolledWindow(JSDialogSender* pSender, ::VclScrolledWindow* pWindow, + SalInstanceBuilder* pBuilder, bool bTakeOwnership, bool bUserManagedScrolling); + + virtual void vadjustment_configure(int value, int lower, int upper, int step_increment, + int page_increment, int page_size) override; + virtual void set_vpolicy(VclPolicyType eVPolicy) override; + + virtual void hadjustment_configure(int value, int lower, int upper, int step_increment, + int page_increment, int page_size) override; + virtual void set_hpolicy(VclPolicyType eVPolicy) override; +}; + class JSLabel final : public JSWidget<SalInstanceLabel, Control> { public: diff --git a/vcl/jsdialog/executor.cxx b/vcl/jsdialog/executor.cxx index 6eb92f105e72..e2e091bfa143 100644 --- a/vcl/jsdialog/executor.cxx +++ b/vcl/jsdialog/executor.cxx @@ -547,6 +547,27 @@ bool ExecuteAction(const std::string& nWindowId, const OString& rWidget, StringM } } } + else if (sControlType == "scrolledwindow") + { + auto pScrolledWindow = dynamic_cast<weld::ScrolledWindow*>(pWidget); + if (pScrolledWindow) + { + if (sAction == "scrollv") + { + sal_Int32 nValue = o3tl::toInt32(rData["data"]); + pScrolledWindow->vadjustment_set_value(nValue); + LOKTrigger::trigger_scrollv(*pScrolledWindow); + return true; + } + else if (sAction == "scrollh") + { + sal_Int32 nValue = o3tl::toInt32(rData["data"]); + pScrolledWindow->hadjustment_set_value(nValue); + LOKTrigger::trigger_scrollh(*pScrolledWindow); + return true; + } + } + } } return false; diff --git a/vcl/jsdialog/jsdialogbuilder.cxx b/vcl/jsdialog/jsdialogbuilder.cxx index 3cfe67c3b56c..d623e9723a7e 100644 --- a/vcl/jsdialog/jsdialogbuilder.cxx +++ b/vcl/jsdialog/jsdialogbuilder.cxx @@ -950,6 +950,21 @@ std::unique_ptr<weld::Container> JSInstanceBuilder::weld_container(const OString return pWeldWidget; } +std::unique_ptr<weld::ScrolledWindow> +JSInstanceBuilder::weld_scrolled_window(const OString& id, bool bUserManagedScrolling) +{ + VclScrolledWindow* pScrolledWindow = m_xBuilder->get<VclScrolledWindow>(id); + auto pWeldWidget = pScrolledWindow + ? std::make_unique<JSScrolledWindow>(this, pScrolledWindow, this, false, + bUserManagedScrolling) + : nullptr; + + if (pWeldWidget) + RememberWidget(id, pWeldWidget.get()); + + return pWeldWidget; +} + std::unique_ptr<weld::Label> JSInstanceBuilder::weld_label(const OString& id) { Control* pLabel = m_xBuilder->get<Control>(id); @@ -1393,6 +1408,42 @@ JSContainer::JSContainer(JSDialogSender* pSender, vcl::Window* pContainer, { } +JSScrolledWindow::JSScrolledWindow(JSDialogSender* pSender, ::VclScrolledWindow* pContainer, + SalInstanceBuilder* pBuilder, bool bTakeOwnership, + bool bUserManagedScrolling) + : JSWidget<SalInstanceScrolledWindow, ::VclScrolledWindow>( + pSender, pContainer, pBuilder, bTakeOwnership, bUserManagedScrolling) +{ +} + +void JSScrolledWindow::vadjustment_configure(int value, int lower, int upper, int step_increment, + int page_increment, int page_size) +{ + SalInstanceScrolledWindow::vadjustment_configure(value, lower, upper, step_increment, + page_increment, page_size); + sendUpdate(); +} + +void JSScrolledWindow::set_vpolicy(VclPolicyType eVPolicy) +{ + SalInstanceScrolledWindow::set_vpolicy(eVPolicy); + sendUpdate(); +} + +void JSScrolledWindow::hadjustment_configure(int value, int lower, int upper, int step_increment, + int page_increment, int page_size) +{ + SalInstanceScrolledWindow::hadjustment_configure(value, lower, upper, step_increment, + page_increment, page_size); + sendUpdate(); +} + +void JSScrolledWindow::set_hpolicy(VclPolicyType eVPolicy) +{ + SalInstanceScrolledWindow::set_hpolicy(eVPolicy); + sendUpdate(); +} + JSLabel::JSLabel(JSDialogSender* pSender, Control* pLabel, SalInstanceBuilder* pBuilder, bool bTakeOwnership) : JSWidget<SalInstanceLabel, Control>(pSender, pLabel, pBuilder, bTakeOwnership)