aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/text
diff options
context:
space:
mode:
authorChristopher James Lahey <clahey@ximian.com>2001-10-23 14:30:54 +0800
committerChris Lahey <clahey@src.gnome.org>2001-10-23 14:30:54 +0800
commit4720ad36fadc7680cb62cb309627d28511555ef2 (patch)
treec4f09e1da1de734d407f4ad46ad4145664125981 /widgets/text
parent343f36cffe95db2943ba897b83bbb88a6c25c366 (diff)
downloadgsoc2013-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')
-rw-r--r--widgets/text/e-entry.c15
-rw-r--r--widgets/text/e-text.c107
-rw-r--r--widgets/text/e-text.h2
3 files changed, 124 insertions, 0 deletions
diff --git a/widgets/text/e-entry.c b/widgets/text/e-entry.c
index b46ed1e6c5..a55f35b90c 100644
--- a/widgets/text/e-entry.c
+++ b/widgets/text/e-entry.c
@@ -99,6 +99,7 @@ enum {
ARG_ALLOW_NEWLINES,
ARG_DRAW_BORDERS,
ARG_DRAW_BACKGROUND,
+ ARG_DRAW_BUTTON,
ARG_CURSOR_POS
};
@@ -289,6 +290,7 @@ e_entry_init (GtkObject *object)
"anchor", GTK_ANCHOR_NW,
"draw_borders", TRUE,
"draw_background", TRUE,
+ "draw_button", FALSE,
"max_lines", 1,
"editable", TRUE,
"allow_newlines", FALSE,
@@ -931,6 +933,12 @@ et_get_arg (GtkObject *o, GtkArg *arg, guint arg_id)
NULL);
break;
+ case ARG_DRAW_BUTTON:
+ gtk_object_get (item,
+ "draw_button", &GTK_VALUE_BOOL (*arg),
+ NULL);
+ break;
+
case ARG_CURSOR_POS:
gtk_object_get (item,
"cursor_pos", &GTK_VALUE_INT (*arg),
@@ -1112,6 +1120,11 @@ et_set_arg (GtkObject *o, GtkArg *arg, guint arg_id)
gtk_object_set (item, "draw_background",
GTK_VALUE_BOOL (*arg), NULL);
break;
+
+ case ARG_DRAW_BUTTON:
+ gtk_object_set (item, "draw_button",
+ GTK_VALUE_BOOL (*arg), NULL);
+ break;
}
}
@@ -1231,6 +1244,8 @@ e_entry_class_init (GtkObjectClass *object_class)
GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_DRAW_BORDERS);
gtk_object_add_arg_type ("EEntry::draw_background",
GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_DRAW_BACKGROUND);
+ gtk_object_add_arg_type ("EEntry::draw_button",
+ GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_DRAW_BUTTON);
gtk_object_add_arg_type ("EEntry::cursor_pos",
GTK_TYPE_INT, GTK_ARG_READWRITE, ARG_CURSOR_POS);
}
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;
diff --git a/widgets/text/e-text.h b/widgets/text/e-text.h
index 9a5b997bba..573a2d9b70 100644
--- a/widgets/text/e-text.h
+++ b/widgets/text/e-text.h
@@ -75,6 +75,7 @@ BEGIN_GNOME_DECLS
* max_lines int RW Number of lines possible when doing line wrap.
* draw_borders boolean RW Whether to draw borders.
* draw_background boolean RW Whether to draw the background.
+ * draw_button boolean RW This makes EText handle being the child of a button properly and highlighting as it should.
*/
#define E_TYPE_TEXT (e_text_get_type ())
@@ -190,6 +191,7 @@ struct _EText {
guint default_cursor_shown : 1; /* Is the default cursor currently shown? */
guint draw_borders : 1; /* Draw borders? */
guint draw_background : 1; /* Draw background? */
+ guint draw_button : 1; /* Draw button? */
guint line_wrap : 1; /* Do line wrap */