diff options
author | Christopher James Lahey <clahey@ximian.com> | 2001-10-23 14:30:54 +0800 |
---|---|---|
committer | Chris Lahey <clahey@src.gnome.org> | 2001-10-23 14:30:54 +0800 |
commit | 4720ad36fadc7680cb62cb309627d28511555ef2 (patch) | |
tree | c4f09e1da1de734d407f4ad46ad4145664125981 /widgets/text/e-text.c | |
parent | 343f36cffe95db2943ba897b83bbb88a6c25c366 (diff) | |
download | gsoc2013-evolution-4720ad36fadc7680cb62cb309627d28511555ef2.tar.gz gsoc2013-evolution-4720ad36fadc7680cb62cb309627d28511555ef2.tar.zst gsoc2013-evolution-4720ad36fadc7680cb62cb309627d28511555ef2.zip |
Bumped version to 0.15.99.3 for EText's "draw_button" argument.
2001-10-23 Christopher James Lahey <clahey@ximian.com>
* configure.in: Bumped version to 0.15.99.3 for EText's
"draw_button" argument.
* gal/e-text/e-entry.c: Forward the "draw_button" argument to the
contained EText.
* gal/e-text/e-text.c, gal/e-text/e-text.h (e_text_draw): Added
new "draw_button" argument. If this is turned on and the first
widget that's a parent of the containing canvas with GTK_NO_WINDOW
turned off above the current one is a button, EText draws a button
underneath itself to match the containing button.
From gal/shortcut-bar/ChangeLog:
2001-10-23 Christopher James Lahey <clahey@ximian.com>
* e-shortcut-bar.c (e_shortcut_bar_add_group): Turn on
"draw_button" argument to EEntry.
svn path=/trunk/; revision=13934
Diffstat (limited to 'widgets/text/e-text.c')
-rw-r--r-- | widgets/text/e-text.c | 107 |
1 files changed, 107 insertions, 0 deletions
diff --git a/widgets/text/e-text.c b/widgets/text/e-text.c index 8d17c4b004..c6259fc3e0 100644 --- a/widgets/text/e-text.c +++ b/widgets/text/e-text.c @@ -99,6 +99,7 @@ enum { ARG_DRAW_BORDERS, ARG_ALLOW_NEWLINES, ARG_DRAW_BACKGROUND, + ARG_DRAW_BUTTON, ARG_CURSOR_POS }; @@ -326,6 +327,8 @@ e_text_class_init (ETextClass *klass) GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_ALLOW_NEWLINES); gtk_object_add_arg_type ("EText::draw_background", GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_DRAW_BACKGROUND); + gtk_object_add_arg_type ("EText::draw_button", + GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_DRAW_BUTTON); gtk_object_add_arg_type ("EText::cursor_pos", GTK_TYPE_INT, GTK_ARG_READWRITE, ARG_CURSOR_POS); @@ -429,6 +432,7 @@ e_text_init (EText *text) text->tpl_timeout = 0; text->draw_background = FALSE; + text->draw_button = FALSE; text->bold = FALSE; text->strikeout = FALSE; @@ -1491,6 +1495,13 @@ e_text_set_arg (GtkObject *object, GtkArg *arg, guint arg_id) } break; + case ARG_DRAW_BUTTON: + if (text->draw_button != GTK_VALUE_BOOL (*arg)){ + text->draw_button = GTK_VALUE_BOOL (*arg); + text->needs_redraw = 1; + } + break; + case ARG_ALLOW_NEWLINES: text->allow_newlines = GTK_VALUE_BOOL (*arg); _get_tep(text); @@ -1662,6 +1673,10 @@ e_text_get_arg (GtkObject *object, GtkArg *arg, guint arg_id) GTK_VALUE_BOOL (*arg) = text->draw_background; break; + case ARG_DRAW_BUTTON: + GTK_VALUE_BOOL (*arg) = text->draw_button; + break; + case ARG_ALLOW_NEWLINES: GTK_VALUE_BOOL (*arg) = text->allow_newlines; break; @@ -2042,6 +2057,98 @@ e_text_draw (GnomeCanvasItem *item, GdkDrawable *drawable, thisheight - widget->style->klass->ythickness * 2); } } + if (text->draw_button) { + GtkWidget *widget; + int xoff = item->x1 - x; + int yoff = item->y1 - y; + + widget = GTK_WIDGET (item->canvas); + + xoff -= widget->allocation.x; + yoff -= widget->allocation.y; + + widget = widget->parent; + + while (widget && !GTK_IS_BUTTON(widget)) { + if (!GTK_WIDGET_NO_WINDOW (widget)) { + widget = NULL; + break; + } + widget = widget->parent; + } + if (widget) { + GtkButton *button = GTK_BUTTON (widget); + GtkShadowType shadow_type; + int thisx, thisy, thisheight, thiswidth; + int default_spacing; + GdkRectangle area; + area.x = 0; + area.y = 0; + area.width = width; + area.height = height; + +#define DEFAULT_SPACING 7 + + default_spacing = gtk_style_get_prop_experimental (widget->style, + "GtkButton::default_spacing", + DEFAULT_SPACING); + + thisx = 0; + thisy = 0; + thiswidth = widget->allocation.width - GTK_CONTAINER (widget)->border_width * 2; + thisheight = widget->allocation.height - GTK_CONTAINER (widget)->border_width * 2; + + if (GTK_WIDGET_HAS_DEFAULT (widget) && + GTK_BUTTON (widget)->relief == GTK_RELIEF_NORMAL) + { + gtk_paint_box (widget->style, drawable, + GTK_STATE_NORMAL, GTK_SHADOW_IN, + &area, widget, "buttondefault", + thisx + xoff, thisy + yoff, thiswidth, thisheight); + } + + if (GTK_WIDGET_CAN_DEFAULT (widget)) { + thisx += widget->style->klass->xthickness; + thisy += widget->style->klass->ythickness; + thiswidth -= 2 * thisx + default_spacing; + thisheight -= 2 * thisy + default_spacing; + thisx += (1 + default_spacing) / 2; + thisy += (1 + default_spacing) / 2; + } + + if (GTK_WIDGET_HAS_FOCUS (widget)) { + thisx += 1; + thisy += 1; + thiswidth -= 2; + thisheight -= 2; + } + + if (GTK_WIDGET_STATE (widget) == GTK_STATE_ACTIVE) + shadow_type = GTK_SHADOW_IN; + else + shadow_type = GTK_SHADOW_OUT; + + if ((button->relief != GTK_RELIEF_NONE) || + ((GTK_WIDGET_STATE(widget) != GTK_STATE_NORMAL) && + (GTK_WIDGET_STATE(widget) != GTK_STATE_INSENSITIVE))) + gtk_paint_box (widget->style, drawable, + GTK_WIDGET_STATE (widget), + shadow_type, &area, widget, "button", + thisx + xoff, thisy + yoff, thiswidth, thisheight); + + if (GTK_WIDGET_HAS_FOCUS (widget)) { + thisx -= 1; + thisy -= 1; + thiswidth += 2; + thisheight += 2; + + gtk_paint_focus (widget->style, widget->window, + &area, widget, "button", + thisx + xoff, thisy + yoff, thiswidth - 1, thisheight - 1); + } + } + } + if (!text->text || !text->font) return; |