Applied #10079: wxAuiToolBar: Allow right-click on any kind of button

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@66926 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Julian Smart
2011-02-16 23:25:21 +00:00
parent df9d094d71
commit 770cd51482

View File

@@ -539,13 +539,13 @@ wxSize wxAuiDefaultToolBarArt::GetLabelSize(
// get item's width // get item's width
width = item.GetMinSize().GetWidth(); width = item.GetMinSize().GetWidth();
if (width == -1) if (width == -1)
{ {
// no width specified, measure the text ourselves // no width specified, measure the text ourselves
width = dc.GetTextExtent(item.GetLabel()).GetX(); width = dc.GetTextExtent(item.GetLabel()).GetX();
} }
return wxSize(width, height); return wxSize(width, height);
} }
@@ -941,9 +941,9 @@ void wxAuiToolBar::AddTool(int tool_id,
item.min_size = wxDefaultSize; item.min_size = wxDefaultSize;
item.user_data = 0; item.user_data = 0;
item.sticky = false; item.sticky = false;
if (item.id == wxID_ANY) if (item.id == wxID_ANY)
item.id = wxNewId(); item.id = wxNewId();
if (!item.disabled_bitmap.IsOk()) if (!item.disabled_bitmap.IsOk())
{ {
@@ -1008,9 +1008,9 @@ void wxAuiToolBar::AddLabel(int tool_id,
item.user_data = 0; item.user_data = 0;
item.sticky = false; item.sticky = false;
if (item.id == wxID_ANY) if (item.id == wxID_ANY)
item.id = wxNewId(); item.id = wxNewId();
m_items.Add(item); m_items.Add(item);
} }
@@ -1482,7 +1482,7 @@ void wxAuiToolBar::ToggleTool(int tool_id, bool state)
int i, idx, count; int i, idx, count;
idx = GetToolIndex(tool_id); idx = GetToolIndex(tool_id);
count = (int)m_items.GetCount(); count = (int)m_items.GetCount();
if (idx >= 0 && idx < count) if (idx >= 0 && idx < count)
{ {
for (i = idx; i < count; ++i) for (i = idx; i < count; ++i)
@@ -1498,7 +1498,7 @@ void wxAuiToolBar::ToggleTool(int tool_id, bool state)
m_items[i].state &= ~wxAUI_BUTTON_STATE_CHECKED; m_items[i].state &= ~wxAUI_BUTTON_STATE_CHECKED;
} }
} }
tool->state |= wxAUI_BUTTON_STATE_CHECKED; tool->state |= wxAUI_BUTTON_STATE_CHECKED;
} }
else if (tool->kind == wxITEM_CHECK) else if (tool->kind == wxITEM_CHECK)
@@ -2426,11 +2426,11 @@ void wxAuiToolBar::OnLeftUp(wxMouseEvent& evt)
toggle = true; toggle = true;
ToggleTool(m_action_item->id, toggle); ToggleTool(m_action_item->id, toggle);
// repaint immediately // repaint immediately
Refresh(false); Refresh(false);
Update(); Update();
wxCommandEvent e(wxEVT_COMMAND_MENU_SELECTED, m_action_item->id); wxCommandEvent e(wxEVT_COMMAND_MENU_SELECTED, m_action_item->id);
e.SetEventObject(this); e.SetEventObject(this);
e.SetInt(toggle); e.SetInt(toggle);
@@ -2498,15 +2498,12 @@ void wxAuiToolBar::OnRightUp(wxMouseEvent& evt)
if (m_action_item && hit_item == m_action_item) if (m_action_item && hit_item == m_action_item)
{ {
if (hit_item->kind == wxITEM_NORMAL) wxAuiToolBarEvent e(wxEVT_COMMAND_AUITOOLBAR_RIGHT_CLICK, m_action_item->id);
{ e.SetEventObject(this);
wxAuiToolBarEvent e(wxEVT_COMMAND_AUITOOLBAR_RIGHT_CLICK, m_action_item->id); e.SetToolId(m_action_item->id);
e.SetEventObject(this); e.SetClickPoint(m_action_pos);
e.SetToolId(m_action_item->id); ProcessEvent(e);
e.SetClickPoint(m_action_pos); DoIdleUpdate();
ProcessEvent(e);
DoIdleUpdate();
}
} }
else else
{ {