X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/03dc350fa6de6edfe3ad9de2b951b1e7eee4f9a6..64ea838d8f4d1853b7d850db93ee565e901d099a:/src/aui/auibar.cpp diff --git a/src/aui/auibar.cpp b/src/aui/auibar.cpp index d9bb3046b4..b145f100af 100644 --- a/src/aui/auibar.cpp +++ b/src/aui/auibar.cpp @@ -798,17 +798,7 @@ BEGIN_EVENT_TABLE(wxAuiToolBar, wxControl) EVT_SET_CURSOR(wxAuiToolBar::OnSetCursor) END_EVENT_TABLE() - -wxAuiToolBar::wxAuiToolBar(wxWindow* parent, - wxWindowID id, - const wxPoint& position, - const wxSize& size, - long style) - : wxControl(parent, - id, - position, - size, - style | wxBORDER_NONE) +void wxAuiToolBar::Init() { m_sizer = new wxBoxSizer(wxHORIZONTAL); m_buttonWidth = -1; @@ -824,15 +814,29 @@ wxAuiToolBar::wxAuiToolBar(wxWindow* parent, m_gripperSizerItem = NULL; m_overflowSizerItem = NULL; m_dragging = false; + m_gripperVisible = (m_style & wxAUI_TB_GRIPPER) ? true : false; + m_overflowVisible = (m_style & wxAUI_TB_OVERFLOW) ? true : false; + m_overflowState = 0; +} + +bool wxAuiToolBar::Create(wxWindow* parent, + wxWindowID id, + const wxPoint& pos, + const wxSize& size, + long style) +{ + style = style|wxBORDER_NONE; + + if (!wxControl::Create(parent, id, pos, size, style)) + return false; + + m_style = style; m_orientation = GetOrientation(style); if (m_orientation == wxBOTH) { m_orientation = wxHORIZONTAL; } - m_style = style | wxBORDER_NONE; - m_gripperVisible = (m_style & wxAUI_TB_GRIPPER) ? true : false; - m_overflowVisible = (m_style & wxAUI_TB_OVERFLOW) ? true : false; - m_overflowState = 0; + SetMargins(5, 5, 2, 2); SetFont(*wxNORMAL_FONT); SetArtFlags(); @@ -840,8 +844,9 @@ wxAuiToolBar::wxAuiToolBar(wxWindow* parent, if (style & wxAUI_TB_HORZ_LAYOUT) SetToolTextOrientation(wxAUI_TBTOOL_TEXT_RIGHT); SetBackgroundStyle(wxBG_STYLE_CUSTOM); -} + return true; +} wxAuiToolBar::~wxAuiToolBar() { @@ -1406,6 +1411,9 @@ bool wxAuiToolBar::SetFont(const wxFont& font) void wxAuiToolBar::SetHoverItem(wxAuiToolBarItem* pitem) { + if (pitem && (pitem->m_state & wxAUI_BUTTON_STATE_DISABLED)) + pitem = NULL; + wxAuiToolBarItem* former_hover = NULL; size_t i, count; @@ -2527,9 +2535,9 @@ void wxAuiToolBar::OnLeftDown(wxMouseEvent& evt) Refresh(false); if (res != -1) { - wxCommandEvent e(wxEVT_COMMAND_MENU_SELECTED, res); - e.SetEventObject(this); - GetParent()->GetEventHandler()->ProcessEvent(e); + wxCommandEvent event(wxEVT_COMMAND_MENU_SELECTED, res); + event.SetEventObject(this); + GetParent()->GetEventHandler()->ProcessEvent(event); } } @@ -2580,6 +2588,11 @@ void wxAuiToolBar::OnLeftDown(wxMouseEvent& evt) if(!GetEventHandler()->ProcessEvent(e) || e.GetSkipped()) CaptureMouse(); + // Ensure hovered item is really ok, as mouse may have moved during + // event processing + wxPoint cursor_pos_after_evt = ScreenToClient(wxGetMousePosition()); + SetHoverItem(FindToolByPosition(cursor_pos_after_evt.x, cursor_pos_after_evt.y)); + DoIdleUpdate(); } } @@ -2591,11 +2604,9 @@ void wxAuiToolBar::OnLeftUp(wxMouseEvent& evt) SetPressedItem(NULL); - wxAuiToolBarItem* hitItem = FindToolByPosition(evt.GetX(), evt.GetY()); - if (hitItem && !(hitItem->m_state & wxAUI_BUTTON_STATE_DISABLED)) - { - SetHoverItem(hitItem); - } + wxAuiToolBarItem* hitItem; + hitItem = FindToolByPosition(evt.GetX(), evt.GetY()); + SetHoverItem(hitItem); if (m_dragging) { @@ -2636,6 +2647,12 @@ void wxAuiToolBar::OnLeftUp(wxMouseEvent& evt) ReleaseMouse(); GetEventHandler()->ProcessEvent(e); + + // Ensure hovered item is really ok, as mouse may have moved during + // event processing + wxPoint cursor_pos_after_evt = ScreenToClient(wxGetMousePosition()); + SetHoverItem(FindToolByPosition(cursor_pos_after_evt.x, cursor_pos_after_evt.y)); + DoIdleUpdate(); } else @@ -2654,14 +2671,13 @@ void wxAuiToolBar::OnRightDown(wxMouseEvent& evt) return; } - if (m_overflowSizerItem) + if (m_overflowSizerItem && m_art) { int dropdown_size = m_art->GetElementSize(wxAUI_TBART_OVERFLOW_SIZE); if (dropdown_size > 0 && evt.m_x > cli_rect.width - dropdown_size && evt.m_y >= 0 && - evt.m_y < cli_rect.height && - m_art) + evt.m_y < cli_rect.height) { return; } @@ -2721,14 +2737,13 @@ void wxAuiToolBar::OnMiddleDown(wxMouseEvent& evt) return; } - if (m_overflowSizerItem) + if (m_overflowSizerItem && m_art) { int dropdown_size = m_art->GetElementSize(wxAUI_TBART_OVERFLOW_SIZE); if (dropdown_size > 0 && evt.m_x > cli_rect.width - dropdown_size && evt.m_y >= 0 && - evt.m_y < cli_rect.height && - m_art) + evt.m_y < cli_rect.height) { return; } @@ -2810,10 +2825,7 @@ void wxAuiToolBar::OnMotion(wxMouseEvent& evt) } else { - if (hitItem && (hitItem->m_state & wxAUI_BUTTON_STATE_DISABLED)) - SetHoverItem(NULL); - else - SetHoverItem(hitItem); + SetHoverItem(hitItem); // tooltips handling wxAuiToolBarItem* packingHitItem;