X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/9a29fe70bc90b08b4f0bd4c23c1d12ad17cbbed2..7d6a4d96961eac84d05db8bb24c64d39003f6e54:/src/aui/auibar.cpp?ds=sidebyside diff --git a/src/aui/auibar.cpp b/src/aui/auibar.cpp index fab0b5d247..9cb1b9ab0a 100644 --- a/src/aui/auibar.cpp +++ b/src/aui/auibar.cpp @@ -655,14 +655,13 @@ void wxAuiDefaultToolBarArt::DrawGripper(wxDC& dc, } void wxAuiDefaultToolBarArt::DrawOverflowButton(wxDC& dc, - wxWindow* wnd, + wxWindow* /*wnd*/, const wxRect& rect, int state) { if (state & wxAUI_BUTTON_STATE_HOVER || state & wxAUI_BUTTON_STATE_PRESSED) { - wxRect cli_rect = wnd->GetClientRect(); wxColor light_gray_bg = m_highlightColour.ChangeLightness(170); if (m_flags & wxAUI_TB_VERTICAL) @@ -1407,6 +1406,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; @@ -1665,8 +1667,9 @@ wxSize wxAuiToolBar::GetHintSize(int dock_direction) const case wxAUI_DOCK_LEFT: return m_vertHintSize; default: - wxCHECK_MSG(false, wxDefaultSize, "invalid dock location value"); + wxFAIL_MSG("invalid dock location value"); } + return wxDefaultSize; } bool wxAuiToolBar::IsPaneValid(const wxAuiPaneInfo& pane) const @@ -2150,7 +2153,7 @@ void wxAuiToolBar::DoIdleUpdate() { bool is_enabled; if (item.m_window) - is_enabled = item.m_window->IsEnabled(); + is_enabled = item.m_window->IsThisEnabled(); else is_enabled = (item.m_state & wxAUI_BUTTON_STATE_DISABLED) ? false : true; @@ -2338,11 +2341,19 @@ void wxAuiToolBar::OnIdle(wxIdleEvent& evt) } } } - - DoIdleUpdate(); evt.Skip(); } +void wxAuiToolBar::UpdateWindowUI(long flags) +{ + if ( flags & wxUPDATE_UI_FROMIDLE ) + { + DoIdleUpdate(); + } + + wxControl::UpdateWindowUI(flags); +} + void wxAuiToolBar::OnPaint(wxPaintEvent& WXUNUSED(evt)) { wxAutoBufferedPaintDC dc(this); @@ -2572,6 +2583,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(); } } @@ -2583,11 +2599,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) { @@ -2628,6 +2642,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 @@ -2646,14 +2666,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; } @@ -2679,15 +2698,12 @@ void wxAuiToolBar::OnRightUp(wxMouseEvent& evt) if (m_actionItem && hitItem == m_actionItem) { - if (hitItem->m_kind == wxITEM_NORMAL) - { - wxAuiToolBarEvent e(wxEVT_COMMAND_AUITOOLBAR_RIGHT_CLICK, m_actionItem->m_toolId); - e.SetEventObject(this); - e.SetToolId(m_actionItem->m_toolId); - e.SetClickPoint(m_actionPos); - GetEventHandler()->ProcessEvent(e); - DoIdleUpdate(); - } + wxAuiToolBarEvent e(wxEVT_COMMAND_AUITOOLBAR_RIGHT_CLICK, m_actionItem->m_toolId); + e.SetEventObject(this); + e.SetToolId(m_actionItem->m_toolId); + e.SetClickPoint(m_actionPos); + GetEventHandler()->ProcessEvent(e); + DoIdleUpdate(); } else { @@ -2716,14 +2732,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; } @@ -2805,10 +2820,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;