summaryrefslogtreecommitdiff
path: root/gtk/gtkwindow-decorate.c
diff options
context:
space:
mode:
authorBenjamin Otte <otte@redhat.com>2010-07-15 13:05:57 +0200
committerBenjamin Otte <otte@redhat.com>2010-07-26 16:42:47 +0200
commita8d805ffbc96abd1be47b034fda7b6e830d951cf (patch)
treeb3e003d75a032a5e68bbca1d1d844e88d174ebe1 /gtk/gtkwindow-decorate.c
parentff25b0dc20c64ca407a91974f192c60ebeaef79f (diff)
downloadgtk+-a8d805ffbc96abd1be47b034fda7b6e830d951cf.tar.gz
decorate: Draw decorations using Cairo
Patch is untested, is there an example using this?
Diffstat (limited to 'gtk/gtkwindow-decorate.c')
-rw-r--r--gtk/gtkwindow-decorate.c64
1 files changed, 31 insertions, 33 deletions
diff --git a/gtk/gtkwindow-decorate.c b/gtk/gtkwindow-decorate.c
index 2d671ab08c..fae32939a9 100644
--- a/gtk/gtkwindow-decorate.c
+++ b/gtk/gtkwindow-decorate.c
@@ -593,6 +593,7 @@ gtk_decorated_window_paint (GtkWidget *widget,
GtkWindowDecoration *deco = get_decoration (window);
gint x1, y1, x2, y2;
GtkStateType border_state;
+ cairo_t *cr;
if (deco->decorated)
{
@@ -638,6 +639,16 @@ gtk_decorated_window_paint (GtkWidget *widget,
DECORATION_BORDER_LEFT - 2, DECORATION_BORDER_TOP - 2,
width - (DECORATION_BORDER_LEFT + DECORATION_BORDER_RIGHT) + 3,
height - (DECORATION_BORDER_TOP + DECORATION_BORDER_BOTTOM) + 3);
+
+ cr = gdk_cairo_create (frame);
+ cairo_set_line_width (cr, 1.0);
+ cairo_set_line_cap (cr, CAIRO_LINE_CAP_SQUARE);
+
+ if (area)
+ {
+ gdk_cairo_rectangle (cr, &area);
+ cairo_clip (cr);
+ }
if (deco->maximizable)
{
@@ -648,20 +659,16 @@ gtk_decorated_window_paint (GtkWidget *widget,
x2 = x1 + DECORATION_BUTTON_SIZE;
y2 = y1 + DECORATION_BUTTON_SIZE;
- if (area)
- gdk_gc_set_clip_rectangle (widget->style->bg_gc[widget->state], area);
-
- gdk_draw_rectangle (frame, widget->style->bg_gc[widget->state], TRUE,
- x1, y1, x2 - x1, y2 - y1);
+ gdk_cairo_set_source_color (cr, &widget->style->bg[widget->state]);
+ cairo_rectangle (cr, x1, y1, x2 - x1, y2 - y1);
+ cairo_fill (cr);
- gdk_draw_line (frame, widget->style->black_gc, x1 + 1, y1 + 1, x2 - 2, y1 + 1);
-
- gdk_draw_rectangle (frame, widget->style->black_gc, FALSE,
- x1 + 1, y1 + 2,
- DECORATION_BUTTON_SIZE - 3, DECORATION_BUTTON_SIZE - 4);
-
- if (area)
- gdk_gc_set_clip_rectangle (widget->style->black_gc, NULL);
+ gdk_cairo_set_source_rgb (cr, 0, 0, 0);
+ cairo_rectangle (cr, x1 + 1, y1 + 1, x2 - x1 - 3, 1);
+ cairo_move_to (cr, x1 + 1.5, y1 + 1.5);
+ cairo_line_to (cr, x2 - 1.5, y1 + 1.5);
+ cairo_rectangle (cr, x1 + 1.5, y1 + 2.5, DECORATION_BUTTON_SIZE - 3, DECORATION_BUTTON_SIZE - 4);
+ cairo_stroke (cr);
}
/* Close button: */
@@ -671,26 +678,16 @@ gtk_decorated_window_paint (GtkWidget *widget,
x2 = width - DECORATION_BORDER_LEFT;
y2 = DECORATION_BUTTON_Y_OFFSET + DECORATION_BUTTON_SIZE;
- if (area)
- gdk_gc_set_clip_rectangle (widget->style->bg_gc[widget->state], area);
-
- gdk_draw_rectangle (frame, widget->style->bg_gc[widget->state], TRUE,
- x1, y1, x2 - x1, y2 - y1);
+ gdk_cairo_set_source_color (cr, &widget->style->bg[widget->state]);
+ cairo_rectangle (cr, x1, y1, x2 - x1, y2 - y1);
+ cairo_fill (cr);
- if (area)
- gdk_gc_set_clip_rectangle (widget->style->bg_gc[widget->state], NULL);
-
- if (area)
- gdk_gc_set_clip_rectangle (widget->style->black_gc, area);
-
- gdk_draw_line (frame, widget->style->black_gc, x1, y1, x2-1, y2-1);
-
- gdk_draw_line (frame, widget->style->black_gc, x1, y2-1, x2-1, y1);
-
- if (area)
- gdk_gc_set_clip_rectangle (widget->style->black_gc, NULL);
-
-
+ /* draw an X */
+ cairo_move_to (cr, x1 + 0.5, y1 + 0.5);
+ cairo_line_to (cr, x2 - 0.5, y2 - 0.5);
+ cairo_move_to (cr, x1 + 0.5, y2 - 0.5);
+ cairo_line_to (cr, x2 - 0.5, y1 + 0.5);
+ cairo_stroke (cr);
/* Title */
if (deco->title_layout)
@@ -705,7 +702,8 @@ gtk_decorated_window_paint (GtkWidget *widget,
if (area)
gdk_gc_set_clip_rectangle (widget->style->fg_gc [border_state], NULL);
}
-
+
+ cairo_destroy (cr);
}
}