From: Vadim Zeitlin Date: Thu, 20 Sep 2012 20:01:36 +0000 (+0000) Subject: Add wxRibbonButtonBar::GetActiveItem() and GetHoveredItem(). X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/02a40ac1da3c074bd305ac7757b89c617f8ec328 Add wxRibbonButtonBar::GetActiveItem() and GetHoveredItem(). Add accessors for the button being currently clicked or hovered over. See #14630. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@72527 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/include/wx/ribbon/buttonbar.h b/include/wx/ribbon/buttonbar.h index 216d6e2a2e..5028143817 100644 --- a/include/wx/ribbon/buttonbar.h +++ b/include/wx/ribbon/buttonbar.h @@ -137,6 +137,9 @@ public: virtual void EnableButton(int button_id, bool enable = true); virtual void ToggleButton(int button_id, bool checked); + virtual wxRibbonButtonBarButtonBase *GetActiveItem() const; + virtual wxRibbonButtonBarButtonBase *GetHoveredItem() const; + virtual void SetArtProvider(wxRibbonArtProvider* art); virtual bool IsSizingContinuous() const; diff --git a/interface/wx/ribbon/buttonbar.h b/interface/wx/ribbon/buttonbar.h index 292d21b326..05e23634d9 100644 --- a/interface/wx/ribbon/buttonbar.h +++ b/interface/wx/ribbon/buttonbar.h @@ -443,6 +443,23 @@ public: @false to set it to the untoggled/unpressed/unchecked state. */ virtual void ToggleButton(int button_id, bool checked); + + /** + Returns the active item of the button bar or NULL if there is none. + The active button is the one being clicked. + + @since 2.9.5 + */ + virtual wxRibbonButtonBarButtonBase *GetActiveItem() const; + + /** + Returns the hovered item of the button bar or NULL if there is none. + The hovered button is the one the mouse is over. + + @since 2.9.5 + */ + virtual wxRibbonButtonBarButtonBase *GetHoveredItem() const; + }; /** diff --git a/src/ribbon/buttonbar.cpp b/src/ribbon/buttonbar.cpp index b558e6daac..6a2fd4cbbd 100644 --- a/src/ribbon/buttonbar.cpp +++ b/src/ribbon/buttonbar.cpp @@ -1139,6 +1139,19 @@ void wxRibbonButtonBar::OnMouseLeave(wxMouseEvent& WXUNUSED(evt)) if(repaint) Refresh(false); } + +wxRibbonButtonBarButtonBase *wxRibbonButtonBar::GetActiveItem() const +{ + return m_active_button == NULL ? NULL : m_active_button->base; +} + + +wxRibbonButtonBarButtonBase *wxRibbonButtonBar::GetHoveredItem() const +{ + return m_hovered_button == NULL ? NULL : m_hovered_button->base; +} + + wxRibbonButtonBarButtonBase *wxRibbonButtonBar::GetItem(size_t n) const { wxCHECK_MSG(n >= 0 && n < m_buttons.GetCount(), NULL, "wxRibbonButtonBar item's index is out of bound");