]> git.saurik.com Git - wxWidgets.git/blobdiff - src/gtk1/tbargtk.cpp
implemented Alex's <object_ref> symlinks in XRC
[wxWidgets.git] / src / gtk1 / tbargtk.cpp
index 8753cade8d270b4e40e4d13f0bd6a62144e9a79a..81e71e29d11715a06dcb08af1db076255ee12f53 100644 (file)
@@ -99,11 +99,8 @@ static void gtk_toolbar_callback( GtkWidget *WXUNUSED(widget),
         wxapp_install_idle_handler();
 
     wxToolBar *tbar = (wxToolBar *)tool->GetToolBar();
-    if ( tbar->m_blockNextEvent )
-    { 
-        tbar->m_blockNextEvent = FALSE;
-        return;
-    }
+    
+    if (tbar->m_blockEvent) return;
 
     if (g_blockEventsOnDrag) return;
     if (!tool->IsEnabled()) return;
@@ -128,12 +125,12 @@ static void gtk_toolbar_callback( GtkWidget *WXUNUSED(widget),
 }
 
 //-----------------------------------------------------------------------------
-// "enter_notify_event"
+// "enter_notify_event" / "leave_notify_event"
 //-----------------------------------------------------------------------------
 
-static gint gtk_toolbar_enter_callback( GtkWidget *WXUNUSED(widget), 
-                                        GdkEventCrossing *WXUNUSED(gdk_event),
-                                        wxToolBarTool *tool )
+static gint gtk_toolbar_tool_callback( GtkWidget *WXUNUSED(widget), 
+                                       GdkEventCrossing *gdk_event,
+                                       wxToolBarTool *tool )
 {
     if (g_isIdle) wxapp_install_idle_handler();
 
@@ -142,7 +139,10 @@ static gint gtk_toolbar_enter_callback( GtkWidget *WXUNUSED(widget),
     wxToolBar *tb = (wxToolBar *)tool->GetToolBar();
     
     // emit the event
-    tb->OnMouseEnter( tool->GetId() );
+    if( gdk_event->type == GDK_ENTER_NOTIFY )
+        tb->OnMouseEnter( tool->GetId() );
+    else
+        tb->OnMouseEnter( -1 );
   
     return FALSE;
 }
@@ -193,7 +193,7 @@ void wxToolBar::Init()
     m_fg =
     m_bg = (GdkColor *)NULL;
     m_toolbar = (GtkToolbar *)NULL;
-    m_blockNextEvent = FALSE;
+    m_blockEvent = FALSE;
 }
 
 wxToolBar::~wxToolBar()
@@ -349,12 +349,16 @@ bool wxToolBar::DoInsertTool(size_t pos, wxToolBarToolBase *toolBase)
 
             gtk_signal_connect( GTK_OBJECT(tool->m_item),
                                 "enter_notify_event", 
-                                GTK_SIGNAL_FUNC(gtk_toolbar_enter_callback),
+                                GTK_SIGNAL_FUNC(gtk_toolbar_tool_callback),
+                                (gpointer)tool );
+            gtk_signal_connect( GTK_OBJECT(tool->m_item),
+                                "leave_notify_event", 
+                                GTK_SIGNAL_FUNC(gtk_toolbar_tool_callback),
                                 (gpointer)tool );
             break;
 
         case wxTOOL_STYLE_SEPARATOR:
-            gtk_toolbar_append_space( m_toolbar );
+            gtk_toolbar_insert_space( m_toolbar, pos );
 
             // skip the rest
             return TRUE;
@@ -433,9 +437,11 @@ void wxToolBar::DoToggleTool( wxToolBarToolBase *toolBase, bool toggle )
             gtk_pixmap_set( pixmap, bitmap.GetPixmap(), mask );
         }
 
-        m_blockNextEvent = TRUE;  // we cannot use gtk_signal_disconnect here
+        m_blockEvent = TRUE;
 
         gtk_toggle_button_set_state( GTK_TOGGLE_BUTTON(item), toggle );
+        
+        m_blockEvent = FALSE;
     }
 }