diff options
author | Chris Lahey <clahey@umich.edu> | 2000-02-28 17:03:20 +0800 |
---|---|---|
committer | Chris Lahey <clahey@src.gnome.org> | 2000-02-28 17:03:20 +0800 |
commit | 486e3906ec0be1b28f7a5122ff882e894df02f5f (patch) | |
tree | 1973d11bb7312f2c3019eed28c99c0b1521a8c49 /widgets/e-text | |
parent | 32646815a482886c48a779690acefdcf0e7f5980 (diff) | |
download | gsoc2013-evolution-486e3906ec0be1b28f7a5122ff882e894df02f5f.tar gsoc2013-evolution-486e3906ec0be1b28f7a5122ff882e894df02f5f.tar.gz gsoc2013-evolution-486e3906ec0be1b28f7a5122ff882e894df02f5f.tar.bz2 gsoc2013-evolution-486e3906ec0be1b28f7a5122ff882e894df02f5f.tar.lz gsoc2013-evolution-486e3906ec0be1b28f7a5122ff882e894df02f5f.tar.xz gsoc2013-evolution-486e3906ec0be1b28f7a5122ff882e894df02f5f.tar.zst gsoc2013-evolution-486e3906ec0be1b28f7a5122ff882e894df02f5f.zip |
Updated these to use the canvas ::update system properly.
2000-02-28 Chris Lahey <clahey@umich.edu>
* widgets/e-text/e-text.c, widgets/e-text/e-text.h: Updated these
to use the canvas ::update system properly.
svn path=/trunk/; revision=1972
Diffstat (limited to 'widgets/e-text')
-rw-r--r-- | widgets/e-text/e-text.c | 131 | ||||
-rw-r--r-- | widgets/e-text/e-text.h | 5 |
2 files changed, 72 insertions, 64 deletions
diff --git a/widgets/e-text/e-text.c b/widgets/e-text/e-text.c index 6647531eee..74cbf0fe8b 100644 --- a/widgets/e-text/e-text.c +++ b/widgets/e-text/e-text.c @@ -540,22 +540,6 @@ get_bounds (EText *text, double *px1, double *py1, double *px2, double *py2) } } -/* Recalculates the bounding box of the text item. The bounding box is defined - * by the text's extents if the clip rectangle is disabled. If it is enabled, - * the bounding box is defined by the clip rectangle itself. - */ -static void -recalc_bounds (EText *text) -{ - GnomeCanvasItem *item; - - item = GNOME_CANVAS_ITEM (text); - - get_bounds (text, &item->x1, &item->y1, &item->x2, &item->y2); - - gnome_canvas_group_child_bounds (GNOME_CANVAS_GROUP (item->parent), item); -} - static void calc_ellipsis (EText *text) { @@ -814,18 +798,17 @@ e_text_set_arg (GtkObject *object, GtkArg *arg, guint arg_id) g_free (text->text); text->text = g_strdup (GTK_VALUE_STRING (*arg)); - split_into_lines (text); - recalc_bounds (text); + text->needs_split_into_lines = 1; break; case ARG_X: text->x = GTK_VALUE_DOUBLE (*arg); - recalc_bounds (text); + text->needs_recalc_bounds = 1; break; case ARG_Y: text->y = GTK_VALUE_DOUBLE (*arg); - recalc_bounds (text); + text->needs_recalc_bounds = 1; break; case ARG_FONT: @@ -843,10 +826,9 @@ e_text_set_arg (GtkObject *object, GtkArg *arg, guint arg_id) calc_ellipsis (text); if ( text->line_wrap ) - split_into_lines (text); + text->needs_split_into_lines = 1; else - calc_line_widths (text); - recalc_bounds (text); + text->needs_calc_line_widths = 1; break; case ARG_FONTSET: @@ -864,10 +846,9 @@ e_text_set_arg (GtkObject *object, GtkArg *arg, guint arg_id) calc_ellipsis (text); if ( text->line_wrap ) - split_into_lines (text); + text->needs_split_into_lines = 1; else - calc_line_widths (text); - recalc_bounds (text); + text->needs_calc_line_widths = 1; break; case ARG_FONT_GDK: @@ -885,54 +866,52 @@ e_text_set_arg (GtkObject *object, GtkArg *arg, guint arg_id) } calc_ellipsis (text); if ( text->line_wrap ) - split_into_lines (text); + text->needs_split_into_lines = 1; else - calc_line_widths (text); - recalc_bounds (text); + text->needs_calc_line_widths = 1; break; case ARG_ANCHOR: text->anchor = GTK_VALUE_ENUM (*arg); - recalc_bounds (text); + text->needs_recalc_bounds = 1; break; case ARG_JUSTIFICATION: text->justification = GTK_VALUE_ENUM (*arg); + text->needs_redraw = 1; break; case ARG_CLIP_WIDTH: text->clip_width = fabs (GTK_VALUE_DOUBLE (*arg)); calc_ellipsis (text); if ( text->line_wrap ) - split_into_lines (text); + text->needs_split_into_lines = 1; else - calc_line_widths (text); - recalc_bounds (text); + text->needs_calc_line_widths = 1; break; case ARG_CLIP_HEIGHT: text->clip_height = fabs (GTK_VALUE_DOUBLE (*arg)); - recalc_bounds (text); + text->needs_recalc_bounds = 1; break; case ARG_CLIP: text->clip = GTK_VALUE_BOOL (*arg); calc_ellipsis (text); if ( text->line_wrap ) - split_into_lines (text); + text->needs_split_into_lines = 1; else - calc_line_widths (text); - recalc_bounds (text); + text->needs_calc_line_widths = 1; break; case ARG_X_OFFSET: text->xofs = GTK_VALUE_DOUBLE (*arg); - recalc_bounds (text); + text->needs_recalc_bounds = 1; break; case ARG_Y_OFFSET: text->yofs = GTK_VALUE_DOUBLE (*arg); - recalc_bounds (text); + text->needs_recalc_bounds = 1; break; case ARG_FILL_COLOR: @@ -944,6 +923,7 @@ e_text_set_arg (GtkObject *object, GtkArg *arg, guint arg_id) (color.blue & 0xff00) | 0xff); color_changed = TRUE; + text->needs_redraw = 1; break; case ARG_FILL_COLOR_GDK: @@ -959,25 +939,28 @@ e_text_set_arg (GtkObject *object, GtkArg *arg, guint arg_id) (color.blue & 0xff00) | 0xff); color_changed = TRUE; + text->needs_redraw = 1; break; case ARG_FILL_COLOR_RGBA: text->rgba = GTK_VALUE_UINT (*arg); color_changed = TRUE; + text->needs_redraw = 1; break; case ARG_FILL_STIPPLE: set_stipple (text, GTK_VALUE_BOXED (*arg), FALSE); + text->needs_redraw = 1; break; case ARG_EDITABLE: text->editable = GTK_VALUE_BOOL (*arg); + text->needs_redraw = 1; break; case ARG_USE_ELLIPSIS: text->use_ellipsis = GTK_VALUE_BOOL (*arg); - calc_line_widths (text); - recalc_bounds (text); + text->needs_calc_line_widths = 1; break; case ARG_ELLIPSIS: @@ -986,24 +969,21 @@ e_text_set_arg (GtkObject *object, GtkArg *arg, guint arg_id) text->ellipsis = g_strdup (GTK_VALUE_STRING (*arg)); calc_ellipsis (text); - calc_line_widths (text); - recalc_bounds (text); + text->needs_calc_line_widths = 1; break; case ARG_LINE_WRAP: text->line_wrap = GTK_VALUE_BOOL (*arg); - split_into_lines (text); - recalc_bounds (text); + text->needs_split_into_lines = 1; break; case ARG_MAX_LINES: text->max_lines = GTK_VALUE_INT (*arg); - split_into_lines (text); - recalc_bounds (text); + text->needs_split_into_lines = 1; break; default: - break; + return; } if (color_changed) { @@ -1015,8 +995,9 @@ e_text_set_arg (GtkObject *object, GtkArg *arg, guint arg_id) if (!item->canvas->aa) set_text_gc_foreground (text); - gnome_canvas_item_request_update (item); } + + gnome_canvas_item_request_update (item); } /* Get_arg handler for the text item */ @@ -1136,20 +1117,38 @@ e_text_update (GnomeCanvasItem *item, double *affine, ArtSVP *clip_path, int fla if (parent_class->update) (* parent_class->update) (item, affine, clip_path, flags); - if (!item->canvas->aa) { - set_text_gc_foreground (text); - set_stipple (text, text->stipple, TRUE); - get_bounds (text, &x1, &y1, &x2, &y2); - - gnome_canvas_update_bbox (item, x1, y1, x2, y2); - } else { - /* aa rendering */ - for (i = 0; i < 6; i++) - text->affine[i] = affine[i]; - get_bounds_item_relative (text, &i_bbox.x0, &i_bbox.y0, &i_bbox.x1, &i_bbox.y1); - art_drect_affine_transform (&c_bbox, &i_bbox, affine); - gnome_canvas_update_bbox (item, c_bbox.x0, c_bbox.y0, c_bbox.x1, c_bbox.y1); - + if ( text->needs_split_into_lines ) { + split_into_lines(text); + text->needs_split_into_lines = 0; + text->needs_calc_line_widths = 1; + } + if ( text->needs_calc_line_widths ) { + calc_line_widths(text); + text->needs_calc_line_widths = 0; + text->needs_recalc_bounds = 1; + } + if ( text->needs_recalc_bounds ) { + gnome_canvas_request_redraw (item->canvas, item->x1, item->y1, item->x2, item->y2); + if (!item->canvas->aa) { + set_text_gc_foreground (text); + set_stipple (text, text->stipple, TRUE); + get_bounds (text, &x1, &y1, &x2, &y2); + } else { + /* aa rendering */ + for (i = 0; i < 6; i++) + text->affine[i] = affine[i]; + get_bounds_item_relative (text, &i_bbox.x0, &i_bbox.y0, &i_bbox.x1, &i_bbox.y1); + art_drect_affine_transform (&c_bbox, &i_bbox, affine); + } + item->x1 = x1; + item->y1 = y1; + item->x2 = x2; + item->y2 = y2; + text->needs_recalc_bounds = 0; + text->needs_redraw = 1; + } + if ( text->needs_redraw ) { + gnome_canvas_request_redraw (item->canvas, item->x1, item->y1, item->x2, item->y2); } } @@ -1816,8 +1815,10 @@ _blink_scroll_timeout (gpointer data) redraw = TRUE; text->show_cursor = FALSE; } - if (redraw) + if (redraw) { + text->needs_redraw = 1; gnome_canvas_item_request_update (GNOME_CANVAS_ITEM(text)); + } return TRUE; } @@ -2264,6 +2265,7 @@ e_text_command(ETextEventProcessor *tep, ETextEventProcessorCommand *command, gp } } + text->needs_redraw = 1; gnome_canvas_item_request_update (GNOME_CANVAS_ITEM(text)); } @@ -2319,6 +2321,7 @@ _selection_clear_event (GtkInvisible *invisible, text->primary_length = 0; text->has_selection = FALSE; + text->needs_redraw = 1; gnome_canvas_item_request_update (GNOME_CANVAS_ITEM(text)); } else if (event->selection == clipboard_atom) { diff --git a/widgets/e-text/e-text.h b/widgets/e-text/e-text.h index 2f29fb189b..710d6d1e64 100644 --- a/widgets/e-text/e-text.h +++ b/widgets/e-text/e-text.h @@ -177,6 +177,11 @@ struct _EText { gint tooltip_timeout; /* Timeout for the tooltip */ GtkWidget *tooltip_window; /* GtkWindow for displaying the tooltip */ gint tooltip_count; /* GDK_ENTER_NOTIFY count. */ + + guint needs_redraw : 1; /* Needs redraw */ + guint needs_recalc_bounds : 1; /* Need recalc_bounds */ + guint needs_calc_line_widths : 1; /* Needs calc_line_widths */ + guint needs_split_into_lines : 1; /* Needs split_into_lines */ }; struct _ETextClass { |