Index: tests/testgtk.c
===================================================================
RCS file: /cvs/gnome/gtk+/tests/testgtk.c,v
retrieving revision 1.321
diff -u -b -B -p -r1.321 testgtk.c
--- tests/testgtk.c	25 Oct 2002 15:00:55 -0000	1.321
+++ tests/testgtk.c	28 Oct 2002 21:49:51 -0000
@@ -2791,6 +2791,149 @@ create_reparent (GtkWidget *widget)
 }
 
 /*
+ * Resize Grips
+ */
+static gboolean
+grippy_button_press (GtkWidget *area, GdkEventButton *event, GdkWindowEdge edge)
+{
+  if (event->button == 1)
+    gtk_window_begin_resize_drag (GTK_WINDOW (gtk_widget_get_toplevel (area)), edge,
+				  event->button, event->x_root, event->y_root,
+				  event->time);
+  return TRUE;
+}
+
+static gboolean
+grippy_expose (GtkWidget *area, GdkEventExpose *event, GdkWindowEdge edge)
+{
+  gtk_paint_resize_grip (area->style,
+			 area->window,
+			 GTK_WIDGET_STATE (area),
+			 &event->area,
+			 area,
+			 "statusbar",
+			 edge,
+			 0, 0,
+			 area->allocation.width,
+			 area->allocation.height);
+
+  return TRUE;
+}
+
+static void
+create_resize_grips (GtkWidget *widget)
+{
+  static GtkWidget *window = NULL;
+  GtkWidget *area;
+  GtkWidget *hbox, *vbox;
+  if (!window)
+    {
+      window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+
+      gtk_window_set_screen (GTK_WINDOW (window),
+			     gtk_widget_get_screen (widget));
+
+      gtk_window_set_title (GTK_WINDOW (window), "resize grips");
+      
+      g_signal_connect (window, "destroy",
+			G_CALLBACK (gtk_widget_destroyed),
+			&window);
+
+      vbox = gtk_vbox_new (FALSE, 0);
+      gtk_container_add (GTK_CONTAINER (window), vbox);
+
+      hbox = gtk_hbox_new (FALSE, 0);
+      gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 0);
+
+      /* North west */
+      area = gtk_drawing_area_new ();
+      gtk_widget_add_events (area, GDK_BUTTON_PRESS_MASK);
+      gtk_box_pack_start (GTK_BOX (hbox), area, TRUE, TRUE, 0);
+      g_signal_connect (area, "expose_event", G_CALLBACK (grippy_expose),
+			GINT_TO_POINTER (GDK_WINDOW_EDGE_NORTH_WEST));
+      g_signal_connect (area, "button_press_event", G_CALLBACK (grippy_button_press),
+			GINT_TO_POINTER (GDK_WINDOW_EDGE_NORTH_WEST));
+      
+      /* North */
+      area = gtk_drawing_area_new ();
+      gtk_widget_add_events (area, GDK_BUTTON_PRESS_MASK);
+      gtk_box_pack_start (GTK_BOX (hbox), area, TRUE, TRUE, 0);
+      g_signal_connect (area, "expose_event", G_CALLBACK (grippy_expose),
+			GINT_TO_POINTER (GDK_WINDOW_EDGE_NORTH));
+      g_signal_connect (area, "button_press_event", G_CALLBACK (grippy_button_press),
+			GINT_TO_POINTER (GDK_WINDOW_EDGE_NORTH));
+
+      /* North east */
+      area = gtk_drawing_area_new ();
+      gtk_widget_add_events (area, GDK_BUTTON_PRESS_MASK);
+      gtk_box_pack_start (GTK_BOX (hbox), area, TRUE, TRUE, 0);
+      g_signal_connect (area, "expose_event", G_CALLBACK (grippy_expose),
+			GINT_TO_POINTER (GDK_WINDOW_EDGE_NORTH_EAST));
+      g_signal_connect (area, "button_press_event", G_CALLBACK (grippy_button_press),
+			GINT_TO_POINTER (GDK_WINDOW_EDGE_NORTH_EAST));
+
+      hbox = gtk_hbox_new (FALSE, 0);
+      gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 0);
+
+      /* West */
+      area = gtk_drawing_area_new ();
+      gtk_widget_add_events (area, GDK_BUTTON_PRESS_MASK);
+      gtk_box_pack_start (GTK_BOX (hbox), area, TRUE, TRUE, 0);
+      g_signal_connect (area, "expose_event", G_CALLBACK (grippy_expose),
+			GINT_TO_POINTER (GDK_WINDOW_EDGE_WEST));
+      g_signal_connect (area, "button_press_event", G_CALLBACK (grippy_button_press),
+			GINT_TO_POINTER (GDK_WINDOW_EDGE_WEST));
+
+      /* Middle */
+      area = gtk_drawing_area_new ();
+      gtk_box_pack_start (GTK_BOX (hbox), area, TRUE, TRUE, 0);
+
+      /* East */
+      area = gtk_drawing_area_new ();
+      gtk_widget_add_events (area, GDK_BUTTON_PRESS_MASK);
+      gtk_box_pack_start (GTK_BOX (hbox), area, TRUE, TRUE, 0);
+      g_signal_connect (area, "expose_event", G_CALLBACK (grippy_expose),
+			GINT_TO_POINTER (GDK_WINDOW_EDGE_EAST));
+      g_signal_connect (area, "button_press_event", G_CALLBACK (grippy_button_press),
+			GINT_TO_POINTER (GDK_WINDOW_EDGE_EAST));
+
+      hbox = gtk_hbox_new (FALSE, 0);
+      gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 0);
+
+      /* South west */
+      area = gtk_drawing_area_new ();
+      gtk_widget_add_events (area, GDK_BUTTON_PRESS_MASK);
+      gtk_box_pack_start (GTK_BOX (hbox), area, TRUE, TRUE, 0);
+      g_signal_connect (area, "expose_event", G_CALLBACK (grippy_expose),
+			GINT_TO_POINTER (GDK_WINDOW_EDGE_SOUTH_WEST));
+      g_signal_connect (area, "button_press_event", G_CALLBACK (grippy_button_press),
+			GINT_TO_POINTER (GDK_WINDOW_EDGE_SOUTH_WEST));
+      /* South */
+      area = gtk_drawing_area_new ();
+      gtk_widget_add_events (area, GDK_BUTTON_PRESS_MASK);
+      gtk_box_pack_start (GTK_BOX (hbox), area, TRUE, TRUE, 0);
+      g_signal_connect (area, "expose_event", G_CALLBACK (grippy_expose),
+			GINT_TO_POINTER (GDK_WINDOW_EDGE_SOUTH));
+      g_signal_connect (area, "button_press_event", G_CALLBACK (grippy_button_press),
+			GINT_TO_POINTER (GDK_WINDOW_EDGE_SOUTH));
+      
+      /* South east */
+      area = gtk_drawing_area_new ();
+      gtk_widget_add_events (area, GDK_BUTTON_PRESS_MASK);
+      gtk_box_pack_start (GTK_BOX (hbox), area, TRUE, TRUE, 0);
+      g_signal_connect (area, "expose_event", G_CALLBACK (grippy_expose),
+			GINT_TO_POINTER (GDK_WINDOW_EDGE_SOUTH_EAST));
+      g_signal_connect (area, "button_press_event", G_CALLBACK (grippy_button_press),
+			GINT_TO_POINTER (GDK_WINDOW_EDGE_SOUTH_EAST));
+    }
+
+  if (!GTK_WIDGET_VISIBLE (window))
+    gtk_widget_show_all (window);
+  else
+    gtk_widget_destroy (window);
+}
+
+/*
  * Saved Position
  */
 gint upositionx = 0;
