style: Replace draw_diamond vfunc with Cairo calls

This commit is contained in:
Benjamin Otte
2010-07-15 00:35:15 +02:00
parent 8f21b09eee
commit 5eb76955fd

View File

@ -2483,68 +2483,61 @@ gtk_default_draw_diamond (GtkStyle *style,
{ {
gint half_width; gint half_width;
gint half_height; gint half_height;
GdkGC *outer_nw = NULL; GdkColor *outer_nw = NULL;
GdkGC *outer_ne = NULL; GdkColor *outer_ne = NULL;
GdkGC *outer_sw = NULL; GdkColor *outer_sw = NULL;
GdkGC *outer_se = NULL; GdkColor *outer_se = NULL;
GdkGC *middle_nw = NULL; GdkColor *middle_nw = NULL;
GdkGC *middle_ne = NULL; GdkColor *middle_ne = NULL;
GdkGC *middle_sw = NULL; GdkColor *middle_sw = NULL;
GdkGC *middle_se = NULL; GdkColor *middle_se = NULL;
GdkGC *inner_nw = NULL; GdkColor *inner_nw = NULL;
GdkGC *inner_ne = NULL; GdkColor *inner_ne = NULL;
GdkGC *inner_sw = NULL; GdkColor *inner_sw = NULL;
GdkGC *inner_se = NULL; GdkColor *inner_se = NULL;
cairo_t *cr;
sanitize_size (window, &width, &height); sanitize_size (window, &width, &height);
half_width = width / 2; half_width = width / 2;
half_height = height / 2; half_height = height / 2;
if (area)
{
gdk_gc_set_clip_rectangle (style->light_gc[state_type], area);
gdk_gc_set_clip_rectangle (style->bg_gc[state_type], area);
gdk_gc_set_clip_rectangle (style->dark_gc[state_type], area);
gdk_gc_set_clip_rectangle (style->black_gc, area);
}
switch (shadow_type) switch (shadow_type)
{ {
case GTK_SHADOW_IN: case GTK_SHADOW_IN:
inner_sw = inner_se = style->bg_gc[state_type]; inner_sw = inner_se = &style->bg[state_type];
middle_sw = middle_se = style->light_gc[state_type]; middle_sw = middle_se = &style->light[state_type];
outer_sw = outer_se = style->light_gc[state_type]; outer_sw = outer_se = &style->light[state_type];
inner_nw = inner_ne = style->black_gc; inner_nw = inner_ne = &style->black;
middle_nw = middle_ne = style->dark_gc[state_type]; middle_nw = middle_ne = &style->dark[state_type];
outer_nw = outer_ne = style->dark_gc[state_type]; outer_nw = outer_ne = &style->dark[state_type];
break; break;
case GTK_SHADOW_OUT: case GTK_SHADOW_OUT:
inner_sw = inner_se = style->dark_gc[state_type]; inner_sw = inner_se = &style->dark[state_type];
middle_sw = middle_se = style->dark_gc[state_type]; middle_sw = middle_se = &style->dark[state_type];
outer_sw = outer_se = style->black_gc; outer_sw = outer_se = &style->black;
inner_nw = inner_ne = style->bg_gc[state_type]; inner_nw = inner_ne = &style->bg[state_type];
middle_nw = middle_ne = style->light_gc[state_type]; middle_nw = middle_ne = &style->light[state_type];
outer_nw = outer_ne = style->light_gc[state_type]; outer_nw = outer_ne = &style->light[state_type];
break; break;
case GTK_SHADOW_ETCHED_IN: case GTK_SHADOW_ETCHED_IN:
inner_sw = inner_se = style->bg_gc[state_type]; inner_sw = inner_se = &style->bg[state_type];
middle_sw = middle_se = style->dark_gc[state_type]; middle_sw = middle_se = &style->dark[state_type];
outer_sw = outer_se = style->light_gc[state_type]; outer_sw = outer_se = &style->light[state_type];
inner_nw = inner_ne = style->bg_gc[state_type]; inner_nw = inner_ne = &style->bg[state_type];
middle_nw = middle_ne = style->light_gc[state_type]; middle_nw = middle_ne = &style->light[state_type];
outer_nw = outer_ne = style->dark_gc[state_type]; outer_nw = outer_ne = &style->dark[state_type];
break; break;
case GTK_SHADOW_ETCHED_OUT: case GTK_SHADOW_ETCHED_OUT:
inner_sw = inner_se = style->bg_gc[state_type]; inner_sw = inner_se = &style->bg[state_type];
middle_sw = middle_se = style->light_gc[state_type]; middle_sw = middle_se = &style->light[state_type];
outer_sw = outer_se = style->dark_gc[state_type]; outer_sw = outer_se = &style->dark[state_type];
inner_nw = inner_ne = style->bg_gc[state_type]; inner_nw = inner_ne = &style->bg[state_type];
middle_nw = middle_ne = style->dark_gc[state_type]; middle_nw = middle_ne = &style->dark[state_type];
outer_nw = outer_ne = style->light_gc[state_type]; outer_nw = outer_ne = &style->light[state_type];
break; break;
default: default:
@ -2552,54 +2545,55 @@ gtk_default_draw_diamond (GtkStyle *style,
break; break;
} }
cr = gdk_cairo_create (window);
if (area)
{
gdk_cairo_rectangle (cr, area);
cairo_clip (cr);
}
if (inner_sw) if (inner_sw)
{ {
gdk_draw_line (window, inner_sw, _cairo_draw_line (cr, inner_sw,
x + 2, y + half_height, x + 2, y + half_height,
x + half_width, y + height - 2); x + half_width, y + height - 2);
gdk_draw_line (window, inner_se, _cairo_draw_line (cr, inner_se,
x + half_width, y + height - 2, x + half_width, y + height - 2,
x + width - 2, y + half_height); x + width - 2, y + half_height);
gdk_draw_line (window, middle_sw, _cairo_draw_line (cr, middle_sw,
x + 1, y + half_height, x + 1, y + half_height,
x + half_width, y + height - 1); x + half_width, y + height - 1);
gdk_draw_line (window, middle_se, _cairo_draw_line (cr, middle_se,
x + half_width, y + height - 1, x + half_width, y + height - 1,
x + width - 1, y + half_height); x + width - 1, y + half_height);
gdk_draw_line (window, outer_sw, _cairo_draw_line (cr, outer_sw,
x, y + half_height, x, y + half_height,
x + half_width, y + height); x + half_width, y + height);
gdk_draw_line (window, outer_se, _cairo_draw_line (cr, outer_se,
x + half_width, y + height, x + half_width, y + height,
x + width, y + half_height); x + width, y + half_height);
gdk_draw_line (window, inner_nw, _cairo_draw_line (cr, inner_nw,
x + 2, y + half_height, x + 2, y + half_height,
x + half_width, y + 2); x + half_width, y + 2);
gdk_draw_line (window, inner_ne, _cairo_draw_line (cr, inner_ne,
x + half_width, y + 2, x + half_width, y + 2,
x + width - 2, y + half_height); x + width - 2, y + half_height);
gdk_draw_line (window, middle_nw, _cairo_draw_line (cr, middle_nw,
x + 1, y + half_height, x + 1, y + half_height,
x + half_width, y + 1); x + half_width, y + 1);
gdk_draw_line (window, middle_ne, _cairo_draw_line (cr, middle_ne,
x + half_width, y + 1, x + half_width, y + 1,
x + width - 1, y + half_height); x + width - 1, y + half_height);
gdk_draw_line (window, outer_nw, _cairo_draw_line (cr, outer_nw,
x, y + half_height, x, y + half_height,
x + half_width, y); x + half_width, y);
gdk_draw_line (window, outer_ne, _cairo_draw_line (cr, outer_ne,
x + half_width, y, x + half_width, y,
x + width, y + half_height); x + width, y + half_height);
} }
if (area) cairo_destroy (cr);
{
gdk_gc_set_clip_rectangle (style->light_gc[state_type], NULL);
gdk_gc_set_clip_rectangle (style->bg_gc[state_type], NULL);
gdk_gc_set_clip_rectangle (style->dark_gc[state_type], NULL);
gdk_gc_set_clip_rectangle (style->black_gc, NULL);
}
} }
static void static void