static void GetGtkStyle(long style,
GtkOrientation *orient, GtkToolbarStyle *gtkStyle)
{
- *orient = style & wxTB_VERTICAL ? GTK_ORIENTATION_VERTICAL
- : GTK_ORIENTATION_HORIZONTAL;
+ *orient = ( style & wxTB_LEFT || style & wxTB_RIGHT ) ? GTK_ORIENTATION_VERTICAL : GTK_ORIENTATION_HORIZONTAL;
if ( style & wxTB_TEXT )
}
}
+extern "C" {
+static
+void gtktoolwidget_size_callback( GtkWidget *widget,
+ GtkAllocation *alloc,
+ wxWindow *win )
+{
+ // this shouldn't happen...
+ if (win->GetParent()->m_wxwindow) return;
+
+ wxSize size = win->GetEffectiveMinSize();
+ if (size.y != alloc->height)
+ {
+ GtkAllocation alloc2;
+ alloc2.x = alloc->x;
+ alloc2.y = (alloc->height - size.y + 3) / 2;
+ alloc2.width = alloc->width;
+ alloc2.height = size.y;
+ gtk_widget_size_allocate( widget, &alloc2 );
+ }
+}
+}
//-----------------------------------------------------------------------------
// InsertChild callback for wxToolBar
//-----------------------------------------------------------------------------
return false;
}
+ FixupStyle();
+
m_toolbar = GTK_TOOLBAR( gtk_toolbar_new() );
GtkSetStyle();
gtk_toolbar_set_orientation(m_toolbar, orient);
gtk_toolbar_set_style(m_toolbar, style);
- gtk_toolbar_set_tooltips( GTK_TOOLBAR(m_toolbar), !(style & wxTB_NO_TOOLTIPS) );
+ gtk_toolbar_set_tooltips(m_toolbar, !(style & wxTB_NO_TOOLTIPS));
}
void wxToolBar::SetWindowStyleFlag( long style )
bool wxToolBar::DoInsertTool(size_t pos, wxToolBarToolBase *toolBase)
{
- wxToolBarTool *tool = (wxToolBarTool *)toolBase;
-
- size_t posGtk = pos;
+ wxToolBarTool* tool = wx_static_cast(wxToolBarTool*, toolBase);
if ( tool->IsButton() )
{
wxCHECK_MSG( bitmap.Ok(), false,
wxT("invalid bitmap for wxToolBar icon") );
- wxCHECK_MSG( bitmap.GetDepth() != 1, false,
- wxT("wxToolBar doesn't support GdkBitmap") );
-
- wxCHECK_MSG( bitmap.GetPixmap() != NULL, false,
- wxT("wxToolBar::Add needs a wxBitmap") );
-
tool->m_image = gtk_image_new();
tool->SetImage(bitmap);
}
}
+ const int posGtk = int(pos);
+
switch ( tool->GetStyle() )
{
case wxTOOL_STYLE_BUTTON:
(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;
}
bool wxToolBar::DoDeleteTool(size_t pos, wxToolBarToolBase *toolBase)
{
- wxToolBarTool *tool = (wxToolBarTool *)toolBase;
+ wxToolBarTool* tool = wx_static_cast(wxToolBarTool*, toolBase);
switch ( tool->GetStyle() )
{
void wxToolBar::DoEnableTool(wxToolBarToolBase *toolBase, bool enable)
{
- wxToolBarTool *tool = (wxToolBarTool *)toolBase;
+ wxToolBarTool* tool = wx_static_cast(wxToolBarTool*, toolBase);
if (tool->m_item)
{
void wxToolBar::DoToggleTool( wxToolBarToolBase *toolBase, bool toggle )
{
- wxToolBarTool *tool = (wxToolBarTool *)toolBase;
+ wxToolBarTool* tool = wx_static_cast(wxToolBarTool*, toolBase);
GtkWidget *item = tool->m_item;
if ( item && GTK_IS_TOGGLE_BUTTON(item) )
void wxToolBar::SetToolShortHelp( int id, const wxString& helpString )
{
- wxToolBarTool *tool = (wxToolBarTool *)FindById(id);
+ wxToolBarTool* tool = wx_static_cast(wxToolBarTool*, FindById(id));
if ( tool )
{
}
}
+void wxToolBar::SetToolNormalBitmap( int id, const wxBitmap& bitmap )
+{
+ wxToolBarTool* tool = wx_static_cast(wxToolBarTool*, FindById(id));
+ if ( tool )
+ {
+ wxCHECK_RET( tool->IsButton(), wxT("Can only set bitmap on button tools."));
+
+ tool->SetNormalBitmap(bitmap);
+ tool->SetImage(tool->GetBitmap());
+ }
+}
+
+void wxToolBar::SetToolDisabledBitmap( int id, const wxBitmap& bitmap )
+{
+ wxToolBarTool* tool = wx_static_cast(wxToolBarTool*, FindById(id));
+ if ( tool )
+ {
+ wxCHECK_RET( tool->IsButton(), wxT("Can only set bitmap on button tools."));
+
+ tool->SetDisabledBitmap(bitmap);
+ tool->SetImage(tool->GetBitmap());
+ }
+}
+
// ----------------------------------------------------------------------------
// wxToolBar idle handling
// ----------------------------------------------------------------------------