Merge branch 'add-ribbonBar-coord-functions' of https://github.com/STgithub64/wxWidgets
Add wxRibbonToolBar GetToolByPos() and GetToolRect(). See https://github.com/wxWidgets/wxWidgets/pull/2152
This commit is contained in:
@@ -131,6 +131,7 @@ public:
|
||||
|
||||
virtual wxRibbonToolBarToolBase* FindById(int tool_id)const;
|
||||
virtual wxRibbonToolBarToolBase* GetToolByPos(size_t pos)const;
|
||||
virtual wxRibbonToolBarToolBase* GetToolByPos(wxCoord x, wxCoord y)const;
|
||||
virtual size_t GetToolCount() const;
|
||||
virtual int GetToolId(const wxRibbonToolBarToolBase* tool)const;
|
||||
|
||||
@@ -139,6 +140,7 @@ public:
|
||||
virtual wxString GetToolHelpString(int tool_id)const;
|
||||
virtual wxRibbonButtonKind GetToolKind(int tool_id)const;
|
||||
virtual int GetToolPos(int tool_id)const;
|
||||
virtual wxRect GetToolRect(int tool_id)const;
|
||||
virtual bool GetToolState(int tool_id)const;
|
||||
|
||||
virtual bool Realize() wxOVERRIDE;
|
||||
|
@@ -307,6 +307,16 @@ public:
|
||||
*/
|
||||
wxRibbonToolBarToolBase* GetToolByPos(size_t pos)const;
|
||||
|
||||
/**
|
||||
Return the opaque pointer for the tool at the given coordinates.
|
||||
|
||||
@return an opaque pointer, NULL if is not found.
|
||||
|
||||
@since 3.1.5
|
||||
*/
|
||||
virtual wxRibbonToolBarToolBase* GetToolByPos(wxCoord x, wxCoord y)const;
|
||||
|
||||
|
||||
/**
|
||||
Returns the number of tools in the toolbar.
|
||||
|
||||
@@ -380,6 +390,18 @@ public:
|
||||
*/
|
||||
virtual int GetToolPos(int tool_id)const;
|
||||
|
||||
/**
|
||||
Returns the rect in the toolbar, or a default-constructed rect if the tool
|
||||
is not found.
|
||||
|
||||
@param tool_id
|
||||
ID of the tool in question, as passed to AddTool().
|
||||
|
||||
@since 3.1.5
|
||||
*/
|
||||
virtual wxRect GetToolRect(int tool_id)const;
|
||||
|
||||
|
||||
/**
|
||||
Gets the on/off state of a toggle tool.
|
||||
|
||||
|
@@ -429,6 +429,26 @@ wxRibbonToolBarToolBase* wxRibbonToolBar::GetToolByPos(size_t pos)const
|
||||
return NULL;
|
||||
}
|
||||
|
||||
wxRibbonToolBarToolBase* wxRibbonToolBar::GetToolByPos(wxCoord x, wxCoord y)const
|
||||
{
|
||||
size_t group_count = m_groups.GetCount();
|
||||
for ( size_t g = 0; g < group_count; ++g )
|
||||
{
|
||||
wxRibbonToolBarToolGroup* group = m_groups.Item(g);
|
||||
size_t tool_count = group->tools.GetCount();
|
||||
for ( size_t t = 0; t < tool_count; ++t )
|
||||
{
|
||||
wxRibbonToolBarToolBase* tool = group->tools.Item(t);
|
||||
wxRect rect(tool->position, tool->size);
|
||||
if(rect.Contains(x, y))
|
||||
{
|
||||
return tool;
|
||||
}
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
size_t wxRibbonToolBar::GetToolCount() const
|
||||
{
|
||||
size_t count = 0;
|
||||
@@ -501,6 +521,30 @@ int wxRibbonToolBar::GetToolPos(int tool_id)const
|
||||
return wxNOT_FOUND;
|
||||
}
|
||||
|
||||
wxRect wxRibbonToolBar::GetToolRect(int tool_id)const
|
||||
{
|
||||
size_t group_count = m_groups.GetCount();
|
||||
size_t g, t;
|
||||
int pos = 0;
|
||||
for(g = 0; g < group_count; ++g)
|
||||
{
|
||||
wxRibbonToolBarToolGroup* group = m_groups.Item(g);
|
||||
size_t tool_count = group->tools.GetCount();
|
||||
for(t = 0; t < tool_count; ++t)
|
||||
{
|
||||
wxRibbonToolBarToolBase* tool = group->tools.Item(t);
|
||||
if (tool->id == tool_id)
|
||||
{
|
||||
wxRect rect(tool->position.x, tool->position.y, tool->size.GetWidth(), tool->size.GetHeight());
|
||||
return rect;
|
||||
}
|
||||
++pos;
|
||||
}
|
||||
++pos; // Increment pos for group separator.
|
||||
}
|
||||
return wxRect();
|
||||
}
|
||||
|
||||
bool wxRibbonToolBar::GetToolState(int tool_id)const
|
||||
{
|
||||
wxRibbonToolBarToolBase* tool = FindById(tool_id);
|
||||
|
Reference in New Issue
Block a user