]> git.saurik.com Git - wxWidgets.git/blobdiff - src/gtk/tbargtk.cpp
removed stray return from SetFont()
[wxWidgets.git] / src / gtk / tbargtk.cpp
index b6180cd225bb63b82daffd27e921ce85353d384e..f1e0bcc9ad4467c6ebfd72b4e2c35049c2603579 100644 (file)
@@ -52,8 +52,7 @@ extern wxCursor   g_globalCursor;
 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 )
@@ -216,6 +215,27 @@ static gint gtk_toolbar_tool_callback( GtkWidget *WXUNUSED(widget),
 }
 }
 
+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
 //-----------------------------------------------------------------------------
@@ -288,6 +308,8 @@ bool wxToolBar::Create( wxWindow *parent,
         return false;
     }
 
+    FixupStyle();
+
     m_toolbar = GTK_TOOLBAR( gtk_toolbar_new() );
     GtkSetStyle();
 
@@ -452,6 +474,11 @@ bool wxToolBar::DoInsertTool(size_t pos, wxToolBarToolBase *toolBase)
                                        (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;
     }
 
@@ -570,6 +597,30 @@ void wxToolBar::SetToolShortHelp( int id, const wxString& helpString )
     }
 }
 
+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
 // ----------------------------------------------------------------------------