diff options
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/inc/salvtables.hxx | 16 | ||||
-rw-r--r-- | vcl/source/app/salvtables.cxx | 84 | ||||
-rw-r--r-- | vcl/source/control/wizardmachine.cxx | 14 | ||||
-rw-r--r-- | vcl/unx/gtk3/gtkinst.cxx | 84 |
4 files changed, 114 insertions, 84 deletions
diff --git a/vcl/inc/salvtables.hxx b/vcl/inc/salvtables.hxx index e21c9d48780e..b6573d2cf489 100644 --- a/vcl/inc/salvtables.hxx +++ b/vcl/inc/salvtables.hxx @@ -228,10 +228,6 @@ public: virtual bool has_child_focus() const override; - virtual void set_has_default(bool has_default) override; - - virtual bool get_has_default() const override; - virtual void show() override; virtual void hide() override; @@ -417,9 +413,6 @@ class SalInstanceContainer : public SalInstanceWidget, public virtual weld::Cont protected: VclPtr<vcl::Window> m_xContainer; -private: - void implResetDefault(const vcl::Window* _pWindow); - public: SalInstanceContainer(vcl::Window* pContainer, SalInstanceBuilder* pBuilder, bool bTakeOwnership); @@ -427,7 +420,6 @@ public: virtual void connect_container_focus_changed(const Link<Container&, void>& rLink) override; virtual void child_grab_focus() override; virtual void move(weld::Widget* pWidget, weld::Container* pNewParent) override; - virtual void recursively_unset_default_buttons() override; virtual css::uno::Reference<css::awt::XWindow> CreateChildFrame() override; }; @@ -442,6 +434,10 @@ private: void clear_child_help(vcl::Window* pParent); + void recursively_unset_default_buttons(); + + void implResetDefault(const vcl::Window* _pWindow); + public: SalInstanceWindow(vcl::Window* pWindow, SalInstanceBuilder* pBuilder, bool bTakeOwnership); @@ -475,6 +471,10 @@ public: virtual void present() override; + virtual void change_default_widget(weld::Widget* pOld, weld::Widget* pNew) override; + + virtual bool is_default_widget(const weld::Widget* pCandidate) const override; + virtual void set_window_state(const OString& rStr) override; virtual OString get_window_state(WindowStateMask nMask) const override; diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx index bfcd6834caac..7f33f6e7973b 100644 --- a/vcl/source/app/salvtables.cxx +++ b/vcl/source/app/salvtables.cxx @@ -304,13 +304,6 @@ bool SalInstanceWidget::is_active() const { return m_xWidget->IsActive(); } bool SalInstanceWidget::has_child_focus() const { return m_xWidget->HasChildPathFocus(true); } -void SalInstanceWidget::set_has_default(bool has_default) -{ - m_xWidget->set_property("has-default", OUString::boolean(has_default)); -} - -bool SalInstanceWidget::get_has_default() const { return m_xWidget->GetStyle() & WB_DEFBUTTON; } - void SalInstanceWidget::show() { m_xWidget->Show(); } void SalInstanceWidget::hide() { m_xWidget->Hide(); } @@ -1179,30 +1172,6 @@ public: }; } -void SalInstanceContainer::implResetDefault(const vcl::Window* _pWindow) -{ - vcl::Window* pChildLoop = _pWindow->GetWindow(GetWindowType::FirstChild); - while (pChildLoop) - { - // does the window participate in the tabbing order? - if (pChildLoop->GetStyle() & WB_DIALOGCONTROL) - implResetDefault(pChildLoop); - - // is it a button? - WindowType eType = pChildLoop->GetType(); - if ((WindowType::PUSHBUTTON == eType) || (WindowType::OKBUTTON == eType) - || (WindowType::CANCELBUTTON == eType) || (WindowType::HELPBUTTON == eType) - || (WindowType::IMAGEBUTTON == eType) || (WindowType::MENUBUTTON == eType) - || (WindowType::MOREBUTTON == eType)) - { - pChildLoop->SetStyle(pChildLoop->GetStyle() & ~WB_DEFBUTTON); - } - - // the next one ... - pChildLoop = pChildLoop->GetWindow(GetWindowType::Next); - } -} - void SalInstanceContainer::connect_container_focus_changed(const Link<Container&, void>& rLink) { ensure_event_listener(); @@ -1250,11 +1219,6 @@ void SalInstanceContainer::child_grab_focus() pFirstChild->ImplControlFocus(); } -void SalInstanceContainer::recursively_unset_default_buttons() -{ - implResetDefault(m_xContainer.get()); -} - css::uno::Reference<css::awt::XWindow> SalInstanceContainer::CreateChildFrame() { auto xPage = VclPtr<VclBin>::Create(m_xContainer.get()); @@ -1514,6 +1478,54 @@ void SalInstanceWindow::present() m_xWindow->ToTop(ToTopFlags::RestoreWhenMin | ToTopFlags::ForegroundTask); } +void SalInstanceWindow::implResetDefault(const vcl::Window* _pWindow) +{ + vcl::Window* pChildLoop = _pWindow->GetWindow(GetWindowType::FirstChild); + while (pChildLoop) + { + // does the window participate in the tabbing order? + if (pChildLoop->GetStyle() & WB_DIALOGCONTROL) + implResetDefault(pChildLoop); + + // is it a button? + WindowType eType = pChildLoop->GetType(); + if ((WindowType::PUSHBUTTON == eType) || (WindowType::OKBUTTON == eType) + || (WindowType::CANCELBUTTON == eType) || (WindowType::HELPBUTTON == eType) + || (WindowType::IMAGEBUTTON == eType) || (WindowType::MENUBUTTON == eType) + || (WindowType::MOREBUTTON == eType)) + { + pChildLoop->SetStyle(pChildLoop->GetStyle() & ~WB_DEFBUTTON); + } + + // the next one ... + pChildLoop = pChildLoop->GetWindow(GetWindowType::Next); + } +} + +void SalInstanceWindow::recursively_unset_default_buttons() { implResetDefault(m_xWindow.get()); } + +void SalInstanceWindow::change_default_widget(weld::Widget* pOld, weld::Widget* pNew) +{ + if (!pOld) + recursively_unset_default_buttons(); + else + { + SalInstanceWidget* pVclOld = dynamic_cast<SalInstanceWidget*>(pOld); + pVclOld->getWidget()->set_property("has-default", OUString::boolean(false)); + } + if (pNew) + { + SalInstanceWidget* pVclNew = dynamic_cast<SalInstanceWidget*>(pNew); + pVclNew->getWidget()->set_property("has-default", OUString::boolean(true)); + } +} + +bool SalInstanceWindow::is_default_widget(const weld::Widget* pCandidate) const +{ + const SalInstanceWidget* pVclCandidate = dynamic_cast<const SalInstanceWidget*>(pCandidate); + return pVclCandidate->getWidget()->GetStyle() & WB_DEFBUTTON; +} + void SalInstanceWindow::set_window_state(const OString& rStr) { SystemWindow* pSysWin = dynamic_cast<SystemWindow*>(m_xWindow.get()); diff --git a/vcl/source/control/wizardmachine.cxx b/vcl/source/control/wizardmachine.cxx index 59d2514fbbce..e2ed41ff0de7 100644 --- a/vcl/source/control/wizardmachine.cxx +++ b/vcl/source/control/wizardmachine.cxx @@ -949,21 +949,15 @@ namespace vcl if (_nWizardButtonFlags & WizardButtonFlags::CANCEL) pNewDefButton = m_xCancel.get(); - if ( pNewDefButton ) - defaultButton( pNewDefButton ); - else - m_xAssistant->recursively_unset_default_buttons(); + defaultButton(pNewDefButton); } void WizardMachine::defaultButton(weld::Button* _pNewDefButton) { // loop through all (direct and indirect) descendants which participate in our tabbing order, and - // reset the WB_DEFBUTTON for every window which is a button - m_xAssistant->recursively_unset_default_buttons(); - - // set its new style - if (_pNewDefButton) - _pNewDefButton->set_has_default(true); + // reset the WB_DEFBUTTON for every window which is a button and set _pNewDefButton as the new + // WB_DEFBUTTON + m_xAssistant->change_default_widget(nullptr, _pNewDefButton); } void WizardMachine::enableButtons(WizardButtonFlags _nWizardButtonFlags, bool _bEnable) diff --git a/vcl/unx/gtk3/gtkinst.cxx b/vcl/unx/gtk3/gtkinst.cxx index 39ebfb67bb38..ebc162dfcf65 100644 --- a/vcl/unx/gtk3/gtkinst.cxx +++ b/vcl/unx/gtk3/gtkinst.cxx @@ -3510,18 +3510,6 @@ public: return false; } - virtual void set_has_default(bool has_default) override - { - g_object_set(G_OBJECT(m_pWidget), "has-default", has_default, nullptr); - } - - virtual bool get_has_default() const override - { - gboolean has_default(false); - g_object_get(G_OBJECT(m_pWidget), "has-default", &has_default, nullptr); - return has_default; - } - virtual void show() override { gtk_widget_show(m_pWidget); @@ -3876,7 +3864,7 @@ public: return m_pWidget; } - GtkWindow* getWindow() + GtkWindow* getWindow() const { return GTK_WINDOW(widget_get_toplevel(m_pWidget)); } @@ -5692,18 +5680,6 @@ private: gulong m_nSetFocusChildSignalId; bool m_bChildHasFocus; - static void implResetDefault(GtkWidget *pWidget, gpointer user_data) - { - if (GTK_IS_BUTTON(pWidget)) - g_object_set(G_OBJECT(pWidget), "has-default", false, nullptr); -#if !GTK_CHECK_VERSION(4, 0, 0) - if (GTK_IS_CONTAINER(pWidget)) - gtk_container_forall(GTK_CONTAINER(pWidget), implResetDefault, user_data); -#else - (void)user_data; -#endif - } - void signal_set_focus_child(bool bChildHasFocus) { if (m_bChildHasFocus != bChildHasFocus) @@ -5807,11 +5783,6 @@ public: g_object_unref(pChild); } - virtual void recursively_unset_default_buttons() override - { - implResetDefault(GTK_WIDGET(m_pContainer), nullptr); - } - virtual css::uno::Reference<css::awt::XWindow> CreateChildFrame() override { // This will cause a GtkSalFrame to be created. With WB_SYSTEMCHILDWINDOW set it @@ -6034,6 +6005,21 @@ private: gulong m_nToplevelFocusChangedSignalId; #if !GTK_CHECK_VERSION(4, 0, 0) + static void implResetDefault(GtkWidget *pWidget, gpointer user_data) + { + if (GTK_IS_BUTTON(pWidget)) + g_object_set(G_OBJECT(pWidget), "has-default", false, nullptr); + if (GTK_IS_CONTAINER(pWidget)) + gtk_container_forall(GTK_CONTAINER(pWidget), implResetDefault, user_data); + } + + void recursively_unset_default_buttons() + { + implResetDefault(GTK_WIDGET(m_pWindow), nullptr); + } +#endif + +#if !GTK_CHECK_VERSION(4, 0, 0) static gboolean help_pressed(GtkAccelGroup*, GObject*, guint, GdkModifierType, gpointer widget) { GtkInstanceWindow* pThis = static_cast<GtkInstanceWindow*>(widget); @@ -6191,6 +6177,44 @@ public: gtk_window_present(m_pWindow); } + virtual void change_default_widget(weld::Widget* pOld, weld::Widget* pNew) override + { +#if GTK_CHECK_VERSION(4, 0, 0) + GtkInstanceWidget* pGtkNew = dynamic_cast<GtkInstanceWidget*>(pNew); + GtkWidget* pWidgetNew = pGtkNew ? pGtkNew->getWidget() : nullptr; + gtk_window_set_default_widget(m_pWindow, pWidgetNew); + (void)pOld; +#else + if (!pOld) + recursively_unset_default_buttons(); + else + { + GtkInstanceWidget* pGtkOld = dynamic_cast<GtkInstanceWidget*>(pOld); + GtkWidget* pWidgetOld = pGtkOld->getWidget(); + g_object_set(G_OBJECT(pWidgetOld), "has-default", false, nullptr); + } + if (pNew) + { + GtkInstanceWidget* pGtkNew = dynamic_cast<GtkInstanceWidget*>(pNew); + GtkWidget* pWidgetNew = pGtkNew->getWidget(); + g_object_set(G_OBJECT(pWidgetNew), "has-default", true, nullptr); + } +#endif + } + + virtual bool is_default_widget(const weld::Widget* pCandidate) const override + { + const GtkInstanceWidget* pGtkCandidate = dynamic_cast<const GtkInstanceWidget*>(pCandidate); + GtkWidget* pWidget = pGtkCandidate->getWidget(); +#if GTK_CHECK_VERSION(4, 0, 0) + return gtk_window_get_default_widget(m_pWindow) == pWidget; +#else + gboolean has_default(false); + g_object_get(G_OBJECT(pWidget), "has-default", &has_default, nullptr); + return has_default; +#endif + } + virtual void set_window_state(const OString& rStr) override { WindowStateData aData; |