aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/table
diff options
context:
space:
mode:
authorArturo Espinosa <unammx@src.gnome.org>1999-12-13 12:39:18 +0800
committerArturo Espinosa <unammx@src.gnome.org>1999-12-13 12:39:18 +0800
commitdf80388fd94f635a0fecb08314eafd5e25131800 (patch)
tree40dd55a1c27190d9180960a1e9fcffc05dab7205 /widgets/table
parent8846da8e48cacd7ab792bdcbec8eef19a9c19736 (diff)
downloadgsoc2013-evolution-df80388fd94f635a0fecb08314eafd5e25131800.tar
gsoc2013-evolution-df80388fd94f635a0fecb08314eafd5e25131800.tar.gz
gsoc2013-evolution-df80388fd94f635a0fecb08314eafd5e25131800.tar.bz2
gsoc2013-evolution-df80388fd94f635a0fecb08314eafd5e25131800.tar.lz
gsoc2013-evolution-df80388fd94f635a0fecb08314eafd5e25131800.tar.xz
gsoc2013-evolution-df80388fd94f635a0fecb08314eafd5e25131800.tar.zst
gsoc2013-evolution-df80388fd94f635a0fecb08314eafd5e25131800.zip
Works with GnomeCanvasGroups -miguel
svn path=/trunk/; revision=1484
Diffstat (limited to 'widgets/table')
-rw-r--r--widgets/table/e-table-group.h2
-rw-r--r--widgets/table/e-table-item.c81
-rw-r--r--widgets/table/e-table.c3
-rw-r--r--widgets/table/test-table.c14
4 files changed, 73 insertions, 27 deletions
diff --git a/widgets/table/e-table-group.h b/widgets/table/e-table-group.h
index d673aebd11..62bc11093f 100644
--- a/widgets/table/e-table-group.h
+++ b/widgets/table/e-table-group.h
@@ -15,7 +15,7 @@ typedef struct {
guint is_leaf :1;
} ETableGroup;
-ETableGroup *e_table_group_new (const char *title);
+ETableGroup *e_table_group_new (ETableCol *ecol, ETableItem *item
ETableGroup *e_table_group_new_leaf (const char *title, ETableModel *table);
void e_table_group_destroy (ETableGroup *etg);
diff --git a/widgets/table/e-table-item.c b/widgets/table/e-table-item.c
index d0a0ad8cba..26e21bfd98 100644
--- a/widgets/table/e-table-item.c
+++ b/widgets/table/e-table-item.c
@@ -14,6 +14,7 @@
#include <stdio.h>
#include <gtk/gtksignal.h>
#include <gdk/gdkkeysyms.h>
+#include <math.h>
#include "e-table-item.h"
#include "e-cell.h"
@@ -103,15 +104,27 @@ static void
eti_update (GnomeCanvasItem *item, double *affine, ArtSVP *clip_path, int flags)
{
ETableItem *eti = E_TABLE_ITEM (item);
+ double i2c [6];
+ ArtPoint c1, c2, i1, i2;
if (GNOME_CANVAS_ITEM_CLASS (eti_parent_class)->update)
(*GNOME_CANVAS_ITEM_CLASS (eti_parent_class)->update)(item, affine, clip_path, flags);
- item->x1 = eti->x1;
- item->y1 = eti->y1;
- item->x2 = eti->x1 + eti->width;
- item->y2 = eti->y1 + eti->height;
+ gnome_canvas_item_i2c_affine (item, i2c);
+ i1.x = eti->x1;
+ i1.y = eti->y1;
+ i2.x = eti->x1 + eti->width;
+ i2.y = eti->y1 + eti->height;
+ art_affine_point (&c1, &i1, i2c);
+ art_affine_point (&c2, &i2, i2c);
+ item->x1 = c1.x;
+ item->y1 = c1.y;
+ item->x2 = c2.x;
+ item->y2 = c2.y;
+
+ printf ("BBOX: %g %g %g %g\n", item->x1, item->y1, item->x2, item->y2);
+
gnome_canvas_group_child_bounds (GNOME_CANVAS_GROUP (item->parent), item);
}
@@ -239,6 +252,23 @@ eti_table_model_changed (ETableModel *table_model, ETableItem *eti)
eti_update (GNOME_CANVAS_ITEM (eti), NULL, NULL, 0);
}
+static void
+eti_item_region_redraw (ETableItem *eti, int x0, int y0, int x1, int y1)
+{
+ GnomeCanvasItem *item = GNOME_CANVAS_ITEM (eti);
+ ArtDRect rect;
+ double i2c [6];
+
+ rect.x0 = x0;
+ rect.y0 = y0;
+ rect.x1 = x1;
+ rect.y1 = y1;
+
+ gnome_canvas_item_i2c_affine (item, i2c);
+ art_drect_affine_transform (&rect, &rect, i2c);
+
+ gnome_canvas_request_redraw (item->canvas, rect.x0, rect.y0, rect.x1, rect.y1);
+}
/*
* eti_request_redraw:
@@ -248,11 +278,7 @@ eti_table_model_changed (ETableModel *table_model, ETableItem *eti)
static void
eti_request_redraw (ETableItem *eti)
{
- GnomeCanvas *canvas = GNOME_CANVAS_ITEM (eti)->canvas;
-
- gnome_canvas_request_redraw (canvas, eti->x1, eti->y1,
- eti->x1 + eti->width + 1,
- eti->y1 + eti->height + 1);
+ eti_item_region_redraw (eti, eti->x1, eti->y1, eti->x1 + eti->width + 1, eti->y1 + eti->height + 1);
}
/*
@@ -286,7 +312,6 @@ eti_request_region_redraw (ETableItem *eti,
int start_col, int start_row,
int end_col, int end_row, int border)
{
- GnomeCanvas *canvas = GNOME_CANVAS_ITEM (eti)->canvas;
int x1, y1, width, height;
x1 = e_table_header_col_diff (eti->header, 0, start_col);
@@ -294,8 +319,7 @@ eti_request_region_redraw (ETableItem *eti,
width = e_table_header_col_diff (eti->header, start_col, end_col + 1);
height = eti_row_diff (eti, start_row, end_row + 1);
- gnome_canvas_request_redraw (canvas,
- eti->x1 + x1 - border,
+ eti_item_region_redraw (eti, eti->x1 + x1 - border,
eti->y1 + y1 - border,
eti->x1 + x1 + width + 1 + border,
eti->y1 + y1 + height + 1 + border);
@@ -561,8 +585,9 @@ eti_draw (GnomeCanvasItem *item, GdkDrawable *drawable, int x, int y, int width,
int x1, x2;
int f_x1, f_x2, f_y1, f_y2;
gboolean f_found;
-
-/* printf ("Rect: %d %d %d %d\n", x, y, width, height); */
+ double i2c [6];
+ ArtPoint eti_base, eti_base_item;
+
/*
* Clear the background
*/
@@ -571,13 +596,21 @@ eti_draw (GnomeCanvasItem *item, GdkDrawable *drawable, int x, int y, int width,
drawable, eti->fill_gc, TRUE,
eti->x1 - x, eti->y1 - y, eti->width, eti->height);
#endif
-
+
+ /*
+ * Find out our real position after grouping
+ */
+ gnome_canvas_item_i2c_affine (item, i2c);
+ eti_base_item.x = eti->x1;
+ eti_base_item.y = eti->y1;
+ art_affine_point (&eti_base, &eti_base_item, i2c);
+
/*
* First column to draw, last column to draw
*/
first_col = -1;
last_col = x_offset = 0;
- x1 = x2 = eti->x1;
+ x1 = x2 = floor (eti_base.x);
for (col = 0; col < cols; col++, x1 = x2){
ETableCol *ecol = e_table_header_get_column (eti->header, col);
@@ -605,7 +638,7 @@ eti_draw (GnomeCanvasItem *item, GdkDrawable *drawable, int x, int y, int width,
*/
first_row = -1;
y_offset = 0;
- y1 = y2 = eti->y1 + 1;
+ y1 = y2 = floor (eti_base.y) + 1;
for (row = 0; row < rows; row++, y1 = y2){
y2 += eti_row_height (eti, row) + 1;
@@ -636,7 +669,7 @@ eti_draw (GnomeCanvasItem *item, GdkDrawable *drawable, int x, int y, int width,
if (eti->draw_grid && first_row == 0){
gdk_draw_line (
drawable, eti->grid_gc,
- eti->x1 - x, yd, eti->x1 + eti->width - x, yd);
+ eti_base.x - x, yd, eti_base.x + eti->width - x, yd);
}
yd++;
@@ -673,7 +706,7 @@ eti_draw (GnomeCanvasItem *item, GdkDrawable *drawable, int x, int y, int width,
if (eti->draw_grid)
gdk_draw_line (
drawable, eti->grid_gc,
- eti->x1 - x, yd, eti->x1 + eti->width - x, yd);
+ eti_base.x - x, yd, eti_base.x + eti->width - x, yd);
yd++;
}
@@ -717,7 +750,7 @@ eti_point (GnomeCanvasItem *item, double x, double y, int cx, int cy,
}
static gboolean
-find_cell (ETableItem *eti, double x, double y, int *col_res, int *row_res, gdouble *x1_res, gdouble *y1_res)
+find_cell (ETableItem *eti, double x, double y, int *col_res, int *row_res, double *x1_res, double *y1_res)
{
const int cols = eti->cols;
const int rows = eti->rows;
@@ -777,9 +810,11 @@ eti_event (GnomeCanvasItem *item, GdkEvent *e)
case GDK_BUTTON_PRESS:
case GDK_BUTTON_RELEASE:
case GDK_2BUTTON_PRESS: {
+ double x1, y1;
int col, row;
- gdouble x1, y1;
-
+
+ gnome_canvas_item_w2i (item, &e->button.x, &e->button.y);
+
if (!find_cell (eti, e->button.x, e->button.y, &col, &row, &x1, &y1))
return TRUE;
@@ -810,6 +845,8 @@ eti_event (GnomeCanvasItem *item, GdkEvent *e)
int col, row;
double x1, y1;
+ gnome_canvas_item_w2i (item, &e->button.x, &e->button.y);
+
if (!find_cell (eti, e->button.x, e->button.y, &col, &row, &x1, &y1))
return TRUE;
diff --git a/widgets/table/e-table.c b/widgets/table/e-table.c
index f9a41a38fc..a37012d4cc 100644
--- a/widgets/table/e-table.c
+++ b/widgets/table/e-table.c
@@ -35,6 +35,7 @@ typedef struct {
} Leaf;
typedef struct {
+
} Node;
@@ -132,7 +133,7 @@ e_table_create_leaf (ETable *e_table, int x_off, int y_off, ETableModel *etm)
NULL);
height = E_TABLE_ITEM (leaf->table_item)->height;
-
+
leaf->rect = gnome_canvas_item_new (
gnome_canvas_root (e_table->table_canvas),
gnome_canvas_rect_get_type (),
diff --git a/widgets/table/test-table.c b/widgets/table/test-table.c
index 83a130d72a..8bf22f980d 100644
--- a/widgets/table/test-table.c
+++ b/widgets/table/test-table.c
@@ -186,6 +186,7 @@ table_browser_test (void)
ETableModel *e_table_model;
ETableHeader *e_table_header;
ECell *cell_left_just;
+ GnomeCanvasItem *group;
int i;
load_data ();
@@ -231,13 +232,20 @@ table_browser_test (void)
"y", 0,
NULL);
- gnome_canvas_item_new (
+ group = gnome_canvas_item_new (
gnome_canvas_root (GNOME_CANVAS (canvas)),
+ gnome_canvas_group_get_type (),
+ "x", 30.0,
+ "y", 30.0,
+ NULL);
+
+ gnome_canvas_item_new (
+ GNOME_CANVAS_GROUP (group),
e_table_item_get_type (),
"ETableHeader", e_table_header,
"ETableModel", e_table_model,
- "x", 10,
- "y", 30,
+ "x", 0,
+ "y", 0,
"drawgrid", TRUE,
"drawfocus", TRUE,
"spreadsheet", TRUE,