]> git.saurik.com Git - wxWidgets.git/commitdiff
Added TOOL_ENTER command. Now wxGTK and wxMSW misbehave
authorRobert Roebling <robert@roebling.de>
Tue, 18 Aug 1998 17:41:55 +0000 (17:41 +0000)
committerRobert Roebling <robert@roebling.de>
Tue, 18 Aug 1998 17:41:55 +0000 (17:41 +0000)
  equally on that matter.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@593 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/gtk/tbargtk.cpp
src/gtk1/tbargtk.cpp

index 1b45b695c427fa08608fe105d80df1fdf9710b03..a35bbe7235ae0fd33dcef9ddc6eb496044ffdb4c 100644 (file)
 #include "wx/toolbar.h"
 #include <wx/intl.h>
 
+//-----------------------------------------------------------------------------
+// data
+//-----------------------------------------------------------------------------
+
+extern bool   g_blockEventsOnDrag;
+
 //-----------------------------------------------------------------------------
 // wxToolBarTool
 //-----------------------------------------------------------------------------
@@ -53,6 +59,7 @@ wxToolBarTool::~wxToolBarTool()
 
 static void gtk_toolbar_callback( GtkWidget *WXUNUSED(widget), wxToolBarTool *tool )
 {
+  if (g_blockEventsOnDrag) return;
   if (!tool->m_enabled) return;
 
   if (tool->m_isToggle) tool->m_toggleState = !tool->m_toggleState;
@@ -60,6 +67,16 @@ static void gtk_toolbar_callback( GtkWidget *WXUNUSED(widget), wxToolBarTool *to
   tool->m_owner->OnLeftClick( tool->m_index, tool->m_toggleState );
 }
 
+static gint gtk_toolbar_enter_callback( GtkWidget *WXUNUSED(widget), 
+  GdkEventCrossing *WXUNUSED(gdk_event), wxToolBarTool *tool )
+{
+  if (g_blockEventsOnDrag) return TRUE;
+  
+  tool->m_owner->OnMouseEnter( tool->m_index );
+  
+  return TRUE;
+}
+
 //-----------------------------------------------------------------------------
 
 IMPLEMENT_DYNAMIC_CLASS(wxToolBar,wxControl)
@@ -130,10 +147,10 @@ void wxToolBar::OnRightClick( int toolIndex, float WXUNUSED(x), float WXUNUSED(y
 
 void wxToolBar::OnMouseEnter( int toolIndex )
 {
-  wxCommandEvent event( wxEVT_COMMAND_TOOL_ENTER, toolIndex );
+  wxCommandEvent event( wxEVT_COMMAND_TOOL_ENTER, GetId() );
   event.SetEventObject(this);
   event.SetInt( toolIndex );
-
+  
   GetEventHandler()->ProcessEvent(event);
 }
 
@@ -171,6 +188,9 @@ wxToolBarTool *wxToolBar::AddTool( int toolIndex, const wxBitmap& bitmap,
   tool->m_item = gtk_toolbar_append_element( m_toolbar, ctype, NULL, NULL, helpString1, "", tool_pixmap, 
                                              (GtkSignalFunc)gtk_toolbar_callback, (gpointer)tool );
 
+  gtk_signal_connect( GTK_OBJECT(tool->m_item), "enter_notify_event", 
+      GTK_SIGNAL_FUNC(gtk_toolbar_enter_callback), (gpointer)tool );
+
   m_tools.Append( tool );
 
   return tool;
index 1b45b695c427fa08608fe105d80df1fdf9710b03..a35bbe7235ae0fd33dcef9ddc6eb496044ffdb4c 100644 (file)
 #include "wx/toolbar.h"
 #include <wx/intl.h>
 
+//-----------------------------------------------------------------------------
+// data
+//-----------------------------------------------------------------------------
+
+extern bool   g_blockEventsOnDrag;
+
 //-----------------------------------------------------------------------------
 // wxToolBarTool
 //-----------------------------------------------------------------------------
@@ -53,6 +59,7 @@ wxToolBarTool::~wxToolBarTool()
 
 static void gtk_toolbar_callback( GtkWidget *WXUNUSED(widget), wxToolBarTool *tool )
 {
+  if (g_blockEventsOnDrag) return;
   if (!tool->m_enabled) return;
 
   if (tool->m_isToggle) tool->m_toggleState = !tool->m_toggleState;
@@ -60,6 +67,16 @@ static void gtk_toolbar_callback( GtkWidget *WXUNUSED(widget), wxToolBarTool *to
   tool->m_owner->OnLeftClick( tool->m_index, tool->m_toggleState );
 }
 
+static gint gtk_toolbar_enter_callback( GtkWidget *WXUNUSED(widget), 
+  GdkEventCrossing *WXUNUSED(gdk_event), wxToolBarTool *tool )
+{
+  if (g_blockEventsOnDrag) return TRUE;
+  
+  tool->m_owner->OnMouseEnter( tool->m_index );
+  
+  return TRUE;
+}
+
 //-----------------------------------------------------------------------------
 
 IMPLEMENT_DYNAMIC_CLASS(wxToolBar,wxControl)
@@ -130,10 +147,10 @@ void wxToolBar::OnRightClick( int toolIndex, float WXUNUSED(x), float WXUNUSED(y
 
 void wxToolBar::OnMouseEnter( int toolIndex )
 {
-  wxCommandEvent event( wxEVT_COMMAND_TOOL_ENTER, toolIndex );
+  wxCommandEvent event( wxEVT_COMMAND_TOOL_ENTER, GetId() );
   event.SetEventObject(this);
   event.SetInt( toolIndex );
-
+  
   GetEventHandler()->ProcessEvent(event);
 }
 
@@ -171,6 +188,9 @@ wxToolBarTool *wxToolBar::AddTool( int toolIndex, const wxBitmap& bitmap,
   tool->m_item = gtk_toolbar_append_element( m_toolbar, ctype, NULL, NULL, helpString1, "", tool_pixmap, 
                                              (GtkSignalFunc)gtk_toolbar_callback, (gpointer)tool );
 
+  gtk_signal_connect( GTK_OBJECT(tool->m_item), "enter_notify_event", 
+      GTK_SIGNAL_FUNC(gtk_toolbar_enter_callback), (gpointer)tool );
+
   m_tools.Append( tool );
 
   return tool;