aboutsummaryrefslogtreecommitdiffstats
path: root/widgets
diff options
context:
space:
mode:
authorArturo Espinosa <unammx@src.gnome.org>1999-12-13 15:57:31 +0800
committerArturo Espinosa <unammx@src.gnome.org>1999-12-13 15:57:31 +0800
commit9bd34cd86289069720397e884d7664772458c33a (patch)
tree24dd21d9e00a13bf8544f590d5fc1575eb308fce /widgets
parentdf80388fd94f635a0fecb08314eafd5e25131800 (diff)
downloadgsoc2013-evolution-9bd34cd86289069720397e884d7664772458c33a.tar.gz
gsoc2013-evolution-9bd34cd86289069720397e884d7664772458c33a.tar.zst
gsoc2013-evolution-9bd34cd86289069720397e884d7664772458c33a.zip
Fix before trip
svn path=/trunk/; revision=1485
Diffstat (limited to 'widgets')
-rw-r--r--widgets/ChangeLog11
-rw-r--r--widgets/Makefile.am2
-rw-r--r--widgets/e-table-group.c163
-rw-r--r--widgets/e-table-group.h36
-rw-r--r--widgets/e-table-header.c3
-rw-r--r--widgets/e-table-item.c8
-rw-r--r--widgets/e-table.c104
-rw-r--r--widgets/e-table/ChangeLog11
-rw-r--r--widgets/e-table/Makefile.am2
-rw-r--r--widgets/e-table/e-table-group.c163
-rw-r--r--widgets/e-table/e-table-group.h36
-rw-r--r--widgets/e-table/e-table-header.c3
-rw-r--r--widgets/e-table/e-table-item.c8
-rw-r--r--widgets/e-table/e-table.c104
-rw-r--r--widgets/e-table/table-test.c2
-rw-r--r--widgets/e-table/test-check.c4
-rw-r--r--widgets/e-table/test-cols.c8
-rw-r--r--widgets/e-table/test-table.c4
-rw-r--r--widgets/table-test.c2
-rw-r--r--widgets/table/e-table-group.c163
-rw-r--r--widgets/table/e-table-group.h36
-rw-r--r--widgets/table/e-table-header.c3
-rw-r--r--widgets/table/e-table-item.c8
-rw-r--r--widgets/table/e-table.c104
-rw-r--r--widgets/table/table-test.c2
-rw-r--r--widgets/table/test-check.c4
-rw-r--r--widgets/table/test-cols.c8
-rw-r--r--widgets/table/test-table.c4
-rw-r--r--widgets/test-check.c4
-rw-r--r--widgets/test-cols.c8
-rw-r--r--widgets/test-table.c4
31 files changed, 620 insertions, 402 deletions
diff --git a/widgets/ChangeLog b/widgets/ChangeLog
index 9f0f836b68..305d0e9d48 100644
--- a/widgets/ChangeLog
+++ b/widgets/ChangeLog
@@ -1,5 +1,16 @@
1999-12-12 Miguel de Icaza <miguel@helixcode.com>
+ * e-table-item.c (eti_class_init): X and Y arguments are now
+ doubles (to make it consistent with the rest of the canvas x, y
+ arguments).
+
+ * e-table.c (e_table_create_leaf): Use new argument values here
+
+ * test-*.c: Update to new argument types for x and y
+
+ * e-table-group.c: New implementation as a canvas item used to
+ group childs.
+
* e-table-item.c (eti_update): Make this play nicely with groups.
(eti_draw): ditto.
(eti_request_region_redraw): ditto.
diff --git a/widgets/Makefile.am b/widgets/Makefile.am
index a82935a262..e59c03a18d 100644
--- a/widgets/Makefile.am
+++ b/widgets/Makefile.am
@@ -21,6 +21,8 @@ libevolutionwidgets_a_SOURCES = \
e-table.h \
e-table-col.c \
e-table-col.h \
+ e-table-group.c \
+ e-table-group.h \
e-table-header.c \
e-table-header.h \
e-table-header-item.c \
diff --git a/widgets/e-table-group.c b/widgets/e-table-group.c
index b1e681d255..76c317369e 100644
--- a/widgets/e-table-group.c
+++ b/widgets/e-table-group.c
@@ -8,93 +8,132 @@
*/
#include <config.h>
+#include <gtk/gtksignal.h>
#include "e-table-group.h"
+#include <libgnomeui/gnome-canvas-rect-ellipse.h>
+#include "e-util.h"
-void
-e_table_group_destroy (ETableGroup *etg)
-{
- g_return_if_fail (etg != NULL);
+#define TITLE_HEIGHT 16
+#define GROUP_INDENT 10
- g_free (etg->title);
+#define PARENT_TYPE gnome_canvas_group_get_type ()
- if (etg->is_leaf == 0){
- GSList *l;
+static GnomeCanvasGroupClass *etg_parent_class;
- for (l = etg->u.children; l; l = l->next){
- ETableGroup *child = l->data;
-
- e_table_group_destroy (child);
- }
- g_slist_free (etg->u.children);
- etg->u.children = NULL;
- }
- g_free (etg);
+static void
+etg_destroy (GtkObject *object)
+{
+ ETableGroup *etg = E_TABLE_GROUP (object);
+
+ gtk_object_unref (GTK_OBJECT (etg->ecol));
+
+ GTK_OBJECT_CLASS (etg_parent_class)->destroy (object);
}
-ETableGroup *
-e_table_group_new_leaf (const char *title, ETableModel *table)
+static int
+etg_width (ETableGroup *etg)
{
- ETableGroup *etg;
+ return e_table_header_total_width (etg->header) + GROUP_INDENT;
+}
- g_return_val_if_fail (title != NULL, NULL);
- g_return_val_if_fail (table != NULL, NULL);
+static int
+etg_height (ETableGroup *etg)
+{
+ GnomeCanvasItem *child = etg->child;
- etg = g_new (ETableGroup, 1);
+ return TITLE_HEIGHT + (child->y2 - child->y1);
+}
+
+static void
+etg_header_changed (ETableHeader *header, ETableGroup *etg)
+{
+ gnome_canvas_item_set (
+ etg->rect,
+ "x2", (double) etg_width (etg),
+ NULL);
+}
- etg->expanded = 0;
- etg->is_leaf = 1;
- etg->u.table = table;
- etg->title = g_strdup (title);
+void
+e_table_group_construct (GnomeCanvasGroup *parent, ETableGroup *etg,
+ ETableHeader *header, int col,
+ GnomeCanvasItem *child, int open)
+{
+ gnome_canvas_item_constructv (GNOME_CANVAS_ITEM (etg), parent, 0, NULL);
+
+ gtk_object_ref (GTK_OBJECT (header));
+
+ etg->header = header;
+ etg->col = col;
+ etg->ecol = e_table_header_get_column (header, col);
+ etg->open = open;
+
+ gtk_signal_connect (
+ GTK_OBJECT (header), "dimension_change",
+ GTK_SIGNAL_FUNC (etg_header_changed), etg);
+
+ etg->child = child;
+
+ etg->rect = gnome_canvas_item_new (
+ GNOME_CANVAS_GROUP (etg),
+ gnome_canvas_rect_get_type (),
+ "fill_color", "gray",
+ "outline_color", "gray20",
+ "x1", 0.0,
+ "y1", 0.0,
+ "x2", (double) etg_width (etg),
+ "y2", (double) etg_height (etg),
+ NULL);
- return etg;
+
+ /*
+ * Reparent the child into our space.
+ */
+ gnome_canvas_item_reparent (child, GNOME_CANVAS_GROUP (etg));
+
+ gnome_canvas_item_set (
+ child,
+ "x", (double) GROUP_INDENT,
+ "y", (double) TITLE_HEIGHT,
+ NULL);
}
-ETableGroup *
-e_table_group_new (const char *title)
+GnomeCanvasItem *
+e_table_group_new (GnomeCanvasGroup *parent, ETableHeader *header, int col, GnomeCanvasItem *child, int open)
{
ETableGroup *etg;
- g_return_val_if_fail (title != NULL, NULL);
+ g_return_val_if_fail (parent != NULL, NULL);
+ g_return_val_if_fail (header != NULL, NULL);
+ g_return_val_if_fail (child != NULL, NULL);
- etg = g_new (ETableGroup, 1);
+ etg = gtk_type_new (e_table_group_get_type ());
- etg->expanded = 0;
- etg->is_leaf = 0;
- etg->u.children = NULL;
- etg->title = g_strdup (title);
+ e_table_group_construct (parent, etg, header, col, child, open);
- return etg;
+ return GNOME_CANVAS_ITEM (etg);
}
-void
-e_table_group_append_child (ETableGroup *etg, ETableGroup *child)
+static void
+etg_realize (GnomeCanvasItem *item)
{
- g_return_if_fail (etg != NULL);
- g_return_if_fail (child != NULL);
- g_return_if_fail (etg->is_leaf != 0);
-
- etg->u.children = g_slist_append (etg->u.children, child);
+ ETableGroup *etg = E_TABLE_GROUP (item);
+
+ GNOME_CANVAS_ITEM_CLASS (etg_parent_class)->realize (item);
}
-#if 0
-int
-e_table_group_size (ETableGroup *etg)
+static void
+etg_class_init (GtkObjectClass *object_class)
{
- g_return_val_if_fail (etg != NULL, 0);
-
- if (etg->is_leaf)
- return e_table_model_height (etg->u.table);
- else {
- GSList *l;
- int size = 0;
-
- for (l = etg->u.children; l; l = l->next){
- ETableGroup *child = l->data;
-
- size += e_table_group_size (child);
- }
- return size;
- }
+ GnomeCanvasItemClass *item_class = (GnomeCanvasItemClass *) object_class;
+
+ object_class->destroy = etg_destroy;
+
+ item_class->realize = etg_realize;
+
+ etg_parent_class = gtk_type_class (PARENT_TYPE);
}
-#endif
+E_MAKE_TYPE (e_table_group, "ETableGroup", ETableGroup, etg_class_init, NULL, PARENT_TYPE);
+
+
+
diff --git a/widgets/e-table-group.h b/widgets/e-table-group.h
index 62bc11093f..18f4b710b1 100644
--- a/widgets/e-table-group.h
+++ b/widgets/e-table-group.h
@@ -1,25 +1,35 @@
#ifndef _E_TABLE_TREE_H_
#define _E_TABLE_TREE_H_
+#include <libgnomeui/gnome-canvas.h>
#include "e-table-model.h"
+#include "e-table-header.h"
-typedef struct {
- char *title;
+#define E_TABLE_GROUP_TYPE (e_table_group_get_type ())
+#define E_TABLE_GROUP(o) (GTK_CHECK_CAST ((o), E_TABLE_GROUP_TYPE, ETableGroup))
+#define E_TABLE_GROUP_CLASS(k) (GTK_CHECK_CLASS_CAST((k), E_TABLE_GROUP_TYPE, ETableGroupClass))
+#define E_IS_TABLE_GROUP(o) (GTK_CHECK_TYPE ((o), E_TABLE_GROUP_TYPE))
+#define E_IS_TABLE_GROUP_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), E_TABLE_GROUP_TYPE))
- union {
- ETableModel *table;
- GSList *children;
- } u;
+typedef struct {
+ GnomeCanvasGroup group;
- guint expanded :1;
- guint is_leaf :1;
+ ETableHeader *header;
+ ETableCol *ecol;
+ int col;
+ int open;
+ GnomeCanvasItem *rect, *child;
} ETableGroup;
-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);
+typedef struct {
+ GnomeCanvasGroupClass parent_class;
+} ETableGroupClass;
-int e_table_group_size (ETableGroup *egroup);
-void e_table_group_append_child (ETableGroup *etg, ETableGroup *child);
+GnomeCanvasItem *e_table_group_new (GnomeCanvasGroup *parent, ETableHeader *header,
+ int col, GnomeCanvasItem *child, int open);
+void e_table_group_construct (GnomeCanvasGroup *parent, ETableGroup *etg,
+ ETableHeader *header, int col,
+ GnomeCanvasItem *child, int open);
+GtkType e_table_group_get_type (void);
#endif /* _E_TABLE_TREE_H_ */
diff --git a/widgets/e-table-header.c b/widgets/e-table-header.c
index 32078d9a78..7c54bd936e 100644
--- a/widgets/e-table-header.c
+++ b/widgets/e-table-header.c
@@ -143,6 +143,7 @@ e_table_header_add_column (ETableHeader *eth, ETableCol *tc, int pos)
eth_update_offsets (eth);
gtk_signal_emit (GTK_OBJECT (eth), eth_signals [STRUCTURE_CHANGE]);
+ gtk_signal_emit (GTK_OBJECT (eth), eth_signals [DIMENSION_CHANGE]);
}
ETableCol *
@@ -283,6 +284,7 @@ e_table_header_move (ETableHeader *eth, int source_index, int target_index)
eth_update_offsets (eth);
gtk_signal_emit (GTK_OBJECT (eth), eth_signals [STRUCTURE_CHANGE]);
+ gtk_signal_emit (GTK_OBJECT (eth), eth_signals [DIMENSION_CHANGE]);
}
void
@@ -295,6 +297,7 @@ e_table_header_remove (ETableHeader *eth, int idx)
eth_do_remove (eth, idx, TRUE);
gtk_signal_emit (GTK_OBJECT (eth), eth_signals [STRUCTURE_CHANGE]);
+ gtk_signal_emit (GTK_OBJECT (eth), eth_signals [DIMENSION_CHANGE]);
}
void
diff --git a/widgets/e-table-item.c b/widgets/e-table-item.c
index 26e21bfd98..23b72d5557 100644
--- a/widgets/e-table-item.c
+++ b/widgets/e-table-item.c
@@ -461,11 +461,11 @@ eti_set_arg (GtkObject *o, GtkArg *arg, guint arg_id)
break;
case ARG_TABLE_X:
- eti->x1 = GTK_VALUE_INT (*arg);
+ eti->x1 = GTK_VALUE_DOUBLE (*arg);
break;
case ARG_TABLE_Y:
- eti->y1 = GTK_VALUE_INT (*arg);
+ eti->y1 = GTK_VALUE_DOUBLE (*arg);
break;
case ARG_LENGHT_THRESHOLD:
@@ -974,9 +974,9 @@ 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_INT,
+ 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_INT,
+ 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);
diff --git a/widgets/e-table.c b/widgets/e-table.c
index a37012d4cc..b5f77f622b 100644
--- a/widgets/e-table.c
+++ b/widgets/e-table.c
@@ -19,6 +19,7 @@
#include "e-table-header-item.h"
#include "e-table-subset.h"
#include "e-table-item.h"
+#include "e-table-group.h"
#define COLUMN_HEADER_HEIGHT 16
#define TITLE_HEIGHT 16
@@ -28,10 +29,10 @@
static GtkObjectClass *e_table_parent_class;
-typedef struct {
+typedef struct {
ETableModel *table;
GnomeCanvasItem *table_item;
- GnomeCanvasItem *rect;
+ GnomeCanvasItem *lead;
} Leaf;
typedef struct {
@@ -87,6 +88,14 @@ e_table_make_header (ETable *e_table, ETableHeader *full_header, const char *col
}
static void
+header_canvas_size_alocate (GtkWidget *widget, GtkAllocation *alloc, ETable *e_table)
+{
+ gnome_canvas_set_scroll_region (
+ GNOME_CANVAS (e_table->header_canvas),
+ 0, 0, alloc->width, COLUMN_HEADER_HEIGHT);
+}
+
+static void
e_table_setup_header (ETable *e_table)
{
e_table->header_canvas = GNOME_CANVAS (gnome_canvas_new ());
@@ -101,9 +110,11 @@ e_table_setup_header (ETable *e_table)
"y", 0,
NULL);
+ gtk_signal_connect (
+ GTK_OBJECT (e_table->header_canvas), "size_allocate",
+ GTK_SIGNAL_FUNC (header_canvas_size_alocate), e_table);
+
gtk_widget_set_usize (GTK_WIDGET (e_table->header_canvas), -1, COLUMN_HEADER_HEIGHT);
- g_warning ("Aqui");
- e_table->header_canvas = 0;
gtk_table_attach (
GTK_TABLE (e_table), GTK_WIDGET (e_table->header_canvas),
@@ -112,10 +123,9 @@ e_table_setup_header (ETable *e_table)
}
static Leaf *
-e_table_create_leaf (ETable *e_table, int x_off, int y_off, ETableModel *etm)
+e_table_create_leaf (ETable *e_table, ETableModel *etm, int col, int height)
{
Leaf *leaf;
- int height;
leaf = g_new (Leaf, 1);
leaf->table = etm;
@@ -125,26 +135,21 @@ e_table_create_leaf (ETable *e_table, int x_off, int y_off, ETableModel *etm)
e_table_item_get_type (),
"ETableHeader", e_table->header,
"ETableModel", etm,
- "x", x_off + GROUP_INDENT,
- "y", y_off + TITLE_HEIGHT,
+ "x", (double) 0,
+ "y", (double) 0,
"drawgrid", e_table->draw_grid,
"drawfocus", e_table->draw_focus,
"spreadsheet", e_table->spreadsheet,
NULL);
- height = E_TABLE_ITEM (leaf->table_item)->height;
-
- leaf->rect = gnome_canvas_item_new (
+ leaf->lead = e_table_group_new (
gnome_canvas_root (e_table->table_canvas),
- gnome_canvas_rect_get_type (),
- "x1", (double) x_off,
- "y1", (double) y_off,
- "x2", (double) x_off + e_table->gen_header_width + GROUP_INDENT,
- "y2", (double) y_off + TITLE_HEIGHT + height,
- "fill_color", "gray",
- "outline_color", "gray20",
+ e_table->header, col, leaf->table_item, TRUE);
+
+ gnome_canvas_item_set (
+ leaf->lead,
+ "y", (double) height,
NULL);
- gnome_canvas_item_lower (leaf->rect, 1);
return leaf;
}
@@ -242,40 +247,30 @@ e_table_make_subtables (ETableModel *model, GArray *groups)
static int
leaf_height (Leaf *leaf)
{
- return E_TABLE_ITEM (leaf->table_item)->height + TITLE_HEIGHT;
+ return leaf->lead->y2 - leaf->lead->y1;
}
-static int
+static Leaf *
e_table_create_nodes (ETable *e_table, ETableModel *model, ETableHeader *header,
- GnomeCanvasGroup *root, int x_off, int y_off,
- int *groups_list)
+ GnomeCanvasGroup *root, int height, int *groups_list)
{
GArray *groups;
ETableModel **tables;
- int key_col;
- int height, i;
+ int key_col, i;
GCompareFunc comp;
-
+ Leaf *leaf;
+ GnomeCanvasItem *group;
+
if (groups_list)
key_col = *groups_list;
else
key_col = -1;
if (key_col == -1){
- Leaf *leaf;
-
printf ("Leaf->with %d rows\n", e_table_model_row_count (model));
- leaf = e_table_create_leaf (e_table, x_off, y_off, model);
+ leaf = e_table_create_leaf (e_table, model, key_col, height);
- {
- static int warn_shown;
-
- if (!warn_shown){
- g_warning ("Leak");
- warn_shown = 1;
- }
- }
- return leaf_height (leaf);
+ return leaf;
}
/*
@@ -286,16 +281,31 @@ e_table_create_nodes (ETable *e_table, ETableModel *model, ETableHeader *header,
tables = e_table_make_subtables (e_table->model, groups);
e_table_destroy_groups (groups);
+ leaf = g_new0 (Leaf, 1);
+
+ leaf->table = NULL;
+ leaf->table_item = NULL;
+ group = gnome_canvas_item_new (
+ root,
+ gnome_canvas_group_get_type (),
+ NULL);
+
height = 0;
for (i = 0; tables [i] != NULL; i++){
printf ("Creating->%d with %d rows\n", i, e_table_model_row_count (tables [i]));
- height += e_table_create_nodes (
- e_table, tables [i], header, root,
- x_off + 20,
- y_off + height, &groups_list [1]);
+
+ leaf = e_table_create_nodes (
+ e_table, tables [i], header, GNOME_CANVAS_GROUP (group), height,
+ &groups_list [1]);
+
+ height += leaf_height (leaf);
}
+
+ leaf->lead = e_table_group_new (
+ root,
+ e_table->header, key_col, group, TRUE);
- return height;
+ return leaf;
}
static int *
@@ -362,8 +372,8 @@ e_table_canvas_realize (GtkWidget *widget)
{
ETableCanvas *e_table_canvas = (ETableCanvas *) widget;
ETable *e_table = e_table_canvas->e_table;
+ Leaf *leaf;
int *groups;
- int height;
GTK_WIDGET_CLASS (e_table_canvas_parent_class)->realize (widget);
@@ -378,9 +388,9 @@ e_table_canvas_realize (GtkWidget *widget)
e_table->gen_header_width = e_table_header_total_width (e_table->header);
- height = e_table_create_nodes (
+ leaf = e_table_create_nodes (
e_table, e_table->model,
- e_table->header, GNOME_CANVAS_GROUP (e_table->root), 0, 0, groups);
+ e_table->header, GNOME_CANVAS_GROUP (e_table->root), 0, groups);
{
static int warn_shown;
@@ -395,7 +405,7 @@ e_table_canvas_realize (GtkWidget *widget)
GNOME_CANVAS (e_table_canvas),
0, 0,
e_table_header_total_width (e_table->header) + 200,
- height);
+ leaf_height (leaf));
if (groups)
g_free (groups);
diff --git a/widgets/e-table/ChangeLog b/widgets/e-table/ChangeLog
index 9f0f836b68..305d0e9d48 100644
--- a/widgets/e-table/ChangeLog
+++ b/widgets/e-table/ChangeLog
@@ -1,5 +1,16 @@
1999-12-12 Miguel de Icaza <miguel@helixcode.com>
+ * e-table-item.c (eti_class_init): X and Y arguments are now
+ doubles (to make it consistent with the rest of the canvas x, y
+ arguments).
+
+ * e-table.c (e_table_create_leaf): Use new argument values here
+
+ * test-*.c: Update to new argument types for x and y
+
+ * e-table-group.c: New implementation as a canvas item used to
+ group childs.
+
* e-table-item.c (eti_update): Make this play nicely with groups.
(eti_draw): ditto.
(eti_request_region_redraw): ditto.
diff --git a/widgets/e-table/Makefile.am b/widgets/e-table/Makefile.am
index a82935a262..e59c03a18d 100644
--- a/widgets/e-table/Makefile.am
+++ b/widgets/e-table/Makefile.am
@@ -21,6 +21,8 @@ libevolutionwidgets_a_SOURCES = \
e-table.h \
e-table-col.c \
e-table-col.h \
+ e-table-group.c \
+ e-table-group.h \
e-table-header.c \
e-table-header.h \
e-table-header-item.c \
diff --git a/widgets/e-table/e-table-group.c b/widgets/e-table/e-table-group.c
index b1e681d255..76c317369e 100644
--- a/widgets/e-table/e-table-group.c
+++ b/widgets/e-table/e-table-group.c
@@ -8,93 +8,132 @@
*/
#include <config.h>
+#include <gtk/gtksignal.h>
#include "e-table-group.h"
+#include <libgnomeui/gnome-canvas-rect-ellipse.h>
+#include "e-util.h"
-void
-e_table_group_destroy (ETableGroup *etg)
-{
- g_return_if_fail (etg != NULL);
+#define TITLE_HEIGHT 16
+#define GROUP_INDENT 10
- g_free (etg->title);
+#define PARENT_TYPE gnome_canvas_group_get_type ()
- if (etg->is_leaf == 0){
- GSList *l;
+static GnomeCanvasGroupClass *etg_parent_class;
- for (l = etg->u.children; l; l = l->next){
- ETableGroup *child = l->data;
-
- e_table_group_destroy (child);
- }
- g_slist_free (etg->u.children);
- etg->u.children = NULL;
- }
- g_free (etg);
+static void
+etg_destroy (GtkObject *object)
+{
+ ETableGroup *etg = E_TABLE_GROUP (object);
+
+ gtk_object_unref (GTK_OBJECT (etg->ecol));
+
+ GTK_OBJECT_CLASS (etg_parent_class)->destroy (object);
}
-ETableGroup *
-e_table_group_new_leaf (const char *title, ETableModel *table)
+static int
+etg_width (ETableGroup *etg)
{
- ETableGroup *etg;
+ return e_table_header_total_width (etg->header) + GROUP_INDENT;
+}
- g_return_val_if_fail (title != NULL, NULL);
- g_return_val_if_fail (table != NULL, NULL);
+static int
+etg_height (ETableGroup *etg)
+{
+ GnomeCanvasItem *child = etg->child;
- etg = g_new (ETableGroup, 1);
+ return TITLE_HEIGHT + (child->y2 - child->y1);
+}
+
+static void
+etg_header_changed (ETableHeader *header, ETableGroup *etg)
+{
+ gnome_canvas_item_set (
+ etg->rect,
+ "x2", (double) etg_width (etg),
+ NULL);
+}
- etg->expanded = 0;
- etg->is_leaf = 1;
- etg->u.table = table;
- etg->title = g_strdup (title);
+void
+e_table_group_construct (GnomeCanvasGroup *parent, ETableGroup *etg,
+ ETableHeader *header, int col,
+ GnomeCanvasItem *child, int open)
+{
+ gnome_canvas_item_constructv (GNOME_CANVAS_ITEM (etg), parent, 0, NULL);
+
+ gtk_object_ref (GTK_OBJECT (header));
+
+ etg->header = header;
+ etg->col = col;
+ etg->ecol = e_table_header_get_column (header, col);
+ etg->open = open;
+
+ gtk_signal_connect (
+ GTK_OBJECT (header), "dimension_change",
+ GTK_SIGNAL_FUNC (etg_header_changed), etg);
+
+ etg->child = child;
+
+ etg->rect = gnome_canvas_item_new (
+ GNOME_CANVAS_GROUP (etg),
+ gnome_canvas_rect_get_type (),
+ "fill_color", "gray",
+ "outline_color", "gray20",
+ "x1", 0.0,
+ "y1", 0.0,
+ "x2", (double) etg_width (etg),
+ "y2", (double) etg_height (etg),
+ NULL);
- return etg;
+
+ /*
+ * Reparent the child into our space.
+ */
+ gnome_canvas_item_reparent (child, GNOME_CANVAS_GROUP (etg));
+
+ gnome_canvas_item_set (
+ child,
+ "x", (double) GROUP_INDENT,
+ "y", (double) TITLE_HEIGHT,
+ NULL);
}
-ETableGroup *
-e_table_group_new (const char *title)
+GnomeCanvasItem *
+e_table_group_new (GnomeCanvasGroup *parent, ETableHeader *header, int col, GnomeCanvasItem *child, int open)
{
ETableGroup *etg;
- g_return_val_if_fail (title != NULL, NULL);
+ g_return_val_if_fail (parent != NULL, NULL);
+ g_return_val_if_fail (header != NULL, NULL);
+ g_return_val_if_fail (child != NULL, NULL);
- etg = g_new (ETableGroup, 1);
+ etg = gtk_type_new (e_table_group_get_type ());
- etg->expanded = 0;
- etg->is_leaf = 0;
- etg->u.children = NULL;
- etg->title = g_strdup (title);
+ e_table_group_construct (parent, etg, header, col, child, open);
- return etg;
+ return GNOME_CANVAS_ITEM (etg);
}
-void
-e_table_group_append_child (ETableGroup *etg, ETableGroup *child)
+static void
+etg_realize (GnomeCanvasItem *item)
{
- g_return_if_fail (etg != NULL);
- g_return_if_fail (child != NULL);
- g_return_if_fail (etg->is_leaf != 0);
-
- etg->u.children = g_slist_append (etg->u.children, child);
+ ETableGroup *etg = E_TABLE_GROUP (item);
+
+ GNOME_CANVAS_ITEM_CLASS (etg_parent_class)->realize (item);
}
-#if 0
-int
-e_table_group_size (ETableGroup *etg)
+static void
+etg_class_init (GtkObjectClass *object_class)
{
- g_return_val_if_fail (etg != NULL, 0);
-
- if (etg->is_leaf)
- return e_table_model_height (etg->u.table);
- else {
- GSList *l;
- int size = 0;
-
- for (l = etg->u.children; l; l = l->next){
- ETableGroup *child = l->data;
-
- size += e_table_group_size (child);
- }
- return size;
- }
+ GnomeCanvasItemClass *item_class = (GnomeCanvasItemClass *) object_class;
+
+ object_class->destroy = etg_destroy;
+
+ item_class->realize = etg_realize;
+
+ etg_parent_class = gtk_type_class (PARENT_TYPE);
}
-#endif
+E_MAKE_TYPE (e_table_group, "ETableGroup", ETableGroup, etg_class_init, NULL, PARENT_TYPE);
+
+
+
diff --git a/widgets/e-table/e-table-group.h b/widgets/e-table/e-table-group.h
index 62bc11093f..18f4b710b1 100644
--- a/widgets/e-table/e-table-group.h
+++ b/widgets/e-table/e-table-group.h
@@ -1,25 +1,35 @@
#ifndef _E_TABLE_TREE_H_
#define _E_TABLE_TREE_H_
+#include <libgnomeui/gnome-canvas.h>
#include "e-table-model.h"
+#include "e-table-header.h"
-typedef struct {
- char *title;
+#define E_TABLE_GROUP_TYPE (e_table_group_get_type ())
+#define E_TABLE_GROUP(o) (GTK_CHECK_CAST ((o), E_TABLE_GROUP_TYPE, ETableGroup))
+#define E_TABLE_GROUP_CLASS(k) (GTK_CHECK_CLASS_CAST((k), E_TABLE_GROUP_TYPE, ETableGroupClass))
+#define E_IS_TABLE_GROUP(o) (GTK_CHECK_TYPE ((o), E_TABLE_GROUP_TYPE))
+#define E_IS_TABLE_GROUP_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), E_TABLE_GROUP_TYPE))
- union {
- ETableModel *table;
- GSList *children;
- } u;
+typedef struct {
+ GnomeCanvasGroup group;
- guint expanded :1;
- guint is_leaf :1;
+ ETableHeader *header;
+ ETableCol *ecol;
+ int col;
+ int open;
+ GnomeCanvasItem *rect, *child;
} ETableGroup;
-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);
+typedef struct {
+ GnomeCanvasGroupClass parent_class;
+} ETableGroupClass;
-int e_table_group_size (ETableGroup *egroup);
-void e_table_group_append_child (ETableGroup *etg, ETableGroup *child);
+GnomeCanvasItem *e_table_group_new (GnomeCanvasGroup *parent, ETableHeader *header,
+ int col, GnomeCanvasItem *child, int open);
+void e_table_group_construct (GnomeCanvasGroup *parent, ETableGroup *etg,
+ ETableHeader *header, int col,
+ GnomeCanvasItem *child, int open);
+GtkType e_table_group_get_type (void);
#endif /* _E_TABLE_TREE_H_ */
diff --git a/widgets/e-table/e-table-header.c b/widgets/e-table/e-table-header.c
index 32078d9a78..7c54bd936e 100644
--- a/widgets/e-table/e-table-header.c
+++ b/widgets/e-table/e-table-header.c
@@ -143,6 +143,7 @@ e_table_header_add_column (ETableHeader *eth, ETableCol *tc, int pos)
eth_update_offsets (eth);
gtk_signal_emit (GTK_OBJECT (eth), eth_signals [STRUCTURE_CHANGE]);
+ gtk_signal_emit (GTK_OBJECT (eth), eth_signals [DIMENSION_CHANGE]);
}
ETableCol *
@@ -283,6 +284,7 @@ e_table_header_move (ETableHeader *eth, int source_index, int target_index)
eth_update_offsets (eth);
gtk_signal_emit (GTK_OBJECT (eth), eth_signals [STRUCTURE_CHANGE]);
+ gtk_signal_emit (GTK_OBJECT (eth), eth_signals [DIMENSION_CHANGE]);
}
void
@@ -295,6 +297,7 @@ e_table_header_remove (ETableHeader *eth, int idx)
eth_do_remove (eth, idx, TRUE);
gtk_signal_emit (GTK_OBJECT (eth), eth_signals [STRUCTURE_CHANGE]);
+ gtk_signal_emit (GTK_OBJECT (eth), eth_signals [DIMENSION_CHANGE]);
}
void
diff --git a/widgets/e-table/e-table-item.c b/widgets/e-table/e-table-item.c
index 26e21bfd98..23b72d5557 100644
--- a/widgets/e-table/e-table-item.c
+++ b/widgets/e-table/e-table-item.c
@@ -461,11 +461,11 @@ eti_set_arg (GtkObject *o, GtkArg *arg, guint arg_id)
break;
case ARG_TABLE_X:
- eti->x1 = GTK_VALUE_INT (*arg);
+ eti->x1 = GTK_VALUE_DOUBLE (*arg);
break;
case ARG_TABLE_Y:
- eti->y1 = GTK_VALUE_INT (*arg);
+ eti->y1 = GTK_VALUE_DOUBLE (*arg);
break;
case ARG_LENGHT_THRESHOLD:
@@ -974,9 +974,9 @@ 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_INT,
+ 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_INT,
+ 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);
diff --git a/widgets/e-table/e-table.c b/widgets/e-table/e-table.c
index a37012d4cc..b5f77f622b 100644
--- a/widgets/e-table/e-table.c
+++ b/widgets/e-table/e-table.c
@@ -19,6 +19,7 @@
#include "e-table-header-item.h"
#include "e-table-subset.h"
#include "e-table-item.h"
+#include "e-table-group.h"
#define COLUMN_HEADER_HEIGHT 16
#define TITLE_HEIGHT 16
@@ -28,10 +29,10 @@
static GtkObjectClass *e_table_parent_class;
-typedef struct {
+typedef struct {
ETableModel *table;
GnomeCanvasItem *table_item;
- GnomeCanvasItem *rect;
+ GnomeCanvasItem *lead;
} Leaf;
typedef struct {
@@ -87,6 +88,14 @@ e_table_make_header (ETable *e_table, ETableHeader *full_header, const char *col
}
static void
+header_canvas_size_alocate (GtkWidget *widget, GtkAllocation *alloc, ETable *e_table)
+{
+ gnome_canvas_set_scroll_region (
+ GNOME_CANVAS (e_table->header_canvas),
+ 0, 0, alloc->width, COLUMN_HEADER_HEIGHT);
+}
+
+static void
e_table_setup_header (ETable *e_table)
{
e_table->header_canvas = GNOME_CANVAS (gnome_canvas_new ());
@@ -101,9 +110,11 @@ e_table_setup_header (ETable *e_table)
"y", 0,
NULL);
+ gtk_signal_connect (
+ GTK_OBJECT (e_table->header_canvas), "size_allocate",
+ GTK_SIGNAL_FUNC (header_canvas_size_alocate), e_table);
+
gtk_widget_set_usize (GTK_WIDGET (e_table->header_canvas), -1, COLUMN_HEADER_HEIGHT);
- g_warning ("Aqui");
- e_table->header_canvas = 0;
gtk_table_attach (
GTK_TABLE (e_table), GTK_WIDGET (e_table->header_canvas),
@@ -112,10 +123,9 @@ e_table_setup_header (ETable *e_table)
}
static Leaf *
-e_table_create_leaf (ETable *e_table, int x_off, int y_off, ETableModel *etm)
+e_table_create_leaf (ETable *e_table, ETableModel *etm, int col, int height)
{
Leaf *leaf;
- int height;
leaf = g_new (Leaf, 1);
leaf->table = etm;
@@ -125,26 +135,21 @@ e_table_create_leaf (ETable *e_table, int x_off, int y_off, ETableModel *etm)
e_table_item_get_type (),
"ETableHeader", e_table->header,
"ETableModel", etm,
- "x", x_off + GROUP_INDENT,
- "y", y_off + TITLE_HEIGHT,
+ "x", (double) 0,
+ "y", (double) 0,
"drawgrid", e_table->draw_grid,
"drawfocus", e_table->draw_focus,
"spreadsheet", e_table->spreadsheet,
NULL);
- height = E_TABLE_ITEM (leaf->table_item)->height;
-
- leaf->rect = gnome_canvas_item_new (
+ leaf->lead = e_table_group_new (
gnome_canvas_root (e_table->table_canvas),
- gnome_canvas_rect_get_type (),
- "x1", (double) x_off,
- "y1", (double) y_off,
- "x2", (double) x_off + e_table->gen_header_width + GROUP_INDENT,
- "y2", (double) y_off + TITLE_HEIGHT + height,
- "fill_color", "gray",
- "outline_color", "gray20",
+ e_table->header, col, leaf->table_item, TRUE);
+
+ gnome_canvas_item_set (
+ leaf->lead,
+ "y", (double) height,
NULL);
- gnome_canvas_item_lower (leaf->rect, 1);
return leaf;
}
@@ -242,40 +247,30 @@ e_table_make_subtables (ETableModel *model, GArray *groups)
static int
leaf_height (Leaf *leaf)
{
- return E_TABLE_ITEM (leaf->table_item)->height + TITLE_HEIGHT;
+ return leaf->lead->y2 - leaf->lead->y1;
}
-static int
+static Leaf *
e_table_create_nodes (ETable *e_table, ETableModel *model, ETableHeader *header,
- GnomeCanvasGroup *root, int x_off, int y_off,
- int *groups_list)
+ GnomeCanvasGroup *root, int height, int *groups_list)
{
GArray *groups;
ETableModel **tables;
- int key_col;
- int height, i;
+ int key_col, i;
GCompareFunc comp;
-
+ Leaf *leaf;
+ GnomeCanvasItem *group;
+
if (groups_list)
key_col = *groups_list;
else
key_col = -1;
if (key_col == -1){
- Leaf *leaf;
-
printf ("Leaf->with %d rows\n", e_table_model_row_count (model));
- leaf = e_table_create_leaf (e_table, x_off, y_off, model);
+ leaf = e_table_create_leaf (e_table, model, key_col, height);
- {
- static int warn_shown;
-
- if (!warn_shown){
- g_warning ("Leak");
- warn_shown = 1;
- }
- }
- return leaf_height (leaf);
+ return leaf;
}
/*
@@ -286,16 +281,31 @@ e_table_create_nodes (ETable *e_table, ETableModel *model, ETableHeader *header,
tables = e_table_make_subtables (e_table->model, groups);
e_table_destroy_groups (groups);
+ leaf = g_new0 (Leaf, 1);
+
+ leaf->table = NULL;
+ leaf->table_item = NULL;
+ group = gnome_canvas_item_new (
+ root,
+ gnome_canvas_group_get_type (),
+ NULL);
+
height = 0;
for (i = 0; tables [i] != NULL; i++){
printf ("Creating->%d with %d rows\n", i, e_table_model_row_count (tables [i]));
- height += e_table_create_nodes (
- e_table, tables [i], header, root,
- x_off + 20,
- y_off + height, &groups_list [1]);
+
+ leaf = e_table_create_nodes (
+ e_table, tables [i], header, GNOME_CANVAS_GROUP (group), height,
+ &groups_list [1]);
+
+ height += leaf_height (leaf);
}
+
+ leaf->lead = e_table_group_new (
+ root,
+ e_table->header, key_col, group, TRUE);
- return height;
+ return leaf;
}
static int *
@@ -362,8 +372,8 @@ e_table_canvas_realize (GtkWidget *widget)
{
ETableCanvas *e_table_canvas = (ETableCanvas *) widget;
ETable *e_table = e_table_canvas->e_table;
+ Leaf *leaf;
int *groups;
- int height;
GTK_WIDGET_CLASS (e_table_canvas_parent_class)->realize (widget);
@@ -378,9 +388,9 @@ e_table_canvas_realize (GtkWidget *widget)
e_table->gen_header_width = e_table_header_total_width (e_table->header);
- height = e_table_create_nodes (
+ leaf = e_table_create_nodes (
e_table, e_table->model,
- e_table->header, GNOME_CANVAS_GROUP (e_table->root), 0, 0, groups);
+ e_table->header, GNOME_CANVAS_GROUP (e_table->root), 0, groups);
{
static int warn_shown;
@@ -395,7 +405,7 @@ e_table_canvas_realize (GtkWidget *widget)
GNOME_CANVAS (e_table_canvas),
0, 0,
e_table_header_total_width (e_table->header) + 200,
- height);
+ leaf_height (leaf));
if (groups)
g_free (groups);
diff --git a/widgets/e-table/table-test.c b/widgets/e-table/table-test.c
index 9de673ede4..73cb22f4b1 100644
--- a/widgets/e-table/table-test.c
+++ b/widgets/e-table/table-test.c
@@ -31,9 +31,11 @@ main (int argc, char *argv [])
gnome_init ("TableTest", "TableTest", argc, argv);
e_cursors_init ();
+#if 0
table_browser_test ();
multi_cols_test ();
check_test ();
+#endif
e_table_test ();
gtk_main ();
diff --git a/widgets/e-table/test-check.c b/widgets/e-table/test-check.c
index 9e003ce9a1..b24a7aff64 100644
--- a/widgets/e-table/test-check.c
+++ b/widgets/e-table/test-check.c
@@ -138,8 +138,8 @@ check_test (void)
e_table_item_get_type (),
"ETableHeader", e_table_header,
"ETableModel", e_table_model,
- "x", 0,
- "y", 30,
+ "x", (double) 0,
+ "y", (double) 30,
"drawgrid", TRUE,
"drawfocus", TRUE,
"spreadsheet", TRUE,
diff --git a/widgets/e-table/test-cols.c b/widgets/e-table/test-cols.c
index b7979c2f3d..6342a1739f 100644
--- a/widgets/e-table/test-cols.c
+++ b/widgets/e-table/test-cols.c
@@ -162,8 +162,8 @@ multi_cols_test (void)
e_table_item_get_type (),
"ETableHeader", e_table_header,
"ETableModel", e_table_model,
- "x", 0,
- "y", 30,
+ "x", (double) 0,
+ "y", (double) 30,
"drawgrid", TRUE,
"drawfocus", TRUE,
"spreadsheet", TRUE,
@@ -181,8 +181,8 @@ multi_cols_test (void)
e_table_item_get_type (),
"ETableHeader", e_table_header_multiple,
"ETableModel", e_table_model,
- "x", 300,
- "y", 30,
+ "x", (double) 300,
+ "y", (double) 30,
"drawgrid", TRUE,
"drawfocus", TRUE,
"spreadsheet", TRUE,
diff --git a/widgets/e-table/test-table.c b/widgets/e-table/test-table.c
index 8bf22f980d..63fd7ce271 100644
--- a/widgets/e-table/test-table.c
+++ b/widgets/e-table/test-table.c
@@ -244,8 +244,8 @@ table_browser_test (void)
e_table_item_get_type (),
"ETableHeader", e_table_header,
"ETableModel", e_table_model,
- "x", 0,
- "y", 0,
+ "x", (double) 0,
+ "y", (double) 0,
"drawgrid", TRUE,
"drawfocus", TRUE,
"spreadsheet", TRUE,
diff --git a/widgets/table-test.c b/widgets/table-test.c
index 9de673ede4..73cb22f4b1 100644
--- a/widgets/table-test.c
+++ b/widgets/table-test.c
@@ -31,9 +31,11 @@ main (int argc, char *argv [])
gnome_init ("TableTest", "TableTest", argc, argv);
e_cursors_init ();
+#if 0
table_browser_test ();
multi_cols_test ();
check_test ();
+#endif
e_table_test ();
gtk_main ();
diff --git a/widgets/table/e-table-group.c b/widgets/table/e-table-group.c
index b1e681d255..76c317369e 100644
--- a/widgets/table/e-table-group.c
+++ b/widgets/table/e-table-group.c
@@ -8,93 +8,132 @@
*/
#include <config.h>
+#include <gtk/gtksignal.h>
#include "e-table-group.h"
+#include <libgnomeui/gnome-canvas-rect-ellipse.h>
+#include "e-util.h"
-void
-e_table_group_destroy (ETableGroup *etg)
-{
- g_return_if_fail (etg != NULL);
+#define TITLE_HEIGHT 16
+#define GROUP_INDENT 10
- g_free (etg->title);
+#define PARENT_TYPE gnome_canvas_group_get_type ()
- if (etg->is_leaf == 0){
- GSList *l;
+static GnomeCanvasGroupClass *etg_parent_class;
- for (l = etg->u.children; l; l = l->next){
- ETableGroup *child = l->data;
-
- e_table_group_destroy (child);
- }
- g_slist_free (etg->u.children);
- etg->u.children = NULL;
- }
- g_free (etg);
+static void
+etg_destroy (GtkObject *object)
+{
+ ETableGroup *etg = E_TABLE_GROUP (object);
+
+ gtk_object_unref (GTK_OBJECT (etg->ecol));
+
+ GTK_OBJECT_CLASS (etg_parent_class)->destroy (object);
}
-ETableGroup *
-e_table_group_new_leaf (const char *title, ETableModel *table)
+static int
+etg_width (ETableGroup *etg)
{
- ETableGroup *etg;
+ return e_table_header_total_width (etg->header) + GROUP_INDENT;
+}
- g_return_val_if_fail (title != NULL, NULL);
- g_return_val_if_fail (table != NULL, NULL);
+static int
+etg_height (ETableGroup *etg)
+{
+ GnomeCanvasItem *child = etg->child;
- etg = g_new (ETableGroup, 1);
+ return TITLE_HEIGHT + (child->y2 - child->y1);
+}
+
+static void
+etg_header_changed (ETableHeader *header, ETableGroup *etg)
+{
+ gnome_canvas_item_set (
+ etg->rect,
+ "x2", (double) etg_width (etg),
+ NULL);
+}
- etg->expanded = 0;
- etg->is_leaf = 1;
- etg->u.table = table;
- etg->title = g_strdup (title);
+void
+e_table_group_construct (GnomeCanvasGroup *parent, ETableGroup *etg,
+ ETableHeader *header, int col,
+ GnomeCanvasItem *child, int open)
+{
+ gnome_canvas_item_constructv (GNOME_CANVAS_ITEM (etg), parent, 0, NULL);
+
+ gtk_object_ref (GTK_OBJECT (header));
+
+ etg->header = header;
+ etg->col = col;
+ etg->ecol = e_table_header_get_column (header, col);
+ etg->open = open;
+
+ gtk_signal_connect (
+ GTK_OBJECT (header), "dimension_change",
+ GTK_SIGNAL_FUNC (etg_header_changed), etg);
+
+ etg->child = child;
+
+ etg->rect = gnome_canvas_item_new (
+ GNOME_CANVAS_GROUP (etg),
+ gnome_canvas_rect_get_type (),
+ "fill_color", "gray",
+ "outline_color", "gray20",
+ "x1", 0.0,
+ "y1", 0.0,
+ "x2", (double) etg_width (etg),
+ "y2", (double) etg_height (etg),
+ NULL);
- return etg;
+
+ /*
+ * Reparent the child into our space.
+ */
+ gnome_canvas_item_reparent (child, GNOME_CANVAS_GROUP (etg));
+
+ gnome_canvas_item_set (
+ child,
+ "x", (double) GROUP_INDENT,
+ "y", (double) TITLE_HEIGHT,
+ NULL);
}
-ETableGroup *
-e_table_group_new (const char *title)
+GnomeCanvasItem *
+e_table_group_new (GnomeCanvasGroup *parent, ETableHeader *header, int col, GnomeCanvasItem *child, int open)
{
ETableGroup *etg;
- g_return_val_if_fail (title != NULL, NULL);
+ g_return_val_if_fail (parent != NULL, NULL);
+ g_return_val_if_fail (header != NULL, NULL);
+ g_return_val_if_fail (child != NULL, NULL);
- etg = g_new (ETableGroup, 1);
+ etg = gtk_type_new (e_table_group_get_type ());
- etg->expanded = 0;
- etg->is_leaf = 0;
- etg->u.children = NULL;
- etg->title = g_strdup (title);
+ e_table_group_construct (parent, etg, header, col, child, open);
- return etg;
+ return GNOME_CANVAS_ITEM (etg);
}
-void
-e_table_group_append_child (ETableGroup *etg, ETableGroup *child)
+static void
+etg_realize (GnomeCanvasItem *item)
{
- g_return_if_fail (etg != NULL);
- g_return_if_fail (child != NULL);
- g_return_if_fail (etg->is_leaf != 0);
-
- etg->u.children = g_slist_append (etg->u.children, child);
+ ETableGroup *etg = E_TABLE_GROUP (item);
+
+ GNOME_CANVAS_ITEM_CLASS (etg_parent_class)->realize (item);
}
-#if 0
-int
-e_table_group_size (ETableGroup *etg)
+static void
+etg_class_init (GtkObjectClass *object_class)
{
- g_return_val_if_fail (etg != NULL, 0);
-
- if (etg->is_leaf)
- return e_table_model_height (etg->u.table);
- else {
- GSList *l;
- int size = 0;
-
- for (l = etg->u.children; l; l = l->next){
- ETableGroup *child = l->data;
-
- size += e_table_group_size (child);
- }
- return size;
- }
+ GnomeCanvasItemClass *item_class = (GnomeCanvasItemClass *) object_class;
+
+ object_class->destroy = etg_destroy;
+
+ item_class->realize = etg_realize;
+
+ etg_parent_class = gtk_type_class (PARENT_TYPE);
}
-#endif
+E_MAKE_TYPE (e_table_group, "ETableGroup", ETableGroup, etg_class_init, NULL, PARENT_TYPE);
+
+
+
diff --git a/widgets/table/e-table-group.h b/widgets/table/e-table-group.h
index 62bc11093f..18f4b710b1 100644
--- a/widgets/table/e-table-group.h
+++ b/widgets/table/e-table-group.h
@@ -1,25 +1,35 @@
#ifndef _E_TABLE_TREE_H_
#define _E_TABLE_TREE_H_
+#include <libgnomeui/gnome-canvas.h>
#include "e-table-model.h"
+#include "e-table-header.h"
-typedef struct {
- char *title;
+#define E_TABLE_GROUP_TYPE (e_table_group_get_type ())
+#define E_TABLE_GROUP(o) (GTK_CHECK_CAST ((o), E_TABLE_GROUP_TYPE, ETableGroup))
+#define E_TABLE_GROUP_CLASS(k) (GTK_CHECK_CLASS_CAST((k), E_TABLE_GROUP_TYPE, ETableGroupClass))
+#define E_IS_TABLE_GROUP(o) (GTK_CHECK_TYPE ((o), E_TABLE_GROUP_TYPE))
+#define E_IS_TABLE_GROUP_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), E_TABLE_GROUP_TYPE))
- union {
- ETableModel *table;
- GSList *children;
- } u;
+typedef struct {
+ GnomeCanvasGroup group;
- guint expanded :1;
- guint is_leaf :1;
+ ETableHeader *header;
+ ETableCol *ecol;
+ int col;
+ int open;
+ GnomeCanvasItem *rect, *child;
} ETableGroup;
-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);
+typedef struct {
+ GnomeCanvasGroupClass parent_class;
+} ETableGroupClass;
-int e_table_group_size (ETableGroup *egroup);
-void e_table_group_append_child (ETableGroup *etg, ETableGroup *child);
+GnomeCanvasItem *e_table_group_new (GnomeCanvasGroup *parent, ETableHeader *header,
+ int col, GnomeCanvasItem *child, int open);
+void e_table_group_construct (GnomeCanvasGroup *parent, ETableGroup *etg,
+ ETableHeader *header, int col,
+ GnomeCanvasItem *child, int open);
+GtkType e_table_group_get_type (void);
#endif /* _E_TABLE_TREE_H_ */
diff --git a/widgets/table/e-table-header.c b/widgets/table/e-table-header.c
index 32078d9a78..7c54bd936e 100644
--- a/widgets/table/e-table-header.c
+++ b/widgets/table/e-table-header.c
@@ -143,6 +143,7 @@ e_table_header_add_column (ETableHeader *eth, ETableCol *tc, int pos)
eth_update_offsets (eth);
gtk_signal_emit (GTK_OBJECT (eth), eth_signals [STRUCTURE_CHANGE]);
+ gtk_signal_emit (GTK_OBJECT (eth), eth_signals [DIMENSION_CHANGE]);
}
ETableCol *
@@ -283,6 +284,7 @@ e_table_header_move (ETableHeader *eth, int source_index, int target_index)
eth_update_offsets (eth);
gtk_signal_emit (GTK_OBJECT (eth), eth_signals [STRUCTURE_CHANGE]);
+ gtk_signal_emit (GTK_OBJECT (eth), eth_signals [DIMENSION_CHANGE]);
}
void
@@ -295,6 +297,7 @@ e_table_header_remove (ETableHeader *eth, int idx)
eth_do_remove (eth, idx, TRUE);
gtk_signal_emit (GTK_OBJECT (eth), eth_signals [STRUCTURE_CHANGE]);
+ gtk_signal_emit (GTK_OBJECT (eth), eth_signals [DIMENSION_CHANGE]);
}
void
diff --git a/widgets/table/e-table-item.c b/widgets/table/e-table-item.c
index 26e21bfd98..23b72d5557 100644
--- a/widgets/table/e-table-item.c
+++ b/widgets/table/e-table-item.c
@@ -461,11 +461,11 @@ eti_set_arg (GtkObject *o, GtkArg *arg, guint arg_id)
break;
case ARG_TABLE_X:
- eti->x1 = GTK_VALUE_INT (*arg);
+ eti->x1 = GTK_VALUE_DOUBLE (*arg);
break;
case ARG_TABLE_Y:
- eti->y1 = GTK_VALUE_INT (*arg);
+ eti->y1 = GTK_VALUE_DOUBLE (*arg);
break;
case ARG_LENGHT_THRESHOLD:
@@ -974,9 +974,9 @@ 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_INT,
+ 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_INT,
+ 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);
diff --git a/widgets/table/e-table.c b/widgets/table/e-table.c
index a37012d4cc..b5f77f622b 100644
--- a/widgets/table/e-table.c
+++ b/widgets/table/e-table.c
@@ -19,6 +19,7 @@
#include "e-table-header-item.h"
#include "e-table-subset.h"
#include "e-table-item.h"
+#include "e-table-group.h"
#define COLUMN_HEADER_HEIGHT 16
#define TITLE_HEIGHT 16
@@ -28,10 +29,10 @@
static GtkObjectClass *e_table_parent_class;
-typedef struct {
+typedef struct {
ETableModel *table;
GnomeCanvasItem *table_item;
- GnomeCanvasItem *rect;
+ GnomeCanvasItem *lead;
} Leaf;
typedef struct {
@@ -87,6 +88,14 @@ e_table_make_header (ETable *e_table, ETableHeader *full_header, const char *col
}
static void
+header_canvas_size_alocate (GtkWidget *widget, GtkAllocation *alloc, ETable *e_table)
+{
+ gnome_canvas_set_scroll_region (
+ GNOME_CANVAS (e_table->header_canvas),
+ 0, 0, alloc->width, COLUMN_HEADER_HEIGHT);
+}
+
+static void
e_table_setup_header (ETable *e_table)
{
e_table->header_canvas = GNOME_CANVAS (gnome_canvas_new ());
@@ -101,9 +110,11 @@ e_table_setup_header (ETable *e_table)
"y", 0,
NULL);
+ gtk_signal_connect (
+ GTK_OBJECT (e_table->header_canvas), "size_allocate",
+ GTK_SIGNAL_FUNC (header_canvas_size_alocate), e_table);
+
gtk_widget_set_usize (GTK_WIDGET (e_table->header_canvas), -1, COLUMN_HEADER_HEIGHT);
- g_warning ("Aqui");
- e_table->header_canvas = 0;
gtk_table_attach (
GTK_TABLE (e_table), GTK_WIDGET (e_table->header_canvas),
@@ -112,10 +123,9 @@ e_table_setup_header (ETable *e_table)
}
static Leaf *
-e_table_create_leaf (ETable *e_table, int x_off, int y_off, ETableModel *etm)
+e_table_create_leaf (ETable *e_table, ETableModel *etm, int col, int height)
{
Leaf *leaf;
- int height;
leaf = g_new (Leaf, 1);
leaf->table = etm;
@@ -125,26 +135,21 @@ e_table_create_leaf (ETable *e_table, int x_off, int y_off, ETableModel *etm)
e_table_item_get_type (),
"ETableHeader", e_table->header,
"ETableModel", etm,
- "x", x_off + GROUP_INDENT,
- "y", y_off + TITLE_HEIGHT,
+ "x", (double) 0,
+ "y", (double) 0,
"drawgrid", e_table->draw_grid,
"drawfocus", e_table->draw_focus,
"spreadsheet", e_table->spreadsheet,
NULL);
- height = E_TABLE_ITEM (leaf->table_item)->height;
-
- leaf->rect = gnome_canvas_item_new (
+ leaf->lead = e_table_group_new (
gnome_canvas_root (e_table->table_canvas),
- gnome_canvas_rect_get_type (),
- "x1", (double) x_off,
- "y1", (double) y_off,
- "x2", (double) x_off + e_table->gen_header_width + GROUP_INDENT,
- "y2", (double) y_off + TITLE_HEIGHT + height,
- "fill_color", "gray",
- "outline_color", "gray20",
+ e_table->header, col, leaf->table_item, TRUE);
+
+ gnome_canvas_item_set (
+ leaf->lead,
+ "y", (double) height,
NULL);
- gnome_canvas_item_lower (leaf->rect, 1);
return leaf;
}
@@ -242,40 +247,30 @@ e_table_make_subtables (ETableModel *model, GArray *groups)
static int
leaf_height (Leaf *leaf)
{
- return E_TABLE_ITEM (leaf->table_item)->height + TITLE_HEIGHT;
+ return leaf->lead->y2 - leaf->lead->y1;
}
-static int
+static Leaf *
e_table_create_nodes (ETable *e_table, ETableModel *model, ETableHeader *header,
- GnomeCanvasGroup *root, int x_off, int y_off,
- int *groups_list)
+ GnomeCanvasGroup *root, int height, int *groups_list)
{
GArray *groups;
ETableModel **tables;
- int key_col;
- int height, i;
+ int key_col, i;
GCompareFunc comp;
-
+ Leaf *leaf;
+ GnomeCanvasItem *group;
+
if (groups_list)
key_col = *groups_list;
else
key_col = -1;
if (key_col == -1){
- Leaf *leaf;
-
printf ("Leaf->with %d rows\n", e_table_model_row_count (model));
- leaf = e_table_create_leaf (e_table, x_off, y_off, model);
+ leaf = e_table_create_leaf (e_table, model, key_col, height);
- {
- static int warn_shown;
-
- if (!warn_shown){
- g_warning ("Leak");
- warn_shown = 1;
- }
- }
- return leaf_height (leaf);
+ return leaf;
}
/*
@@ -286,16 +281,31 @@ e_table_create_nodes (ETable *e_table, ETableModel *model, ETableHeader *header,
tables = e_table_make_subtables (e_table->model, groups);
e_table_destroy_groups (groups);
+ leaf = g_new0 (Leaf, 1);
+
+ leaf->table = NULL;
+ leaf->table_item = NULL;
+ group = gnome_canvas_item_new (
+ root,
+ gnome_canvas_group_get_type (),
+ NULL);
+
height = 0;
for (i = 0; tables [i] != NULL; i++){
printf ("Creating->%d with %d rows\n", i, e_table_model_row_count (tables [i]));
- height += e_table_create_nodes (
- e_table, tables [i], header, root,
- x_off + 20,
- y_off + height, &groups_list [1]);
+
+ leaf = e_table_create_nodes (
+ e_table, tables [i], header, GNOME_CANVAS_GROUP (group), height,
+ &groups_list [1]);
+
+ height += leaf_height (leaf);
}
+
+ leaf->lead = e_table_group_new (
+ root,
+ e_table->header, key_col, group, TRUE);
- return height;
+ return leaf;
}
static int *
@@ -362,8 +372,8 @@ e_table_canvas_realize (GtkWidget *widget)
{
ETableCanvas *e_table_canvas = (ETableCanvas *) widget;
ETable *e_table = e_table_canvas->e_table;
+ Leaf *leaf;
int *groups;
- int height;
GTK_WIDGET_CLASS (e_table_canvas_parent_class)->realize (widget);
@@ -378,9 +388,9 @@ e_table_canvas_realize (GtkWidget *widget)
e_table->gen_header_width = e_table_header_total_width (e_table->header);
- height = e_table_create_nodes (
+ leaf = e_table_create_nodes (
e_table, e_table->model,
- e_table->header, GNOME_CANVAS_GROUP (e_table->root), 0, 0, groups);
+ e_table->header, GNOME_CANVAS_GROUP (e_table->root), 0, groups);
{
static int warn_shown;
@@ -395,7 +405,7 @@ e_table_canvas_realize (GtkWidget *widget)
GNOME_CANVAS (e_table_canvas),
0, 0,
e_table_header_total_width (e_table->header) + 200,
- height);
+ leaf_height (leaf));
if (groups)
g_free (groups);
diff --git a/widgets/table/table-test.c b/widgets/table/table-test.c
index 9de673ede4..73cb22f4b1 100644
--- a/widgets/table/table-test.c
+++ b/widgets/table/table-test.c
@@ -31,9 +31,11 @@ main (int argc, char *argv [])
gnome_init ("TableTest", "TableTest", argc, argv);
e_cursors_init ();
+#if 0
table_browser_test ();
multi_cols_test ();
check_test ();
+#endif
e_table_test ();
gtk_main ();
diff --git a/widgets/table/test-check.c b/widgets/table/test-check.c
index 9e003ce9a1..b24a7aff64 100644
--- a/widgets/table/test-check.c
+++ b/widgets/table/test-check.c
@@ -138,8 +138,8 @@ check_test (void)
e_table_item_get_type (),
"ETableHeader", e_table_header,
"ETableModel", e_table_model,
- "x", 0,
- "y", 30,
+ "x", (double) 0,
+ "y", (double) 30,
"drawgrid", TRUE,
"drawfocus", TRUE,
"spreadsheet", TRUE,
diff --git a/widgets/table/test-cols.c b/widgets/table/test-cols.c
index b7979c2f3d..6342a1739f 100644
--- a/widgets/table/test-cols.c
+++ b/widgets/table/test-cols.c
@@ -162,8 +162,8 @@ multi_cols_test (void)
e_table_item_get_type (),
"ETableHeader", e_table_header,
"ETableModel", e_table_model,
- "x", 0,
- "y", 30,
+ "x", (double) 0,
+ "y", (double) 30,
"drawgrid", TRUE,
"drawfocus", TRUE,
"spreadsheet", TRUE,
@@ -181,8 +181,8 @@ multi_cols_test (void)
e_table_item_get_type (),
"ETableHeader", e_table_header_multiple,
"ETableModel", e_table_model,
- "x", 300,
- "y", 30,
+ "x", (double) 300,
+ "y", (double) 30,
"drawgrid", TRUE,
"drawfocus", TRUE,
"spreadsheet", TRUE,
diff --git a/widgets/table/test-table.c b/widgets/table/test-table.c
index 8bf22f980d..63fd7ce271 100644
--- a/widgets/table/test-table.c
+++ b/widgets/table/test-table.c
@@ -244,8 +244,8 @@ table_browser_test (void)
e_table_item_get_type (),
"ETableHeader", e_table_header,
"ETableModel", e_table_model,
- "x", 0,
- "y", 0,
+ "x", (double) 0,
+ "y", (double) 0,
"drawgrid", TRUE,
"drawfocus", TRUE,
"spreadsheet", TRUE,
diff --git a/widgets/test-check.c b/widgets/test-check.c
index 9e003ce9a1..b24a7aff64 100644
--- a/widgets/test-check.c
+++ b/widgets/test-check.c
@@ -138,8 +138,8 @@ check_test (void)
e_table_item_get_type (),
"ETableHeader", e_table_header,
"ETableModel", e_table_model,
- "x", 0,
- "y", 30,
+ "x", (double) 0,
+ "y", (double) 30,
"drawgrid", TRUE,
"drawfocus", TRUE,
"spreadsheet", TRUE,
diff --git a/widgets/test-cols.c b/widgets/test-cols.c
index b7979c2f3d..6342a1739f 100644
--- a/widgets/test-cols.c
+++ b/widgets/test-cols.c
@@ -162,8 +162,8 @@ multi_cols_test (void)
e_table_item_get_type (),
"ETableHeader", e_table_header,
"ETableModel", e_table_model,
- "x", 0,
- "y", 30,
+ "x", (double) 0,
+ "y", (double) 30,
"drawgrid", TRUE,
"drawfocus", TRUE,
"spreadsheet", TRUE,
@@ -181,8 +181,8 @@ multi_cols_test (void)
e_table_item_get_type (),
"ETableHeader", e_table_header_multiple,
"ETableModel", e_table_model,
- "x", 300,
- "y", 30,
+ "x", (double) 300,
+ "y", (double) 30,
"drawgrid", TRUE,
"drawfocus", TRUE,
"spreadsheet", TRUE,
diff --git a/widgets/test-table.c b/widgets/test-table.c
index 8bf22f980d..63fd7ce271 100644
--- a/widgets/test-table.c
+++ b/widgets/test-table.c
@@ -244,8 +244,8 @@ table_browser_test (void)
e_table_item_get_type (),
"ETableHeader", e_table_header,
"ETableModel", e_table_model,
- "x", 0,
- "y", 0,
+ "x", (double) 0,
+ "y", (double) 0,
"drawgrid", TRUE,
"drawfocus", TRUE,
"spreadsheet", TRUE,