aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/text/e-text.c
diff options
context:
space:
mode:
authorChris Lahey <clahey@src.gnome.org>2000-01-12 13:05:30 +0800
committerChris Lahey <clahey@src.gnome.org>2000-01-12 13:05:30 +0800
commit4d2a782588b3d7b7a24b5838be9a9b280a089895 (patch)
tree64f7b2cfe89c29f86988144e6725f9e18a3904c1 /widgets/text/e-text.c
parentc1209c281ed79b5dcc9c201f1968fba972c3641a (diff)
downloadgsoc2013-evolution-4d2a782588b3d7b7a24b5838be9a9b280a089895.tar
gsoc2013-evolution-4d2a782588b3d7b7a24b5838be9a9b280a089895.tar.gz
gsoc2013-evolution-4d2a782588b3d7b7a24b5838be9a9b280a089895.tar.bz2
gsoc2013-evolution-4d2a782588b3d7b7a24b5838be9a9b280a089895.tar.lz
gsoc2013-evolution-4d2a782588b3d7b7a24b5838be9a9b280a089895.tar.xz
gsoc2013-evolution-4d2a782588b3d7b7a24b5838be9a9b280a089895.tar.zst
gsoc2013-evolution-4d2a782588b3d7b7a24b5838be9a9b280a089895.zip
Added a resize signal for when the card changes height. Made it so that
* widgets/e-minicard.c, widgets/e-minicard.h: Added a resize signal for when the card changes height. Made it so that when you press tab inside of a field, it goes to the next field. * widgets/e-minicard-label.c, widgets/e-minicard-label.h: Added a resize signal for when the label changes height. * widgets/e-text.c, widgets/e-text.h: Added a resize signal for multiple lines. Added scrolling based on cursor position. * widgets/Makefile.am: Removed an extraneous build target. svn path=/trunk/; revision=1562
Diffstat (limited to 'widgets/text/e-text.c')
-rw-r--r--widgets/text/e-text.c85
1 files changed, 77 insertions, 8 deletions
diff --git a/widgets/text/e-text.c b/widgets/text/e-text.c
index e4e8e11f9b..023ad2428d 100644
--- a/widgets/text/e-text.c
+++ b/widgets/text/e-text.c
@@ -27,6 +27,14 @@
#include "e-text-event-processor-emacs-like.h"
+enum {
+ E_TEXT_RESIZE,
+ E_TEXT_CHANGE,
+ E_TEXT_LAST_SIGNAL
+};
+
+static guint e_text_signals[E_TEXT_LAST_SIGNAL] = { 0 };
+
/* This defines a line of text */
@@ -130,16 +138,36 @@ e_text_get_type (void)
/* Class initialization function for the text item */
static void
-e_text_class_init (ETextClass *class)
+e_text_class_init (ETextClass *klass)
{
GtkObjectClass *object_class;
GnomeCanvasItemClass *item_class;
- object_class = (GtkObjectClass *) class;
- item_class = (GnomeCanvasItemClass *) class;
+ object_class = (GtkObjectClass *) klass;
+ item_class = (GnomeCanvasItemClass *) klass;
parent_class = gtk_type_class (gnome_canvas_item_get_type ());
+ e_text_signals[E_TEXT_RESIZE] =
+ gtk_signal_new ("resize",
+ GTK_RUN_LAST,
+ object_class->type,
+ GTK_SIGNAL_OFFSET (ETextClass, resize),
+ gtk_marshal_NONE__NONE,
+ GTK_TYPE_NONE, 0);
+
+
+ e_text_signals[E_TEXT_CHANGE] =
+ gtk_signal_new ("change",
+ GTK_RUN_LAST,
+ object_class->type,
+ GTK_SIGNAL_OFFSET (ETextClass, change),
+ gtk_marshal_NONE__NONE,
+ GTK_TYPE_NONE, 0);
+
+
+ gtk_object_class_add_signals (object_class, e_text_signals, E_TEXT_LAST_SIGNAL);
+
gtk_object_add_arg_type ("EText::text",
GTK_TYPE_STRING, GTK_ARG_READWRITE, ARG_TEXT);
gtk_object_add_arg_type ("EText::x",
@@ -185,6 +213,9 @@ e_text_class_init (ETextClass *class)
gtk_object_add_arg_type ("EText::ellipsis",
GTK_TYPE_STRING, GTK_ARG_READWRITE, ARG_ELLIPSIS);
+ klass->resize = NULL;
+ klass->change = NULL;
+
object_class->destroy = e_text_destroy;
object_class->set_arg = e_text_set_arg;
object_class->get_arg = e_text_get_arg;
@@ -277,6 +308,7 @@ get_bounds_item_relative (EText *text, double *px1, double *py1, double *px2, do
GnomeCanvasItem *item;
double x, y;
double clip_x, clip_y;
+ int old_height;
item = GNOME_CANVAS_ITEM (text);
@@ -288,11 +320,16 @@ get_bounds_item_relative (EText *text, double *px1, double *py1, double *px2, do
/* Calculate text dimensions */
+ old_height = text->height;
+
if (text->text && text->font)
text->height = (text->font->ascent + text->font->descent) * text->num_lines;
else
text->height = 0;
+ if (old_height != text->height)
+ gtk_signal_emit_by_name (GTK_OBJECT (text), "resize");
+
/* Anchor text */
switch (text->anchor) {
@@ -358,6 +395,7 @@ get_bounds (EText *text, double *px1, double *py1, double *px2, double *py2)
{
GnomeCanvasItem *item;
double wx, wy;
+ int old_height;
item = GNOME_CANVAS_ITEM (text);
@@ -376,11 +414,16 @@ get_bounds (EText *text, double *px1, double *py1, double *px2, double *py2)
/* Calculate text dimensions */
+ old_height = text->height;
+
if (text->text && text->font)
text->height = (text->font->ascent + text->font->descent) * text->num_lines;
else
text->height = 0;
+ if (old_height != text->height)
+ gtk_signal_emit_by_name (GTK_OBJECT (text), "resize");
+
/* Anchor text */
switch (text->anchor) {
@@ -552,17 +595,18 @@ split_into_lines (EText *text)
len = 0;
for (p = text->text; *p; p++) {
+ if (len == 0)
+ lines->text = p;
if (*p == '\n') {
lines->length = len;
lines++;
len = 0;
- } else if (len == 0) {
- len++;
- lines->text = p;
} else
len++;
}
+ if (len == 0)
+ lines->text = p;
lines->length = len;
calc_line_widths (text);
@@ -1517,8 +1561,8 @@ _blink_scroll_timeout (gpointer data)
if (text->lastx - text->clip_cx > text->clip_cwidth &&
text->xofs_edit < text->max_width - text->clip_cwidth) {
text->xofs_edit += 4;
- if (text->xofs_edit > text->max_width - text->clip_cwidth)
- text->xofs_edit = text->max_width - text->clip_cwidth;
+ if (text->xofs_edit > text->max_width - text->clip_cwidth + 1)
+ text->xofs_edit = text->max_width - text->clip_cwidth + 1;
redraw = TRUE;
}
if (text->lastx - text->clip_cx < 0 &&
@@ -1826,6 +1870,31 @@ e_text_command(ETextEventProcessor *tep, ETextEventProcessorCommand *command, gp
case E_TEP_NOP:
break;
}
+
+ if (!text->button_down) {
+ int x;
+ int i;
+ struct line *lines = text->lines;
+ for (lines = text->lines, i = 0; i < text->num_lines ; i++, lines ++) {
+ if (lines->text - text->text > text->selection_end) {
+ break;
+ }
+ }
+ lines --;
+ x = gdk_text_width(text->font,
+ lines->text,
+ text->selection_end - (lines->text - text->text));
+
+
+ if (x < text->xofs_edit) {
+ text->xofs_edit = x;
+ }
+
+ if (2 + x - text->clip_width > text->xofs_edit) {
+ text->xofs_edit = 2 + x - text->clip_width;
+ }
+ }
+
gnome_canvas_item_request_update (GNOME_CANVAS_ITEM(text));
}