]> git.saurik.com Git - wxWidgets.git/blobdiff - src/gtk/tbargtk.cpp
Make sure mouse events are only sent in the case of the native control.
[wxWidgets.git] / src / gtk / tbargtk.cpp
index f73ea91ec8543287437a0ab8ab30ce05370530cf..3ce3d74f7d16d2352051678fc8c4cbd08686d87d 100644 (file)
@@ -215,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
 //-----------------------------------------------------------------------------
@@ -287,6 +308,8 @@ bool wxToolBar::Create( wxWindow *parent,
         return false;
     }
 
+    FixupStyle();
+
     m_toolbar = GTK_TOOLBAR( gtk_toolbar_new() );
     GtkSetStyle();
 
@@ -451,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;
     }
 
@@ -632,8 +660,4 @@ wxToolBar::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant))
     return GetDefaultAttributesFromGTKWidget(gtk_toolbar_new);
 }
 
-bool wxToolBar::IsVertical()
-{
-    return HasFlag(wxTB_LEFT) || HasFlag(wxTB_RIGHT);
-}
 #endif // wxUSE_TOOLBAR_NATIVE