diff options
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/source/app/salvtables.cxx | 66 | ||||
-rw-r--r-- | vcl/unx/gtk3/gtk3gtkinst.cxx | 32 |
2 files changed, 67 insertions, 31 deletions
diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx index 33870d28111d..15630fe70503 100644 --- a/vcl/source/app/salvtables.cxx +++ b/vcl/source/app/salvtables.cxx @@ -952,6 +952,7 @@ private: DECL_LINK(ClickHdl, ToolBox*, void); DECL_LINK(DropdownClick, ToolBox*, void); + public: SalInstanceToolbar(ToolBox* pToolBox, SalInstanceBuilder* pBuilder, bool bTakeOwnership) : SalInstanceWidget(pToolBox, pBuilder, bTakeOwnership) @@ -985,34 +986,57 @@ public: { sal_uInt16 nItemId = m_xToolBox->GetItemId(OUString::fromUtf8(rIdent)); m_xToolBox->CheckItem(nItemId, bActive); + } + + virtual bool get_item_active(const OString& rIdent) const override + { + return m_xToolBox->IsItemChecked(m_xToolBox->GetItemId(OUString::fromUtf8(rIdent))); + } + + void set_menu_item_active(const OString& rIdent, bool bActive) override + { + sal_uInt16 nItemId = m_xToolBox->GetItemId(OUString::fromUtf8(rIdent)); + assert (m_xToolBox->GetItemBits(nItemId) & ToolBoxItemBits::DROPDOWN); - if (m_xToolBox->GetItemBits(nItemId) & ToolBoxItemBits::DROPDOWN) + auto pFloat = m_aFloats[nItemId]; + if (pFloat) { - auto pFloat = m_aFloats[nItemId]; - if (pFloat) - { - if (bActive) - vcl::Window::GetDockingManager()->StartPopupMode(m_xToolBox, pFloat, FloatWinPopupFlags::GrabFocus); - else - vcl::Window::GetDockingManager()->EndPopupMode(pFloat); - } - auto pPopup = m_aMenus[nItemId]; - if (pPopup) + if (bActive) + vcl::Window::GetDockingManager()->StartPopupMode(m_xToolBox, pFloat, FloatWinPopupFlags::GrabFocus); + else + vcl::Window::GetDockingManager()->EndPopupMode(pFloat); + } + auto pPopup = m_aMenus[nItemId]; + if (pPopup) + { + if (bActive) { - if (bActive) - { - tools::Rectangle aRect = m_xToolBox->GetItemRect(nItemId); - pPopup->Execute(m_xToolBox, aRect, PopupMenuFlags::ExecuteDown); - } - else - pPopup->EndExecute(); + tools::Rectangle aRect = m_xToolBox->GetItemRect(nItemId); + pPopup->Execute(m_xToolBox, aRect, PopupMenuFlags::ExecuteDown); } + else + pPopup->EndExecute(); } } - virtual bool get_item_active(const OString& rIdent) const override + bool get_menu_item_active(const OString& rIdent) const override { - return m_xToolBox->IsItemChecked(m_xToolBox->GetItemId(OUString::fromUtf8(rIdent))); + sal_uInt16 nItemId = m_xToolBox->GetItemId(OUString::fromUtf8(rIdent)); + assert (m_xToolBox->GetItemBits(nItemId) & ToolBoxItemBits::DROPDOWN); + + auto aFloat = m_aFloats.find(nItemId); + if (aFloat != m_aFloats.end()) + { + return vcl::Window::GetDockingManager()->IsInPopupMode(aFloat->second); + } + + auto aPopup = m_aMenus.find(nItemId); + if (aPopup != m_aMenus.end()) + { + return PopupMenu::GetActivePopupMenu() == aPopup->second;; + } + + return false; } virtual void set_item_popover(const OString& rIdent, weld::Widget* pPopover) override @@ -1113,7 +1137,7 @@ IMPL_LINK_NOARG(SalInstanceToolbar, ClickHdl, ToolBox*, void) IMPL_LINK_NOARG(SalInstanceToolbar, DropdownClick, ToolBox*, void) { sal_uInt16 nItemId = m_xToolBox->GetCurItemId(); - set_item_active(m_xToolBox->GetItemCommand(nItemId).toUtf8(), true); + set_menu_item_active(m_xToolBox->GetItemCommand(nItemId).toUtf8(), true); } namespace { diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx index 1f9815839f24..1addc51082d2 100644 --- a/vcl/unx/gtk3/gtk3gtkinst.cxx +++ b/vcl/unx/gtk3/gtk3gtkinst.cxx @@ -7138,16 +7138,10 @@ public: { disable_item_notify_events(); - auto aFind = m_aMenuButtonMap.find(rIdent); - if (aFind != m_aMenuButtonMap.end()) - aFind->second->set_active(bActive); - else - { - GtkToolButton* pToolButton = m_aMap.find(rIdent)->second; - assert(GTK_IS_TOGGLE_TOOL_BUTTON(pToolButton) || !bActive); - if (GTK_IS_TOGGLE_TOOL_BUTTON(pToolButton)) - gtk_toggle_tool_button_set_active(GTK_TOGGLE_TOOL_BUTTON(pToolButton), bActive); - } + GtkToolButton* pToolButton = m_aMap.find(rIdent)->second; + assert(GTK_IS_TOGGLE_TOOL_BUTTON(pToolButton) || !bActive); + if (GTK_IS_TOGGLE_TOOL_BUTTON(pToolButton)) + gtk_toggle_tool_button_set_active(GTK_TOGGLE_TOOL_BUTTON(pToolButton), bActive); enable_item_notify_events(); } @@ -7162,6 +7156,24 @@ public: return gtk_toggle_tool_button_get_active(GTK_TOGGLE_TOOL_BUTTON(pToolButton)); } + virtual void set_menu_item_active(const OString& rIdent, bool bActive) override + { + disable_item_notify_events(); + + auto aFind = m_aMenuButtonMap.find(rIdent); + assert (aFind != m_aMenuButtonMap.end()); + aFind->second->set_active(bActive); + + enable_item_notify_events(); + } + + virtual bool get_menu_item_active(const OString& rIdent) const override + { + auto aFind = m_aMenuButtonMap.find(rIdent); + assert (aFind != m_aMenuButtonMap.end()); + return aFind->second->get_active(); + } + virtual void insert_separator(int pos, const OUString& rId) override { GtkToolItem* pItem = gtk_separator_tool_item_new(); |