Add wxRibbonButtonBar::GetItem(), GetItemById() and GetItemId().
Allow accessing the ribbon bar buttons either by index or ID. See #14630. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@72526 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
4f97cb83cf
commit
71a77e77d1
@ -126,6 +126,10 @@ public:
|
||||
wxObject* client_data = NULL);
|
||||
|
||||
virtual size_t GetButtonCount() const;
|
||||
virtual wxRibbonButtonBarButtonBase *GetItem(size_t n) const;
|
||||
virtual wxRibbonButtonBarButtonBase *GetItemById(int id) const;
|
||||
virtual int GetItemId(wxRibbonButtonBarButtonBase *button) const;
|
||||
|
||||
|
||||
virtual bool Realize();
|
||||
virtual void ClearButtons();
|
||||
|
@ -377,6 +377,29 @@ public:
|
||||
*/
|
||||
virtual size_t GetButtonCount() const;
|
||||
|
||||
/**
|
||||
Returns the N-th button of the bar.
|
||||
|
||||
@see GetButtonCount()
|
||||
|
||||
@since 2.9.5
|
||||
*/
|
||||
virtual wxRibbonButtonBarButtonBase *GetItem(size_t n) const;
|
||||
|
||||
/**
|
||||
Returns the first button having a given id or NULL if none matches.
|
||||
|
||||
@since 2.9.5
|
||||
*/
|
||||
virtual wxRibbonButtonBarButtonBase *GetItemById(int id) const;
|
||||
|
||||
/**
|
||||
Returns the id of a button.
|
||||
|
||||
@since 2.9.5
|
||||
*/
|
||||
virtual int GetItemId(wxRibbonButtonBarButtonBase *) const;
|
||||
|
||||
/**
|
||||
Calculate button layouts and positions.
|
||||
|
||||
|
@ -1139,6 +1139,32 @@ void wxRibbonButtonBar::OnMouseLeave(wxMouseEvent& WXUNUSED(evt))
|
||||
if(repaint)
|
||||
Refresh(false);
|
||||
}
|
||||
wxRibbonButtonBarButtonBase *wxRibbonButtonBar::GetItem(size_t n) const
|
||||
{
|
||||
wxCHECK_MSG(n >= 0 && n < m_buttons.GetCount(), NULL, "wxRibbonButtonBar item's index is out of bound");
|
||||
return m_buttons.Item(n);
|
||||
}
|
||||
|
||||
wxRibbonButtonBarButtonBase *wxRibbonButtonBar::GetItemById(int button_id) const
|
||||
{
|
||||
size_t count = m_buttons.GetCount();
|
||||
for ( size_t i = 0; i < count; ++i )
|
||||
{
|
||||
wxRibbonButtonBarButtonBase* button = m_buttons.Item(i);
|
||||
if ( button->id == button_id )
|
||||
return button;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
||||
}
|
||||
|
||||
int wxRibbonButtonBar::GetItemId(wxRibbonButtonBarButtonBase *item) const
|
||||
{
|
||||
wxCHECK_MSG(item != NULL, wxNOT_FOUND, "wxRibbonButtonBar item should not be NULL");
|
||||
return item->id;
|
||||
}
|
||||
|
||||
|
||||
bool wxRibbonButtonBarEvent::PopupMenu(wxMenu* menu)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user