X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e76c0b5fc59b06273ebbe9c1d9b2646befd0acd0..f6f5941be5f080ca42cb5fed4b672f5db16c0d8e:/src/common/tbarbase.cpp diff --git a/src/common/tbarbase.cpp b/src/common/tbarbase.cpp index eb371ebc84..5f4b02fa90 100644 --- a/src/common/tbarbase.cpp +++ b/src/common/tbarbase.cpp @@ -206,6 +206,24 @@ wxToolBarToolBase *wxToolBarBase::InsertControl(size_t pos, wxControl *control) return tool; } +wxControl *wxToolBarBase::FindControl( int id ) +{ + for ( wxToolBarToolsList::Node* node = m_tools.GetFirst(); + node; + node = node->GetNext() ) + { + wxControl *control = node->GetData()->GetControl(); + + if (control) + { + if (control->GetId() == id) + return control; + } + } + + return NULL; +} + wxToolBarToolBase *wxToolBarBase::AddSeparator() { return InsertSeparator(GetToolsCount()); @@ -507,25 +525,15 @@ void wxToolBarBase::OnMouseEnter(int id) event.SetEventObject(this); event.SetInt(id); - (void)GetEventHandler()->ProcessEvent(event); - wxFrame *frame = wxDynamicCast(GetParent(), wxFrame); - if ( !frame ) - return; - - wxString helpstring; - - if ( id != -1 ) + if( frame ) { - wxToolBarToolBase *tool = FindById(id); - if ( tool ) - helpstring = tool->GetLongHelp(); + wxToolBarToolBase* tool = id == -1 ? (wxToolBarToolBase*)0 : FindById(id); + wxString help = tool ? tool->GetLongHelp() : wxString(); + frame->DoGiveHelp( help, id != -1 ); } - // set the status text anyhow, even if the string is empty: this ensures - // that it is cleared when the mouse leaves the toolbar or enters a tool - // without help - frame->SetStatusText(helpstring); + (void)GetEventHandler()->ProcessEvent(event); } // ---------------------------------------------------------------------------- @@ -546,11 +554,15 @@ void wxToolBarBase::DoToolbarUpdates() while (parent->GetParent()) parent = parent->GetParent(); -#ifdef __WXMSW__ - wxWindow* focusWin = wxFindFocusDescendant(parent); -#else +// 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 +// #endif wxEvtHandler* evtHandler = focusWin ? focusWin->GetEventHandler() : GetEventHandler() ;