aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/table/e-table-item.c
diff options
context:
space:
mode:
authorChristopher James Lahey <clahey@helixcode.com>2000-02-24 14:51:23 +0800
committerChris Lahey <clahey@src.gnome.org>2000-02-24 14:51:23 +0800
commit7699b8996aa2d9ae3fea0e94981637c98e89a273 (patch)
treef4321790cd8c8619babfac9e2d4f38ca621d7e2d /widgets/table/e-table-item.c
parent6b338ae8ecd1332f574e33620e0765a16aab03a3 (diff)
downloadgsoc2013-evolution-7699b8996aa2d9ae3fea0e94981637c98e89a273.tar.gz
gsoc2013-evolution-7699b8996aa2d9ae3fea0e94981637c98e89a273.tar.zst
gsoc2013-evolution-7699b8996aa2d9ae3fea0e94981637c98e89a273.zip
This were moved to widgets/e-text/ a while ago but never removed. They
2000-02-24 Christopher James Lahey <clahey@helixcode.com> * widgets/e-text.c, widgets/e-text.h, e-text-event-processor.c, e-text-event-processor.h, e-text-event-processor-emacs-like.c, e-text-event-processor-emacs-like.h, e-text-event-processor-types.h: This were moved to widgets/e-text/ a while ago but never removed. They have now been removed. * widgets/e-text/e-text.c, widgets/e-text/e-text.h: Removed some warnings from this file. Made tooltips disappear when you're finished with them. * widgets/e-minicard/test-reflow.c, widgets/e-minicard/test-minicard.c, widgets/e-minicard/test-minicard-label.c: Commented out unused about_callback functions. * widgets/e-minicard/e-reflow.c: Made e-reflow pass an EFocus to its e-minicard children. * widgets/e-minicard/e-minicard.c: Made e-minicard take and return an EFocus for its "has_focus" argument. This makes shift-tab work properly. * widgets/e-minicard/e-minicard-label.c: Made e-minicard-label take and return an EFocus for its "has_focus" argument. Made the font that e-minicard-label uses only be allocated once. * e-util/e-canvas-utils.h: Fixed the comment at the top and added #ifndef __E_CANVAS_UTILS__. * e-util/Makefile.am: Added e-xml-utils.c and e-xml-utils.h. * e-util/e-xml-utils.h, e-util/e-xml-utils.c: Added files for some xml utilities. * e-util/e-util.h: Added type EFocus which describes which direction the focus will be coming from. in mail: 2000-02-24 Christopher James Lahey <clahey@helixcode.com> * message-list.c: Changed this to not use the "x" and "y" arguments to e-table-item. in widgets/e-table: 2000-02-24 Christopher James Lahey <clahey@helixcode.com> * e-table-subset-variable.c, e-table-subset-variable.h: A new model which is a subset, but you can add and remove rows. * test-table.c: Added a thaw method for use with the e-table-subset (emits model_changed.) Adapted to the changes to e_table_item. Properly parse headers. Adapted to the changes to e_table, including creating example xml spec data. * test-cols.c, test-check.c: Added a thaw method for use with the e-table-subset (emits model_changed.) Adapted to the changes to e_table_item. * e-table.c, e-table.h: Reworked e-table to use the ETable grouping system. The only difference for the interface is that instead of passing in a column_spec and a grouping_spec, you pass in a single string that is an xml format that includes both pieces of information. * e-table-subset.h: Added rules for emacs to do correct indentation. * e-table-subset.c: Implemented freezing. No signals are emitted while frozen and "model_changed" is emitted when thawed. * e-table-sorted.h: ETableSortedClass has ETableSubset as its parent object instead of ETableSubsetClass. Fixed this. * e-table-simple.c, e-table-simple.h: Implemented the thaw method. Use of simple now requires an extra argument (the thaw method.) * e-table-model.h, e-table-model.c: Added e_table_model_freeze and e_table_model_thaw. * e-table-item.h, e-table-item.c: Reworked this a bit to make it provide some things the new group system needed and to make inter-item keyboard focus work. Changed the external interface only in the list of arguments it recognizes and signals it emits. Instead of "x" and "y", you have to use e_canvas_item_move_absolute and instead of emitting a "height_changed" signal, it emits a "resize" signal. There's new "has_focus", "width", and "height" arguments and a function to get the currently focused column. * e-table-header-item.c: Got rid of some warnings here. Changed the * e-table-group-leaf.h, e-table-group-leaf.c, e-table-group-container.h, e-table-group-container.c: New types to make e_table_group work properly. * e-table-group.h, e-table-group.c: Completely reworked e-table grouping. e-table-group now uses a hierarchical structure. * e-cell.h: Added e_cell_print. This doesn't work yet. * e-cell.c: Made e_cell_realize exist. (It was improperly named e_cell_view_realize in the .c.) * e-cell-text.c: Made the blinking cursor disappear properly. * check-filled.xpm, check-empty.xpm: Made these const char *[] instead of char *[] to avoid compiler warnings. * Makefile.am: Added e-table-group-container.c, e-table-group-container.h, e-table-group-leaf.c, e-table-group-leaf.h, e-table-subset-variable.c, e-table-subset-variable.h. svn path=/trunk/; revision=1915
Diffstat (limited to 'widgets/table/e-table-item.c')
-rw-r--r--widgets/table/e-table-item.c163
1 files changed, 102 insertions, 61 deletions
diff --git a/widgets/table/e-table-item.c b/widgets/table/e-table-item.c
index 130c51a85c..d8ecdf1404 100644
--- a/widgets/table/e-table-item.c
+++ b/widgets/table/e-table-item.c
@@ -1,3 +1,4 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* E-table-item.c: A GnomeCanvasItem that is a view of an ETableModel.
*
@@ -26,7 +27,7 @@ static GnomeCanvasItemClass *eti_parent_class;
enum {
ROW_SELECTION,
- HEIGHT_CHANGED,
+ RESIZE,
LAST_SIGNAL
};
@@ -36,12 +37,14 @@ enum {
ARG_0,
ARG_TABLE_HEADER,
ARG_TABLE_MODEL,
- ARG_TABLE_X,
- ARG_TABLE_Y,
ARG_TABLE_DRAW_GRID,
ARG_TABLE_DRAW_FOCUS,
ARG_MODE_SPREADSHEET,
- ARG_LENGHT_THRESHOLD
+ ARG_LENGHT_THRESHOLD,
+
+ ARG_WIDTH,
+ ARG_HEIGHT,
+ ARG_HAS_FOCUS
};
static gboolean
@@ -67,7 +70,7 @@ eti_realize_cell_views (ETableItem *eti)
int i;
for (i = 0; i < eti->n_cells; i++)
- e_cell_view_realize (eti->cell_views [i], eti);
+ e_cell_realize (eti->cell_views [i]);
eti->cell_views_realized = 1;
}
@@ -287,13 +290,13 @@ eti_compute_height (ETableItem *eti)
int new_height = eti_get_height (eti);
if (new_height != eti->height){
- double x1, y1, x2, y2;
+ /* double x1, y1, x2, y2;*/
printf ("Emitting!\n");
eti->height = new_height;
eti_update (GNOME_CANVAS_ITEM (eti), NULL, NULL, 0);
- gtk_signal_emit (GTK_OBJECT (eti), eti_signals [HEIGHT_CHANGED]);
+ gtk_signal_emit (GTK_OBJECT (eti), eti_signals [RESIZE]);
}
}
@@ -537,14 +540,6 @@ eti_set_arg (GtkObject *o, GtkArg *arg, guint arg_id)
eti_add_table_model (eti, GTK_VALUE_POINTER (*arg));
break;
- case ARG_TABLE_X:
- eti->x1 = GTK_VALUE_DOUBLE (*arg);
- break;
-
- case ARG_TABLE_Y:
- eti->y1 = GTK_VALUE_DOUBLE (*arg);
- break;
-
case ARG_LENGHT_THRESHOLD:
eti->length_threshold = GTK_VALUE_INT (*arg);
break;
@@ -565,6 +560,27 @@ eti_set_arg (GtkObject *o, GtkArg *arg, guint arg_id)
}
static void
+eti_get_arg (GtkObject *o, GtkArg *arg, guint arg_id)
+{
+ GnomeCanvasItem *item;
+ ETableItem *eti;
+
+ item = GNOME_CANVAS_ITEM (o);
+ eti = E_TABLE_ITEM (o);
+
+ switch (arg_id){
+ case ARG_WIDTH:
+ GTK_VALUE_DOUBLE (*arg) = eti->width;
+ break;
+ case ARG_HEIGHT:
+ GTK_VALUE_DOUBLE (*arg) = eti->height;
+ break;
+ default:
+ arg->type = GTK_TYPE_INVALID;
+ }
+}
+
+static void
eti_init (GnomeCanvasItem *item)
{
ETableItem *eti = E_TABLE_ITEM (item);
@@ -576,7 +592,7 @@ eti_init (GnomeCanvasItem *item)
eti->height = 0;
eti->length_threshold = -1;
- eti->renderers_can_change_size = 0;
+ eti->renderers_can_change_size = 1;
eti->selection_mode = GTK_SELECTION_SINGLE;
}
@@ -878,31 +894,34 @@ find_cell (ETableItem *eti, double x, double y, int *col_res, int *row_res, doub
}
static void
-eti_cursor_move_left (ETableItem *eti)
+eti_cursor_move (ETableItem *eti, gint row, gint column)
{
e_table_item_leave_edit (eti);
- e_table_item_focus (eti, eti->focused_col - 1, eti->focused_row);
+ e_table_item_focus (eti, column, row);
+}
+
+static void
+eti_cursor_move_left (ETableItem *eti)
+{
+ eti_cursor_move(eti, eti->focused_row, eti->focused_col - 1);
}
static void
eti_cursor_move_right (ETableItem *eti)
{
- e_table_item_leave_edit (eti);
- e_table_item_focus (eti, eti->focused_col + 1, eti->focused_row);
+ eti_cursor_move(eti, eti->focused_row, eti->focused_col + 1);
}
static void
eti_cursor_move_up (ETableItem *eti)
{
- e_table_item_leave_edit (eti);
- e_table_item_focus (eti, eti->focused_col, eti->focused_row - 1);
+ eti_cursor_move(eti, eti->focused_row - 1, eti->focused_col);
}
static void
eti_cursor_move_down (ETableItem *eti)
{
- e_table_item_leave_edit (eti);
- e_table_item_focus (eti, eti->focused_col, eti->focused_row + 1);
+ eti_cursor_move(eti, eti->focused_row + 1, eti->focused_col);
}
static int
@@ -911,6 +930,7 @@ eti_event (GnomeCanvasItem *item, GdkEvent *e)
ETableItem *eti = E_TABLE_ITEM (item);
ECellView *ecell_view;
ETableCol *ecol;
+ gint return_val = TRUE;
switch (e->type){
case GDK_BUTTON_PRESS:
@@ -982,66 +1002,66 @@ eti_event (GnomeCanvasItem *item, GdkEvent *e)
if (eti->focused_col > 0)
eti_cursor_move_left (eti);
-
- return TRUE;
-
+ break;
+
case GDK_Right:
if (!eti->mode_spreadsheet && eti_editing (eti))
break;
- if ((eti->focused_col + 1) < eti->cols)
+ if (eti->focused_col < eti->cols - 1)
eti_cursor_move_right (eti);
- return TRUE;
-
+ break;
+
case GDK_Up:
if (eti->focused_row > 0)
eti_cursor_move_up (eti);
- return TRUE;
+ else
+ return_val = FALSE;
+ break;
case GDK_Down:
if ((eti->focused_row + 1) < eti->rows)
eti_cursor_move_down (eti);
-
- return TRUE;
+ else
+ return_val = FALSE;
+ break;
case GDK_Tab:
+ case GDK_KP_Tab:
+ case GDK_ISO_Left_Tab:
if ((e->key.state & GDK_SHIFT_MASK) != 0){
/* shift tab */
if (eti->focused_col > 0)
eti_cursor_move_left (eti);
- else if (eti->focused_row > 0){
- e_table_item_leave_edit (eti);
- e_table_item_focus (eti, eti->cols - 1, eti->focused_row - 1);
- } else {
- /* FIXME: request focus leave backward */
- }
+ else if (eti->focused_row > 0)
+ eti_cursor_move(eti, eti->focused_row - 1, eti->cols - 1);
+ else
+ return_val = FALSE;
} else {
- if ((eti->focused_col + 1) < eti->cols)
+ if (eti->focused_col < eti->cols - 1)
eti_cursor_move_right (eti);
- else if ((eti->focused_row + 1) < eti->rows){
- e_table_item_leave_edit (eti);
- e_table_item_focus (eti, 0, eti->rows - 1);
- } else {
- /* FIXME: request focus leave forward */
- }
+ else if (eti->focused_row < eti->rows - 1)
+ eti_cursor_move(eti, eti->focused_row + 1, 0);
+ else
+ return_val = FALSE;
}
break;
default:
if (!eti_editing (eti)){
if ((e->key.state & (GDK_MOD1_MASK | GDK_CONTROL_MASK)) != 0)
- return 0;
+ return_val = FALSE;
if (!(e->key.keyval >= 0x20 && e->key.keyval <= 0xff))
- return 0;
+ return_val = FALSE;
}
- }
- ecol = e_table_header_get_column (eti->header, eti->focused_col);
- ecell_view = eti->cell_views [eti->focused_col];
- e_cell_event (ecell_view, e, ecol->col_idx, eti->focused_col, eti->focused_row);
+ ecol = e_table_header_get_column (eti->header, eti->focused_col);
+ ecell_view = eti->cell_views [eti->focused_col];
+ e_cell_event (ecell_view, e, ecol->col_idx, eti->focused_col, eti->focused_row);
+ }
break;
-
+
case GDK_KEY_RELEASE:
if (eti->focused_col == -1)
return FALSE;
@@ -1053,8 +1073,15 @@ eti_event (GnomeCanvasItem *item, GdkEvent *e)
}
break;
+ case GDK_FOCUS_CHANGE:
+ if (e->focus_change.in) {
+ } else {
+ e_table_item_leave_edit (eti);
+ e_table_item_unfocus (eti);
+ }
+
default:
- return FALSE;
+ return_val = FALSE;
}
return TRUE;
}
@@ -1084,6 +1111,7 @@ eti_class_init (GtkObjectClass *object_class)
object_class->destroy = eti_destroy;
object_class->set_arg = eti_set_arg;
+ object_class->get_arg = eti_get_arg;
item_class->update = eti_update;
item_class->realize = eti_realize;
@@ -1099,10 +1127,6 @@ eti_class_init (GtkObjectClass *object_class)
GTK_ARG_WRITABLE, ARG_TABLE_HEADER);
gtk_object_add_arg_type ("ETableItem::ETableModel", GTK_TYPE_POINTER,
GTK_ARG_WRITABLE, ARG_TABLE_MODEL);
- gtk_object_add_arg_type ("ETableItem::x", GTK_TYPE_DOUBLE,
- GTK_ARG_WRITABLE, ARG_TABLE_X);
- gtk_object_add_arg_type ("ETableItem::y", GTK_TYPE_DOUBLE,
- GTK_ARG_WRITABLE, ARG_TABLE_Y);
gtk_object_add_arg_type ("ETableItem::drawgrid", GTK_TYPE_BOOL,
GTK_ARG_WRITABLE, ARG_TABLE_DRAW_GRID);
gtk_object_add_arg_type ("ETableItem::drawfocus", GTK_TYPE_BOOL,
@@ -1110,6 +1134,13 @@ eti_class_init (GtkObjectClass *object_class)
gtk_object_add_arg_type ("ETableItem::spreadsheet", GTK_TYPE_BOOL,
GTK_ARG_WRITABLE, ARG_MODE_SPREADSHEET);
+ gtk_object_add_arg_type ("ETableItem::width", GTK_TYPE_DOUBLE,
+ GTK_ARG_READWRITE, ARG_WIDTH);
+ gtk_object_add_arg_type ("ETableItem::height", GTK_TYPE_DOUBLE,
+ GTK_ARG_READABLE, ARG_HEIGHT);
+ gtk_object_add_arg_type ("ETableItem::has_focus", GTK_TYPE_BOOL,
+ GTK_ARG_READWRITE, ARG_HAS_FOCUS);
+
eti_signals [ROW_SELECTION] =
gtk_signal_new ("row_selection",
GTK_RUN_LAST,
@@ -1118,11 +1149,11 @@ eti_class_init (GtkObjectClass *object_class)
gtk_marshal_NONE__INT_INT,
GTK_TYPE_NONE, 2, GTK_TYPE_INT, GTK_TYPE_INT);
- eti_signals [HEIGHT_CHANGED] =
- gtk_signal_new ("height_changed",
+ eti_signals [RESIZE] =
+ gtk_signal_new ("resize",
GTK_RUN_LAST,
object_class->type,
- GTK_SIGNAL_OFFSET (ETableItemClass, height_changed),
+ GTK_SIGNAL_OFFSET (ETableItemClass, resize),
gtk_marshal_NONE__NONE,
GTK_TYPE_NONE, 0);
@@ -1192,6 +1223,16 @@ e_table_item_unfocus (ETableItem *eti)
eti->focused_row = -1;
}
+gint
+e_table_item_get_focused_column (ETableItem *eti)
+{
+ g_return_val_if_fail (eti != NULL, -1);
+ g_return_val_if_fail (E_IS_TABLE_ITEM (eti), -1);
+
+ return eti->focused_col;
+}
+
+
const GSList *
e_table_item_get_selection (ETableItem *eti)
{