Commit 8d833752 authored by Owen Taylor's avatar Owen Taylor Committed by Owen Taylor

Implement PANGO_UNDERLINE_ERROR (Based on a patch by Nicolas Setton,

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.
parent 462ede8f
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> Sun Feb 29 19:04:33 2004 Soeren Sandmann <sandmann@daimi.au.dk>
* gtk/gtkrange.c (_gtk_range_get_wheel_delta): New internal * gtk/gtkrange.c (_gtk_range_get_wheel_delta): New internal
......
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> Sun Feb 29 19:04:33 2004 Soeren Sandmann <sandmann@daimi.au.dk>
* gtk/gtkrange.c (_gtk_range_get_wheel_delta): New internal * gtk/gtkrange.c (_gtk_range_get_wheel_delta): New internal
......
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> Sun Feb 29 19:04:33 2004 Soeren Sandmann <sandmann@daimi.au.dk>
* gtk/gtkrange.c (_gtk_range_get_wheel_delta): New internal * gtk/gtkrange.c (_gtk_range_get_wheel_delta): New internal
......
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> Sun Feb 29 19:04:33 2004 Soeren Sandmann <sandmann@daimi.au.dk>
* gtk/gtkrange.c (_gtk_range_get_wheel_delta): New internal * gtk/gtkrange.c (_gtk_range_get_wheel_delta): New internal
......
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> Sun Feb 29 19:04:33 2004 Soeren Sandmann <sandmann@daimi.au.dk>
* gtk/gtkrange.c (_gtk_range_get_wheel_delta): New internal * gtk/gtkrange.c (_gtk_range_get_wheel_delta): New internal
......
...@@ -186,6 +186,25 @@ draw_underline (GdkDrawable *drawable, ...@@ -186,6 +186,25 @@ draw_underline (GdkDrawable *drawable,
start_x, baseline_y + 1, start_x, baseline_y + 1,
end_x, baseline_y + 1); end_x, baseline_y + 1);
break; 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: case PANGO_UNDERLINE_LOW:
gdk_draw_line (drawable, gc, gdk_draw_line (drawable, gc,
start_x, low_y + 1, start_x, low_y + 1,
......
...@@ -92,6 +92,7 @@ struct _GtkTextRenderState ...@@ -92,6 +92,7 @@ struct _GtkTextRenderState
GtkTextAppearance *last_bg_appearance; GtkTextAppearance *last_bg_appearance;
GdkGC *fg_gc; GdkGC *fg_gc;
GdkGC *bg_gc; GdkGC *bg_gc;
GdkGC *error_gc;
GdkRectangle clip_rect; GdkRectangle clip_rect;
}; };
...@@ -116,6 +117,7 @@ gtk_text_render_state_new (GtkWidget *widget, ...@@ -116,6 +117,7 @@ gtk_text_render_state_new (GtkWidget *widget,
state->widget = widget; state->widget = widget;
state->fg_gc = gdk_gc_new (drawable); state->fg_gc = gdk_gc_new (drawable);
state->bg_gc = gdk_gc_new (drawable); state->bg_gc = gdk_gc_new (drawable);
state->clip_rect = *clip_rect; state->clip_rect = *clip_rect;
return state; return state;
...@@ -126,6 +128,8 @@ gtk_text_render_state_destroy (GtkTextRenderState *state) ...@@ -126,6 +128,8 @@ gtk_text_render_state_destroy (GtkTextRenderState *state)
{ {
g_object_unref (state->fg_gc); g_object_unref (state->fg_gc);
g_object_unref (state->bg_gc); g_object_unref (state->bg_gc);
if (state->error_gc)
g_object_unref (state->error_gc);
g_free (state); g_free (state);
} }
...@@ -204,6 +208,36 @@ gtk_text_render_state_update (GtkTextRenderState *state, ...@@ -204,6 +208,36 @@ gtk_text_render_state_update (GtkTextRenderState *state,
state->last_appearance = new_appearance; 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 static void
get_shape_extents (PangoLayoutRun *run, get_shape_extents (PangoLayoutRun *run,
PangoRectangle *ink_rect, PangoRectangle *ink_rect,
...@@ -423,6 +457,29 @@ render_layout_line (GdkDrawable *drawable, ...@@ -423,6 +457,29 @@ render_layout_line (GdkDrawable *drawable,
x + (x_off + ink_rect.x + ink_rect.width) / PANGO_SCALE, x + (x_off + ink_rect.x + ink_rect.width) / PANGO_SCALE,
risen_y + 1); risen_y + 1);
break; 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: case PANGO_UNDERLINE_LOW:
g_assert (need_ink); g_assert (need_ink);
gdk_draw_line (drawable, fg_gc, gdk_draw_line (drawable, fg_gc,
......
...@@ -675,6 +675,16 @@ gtk_text_view_class_init (GtkTextViewClass *klass) ...@@ -675,6 +675,16 @@ gtk_text_view_class_init (GtkTextViewClass *klass)
TRUE, TRUE,
G_PARAM_READWRITE)); 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 * Signals
*/ */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment