aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristopher James Lahey <clahey@ximian.com>2001-04-24 09:30:48 +0800
committerChris Lahey <clahey@src.gnome.org>2001-04-24 09:30:48 +0800
commit44c7d231440ad4f4ef59bfbf175be6cf35271e86 (patch)
tree9929929ac2369484283e05cac27bbcfacdfb4f57
parentfb53364c9c0114daa0f961965b38652016c900e5 (diff)
downloadgsoc2013-evolution-44c7d231440ad4f4ef59bfbf175be6cf35271e86.tar.gz
gsoc2013-evolution-44c7d231440ad4f4ef59bfbf175be6cf35271e86.tar.zst
gsoc2013-evolution-44c7d231440ad4f4ef59bfbf175be6cf35271e86.zip
Added get_cell_geometry method.
2001-04-23 Christopher James Lahey <clahey@ximian.com> * e-table-group-container.c, e-table-group-leaf.c, e-table-group.c, e-table-group-.h: Added get_cell_geometry method. * e-table-item.c, e-table-item.h: Added e_table_item_get_cell_geometry. * e-table.c, e-table.h: Added e_table_get_cell_geometry. svn path=/trunk/; revision=9532
-rw-r--r--widgets/table/e-table-group-container.c29
-rw-r--r--widgets/table/e-table-group-leaf.c10
-rw-r--r--widgets/table/e-table-group.c14
-rw-r--r--widgets/table/e-table-group.h10
-rw-r--r--widgets/table/e-table-item.c25
-rw-r--r--widgets/table/e-table-item.h7
-rw-r--r--widgets/table/e-table.c31
-rw-r--r--widgets/table/e-table.h5
8 files changed, 122 insertions, 9 deletions
diff --git a/widgets/table/e-table-group-container.c b/widgets/table/e-table-group-container.c
index abb2690b61..5812910643 100644
--- a/widgets/table/e-table-group-container.c
+++ b/widgets/table/e-table-group-container.c
@@ -665,6 +665,34 @@ etgc_compute_location (ETableGroup *etg, int *x, int *y, int *row, int *col)
}
}
+static void
+etgc_get_cell_geometry (ETableGroup *etg, int *row, int *col, int *x, int *y, int *width, int *height)
+{
+ ETableGroupContainer *etgc = E_TABLE_GROUP_CONTAINER(etg);
+
+ int ypos;
+
+ ypos = 0;
+
+ if (etgc->children) {
+ GList *list;
+ for (list = etgc->children; list; list = list->next) {
+ ETableGroupContainerChildNode *child_node = (ETableGroupContainerChildNode *)list->data;
+ ETableGroup *child = child_node->child;
+ int thisy;
+
+ e_table_group_get_cell_geometry (child, row, col, x, &thisy, width, height);
+ ypos += thisy;
+ if ((*row == -1) || (*col == -1)) {
+ ypos += TITLE_HEIGHT;
+ *x += GROUP_INDENT;
+ *y = ypos;
+ return;
+ }
+ }
+ }
+}
+
static void etgc_thaw (ETableGroup *etg)
{
e_canvas_item_request_reflow (GNOME_CANVAS_ITEM(etg));
@@ -817,6 +845,7 @@ etgc_class_init (GtkObjectClass *object_class)
e_group_class->get_focus_column = etgc_get_focus_column;
e_group_class->get_printable = etgc_get_printable;
e_group_class->compute_location = etgc_compute_location;
+ e_group_class->get_cell_geometry = etgc_get_cell_geometry;
gtk_object_add_arg_type ("ETableGroupContainer::horizontal_draw_grid", GTK_TYPE_BOOL,
GTK_ARG_WRITABLE, ARG_TABLE_HORIZONTAL_DRAW_GRID);
diff --git a/widgets/table/e-table-group-leaf.c b/widgets/table/e-table-group-leaf.c
index b1a91ad67e..c1e303f9e7 100644
--- a/widgets/table/e-table-group-leaf.c
+++ b/widgets/table/e-table-group-leaf.c
@@ -295,6 +295,13 @@ etgl_compute_location (ETableGroup *etg, int *x, int *y, int *row, int *col)
}
static void
+etgl_get_cell_geometry (ETableGroup *etg, int *row, int *col, int *x, int *y, int *width, int *height)
+{
+ ETableGroupLeaf *etgl = E_TABLE_GROUP_LEAF (etg);
+ e_table_item_get_cell_geometry (etgl->item, row, col, x, y, width, height);
+}
+
+static void
etgl_set_arg (GtkObject *object, GtkArg *arg, guint arg_id)
{
ETableGroup *etg = E_TABLE_GROUP (object);
@@ -427,7 +434,8 @@ etgl_class_init (GtkObjectClass *object_class)
e_group_class->get_focus_column = etgl_get_focus_column;
e_group_class->get_printable = etgl_get_printable;
e_group_class->compute_location = etgl_compute_location;
-
+ e_group_class->get_cell_geometry = etgl_get_cell_geometry;
+
gtk_object_add_arg_type ("ETableGroupLeaf::horizontal_draw_grid", GTK_TYPE_BOOL,
GTK_ARG_WRITABLE, ARG_TABLE_HORIZONTAL_DRAW_GRID);
gtk_object_add_arg_type ("ETableGroupLeaf::vertical_draw_grid", GTK_TYPE_BOOL,
diff --git a/widgets/table/e-table-group.c b/widgets/table/e-table-group.c
index f70b9abaf6..c31be579d4 100644
--- a/widgets/table/e-table-group.c
+++ b/widgets/table/e-table-group.c
@@ -381,13 +381,19 @@ e_table_group_compute_location (ETableGroup *etg, int *x, int *y, int *row, int
* removed from the value row points to.
*/
void
-e_table_group_get_position (ETableGroup *etg, int *x, int *y, int *row, int *col)
+e_table_group_get_cell_geometry (ETableGroup *etg,
+ int *row,
+ int *col,
+ int *x,
+ int *y,
+ int *width,
+ int *height)
{
g_return_if_fail (etg != NULL);
g_return_if_fail (E_IS_TABLE_GROUP (etg));
- if (ETG_CLASS (etg)->get_position)
- ETG_CLASS (etg)->get_position (etg, x, y, row, col);
+ if (ETG_CLASS (etg)->get_cell_geometry)
+ ETG_CLASS (etg)->get_cell_geometry (etg, row, col, x, y, width, height);
}
/**
@@ -592,7 +598,7 @@ etg_class_init (GtkObjectClass *object_class)
klass->get_focus = etg_get_focus;
klass->get_printable = NULL;
klass->compute_location = NULL;
- klass->get_position = NULL;
+ klass->get_cell_geometry = NULL;
etg_parent_class = gtk_type_class (PARENT_TYPE);
diff --git a/widgets/table/e-table-group.h b/widgets/table/e-table-group.h
index f8d23168fe..18866b7ad5 100644
--- a/widgets/table/e-table-group.h
+++ b/widgets/table/e-table-group.h
@@ -67,7 +67,7 @@ typedef struct {
gint (*get_focus_column) (ETableGroup *etg);
EPrintable *(*get_printable) (ETableGroup *etg);
void (*compute_location) (ETableGroup *etg, int *x, int *y, int *row, int *col);
- void (*get_position) (ETableGroup *etg, int *x, int *y, int *row, int *col);
+ void (*get_cell_geometry) (ETableGroup *etg, int *row, int *col, int *x, int *y, int *width, int *height);
} ETableGroupClass;
@@ -99,11 +99,13 @@ void e_table_group_compute_location (ETableGroup *etg,
int *y,
int *row,
int *col);
-void e_table_group_get_position (ETableGroup *etg,
+void e_table_group_get_cell_geometry (ETableGroup *etg,
+ int *row,
+ int *col,
int *x,
int *y,
- int *row,
- int *col);
+ int *width,
+ int *height);
ETableGroup *e_table_group_new (GnomeCanvasGroup *parent,
ETableHeader *full_header,
ETableHeader *header,
diff --git a/widgets/table/e-table-item.c b/widgets/table/e-table-item.c
index 5b2875425a..2509299fe2 100644
--- a/widgets/table/e-table-item.c
+++ b/widgets/table/e-table-item.c
@@ -2415,6 +2415,31 @@ e_table_item_compute_location (ETableItem *eti,
eti->grabbed_row = grabbed_row;
}
+void
+e_table_item_get_cell_geometry (ETableItem *eti,
+ int *row,
+ int *col,
+ int *x,
+ int *y,
+ int *width,
+ int *height)
+{
+ if (eti->rows > *row) {
+ if (x)
+ *x = e_table_header_col_diff (eti->header, 0, *col);
+ if (y)
+ *y = e_table_item_row_diff (eti, 0, *row);
+ if (width)
+ *width = e_table_header_col_diff (eti->header, *col, *col + 1);
+ if (height)
+ *height = ETI_ROW_HEIGHT (eti, *row);
+ *row = -1;
+ *col = -1;
+ } else {
+ *row -= eti->rows;
+ }
+}
+
typedef struct {
ETableItem *item;
int rows_printed;
diff --git a/widgets/table/e-table-item.h b/widgets/table/e-table-item.h
index c5281b5185..2b0d5a11cc 100644
--- a/widgets/table/e-table-item.h
+++ b/widgets/table/e-table-item.h
@@ -140,6 +140,13 @@ void e_table_item_compute_location (ETableItem *eti,
int *y,
int *row,
int *col);
+void e_table_item_get_cell_geometry (ETableItem *eti,
+ int *row,
+ int *col,
+ int *x,
+ int *y,
+ int *width,
+ int *height);
int e_table_item_row_diff (ETableItem *eti,
int start_row,
diff --git a/widgets/table/e-table.c b/widgets/table/e-table.c
index 059d339444..cb725c9a1f 100644
--- a/widgets/table/e-table.c
+++ b/widgets/table/e-table.c
@@ -1522,6 +1522,37 @@ e_table_get_cell_at (ETable *table,
e_table_group_compute_location(table->group, &x, &y, row_return, col_return);
}
+/**
+ * e_table_get_cell_at:
+ * @table: An ETable widget
+ * @x: X coordinate for the pixel
+ * @y: Y coordinate for the pixel
+ * @row_return: Pointer to return the row value
+ * @col_return: Pointer to return the column value
+ *
+ * Return the row and column for the cell in which the pixel at (@x, @y) is
+ * contained.
+ **/
+void
+e_table_get_cell_geometry (ETable *table,
+ int row, int col,
+ int *x_return, int *y_return,
+ int *width_return, int *height_return)
+{
+ g_return_if_fail (table != NULL);
+ g_return_if_fail (E_IS_TABLE (table));
+
+ /* FIXME it would be nice if it could handle a NULL row_return or
+ * col_return gracefully. */
+
+ e_table_group_get_cell_geometry(table->group, &row, &col, x_return, y_return, width_return, height_return);
+
+ if (x_return)
+ (*x_return) -= GTK_LAYOUT(table->table_canvas)->hadjustment->value;
+ if (y_return)
+ (*y_return) -= GTK_LAYOUT(table->table_canvas)->vadjustment->value;
+}
+
struct _ETableDragSourceSite
{
GdkModifierType start_button_mask;
diff --git a/widgets/table/e-table.h b/widgets/table/e-table.h
index 307952fbef..8f489f3439 100644
--- a/widgets/table/e-table.h
+++ b/widgets/table/e-table.h
@@ -230,6 +230,11 @@ void e_table_get_cell_at (ETable *table,
int x, int y,
int *row_return, int *col_return);
+void e_table_get_cell_geometry (ETable *table,
+ int row, int col,
+ int *x_return, int *y_return,
+ int *width_return, int *height_return);
+
/* Drag & drop stuff. */
/* Target */
void e_table_drag_get_data (ETable *table,