Change copy_area => !set_bg. Use tile instead of gdk_window_copy_area when

Thu Jan 14 20:29:16 1999  Owen Taylor  <otaylor@redhat.com>

	* gtk/gtkstyle.[ch] (gtk_style_apply_default_background):
	Change copy_area => !set_bg. Use tile instead of
	gdk_window_copy_area when drawing without !set_bg.

	This does mess up timj's neat check-button example,
	but is consistent with how we interpret background
	pixmaps everywhere else in the default scheme.

	Restructure code for clarity.
This commit is contained in:
Owen Taylor 1999-01-15 15:54:39 +00:00 committed by Owen Taylor
parent 467e0fcb24
commit 40f9670464
2 changed files with 45 additions and 53 deletions

View File

@ -1092,7 +1092,7 @@ gtk_style_set_background (GtkStyle *style,
void void
gtk_style_apply_default_background (GtkStyle *style, gtk_style_apply_default_background (GtkStyle *style,
GdkWindow *window, GdkWindow *window,
gboolean copy_area, gboolean set_bg,
GtkStateType state_type, GtkStateType state_type,
GdkRectangle *area, GdkRectangle *area,
gint x, gint x,
@ -1101,31 +1101,46 @@ gtk_style_apply_default_background (GtkStyle *style,
gint height) gint height)
{ {
GdkRectangle new_rect, old_rect; GdkRectangle new_rect, old_rect;
GdkGC *gc;
if (!style->bg_pixmap[state_type] ||
gdk_window_get_type (window) == GDK_WINDOW_PIXMAP) if (area)
{ {
gc = style->bg_gc[state_type];
old_rect.x = x; old_rect.x = x;
old_rect.y = y; old_rect.y = y;
old_rect.width = width; old_rect.width = width;
old_rect.height = height; old_rect.height = height;
if (area) if (!gdk_rectangle_intersect (area, &old_rect, &new_rect))
{ return;
if (gdk_rectangle_intersect (area, &old_rect, &new_rect))
gdk_draw_rectangle (window, gc, TRUE,
new_rect.x, new_rect.y, new_rect.width, new_rect.height);
}
else
gdk_draw_rectangle (window, gc, TRUE,
x, y, width, height);
} }
else if (!copy_area || style->bg_pixmap[state_type] == (GdkPixmap*) GDK_PARENT_RELATIVE) else
{ {
if (!copy_area) new_rect.x = x;
new_rect.y = y;
new_rect.width = width;
new_rect.height = height;
}
if (!style->bg_pixmap[state_type] ||
(gdk_window_get_type (window) == GDK_WINDOW_PIXMAP) ||
(!set_bg && (style->bg_pixmap[state_type] != (GdkPixmap *) GDK_PARENT_RELATIVE)))
{
GdkGC *gc = style->bg_gc[state_type];
if (style->bg_pixmap[state_type])
{
gdk_gc_set_fill (gc, GDK_TILED);
gdk_gc_set_tile (gc, style->bg_pixmap[state_type]);
}
gdk_draw_rectangle (window, gc, TRUE,
new_rect.x, new_rect.y, new_rect.width, new_rect.height);
if (style->bg_pixmap[state_type])
gdk_gc_set_fill (gc, GDK_SOLID);
}
else
{
if (set_bg)
{ {
if (style->bg_pixmap[state_type] == (GdkPixmap*) GDK_PARENT_RELATIVE) if (style->bg_pixmap[state_type] == (GdkPixmap*) GDK_PARENT_RELATIVE)
gdk_window_set_back_pixmap (window, NULL, TRUE); gdk_window_set_back_pixmap (window, NULL, TRUE);
@ -1133,32 +1148,9 @@ gtk_style_apply_default_background (GtkStyle *style,
gdk_window_set_back_pixmap (window, style->bg_pixmap[state_type], FALSE); gdk_window_set_back_pixmap (window, style->bg_pixmap[state_type], FALSE);
} }
old_rect.x = x; gdk_window_clear_area (window,
old_rect.y = y; new_rect.x, new_rect.y,
old_rect.width = width; new_rect.width, new_rect.height);
old_rect.height = height;
if (area && gdk_rectangle_intersect (area, &old_rect, &new_rect))
gdk_window_clear_area (window, new_rect.x, new_rect.y, new_rect.width, new_rect.height);
else
gdk_window_clear_area (window, x, y, width, height);
}
else
{
old_rect.x = x;
old_rect.y = y;
old_rect.width = width;
old_rect.height = height;
if (area && gdk_rectangle_intersect (area, &old_rect, &new_rect))
gdk_window_copy_area (window, style->bg_gc[state_type], new_rect.x, new_rect.y,
style->bg_pixmap[state_type], 0, 0, new_rect.width, new_rect.height);
else
{
gdk_window_clear_area (window, x, y, width, height);
gdk_window_copy_area (window, style->bg_gc[state_type], x, y,
style->bg_pixmap[state_type], 0, 0, width, height);
}
} }
} }
@ -1172,7 +1164,7 @@ gtk_style_apply_default_pixmap (GtkStyle *style,
gint width, gint width,
gint height) gint height)
{ {
gtk_style_apply_default_background (style, window, FALSE, state_type, gtk_style_apply_default_background (style, window, TRUE, state_type,
area, x, y, width, height); area, x, y, width, height);
} }
@ -2162,7 +2154,7 @@ gtk_default_draw_box (GtkStyle *style,
} }
else else
gtk_style_apply_default_background (style, window, gtk_style_apply_default_background (style, window,
widget && GTK_WIDGET_NO_WINDOW (widget), widget && !GTK_WIDGET_NO_WINDOW (widget),
state_type, area, x, y, width, height); state_type, area, x, y, width, height);
gtk_paint_shadow (style, window, state_type, shadow_type, area, widget, detail, gtk_paint_shadow (style, window, state_type, shadow_type, area, widget, detail,
@ -2222,7 +2214,7 @@ gtk_default_draw_flat_box (GtkStyle *style,
} }
else else
gtk_style_apply_default_background (style, window, gtk_style_apply_default_background (style, window,
widget && GTK_WIDGET_NO_WINDOW (widget), widget && !GTK_WIDGET_NO_WINDOW (widget),
state_type, area, x, y, width, height); state_type, area, x, y, width, height);
} }
@ -2559,7 +2551,7 @@ gtk_default_draw_box_gap (GtkStyle *style,
g_return_if_fail (window != NULL); g_return_if_fail (window != NULL);
gtk_style_apply_default_background (style, window, gtk_style_apply_default_background (style, window,
widget && GTK_WIDGET_NO_WINDOW (widget), widget && !GTK_WIDGET_NO_WINDOW (widget),
state_type, area, x, y, width, height); state_type, area, x, y, width, height);
if ((width == -1) && (height == -1)) if ((width == -1) && (height == -1))
@ -2781,7 +2773,7 @@ gtk_default_draw_extension (GtkStyle *style,
g_return_if_fail (window != NULL); g_return_if_fail (window != NULL);
gtk_style_apply_default_background (style, window, gtk_style_apply_default_background (style, window,
widget && GTK_WIDGET_NO_WINDOW (widget), widget && !GTK_WIDGET_NO_WINDOW (widget),
GTK_STATE_NORMAL, area, x, y, width, height); GTK_STATE_NORMAL, area, x, y, width, height);
if ((width == -1) && (height == -1)) if ((width == -1) && (height == -1))
@ -2838,7 +2830,7 @@ gtk_default_draw_extension (GtkStyle *style,
{ {
case GTK_POS_TOP: case GTK_POS_TOP:
gtk_style_apply_default_background (style, window, gtk_style_apply_default_background (style, window,
widget && GTK_WIDGET_NO_WINDOW (widget), widget && !GTK_WIDGET_NO_WINDOW (widget),
state_type, area, state_type, area,
x + style->klass->xthickness, x + style->klass->xthickness,
y, y,
@ -2860,7 +2852,7 @@ gtk_default_draw_extension (GtkStyle *style,
break; break;
case GTK_POS_BOTTOM: case GTK_POS_BOTTOM:
gtk_style_apply_default_background (style, window, gtk_style_apply_default_background (style, window,
widget && GTK_WIDGET_NO_WINDOW (widget), widget && !GTK_WIDGET_NO_WINDOW (widget),
state_type, area, state_type, area,
x + style->klass->xthickness, x + style->klass->xthickness,
y + style->klass->ythickness, y + style->klass->ythickness,
@ -2882,7 +2874,7 @@ gtk_default_draw_extension (GtkStyle *style,
break; break;
case GTK_POS_LEFT: case GTK_POS_LEFT:
gtk_style_apply_default_background (style, window, gtk_style_apply_default_background (style, window,
widget && GTK_WIDGET_NO_WINDOW (widget), widget && !GTK_WIDGET_NO_WINDOW (widget),
state_type, area, state_type, area,
x, x,
y + style->klass->ythickness, y + style->klass->ythickness,
@ -2904,7 +2896,7 @@ gtk_default_draw_extension (GtkStyle *style,
break; break;
case GTK_POS_RIGHT: case GTK_POS_RIGHT:
gtk_style_apply_default_background (style, window, gtk_style_apply_default_background (style, window,
widget && GTK_WIDGET_NO_WINDOW (widget), widget && !GTK_WIDGET_NO_WINDOW (widget),
state_type, area, state_type, area,
x + style->klass->xthickness, x + style->klass->xthickness,
y + style->klass->ythickness, y + style->klass->ythickness,

View File

@ -344,7 +344,7 @@ void gtk_style_set_background (GtkStyle *style,
GtkStateType state_type); GtkStateType state_type);
void gtk_style_apply_default_background (GtkStyle *style, void gtk_style_apply_default_background (GtkStyle *style,
GdkWindow *window, GdkWindow *window,
gboolean copy_area, gboolean set_bg,
GtkStateType state_type, GtkStateType state_type,
GdkRectangle *area, GdkRectangle *area,
gint x, gint x,