]> git.saurik.com Git - wxWidgets.git/blobdiff - src/gtk1/win_gtk.c
unused parameter warnings suppressed
[wxWidgets.git] / src / gtk1 / win_gtk.c
index c199d05b9b188cb67ad10ef60193262de91cba5e..d7f721c56b66d89ec0844f63fde2ce1d3ad57d9b 100644 (file)
@@ -9,6 +9,7 @@
 
 #include "wx/gtk/win_gtk.h"
 #include "gtk/gtksignal.h"
+#include "gtk/gtknotebook.h"
 
 #ifdef __cplusplus
 extern "C" {
@@ -201,9 +202,11 @@ gtk_myfixed_set_shadow_type (GtkMyFixed   *myfixed,
 
 void
 gtk_myfixed_put (GtkMyFixed   *myfixed,
-               GtkWidget      *widget,
-               gint16         x,
-               gint16         y)
+                 GtkWidget      *widget,
+                 gint16         x,
+                 gint16         y,
+                gint16         width,
+                gint16         height)
 {
   GtkMyFixedChild *child_info;
 
@@ -215,6 +218,8 @@ gtk_myfixed_put (GtkMyFixed   *myfixed,
   child_info->widget = widget;
   child_info->x = x;
   child_info->y = y;
+  child_info->width = width;
+  child_info->height = height;
   
   gtk_widget_set_parent (widget, GTK_WIDGET (myfixed));
 
@@ -231,10 +236,10 @@ gtk_myfixed_put (GtkMyFixed   *myfixed,
 }
 
 void
-gtk_myfixed_move (GtkMyFixed       *myfixed,
-                GtkWidget      *widget,
-                gint16         x,
-                gint16         y)
+gtk_myfixed_move (GtkMyFixed     *myfixed,
+                  GtkWidget      *widget,
+                  gint16         x,
+                  gint16         y)
 {
   GtkMyFixedChild *child;
   GList *children;
@@ -248,16 +253,91 @@ gtk_myfixed_move (GtkMyFixed       *myfixed,
     {
       child = children->data;
       children = children->next;
+      
+      if (child->widget == widget)
+        {
+           gtk_myfixed_set_size( myfixed, widget, x, y, child->width, child->height );
+          break;
+       }
+    }
+}
+
+void
+gtk_myfixed_resize (GtkMyFixed     *myfixed,
+                    GtkWidget      *widget,
+                   gint16         width,
+                   gint16         height)
+{
+  GtkMyFixedChild *child;
+  GList *children;
+
+  g_return_if_fail (myfixed != NULL);
+  g_return_if_fail (GTK_IS_MYFIXED (myfixed));
+  g_return_if_fail (widget != NULL);
 
+  children = myfixed->children;
+  while (children)
+    {
+      child = children->data;
+      children = children->next;
+      
       if (child->widget == widget)
         {
-         if ((child->x == x) && (child->y == y)) return;
+           gtk_myfixed_set_size( myfixed, widget, child->x, child->y, width, height );
+          break;
+       }
+    }
+}
+
+void
+gtk_myfixed_set_size (GtkMyFixed     *myfixed,
+                      GtkWidget      *widget,
+                      gint16         x,
+                      gint16         y,
+                     gint16         width,
+                     gint16         height)
+{
+  GtkMyFixedChild *child;
+  GList *children;
+  GtkAllocation child_allocation;
+
+  g_return_if_fail (myfixed != NULL);
+  g_return_if_fail (GTK_IS_MYFIXED (myfixed));
+  g_return_if_fail (widget != NULL);
+
+  children = myfixed->children;
+  while (children)
+    {
+      child = children->data;
+      children = children->next;
+
+      if (child->widget == widget)
+        {
+         if ((child->x == x) && 
+             (child->y == y) &&
+             (child->width == width) && 
+             (child->height == height)) return;
          
           child->x = x;
           child->y = y;
+          child->width = width;
+          child->height = height;
 
           if (GTK_WIDGET_VISIBLE (widget) && GTK_WIDGET_VISIBLE (myfixed))
-            gtk_widget_queue_resize (GTK_WIDGET (myfixed));
+         {
+             if ((child->width > 1) && (child->height > 1) && (GTK_WIDGET_REALIZED(widget)))
+            {
+                child_allocation.x = child->x;
+                child_allocation.y = child->y;
+                child_allocation.width = child->width;
+                child_allocation.height = child->height;
+                gtk_widget_size_allocate (widget, &child_allocation);
+             } 
+            else 
+            {
+                gtk_widget_queue_resize (GTK_WIDGET (myfixed));
+            }
+         }
 
           break;
         }
@@ -319,18 +399,21 @@ gtk_myfixed_realize (GtkWidget *widget)
   attributes.window_type = GDK_WINDOW_CHILD;
   
 #if (GTK_MINOR_VERSION > 0)
+  attributes.x = widget->allocation.x;
+  attributes.y = widget->allocation.y;
+  attributes.width = widget->allocation.width;
+  attributes.height = widget->allocation.height;
+
   if (myfixed->shadow_type != GTK_SHADOW_NONE)
-    {
-      attributes.x = 2;
-      attributes.y = 2;
-    }
-  else
-    {
-      attributes.x = 0;
-      attributes.y = 0;
-    }
-  attributes.width = MAX (1, (gint)widget->allocation.width - attributes.x * 2 );
-  attributes.height = MAX (1, (gint)widget->allocation.height - attributes.y * 2 );
+  {
+      attributes.x += 2;
+      attributes.y += 2;
+      attributes.width -= 4;
+      attributes.height -= 4;
+  }
+    
+  if (attributes.width < 2) attributes.width = 2;
+  if (attributes.height < 2) attributes.height = 2;
 #else
   attributes.x = widget->allocation.x;
   attributes.y = widget->allocation.y;
@@ -381,8 +464,10 @@ gtk_myfixed_size_request (GtkWidget      *widget,
 
   myfixed = GTK_MYFIXED (widget);
   
-  requisition->width = 0;
-  requisition->height = 0;
+  /* request very little, I'm not sure if requesting nothing
+     will always have positive effects on stability... */
+  requisition->width = 2;
+  requisition->height = 2;
 
   children = myfixed->children;
   while (children)
@@ -399,7 +484,7 @@ gtk_myfixed_size_request (GtkWidget      *widget,
 
 static void
 gtk_myfixed_size_allocate (GtkWidget     *widget,
-                        GtkAllocation *allocation)
+                          GtkAllocation *allocation)
 {
   GtkMyFixed *myfixed;
   gint border;
@@ -412,7 +497,8 @@ gtk_myfixed_size_allocate (GtkWidget     *widget,
   g_return_if_fail (allocation != NULL);
 
   myfixed = GTK_MYFIXED (widget);
-
+  
+    widget->allocation = *allocation;
 #if (GTK_MINOR_VERSION > 0)
   if (myfixed->shadow_type == GTK_SHADOW_NONE)
     border = 0;
@@ -422,7 +508,6 @@ gtk_myfixed_size_allocate (GtkWidget     *widget,
   border = 0;
 #endif
 
-  widget->allocation = *allocation;
   if (GTK_WIDGET_REALIZED (widget))
   {
     gdk_window_move_resize( widget->window, 
@@ -440,13 +525,17 @@ gtk_myfixed_size_allocate (GtkWidget     *widget,
     {
       child = children->data;
       children = children->next;
-      
-      if (GTK_WIDGET_VISIBLE (child->widget))
+      /* please look at the text in wxWindow::DoSetSize() on why the
+         test GTK_WIDGET_REALIZED() has to be here */
+      if (GTK_WIDGET_VISIBLE (child->widget) && 
+         !(!GTK_WIDGET_REALIZED(child->widget) &&
+           GTK_IS_NOTEBOOK(child->widget) ))
        {
          child_allocation.x = child->x;
          child_allocation.y = child->y;
-         child_allocation.width = child->widget->requisition.width;
-         child_allocation.height = child->widget->requisition.height;
+         child_allocation.width = child->width;
+         child_allocation.height = child->height;
          gtk_widget_size_allocate (child->widget, &child_allocation);
        }
     }
@@ -454,7 +543,7 @@ gtk_myfixed_size_allocate (GtkWidget     *widget,
 
 static void
 gtk_myfixed_paint (GtkWidget    *widget,
-                GdkRectangle *area)
+                  GdkRectangle *area)
 {
   g_return_if_fail (widget != NULL);
   g_return_if_fail (GTK_IS_MYFIXED (widget));
@@ -468,7 +557,7 @@ gtk_myfixed_paint (GtkWidget    *widget,
 
 static void
 gtk_myfixed_draw (GtkWidget    *widget,
-               GdkRectangle *area)
+                 GdkRectangle *area)
 {
   GtkMyFixed *myfixed;
   GtkMyFixedChild *child;
@@ -497,7 +586,7 @@ gtk_myfixed_draw (GtkWidget    *widget,
 
 static gint
 gtk_myfixed_expose (GtkWidget      *widget,
-                 GdkEventExpose *event)
+                   GdkEventExpose *event)
 {
   GtkMyFixed *myfixed;
   GtkMyFixedChild *child;
@@ -538,7 +627,7 @@ gtk_myfixed_add (GtkContainer *container,
   g_return_if_fail (GTK_IS_MYFIXED (container));
   g_return_if_fail (widget != NULL);
 
-  gtk_myfixed_put (GTK_MYFIXED (container), widget, 0, 0);
+  gtk_myfixed_put (GTK_MYFIXED (container), widget, 0, 0, 20, 20 );
 }
 
 static void