X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/903f689bf7c3c379cba45881373aa9bdd15d6e70..9c039d08bfbb59c0abcbc705fb49f9b2cb321edf:/src/gtk1/tbargtk.cpp diff --git a/src/gtk1/tbargtk.cpp b/src/gtk1/tbargtk.cpp index 1b45b695c4..57bd59292e 100644 --- a/src/gtk1/tbargtk.cpp +++ b/src/gtk1/tbargtk.cpp @@ -16,6 +16,12 @@ #include "wx/toolbar.h" #include +//----------------------------------------------------------------------------- +// data +//----------------------------------------------------------------------------- + +extern bool g_blockEventsOnDrag; + //----------------------------------------------------------------------------- // wxToolBarTool //----------------------------------------------------------------------------- @@ -48,11 +54,12 @@ wxToolBarTool::~wxToolBarTool() } //----------------------------------------------------------------------------- -// wxToolBar +// "clicked" (internal from gtk_toolbar) //----------------------------------------------------------------------------- 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,12 +67,25 @@ static void gtk_toolbar_callback( GtkWidget *WXUNUSED(widget), wxToolBarTool *to tool->m_owner->OnLeftClick( tool->m_index, tool->m_toggleState ); } +//----------------------------------------------------------------------------- +// "enter_notify_event" //----------------------------------------------------------------------------- -IMPLEMENT_DYNAMIC_CLASS(wxToolBar,wxControl) +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 FALSE; +} + +//----------------------------------------------------------------------------- +// wxToolBar +//----------------------------------------------------------------------------- -BEGIN_EVENT_TABLE(wxToolBar, wxControl) -END_EVENT_TABLE() +IMPLEMENT_DYNAMIC_CLASS(wxToolBar,wxControl) wxToolBar::wxToolBar() { @@ -130,10 +150,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); } @@ -142,12 +162,12 @@ wxToolBarTool *wxToolBar::AddTool( int toolIndex, const wxBitmap& bitmap, float WXUNUSED(xPos), float WXUNUSED(yPos), wxObject *clientData, const wxString& helpString1, const wxString& helpString2 ) { - if (!bitmap.Ok()) return NULL; + if (!bitmap.Ok()) return (wxToolBarTool *) NULL; wxToolBarTool *tool = new wxToolBarTool( this, toolIndex, bitmap, pushedBitmap, toggle, clientData, helpString1, helpString2 ); - GtkWidget *tool_pixmap = NULL; + GtkWidget *tool_pixmap = (GtkWidget *) NULL; wxCHECK_MSG( bitmap.GetBitmap() == NULL, (wxToolBarTool *)NULL, "wxToolBar doesn't support GdkBitmap" ) @@ -157,7 +177,7 @@ wxToolBarTool *wxToolBar::AddTool( int toolIndex, const wxBitmap& bitmap, { GdkPixmap *pixmap = bitmap.GetPixmap(); - GdkBitmap *mask = NULL; + GdkBitmap *mask = (GdkBitmap *) NULL; if (bitmap.GetMask()) mask = bitmap.GetMask()->GetBitmap(); tool_pixmap = gtk_pixmap_new( pixmap, mask ); @@ -168,8 +188,12 @@ wxToolBarTool *wxToolBar::AddTool( int toolIndex, const wxBitmap& bitmap, GtkToolbarChildType ctype = GTK_TOOLBAR_CHILD_BUTTON; if (toggle) ctype = GTK_TOOLBAR_CHILD_TOGGLEBUTTON; - tool->m_item = gtk_toolbar_append_element( m_toolbar, ctype, NULL, NULL, helpString1, "", tool_pixmap, - (GtkSignalFunc)gtk_toolbar_callback, (gpointer)tool ); + tool->m_item = gtk_toolbar_append_element( + m_toolbar, ctype, (GtkWidget *) NULL, (const char *) 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 );