aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/table/e-cell-text.c
diff options
context:
space:
mode:
authorMiguel de Icaza <miguel@gnu.org>1999-11-30 13:50:54 +0800
committerArturo Espinosa <unammx@src.gnome.org>1999-11-30 13:50:54 +0800
commitc50636dba333983e99deeb76338bbec3390a1fbe (patch)
treec89789be25d6ec51dfa37ea7051f203617439911 /widgets/table/e-cell-text.c
parent6e69c396983498a6ff78a33928ad5fec98c8513f (diff)
downloadgsoc2013-evolution-c50636dba333983e99deeb76338bbec3390a1fbe.tar
gsoc2013-evolution-c50636dba333983e99deeb76338bbec3390a1fbe.tar.gz
gsoc2013-evolution-c50636dba333983e99deeb76338bbec3390a1fbe.tar.bz2
gsoc2013-evolution-c50636dba333983e99deeb76338bbec3390a1fbe.tar.lz
gsoc2013-evolution-c50636dba333983e99deeb76338bbec3390a1fbe.tar.xz
gsoc2013-evolution-c50636dba333983e99deeb76338bbec3390a1fbe.tar.zst
gsoc2013-evolution-c50636dba333983e99deeb76338bbec3390a1fbe.zip
New file. Implement a multi-state image toggle cell object.
1999-11-29 Miguel de Icaza <miguel@gnu.org> * e-cell-toggle.c, e-cell-toggle.h: New file. Implement a multi-state image toggle cell object. * e-cell-text.c (ect_leave_edit): Handle the case of us calling leave edit manually. (ect_stop_editing): Leave manually editing here. (ect_draw): Add one pixel to the border for left and right; Handle off-screen cursor (must be improved). (ect_edit_select_all): New function. (ect_event): Select all text on editing start * e-table-item.c (eti_event): Map mouse events and dispatch them. (eti_event): Add spreadsheet mode for editing; Enter editing only with visual characters; Leave editing mode when a different row has been selected. (eti_get_height): Fix the computation for this; Fix logic for the length_threshold. (eti_draw): Add borders on all sides of the box; Only draw focus if the cell is not being edited. svn path=/trunk/; revision=1445
Diffstat (limited to 'widgets/table/e-cell-text.c')
-rw-r--r--widgets/table/e-cell-text.c74
1 files changed, 58 insertions, 16 deletions
diff --git a/widgets/table/e-cell-text.c b/widgets/table/e-cell-text.c
index f0501ab4cb..b18c179ca5 100644
--- a/widgets/table/e-cell-text.c
+++ b/widgets/table/e-cell-text.c
@@ -82,6 +82,8 @@ ect_stop_editing (ECellTextView *text_view)
g_free (edit);
text_view->edit = NULL;
+
+ e_table_item_leave_edit (text_view->eti);
}
/*
@@ -166,8 +168,6 @@ ect_draw (ECellView *ecell_view, GdkDrawable *drawable,
if (text_view->edit){
CellEdit *edit = text_view->edit;
- printf ("We are editing a cell [%d %d %d %d]\n", col, row, edit->col, edit->row);
-
if ((edit->col == col) && (edit->row == row))
edit_display = TRUE;
}
@@ -192,11 +192,6 @@ ect_draw (ECellView *ecell_view, GdkDrawable *drawable,
text_wc [text_wc_len] = 0;
/*
- * Find a good spot for painting
- */
- xoff = 0;
-
- /*
* Paint
*/
gdk_gc_set_foreground (text_view->gc, &w->style->base [GTK_STATE_NORMAL]);
@@ -208,11 +203,23 @@ ect_draw (ECellView *ecell_view, GdkDrawable *drawable,
GdkGC *gc = text_view->gc;
const int y = y2 - font->descent - ((y2-y1-height)/2);
int px, i;
+
+ /*
+ * Border
+ */
+ x1 += 2;
+ x2--;
px = x1;
- printf ("Cursor at: %d\n", cursor_pos);
-
+ /*
+ * If the cursor is outside the visible range
+ *
+ * FIXME: we really want a better behaviour.
+ */
+ if ((px + left_len) > x2)
+ px -= left_len - (x2-x1);
+
for (i = 0; *text_wc; text_wc++, i++){
gdk_draw_text_wc (
drawable, font, gc, px, y, text_wc, 1);
@@ -240,6 +247,12 @@ ect_draw (ECellView *ecell_view, GdkDrawable *drawable,
*/
GdkColor *background, *foreground;
int width;
+
+ /*
+ * Border
+ */
+ x1++;
+ x2--;
/*
* Compute draw mode
@@ -285,6 +298,17 @@ ect_draw (ECellView *ecell_view, GdkDrawable *drawable,
}
/*
+ * Selects the entire string
+ */
+static void
+ect_edit_select_all (ECellTextView *text_view)
+{
+ g_assert (text_view->edit);
+
+ gtk_editable_select_region (GTK_EDITABLE (text_view->edit->entry), 0, -1);
+}
+
+/*
* ECell::event method
*/
static gint
@@ -294,6 +318,12 @@ ect_event (ECellView *ecell_view, GdkEvent *event, int col, int row)
switch (event->type){
case GDK_BUTTON_PRESS:
+ /*
+ * Adjust for the border we use
+ */
+ event->button.x++;
+
+ printf ("Button pressed at %g %g\n", event->button.x, event->button.y);
if (text_view->edit){
printf ("FIXME: Should handle click here\n");
} else
@@ -301,6 +331,11 @@ ect_event (ECellView *ecell_view, GdkEvent *event, int col, int row)
break;
case GDK_BUTTON_RELEASE:
+ /*
+ * Adjust for the border we use
+ */
+ event->button.x++;
+ printf ("Button released at %g %g\n", event->button.x, event->button.y);
return TRUE;
case GDK_KEY_PRESS:
@@ -309,8 +344,10 @@ ect_event (ECellView *ecell_view, GdkEvent *event, int col, int row)
return TRUE;
}
- if (!text_view->edit)
+ if (!text_view->edit){
e_table_item_enter_edit (text_view->eti, col, row);
+ ect_edit_select_all (text_view);
+ }
gtk_widget_event (GTK_WIDGET (text_view->edit->entry), event);
ect_queue_redraw (text_view, col, row);
@@ -355,10 +392,11 @@ ect_enter_edit (ECellView *ecell_view, int col, int row)
const char *str = e_table_model_value_at (ecell_view->ecell->table_model, col, row);
CellEdit *edit;
- printf ("Entering edit mode! [%d %d]\n", col, row);
-
edit = g_new (CellEdit, 1);
text_view->edit = edit;
+
+ edit->col = col;
+ edit->row = row;
edit->entry = (GtkEntry *) gtk_entry_new ();
gtk_entry_set_text (edit->entry, str);
@@ -387,10 +425,14 @@ ect_leave_edit (ECellView *ecell_view, int col, int row, void *edit_context)
{
ECellTextView *text_view = (ECellTextView *) ecell_view;
- printf ("Leaving edit mode!\n");
-
- ect_accept_edits (text_view);
- ect_stop_editing (text_view);
+ if (text_view->edit){
+ ect_accept_edits (text_view);
+ ect_stop_editing (text_view);
+ } else {
+ /*
+ * We did invoke this leave edit internally
+ */
+ }
}
/*