]> git.saurik.com Git - wxWidgets.git/blobdiff - src/gtk/win_gtk.cpp
fixing setting initial value under osx_cocoa for single line text controls
[wxWidgets.git] / src / gtk / win_gtk.cpp
index 9e5a1e6ffdb183b66a9d37d5105ec1d1f97d651e..729463a3adb2cf225be0feeb80d8dd30dfc7adb5 100644 (file)
@@ -47,8 +47,6 @@ static void size_allocate(GtkWidget* widget, GtkAllocation* alloc)
         widget->allocation.x != alloc->x ||
         widget->allocation.y != alloc->y;
 
-    widget->allocation = *alloc;
-
     wxPizza* pizza = WX_PIZZA(widget);
     int border_x, border_y;
     pizza->get_border_widths(border_x, border_y);
@@ -73,22 +71,31 @@ static void size_allocate(GtkWidget* widget, GtkAllocation* alloc)
             // one window
             gdk_window_move_resize(widget->window,
                 alloc->x + border_x, alloc->y + border_y, w, h);
-                
-            if ((border_x > 0) || (border_y > 0))
+
+            if (is_resize && (border_x || border_y))
             {
-                // Otherwise we get can redraw artefacts from
-                // the border.
-                GtkWidget *parent = gtk_widget_get_parent( widget );
-                gtk_widget_queue_draw( parent );
+                // old and new border areas need to be invalidated,
+                // otherwise they will not be erased/redrawn properly
+                const GtkAllocation& a1 = widget->allocation;
+                const GtkAllocation& a2 = *alloc;
+                GdkRectangle r1 = { a1.x, a1.y, a1.width, a1.height };
+                GdkRectangle r2 = { a2.x, a2.y, a2.width, a2.height };
+                gdk_window_invalidate_rect(widget->parent->window, &r1, false);
+                gdk_window_invalidate_rect(widget->parent->window, &r2, false);
             }
         }
     }
+
+    widget->allocation = *alloc;
+
     // adjust child positions
     for (const GList* list = pizza->m_fixed.children; list; list = list->next)
     {
         const GtkFixedChild* child = static_cast<GtkFixedChild*>(list->data);
         if (GTK_WIDGET_VISIBLE(child->widget))
         {
+            GtkAllocation child_old_alloc = child->widget->allocation;
+
             GtkAllocation child_alloc;
             // note that child positions do not take border into
             // account, they need to be relative to widget->window,
@@ -100,9 +107,7 @@ static void size_allocate(GtkWidget* widget, GtkAllocation* alloc)
             child_alloc.width  = req.width;
             child_alloc.height = req.height;
             if (gtk_widget_get_direction(widget) == GTK_TEXT_DIR_RTL)
-            {
                 child_alloc.x = w - child_alloc.x - child_alloc.width;
-            }
             gtk_widget_size_allocate(child->widget, &child_alloc);
         }
     }
@@ -277,10 +282,11 @@ GType wxPizza::type()
     return type;
 }
 
-GtkWidget* wxPizza::New(long windowStyle)
+GtkWidget* wxPizza::New(long windowStyle,void* owner)
 {
     GtkWidget* widget = GTK_WIDGET(g_object_new(type(), NULL));
     wxPizza* pizza = WX_PIZZA(widget);
+    pizza->m_owner = owner;
     pizza->m_backing_window = NULL;
     pizza->m_scroll_x = 0;
     pizza->m_scroll_y = 0;
@@ -334,10 +340,11 @@ extern "C" {
 static void scroll_adjust(GtkWidget* widget, void* data)
 {
     const AdjustData* p = static_cast<AdjustData*>(data);
+    widget->allocation.x += p->dx;
+    widget->allocation.y += p->dy;
+
     if (widget->window == p->window)
     {
-        widget->allocation.x += p->dx;
-        widget->allocation.y += p->dy;
         // GtkFrame requires a queue_resize, otherwise parts of
         // the frame newly exposed by the scroll are not drawn.
         // To be safe, do it for all widgets.
@@ -368,16 +375,30 @@ void wxPizza::scroll(int dx, int dy)
 void wxPizza::get_border_widths(int& x, int& y)
 {
     x = y = 0;
+    if (m_border_style == 0)
+        return;
+
 #ifndef __WXUNIVERSAL__
     if (m_border_style & wxBORDER_SIMPLE)
         x = y = 1;
-    else if (m_border_style)
+    else if (m_is_scrollable /* || (m_border_style & wxBORDER_THEME) */)
+    {
+        GtkWidget *style_widget = wxGTKPrivate::GetTreeWidget();
+
+        if (style_widget->style)
+        {
+            x = style_widget->style->xthickness;
+            y = style_widget->style->ythickness;
+        }
+    }
+    else
     {
-        GtkWidget *entry_widget = wxGTKPrivate::GetEntryWidget();
-        if (entry_widget->style)
+        GtkWidget *style_widget = wxGTKPrivate::GetEntryWidget();
+
+        if (style_widget->style)
         {
-            x = entry_widget->style->xthickness;
-            y = entry_widget->style->ythickness;
+            x = style_widget->style->xthickness;
+            y = style_widget->style->ythickness;
         }
     }
 #endif