Re: [gtk-list] paned [patch]




> if I put a horizontal paned into a notebook page, it behaves different
> weather it is the first page or not. The first page is right balanced
> but the second and third (and probably all other) look strange: the
> little paned button is at the top and not at the bottom and the left
> part has a width of 0 pixels.

OK, it was a bug in the way the Paned widgets did there size
allocation. Here's a fix.

Regards,
                                        Owen

*** gtk+970925.orig/gtk/gtkhpaned.c	Wed Sep 24 21:29:12 1997
--- gtk+970925/gtkhpaned.c	Fri Oct 17 16:55:47 1997
***************
*** 137,193 ****
  
    widget->allocation = *allocation;
  
!   if (GTK_WIDGET_REALIZED (widget))
!     {
!       paned = GTK_PANED (widget);
!       border_width = GTK_CONTAINER (paned)->border_width;
! 
!       if (GTK_WIDGET_MAPPED (widget))
! 	{
! 	  gdk_window_clear_area (widget->window,
! 				 paned->groove_rectangle.x,
! 				 paned->groove_rectangle.y,
! 				 paned->groove_rectangle.width,
! 				 paned->groove_rectangle.height);
! 	}
! 
!       child_allocation.height = allocation->height - border_width * 2;
!       child_allocation.width = 0;
!       child_allocation.x = allocation->x + border_width;
!       child_allocation.y = allocation->y + border_width;
! 
!       if (paned->position_set)
! 	{
! 	  child_allocation.width = paned->child1_size;
! 	}
!       else if (paned->child1 && GTK_WIDGET_VISIBLE (paned->child1))
! 	{
! 	  child_allocation.width = paned->child1->requisition.width;
! 	  paned->child1_size = paned->child1->requisition.width;
! 	}
!       if (paned->child1)
! 	{
! 	  gtk_widget_size_allocate (paned->child1, &child_allocation);
! 	}
! 
!       child_allocation.x += child_allocation.width + paned->gutter_size / 2;
! 
!       paned->groove_rectangle.x = child_allocation.x - 1;
!       paned->groove_rectangle.y = allocation->y;
!       paned->groove_rectangle.width = 2;
!       paned->groove_rectangle.height = allocation->height;
! 
!       child_allocation.x += paned->gutter_size / 2;
  
!       if (paned->child2)
! 	{
! 	  child_allocation.width = allocation->x + allocation->width - child_allocation.x - border_width;
! 	  gtk_widget_size_allocate (paned->child2, &child_allocation);
! 	}
  
!       gdk_window_move (paned->handle,
! 		       allocation->x + paned->child1_size + border_width + paned->gutter_size / 2 - paned->handle_size / 2,
! 		       allocation->y + allocation->height - border_width - 2*paned->handle_size);
        gdk_window_raise (paned->handle);
      }
  }
--- 137,194 ----
  
    widget->allocation = *allocation;
  
!   paned = GTK_PANED (widget);
!   border_width = GTK_CONTAINER (paned)->border_width;
  
!   if (GTK_WIDGET_MAPPED (widget))
!     {
!       gdk_window_clear_area (widget->window,
! 			     paned->groove_rectangle.x,
! 			     paned->groove_rectangle.y,
! 			     paned->groove_rectangle.width,
! 			     paned->groove_rectangle.height);
!     }
!   
!   child_allocation.height = allocation->height - border_width * 2;
!   child_allocation.width = 0;
!   child_allocation.x = allocation->x + border_width;
!   child_allocation.y = allocation->y + border_width;
!   
!   if (paned->position_set)
!     {
!       child_allocation.width = paned->child1_size;
!     }
!   else if (paned->child1 && GTK_WIDGET_VISIBLE (paned->child1))
!     {
!       child_allocation.width = paned->child1->requisition.width;
!       paned->child1_size = paned->child1->requisition.width;
!     }
!   if (paned->child1 && GTK_WIDGET_VISIBLE (paned->child1))
!     {
!       gtk_widget_size_allocate (paned->child1, &child_allocation);
!     }
!   
!   child_allocation.x += child_allocation.width + paned->gutter_size / 2;
!   
!   paned->groove_rectangle.x = child_allocation.x - 1;
!   paned->groove_rectangle.y = allocation->y;
!   paned->groove_rectangle.width = 2;
!   paned->groove_rectangle.height = allocation->height;
!       
!   child_allocation.x += paned->gutter_size / 2;
!   
!   if (paned->child2 && GTK_WIDGET_VISIBLE (paned->child2))
!     {
!       child_allocation.width = allocation->x + allocation->width - child_allocation.x - border_width;
!       gtk_widget_size_allocate (paned->child2, &child_allocation);
!     }
!   
!   paned->handle_xpos = allocation->x + paned->child1_size + border_width + paned->gutter_size / 2 - paned->handle_size / 2;
!   paned->handle_ypos = allocation->y + allocation->height - border_width - 2*paned->handle_size;
  
