diff options
author | Christopher James Lahey <clahey@helixcode.com> | 2000-04-15 08:10:19 +0800 |
---|---|---|
committer | Chris Lahey <clahey@src.gnome.org> | 2000-04-15 08:10:19 +0800 |
commit | b8681b4d2546a139781f8f6aea05c0fd29343f30 (patch) | |
tree | d107331478eb0eaf72185c63fa188961f18d54d8 /widgets/e-table/e-table-item.c | |
parent | a7c2eba660170e0299e99e5ef29e621bdf74d526 (diff) | |
download | gsoc2013-evolution-b8681b4d2546a139781f8f6aea05c0fd29343f30.tar.gz gsoc2013-evolution-b8681b4d2546a139781f8f6aea05c0fd29343f30.tar.zst gsoc2013-evolution-b8681b4d2546a139781f8f6aea05c0fd29343f30.zip |
Added a row height cache.
2000-04-14 Christopher James Lahey <clahey@helixcode.com>
* e-table-item.c, e-table-item.h: Added a row height cache.
svn path=/trunk/; revision=2443
Diffstat (limited to 'widgets/e-table/e-table-item.c')
-rw-r--r-- | widgets/e-table/e-table-item.c | 61 |
1 files changed, 59 insertions, 2 deletions
diff --git a/widgets/e-table/e-table-item.c b/widgets/e-table/e-table-item.c index 3e1af6b5b1..53515517e6 100644 --- a/widgets/e-table/e-table-item.c +++ b/widgets/e-table/e-table-item.c @@ -225,10 +225,13 @@ eti_remove_table_model (ETableItem *eti) eti->table_model_change_id); gtk_signal_disconnect (GTK_OBJECT (eti->table_model), eti->table_model_row_change_id); + gtk_signal_disconnect (GTK_OBJECT (eti->table_model), + eti->table_model_cell_change_id); gtk_object_unref (GTK_OBJECT (eti->table_model)); eti->table_model_change_id = 0; eti->table_model_row_change_id = 0; + eti->table_model_cell_change_id = 0; eti->table_model = NULL; } @@ -261,13 +264,13 @@ eti_remove_header_model (ETableItem *eti) } /* - * eti_row_height: + * eti_row_height_real: * * Returns the height used by row @row. This does not include the one-pixel * used as a separator between rows */ static int -eti_row_height (ETableItem *eti, int row) +eti_row_height_real (ETableItem *eti, int row) { const int cols = e_table_header_count (eti->header); int col; @@ -288,6 +291,41 @@ eti_row_height (ETableItem *eti, int row) return max_h; } +static void +free_height_cache (ETableItem *eti) +{ + if (eti->height_cache) + g_free (eti->height_cache); + eti->height_cache = NULL; +} + +static void +calculate_height_cache (ETableItem *eti) +{ + int i; + free_height_cache(eti); + eti->height_cache = g_new(int, eti->rows); + for (i = 0; i < eti->rows; i++) { + eti->height_cache[i] = eti_row_height_real(eti, i); + } +} + + +/* + * eti_row_height: + * + * Returns the height used by row @row. This does not include the one-pixel + * used as a separator between rows + */ +static int +eti_row_height (ETableItem *eti, int row) +{ + if (!eti->height_cache) { + calculate_height_cache (eti); + } + return eti->height_cache[row]; +} + /* * eti_get_height: * @@ -357,6 +395,8 @@ eti_table_model_changed (ETableModel *table_model, ETableItem *eti) if (eti->focused_row > eti->rows - 1) eti->focused_row = eti->rows - 1; + free_height_cache(eti); + eti->needs_compute_height = 1; e_canvas_item_request_reflow (GNOME_CANVAS_ITEM (eti)); eti->needs_redraw = 1; @@ -428,7 +468,18 @@ eti_table_model_row_changed (ETableModel *table_model, int row, ETableItem *eti) eti_table_model_changed (table_model, eti); return; } + + eti_request_region_redraw (eti, 0, row, eti->cols, row, 0); +} +static void +eti_table_model_cell_changed (ETableModel *table_model, int col, int row, ETableItem *eti) +{ + if (eti->renderers_can_change_size) { + eti_table_model_changed (table_model, eti); + return; + } + eti_request_region_redraw (eti, 0, row, eti->cols, row, 0); } @@ -469,6 +520,10 @@ eti_add_table_model (ETableItem *eti, ETableModel *table_model) GTK_OBJECT (table_model), "model_row_changed", GTK_SIGNAL_FUNC (eti_table_model_row_changed), eti); + eti->table_model_cell_change_id = gtk_signal_connect ( + GTK_OBJECT (table_model), "model_cell_changed", + GTK_SIGNAL_FUNC (eti_table_model_cell_changed), eti); + if (eti->header) { eti_detach_cell_views (eti); eti_attach_cell_views (eti); @@ -617,6 +672,8 @@ eti_init (GnomeCanvasItem *item) eti->editing_col = -1; eti->editing_row = -1; eti->height = 0; + + eti->height_cache = NULL; eti->length_threshold = -1; eti->renderers_can_change_size = 1; |