Add functions for getting current ribbon tool rectangle
wxRibbonButtonBar::GetItemRect() and wxRibbonToolBar::GetActiveTool() are helpful for positioning other windows (e.g. popup ones) that should be aligned to tools and buttons in the ribbon bar. Closes #22329.
This commit is contained in:
committed by
Vadim Zeitlin
parent
692073ea7d
commit
94f698cc15
@@ -1508,6 +1508,29 @@ int wxRibbonButtonBar::GetItemId(wxRibbonButtonBarButtonBase *item) const
|
||||
return item->id;
|
||||
}
|
||||
|
||||
wxRect wxRibbonButtonBar::GetItemRect(int button_id)const
|
||||
{
|
||||
wxRibbonButtonBarLayout* layout = m_layouts.Item(m_current_layout);
|
||||
size_t btn_count = layout->buttons.Count();
|
||||
size_t btn_i;
|
||||
|
||||
for (btn_i = 0; btn_i < btn_count; ++btn_i)
|
||||
{
|
||||
wxRibbonButtonBarButtonInstance& instance = layout->buttons.Item(btn_i);
|
||||
wxRibbonButtonBarButtonBase* button = instance.base;
|
||||
|
||||
if (button->id == button_id)
|
||||
{
|
||||
wxRibbonButtonBarButtonSizeInfo& size = button->sizes[instance.size];
|
||||
wxRect btn_rect;
|
||||
btn_rect.SetTopLeft(m_layout_offset + instance.position);
|
||||
btn_rect.SetSize(size.size);
|
||||
|
||||
return btn_rect;
|
||||
}
|
||||
}
|
||||
return wxRect();
|
||||
}
|
||||
|
||||
bool wxRibbonButtonBarEvent::PopupMenu(wxMenu* menu)
|
||||
{
|
||||
|
||||
@@ -470,6 +470,11 @@ int wxRibbonToolBar::GetToolId(const wxRibbonToolBarToolBase* tool)const
|
||||
return tool->id;
|
||||
}
|
||||
|
||||
wxRibbonToolBarToolBase* wxRibbonToolBar::GetActiveTool() const
|
||||
{
|
||||
return m_active_tool == NULL ? NULL : m_active_tool;
|
||||
}
|
||||
|
||||
wxObject* wxRibbonToolBar::GetToolClientData(int tool_id)const
|
||||
{
|
||||
wxRibbonToolBarToolBase* tool = FindById(tool_id);
|
||||
|
||||
Reference in New Issue
Block a user