+ if( !tbar->OnLeftClick( tool->GetId(), tool->IsToggled() ) && tool->CanBeToggled() )
+ {
+ // revert back
+ tool->Toggle();
+
+ tool->SetImage(tool->GetBitmap());
+ }
+}
+}
+
+//-----------------------------------------------------------------------------
+// "right-click"
+//-----------------------------------------------------------------------------
+extern "C" {
+static gboolean gtk_toolbar_tool_rclick_callback(GtkWidget *WXUNUSED(widget),
+ GdkEventButton *event,
+ wxToolBarToolBase *tool)
+{
+ if (event->button != 3)
+ return FALSE;
+
+ wxToolBar *tbar = (wxToolBar *)tool->GetToolBar();
+
+ if (tbar->m_blockEvent) return TRUE;
+
+ if (g_blockEventsOnDrag) return TRUE;
+ if (!tool->IsEnabled()) return TRUE;
+
+ tbar->OnRightClick( tool->GetId(), (int)event->x, (int)event->y );
+
+ return TRUE;
+}
+}
+
+//-----------------------------------------------------------------------------
+// "enter_notify_event" / "leave_notify_event" from dropdown
+//-----------------------------------------------------------------------------
+
+extern "C" {
+static gint gtk_toolbar_buddy_enter_callback( GtkWidget *WXUNUSED(widget),
+ GdkEventCrossing *WXUNUSED(gdk_event),
+ GtkWidget *tool )
+{
+ guint8 state = GTK_WIDGET_STATE( tool );
+ state |= GTK_STATE_PRELIGHT;
+ gtk_widget_set_state( tool, (GtkStateType) state );
+ return FALSE;
+}
+
+static gint gtk_toolbar_buddy_leave_callback( GtkWidget *WXUNUSED(widget),
+ GdkEventCrossing *WXUNUSED(gdk_event),
+ GtkWidget *tool )
+{
+ guint8 state = GTK_WIDGET_STATE( tool );
+ state &= ~GTK_STATE_PRELIGHT;
+ gtk_widget_set_state( tool, (GtkStateType) state );
+ return FALSE;
+}
+}
+
+//-----------------------------------------------------------------------------
+// "left-click" on dropdown
+//-----------------------------------------------------------------------------
+
+extern "C"
+{
+static void gtk_pop_tb_hide_callback( GtkWidget *WXUNUSED(menu), GtkToggleButton *button )
+{
+ gtk_toggle_button_set_active( button, FALSE );
+}
+
+static gboolean gtk_toolbar_dropdown_lclick_callback(GtkWidget *widget,
+ GdkEventButton *event,
+ wxToolBarToolBase *tool)
+{
+ if (event->button != 1)
+ return FALSE;
+
+ wxToolBar *tbar = (wxToolBar *)tool->GetToolBar();
+
+ if (tbar->m_blockEvent) return FALSE;
+
+ if (g_blockEventsOnDrag) return FALSE;
+ if (!tool->IsEnabled()) return FALSE;
+
+ wxCommandEvent evt(wxEVT_COMMAND_TOOL_DROPDOWN_CLICKED, tool->GetId() );
+ if ( tbar->HandleWindowEvent(evt) )
+ {
+ return TRUE;
+ }
+
+ wxMenu * const menu = tool->GetDropdownMenu();
+ if (!menu)
+ return TRUE;
+
+ // simulate press
+ gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(widget), TRUE );
+
+ g_signal_connect (menu->m_menu, "hide",
+ G_CALLBACK (gtk_pop_tb_hide_callback),
+ widget);
+
+ tbar->PopupMenu( menu, widget->allocation.x,
+ widget->allocation.y + widget->allocation.height );
+
+
+ return TRUE;
+}