diff options
author | Miguel de Icaza <miguel@helixcode.com> | 2000-12-25 06:28:17 +0800 |
---|---|---|
committer | Miguel de Icaza <miguel@src.gnome.org> | 2000-12-25 06:28:17 +0800 |
commit | ac6661ee1265683ac81f5a5306540572d8cc491c (patch) | |
tree | dcc0c0b277a6913ecc5b184bbae01705b74db627 /widgets/text/e-entry.c | |
parent | d52ef16370370f59077bf209ae7dad639829495c (diff) | |
download | gsoc2013-evolution-ac6661ee1265683ac81f5a5306540572d8cc491c.tar.gz gsoc2013-evolution-ac6661ee1265683ac81f5a5306540572d8cc491c.tar.zst gsoc2013-evolution-ac6661ee1265683ac81f5a5306540572d8cc491c.zip |
Handle draw background. (e_text_draw): Support both border drawing and
2000-12-24 Miguel de Icaza <miguel@helixcode.com>
* gal/e-text/e-text.c (e_text_set_arg): Handle draw background.
(e_text_draw): Support both border drawing and background drawing.
* gal/e-text/e-entry.c (et_get_arg, et_set_arg): Reduce code size by casting
once.
(et_set_arg, et_get_arg): Add ARG_DRAW_BORDERS handling.
svn path=/trunk/; revision=7159
Diffstat (limited to 'widgets/text/e-entry.c')
-rw-r--r-- | widgets/text/e-entry.c | 107 |
1 files changed, 70 insertions, 37 deletions
diff --git a/widgets/text/e-entry.c b/widgets/text/e-entry.c index fdc08f4e20..0ae2803744 100644 --- a/widgets/text/e-entry.c +++ b/widgets/text/e-entry.c @@ -63,6 +63,7 @@ enum { ARG_BREAK_CHARACTERS, ARG_MAX_LINES, ARG_ALLOW_NEWLINES, + ARG_DRAW_BORDERS }; static void @@ -80,16 +81,25 @@ canvas_size_allocate (GtkWidget *widget, GtkAllocation *alloc, static void canvas_size_request (GtkWidget *widget, GtkRequisition *requisition, - EEntry *e_entry) + EEntry *ee) { + int border; + gboolean draw_borders = 0; + g_return_if_fail (widget != NULL); g_return_if_fail (GNOME_IS_CANVAS (widget)); g_return_if_fail (requisition != NULL); - requisition->width = MIN_ENTRY_WIDTH + (widget->style->klass->xthickness + INNER_BORDER) * 2; + gtk_object_get (GTK_OBJECT (ee->item), "draw_borders", &draw_borders, NULL); + if (draw_borders) + border = INNER_BORDER; + else + border = 0; + + requisition->width = MIN_ENTRY_WIDTH + (widget->style->klass->xthickness + border) * 2; requisition->height = (widget->style->font->ascent + widget->style->font->descent + - (widget->style->klass->ythickness + INNER_BORDER) * 2); + (widget->style->klass->ythickness + border) * 2); } static gint @@ -147,96 +157,104 @@ static void et_get_arg (GtkObject *o, GtkArg *arg, guint arg_id) { EEntry *ee = E_ENTRY (o); - + GtkObject *item = GTK_OBJECT (ee->item); + switch (arg_id){ case ARG_MODEL: - gtk_object_get(GTK_OBJECT(ee->item), + gtk_object_get(item, "model", >K_VALUE_OBJECT (*arg), NULL); break; case ARG_EVENT_PROCESSOR: - gtk_object_get(GTK_OBJECT(ee->item), + gtk_object_get(item, "event_processor", >K_VALUE_OBJECT (*arg), NULL); break; case ARG_TEXT: - gtk_object_get(GTK_OBJECT(ee->item), + gtk_object_get(item, "text", >K_VALUE_STRING (*arg), NULL); break; case ARG_FONT_GDK: - gtk_object_get(GTK_OBJECT(ee->item), + gtk_object_get(item, "font_gdk", >K_VALUE_BOXED (*arg), NULL); break; case ARG_JUSTIFICATION: - gtk_object_get(GTK_OBJECT(ee->item), + gtk_object_get(item, "justification", >K_VALUE_ENUM (*arg), NULL); break; case ARG_FILL_COLOR_GDK: - gtk_object_get(GTK_OBJECT(ee->item), + gtk_object_get(item, "fill_color_gdk", >K_VALUE_BOXED (*arg), NULL); break; case ARG_FILL_COLOR_RGBA: - gtk_object_get(GTK_OBJECT(ee->item), + gtk_object_get(item, "fill_color_rgba", >K_VALUE_UINT (*arg), NULL); break; case ARG_FILL_STIPPLE: - gtk_object_get(GTK_OBJECT(ee->item), + gtk_object_get(item, "fill_stiple", >K_VALUE_BOXED (*arg), NULL); break; case ARG_EDITABLE: - gtk_object_get(GTK_OBJECT(ee->item), + gtk_object_get(item, "editable", >K_VALUE_BOOL (*arg), NULL); break; case ARG_USE_ELLIPSIS: - gtk_object_get(GTK_OBJECT(ee->item), + gtk_object_get(item, "use_ellipsis", >K_VALUE_BOOL (*arg), NULL); break; case ARG_ELLIPSIS: - gtk_object_get(GTK_OBJECT(ee->item), + gtk_object_get(item, "ellipsis", >K_VALUE_STRING (*arg), NULL); break; case ARG_LINE_WRAP: - gtk_object_get(GTK_OBJECT(ee->item), + gtk_object_get(item, "line_wrap", >K_VALUE_BOOL (*arg), NULL); break; case ARG_BREAK_CHARACTERS: - gtk_object_get(GTK_OBJECT(ee->item), + gtk_object_get(item, "break_characters", >K_VALUE_STRING (*arg), NULL); break; case ARG_MAX_LINES: - gtk_object_get(GTK_OBJECT(ee->item), + gtk_object_get(item, "max_lines", >K_VALUE_INT (*arg), NULL); break; case ARG_ALLOW_NEWLINES: - gtk_object_get(GTK_OBJECT(ee->item), + gtk_object_get(item, "allow_newlines", >K_VALUE_BOOL (*arg), NULL); break; + + case ARG_DRAW_BORDERS: + gtk_object_get (item, + "draw_borders", >K_VALUE_BOOL (*arg), + NULL); + break; + default: arg->type = GTK_TYPE_INVALID; break; @@ -247,115 +265,128 @@ static void et_set_arg (GtkObject *o, GtkArg *arg, guint arg_id) { EEntry *ee = E_ENTRY (o); + GtkObject *item = GTK_OBJECT (ee->item); switch (arg_id){ case ARG_MODEL: - gtk_object_set(GTK_OBJECT(ee->item), + gtk_object_set(item, "model", GTK_VALUE_OBJECT (*arg), NULL); break; case ARG_EVENT_PROCESSOR: - gtk_object_set(GTK_OBJECT(ee->item), + gtk_object_set(item, "event_processor", GTK_VALUE_OBJECT (*arg), NULL); break; case ARG_TEXT: - gtk_object_set(GTK_OBJECT(ee->item), + gtk_object_set(item, "text", GTK_VALUE_STRING (*arg), NULL); break; case ARG_FONT: - gtk_object_set(GTK_OBJECT(ee->item), + gtk_object_set(item, "font", GTK_VALUE_STRING (*arg), NULL); break; case ARG_FONTSET: - gtk_object_set(GTK_OBJECT(ee->item), + gtk_object_set(item, "fontset", GTK_VALUE_STRING (*arg), NULL); break; case ARG_FONT_GDK: - gtk_object_set(GTK_OBJECT(ee->item), + gtk_object_set(item, "font_gdk", GTK_VALUE_BOXED (*arg), NULL); break; case ARG_JUSTIFICATION: - gtk_object_set(GTK_OBJECT(ee->item), + gtk_object_set(item, "justification", GTK_VALUE_ENUM (*arg), NULL); break; case ARG_FILL_COLOR: - gtk_object_set(GTK_OBJECT(ee->item), + gtk_object_set(item, "fill_color", GTK_VALUE_STRING (*arg), NULL); break; case ARG_FILL_COLOR_GDK: - gtk_object_set(GTK_OBJECT(ee->item), + gtk_object_set(item, "fill_color_gdk", GTK_VALUE_BOXED (*arg), NULL); break; case ARG_FILL_COLOR_RGBA: - gtk_object_set(GTK_OBJECT(ee->item), + gtk_object_set(item, "fill_color_rgba", GTK_VALUE_UINT (*arg), NULL); break; case ARG_FILL_STIPPLE: - gtk_object_set(GTK_OBJECT(ee->item), + gtk_object_set(item, "fill_stiple", GTK_VALUE_BOXED (*arg), NULL); break; case ARG_EDITABLE: - gtk_object_set(GTK_OBJECT(ee->item), + gtk_object_set(item, "editable", GTK_VALUE_BOOL (*arg), NULL); break; case ARG_USE_ELLIPSIS: - gtk_object_set(GTK_OBJECT(ee->item), + gtk_object_set(item, "use_ellipsis", GTK_VALUE_BOOL (*arg), NULL); break; case ARG_ELLIPSIS: - gtk_object_set(GTK_OBJECT(ee->item), + gtk_object_set(item, "ellipsis", GTK_VALUE_STRING (*arg), NULL); break; case ARG_LINE_WRAP: - gtk_object_set(GTK_OBJECT(ee->item), + gtk_object_set(item, "line_wrap", GTK_VALUE_BOOL (*arg), NULL); break; case ARG_BREAK_CHARACTERS: - gtk_object_set(GTK_OBJECT(ee->item), + gtk_object_set(item, "break_characters", GTK_VALUE_STRING (*arg), NULL); break; case ARG_MAX_LINES: - gtk_object_set(GTK_OBJECT(ee->item), + gtk_object_set(item, "max_lines", GTK_VALUE_INT (*arg), NULL); break; case ARG_ALLOW_NEWLINES: - gtk_object_set(GTK_OBJECT(ee->item), + gtk_object_set(item, "allow_newlines", GTK_VALUE_BOOL (*arg), NULL); break; + + case ARG_DRAW_BORDERS: { + gboolean draw_border; + gboolean need_queue; + + gtk_object_get (item, "draw_borders", &draw_border, NULL); + + need_queue = (draw_border ^ GTK_VALUE_BOOL (*arg)); + gtk_object_set (item, "draw_borders", GTK_VALUE_BOOL (*arg), NULL); + if (need_queue) + gtk_widget_queue_resize (GTK_WIDGET (ee)); + } } } @@ -426,6 +457,8 @@ e_entry_class_init (GtkObjectClass *object_class) GTK_TYPE_INT, GTK_ARG_READWRITE, ARG_MAX_LINES); gtk_object_add_arg_type ("EEntry::allow_newlines", GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_ALLOW_NEWLINES); + gtk_object_add_arg_type ("EEntry::draw_borders", + GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_DRAW_BORDERS); } E_MAKE_TYPE(e_entry, "EEntry", EEntry, e_entry_class_init, e_entry_init, PARENT_TYPE); |