handlebox: Simplify painting code

This commit is contained in:
Benjamin Otte 2010-09-08 14:40:22 +02:00
parent 08d05f954d
commit 2e53b58b01

View File

@ -149,8 +149,7 @@ static void gtk_handle_box_remove (GtkContainer *container,
GtkWidget *widget); GtkWidget *widget);
static void gtk_handle_box_draw_ghost (GtkHandleBox *hb); static void gtk_handle_box_draw_ghost (GtkHandleBox *hb);
static void gtk_handle_box_paint (GtkWidget *widget, static void gtk_handle_box_paint (GtkWidget *widget,
GdkEventExpose *event, GdkEventExpose *event);
GdkRectangle *area);
static gboolean gtk_handle_box_expose (GtkWidget *widget, static gboolean gtk_handle_box_expose (GtkWidget *widget,
GdkEventExpose *event); GdkEventExpose *event);
static gboolean gtk_handle_box_button_press (GtkWidget *widget, static gboolean gtk_handle_box_button_press (GtkWidget *widget,
@ -789,17 +788,6 @@ gtk_handle_box_draw_ghost (GtkHandleBox *hb)
allocation.width / 2); allocation.width / 2);
} }
static void
draw_textured_frame (GtkWidget *widget, GdkWindow *window, GdkRectangle *rect, GtkShadowType shadow,
GdkRectangle *clip, GtkOrientation orientation)
{
gtk_paint_handle (gtk_widget_get_style (widget), window,
GTK_STATE_NORMAL, shadow,
clip, widget, "handlebox",
rect->x, rect->y, rect->width, rect->height,
orientation);
}
void void
gtk_handle_box_set_shadow_type (GtkHandleBox *handle_box, gtk_handle_box_set_shadow_type (GtkHandleBox *handle_box,
GtkShadowType type) GtkShadowType type)
@ -929,8 +917,7 @@ gtk_handle_box_get_child_detached (GtkHandleBox *handle_box)
static void static void
gtk_handle_box_paint (GtkWidget *widget, gtk_handle_box_paint (GtkWidget *widget,
GdkEventExpose *event, GdkEventExpose *event)
GdkRectangle *area)
{ {
GtkHandleBox *hb = GTK_HANDLE_BOX (widget); GtkHandleBox *hb = GTK_HANDLE_BOX (widget);
GtkHandleBoxPrivate *priv = hb->priv; GtkHandleBoxPrivate *priv = hb->priv;
@ -938,7 +925,6 @@ gtk_handle_box_paint (GtkWidget *widget,
GtkWidget *child; GtkWidget *child;
gint width, height; gint width, height;
GdkRectangle rect; GdkRectangle rect;
GdkRectangle dest;
gint handle_position; gint handle_position;
GtkOrientation handle_orientation; GtkOrientation handle_orientation;
@ -946,14 +932,6 @@ gtk_handle_box_paint (GtkWidget *widget,
gdk_drawable_get_size (priv->bin_window, &width, &height); gdk_drawable_get_size (priv->bin_window, &width, &height);
if (!event)
gtk_paint_box (gtk_widget_get_style (widget),
priv->bin_window,
gtk_widget_get_state (widget),
priv->shadow_type,
area, widget, "handlebox_bin",
0, 0, -1, -1);
else
gtk_paint_box (gtk_widget_get_style (widget), gtk_paint_box (gtk_widget_get_style (widget),
priv->bin_window, priv->bin_window,
gtk_widget_get_state (widget), gtk_widget_get_state (widget),
@ -961,14 +939,6 @@ gtk_handle_box_paint (GtkWidget *widget,
&event->area, widget, "handlebox_bin", &event->area, widget, "handlebox_bin",
0, 0, -1, -1); 0, 0, -1, -1);
/* We currently draw the handle _above_ the relief of the handlebox.
* it could also be drawn on the same level...
priv->handle_position == GTK_POS_LEFT ? DRAG_HANDLE_SIZE : 0,
priv->handle_position == GTK_POS_TOP ? DRAG_HANDLE_SIZE : 0,
width,
height);*/
switch (handle_position) switch (handle_position)
{ {
case GTK_POS_LEFT: case GTK_POS_LEFT:
@ -1004,10 +974,11 @@ gtk_handle_box_paint (GtkWidget *widget,
break; break;
} }
if (gdk_rectangle_intersect (event ? &event->area : area, &rect, &dest)) if (gdk_rectangle_intersect (&event->area, &rect, NULL))
draw_textured_frame (widget, priv->bin_window, &rect, gtk_paint_handle (gtk_widget_get_style (widget), priv->bin_window,
GTK_SHADOW_OUT, GTK_STATE_NORMAL, GTK_SHADOW_OUT,
event ? &event->area : area, &event->area, widget, "handlebox",
rect.x, rect.y, rect.width, rect.height,
handle_orientation); handle_orientation);
child = gtk_bin_get_child (bin); child = gtk_bin_get_child (bin);
@ -1033,7 +1004,7 @@ gtk_handle_box_expose (GtkWidget *widget,
gtk_handle_box_draw_ghost (hb); gtk_handle_box_draw_ghost (hb);
} }
else else
gtk_handle_box_paint (widget, event, NULL); gtk_handle_box_paint (widget, event);
} }
return FALSE; return FALSE;