!   if (GTK_WIDGET_REALIZED (widget))
!     {
!       gdk_window_move (paned->handle, paned->handle_xpos, paned->handle_ypos);
        gdk_window_raise (paned->handle);
      }
  }
*** gtk+970925.orig/gtk/gtkpaned.c	Wed Sep 24 21:29:12 1997
--- gtk+970925/gtkpaned.c	Fri Oct 17 16:58:03 1997
***************
*** 102,107 ****
--- 102,110 ----
    paned->gutter_size = 6;
    paned->position_set = FALSE;
    paned->in_drag = FALSE;
+ 
+   paned->handle_xpos = -1;
+   paned->handle_ypos = -1;
  }
  
  
***************
*** 145,152 ****
    GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
    paned = GTK_PANED (widget);
  
!   attributes.x = widget->allocation.x;
!   attributes.y = widget->allocation.y + (widget->allocation.height - widget->requisition.height) / 2;
    attributes.width = paned->handle_size;
    attributes.height = paned->handle_size;
    attributes.wclass = GDK_INPUT_OUTPUT;
--- 148,155 ----
    GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
    paned = GTK_PANED (widget);
  
!   attributes.x = paned->handle_xpos;
!   attributes.y = paned->handle_ypos;
    attributes.width = paned->handle_size;
    attributes.height = paned->handle_size;
    attributes.wclass = GDK_INPUT_OUTPUT;
***************
*** 167,172 ****
--- 170,176 ----
    paned->handle = gdk_window_new (widget->parent->window, &attributes, attributes_mask);
    gdk_window_set_user_data (paned->handle, widget);
    gdk_window_show (paned->handle);
+   gdk_window_raise (paned->handle);
  
    widget->window = widget->parent->window;
    widget->style = gtk_style_attach (widget->style, widget->window);
*** gtk+970925.orig/gtk/gtkpaned.h	Wed Sep 24 21:29:12 1997
--- gtk+970925/gtkpaned.h	Fri Oct 17 16:52:15 1997
***************
*** 53,58 ****
--- 53,61 ----
    gint child1_size;
    guint position_set : 1;
    guint in_drag : 1;
+ 
+   gint16 handle_xpos;
+   gint16 handle_ypos;
  };
  
  struct _GtkPanedClass
*** gtk+970925.orig/gtk/gtkvpaned.c	Wed Sep 24 21:29:12 1997
--- gtk+970925/gtkvpaned.c	Fri Oct 17 16:55:39 1997
***************
*** 137,193 ****
  
    widget->allocation = *allocation;
  
