]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/tbarbase.cpp
reverted wxMGL-specific code (didn't mean to commit this...)
[wxWidgets.git] / src / common / tbarbase.cpp
index f66ce0f3b1a52e5fdd67d221565076797934bbc3..91b6a23e2891d1606f67cdf64efcca9df6150481 100644 (file)
     #pragma hdrstop
 #endif
 
+#if wxUSE_TOOLBAR
+
 #ifndef WX_PRECOMP
-    #include "wx/wx.h"
+    #include "wx/control.h"
 #endif
 
 #include "wx/frame.h"
 #include <windows.h>
 #endif
 
-#if wxUSE_TOOLBAR
-
 #include "wx/tbarbase.h"
 
 // ----------------------------------------------------------------------------
 // wxWindows macros
 // ----------------------------------------------------------------------------
 
-#if !USE_SHARED_LIBRARY
-    BEGIN_EVENT_TABLE(wxToolBarBase, wxControl)
-        EVT_IDLE(wxToolBarBase::OnIdle)
-    END_EVENT_TABLE()
-#endif
+IMPLEMENT_CLASS(wxToolBarBase, wxControl)
+
+BEGIN_EVENT_TABLE(wxToolBarBase, wxControl)
+    EVT_IDLE(wxToolBarBase::OnIdle)
+END_EVENT_TABLE()
 
 #include "wx/listimpl.cpp"
 
@@ -319,6 +319,8 @@ wxToolBarToolBase *wxToolBarBase::FindById(int id) const
             // found
             break;
         }
+
+        tool = NULL;
     }
 
     return tool;
@@ -468,7 +470,12 @@ bool wxToolBarBase::OnLeftClick(int id, bool toggleDown)
 {
     wxCommandEvent event(wxEVT_COMMAND_TOOL_CLICKED, id);
     event.SetEventObject(this);
-    event.SetExtraLong((long) toggleDown);
+
+    // we use SetInt() to make wxCommandEvent::IsChecked() return toggleDown
+    event.SetInt((int)toggleDown);
+
+    // and SetExtraLong() for backwards compatibility
+    event.SetExtraLong((long)toggleDown);
 
     // Send events to this toolbar instead (and thence up the window hierarchy)
     GetEventHandler()->ProcessEvent(event);
@@ -526,7 +533,17 @@ void wxToolBarBase::OnIdle(wxIdleEvent& event)
 // Do the toolbar button updates (check for EVT_UPDATE_UI handlers)
 void wxToolBarBase::DoToolbarUpdates()
 {
-    wxEvtHandler* evtHandler = GetEventHandler();
+    wxWindow* parent = this;
+    while (parent->GetParent())
+        parent = parent->GetParent();
+
+#ifdef __WXMSW__
+    wxWindow* focusWin = wxFindFocusDescendant(parent);
+#else
+    wxWindow* focusWin = (wxWindow*) NULL;
+#endif
+
+    wxEvtHandler* evtHandler = focusWin ? focusWin->GetEventHandler() : GetEventHandler() ;
 
     for ( wxToolBarToolsList::Node* node = m_tools.GetFirst();
           node;