+wxRibbonToolBarToolGroup* wxRibbonToolBar::InsertGroup(size_t pos)
+{
+ wxRibbonToolBarToolGroup* group = new wxRibbonToolBarToolGroup;
+ group->position = wxPoint(0, 0);
+ group->size = wxSize(0, 0);
+ m_groups.Insert(group, pos);
+ return group;
+}
+
+void wxRibbonToolBar::ClearTools()
+{
+ size_t count = m_groups.GetCount();
+ size_t i, t;
+ for(i = 0; i < count; ++i)
+ {
+ wxRibbonToolBarToolGroup* group = m_groups.Item(i);
+ size_t tool_count = group->tools.GetCount();
+ for(t = 0; t < tool_count; ++t)
+ {
+ wxRibbonToolBarToolBase* tool = group->tools.Item(t);
+ delete tool;
+ }
+ delete group;
+ }
+ m_groups.Clear();
+}
+
+bool wxRibbonToolBar::DeleteTool(int tool_id)
+{
+ size_t group_count = m_groups.GetCount();
+ size_t g, t;
+ 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)
+ {
+ group->tools.RemoveAt(t);
+ delete tool;
+ return true;
+ }
+ }
+ }
+ return false;
+}
+
+bool wxRibbonToolBar::DeleteToolByPos(size_t pos)
+{
+ size_t group_count = m_groups.GetCount();
+ size_t g, t;
+ for(g = 0; g < group_count; ++g)
+ {
+ wxRibbonToolBarToolGroup* group = m_groups.Item(g);
+ size_t tool_count = group->tools.GetCount();
+ if(pos<tool_count)
+ {
+ // Remove tool
+ wxRibbonToolBarToolBase* tool = group->tools.Item(pos);
+ group->tools.RemoveAt(pos);
+ delete tool;
+ return true;
+ }
+ else if(pos==tool_count)
+ {
+ // Remove separator
+ if(g < group_count - 1)
+ {
+ wxRibbonToolBarToolGroup* next_group = m_groups.Item(g+1);
+ for(t = 0; t < next_group->tools.GetCount(); ++t)
+ group->tools.Add(next_group->tools[t]);
+ m_groups.RemoveAt(g+1);
+ delete next_group;
+ }
+ return true;
+ }
+ }
+ return false;
+}
+
+wxRibbonToolBarToolBase* wxRibbonToolBar::FindById(int tool_id)const
+{
+ size_t group_count = m_groups.GetCount();
+ size_t g, t;
+ 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)
+ {
+ return tool;
+ }
+ }
+ }
+ return NULL;
+}
+
+wxRibbonToolBarToolBase* wxRibbonToolBar::GetToolByPos(size_t pos)const
+{
+ size_t group_count = m_groups.GetCount();
+ size_t g;
+ for(g = 0; g < group_count; ++g)
+ {
+ wxRibbonToolBarToolGroup* group = m_groups.Item(g);
+ size_t tool_count = group->tools.GetCount();
+ if(pos<tool_count)
+ {
+ return group->tools[pos];
+ }
+ else if(pos==tool_count)
+ {
+ return NULL;
+ }
+ }
+ return NULL;
+}
+
+size_t wxRibbonToolBar::GetToolCount() const
+{
+ size_t count = 0;
+ for(size_t g = 0; g < m_groups.GetCount(); ++g)
+ {
+ wxRibbonToolBarToolGroup* group = m_groups.Item(g);
+ count += group->tools.GetCount();
+ }
+ // There is a splitter in front of every group except for the first
+ // If only one group, no separator.
+ if(m_groups.GetCount()>1)
+ count += m_groups.GetCount() - 1;
+ return count;
+}
+
+int wxRibbonToolBar::GetToolId(const wxRibbonToolBarToolBase* tool)const
+{
+ wxCHECK_MSG(tool != NULL , wxNOT_FOUND, "The tool pointer must not be NULL");
+ return tool->id;
+}
+
+wxObject* wxRibbonToolBar::GetToolClientData(int tool_id)const
+{
+ wxRibbonToolBarToolBase* tool = FindById(tool_id);
+ wxCHECK_MSG(tool != NULL , NULL, "Invalid tool id");
+ return tool->client_data;
+}
+
+bool wxRibbonToolBar::GetToolEnabled(int tool_id)const
+{
+ wxRibbonToolBarToolBase* tool = FindById(tool_id);
+ wxCHECK_MSG(tool != NULL , false, "Invalid tool id");
+ return (tool->state & wxRIBBON_TOOLBAR_TOOL_DISABLED) == 0;
+}
+
+wxString wxRibbonToolBar::GetToolHelpString(int tool_id)const
+{
+ wxRibbonToolBarToolBase* tool = FindById(tool_id);
+ wxCHECK_MSG(tool != NULL , wxEmptyString, "Invalid tool id");
+ return tool->help_string;
+}
+
+wxRibbonButtonKind wxRibbonToolBar::GetToolKind(int tool_id)const
+{
+ wxRibbonToolBarToolBase* tool = FindById(tool_id);
+ wxCHECK_MSG(tool != NULL , wxRIBBON_BUTTON_NORMAL, "Invalid tool id");
+ return tool->kind;
+}
+
+int wxRibbonToolBar::GetToolPos(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)
+ {
+ return pos;
+ }
+ ++pos;
+ }
+ ++pos; // Increment pos for group separator.
+ }
+ return wxNOT_FOUND;
+}
+
+bool wxRibbonToolBar::GetToolState(int tool_id)const
+{
+ wxRibbonToolBarToolBase* tool = FindById(tool_id);
+ wxCHECK_MSG(tool != NULL , false, "Invalid tool id");
+ return (tool->state & wxRIBBON_TOOLBAR_TOOL_TOGGLED) != 0;
+}
+