@@ -12147,6 +12290,7 @@ struct {
   { "range controls", create_range_controls },
   { "rc file", create_rc_file },
   { "reparent", create_reparent },
+  { "resize grips", create_resize_grips },
   { "rulers", create_rulers },
   { "saved position", create_saved_position },
   { "scrolled windows", create_scrolled_windows },
Index: gtk/gtkstyle.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkstyle.c,v
retrieving revision 1.127
diff -u -b -B -p -r1.127 gtkstyle.c
--- gtk/gtkstyle.c	22 Oct 2002 23:05:29 -0000	1.127
+++ gtk/gtkstyle.c	28 Oct 2002 21:49:53 -0000
@@ -5011,6 +5017,72 @@ gtk_default_draw_resize_grip (GtkStyle  
       gdk_gc_set_clip_rectangle (style->bg_gc[state_type], area);
     }
 
+  switch (edge)
+    {
+    case GDK_WINDOW_EDGE_NORTH_WEST:
+      /* make it square */
+      if (width < height)
+	{
+	  height = width;
+	}
+      else if (height < width)
+	{
+	  width = height;
+	}
+      break;
+    case GDK_WINDOW_EDGE_NORTH:
+      if (width < height)
+	{
+	  height = width;
+	}
+      break;
+    case GDK_WINDOW_EDGE_NORTH_EAST:
+      /* make it square, aligning to top right */
+      if (width < height)
+	{
+	  height = width;
+	}
+      else if (height < width)
+	{
+	  x += (width - height);
+	  width = height;
+	}
+      break;
+    case GDK_WINDOW_EDGE_WEST:
+      if (height < width)
+	{
+	   width = height;
+	}
+      break;
+    case GDK_WINDOW_EDGE_EAST:
+      /* aligning to right */
+      if (height < width)
+	{
+	  x += (width - height);
+	  width = height;
+	}
+      break;
+    case GDK_WINDOW_EDGE_SOUTH_WEST:
+      /* make it square, aligning to bottom left */
+      if (width < height)
+	{
+	  y += (height - width);
+	  height = width;
+	}
+      else if (height < width)
+	{
+	  width = height;
+	}
+      break;
+    case GDK_WINDOW_EDGE_SOUTH:
+      /* align to bottom */
+      if (width < height)
+	{
+	  y += (height - width);
+	  height = width;
+	}
+      break;
+    case GDK_WINDOW_EDGE_SOUTH_EAST:
   /* make it square, aligning to bottom right */
   if (width < height)
     {
@@ -5022,7 +5094,10 @@ gtk_default_draw_resize_grip (GtkStyle  
       x += (width - height);
       width = height;
     }
-
+      break;
+    default:
+      g_assert_not_reached ();
+    }
   /* Clear background */
   gtk_style_apply_default_background (style, window, FALSE,
 				      state_type, area,
@@ -5030,6 +5105,161 @@ gtk_default_draw_resize_grip (GtkStyle  
 
   switch (edge)
     {
+    case GDK_WINDOW_EDGE_WEST:
+    case GDK_WINDOW_EDGE_EAST:
+      {
+	gint xi;
+
+	xi = x;
+
+	while (xi < x + width)
+	  {
+	    gdk_draw_line (window,
+			   style->light_gc[state_type],
+			   xi, y,
+			   xi, y + height);
+
+	    xi++;
+	    gdk_draw_line (window,
+			   style->dark_gc[state_type],
+			   xi, y,
+			   xi, y + height);
+
+	    xi += 2;
+	  }
+      }
+      break;
+    case GDK_WINDOW_EDGE_NORTH:
+    case GDK_WINDOW_EDGE_SOUTH:
+      {
+	gint yi;
+
+	yi = y;
+
+	while (yi < y + height)
+	  {
+	    gdk_draw_line (window,
+			   style->light_gc[state_type],
+			   x, yi,
+			   x + width, yi);
+
+	    yi++;
+	    gdk_draw_line (window,
+			   style->dark_gc[state_type],
+			   x, yi,
+			   x + width, yi);
+
+	    yi+= 2;
+	  }
+      }
+      break;
+    case GDK_WINDOW_EDGE_NORTH_WEST:
+      {
+	gint xi, yi;
+
+	xi = x + width;
+	yi = y + height;
+
+	while (xi > x + 3)
+	  {
+	    gdk_draw_line (window,
+			   style->dark_gc[state_type],
+			   xi, y,
+			   x, yi);
+
+	    --xi;
+	    --yi;
+
+	    gdk_draw_line (window,
+			   style->dark_gc[state_type],
+			   xi, y,
+			   x, yi);
+
+	    --xi;
+	    --yi;
+
+	    gdk_draw_line (window,
+			   style->light_gc[state_type],
+			   xi, y,
+			   x, yi);
+
+	    xi -= 3;
+	    yi -= 3;
+	    
+	  }
+      }
+      break;
+    case GDK_WINDOW_EDGE_NORTH_EAST:
+      {
+        gint xi, yi;
+
+        xi = x;
+        yi = y + height;
+
+        while (xi < (x + width - 3))
+          {
+            gdk_draw_line (window,
+                           style->light_gc[state_type],
+                           xi, y,
+                           x + width, yi);                           
+
+            ++xi;
+            --yi;
+            
+            gdk_draw_line (window,
+                           style->dark_gc[state_type],
+                           xi, y,
+                           x + width, yi);                           
+
+            ++xi;
+            --yi;
+            
+            gdk_draw_line (window,
+                           style->dark_gc[state_type],
+                           xi, y,
+                           x + width, yi);
+
+            xi += 3;
+            yi -= 3;
+          }
+      }
+      break;
+    case GDK_WINDOW_EDGE_SOUTH_WEST:
+      {
+	gint xi, yi;
+
+	xi = x + width;
+	yi = y;
+
+	while (xi > x + 3)
+	  {
+	    gdk_draw_line (window,
+			   style->dark_gc[state_type],
+			   x, yi,
+			   xi, y + height);
+
+	    --xi;
+	    ++yi;
+
+	    gdk_draw_line (window,
+			   style->dark_gc[state_type],
+			   x, yi,
+			   xi, y + height);
+
+	    --xi;
+	    ++yi;
+
+	    gdk_draw_line (window,
+			   style->light_gc[state_type],
+			   x, yi,
+			   xi, y + height);
+
+	    xi -= 3;
+	    yi += 3;
+	    
+	  }
+      }
+      break;
     case GDK_WINDOW_EDGE_SOUTH_EAST:
       {
         gint xi, yi;
