diff options
author | Christopher James Lahey <clahey@ximian.com> | 2001-10-05 21:27:03 +0800 |
---|---|---|
committer | Chris Lahey <clahey@src.gnome.org> | 2001-10-05 21:27:03 +0800 |
commit | 9a92cc103a4cb253f7c9c86a2195ed6c01361e2d (patch) | |
tree | da2fc6200f129fae6205e1655a07653a9b142c32 /widgets | |
parent | cc3e486ed62270d66522dfc0c9d325dd95364b7d (diff) | |
download | gsoc2013-evolution-9a92cc103a4cb253f7c9c86a2195ed6c01361e2d.tar gsoc2013-evolution-9a92cc103a4cb253f7c9c86a2195ed6c01361e2d.tar.gz gsoc2013-evolution-9a92cc103a4cb253f7c9c86a2195ed6c01361e2d.tar.bz2 gsoc2013-evolution-9a92cc103a4cb253f7c9c86a2195ed6c01361e2d.tar.lz gsoc2013-evolution-9a92cc103a4cb253f7c9c86a2195ed6c01361e2d.tar.xz gsoc2013-evolution-9a92cc103a4cb253f7c9c86a2195ed6c01361e2d.tar.zst gsoc2013-evolution-9a92cc103a4cb253f7c9c86a2195ed6c01361e2d.zip |
Adapted height method to deal with a row of -1.
2001-10-05 Christopher James Lahey <clahey@ximian.com>
* e-cell-text, e-cell-pixbuf: Adapted height method to deal with a
row of -1.
* e-table-group-container.c, e-table-group-container.h,
e-table-group-leaf.c, e-table-group-leaf.h, e-table-item.c,
e-table-item.h, e-table.c, e-table.h, e-tree.c: Added
"uniform_row_height" argument.
svn path=/trunk/; revision=13440
Diffstat (limited to 'widgets')
-rw-r--r-- | widgets/table/e-cell-pixbuf.c | 7 | ||||
-rw-r--r-- | widgets/table/e-cell-text.c | 10 | ||||
-rw-r--r-- | widgets/table/e-table-group-container.c | 19 | ||||
-rw-r--r-- | widgets/table/e-table-group-container.h | 1 | ||||
-rw-r--r-- | widgets/table/e-table-group-leaf.c | 16 | ||||
-rw-r--r-- | widgets/table/e-table-group-leaf.h | 1 | ||||
-rw-r--r-- | widgets/table/e-table-item.c | 232 | ||||
-rw-r--r-- | widgets/table/e-table-item.h | 3 | ||||
-rw-r--r-- | widgets/table/e-table.c | 18 | ||||
-rw-r--r-- | widgets/table/e-table.h | 2 | ||||
-rw-r--r-- | widgets/table/e-tree.c | 21 |
11 files changed, 234 insertions, 96 deletions
diff --git a/widgets/table/e-cell-pixbuf.c b/widgets/table/e-cell-pixbuf.c index f2764199bd..1db126142c 100644 --- a/widgets/table/e-cell-pixbuf.c +++ b/widgets/table/e-cell-pixbuf.c @@ -136,6 +136,13 @@ static gint pixbuf_height (ECellView *ecell_view, int model_col, int view_col, int row) { GdkPixbuf *pixbuf; + if (row == -1) { + if (e_table_model_row_count (ecell_view->e_table_model) > 0) { + row = 0; + } else { + return 6; + } + } pixbuf = (GdkPixbuf *) e_table_model_value_at (ecell_view->e_table_model, model_col, row); if (!pixbuf) diff --git a/widgets/table/e-cell-text.c b/widgets/table/e-cell-text.c index ded6e93c0d..0de114d2ab 100644 --- a/widgets/table/e-cell-text.c +++ b/widgets/table/e-cell-text.c @@ -926,9 +926,13 @@ ect_height (ECellView *ecell_view, int model_col, int view_col, int row) font = text_view->font; - string = ect_get_text(ect, ecell_view->e_table_model, model_col, row); - value = e_font_height (font) * number_of_lines(string) + TEXT_PAD; - ect_free_text(ect, string); + if (row == -1) { + value = e_font_height (font) + TEXT_PAD; + } else { + string = ect_get_text(ect, ecell_view->e_table_model, model_col, row); + value = e_font_height (font) * number_of_lines(string) + TEXT_PAD; + ect_free_text(ect, string); + } return value; } diff --git a/widgets/table/e-table-group-container.c b/widgets/table/e-table-group-container.c index 8eca550d6b..f18ba25e69 100644 --- a/widgets/table/e-table-group-container.c +++ b/widgets/table/e-table-group-container.c @@ -44,6 +44,7 @@ enum { ARG_CURSOR_MODE, ARG_SELECTION_MODEL, ARG_LENGTH_THRESHOLD, + ARG_UNIFORM_ROW_HEIGHT, }; typedef struct { @@ -438,6 +439,7 @@ create_child_node (ETableGroupContainer *etgc, void *val) "cursor_mode", etgc->cursor_mode, "selection_model", etgc->selection_model, "length_threshold", etgc->length_threshold, + "uniform_row_height", etgc->uniform_row_height, "minimum_width", etgc->minimum_width - GROUP_INDENT, NULL); @@ -756,6 +758,15 @@ etgc_set_arg (GtkObject *object, GtkArg *arg, guint arg_id) NULL); } break; + case ARG_UNIFORM_ROW_HEIGHT: + etgc->uniform_row_height = GTK_VALUE_BOOL (*arg); + for (list = etgc->children; list; list = g_list_next (list)) { + ETableGroupContainerChildNode *child_node = (ETableGroupContainerChildNode *)list->data; + gtk_object_set (GTK_OBJECT(child_node->child), + "uniform_row_height", GTK_VALUE_BOOL (*arg), + NULL); + } + break; case ARG_SELECTION_MODEL: if (etgc->selection_model) @@ -842,7 +853,10 @@ etgc_get_arg (GtkObject *object, GtkArg *arg, guint arg_id) GTK_VALUE_DOUBLE (*arg) = etgc->width; break; case ARG_MINIMUM_WIDTH: - etgc->minimum_width = GTK_VALUE_DOUBLE(*arg); + GTK_VALUE_DOUBLE(*arg) = etgc->minimum_width; + break; + case ARG_UNIFORM_ROW_HEIGHT: + GTK_VALUE_BOOL(*arg) = etgc->uniform_row_height; break; default: arg->type = GTK_TYPE_INVALID; @@ -893,6 +907,8 @@ etgc_class_init (GtkObjectClass *object_class) GTK_ARG_WRITABLE, ARG_SELECTION_MODEL); gtk_object_add_arg_type ("ETableGroupContainer::length_threshold", GTK_TYPE_INT, GTK_ARG_WRITABLE, ARG_LENGTH_THRESHOLD); + gtk_object_add_arg_type ("ETableGroupContainer::uniform_row_height", GTK_TYPE_BOOL, + GTK_ARG_READWRITE, ARG_UNIFORM_ROW_HEIGHT); gtk_object_add_arg_type ("ETableGroupContainer::frozen", GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_FROZEN); @@ -1000,6 +1016,7 @@ etgc_init (GtkObject *object) container->cursor_mode = E_CURSOR_SIMPLE; container->length_threshold = -1; container->selection_model = NULL; + container->uniform_row_height = FALSE; } E_MAKE_TYPE (e_table_group_container, "ETableGroupContainer", ETableGroupContainer, etgc_class_init, etgc_init, PARENT_TYPE); diff --git a/widgets/table/e-table-group-container.h b/widgets/table/e-table-group-container.h index d7e314d517..e65f60fc6a 100644 --- a/widgets/table/e-table-group-container.h +++ b/widgets/table/e-table-group-container.h @@ -49,6 +49,7 @@ typedef struct { guint horizontal_draw_grid : 1; guint vertical_draw_grid : 1; guint draw_focus : 1; + guint uniform_row_height : 1; ECursorMode cursor_mode; /* diff --git a/widgets/table/e-table-group-leaf.c b/widgets/table/e-table-group-leaf.c index c721b7d49a..f2b46c91ab 100644 --- a/widgets/table/e-table-group-leaf.c +++ b/widgets/table/e-table-group-leaf.c @@ -36,6 +36,7 @@ enum { ARG_CURSOR_MODE, ARG_LENGTH_THRESHOLD, ARG_SELECTION_MODEL, + ARG_UNIFORM_ROW_HEIGHT, }; static void etgl_set_arg (GtkObject *object, GtkArg *arg, guint arg_id); @@ -251,6 +252,7 @@ etgl_realize (GnomeCanvasItem *item) "minimum_width", etgl->minimum_width, "length_threshold", etgl->length_threshold, "selection_model", etgl->selection_model, + "uniform_row_height", etgl->uniform_row_height, NULL)); etgl->etgl_cursor_change_id = gtk_signal_connect (GTK_OBJECT(etgl->item), @@ -443,6 +445,15 @@ etgl_set_arg (GtkObject *object, GtkArg *arg, guint arg_id) } break; + case ARG_UNIFORM_ROW_HEIGHT: + etgl->uniform_row_height = GTK_VALUE_BOOL (*arg); + if (etgl->item) { + gnome_canvas_item_set (GNOME_CANVAS_ITEM(etgl->item), + "uniform_row_height", etgl->uniform_row_height, + NULL); + } + break; + case ARG_TABLE_ALTERNATING_ROW_COLORS: etgl->alternating_row_colors = GTK_VALUE_BOOL (*arg); if (etgl->item) { @@ -511,6 +522,8 @@ etgl_get_arg (GtkObject *object, GtkArg *arg, guint arg_id) case ARG_MINIMUM_WIDTH: GTK_VALUE_DOUBLE (*arg) = etgl->minimum_width; break; + case ARG_UNIFORM_ROW_HEIGHT: + GTK_VALUE_BOOL (*arg) = etgl->uniform_row_height; default: arg->type = GTK_TYPE_INVALID; break; @@ -567,6 +580,8 @@ etgl_class_init (GtkObjectClass *object_class) GTK_ARG_READWRITE, ARG_MINIMUM_WIDTH); gtk_object_add_arg_type ("ETableGroupLeaf::frozen", GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_FROZEN); + gtk_object_add_arg_type ("ETableGroupLeaf::uniform_row_height", GTK_TYPE_BOOL, + GTK_ARG_READWRITE, ARG_UNIFORM_ROW_HEIGHT); } static void @@ -597,6 +612,7 @@ etgl_init (GtkObject *object) etgl->length_threshold = -1; etgl->selection_model = NULL; + etgl->uniform_row_height = FALSE; e_canvas_item_set_reflow_callback (GNOME_CANVAS_ITEM(object), etgl_reflow); } diff --git a/widgets/table/e-table-group-leaf.h b/widgets/table/e-table-group-leaf.h index e7ba841493..3a092b3092 100644 --- a/widgets/table/e-table-group-leaf.h +++ b/widgets/table/e-table-group-leaf.h @@ -36,6 +36,7 @@ typedef struct { guint horizontal_draw_grid : 1; guint vertical_draw_grid : 1; guint draw_focus : 1; + guint uniform_row_height : 1; ECursorMode cursor_mode; int etgl_cursor_change_id; diff --git a/widgets/table/e-table-item.c b/widgets/table/e-table-item.c index c4b23b83ca..162dd3aede 100644 --- a/widgets/table/e-table-item.c +++ b/widgets/table/e-table-item.c @@ -67,6 +67,7 @@ enum { ARG_CURSOR_MODE, ARG_LENGTH_THRESHOLD, ARG_CURSOR_ROW, + ARG_UNIFORM_ROW_HEIGHT, ARG_MINIMUM_WIDTH, ARG_WIDTH, @@ -84,7 +85,9 @@ static void eti_cursor_change (ESelectionModel *selection, int row, int col, ETa static void eti_cursor_activated (ESelectionModel *selection, int row, int col, ETableItem *eti); static void eti_selection_change (ESelectionModel *selection, ETableItem *eti); -#define ETI_ROW_HEIGHT(eti,row) ((eti)->height_cache && (eti)->height_cache[(row)] != -1 ? (eti)->height_cache[(row)] : eti_row_height((eti),(row))) +#define ETI_SINGLE_ROW_HEIGHT(eti) ((eti)->uniform_row_height_cache != -1 ? (eti)->uniform_row_height_cache : eti_row_height((eti), -1)) +#define ETI_MULTIPLE_ROW_HEIGHT(eti,row) ((eti)->height_cache && (eti)->height_cache[(row)] != -1 ? (eti)->height_cache[(row)] : eti_row_height((eti),(row))) +#define ETI_ROW_HEIGHT(eti,row) ((eti)->uniform_row_height ? ETI_SINGLE_ROW_HEIGHT ((eti)) : ETI_MULTIPLE_ROW_HEIGHT((eti),(row))) inline static gint model_to_view_row(ETableItem *eti, int row) @@ -497,7 +500,7 @@ confirm_height_cache (ETableItem *eti) { int i; - if (eti->height_cache) + if (eti->uniform_row_height || eti->height_cache) return; eti->height_cache = g_new(int, eti->rows); for (i = 0; i < eti->rows; i++) { @@ -534,8 +537,14 @@ free_height_cache (ETableItem *eti) g_free (eti->height_cache); eti->height_cache = NULL; eti->height_cache_idle_count = 0; - - if (eti->height_cache_idle_id == 0) + eti->uniform_row_height_cache = -1; + + if (eti->uniform_row_height && eti->height_cache_idle_id != 0) { + g_source_remove(eti->height_cache_idle_id); + eti->height_cache_idle_id = 0; + } + + if ((!eti->uniform_row_height) && eti->height_cache_idle_id == 0) eti->height_cache_idle_id = g_idle_add_full(G_PRIORITY_LOW, (GSourceFunc) height_cache_idle, eti, NULL); } @@ -556,20 +565,25 @@ calculate_height_cache (ETableItem *eti) static int eti_row_height (ETableItem *eti, int row) { - if (!eti->height_cache) { - calculate_height_cache (eti); - } - if (eti->height_cache[row] == -1) { - eti->height_cache[row] = eti_row_height_real(eti, row); - if (row > 0 && - eti->length_threshold != -1 && - eti->rows > eti->length_threshold && - eti->height_cache[row] != eti_row_height(eti, 0)) { - eti->needs_compute_height = 1; - e_canvas_item_request_reflow(GNOME_CANVAS_ITEM(eti)); + if (eti->uniform_row_height) { + eti->uniform_row_height_cache = eti_row_height_real (eti, -1); + return eti->uniform_row_height_cache; + } else { + if (!eti->height_cache) { + calculate_height_cache (eti); } + if (eti->height_cache[row] == -1) { + eti->height_cache[row] = eti_row_height_real(eti, row); + if (row > 0 && + eti->length_threshold != -1 && + eti->rows > eti->length_threshold && + eti->height_cache[row] != eti_row_height(eti, 0)) { + eti->needs_compute_height = 1; + e_canvas_item_request_reflow(GNOME_CANVAS_ITEM(eti)); + } + } + return eti->height_cache[row]; } - return eti->height_cache[row]; } /* @@ -588,41 +602,46 @@ static int eti_get_height (ETableItem *eti) { const int rows = eti->rows; - int row; - int height; int height_extra = eti->horizontal_draw_grid ? 1 : 0; if (rows == 0) return 0; - if (eti->length_threshold != -1){ - if (rows > eti->length_threshold){ - int row_height = eti_row_height(eti, 0); - if (eti->height_cache) { - height = 0; - for (row = 0; row < rows; row++) { - if (eti->height_cache[row] == -1) { - height += (row_height + height_extra) * (rows - row); - break; + if (eti->uniform_row_height) { + int row_height = eti_row_height(eti, -1); + return ((row_height + height_extra) * rows + height_extra); + } else { + int height; + int row; + if (eti->length_threshold != -1){ + if (rows > eti->length_threshold){ + int row_height = eti_row_height(eti, 0); + if (eti->height_cache) { + height = 0; + for (row = 0; row < rows; row++) { + if (eti->height_cache[row] == -1) { + height += (row_height + height_extra) * (rows - row); + break; + } + else + height += eti->height_cache[row] + height_extra; } - else - height += eti->height_cache[row] + height_extra; - } - } else - height = (eti_row_height (eti, 0) + height_extra) * rows; + } else + height = (eti_row_height (eti, 0) + height_extra) * rows; - /* - * 1 pixel at the top - */ - return height + height_extra; + /* + * 1 pixel at the top + */ + return height + height_extra; + } } - } - height = height_extra; - for (row = 0; row < rows; row++) - height += eti_row_height (eti, row) + height_extra; + height = height_extra; + for (row = 0; row < rows; row++) + height += eti_row_height (eti, row) + height_extra; - return height; + return height; + } } static void @@ -649,19 +668,23 @@ eti_item_region_redraw (ETableItem *eti, int x0, int y0, int x1, int y1) int e_table_item_row_diff (ETableItem *eti, int start_row, int end_row) { - int row, total; int height_extra = eti->horizontal_draw_grid ? 1 : 0; - total = 0; if (start_row < 0) start_row = 0; if (end_row > eti->rows) end_row = eti->rows; - for (row = start_row; row < end_row; row++) - total += eti_row_height (eti, row) + height_extra; + if (eti->uniform_row_height) { + return ((end_row - start_row) * (eti_row_height(eti, -1) + height_extra)); + } else { + int row, total; + total = 0; + for (row = start_row; row < end_row; row++) + total += eti_row_height (eti, row) + height_extra; - return total; + return total; + } } static void @@ -871,9 +894,10 @@ eti_table_model_row_changed (ETableModel *table_model, int row, ETableItem *eti) { if (!(GTK_OBJECT_FLAGS(eti) & GNOME_CANVAS_ITEM_REALIZED)) return; - if (eti->renderers_can_change_size && - eti->height_cache && eti->height_cache[row] != -1 && - eti_row_height_real(eti, row) != eti->height_cache[row]) { + if (eti->uniform_row_height) + return; + + if (eti->height_cache && eti->height_cache[row] != -1 && eti_row_height_real(eti, row) != eti->height_cache[row]) { eti_table_model_changed (table_model, eti); return; } @@ -886,9 +910,9 @@ eti_table_model_cell_changed (ETableModel *table_model, int col, int row, ETable { if (!(GTK_OBJECT_FLAGS(eti) & GNOME_CANVAS_ITEM_REALIZED)) return; - if (eti->renderers_can_change_size && - eti->height_cache && eti->height_cache[row] != -1 && - eti_row_height_real(eti, row) != eti->height_cache[row]) { + if (eti->uniform_row_height) + return; + if (eti->height_cache && eti->height_cache[row] != -1 && eti_row_height_real(eti, row) != eti->height_cache[row]) { eti_table_model_changed (table_model, eti); return; } @@ -1135,8 +1159,10 @@ eti_destroy (GtkObject *object) eti_remove_table_model (eti); eti_remove_selection_model (eti); - if (eti->height_cache_idle_id) + if (eti->height_cache_idle_id) { g_source_remove(eti->height_cache_idle_id); + eti->height_cache_idle_id = 0; + } if (eti->height_cache) g_free (eti->height_cache); @@ -1225,6 +1251,14 @@ eti_set_arg (GtkObject *o, GtkArg *arg, guint arg_id) e_table_item_focus (eti, cursor_col != -1 ? cursor_col : 0, view_to_model_row(eti, GTK_VALUE_INT (*arg)), 0); break; + case ARG_UNIFORM_ROW_HEIGHT: + eti->uniform_row_height = GTK_VALUE_BOOL (*arg); + free_height_cache(eti); + eti->needs_compute_height = 1; + e_canvas_item_request_reflow (GNOME_CANVAS_ITEM (eti)); + eti->needs_redraw = 1; + gnome_canvas_item_request_update (GNOME_CANVAS_ITEM (eti)); + break; } eti->needs_redraw = 1; gnome_canvas_item_request_update (GNOME_CANVAS_ITEM(eti)); @@ -1256,8 +1290,12 @@ eti_get_arg (GtkObject *o, GtkArg *arg, guint arg_id) NULL); GTK_VALUE_INT (*arg) = model_to_view_row(eti, row); break; + case ARG_UNIFORM_ROW_HEIGHT: + GTK_VALUE_BOOL (*arg) = eti->uniform_row_height; + break; default: arg->type = GTK_TYPE_INVALID; + break; } } @@ -1279,7 +1317,7 @@ eti_init (GnomeCanvasItem *item) eti->height_cache_idle_count = 0; eti->length_threshold = -1; - eti->renderers_can_change_size = 1; + eti->uniform_row_height = FALSE; eti->uses_source_model = 0; eti->source_model = NULL; @@ -1438,7 +1476,7 @@ eti_draw (GnomeCanvasItem *item, GdkDrawable *drawable, int x, int y, int width, ETableItem *eti = E_TABLE_ITEM (item); const int rows = eti->rows; const int cols = eti->cols; - int row, col, y1, y2; + int row, col; int first_col, last_col, x_offset; int first_row, last_row, y_offset, yd; int x1, x2; @@ -1492,28 +1530,43 @@ eti_draw (GnomeCanvasItem *item, GdkDrawable *drawable, int x, int y, int width, /* * Compute row span. */ - first_row = -1; - y_offset = 0; - y1 = y2 = floor (eti_base.y) + height_extra; - for (row = 0; row < rows; row++, y1 = y2){ + if (eti->uniform_row_height) { + first_row = (y - floor (eti_base.y) - height_extra) / (eti_row_height (eti, -1) + height_extra); + last_row = (y + height - floor (eti_base.y) ) / (eti_row_height (eti, -1) + height_extra) + 1; + if (first_row > last_row) + return; + y_offset = floor (eti_base.y) - y + height_extra + first_row * (eti_row_height (eti, -1) + height_extra); + if (first_row < 0) + first_row = 0; + if (last_row > eti->rows) + last_row = eti->rows; + } else { + int y1, y2; - y2 += ETI_ROW_HEIGHT (eti, row) + height_extra; + y_offset = 0; + first_row = -1; - if (y1 > y + height) - break; + y1 = y2 = floor (eti_base.y) + height_extra; + for (row = 0; row < rows; row++, y1 = y2){ - if (y2 < y) - continue; + y2 += ETI_ROW_HEIGHT (eti, row) + height_extra; + + if (y1 > y + height) + break; + + if (y2 < y) + continue; - if (first_row == -1){ - y_offset = y1 - y; - first_row = row; + if (first_row == -1){ + y_offset = y1 - y; + first_row = row; + } } - } - last_row = row; + last_row = row; - if (first_row == -1) - return; + if (first_row == -1) + return; + } /* * Draw cells @@ -1708,15 +1761,23 @@ find_cell (ETableItem *eti, double x, double y, int *view_col_res, int *view_row break; } - y1 = y2 = 0; - for (row = 0; row < rows - 1; row++, y1 = y2){ - if (y < y1) + if (eti->uniform_row_height) { + if (y < height_extra) return FALSE; - - y2 += ETI_ROW_HEIGHT (eti, row) + height_extra; + row = (y - height_extra) / (eti_row_height (eti, -1) + height_extra); + y1 = row * (eti_row_height (eti, -1) + height_extra) + height_extra; + if (row >= eti->rows) + return FALSE; + } else { + y1 = y2 = height_extra; + if (y < height_extra) + return FALSE; + for (row = 0; row < rows - 1; row++, y1 = y2){ + y2 += ETI_ROW_HEIGHT (eti, row) + height_extra; - if (y <= y2) - break; + if (y <= y2) + break; + } } *view_col_res = col; if (x1_res) @@ -1763,9 +1824,6 @@ static int _do_tooltip (ETableItem *eti) { ECellView *ecell_view; - int x = 0, y = 0; - int i; - int height_extra = eti->horizontal_draw_grid ? 1 : 0; gboolean free_color; ETableCol *ecol; gboolean selected; @@ -1778,14 +1836,10 @@ _do_tooltip (ETableItem *eti) ecell_view = eti->cell_views[eti->tooltip->col]; - for (i = 0; i < eti->tooltip->col; i++) - x += eti->header->columns[i]->width; - eti->tooltip->x = x; + eti->tooltip->x = e_table_header_col_diff (eti->header, 0, eti->tooltip->col); - for (i = 0; i < eti->tooltip->row; i++) - y += (ETI_ROW_HEIGHT (eti, i) + height_extra); - eti->tooltip->y = y; - eti->tooltip->row_height = ETI_ROW_HEIGHT (eti, i); + eti->tooltip->y = e_table_item_row_diff (eti, 0, eti->tooltip->row); + eti->tooltip->row_height = ETI_ROW_HEIGHT (eti, eti->tooltip->row); selected = e_selection_model_is_row_selected(E_SELECTION_MODEL (eti->selection), view_to_model_row(eti,eti->tooltip->row)); @@ -2429,6 +2483,8 @@ eti_class_init (GtkObjectClass *object_class) GTK_ARG_READABLE, ARG_HEIGHT); gtk_object_add_arg_type ("ETableItem::cursor_row", GTK_TYPE_INT, GTK_ARG_READWRITE, ARG_CURSOR_ROW); + gtk_object_add_arg_type ("ETableItem::uniform_row_height", GTK_TYPE_BOOL, + GTK_ARG_READWRITE, ARG_UNIFORM_ROW_HEIGHT); eti_signals [CURSOR_CHANGE] = gtk_signal_new ("cursor_change", diff --git a/widgets/table/e-table-item.h b/widgets/table/e-table-item.h index 2e91473947..228f104ad8 100644 --- a/widgets/table/e-table-item.h +++ b/widgets/table/e-table-item.h @@ -64,7 +64,7 @@ typedef struct { guint horizontal_draw_grid:1; guint vertical_draw_grid:1; guint draw_focus:1; - guint renderers_can_change_size:1; + guint uniform_row_height:1; guint cell_views_realized:1; guint needs_redraw : 1; @@ -101,6 +101,7 @@ typedef struct { int n_cells; int *height_cache; + int uniform_row_height_cache; int height_cache_idle_id; int height_cache_idle_count; diff --git a/widgets/table/e-table.c b/widgets/table/e-table.c index 19393a4d85..9f250da2c2 100644 --- a/widgets/table/e-table.c +++ b/widgets/table/e-table.c @@ -70,6 +70,7 @@ enum { ARG_0, ARG_LENGTH_THRESHOLD, ARG_MODEL, + ARG_UNIFORM_ROW_HEIGHT, }; static gint et_signals [LAST_SIGNAL] = { 0, }; @@ -219,6 +220,7 @@ e_table_init (GtkObject *object) e_table->draw_focus = 1; e_table->cursor_mode = E_CURSOR_SIMPLE; e_table->length_threshold = 200; + e_table->uniform_row_height = FALSE; e_table->need_rebuild = 0; e_table->rebuild_idle_id = 0; @@ -618,6 +620,7 @@ et_build_groups (ETable *et) "drawfocus", et->draw_focus, "cursor_mode", et->cursor_mode, "length_threshold", et->length_threshold, + "uniform_row_height", et->uniform_row_height, "selection_model", et->selection, NULL); @@ -1423,7 +1426,9 @@ et_get_arg (GtkObject *o, GtkArg *arg, guint arg_id) case ARG_MODEL: GTK_VALUE_OBJECT (*arg) = (GtkObject *) etable->model; break; - + case ARG_UNIFORM_ROW_HEIGHT: + GTK_VALUE_BOOL (*arg) = etable->uniform_row_height; + break; default: break; } @@ -1448,7 +1453,14 @@ et_set_arg (GtkObject *o, GtkArg *arg, guint arg_id) NULL); } break; - + case ARG_UNIFORM_ROW_HEIGHT: + etable->uniform_row_height = GTK_VALUE_BOOL (*arg); + if (etable->group) { + gnome_canvas_item_set (GNOME_CANVAS_ITEM(etable->group), + "uniform_row_height", GTK_VALUE_BOOL (*arg), + NULL); + } + break; } } @@ -2417,6 +2429,8 @@ e_table_class_init (ETableClass *class) gtk_object_add_arg_type ("ETable::length_threshold", GTK_TYPE_INT, GTK_ARG_WRITABLE, ARG_LENGTH_THRESHOLD); + gtk_object_add_arg_type ("ETable::uniform_row_height", GTK_TYPE_BOOL, + GTK_ARG_READWRITE, ARG_UNIFORM_ROW_HEIGHT); gtk_object_add_arg_type ("ETable::model", E_TABLE_MODEL_TYPE, GTK_ARG_READABLE, ARG_MODEL); } diff --git a/widgets/table/e-table.h b/widgets/table/e-table.h index be2942a751..03539ebc65 100644 --- a/widgets/table/e-table.h +++ b/widgets/table/e-table.h @@ -87,6 +87,8 @@ typedef struct { guint scroll_down : 1; guint do_drag : 1; + + guint uniform_row_height : 1; char *click_to_add_message; GnomeCanvasItem *click_to_add; diff --git a/widgets/table/e-tree.c b/widgets/table/e-tree.c index abb5bdcec8..acd841d085 100644 --- a/widgets/table/e-tree.c +++ b/widgets/table/e-tree.c @@ -74,7 +74,8 @@ enum { ARG_HORIZONTAL_DRAW_GRID, ARG_VERTICAL_DRAW_GRID, ARG_DRAW_FOCUS, - ARG_ETTA + ARG_ETTA, + ARG_UNIFORM_ROW_HEIGHT, }; struct ETreePriv { @@ -124,6 +125,8 @@ struct ETreePriv { guint do_drag : 1; + guint uniform_row_height : 1; + ECursorMode cursor_mode; int drop_row; @@ -295,6 +298,7 @@ e_tree_init (GtkObject *object) e_tree->priv->draw_focus = 1; e_tree->priv->cursor_mode = E_CURSOR_SIMPLE; e_tree->priv->length_threshold = 200; + e_tree->priv->uniform_row_height = FALSE; e_tree->priv->row_selection_active = FALSE; e_tree->priv->horizontal_scrolling = FALSE; @@ -652,6 +656,7 @@ et_build_item (ETree *et) "drawfocus", et->priv->draw_focus, "cursor_mode", et->priv->cursor_mode, "length_threshold", et->priv->length_threshold, + "uniform_row_height", et->priv->uniform_row_height, NULL); gtk_signal_connect (GTK_OBJECT (et->priv->item), "cursor_change", @@ -1284,6 +1289,9 @@ et_get_arg (GtkObject *o, GtkArg *arg, guint arg_id) GTK_VALUE_OBJECT (*arg) = GTK_OBJECT (etree->priv->etta); } break; + case ARG_UNIFORM_ROW_HEIGHT: + GTK_VALUE_BOOL (*arg) = etree->priv->uniform_row_height; + break; default: break; @@ -1336,6 +1344,15 @@ et_set_arg (GtkObject *o, GtkArg *arg, guint arg_id) NULL); } break; + + case ARG_UNIFORM_ROW_HEIGHT: + etree->priv->uniform_row_height = GTK_VALUE_BOOL (*arg); + if (etree->priv->item) { + gnome_canvas_item_set (GNOME_CANVAS_ITEM(etree->priv->item), + "uniform_row_height", GTK_VALUE_BOOL (*arg), + NULL); + } + break; } } @@ -2584,6 +2601,8 @@ e_tree_class_init (ETreeClass *class) GTK_ARG_WRITABLE, ARG_DRAW_FOCUS); gtk_object_add_arg_type ("ETree::ETreeTableAdapter", GTK_TYPE_OBJECT, GTK_ARG_READABLE, ARG_ETTA); + gtk_object_add_arg_type ("ETree::uniform_row_height", GTK_TYPE_BOOL, + GTK_ARG_READWRITE, ARG_UNIFORM_ROW_HEIGHT); } E_MAKE_TYPE(e_tree, "ETree", ETree, e_tree_class_init, e_tree_init, PARENT_TYPE); |