+ wxToolBarTool* tool = wx_static_cast(wxToolBarTool*, toolBase);
+
+ if ( tool->IsButton() )
+ {
+ if ( !HasFlag(wxTB_NOICONS) )
+ {
+ wxBitmap bitmap = tool->GetNormalBitmap();
+
+ wxCHECK_MSG( bitmap.Ok(), false,
+ wxT("invalid bitmap for wxToolBar icon") );
+
+ tool->m_image = gtk_image_new();
+ tool->SetImage(bitmap);
+
+ gtk_misc_set_alignment((GtkMisc*)tool->m_image, 0.5, 0.5);
+ }
+ }
+
+ const int posGtk = int(pos);
+
+ switch ( tool->GetStyle() )
+ {
+ case wxTOOL_STYLE_BUTTON:
+ // for a radio button we need the widget which starts the radio
+ // group it belongs to, i.e. the first radio button immediately
+ // preceding this one
+ {
+ GtkWidget *widget = NULL;
+
+ if ( tool->IsRadio() )
+ {
+ wxToolBarToolsList::compatibility_iterator node
+ = wxToolBarToolsList::compatibility_iterator();
+ if ( pos )
+ node = m_tools.Item(pos - 1);
+
+ while ( node )
+ {
+ wxToolBarTool *toolNext = (wxToolBarTool *)node->GetData();
+ if ( !toolNext->IsRadio() )
+ break;
+
+ widget = toolNext->m_item;
+
+ node = node->GetPrevious();
+ }
+
+ if ( !widget )
+ {
+ // this is the first button in the radio button group,
+ // it will be toggled automatically by GTK so bring the
+ // internal flag in sync
+ tool->Toggle(true);
+ }
+ }
+
+ tool->m_item = gtk_toolbar_insert_element
+ (
+ m_toolbar,
+ tool->GetGtkChildType(),
+ widget,
+ tool->GetLabel().empty()
+ ? NULL
+ : (const char*) wxGTK_CONV( tool->GetLabel() ),
+ tool->GetShortHelp().empty()
+ ? NULL
+ : (const char*) wxGTK_CONV( tool->GetShortHelp() ),
+ "", // tooltip_private_text (?)
+ tool->m_image,
+ (GtkSignalFunc)gtk_toolbar_callback,
+ (gpointer)tool,
+ posGtk
+ );
+
+ wxCHECK_MSG(tool->m_item != NULL, false, _T("gtk_toolbar_insert_element() failed"));
+
+ g_signal_connect (tool->m_item, "enter_notify_event",
+ G_CALLBACK (gtk_toolbar_tool_callback),
+ tool);
+ g_signal_connect (tool->m_item, "leave_notify_event",
+ G_CALLBACK (gtk_toolbar_tool_callback),
+ tool);
+ }
+ break;
+
+ case wxTOOL_STYLE_SEPARATOR:
+ gtk_toolbar_insert_space( m_toolbar, posGtk );
+
+ // skip the rest
+ return true;
+
+ case wxTOOL_STYLE_CONTROL:
+ gtk_toolbar_insert_widget(
+ m_toolbar,
+ tool->GetControl()->m_widget,
+ (const char *) NULL,
+ (const char *) NULL,
+ posGtk
+ );
+
+ // connect after in order to correct size_allocate events
+ g_signal_connect_after (tool->GetControl()->m_widget, "size_allocate",
+ G_CALLBACK (gtktoolwidget_size_callback), tool->GetControl());
+
+ break;
+ }
+
+ GtkRequisition req;
+ (* GTK_WIDGET_CLASS( GTK_OBJECT_GET_CLASS(m_widget) )->size_request )
+ (m_widget, &req );
+ m_width = req.width + m_xMargin;
+ m_height = req.height + 2*m_yMargin;
+ InvalidateBestSize();
+
+ return true;