!   if (GTK_WIDGET_REALIZED (widget))
!     {
!       paned = GTK_PANED (widget);
!       border_width = GTK_CONTAINER (paned)->border_width;
! 
!       if (GTK_WIDGET_MAPPED (widget))
! 	{
! 	  gdk_window_clear_area (widget->window,
! 				 paned->groove_rectangle.x,
! 				 paned->groove_rectangle.y,
! 				 paned->groove_rectangle.width,
! 				 paned->groove_rectangle.height);
! 	}
! 
!       child_allocation.width = allocation->width - border_width * 2;
!       child_allocation.height = 0;
!       child_allocation.x = allocation->x + border_width;
!       child_allocation.y = allocation->y + border_width;
  
!       if (paned->position_set)
! 	{
! 	  child_allocation.height = paned->child1_size;
! 	}
!       else if (paned->child1 && GTK_WIDGET_VISIBLE (paned->child1))
! 	{
! 	  child_allocation.height = paned->child1->requisition.height;
! 	  paned->child1_size = paned->child1->requisition.height;
! 	}
!       if (paned->child1)
! 	{
! 	  gtk_widget_size_allocate (paned->child1, &child_allocation);
! 	}
! 
!       child_allocation.y += child_allocation.height + paned->gutter_size / 2;
! 
!       paned->groove_rectangle.y = child_allocation.y - 1;
!       paned->groove_rectangle.x = allocation->x;
!       paned->groove_rectangle.height = 2;
!       paned->groove_rectangle.width = allocation->width;
  
!       child_allocation.y += paned->gutter_size / 2;
  
!       if (paned->child2)
! 	{
! 	  child_allocation.height = allocation->y + allocation->height - child_allocation.y - border_width;
! 	  gtk_widget_size_allocate (paned->child2, &child_allocation);
! 	}
  
!       gdk_window_move (paned->handle,
! 		       allocation->x + allocation->width - border_width - 2 * paned->handle_size,
! 		       allocation->y + paned->child1_size + border_width + paned->gutter_size / 2 - paned->handle_size / 2);
        gdk_window_raise (paned->handle);
      }
  }
--- 137,195 ----
  
    widget->allocation = *allocation;
  
!   paned = GTK_PANED (widget);
!   border_width = GTK_CONTAINER (paned)->border_width;
  
!   if (GTK_WIDGET_MAPPED (widget))
!     {
!       gdk_window_clear_area (widget->window,
! 			     paned->groove_rectangle.x,
! 			     paned->groove_rectangle.y,
! 			     paned->groove_rectangle.width,
! 			     paned->groove_rectangle.height);
!     }
!   
!   child_allocation.width = allocation->width - border_width * 2;
!   child_allocation.height = 0;
!   child_allocation.x = allocation->x + border_width;
!   child_allocation.y = allocation->y + border_width;
!   
!   if (paned->position_set)
!     {
!       child_allocation.height = paned->child1_size;
!     }
!   else if (paned->child1 && GTK_WIDGET_VISIBLE (paned->child1))
!     {
!       child_allocation.height = paned->child1->requisition.height;
!       paned->child1_size = paned->child1->requisition.height;
!     }
  
!   if (paned->child1 && GTK_WIDGET_VISIBLE (paned->child1))
!     {
!       gtk_widget_size_allocate (paned->child1, &child_allocation);
!     }
!   
!   child_allocation.y += child_allocation.height + paned->gutter_size / 2;
!   
!   paned->groove_rectangle.y = child_allocation.y - 1;
!   paned->groove_rectangle.x = allocation->x;
!   paned->groove_rectangle.height = 2;
!   paned->groove_rectangle.width = allocation->width;
!   
!   child_allocation.y += paned->gutter_size / 2;
!   
!   if (paned->child2 && GTK_WIDGET_VISIBLE (paned->child2))
!     {
!       child_allocation.height = allocation->y + allocation->height - child_allocation.y - border_width;
!       gtk_widget_size_allocate (paned->child2, &child_allocation);
!     }
  
!   paned->handle_xpos = allocation->x + allocation->width - border_width - 2 * paned->handle_size;
!   paned->handle_ypos = allocation->y + paned->child1_size + border_width + paned->gutter_size / 2 - paned->handle_size / 2;
  
!   if (GTK_WIDGET_REALIZED (widget))
!     {
!       gdk_window_move (paned->handle, paned->handle_xpos, paned->handle_ypos);
        gdk_window_raise (paned->handle);
      }
  }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]