aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristopher James Lahey <clahey@helixcode.com>2000-12-10 06:20:52 +0800
committerChris Lahey <clahey@src.gnome.org>2000-12-10 06:20:52 +0800
commit3018f79188018eb590be1412a95b830a0d842fbc (patch)
tree50882bfcef5fcb05bbf4d07637be2da0b0bb0601
parent9cf73d61eb344bbbbf50d6932bff5ce23f2971e6 (diff)
downloadgsoc2013-evolution-3018f79188018eb590be1412a95b830a0d842fbc.tar
gsoc2013-evolution-3018f79188018eb590be1412a95b830a0d842fbc.tar.gz
gsoc2013-evolution-3018f79188018eb590be1412a95b830a0d842fbc.tar.bz2
gsoc2013-evolution-3018f79188018eb590be1412a95b830a0d842fbc.tar.lz
gsoc2013-evolution-3018f79188018eb590be1412a95b830a0d842fbc.tar.xz
gsoc2013-evolution-3018f79188018eb590be1412a95b830a0d842fbc.tar.zst
gsoc2013-evolution-3018f79188018eb590be1412a95b830a0d842fbc.zip
Added the actions parameter to ect_event. Added an actions field to
2000-12-09 Christopher James Lahey <clahey@helixcode.com> * e-cell-text.c: Added the actions parameter to ect_event. Added an actions field to CellEdit. Handle CellEdit properly in the ect_event function to do grabbing and ungrabbing when appropriate. Set the actions field in CellEdit when appropriate in e_cell_text_view_command. * e-cell-toggle.c, e-cell-tree.c, e-cell.c, e-cell.h: Added a ECellActions enum, a ECellActions actions parameter to e_cell_event and added the actions parameter to all the handlers of the event method including having ECellTree pass it on to its child cell. * e-table-header-item.c: Use the NULL cursor instead of the E_CURSORS_ARROW cursor. * e-table-item.c, e-table-item.h: Added grabbed_row and grabbed_col fields to ETableItem (-1 on either means ungrabbed.) Pay attention to them in the find_cell function. Handle the actions parameter of e_cell_event and grab or ungrab the pointer to a given cell if requested. This is done using the new function eti_e_cell_event (which is internal to e-table-item.c,) instead of the old e_cell_event function call. Fake an ungrabbed table when calling find_cell from within the compute_location method. svn path=/trunk/; revision=6889
-rw-r--r--widgets/table/e-cell-text.c20
-rw-r--r--widgets/table/e-cell-toggle.c2
-rw-r--r--widgets/table/e-cell-tree.c4
-rw-r--r--widgets/table/e-cell.c11
-rw-r--r--widgets/table/e-cell.h9
-rw-r--r--widgets/table/e-table-header-item.c6
-rw-r--r--widgets/table/e-table-item.c120
-rw-r--r--widgets/table/e-table-item.h2
8 files changed, 112 insertions, 62 deletions
diff --git a/widgets/table/e-cell-text.c b/widgets/table/e-cell-text.c
index 5a1251cf01..153501fa63 100644
--- a/widgets/table/e-cell-text.c
+++ b/widgets/table/e-cell-text.c
@@ -168,6 +168,8 @@ struct _CellEdit {
guint pointer_in : 1;
guint default_cursor_shown : 1;
+
+ ECellActions actions;
};
static void e_cell_text_view_command (ETextEventProcessor *tep, ETextEventProcessorCommand *command, gpointer data);
@@ -871,7 +873,7 @@ ect_edit_select_all (ECellTextView *text_view)
* ECell::event method
*/
static gint
-ect_event (ECellView *ecell_view, GdkEvent *event, int model_col, int view_col, int row, ECellFlags flags)
+ect_event (ECellView *ecell_view, GdkEvent *event, int model_col, int view_col, int row, ECellFlags flags, ECellActions *actions)
{
ECellTextView *text_view = (ECellTextView *) ecell_view;
ETextEventProcessorEvent e_tep_event;
@@ -943,6 +945,7 @@ ect_event (ECellView *ecell_view, GdkEvent *event, int model_col, int view_col,
_get_tep (edit);
return_val = e_text_event_processor_handle_event (edit->tep, &e_tep_event);
+ *actions = edit->actions;
if (e_tep_event.key.string) g_free (e_tep_event.key.string);
break;
}
@@ -974,6 +977,7 @@ ect_event (ECellView *ecell_view, GdkEvent *event, int model_col, int view_col,
_get_tep (edit);
return_val = e_text_event_processor_handle_event (edit->tep,
&e_tep_event);
+ *actions = edit->actions;
if (event->button.button == 1) {
if (event->type == GDK_BUTTON_PRESS)
edit->button_down = TRUE;
@@ -995,6 +999,7 @@ ect_event (ECellView *ecell_view, GdkEvent *event, int model_col, int view_col,
_get_tep (edit);
return_val = e_text_event_processor_handle_event (edit->tep,
&e_tep_event);
+ *actions = edit->actions;
if (event->button.button == 1) {
if (event->type == GDK_BUTTON_PRESS)
edit->button_down = TRUE;
@@ -1017,6 +1022,7 @@ ect_event (ECellView *ecell_view, GdkEvent *event, int model_col, int view_col,
_get_tep (edit);
return_val = e_text_event_processor_handle_event (edit->tep,
&e_tep_event);
+ *actions = edit->actions;
edit->lastx = motion.x;
edit->lasty = motion.y;
edit->last_state = motion.state;
@@ -2141,17 +2147,11 @@ e_cell_text_view_command (ETextEventProcessor *tep, ETextEventProcessorCommand *
edit->select_by_word = command->value;
break;
case E_TEP_GRAB:
- case E_TEP_UNGRAB:
-#if 0
- case E_TEP_GRAB:
- gnome_canvas_item_grab (GNOME_CANVAS_ITEM(text),
- GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK,
- text_view->i_cursor,
- command->time);
+ edit->actions = E_CELL_GRAB;
break;
- gnome_canvas_item_ungrab (GNOME_CANVAS_ITEM(text), command->time);
+ case E_TEP_UNGRAB:
+ edit->actions = E_CELL_UNGRAB;
break;
-#endif
case E_TEP_NOP:
break;
}
diff --git a/widgets/table/e-cell-toggle.c b/widgets/table/e-cell-toggle.c
index c4ddc66053..abfb264f9f 100644
--- a/widgets/table/e-cell-toggle.c
+++ b/widgets/table/e-cell-toggle.c
@@ -182,7 +182,7 @@ etog_set_value (ECellToggleView *toggle_view, int model_col, int view_col, int r
* ECell::event method
*/
static gint
-etog_event (ECellView *ecell_view, GdkEvent *event, int model_col, int view_col, int row, ECellFlags flags)
+etog_event (ECellView *ecell_view, GdkEvent *event, int model_col, int view_col, int row, ECellFlags flags, ECellActions *actions)
{
ECellToggleView *toggle_view = (ECellToggleView *) ecell_view;
void *_value = e_table_model_value_at (ecell_view->e_table_model, model_col, row);
diff --git a/widgets/table/e-cell-tree.c b/widgets/table/e-cell-tree.c
index 6de490cd29..510c993c1b 100644
--- a/widgets/table/e-cell-tree.c
+++ b/widgets/table/e-cell-tree.c
@@ -300,7 +300,7 @@ ect_draw (ECellView *ecell_view, GdkDrawable *drawable,
* ECell::event method
*/
static gint
-ect_event (ECellView *ecell_view, GdkEvent *event, int model_col, int view_col, int row, ECellFlags flags)
+ect_event (ECellView *ecell_view, GdkEvent *event, int model_col, int view_col, int row, ECellFlags flags, ECellActions *actions)
{
ECellTreeView *tree_view = (ECellTreeView *) ecell_view;
ETreeModel *tree_model = e_cell_tree_get_tree_model (ecell_view->e_table_model, row);
@@ -339,7 +339,7 @@ ect_event (ECellView *ecell_view, GdkEvent *event, int model_col, int view_col,
default:
/* nada */
}
- return e_cell_event(tree_view->subcell_view, event, model_col, view_col, row, flags);
+ return e_cell_event(tree_view->subcell_view, event, model_col, view_col, row, flags, actions);
}
}
diff --git a/widgets/table/e-cell.c b/widgets/table/e-cell.c
index ab22adb53e..db2277ba4e 100644
--- a/widgets/table/e-cell.c
+++ b/widgets/table/e-cell.c
@@ -43,7 +43,7 @@ ec_draw (ECellView *ecell_view, GdkDrawable *drawable,
}
static gint
-ec_event (ECellView *ecell_view, GdkEvent *event, int model_col, int view_col, int row, ECellFlags flags)
+ec_event (ECellView *ecell_view, GdkEvent *event, int model_col, int view_col, int row, ECellFlags flags, ECellActions *actions)
{
g_error ("e-cell-event invoked\n");
return 0;
@@ -52,7 +52,7 @@ ec_event (ECellView *ecell_view, GdkEvent *event, int model_col, int view_col, i
static gint
ec_height (ECellView *ecell_view, int model_col, int view_col, int row)
{
- g_error ("e-cell-event invoked\n");
+ g_error ("e-cell-height invoked\n");
return 0;
}
@@ -131,17 +131,18 @@ E_MAKE_TYPE(e_cell, "ECell", ECell, e_cell_class_init, e_cell_init, PARENT_TYPE)
* @model_col: the column in the model
* @view_col: the column in the view
* @row: the row
- * @flags: the flags passed to the ECellView.
+ * @flags: flags about the current state
+ * @actions: A second return value in case the cell wants to take some action (specifically grabbing & ungrabbing)
*
* Dispatches the event @event to the @ecell_view for.
*
* Returns: processing state from the GdkEvent handling.
*/
gint
-e_cell_event (ECellView *ecell_view, GdkEvent *event, int model_col, int view_col, int row, ECellFlags flags)
+e_cell_event (ECellView *ecell_view, GdkEvent *event, int model_col, int view_col, int row, ECellFlags flags, ECellActions *actions)
{
return E_CELL_CLASS (GTK_OBJECT (ecell_view->ecell)->klass)->event (
- ecell_view, event, model_col, view_col, row, flags);
+ ecell_view, event, model_col, view_col, row, flags, actions);
}
/**
diff --git a/widgets/table/e-cell.h b/widgets/table/e-cell.h
index a76f7e37f4..40ffae96ae 100644
--- a/widgets/table/e-cell.h
+++ b/widgets/table/e-cell.h
@@ -30,6 +30,11 @@ typedef enum {
E_CELL_EDITING = 1 << 4,
} ECellFlags;
+typedef enum {
+ E_CELL_GRAB = 1 << 0,
+ E_CELL_UNGRAB = 1 << 1,
+} ECellActions;
+
typedef struct {
GtkObject object;
} ECell;
@@ -57,7 +62,7 @@ typedef struct {
void (*draw) (ECellView *ecell_view, GdkDrawable *drawable,
int model_col, int view_col, int row,
ECellFlags flags, int x1, int y1, int x2, int y2);
- gint (*event) (ECellView *ecell_view, GdkEvent *event, int model_col, int view_col, int row, ECellFlags flags);
+ gint (*event) (ECellView *ecell_view, GdkEvent *event, int model_col, int view_col, int row, ECellFlags flags, ECellActions *actions);
void (*focus) (ECellView *ecell_view, int model_col, int view_col,
int row, int x1, int y1, int x2, int y2);
void (*unfocus) (ECellView *ecell_view);
@@ -78,7 +83,7 @@ GtkType e_cell_get_type (void);
ECellView *e_cell_new_view (ECell *ecell, ETableModel *table_model, void *e_table_item_view);
void e_cell_kill_view (ECellView *ecell_view);
-gint e_cell_event (ECellView *ecell_view, GdkEvent *event, int model_col, int view_col, int row, ECellFlags flags);
+gint e_cell_event (ECellView *ecell_view, GdkEvent *event, int model_col, int view_col, int row, ECellFlags flags, ECellActions *actions);
void e_cell_realize (ECellView *ecell_view);
void e_cell_unrealize (ECellView *ecell_view);
diff --git a/widgets/table/e-table-header-item.c b/widgets/table/e-table-header-item.c
index 6d12b6da46..71ae0e0c1e 100644
--- a/widgets/table/e-table-header-item.c
+++ b/widgets/table/e-table-header-item.c
@@ -913,7 +913,8 @@ set_cursor (ETableHeaderItem *ethi, int pos)
if (resizeable)
e_cursor_set (canvas->window, E_CURSOR_SIZE_X);
else
- e_cursor_set (canvas->window, E_CURSOR_ARROW);
+ gdk_window_set_cursor (canvas->window, NULL);
+ /* e_cursor_set (canvas->window, E_CURSOR_ARROW);*/
}
static void
@@ -1265,7 +1266,8 @@ ethi_event (GnomeCanvasItem *item, GdkEvent *e)
break;
case GDK_LEAVE_NOTIFY:
- e_cursor_set (GTK_WIDGET (canvas)->window, E_CURSOR_ARROW);
+ gdk_window_set_cursor (GTK_WIDGET (canvas)->window, NULL);
+ /* e_cursor_set (GTK_WIDGET (canvas)->window, E_CURSOR_ARROW);*/
break;
case GDK_MOTION_NOTIFY:
diff --git a/widgets/table/e-table-item.c b/widgets/table/e-table-item.c
index 67833f0f6b..1a6d866813 100644
--- a/widgets/table/e-table-item.c
+++ b/widgets/table/e-table-item.c
@@ -1016,36 +1016,39 @@ eti_init (GnomeCanvasItem *item)
{
ETableItem *eti = E_TABLE_ITEM (item);
- eti->editing_col = -1;
- eti->editing_row = -1;
- eti->height = 0;
- eti->width = 0;
- eti->minimum_width = 0;
-
- eti->height_cache = NULL;
- eti->height_cache_idle_id = 0;
- eti->height_cache_idle_count = 0;
+ eti->editing_col = -1;
+ eti->editing_row = -1;
+ eti->height = 0;
+ eti->width = 0;
+ eti->minimum_width = 0;
+
+ eti->height_cache = NULL;
+ eti->height_cache_idle_id = 0;
+ eti->height_cache_idle_count = 0;
- eti->length_threshold = -1;
+ eti->length_threshold = -1;
eti->renderers_can_change_size = 1;
- eti->uses_source_model = 0;
- eti->source_model = NULL;
+ eti->uses_source_model = 0;
+ eti->source_model = NULL;
- eti->row_guess = -1;
- eti->cursor_mode = E_TABLE_CURSOR_SIMPLE;
+ eti->row_guess = -1;
+ eti->cursor_mode = E_TABLE_CURSOR_SIMPLE;
- eti->selection_change_id = 0;
- eti->cursor_change_id = 0;
- eti->selection = NULL;
+ eti->selection_change_id = 0;
+ eti->cursor_change_id = 0;
+ eti->selection = NULL;
- eti->needs_redraw = 0;
- eti->needs_compute_height = 0;
+ eti->needs_redraw = 0;
+ eti->needs_compute_height = 0;
- eti->tooltip = g_new0 (ETableTooltip, 1);
- eti->tooltip->timer = 0;
- eti->tooltip->window = NULL;
- eti->tooltip->eti = GNOME_CANVAS_ITEM (eti);
+ eti->tooltip = g_new0 (ETableTooltip, 1);
+ eti->tooltip->timer = 0;
+ eti->tooltip->window = NULL;
+ eti->tooltip->eti = GNOME_CANVAS_ITEM (eti);
+
+ eti->grabbed_col = -1;
+ eti->grabbed_row = -1;
e_canvas_item_set_reflow_callback (GNOME_CANVAS_ITEM (eti), eti_reflow);
}
@@ -1362,6 +1365,14 @@ find_cell (ETableItem *eti, double x, double y, int *col_res, int *row_res, doub
int col, row;
/* FIXME: this routine is inneficient, fix later */
+
+ if (eti->grabbed_col >= 0 && eti->grabbed_row >= 0) {
+ *col_res = eti->grabbed_col;
+ *row_res = eti->grabbed_row;
+ *x1_res = x - eti->x1 - e_table_header_col_diff (eti->header, 0, eti->grabbed_col);
+ *y1_res = y - eti->y1 - eti_row_diff (eti, 0, eti->grabbed_row);
+ return TRUE;
+ }
if (cols == 0 || rows == 0)
return FALSE;
@@ -1486,6 +1497,29 @@ _do_tooltip (ETableItem *eti)
return FALSE;
}
+static gint
+eti_e_cell_event (ETableItem *item, ECellView *ecell_view, GdkEvent *event, int time, int model_col, int view_col, int row, ECellFlags flags)
+{
+ ECellActions actions = 0;
+ gint ret_val;
+
+ ret_val = e_cell_event (ecell_view, event, model_col, view_col, row, flags, &actions);
+
+ if (actions & E_CELL_GRAB) {
+ gnome_canvas_item_grab(GNOME_CANVAS_ITEM(item), GDK_POINTER_MOTION_MASK | GDK_BUTTON_RELEASE_MASK, NULL, time);
+ item->grabbed_col = view_col;
+ item->grabbed_row = row;
+ }
+
+ if (actions & E_CELL_UNGRAB) {
+ gnome_canvas_item_ungrab(GNOME_CANVAS_ITEM(item), time);
+ item->grabbed_col = -1;
+ item->grabbed_row = -1;
+ }
+
+ return ret_val;
+}
+
/* FIXME: cursor */
static int
eti_event (GnomeCanvasItem *item, GdkEvent *e)
@@ -1520,7 +1554,7 @@ eti_event (GnomeCanvasItem *item, GdkEvent *e)
button.x = x1;
button.y = y1;
- return_val = e_cell_event (ecell_view, (GdkEvent *) &button, view_to_model_col(eti, col), col, row, 0);
+ return_val = eti_e_cell_event (eti, ecell_view, (GdkEvent *) &button, button.time, view_to_model_col(eti, col), col, row, 0);
if (return_val)
return TRUE;
@@ -1547,8 +1581,8 @@ eti_event (GnomeCanvasItem *item, GdkEvent *e)
* Adjust the event positions
*/
- return_val = e_cell_event (ecell_view, (GdkEvent *) &button,
- view_to_model_col(eti, col), col, row, E_CELL_EDITING);
+ return_val = eti_e_cell_event (eti, ecell_view, (GdkEvent *) &button, button.time,
+ view_to_model_col(eti, col), col, row, E_CELL_EDITING);
}
break;
@@ -1607,8 +1641,8 @@ eti_event (GnomeCanvasItem *item, GdkEvent *e)
e->button.x = x1;
e->button.y = y1;
- return_val = e_cell_event (ecell_view, e,
- view_to_model_col(eti, col), col, row, E_CELL_EDITING);
+ return_val = eti_e_cell_event (eti, ecell_view, e, e->button.time,
+ view_to_model_col(eti, col), col, row, E_CELL_EDITING);
}
break;
case 3:
@@ -1675,8 +1709,8 @@ eti_event (GnomeCanvasItem *item, GdkEvent *e)
e->motion.x = x1;
e->motion.y = y1;
- return_val = e_cell_event (ecell_view, e,
- view_to_model_col(eti, col), col, row, E_CELL_EDITING);
+ return_val = eti_e_cell_event (eti, ecell_view, e, e->motion.time,
+ view_to_model_col(eti, col), col, row, E_CELL_EDITING);
}
break;
}
@@ -1765,9 +1799,9 @@ eti_event (GnomeCanvasItem *item, GdkEvent *e)
e_table_item_leave_edit (eti);
#if 0
ecell_view = eti->cell_views [eti->editing_col];
- return_val = e_cell_event (ecell_view, e,
- view_to_model_col(eti, eti->editing_col),
- eti->editing_col, eti->editing_row, E_CELL_EDITING);
+ return_val = eti_e_cell_event (eti, ecell_view, e, e->key.time,
+ view_to_model_col(eti, eti->editing_col),
+ eti->editing_col, eti->editing_row, E_CELL_EDITING);
#endif
}
return_val = FALSE;
@@ -1793,9 +1827,9 @@ eti_event (GnomeCanvasItem *item, GdkEvent *e)
model_to_view_row(eti, cursor_row), cursor_col, e, &return_val);
} else {
ecell_view = eti->cell_views [eti->editing_col];
- return_val = e_cell_event (ecell_view, e,
- view_to_model_col(eti, eti->editing_col),
- eti->editing_col, eti->editing_row, E_CELL_EDITING);
+ return_val = eti_e_cell_event (eti, ecell_view, e, e->key.time,
+ view_to_model_col(eti, eti->editing_col),
+ eti->editing_col, eti->editing_row, E_CELL_EDITING);
}
}
break;
@@ -1814,9 +1848,9 @@ eti_event (GnomeCanvasItem *item, GdkEvent *e)
if (eti_editing (eti)){
ecell_view = eti->cell_views [eti->editing_col];
- return_val = e_cell_event (ecell_view, e,
- view_to_model_col(eti, eti->editing_col),
- eti->editing_col, eti->editing_row, E_CELL_EDITING);
+ return_val = eti_e_cell_event (eti, ecell_view, e, e->key.time,
+ view_to_model_col(eti, eti->editing_col),
+ eti->editing_col, eti->editing_row, E_CELL_EDITING);
}
break;
}
@@ -2076,10 +2110,16 @@ e_table_item_compute_location (ETableItem *eti,
int *row,
int *col)
{
+ /* Save the grabbed row but make sure that we don't get flawed
+ results because the cursor is grabbed. */
+ int grabbed_row = eti->grabbed_row;
+ eti->grabbed_row = -1;
+
if (!find_cell (eti, *x, *y, col, row, NULL, NULL)) {
*y -= eti_get_height(eti);
}
-
+
+ eti->grabbed_row = grabbed_row;
}
typedef struct {
diff --git a/widgets/table/e-table-item.h b/widgets/table/e-table-item.h
index 9ce5cba637..eaf52882e6 100644
--- a/widgets/table/e-table-item.h
+++ b/widgets/table/e-table-item.h
@@ -86,6 +86,8 @@ typedef struct {
int editing_col, editing_row;
void *edit_ctx;
+ int grabbed_col, grabbed_row;
+
/*
* Tooltip
*/