+ const wxBitmap& bitmap = GetNormalBitmap();
+ wxCHECK_RET(bitmap.IsOk(), "invalid bitmap for wxToolBar icon");
+
+ GtkWidget* image = gtk_tool_button_get_icon_widget(GTK_TOOL_BUTTON(m_item));
+ // always use pixbuf, because pixmap mask does not
+ // work with disabled images in some themes
+ gtk_image_set_from_pixbuf(GTK_IMAGE(image), bitmap.GetPixbuf());
+}
+
+// helper to create a dropdown menu item
+void wxToolBarTool::CreateDropDown()
+{
+ gtk_tool_item_set_homogeneous(m_item, false);
+ GtkWidget* box;
+ GtkWidget* arrow;
+ if (GetToolBar()->HasFlag(wxTB_LEFT | wxTB_RIGHT))
+ {
+ box = gtk_vbox_new(false, 0);
+ arrow = gtk_arrow_new(GTK_ARROW_RIGHT, GTK_SHADOW_NONE);
+ }
+ else
+ {
+ box = gtk_hbox_new(false, 0);
+ arrow = gtk_arrow_new(GTK_ARROW_DOWN, GTK_SHADOW_NONE);
+ }
+ GtkWidget* tool_button = GTK_BIN(m_item)->child;
+ gtk_widget_reparent(tool_button, box);
+ GtkWidget* arrow_button = gtk_toggle_button_new();
+ gtk_button_set_relief(GTK_BUTTON(arrow_button),
+ gtk_tool_item_get_relief_style(GTK_TOOL_ITEM(m_item)));
+ gtk_container_add(GTK_CONTAINER(arrow_button), arrow);
+ gtk_container_add(GTK_CONTAINER(box), arrow_button);
+ gtk_widget_show_all(box);
+ gtk_container_add(GTK_CONTAINER(m_item), box);
+
+ g_signal_connect(arrow_button, "toggled", G_CALLBACK(arrow_toggled), this);
+ g_signal_connect(arrow_button, "button_press_event",
+ G_CALLBACK(arrow_button_press_event), this);
+}
+
+void wxToolBarTool::ShowDropdown(GtkToggleButton* button)
+{
+ wxToolBarBase* toolbar = GetToolBar();
+ wxCommandEvent event(wxEVT_COMMAND_TOOL_DROPDOWN_CLICKED, GetId());
+ if (!toolbar->HandleWindowEvent(event))
+ {
+ wxMenu* menu = GetDropdownMenu();
+ if (menu)
+ {
+ const GtkAllocation& alloc = GTK_WIDGET(button)->allocation;
+ int x = alloc.x;
+ int y = alloc.y;
+ if (toolbar->HasFlag(wxTB_LEFT | wxTB_RIGHT))
+ x += alloc.width;
+ else
+ y += alloc.height;
+ toolbar->PopupMenu(menu, x, y);
+ }
+ }