aboutsummaryrefslogtreecommitdiffstats
path: root/widgets
diff options
context:
space:
mode:
Diffstat (limited to 'widgets')
-rw-r--r--widgets/e-table-item.c70
-rw-r--r--widgets/e-table-item.h7
-rw-r--r--widgets/e-table-model.c2
-rw-r--r--widgets/e-table-simple.c13
-rw-r--r--widgets/e-table-simple.h1
-rw-r--r--widgets/e-table/e-table-item.c70
-rw-r--r--widgets/e-table/e-table-item.h7
-rw-r--r--widgets/e-table/e-table-model.c2
-rw-r--r--widgets/e-table/e-table-simple.c13
-rw-r--r--widgets/e-table/e-table-simple.h1
-rw-r--r--widgets/e-table/table-test.c18
-rw-r--r--widgets/table-test.c18
-rw-r--r--widgets/table/e-table-item.c70
-rw-r--r--widgets/table/e-table-item.h7
-rw-r--r--widgets/table/e-table-model.c2
-rw-r--r--widgets/table/e-table-simple.c13
-rw-r--r--widgets/table/e-table-simple.h1
-rw-r--r--widgets/table/table-test.c18
18 files changed, 300 insertions, 33 deletions
diff --git a/widgets/e-table-item.c b/widgets/e-table-item.c
index 6399f252b2..904848e8c6 100644
--- a/widgets/e-table-item.c
+++ b/widgets/e-table-item.c
@@ -110,7 +110,7 @@ eti_add_header_model (ETableItem *eti, ETableHeader *header)
GTK_SIGNAL_FUNC (eti_header_dim_changed), eti);
eti->header_structure_change_id = gtk_signal_connect (
- GTK_OBJECT (header), "structure_changed",
+ GTK_OBJECT (header), "structure_change",
GTK_SIGNAL_FUNC (eti_header_structure_changed), eti);
}
@@ -138,12 +138,14 @@ eti_set_arg (GtkObject *o, GtkArg *arg, guint arg_id)
switch (arg_id){
case ARG_TABLE_HEADER:
- eti->header = GTK_VALUE_POINTER (*arg);
- gtk_object_ref (GTK_OBJECT (eti->header));
+ eti_remove_header_model (eti);
+ eti_add_header_model (eti, GTK_VALUE_POINTER (*arg));
break;
case ARG_TABLE_MODEL:
eti_remove_table_model (eti);
+ eti_add_table_model (eti, GTK_VALUE_POINTER (*arg));
+
eti->height = e_table_model_height (eti->table_model);
break;
@@ -176,9 +178,61 @@ eti_unrealize (GnomeCanvasItem *item)
}
static void
-eti_draw (GnomeCanvasItem *item, GdkDrawable *drawable, int x1, int y1, int width, int height)
+eti_draw (GnomeCanvasItem *item, GdkDrawable *drawable, int x, int y, int width, int height)
{
+ ETableItem *eti = E_TABLE_ITEM (item);
+ const int rows = e_table_model_row_count (eti->table_model);
+ const int cols = e_table_header_count (eti->header);
+ int row, col, y1, y2;
+ int first_col, last_col, x_offset;
+ int x1, x2;
+
+ /*
+ * Clear the background
+ */
+ gdk_draw_rectangle (
+ drawable, eti->fill_gc, TRUE, 0, 0, width, height);
+
+ /*
+ * First column to draw, last column to draw
+ */
+ x1 = x_offset = 0;
+ first_col = -1;
+ last_col = 0;
+ for (col = 0; col < cols; col++, x1 = x2){
+ ETableCol *ecol = e_table_header_get_column (eti->header, col);
+
+ x2 = x1 + ecol->width;
+
+ if (x1 > (x + width))
+ break;
+ if (x2 < x)
+ continue;
+ if (first_col == -1){
+ x_offset = x - x1;
+ first_col = col;
+ }
+ }
+ last_col = col;
+ /*
+ * Draw individual lines
+ */
+ y1 = y2 = 0;
+ for (row = eti->top_item; row < rows; row++, y1 = y2){
+ y2 += e_table_model_row_height (eti->table_model, row) + 1;
+
+ if (y1 > y + height)
+ break;
+
+ if (y2 < y)
+ continue;
+
+ if (eti->draw_grid)
+ gdk_draw_line (drawable, eti->grid_gc, 0, y - y2, width, y - y2);
+
+
+ }
}
static double
@@ -213,13 +267,13 @@ eti_class_init (GtkObjectClass *object_class)
item_class->point = eti_point;
item_class->event = eti_event;
- gtk_object_add_arg_type ("ETableHeaderItem::ETableHeader", GTK_TYPE_POINTER,
+ gtk_object_add_arg_type ("ETableItem::ETableHeader", GTK_TYPE_POINTER,
GTK_ARG_WRITABLE, ARG_TABLE_HEADER);
- gtk_object_add_arg_type ("ETableHeaderItem::ETableModel", GTK_TYPE_POINTER,
+ gtk_object_add_arg_type ("ETableItem::ETableModel", GTK_TYPE_POINTER,
GTK_ARG_WRITABLE, ARG_TABLE_MODEL);
- gtk_object_add_arg_type ("ETableHeaderItem::x", GTK_TYPE_INT,
+ gtk_object_add_arg_type ("ETableItem::x", GTK_TYPE_INT,
GTK_ARG_WRITABLE, ARG_TABLE_X);
- gtk_object_add_arg_type ("ETableHeaderItem::y", GTK_TYPE_INT,
+ gtk_object_add_arg_type ("ETableItem::y", GTK_TYPE_INT,
GTK_ARG_WRITABLE, ARG_TABLE_Y);
}
diff --git a/widgets/e-table-item.h b/widgets/e-table-item.h
index 9b8ab541ae..55893bb9ae 100644
--- a/widgets/e-table-item.h
+++ b/widgets/e-table-item.h
@@ -19,12 +19,19 @@ typedef struct {
int x1, y1;
int height;
+ int top_item;
+
/*
* Ids for the signals we connect to
*/
int header_dim_change_id;
int header_structure_change_id;
int table_model_change_id;
+
+ GdkGC *fill_gc;
+ GdkGC *grid_gc;
+
+ unsigned int draw_grid:1;
} ETableItem;
typedef struct {
diff --git a/widgets/e-table-model.c b/widgets/e-table-model.c
index e7c591c345..de7bc67c51 100644
--- a/widgets/e-table-model.c
+++ b/widgets/e-table-model.c
@@ -126,7 +126,7 @@ e_table_model_height (ETableModel *etable)
size = 0;
for (i = 0; i < rows; i++)
- size += e_table_model_row_height (etable, i);
+ size += e_table_model_row_height (etable, i) + 1;
return size;
}
diff --git a/widgets/e-table-simple.c b/widgets/e-table-simple.c
index 4d82bbe995..32f7145bc6 100644
--- a/widgets/e-table-simple.c
+++ b/widgets/e-table-simple.c
@@ -60,6 +60,14 @@ simple_is_cell_editable (ETableModel *etm, int col, int row)
return simple->is_cell_editable (etm, col, row, simple->data);
}
+static int
+simple_row_height (ETableModel *etm, int row)
+{
+ ETableSimple *simple = (ETableSimple *)etm;
+
+ return simple->row_height (etm, row, simple->data);
+}
+
static void
e_table_simple_class_init (GtkObjectClass *object_class)
{
@@ -71,6 +79,7 @@ e_table_simple_class_init (GtkObjectClass *object_class)
model_class->value_at = simple_value_at;
model_class->set_value_at = simple_set_value_at;
model_class->is_cell_editable = simple_is_cell_editable;
+ model_class->row_height = simple_row_height;
}
GtkType
@@ -103,6 +112,7 @@ e_table_simple_new (ETableSimpleColumnCountFn col_count,
ETableSimpleValueAtFn value_at,
ETableSimpleSetValueAtFn set_value_at,
ETableSimpleIsCellEditableFn is_cell_editable,
+ ETableSimpleRowHeightFn row_height,
void *data)
{
ETableSimple *et;
@@ -115,6 +125,7 @@ e_table_simple_new (ETableSimpleColumnCountFn col_count,
et->value_at = value_at;
et->set_value_at = set_value_at;
et->is_cell_editable = is_cell_editable;
-
+ et->row_height = row_height;
+
return (ETableModel *) et;
}
diff --git a/widgets/e-table-simple.h b/widgets/e-table-simple.h
index d47a1cbe0b..ac34d6045c 100644
--- a/widgets/e-table-simple.h
+++ b/widgets/e-table-simple.h
@@ -36,6 +36,7 @@ ETableModel *e_table_simple_new (ETableSimpleColumnCountFn col_count,
ETableSimpleValueAtFn value_at,
ETableSimpleSetValueAtFn set_value_at,
ETableSimpleIsCellEditableFn is_cell_editable,
+ ETableSimpleRowHeightFn row_height,
void *data);
#endif /* _E_TABLE_SIMPLE_H_ */
diff --git a/widgets/e-table/e-table-item.c b/widgets/e-table/e-table-item.c
index 6399f252b2..904848e8c6 100644
--- a/widgets/e-table/e-table-item.c
+++ b/widgets/e-table/e-table-item.c
@@ -110,7 +110,7 @@ eti_add_header_model (ETableItem *eti, ETableHeader *header)
GTK_SIGNAL_FUNC (eti_header_dim_changed), eti);
eti->header_structure_change_id = gtk_signal_connect (
- GTK_OBJECT (header), "structure_changed",
+ GTK_OBJECT (header), "structure_change",
GTK_SIGNAL_FUNC (eti_header_structure_changed), eti);
}
@@ -138,12 +138,14 @@ eti_set_arg (GtkObject *o, GtkArg *arg, guint arg_id)
switch (arg_id){
case ARG_TABLE_HEADER:
- eti->header = GTK_VALUE_POINTER (*arg);
- gtk_object_ref (GTK_OBJECT (eti->header));
+ eti_remove_header_model (eti);
+ eti_add_header_model (eti, GTK_VALUE_POINTER (*arg));
break;
case ARG_TABLE_MODEL:
eti_remove_table_model (eti);
+ eti_add_table_model (eti, GTK_VALUE_POINTER (*arg));
+
eti->height = e_table_model_height (eti->table_model);
break;
@@ -176,9 +178,61 @@ eti_unrealize (GnomeCanvasItem *item)
}
static void
-eti_draw (GnomeCanvasItem *item, GdkDrawable *drawable, int x1, int y1, int width, int height)
+eti_draw (GnomeCanvasItem *item, GdkDrawable *drawable, int x, int y, int width, int height)
{
+ ETableItem *eti = E_TABLE_ITEM (item);
+ const int rows = e_table_model_row_count (eti->table_model);
+ const int cols = e_table_header_count (eti->header);
+ int row, col, y1, y2;
+ int first_col, last_col, x_offset;
+ int x1, x2;
+
+ /*
+ * Clear the background
+ */
+ gdk_draw_rectangle (
+ drawable, eti->fill_gc, TRUE, 0, 0, width, height);
+
+ /*
+ * First column to draw, last column to draw
+ */
+ x1 = x_offset = 0;
+ first_col = -1;
+ last_col = 0;
+ for (col = 0; col < cols; col++, x1 = x2){
+ ETableCol *ecol = e_table_header_get_column (eti->header, col);
+
+ x2 = x1 + ecol->width;
+
+ if (x1 > (x + width))
+ break;
+ if (x2 < x)
+ continue;
+ if (first_col == -1){
+ x_offset = x - x1;
+ first_col = col;
+ }
+ }
+ last_col = col;
+ /*
+ * Draw individual lines
+ */
+ y1 = y2 = 0;
+ for (row = eti->top_item; row < rows; row++, y1 = y2){
+ y2 += e_table_model_row_height (eti->table_model, row) + 1;
+
+ if (y1 > y + height)
+ break;
+
+ if (y2 < y)
+ continue;
+
+ if (eti->draw_grid)
+ gdk_draw_line (drawable, eti->grid_gc, 0, y - y2, width, y - y2);
+
+
+ }
}
static double
@@ -213,13 +267,13 @@ eti_class_init (GtkObjectClass *object_class)
item_class->point = eti_point;
item_class->event = eti_event;
- gtk_object_add_arg_type ("ETableHeaderItem::ETableHeader", GTK_TYPE_POINTER,
+ gtk_object_add_arg_type ("ETableItem::ETableHeader", GTK_TYPE_POINTER,
GTK_ARG_WRITABLE, ARG_TABLE_HEADER);
- gtk_object_add_arg_type ("ETableHeaderItem::ETableModel", GTK_TYPE_POINTER,
+ gtk_object_add_arg_type ("ETableItem::ETableModel", GTK_TYPE_POINTER,
GTK_ARG_WRITABLE, ARG_TABLE_MODEL);
- gtk_object_add_arg_type ("ETableHeaderItem::x", GTK_TYPE_INT,
+ gtk_object_add_arg_type ("ETableItem::x", GTK_TYPE_INT,
GTK_ARG_WRITABLE, ARG_TABLE_X);
- gtk_object_add_arg_type ("ETableHeaderItem::y", GTK_TYPE_INT,
+ gtk_object_add_arg_type ("ETableItem::y", GTK_TYPE_INT,
GTK_ARG_WRITABLE, ARG_TABLE_Y);
}
diff --git a/widgets/e-table/e-table-item.h b/widgets/e-table/e-table-item.h
index 9b8ab541ae..55893bb9ae 100644
--- a/widgets/e-table/e-table-item.h
+++ b/widgets/e-table/e-table-item.h
@@ -19,12 +19,19 @@ typedef struct {
int x1, y1;
int height;
+ int top_item;
+
/*
* Ids for the signals we connect to
*/
int header_dim_change_id;
int header_structure_change_id;
int table_model_change_id;
+
+ GdkGC *fill_gc;
+ GdkGC *grid_gc;
+
+ unsigned int draw_grid:1;
} ETableItem;
typedef struct {
diff --git a/widgets/e-table/e-table-model.c b/widgets/e-table/e-table-model.c
index e7c591c345..de7bc67c51 100644
--- a/widgets/e-table/e-table-model.c
+++ b/widgets/e-table/e-table-model.c
@@ -126,7 +126,7 @@ e_table_model_height (ETableModel *etable)
size = 0;
for (i = 0; i < rows; i++)
- size += e_table_model_row_height (etable, i);
+ size += e_table_model_row_height (etable, i) + 1;
return size;
}
diff --git a/widgets/e-table/e-table-simple.c b/widgets/e-table/e-table-simple.c
index 4d82bbe995..32f7145bc6 100644
--- a/widgets/e-table/e-table-simple.c
+++ b/widgets/e-table/e-table-simple.c
@@ -60,6 +60,14 @@ simple_is_cell_editable (ETableModel *etm, int col, int row)
return simple->is_cell_editable (etm, col, row, simple->data);
}
+static int
+simple_row_height (ETableModel *etm, int row)
+{
+ ETableSimple *simple = (ETableSimple *)etm;
+
+ return simple->row_height (etm, row, simple->data);
+}
+
static void
e_table_simple_class_init (GtkObjectClass *object_class)
{
@@ -71,6 +79,7 @@ e_table_simple_class_init (GtkObjectClass *object_class)
model_class->value_at = simple_value_at;
model_class->set_value_at = simple_set_value_at;
model_class->is_cell_editable = simple_is_cell_editable;
+ model_class->row_height = simple_row_height;
}
GtkType
@@ -103,6 +112,7 @@ e_table_simple_new (ETableSimpleColumnCountFn col_count,
ETableSimpleValueAtFn value_at,
ETableSimpleSetValueAtFn set_value_at,
ETableSimpleIsCellEditableFn is_cell_editable,
+ ETableSimpleRowHeightFn row_height,
void *data)
{
ETableSimple *et;
@@ -115,6 +125,7 @@ e_table_simple_new (ETableSimpleColumnCountFn col_count,
et->value_at = value_at;
et->set_value_at = set_value_at;
et->is_cell_editable = is_cell_editable;
-
+ et->row_height = row_height;
+
return (ETableModel *) et;
}
diff --git a/widgets/e-table/e-table-simple.h b/widgets/e-table/e-table-simple.h
index d47a1cbe0b..ac34d6045c 100644
--- a/widgets/e-table/e-table-simple.h
+++ b/widgets/e-table/e-table-simple.h
@@ -36,6 +36,7 @@ ETableModel *e_table_simple_new (ETableSimpleColumnCountFn col_count,
ETableSimpleValueAtFn value_at,
ETableSimpleSetValueAtFn set_value_at,
ETableSimpleIsCellEditableFn is_cell_editable,
+ ETableSimpleRowHeightFn row_height,
void *data);
#endif /* _E_TABLE_SIMPLE_H_ */
diff --git a/widgets/e-table/table-test.c b/widgets/e-table/table-test.c
index d67a211094..50fa8a7597 100644
--- a/widgets/e-table/table-test.c
+++ b/widgets/e-table/table-test.c
@@ -12,6 +12,7 @@
#include "e-table-header.h"
#include "e-table-header-item.h"
#include "e-table-render.h"
+#include "e-table-item.h"
char buffer [1024];
char **column_labels;
@@ -172,6 +173,12 @@ set_canvas_size (GnomeCanvas *canvas, GtkAllocation *alloc)
gnome_canvas_set_scroll_region (canvas, 0, 0, alloc->width, alloc->height);
}
+static int
+row_height (ETableModel *etm, int row, void *data)
+{
+ return row * 2 + 14;
+}
+
int
main (int argc, char *argv [])
{
@@ -190,7 +197,7 @@ main (int argc, char *argv [])
*/
e_table_model = e_table_simple_new (
col_count, col_name, row_count, value_at,
- set_value_at, is_cell_editable, NULL);
+ set_value_at, is_cell_editable, row_height, NULL);
/*
* Header
@@ -229,6 +236,15 @@ main (int argc, char *argv [])
"y2", 10.0,
"fill_color", "red",
NULL);
+
+ gnome_canvas_item_new (
+ gnome_canvas_root (GNOME_CANVAS (canvas)),
+ e_table_item_get_type (),
+ "ETableHeader", e_table_header,
+ "ETableModel", e_table_model,
+ "x", 0,
+ "y", 30,
+ NULL);
gtk_main ();
e_cursors_shutdown ();
diff --git a/widgets/table-test.c b/widgets/table-test.c
index d67a211094..50fa8a7597 100644
--- a/widgets/table-test.c
+++ b/widgets/table-test.c
@@ -12,6 +12,7 @@
#include "e-table-header.h"
#include "e-table-header-item.h"
#include "e-table-render.h"
+#include "e-table-item.h"
char buffer [1024];
char **column_labels;
@@ -172,6 +173,12 @@ set_canvas_size (GnomeCanvas *canvas, GtkAllocation *alloc)
gnome_canvas_set_scroll_region (canvas, 0, 0, alloc->width, alloc->height);
}
+static int
+row_height (ETableModel *etm, int row, void *data)
+{
+ return row * 2 + 14;
+}
+
int
main (int argc, char *argv [])
{
@@ -190,7 +197,7 @@ main (int argc, char *argv [])
*/
e_table_model = e_table_simple_new (
col_count, col_name, row_count, value_at,
- set_value_at, is_cell_editable, NULL);
+ set_value_at, is_cell_editable, row_height, NULL);
/*
* Header
@@ -229,6 +236,15 @@ main (int argc, char *argv [])
"y2", 10.0,
"fill_color", "red",
NULL);
+
+ gnome_canvas_item_new (
+ gnome_canvas_root (GNOME_CANVAS (canvas)),
+ e_table_item_get_type (),
+ "ETableHeader", e_table_header,
+ "ETableModel", e_table_model,
+ "x", 0,
+ "y", 30,
+ NULL);
gtk_main ();
e_cursors_shutdown ();
diff --git a/widgets/table/e-table-item.c b/widgets/table/e-table-item.c
index 6399f252b2..904848e8c6 100644
--- a/widgets/table/e-table-item.c
+++ b/widgets/table/e-table-item.c
@@ -110,7 +110,7 @@ eti_add_header_model (ETableItem *eti, ETableHeader *header)
GTK_SIGNAL_FUNC (eti_header_dim_changed), eti);
eti->header_structure_change_id = gtk_signal_connect (
- GTK_OBJECT (header), "structure_changed",
+ GTK_OBJECT (header), "structure_change",
GTK_SIGNAL_FUNC (eti_header_structure_changed), eti);
}
@@ -138,12 +138,14 @@ eti_set_arg (GtkObject *o, GtkArg *arg, guint arg_id)
switch (arg_id){
case ARG_TABLE_HEADER:
- eti->header = GTK_VALUE_POINTER (*arg);
- gtk_object_ref (GTK_OBJECT (eti->header));
+ eti_remove_header_model (eti);
+ eti_add_header_model (eti, GTK_VALUE_POINTER (*arg));
break;
case ARG_TABLE_MODEL:
eti_remove_table_model (eti);
+ eti_add_table_model (eti, GTK_VALUE_POINTER (*arg));
+
eti->height = e_table_model_height (eti->table_model);
break;
@@ -176,9 +178,61 @@ eti_unrealize (GnomeCanvasItem *item)
}
static void
-eti_draw (GnomeCanvasItem *item, GdkDrawable *drawable, int x1, int y1, int width, int height)
+eti_draw (GnomeCanvasItem *item, GdkDrawable *drawable, int x, int y, int width, int height)
{
+ ETableItem *eti = E_TABLE_ITEM (item);
+ const int rows = e_table_model_row_count (eti->table_model);
+ const int cols = e_table_header_count (eti->header);
+ int row, col, y1, y2;
+ int first_col, last_col, x_offset;
+ int x1, x2;
+
+ /*
+ * Clear the background
+ */
+ gdk_draw_rectangle (
+ drawable, eti->fill_gc, TRUE, 0, 0, width, height);
+
+ /*
+ * First column to draw, last column to draw
+ */
+ x1 = x_offset = 0;
+ first_col = -1;
+ last_col = 0;
+ for (col = 0; col < cols; col++, x1 = x2){
+ ETableCol *ecol = e_table_header_get_column (eti->header, col);
+
+ x2 = x1 + ecol->width;
+
+ if (x1 > (x + width))
+ break;
+ if (x2 < x)
+ continue;
+ if (first_col == -1){
+ x_offset = x - x1;
+ first_col = col;
+ }
+ }
+ last_col = col;
+ /*
+ * Draw individual lines
+ */
+ y1 = y2 = 0;
+ for (row = eti->top_item; row < rows; row++, y1 = y2){
+ y2 += e_table_model_row_height (eti->table_model, row) + 1;
+
+ if (y1 > y + height)
+ break;
+
+ if (y2 < y)
+ continue;
+
+ if (eti->draw_grid)
+ gdk_draw_line (drawable, eti->grid_gc, 0, y - y2, width, y - y2);
+
+
+ }
}
static double
@@ -213,13 +267,13 @@ eti_class_init (GtkObjectClass *object_class)
item_class->point = eti_point;
item_class->event = eti_event;
- gtk_object_add_arg_type ("ETableHeaderItem::ETableHeader", GTK_TYPE_POINTER,
+ gtk_object_add_arg_type ("ETableItem::ETableHeader", GTK_TYPE_POINTER,
GTK_ARG_WRITABLE, ARG_TABLE_HEADER);
- gtk_object_add_arg_type ("ETableHeaderItem::ETableModel", GTK_TYPE_POINTER,
+ gtk_object_add_arg_type ("ETableItem::ETableModel", GTK_TYPE_POINTER,
GTK_ARG_WRITABLE, ARG_TABLE_MODEL);
- gtk_object_add_arg_type ("ETableHeaderItem::x", GTK_TYPE_INT,
+ gtk_object_add_arg_type ("ETableItem::x", GTK_TYPE_INT,
GTK_ARG_WRITABLE, ARG_TABLE_X);
- gtk_object_add_arg_type ("ETableHeaderItem::y", GTK_TYPE_INT,
+ gtk_object_add_arg_type ("ETableItem::y", GTK_TYPE_INT,
GTK_ARG_WRITABLE, ARG_TABLE_Y);
}
diff --git a/widgets/table/e-table-item.h b/widgets/table/e-table-item.h
index 9b8ab541ae..55893bb9ae 100644
--- a/widgets/table/e-table-item.h
+++ b/widgets/table/e-table-item.h
@@ -19,12 +19,19 @@ typedef struct {
int x1, y1;
int height;
+ int top_item;
+
/*
* Ids for the signals we connect to
*/
int header_dim_change_id;
int header_structure_change_id;
int table_model_change_id;
+
+ GdkGC *fill_gc;
+ GdkGC *grid_gc;
+
+ unsigned int draw_grid:1;
} ETableItem;
typedef struct {
diff --git a/widgets/table/e-table-model.c b/widgets/table/e-table-model.c
index e7c591c345..de7bc67c51 100644
--- a/widgets/table/e-table-model.c
+++ b/widgets/table/e-table-model.c
@@ -126,7 +126,7 @@ e_table_model_height (ETableModel *etable)
size = 0;
for (i = 0; i < rows; i++)
- size += e_table_model_row_height (etable, i);
+ size += e_table_model_row_height (etable, i) + 1;
return size;
}
diff --git a/widgets/table/e-table-simple.c b/widgets/table/e-table-simple.c
index 4d82bbe995..32f7145bc6 100644
--- a/widgets/table/e-table-simple.c
+++ b/widgets/table/e-table-simple.c
@@ -60,6 +60,14 @@ simple_is_cell_editable (ETableModel *etm, int col, int row)
return simple->is_cell_editable (etm, col, row, simple->data);
}
+static int
+simple_row_height (ETableModel *etm, int row)
+{
+ ETableSimple *simple = (ETableSimple *)etm;
+
+ return simple->row_height (etm, row, simple->data);
+}
+
static void
e_table_simple_class_init (GtkObjectClass *object_class)
{
@@ -71,6 +79,7 @@ e_table_simple_class_init (GtkObjectClass *object_class)
model_class->value_at = simple_value_at;
model_class->set_value_at = simple_set_value_at;
model_class->is_cell_editable = simple_is_cell_editable;
+ model_class->row_height = simple_row_height;
}
GtkType
@@ -103,6 +112,7 @@ e_table_simple_new (ETableSimpleColumnCountFn col_count,
ETableSimpleValueAtFn value_at,
ETableSimpleSetValueAtFn set_value_at,
ETableSimpleIsCellEditableFn is_cell_editable,
+ ETableSimpleRowHeightFn row_height,
void *data)
{
ETableSimple *et;
@@ -115,6 +125,7 @@ e_table_simple_new (ETableSimpleColumnCountFn col_count,
et->value_at = value_at;
et->set_value_at = set_value_at;
et->is_cell_editable = is_cell_editable;
-
+ et->row_height = row_height;
+
return (ETableModel *) et;
}
diff --git a/widgets/table/e-table-simple.h b/widgets/table/e-table-simple.h
index d47a1cbe0b..ac34d6045c 100644
--- a/widgets/table/e-table-simple.h
+++ b/widgets/table/e-table-simple.h
@@ -36,6 +36,7 @@ ETableModel *e_table_simple_new (ETableSimpleColumnCountFn col_count,
ETableSimpleValueAtFn value_at,
ETableSimpleSetValueAtFn set_value_at,
ETableSimpleIsCellEditableFn is_cell_editable,
+ ETableSimpleRowHeightFn row_height,
void *data);
#endif /* _E_TABLE_SIMPLE_H_ */
diff --git a/widgets/table/table-test.c b/widgets/table/table-test.c
index d67a211094..50fa8a7597 100644
--- a/widgets/table/table-test.c
+++ b/widgets/table/table-test.c
@@ -12,6 +12,7 @@
#include "e-table-header.h"
#include "e-table-header-item.h"
#include "e-table-render.h"
+#include "e-table-item.h"
char buffer [1024];
char **column_labels;
@@ -172,6 +173,12 @@ set_canvas_size (GnomeCanvas *canvas, GtkAllocation *alloc)
gnome_canvas_set_scroll_region (canvas, 0, 0, alloc->width, alloc->height);
}
+static int
+row_height (ETableModel *etm, int row, void *data)
+{
+ return row * 2 + 14;
+}
+
int
main (int argc, char *argv [])
{
@@ -190,7 +197,7 @@ main (int argc, char *argv [])
*/
e_table_model = e_table_simple_new (
col_count, col_name, row_count, value_at,
- set_value_at, is_cell_editable, NULL);
+ set_value_at, is_cell_editable, row_height, NULL);
/*
* Header
@@ -229,6 +236,15 @@ main (int argc, char *argv [])
"y2", 10.0,
"fill_color", "red",
NULL);
+
+ gnome_canvas_item_new (
+ gnome_canvas_root (GNOME_CANVAS (canvas)),
+ e_table_item_get_type (),
+ "ETableHeader", e_table_header,
+ "ETableModel", e_table_model,
+ "x", 0,
+ "y", 30,
+ NULL);
gtk_main ();
e_cursors_shutdown ();