X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/dd91da4ed1e9d2ba5d3bc2fae64a8e4ea86b5d41..a03c55c13c674ea6f8489b764d5414a4979b348b:/src/common/tbarbase.cpp diff --git a/src/common/tbarbase.cpp b/src/common/tbarbase.cpp index 16589483c6..9b03daccee 100644 --- a/src/common/tbarbase.cpp +++ b/src/common/tbarbase.cpp @@ -5,8 +5,8 @@ // Modified by: VZ at 11.12.99 (wxScrollableToolBar splitted off) // Created: 04/01/98 // RCS-ID: $Id$ -// Copyright: (c) Julian Smart and Markus Holzem -// Licence: wxWindows license +// Copyright: (c) Julian Smart +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// // ============================================================================ @@ -47,7 +47,6 @@ IMPLEMENT_CLASS(wxToolBarBase, wxControl) BEGIN_EVENT_TABLE(wxToolBarBase, wxControl) - EVT_IDLE(wxToolBarBase::OnIdle) END_EVENT_TABLE() #include "wx/listimpl.cpp" @@ -229,12 +228,20 @@ wxControl *wxToolBarBase::FindControl( int id ) node; node = node->GetNext() ) { - wxControl *control = node->GetData()->GetControl(); - - if (control) + const wxToolBarToolBase * const tool = node->GetData(); + if ( tool->IsControl() ) { - if (control->GetId() == id) + wxControl * const control = tool->GetControl(); + + if ( !control ) + { + wxFAIL_MSG( _T("NULL control in toolbar?") ); + } + else if ( control->GetId() == id ) + { + // found return control; + } } } @@ -450,6 +457,22 @@ void wxToolBarBase::SetToolClientData(int id, wxObject *clientData) tool->SetClientData(clientData); } +int wxToolBarBase::GetToolPos(int id) const +{ + size_t pos = 0; + wxToolBarToolsList::Node *node; + + for ( node = m_tools.GetFirst(); node; node = node->GetNext() ) + { + if ( node->GetData()->GetId() == id ) + return pos; + + pos++; + } + + return wxNOT_FOUND; +} + bool wxToolBarBase::GetToolState(int id) const { wxToolBarToolBase *tool = FindById(id); @@ -557,31 +580,12 @@ void wxToolBarBase::OnMouseEnter(int id) // UI updates // ---------------------------------------------------------------------------- -void wxToolBarBase::OnIdle(wxIdleEvent& event) +// Do the toolbar button updates (check for EVT_UPDATE_UI handlers) +void wxToolBarBase::UpdateWindowUI(long flags) { - DoToolbarUpdates(); + wxWindowBase::UpdateWindowUI(flags); - event.Skip(); -} - -// Do the toolbar button updates (check for EVT_UPDATE_UI handlers) -void wxToolBarBase::DoToolbarUpdates() -{ - wxWindow* parent = this; - while (parent->GetParent()) - parent = parent->GetParent(); - -// This kind of #ifdef is a good way to annoy people. It breaks -// apps, but only on one platform and due to a hack in officially -// platform independent code. It took me hours to fix this. RR. -// -// #ifdef __WXMSW__ -// wxWindow* focusWin = wxFindFocusDescendant(parent); -// #else - wxWindow* focusWin = (wxWindow*) NULL; -// #endif - - wxEvtHandler* evtHandler = focusWin ? focusWin->GetEventHandler() : GetEventHandler() ; + wxEvtHandler* evtHandler = GetEventHandler() ; for ( wxToolBarToolsList::Node* node = m_tools.GetFirst(); node;