diff options
author | Arturo Espinosa <unammx@src.gnome.org> | 1998-01-27 23:40:51 +0000 |
---|---|---|
committer | Arturo Espinosa <unammx@src.gnome.org> | 1998-01-27 23:40:51 +0000 |
commit | 4cb6dec331641c742135dbf8d74c23825f07fee8 (patch) | |
tree | a62a972c5889bcaac14a453d107690e8613dc471 /gtk/gtktable.c | |
parent | d43c0de3f412bb8597799d9c85728595880356c3 (diff) | |
download | gtk+-4cb6dec331641c742135dbf8d74c23825f07fee8.tar.gz |
Tables autoresize now -miguel
Diffstat (limited to 'gtk/gtktable.c')
-rw-r--r-- | gtk/gtktable.c | 93 |
1 files changed, 69 insertions, 24 deletions
diff --git a/gtk/gtktable.c b/gtk/gtktable.c index 623c2c210e..7b4f7ac815 100644 --- a/gtk/gtktable.c +++ b/gtk/gtktable.c @@ -116,48 +116,86 @@ gtk_table_init (GtkTable *table) table->homogeneous = FALSE; } -GtkWidget* -gtk_table_new (gint rows, - gint columns, - gint homogeneous) +static void +gtk_table_init_rows (GtkTable *table, int start, int end) { - GtkTable *table; - gint row, col; - - table = gtk_type_new (gtk_table_get_type ()); - - table->nrows = rows; - table->ncols = columns; - table->homogeneous = (homogeneous ? TRUE : FALSE); + const int spacing = table->row_spacing; + int row; - table->rows = g_new (GtkTableRowCol, table->nrows); - table->cols = g_new (GtkTableRowCol, table->ncols); - - for (row = 0; row < table->nrows; row++) + for (row = start; row < end; row++) { table->rows[row].requisition = 0; table->rows[row].allocation = 0; - table->rows[row].spacing = 0; + table->rows[row].spacing = spacing; table->rows[row].need_expand = 0; table->rows[row].need_shrink = 0; table->rows[row].expand = 0; table->rows[row].shrink = 0; } +} - for (col = 0; col < table->ncols; col++) +static void +gtk_table_init_cols (GtkTable *table, int start, int end) +{ + const int spacing = table->column_spacing; + int col; + + for (col = start; col < end; col++) { table->cols[col].requisition = 0; table->cols[col].allocation = 0; - table->cols[col].spacing = 0; + table->cols[col].spacing = spacing; table->cols[col].need_expand = 0; table->cols[col].need_shrink = 0; table->cols[col].expand = 0; table->cols[col].shrink = 0; } +} + +GtkWidget* +gtk_table_new (gint rows, + gint columns, + gint homogeneous) +{ + GtkTable *table; + + table = gtk_type_new (gtk_table_get_type ()); + + table->nrows = rows; + table->ncols = columns; + table->homogeneous = (homogeneous ? TRUE : FALSE); + table->column_spacing = 0; + table->row_spacing = 0; + + table->rows = g_new (GtkTableRowCol, table->nrows); + table->cols = g_new (GtkTableRowCol, table->ncols); + + gtk_table_init_rows (table, 0, table->nrows); + gtk_table_init_cols (table, 0, table->ncols); return GTK_WIDGET (table); } +static void +gtk_table_expand_cols (GtkTable *table, int new_max) +{ + int i; + + table->cols = g_realloc (table->cols, new_max * sizeof (GtkTableRowCol)); + gtk_table_init_cols (table, table->ncols, new_max); + table->ncols = new_max; +} + +static void +gtk_table_expand_rows (GtkTable *table, int new_max) +{ + int i; + + table->rows = g_realloc (table->rows, new_max * sizeof (GtkTableRowCol)); + gtk_table_init_rows (table, table->nrows, new_max); + table->nrows = new_max; +} + void gtk_table_attach (GtkTable *table, GtkWidget *child, @@ -171,15 +209,22 @@ gtk_table_attach (GtkTable *table, gint ypadding) { GtkTableChild *table_child; - + int resize = 0; + g_return_if_fail (table != NULL); g_return_if_fail (GTK_IS_TABLE (table)); g_return_if_fail (child != NULL); - g_return_if_fail ((left_attach >= 0) && (left_attach < table->ncols)); - g_return_if_fail ((left_attach < right_attach) && (right_attach <= table->ncols)); - g_return_if_fail ((top_attach >= 0) && (top_attach < table->nrows)); - g_return_if_fail ((top_attach < bottom_attach) && (bottom_attach <= table->nrows)); + g_return_if_fail (left_attach >= 0); + g_return_if_fail (left_attach < right_attach); + g_return_if_fail (top_attach >= 0); + g_return_if_fail (top_attach < bottom_attach); + + if (right_attach >= table->ncols) + gtk_table_expand_cols (table, right_attach); + + if (bottom_attach >= table->nrows) + gtk_table_expand_rows (table, bottom_attach); table_child = g_new (GtkTableChild, 1); table_child->widget = child; |