[gnome-games/gnome-2-32] aisleriot: Set dash pattern when drawing focus rectangle



commit 1130c0df06b9c6da90390f2968d89efc9779ec70
Author: Christian Persch <chpe gnome org>
Date:   Sun Aug 29 21:05:40 2010 +0200

    aisleriot: Set dash pattern when drawing focus rectangle
    
    Code adapted from gtkstyle.c.

 aisleriot/board-noclutter.c |   25 +++++++++++++++++++++++--
 1 files changed, 23 insertions(+), 2 deletions(-)
---
diff --git a/aisleriot/board-noclutter.c b/aisleriot/board-noclutter.c
index 39b12bd..a8b831e 100644
--- a/aisleriot/board-noclutter.c
+++ b/aisleriot/board-noclutter.c
@@ -3436,6 +3436,7 @@ draw_focus:
                   gtk_widget_has_focus (widget))) {
     GdkRectangle focus_rect;
     double line_width;
+    gint8 *line_pattern = NULL;
 
     /* Check whether this needs to be drawn */
 #ifdef OPTIMISED_EXPOSE
@@ -3458,15 +3459,35 @@ draw_focus:
                                  &focus_rect);
     }
 
+    cairo_save (cr);
     line_width = ar_style_get_focus_line_width (priv->style);
-    cairo_set_source_rgb (cr, 1., 1., 1.); /* FIXME focus line colour? */
-    cairo_set_line_width (cr, line_width);
     cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
+    cairo_set_line_width (cr, line_width);
+    gdk_cairo_set_source_color (cr, &gtk_widget_get_style (widget)->fg[gtk_widget_get_state (widget)]);
+
+    gtk_widget_style_get (widget, "focus-line-pattern", &line_pattern, NULL);
+    if (line_pattern && line_pattern[0]) {
+      int i, n_dashes; 
+      double *dashes;
+
+      n_dashes = strlen ((char *) line_pattern);
+      dashes = g_newa (double, n_dashes);
+      for (i = 0; i < n_dashes; i++)
+        dashes[i] = (double) line_pattern[i];
+
+      cairo_set_dash (cr, dashes, n_dashes, - line_width / 2.);
+    } else {
+      static const double dashes[] = { 1., 1. };
+
+      cairo_set_dash (cr, dashes, G_N_ELEMENTS (dashes), - line_width / 2.);
+    }
+    g_free (line_pattern);
 
     cairo_rectangle (cr,
                      focus_rect.x + line_width / 2., focus_rect.y + line_width / 2.,
                      focus_rect.width - line_width, focus_rect.height - line_width);
     cairo_stroke (cr);
+    cairo_restore (cr);
   }
 
 #ifdef OPTIMISED_EXPOSE



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]