diff options
author | Christopher James Lahey <clahey@ximian.com> | 2001-04-15 20:59:16 +0800 |
---|---|---|
committer | Chris Lahey <clahey@src.gnome.org> | 2001-04-15 20:59:16 +0800 |
commit | 15541de2db8a7475e33c439e5640d9b89559a176 (patch) | |
tree | 95e8d83e88cd8c4a9b02d2b84c677f4bf80e8338 | |
parent | cc23e4d8b4342d7df4821b17a58e6aee0d896687 (diff) | |
download | gsoc2013-evolution-15541de2db8a7475e33c439e5640d9b89559a176.tar gsoc2013-evolution-15541de2db8a7475e33c439e5640d9b89559a176.tar.gz gsoc2013-evolution-15541de2db8a7475e33c439e5640d9b89559a176.tar.bz2 gsoc2013-evolution-15541de2db8a7475e33c439e5640d9b89559a176.tar.lz gsoc2013-evolution-15541de2db8a7475e33c439e5640d9b89559a176.tar.xz gsoc2013-evolution-15541de2db8a7475e33c439e5640d9b89559a176.tar.zst gsoc2013-evolution-15541de2db8a7475e33c439e5640d9b89559a176.zip |
Added "bold" argument.
2001-04-15 Christopher James Lahey <clahey@ximian.com>
* gal/e-text/e-text.c, gal/e-text/e-text.h: Added "bold" argument.
svn path=/trunk/; revision=9319
-rw-r--r-- | widgets/text/e-text.c | 71 | ||||
-rw-r--r-- | widgets/text/e-text.h | 24 |
2 files changed, 58 insertions, 37 deletions
diff --git a/widgets/text/e-text.c b/widgets/text/e-text.c index a8bae6a1f0..76fb2f4714 100644 --- a/widgets/text/e-text.c +++ b/widgets/text/e-text.c @@ -72,6 +72,7 @@ enum { ARG_FONTSET, ARG_FONT_GDK, ARG_FONT_E, + ARG_BOLD, ARG_ANCHOR, ARG_JUSTIFICATION, ARG_CLIP_WIDTH, @@ -268,6 +269,8 @@ e_text_class_init (ETextClass *klass) GTK_TYPE_GDK_FONT, GTK_ARG_WRITABLE, ARG_FONT_GDK); gtk_object_add_arg_type ("EText::font_e", GTK_TYPE_POINTER, GTK_ARG_READWRITE, ARG_FONT_E); + gtk_object_add_arg_type ("EText::bold", + GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_BOLD); gtk_object_add_arg_type ("EText::anchor", GTK_TYPE_ANCHOR_TYPE, GTK_ARG_READWRITE, ARG_ANCHOR); gtk_object_add_arg_type ("EText::justification", @@ -420,6 +423,10 @@ e_text_init (EText *text) text->tpl_timeout = 0; text->draw_background = FALSE; + + text->bold = FALSE; + + text->style = E_FONT_PLAIN; e_canvas_item_set_reflow_callback(GNOME_CANVAS_ITEM(text), e_text_reflow); } @@ -759,7 +766,7 @@ calc_ellipsis (EText *text) { if (text->font) text->ellipsis_width = - e_font_utf8_text_width (text->font, E_FONT_PLAIN, + e_font_utf8_text_width (text->font, text->style, text->ellipsis ? text->ellipsis : "...", text->ellipsis ? strlen (text->ellipsis) : 3); } @@ -795,7 +802,7 @@ calc_line_widths (EText *text) if (lines->length != 0) { if (text->font) { lines->width = text_width_with_objects (text->model, - text->font, E_FONT_PLAIN, + text->font, text->style, lines->text, lines->length); lines->ellipsis_length = 0; } else { @@ -811,7 +818,7 @@ calc_line_widths (EText *text) lines->ellipsis_length = 0; for (p = lines->text; p && *p && (p - lines->text) < lines->length; p = unicode_next_utf8 (p)) { gint text_width = text_width_with_objects (text->model, - text->font, E_FONT_PLAIN, + text->font, text->style, lines->text, p - lines->text); if (clip_width >= text_width + text->ellipsis_width) lines->ellipsis_length = p - lines->text; @@ -822,7 +829,7 @@ calc_line_widths (EText *text) else lines->ellipsis_length = 0; lines->width = text_width_with_objects (text->model, - text->font, E_FONT_PLAIN, + text->font, text->style, lines->text, lines->ellipsis_length) + text->ellipsis_width; } @@ -944,7 +951,7 @@ split_into_lines (EText *text) && e_text_model_get_object_at_pointer (text->model, cp) == -1) { /* don't break mid-object */ if (laststart != lastend && clip_width < text_width_with_objects (text->model, - text->font, E_FONT_PLAIN, + text->font, text->style, linestart, cp - linestart)) { text->num_lines ++; @@ -961,7 +968,7 @@ split_into_lines (EText *text) if (laststart != lastend && unicode_index_to_offset (linestart, cp - linestart) != 1 && clip_width < text_width_with_objects (text->model, - text->font, E_FONT_PLAIN, + text->font, text->style, linestart, p - linestart)) { text->num_lines ++; @@ -987,7 +994,7 @@ split_into_lines (EText *text) && p && laststart != lastend && clip_width < text_width_with_objects (text->model, - text->font, E_FONT_PLAIN, + text->font, text->style, linestart, cp - linestart)) { text->num_lines ++; } @@ -1017,7 +1024,7 @@ split_into_lines (EText *text) && (unicode_isspace (unival) || unival == '\n') && e_text_model_get_object_at_pointer (text->model, cp) == -1) { /* don't break mid-object */ if (clip_width < text_width_with_objects (text->model, - text->font, E_FONT_PLAIN, + text->font, text->style, lines->text, cp - lines->text) && laststart != lastend) { @@ -1041,7 +1048,7 @@ split_into_lines (EText *text) if (laststart != lastend && unicode_index_to_offset (lines->text, cp - lines->text) != 1 && clip_width < text_width_with_objects (text->model, - text->font, E_FONT_PLAIN, + text->font, text->style, lines->text, p - lines->text)) { lines->length = lastend - lines->text; @@ -1077,7 +1084,7 @@ split_into_lines (EText *text) if ( line_num < text->num_lines && text->line_wrap ) { if (clip_width < text_width_with_objects (text->model, - text->font, E_FONT_PLAIN, + text->font, text->style, lines->text, cp - lines->text) && laststart != lastend ) { @@ -1287,6 +1294,10 @@ e_text_set_arg (GtkObject *object, GtkArg *arg, guint arg_id) text->needs_calc_line_widths = 1; needs_reflow = 1; break; + case ARG_BOLD: + text->bold = GTK_VALUE_BOOL (*arg); + text->style = text->bold ? E_FONT_BOLD : E_FONT_PLAIN; + break; case ARG_ANCHOR: text->anchor = GTK_VALUE_ENUM (*arg); text->needs_recalc_bounds = 1; @@ -1521,6 +1532,10 @@ e_text_get_arg (GtkObject *object, GtkArg *arg, guint arg_id) GTK_VALUE_BOXED (*arg) = text->font; break; + case ARG_BOLD: + GTK_VALUE_BOOL (*arg) = text->bold; + break; + case ARG_ANCHOR: GTK_VALUE_ENUM (*arg) = text->anchor; break; @@ -1671,7 +1686,7 @@ e_text_reflow (GnomeCanvasItem *item, int flags) lines --; i--; x = text_width_with_objects (text->model, - text->font, E_FONT_PLAIN, + text->font, text->style, lines->text, text->selection_end - (lines->text - text->text)); @@ -2050,12 +2065,12 @@ e_text_draw (GnomeCanvasItem *item, GdkDrawable *drawable, sel_end = end_char; if ( sel_start < sel_end ) { sel_rect.x = xpos - x + text_width_with_objects (text->model, - text->font, E_FONT_PLAIN, + text->font, text->style, lines->text, sel_start - start_char); sel_rect.y = ypos - y - e_font_ascent (text->font); sel_rect.width = text_width_with_objects (text->model, - text->font, E_FONT_PLAIN, + text->font, text->style, lines->text + sel_start - start_char, sel_end - sel_start); sel_rect.height = e_font_height (text->font); @@ -2074,7 +2089,7 @@ e_text_draw (GnomeCanvasItem *item, GdkDrawable *drawable, sel_rect.height); text_draw_with_objects (text->model, drawable, - text->font, E_FONT_PLAIN, + text->font, text->style, text->gc, xpos - x, ypos - y, @@ -2082,10 +2097,10 @@ e_text_draw (GnomeCanvasItem *item, GdkDrawable *drawable, sel_start - start_char); text_draw_with_objects (text->model, drawable, - text->font, E_FONT_PLAIN, + text->font, text->style, fg_gc, xpos - x + text_width_with_objects (text->model, - text->font, E_FONT_PLAIN, + text->font, text->style, lines->text, sel_start - start_char), ypos - y, @@ -2093,10 +2108,10 @@ e_text_draw (GnomeCanvasItem *item, GdkDrawable *drawable, sel_end - sel_start); text_draw_with_objects (text->model, drawable, - text->font, E_FONT_PLAIN, + text->font, text->style, text->gc, xpos - x + text_width_with_objects (text->model, - text->font, E_FONT_PLAIN, + text->font, text->style, lines->text, sel_end - start_char), ypos - y, @@ -2105,7 +2120,7 @@ e_text_draw (GnomeCanvasItem *item, GdkDrawable *drawable, } else { text_draw_with_objects (text->model, drawable, - text->font, E_FONT_PLAIN, + text->font, text->style, text->gc, xpos - x, ypos - y, @@ -2120,7 +2135,7 @@ e_text_draw (GnomeCanvasItem *item, GdkDrawable *drawable, text->gc, TRUE, xpos - x + text_width_with_objects (text->model, - text->font, E_FONT_PLAIN, + text->font, text->style, lines->text, sel_start - start_char), ypos - y - e_font_ascent (text->font), @@ -2131,14 +2146,14 @@ e_text_draw (GnomeCanvasItem *item, GdkDrawable *drawable, if (text->clip && text->use_ellipsis && lines->ellipsis_length < lines->length) { text_draw_with_objects (text->model, drawable, - text->font, E_FONT_PLAIN, + text->font, text->style, text->gc, xpos - x, ypos - y, lines->text, lines->ellipsis_length); e_font_draw_utf8_text (drawable, - text->font, E_FONT_PLAIN, + text->font, text->style, text->gc, xpos - x + lines->width - text->ellipsis_width, ypos - y, @@ -2147,7 +2162,7 @@ e_text_draw (GnomeCanvasItem *item, GdkDrawable *drawable, } else text_draw_with_objects (text->model, drawable, - text->font, E_FONT_PLAIN, + text->font, text->style, text->gc, xpos - x, ypos - y, @@ -2450,7 +2465,7 @@ _get_xy_from_position (EText *text, gint position, gint *xp, gint *yp) y -= e_font_descent (text->font); x += text_width_with_objects (text->model, - text->font, E_FONT_PLAIN, + text->font, text->style, lines->text, position - (lines->text - text->text)); x -= text->xofs_edit; @@ -2532,7 +2547,7 @@ _get_position_from_xy (EText *text, gint x, gint y) #if 0 if (unival == '\1') { const gchar *obj_str = NULL; /*e_text_model_get_nth_object (text->model, object_num);*/ - charwidth = e_font_utf8_text_width (text->font, E_FONT_PLAIN, obj_str, strlen (obj_str)); + charwidth = e_font_utf8_text_width (text->font, text->style, obj_str, strlen (obj_str)); ++object_num; step1 = charwidth; @@ -2541,7 +2556,7 @@ _get_position_from_xy (EText *text, gint x, gint y) } else { #endif - charwidth = e_font_utf8_char_width (text->font, E_FONT_PLAIN, (gchar *) p); + charwidth = e_font_utf8_char_width (text->font, text->style, (gchar *) p); step1 = charwidth / 2; step2 = (charwidth + 1) / 2; @@ -2736,7 +2751,7 @@ _do_tooltip (gpointer data) for (lines = text->lines, i = 0; i < text->num_lines; lines++, i++) { gdouble line_width; - line_width = text_width_with_objects (text->model, text->font, E_FONT_PLAIN, lines->text, lines->length); + line_width = text_width_with_objects (text->model, text->font, text->style, lines->text, lines->length); max_width = MAX (max_width, line_width); } @@ -3505,7 +3520,7 @@ e_text_command(ETextEventProcessor *tep, ETextEventProcessorCommand *command, gp lines --; i --; x = text_width_with_objects (text->model, - text->font, E_FONT_PLAIN, + text->font, text->style, lines->text, text->selection_end - (lines->text - text->text)); diff --git a/widgets/text/e-text.h b/widgets/text/e-text.h index 185734d1df..e769818e74 100644 --- a/widgets/text/e-text.h +++ b/widgets/text/e-text.h @@ -49,6 +49,7 @@ BEGIN_GNOME_DECLS * font string W X logical font descriptor * fontset string W X logical fontset descriptor * font_gdk GdkFont* RW Pointer to a GdkFont + * bold boolean RW Bold? * anchor GtkAnchorType RW Anchor side for the text * justification GtkJustification RW Justification for multiline text * fill_color string W X color specification for text @@ -143,9 +144,6 @@ struct _EText { int width; /* Rendered text width in pixels */ int height; /* Rendered text height in pixels */ - guint clip : 1; /* Use clip rectangle? */ - guint fill_clip_rectangle : 1; /* Fill the clipping rectangle. */ - /* Antialiased specific stuff follows */ #if 0 ETextSuckFont *suckfont; /* Sucked font */ @@ -189,12 +187,26 @@ struct _EText { gchar *clipboard_selection; /* Clipboard selection text */ gint clipboard_length; /* Clipboard selection text length*/ + guint clip : 1; /* Use clip rectangle? */ + guint fill_clip_rectangle : 1; /* Fill the clipping rectangle. */ + guint pointer_in : 1; /* Is the pointer currently over us? */ guint default_cursor_shown : 1; /* Is the default cursor currently shown? */ guint draw_borders : 1; /* Draw borders? */ guint draw_background : 1; /* Draw background? */ guint line_wrap : 1; /* Do line wrap */ + + guint needs_redraw : 1; /* Needs redraw */ + guint needs_recalc_bounds : 1; /* Need recalc_bounds */ + guint needs_calc_height : 1; /* Need calc_height */ + guint needs_calc_line_widths : 1; /* Needs calc_line_widths */ + guint needs_split_into_lines : 1; /* Needs split_into_lines */ + + guint bold : 1; + + EFontStyle style; + gchar *break_characters; /* Characters to optionally break after */ gint max_lines; /* Max number of lines (-1 = infinite) */ @@ -206,12 +218,6 @@ struct _EText { 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_height : 1; /* Need calc_height */ - guint needs_calc_line_widths : 1; /* Needs calc_line_widths */ - guint needs_split_into_lines : 1; /* Needs split_into_lines */ - gint dbl_timeout; /* Double click timeout */ gint tpl_timeout; /* Triple click timeout */ }; |