]> Pileus Git - ~andy/gtk/commitdiff
Implement PANGO_UNDERLINE_ERROR (Based on a patch by Nicolas Setton,
authorOwen Taylor <otaylor@redhat.com>
Sun, 29 Feb 2004 21:39:18 +0000 (21:39 +0000)
committerOwen Taylor <otaylor@src.gnome.org>
Sun, 29 Feb 2004 21:39:18 +0000 (21:39 +0000)
Sun Feb 29 16:35:23 2004  Owen Taylor  <otaylor@redhat.com>

        * gdk/gdkpango.c gtk/gtktextdisplay.c: Implement
        PANGO_UNDERLINE_ERROR (Based on a patch by
        Nicolas Setton, #114237)

        * gtk/gtktextview.c: Add a error-underline-color style
        property.

ChangeLog
ChangeLog.pre-2-10
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
gdk/gdkpango.c
gtk/gtktextdisplay.c
gtk/gtktextview.c

index 7a23521f9d970eb6f5a1bb88d5c69e32ae9d1e14..5dd31ede6bd9e385426b24ff4faa995dc087eaa2 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+Sun Feb 29 16:35:23 2004  Owen Taylor  <otaylor@redhat.com>
+
+       * gdk/gdkpango.c gtk/gtktextdisplay.c: Implement
+       PANGO_UNDERLINE_ERROR (Based on a patch by
+       Nicolas Setton, #114237)
+
+       * gtk/gtktextview.c: Add a error-underline-color style
+       property.
+
 Sun Feb 29 19:04:33 2004  Soeren Sandmann  <sandmann@daimi.au.dk>
 
        * gtk/gtkrange.c (_gtk_range_get_wheel_delta): New internal
index 7a23521f9d970eb6f5a1bb88d5c69e32ae9d1e14..5dd31ede6bd9e385426b24ff4faa995dc087eaa2 100644 (file)
@@ -1,3 +1,12 @@
+Sun Feb 29 16:35:23 2004  Owen Taylor  <otaylor@redhat.com>
+
+       * gdk/gdkpango.c gtk/gtktextdisplay.c: Implement
+       PANGO_UNDERLINE_ERROR (Based on a patch by
+       Nicolas Setton, #114237)
+
+       * gtk/gtktextview.c: Add a error-underline-color style
+       property.
+
 Sun Feb 29 19:04:33 2004  Soeren Sandmann  <sandmann@daimi.au.dk>
 
        * gtk/gtkrange.c (_gtk_range_get_wheel_delta): New internal
index 7a23521f9d970eb6f5a1bb88d5c69e32ae9d1e14..5dd31ede6bd9e385426b24ff4faa995dc087eaa2 100644 (file)
@@ -1,3 +1,12 @@
+Sun Feb 29 16:35:23 2004  Owen Taylor  <otaylor@redhat.com>
+
+       * gdk/gdkpango.c gtk/gtktextdisplay.c: Implement
+       PANGO_UNDERLINE_ERROR (Based on a patch by
+       Nicolas Setton, #114237)
+
+       * gtk/gtktextview.c: Add a error-underline-color style
+       property.
+
 Sun Feb 29 19:04:33 2004  Soeren Sandmann  <sandmann@daimi.au.dk>
 
        * gtk/gtkrange.c (_gtk_range_get_wheel_delta): New internal
index 7a23521f9d970eb6f5a1bb88d5c69e32ae9d1e14..5dd31ede6bd9e385426b24ff4faa995dc087eaa2 100644 (file)
@@ -1,3 +1,12 @@
+Sun Feb 29 16:35:23 2004  Owen Taylor  <otaylor@redhat.com>
+
+       * gdk/gdkpango.c gtk/gtktextdisplay.c: Implement
+       PANGO_UNDERLINE_ERROR (Based on a patch by
+       Nicolas Setton, #114237)
+
+       * gtk/gtktextview.c: Add a error-underline-color style
+       property.
+
 Sun Feb 29 19:04:33 2004  Soeren Sandmann  <sandmann@daimi.au.dk>
 
        * gtk/gtkrange.c (_gtk_range_get_wheel_delta): New internal
index 7a23521f9d970eb6f5a1bb88d5c69e32ae9d1e14..5dd31ede6bd9e385426b24ff4faa995dc087eaa2 100644 (file)
@@ -1,3 +1,12 @@
+Sun Feb 29 16:35:23 2004  Owen Taylor  <otaylor@redhat.com>
+
+       * gdk/gdkpango.c gtk/gtktextdisplay.c: Implement
+       PANGO_UNDERLINE_ERROR (Based on a patch by
+       Nicolas Setton, #114237)
+
+       * gtk/gtktextview.c: Add a error-underline-color style
+       property.
+
 Sun Feb 29 19:04:33 2004  Soeren Sandmann  <sandmann@daimi.au.dk>
 
        * gtk/gtkrange.c (_gtk_range_get_wheel_delta): New internal
index 24ec81b61559e919cdf0ec5b3a4fcdd6a878355b..35a0a49685bc1c63118ba13088ac889399d744b5 100644 (file)
@@ -186,6 +186,25 @@ draw_underline (GdkDrawable    *drawable,
                     start_x, baseline_y + 1,
                     end_x,   baseline_y + 1);
       break;
+    case PANGO_UNDERLINE_ERROR:
+      {
+        int point_x, point_y;
+        int counter = 0;
+
+        for (point_x = start_x;
+             point_x <= end_x;
+             point_x += 2)
+         {
+           point_y = counter ? baseline_y + 1 : baseline_y + 2;
+           
+           gdk_draw_line (drawable, gc,
+                          point_x, point_y,
+                          MIN (point_x + 1, end_x), point_y);
+           
+           counter = (counter + 1) % 2;
+         }
+      }
+      break;
     case PANGO_UNDERLINE_LOW:
       gdk_draw_line (drawable, gc,
                     start_x, low_y + 1,
index f5937298bea9823bf32a45d3cd5b2e0cdd6d0dc3..889b62171dd60345838f964e63b918cebc95ed65 100644 (file)
@@ -92,6 +92,7 @@ struct _GtkTextRenderState
   GtkTextAppearance *last_bg_appearance;
   GdkGC *fg_gc;
   GdkGC *bg_gc;
+  GdkGC *error_gc;
   GdkRectangle clip_rect;
 };
 
@@ -116,6 +117,7 @@ gtk_text_render_state_new (GtkWidget    *widget,
   state->widget = widget;
   state->fg_gc = gdk_gc_new (drawable);
   state->bg_gc = gdk_gc_new (drawable);
+
   state->clip_rect = *clip_rect;
 
   return state;
@@ -126,6 +128,8 @@ gtk_text_render_state_destroy (GtkTextRenderState *state)
 {
   g_object_unref (state->fg_gc);
   g_object_unref (state->bg_gc);
+  if (state->error_gc)
+    g_object_unref (state->error_gc);
 
   g_free (state);
 }
@@ -204,6 +208,36 @@ gtk_text_render_state_update (GtkTextRenderState *state,
   state->last_appearance = new_appearance;
 }
 
+static GdkGC *
+gtk_text_render_state_get_error_gc (GtkTextRenderState *state)
+{
+  if (!state->error_gc)
+    {
+      static const GdkColor red = { 0, 0xffff, 0, 0 };
+      
+      GdkGCValues gc_values;
+      GdkGCValuesMask gc_values_mask;
+      GdkColor *underline_color;
+      GtkWidget *widget = state->widget;
+
+      gtk_widget_style_get (widget, "error-underline_color", &underline_color, NULL);
+      
+      gc_values_mask = GDK_GC_FOREGROUND;
+      if (underline_color)
+       {
+         gc_values.foreground = *underline_color;
+         gdk_color_free (underline_color);
+       }
+      else
+       gc_values.foreground = red;
+      
+      gdk_rgb_find_color (widget->style->colormap, &gc_values.foreground);
+      state->error_gc = gdk_gc_new_with_values (widget->window, &gc_values, gc_values_mask);
+    }
+
+  return state->error_gc;
+}
+
 static void
 get_shape_extents (PangoLayoutRun *run,
                    PangoRectangle *ink_rect,
@@ -423,6 +457,29 @@ render_layout_line (GdkDrawable        *drawable,
                          x + (x_off + ink_rect.x + ink_rect.width) / PANGO_SCALE,
                          risen_y + 1);
           break;
+        case PANGO_UNDERLINE_ERROR:
+          g_assert (need_ink);
+          {
+           GdkGC *error_gc = gtk_text_render_state_get_error_gc (render_state);
+
+            int point_x, point_y;
+            int counter = 0;
+           int end_x = x + (x_off + ink_rect.x + ink_rect.width) / PANGO_SCALE;
+
+            for (point_x = x + (x_off + ink_rect.x) / PANGO_SCALE - 1;
+                 point_x <= end_x;
+                 point_x += 2)
+             {
+               point_y = counter ? risen_y + 1 : risen_y + 2;
+               
+               gdk_draw_line (drawable, error_gc,
+                              point_x, point_y,
+                              MIN (point_x + 1, end_x), point_y);
+               
+               counter = (counter + 1) % 2;
+             }
+          }
+          break;
         case PANGO_UNDERLINE_LOW:
           g_assert (need_ink);
           gdk_draw_line (drawable, fg_gc,
index 7609831225ac414c04f271accb7e5c8c5d49ca48..a1e9377473ba89326f5083bc2fc6b4002413b501 100644 (file)
@@ -675,6 +675,16 @@ gtk_text_view_class_init (GtkTextViewClass *klass)
                                                         TRUE,
                                                         G_PARAM_READWRITE));
 
+  /*
+   * Style properties
+   */
+  gtk_widget_class_install_style_property (widget_class,
+                                          g_param_spec_boxed ("error-underline-color",
+                                                              P_("Error Underline Color"),
+                                                              P_("Color with which to error-indication underlines"),
+                                                              GDK_TYPE_COLOR,
+                                                              G_PARAM_READABLE));
+  
   /*
    * Signals
    */