diff options
author | Christopher James Lahey <clahey@helixcode.com> | 2000-05-14 22:31:22 +0800 |
---|---|---|
committer | Chris Lahey <clahey@src.gnome.org> | 2000-05-14 22:31:22 +0800 |
commit | 32471accadcf2099f9d3567f51add9fab197ec24 (patch) | |
tree | 8b070bcbdbcd962de9016b0fceaa15ec45848310 /widgets/table/e-table-item.c | |
parent | 623ba9a279db035339ac8ae5030683c1e79b8618 (diff) | |
download | gsoc2013-evolution-32471accadcf2099f9d3567f51add9fab197ec24.tar.gz gsoc2013-evolution-32471accadcf2099f9d3567f51add9fab197ec24.tar.zst gsoc2013-evolution-32471accadcf2099f9d3567f51add9fab197ec24.zip |
From widgets/e-table/ChangeLog
2000-05-14 Christopher James Lahey <clahey@helixcode.com>
* Implemented the feature where the ETable columns automatically
fill the given space.
* e-cell-text.c, e-cell-text.h: Moved #include
e-text-event-processor.h from the .h to the .c.
* e-table-col.c, e-table-col.h: Added an expansion variable, and
made it so that width isn't set by the programmer but instead by
the e-table-header.
* e-table-example-1.c, e-table-example-2.c, e-table-size-test.c,
test-check.c, test-cols.c, test-table.c: Fixed to handle new
ETable column resizing.
* e-table-group-container.c, e-table-group-container.h,
e-table-group-leaf.c, e-table-group-leaf.h, e-table-group.c,
e-table-group.h, e-table-item.c, e-table-item.h: Fixed these to do
a proper canvas reflow/update loop. Changed them to take a
minimum width and return a width and a height.
* e-table-header-item.c, e-table-header-item.h: Made this so that
it depends on e-table-header.c for deciding the actual size of
columns during resize (it was making incorrect decisions on its
own.)
* e-table-header.c, e-table-header.h: Changed this to make sure
that the sum of the widths of the columns was always as close as
possible to the width of the window. This is done by taking a
full width and having each of the columns have an "expansion"
field. This field is what makes each column have approximately
the same portion of its part of the screen that it used to.
* e-table.c: Changed this to set the width on the ETableHeader as
well as set the proper minimum width on the ETableGroup and get
the width and height it reports.
From addressbook/ChangeLog
2000-05-14 Christopher James Lahey <clahey@helixcode.com>
* backend/ebook/Makefile.am: Added libeutil for e-card's support
for categories.
* backend/ebook/e-card-list.c, backend/ebook/e-card-list.h: Added
a function to get the length.
* backend/ebook/e-card.c, backend/ebook/e-card.h: Added categories
support (accessible either as "categories" or "category_list".)
* contact-editor/Makefile.am: Added e-table and all of the
categories files.
* contact-editor/categories.glade,
contact-editor/categories-strings.h,
contact-editor/e-contact-editor-categories.c,
contact-editor/e-contact-editor-categories.h:
* contact-editor/contact-editor.glade,
contact-editor/e-contact-editor-strings.h: Rearranged this dialog.
* contact-editor/e-contact-editor.c: Rearranged dialog a bit.
Added opening of categories dialog.
* gui/component/Makefile.am: Rearranged libraries so that
libetable would be available for the contact editor categories
dialog.
* gui/component/addressbook.c: Fix for new ETable resizing. Make
contact editor dialog resizable.
* gui/minicard/Makefile.am: Added libetable contact editor
categories dialog.
* gui/minicard/e-minicard.c: Make contact editor dialog resizable.
From mail/ChangeLog
2000-05-14 Christopher James Lahey <clahey@helixcode.com>
* message-list.c: Updated to work with new ETable resizing.
svn path=/trunk/; revision=3027
Diffstat (limited to 'widgets/table/e-table-item.c')
-rw-r--r-- | widgets/table/e-table-item.c | 104 |
1 files changed, 56 insertions, 48 deletions
diff --git a/widgets/table/e-table-item.c b/widgets/table/e-table-item.c index 13699e1d91..560cb4affe 100644 --- a/widgets/table/e-table-item.c +++ b/widgets/table/e-table-item.c @@ -42,12 +42,14 @@ enum { ARG_MODE_SPREADSHEET, ARG_LENGTH_THRESHOLD, + ARG_MINIMUM_WIDTH, ARG_WIDTH, ARG_HEIGHT, ARG_HAS_FOCUS, }; static int eti_get_height (ETableItem *eti); +static int eti_get_minimum_width (ETableItem *eti); static int eti_row_height (ETableItem *eti, int row); #define ETI_ROW_HEIGHT(eti,row) ((eti)->height_cache && (eti)->height_cache[(row)] != -1 ? (eti)->height_cache[(row)] : eti_row_height((eti),(row))) @@ -141,18 +143,10 @@ eti_bounds (GnomeCanvasItem *item, double *x1, double *y1, double *x2, double *y { double i2c [6]; ArtPoint c1, c2, i1, i2; - int col, width = 0; ETableItem *eti = E_TABLE_ITEM (item); /* Wrong BBox's are the source of redraw nightmares */ - for (col = 0; col < eti->cols; col++, x1 = x2){ - ETableCol *ecol = e_table_header_get_column (eti->header, col); - - width += ecol->width; - } - eti->width = width; - gnome_canvas_item_i2c_affine (GNOME_CANVAS_ITEM (eti), i2c); i1.x = eti->x1; @@ -184,6 +178,17 @@ eti_reflow (GnomeCanvasItem *item, gint flags) } eti->needs_compute_height = 0; } + if (eti->needs_compute_width) { + int new_width = eti_get_minimum_width (eti); + new_width = MAX(new_width, eti->minimum_width); + if (new_width != eti->width) { + eti->width = new_width; + e_canvas_item_request_parent_reflow (GNOME_CANVAS_ITEM (eti)); + eti->needs_redraw = 1; + gnome_canvas_item_request_update (GNOME_CANVAS_ITEM (eti)); + } + eti->needs_compute_width = 0; + } } /* @@ -363,7 +368,6 @@ calculate_height_cache (ETableItem *eti) static int eti_row_height (ETableItem *eti, int row) { -#if 1 if (!eti->height_cache) { calculate_height_cache (eti); } @@ -378,9 +382,6 @@ eti_row_height (ETableItem *eti, int row) } } return eti->height_cache[row]; -#else - return eti_row_height_real(eti, row); -#endif } /* @@ -435,6 +436,19 @@ eti_get_height (ETableItem *eti) return height; } +static int +eti_get_minimum_width (ETableItem *eti) +{ + int width = 0; + int col; + for (col = 0; col < eti->cols; col++){ + ETableCol *ecol = e_table_header_get_column (eti->header, col); + + width += ecol->min_width; + } + return width; +} + static void eti_item_region_redraw (ETableItem *eti, int x0, int y0, int x1, int y1) { @@ -472,20 +486,6 @@ eti_table_model_changed (ETableModel *table_model, ETableItem *eti) gnome_canvas_item_request_update (GNOME_CANVAS_ITEM (eti)); } -/* Unused. */ -#if 0 -/* - * eti_request_redraw: - * - * Queues a canvas redraw for the entire ETableItem. - */ -static void -eti_request_redraw (ETableItem *eti) -{ - eti_item_region_redraw (eti, eti->x1, eti->y1, eti->x1 + eti->width + 1, eti->y1 + eti->height + 1); -} -#endif - /* * Computes the distance between @start_row and @end_row in pixels */ @@ -624,8 +624,8 @@ eti_add_table_model (ETableItem *eti, ETableModel *table_model) static void eti_header_dim_changed (ETableHeader *eth, int col, ETableItem *eti) { - eti->needs_redraw = 1; - gnome_canvas_item_request_update (GNOME_CANVAS_ITEM (eti)); + eti->needs_compute_width = 1; + e_canvas_item_request_reflow (GNOME_CANVAS_ITEM (eti)); } static void @@ -650,8 +650,8 @@ eti_header_structure_changed (ETableHeader *eth, ETableItem *eti) eti_attach_cell_views (eti); } } - eti->needs_redraw = 1; - gnome_canvas_item_request_update (GNOME_CANVAS_ITEM (eti)); + eti->needs_compute_width = 1; + e_canvas_item_request_reflow (GNOME_CANVAS_ITEM (eti)); } static void @@ -728,7 +728,13 @@ eti_set_arg (GtkObject *o, GtkArg *arg, guint arg_id) case ARG_MODE_SPREADSHEET: eti->mode_spreadsheet = GTK_VALUE_BOOL (*arg); break; - + case ARG_MINIMUM_WIDTH: + if (eti->minimum_width == eti->width && GTK_VALUE_DOUBLE (*arg) > eti->width) + e_canvas_item_request_reflow (GNOME_CANVAS_ITEM (eti)); + eti->minimum_width = GTK_VALUE_DOUBLE (*arg); + if (eti->minimum_width < eti->width) + e_canvas_item_request_reflow (GNOME_CANVAS_ITEM (eti)); + break; } eti->needs_redraw = 1; gnome_canvas_item_request_update (GNOME_CANVAS_ITEM(eti)); @@ -750,6 +756,9 @@ eti_get_arg (GtkObject *o, GtkArg *arg, guint arg_id) case ARG_HEIGHT: GTK_VALUE_DOUBLE (*arg) = eti->height; break; + case ARG_MINIMUM_WIDTH: + GTK_VALUE_DOUBLE (*arg) = eti->minimum_width; + break; default: arg->type = GTK_TYPE_INVALID; } @@ -765,6 +774,8 @@ eti_init (GnomeCanvasItem *item) eti->editing_col = -1; eti->editing_row = -1; eti->height = 0; + eti->width = 0; + eti->minimum_width = 0; eti->height_cache = NULL; eti->height_cache_idle_id = 0; @@ -1042,7 +1053,7 @@ find_cell (ETableItem *eti, double x, double y, int *col_res, int *row_res, doub y -= eti->y1; x1 = 0; - for (col = 0; col < cols; col++, x1 = x2){ + for (col = 0; col < cols - 1; col++, x1 = x2){ ETableCol *ecol = e_table_header_get_column (eti->header, col); if (x < x1) @@ -1050,31 +1061,26 @@ find_cell (ETableItem *eti, double x, double y, int *col_res, int *row_res, doub x2 = x1 + ecol->width; - if (x > x2) - continue; - - *col_res = col; - if (x1_res) - *x1_res = x - x1; - break; + if (x <= x2) + break; } y1 = y2 = 0; - for (row = 0; row < rows; row++, y1 = y2){ + for (row = 0; row < rows - 1; row++, y1 = y2){ if (y < y1) return FALSE; y2 += ETI_ROW_HEIGHT (eti, row) + 1; - if (y > y2) - continue; - - *row_res = row; - if (y1_res) - *y1_res = y - y1; - break; + if (y <= y2) + break; } - + *col_res = col; + if (x1_res) + *x1_res = x - x1; + *row_res = row; + if (y1_res) + *y1_res = y - y1; return TRUE; } @@ -1324,6 +1330,8 @@ eti_class_init (GtkObjectClass *object_class) gtk_object_add_arg_type ("ETableItem::length_threshold", GTK_TYPE_INT, GTK_ARG_WRITABLE, ARG_LENGTH_THRESHOLD); + gtk_object_add_arg_type ("ETableItem::minimum_width", GTK_TYPE_DOUBLE, + GTK_ARG_READWRITE, ARG_MINIMUM_WIDTH); gtk_object_add_arg_type ("ETableItem::width", GTK_TYPE_DOUBLE, GTK_ARG_READWRITE, ARG_WIDTH); gtk_object_add_arg_type ("ETableItem::height", GTK_TYPE_DOUBLE, |