diff options
author | Tim Janik <timj@src.gnome.org> | 1998-06-16 05:20:05 +0000 |
---|---|---|
committer | Tim Janik <timj@src.gnome.org> | 1998-06-16 05:20:05 +0000 |
commit | 742d01908f754f9473e6a7993276c3aee060d1ec (patch) | |
tree | bfeef446f36bd92a51a6fa3ccd671ec706b0b9c4 /gtk/gtktable.c | |
parent | d36df18dee814c690fd5736729ea54175b3be628 (diff) | |
download | gtk+-742d01908f754f9473e6a7993276c3aee060d1ec.tar.gz |
boy! did i really modify that many files?
anyways, here go the child args and a lot of cleanups ;)
you wouldn't want me to put the ChangeLog entry in here, would you?
Diffstat (limited to 'gtk/gtktable.c')
-rw-r--r-- | gtk/gtktable.c | 1377 |
1 files changed, 823 insertions, 554 deletions
diff --git a/gtk/gtktable.c b/gtk/gtktable.c index f77e405ec3..8d7a64dd3c 100644 --- a/gtk/gtktable.c +++ b/gtk/gtktable.c @@ -8,7 +8,7 @@ * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public @@ -18,29 +18,68 @@ */ #include "gtktable.h" +enum +{ + ARG_0, + ARG_N_ROWS, + ARG_N_COLUMNS, + ARG_COLUMN_SPACING, + ARG_ROW_SPACING, + ARG_HOMOGENEOUS, +}; + +enum +{ + CHILD_ARG_0, + CHILD_ARG_LEFT_ATTACH, + CHILD_ARG_RIGHT_ATTACH, + CHILD_ARG_TOP_ATTACH, + CHILD_ARG_BOTTOM_ATTACH, + CHILD_ARG_X_OPTIONS, + CHILD_ARG_Y_OPTIONS, + CHILD_ARG_X_PADDING, + CHILD_ARG_Y_PADDING +}; + static void gtk_table_class_init (GtkTableClass *klass); -static void gtk_table_init (GtkTable *table); -static void gtk_table_finalize (GtkObject *object); -static void gtk_table_map (GtkWidget *widget); -static void gtk_table_unmap (GtkWidget *widget); -static void gtk_table_draw (GtkWidget *widget, +static void gtk_table_init (GtkTable *table); +static void gtk_table_finalize (GtkObject *object); +static void gtk_table_map (GtkWidget *widget); +static void gtk_table_unmap (GtkWidget *widget); +static void gtk_table_draw (GtkWidget *widget, GdkRectangle *area); -static gint gtk_table_expose (GtkWidget *widget, +static gint gtk_table_expose (GtkWidget *widget, GdkEventExpose *event); -static void gtk_table_size_request (GtkWidget *widget, +static void gtk_table_size_request (GtkWidget *widget, GtkRequisition *requisition); -static void gtk_table_size_allocate (GtkWidget *widget, +static void gtk_table_size_allocate (GtkWidget *widget, GtkAllocation *allocation); -static void gtk_table_add (GtkContainer *container, - GtkWidget *widget); -static void gtk_table_remove (GtkContainer *container, - GtkWidget *widget); -static void gtk_table_foreach (GtkContainer *container, +static void gtk_table_add (GtkContainer *container, + GtkWidget *widget); +static void gtk_table_remove (GtkContainer *container, + GtkWidget *widget); +static void gtk_table_foreach (GtkContainer *container, GtkCallback callback, - gpointer callback_data); - -static void gtk_table_size_request_init (GtkTable *table); + gpointer callback_data); +static void gtk_table_get_arg (GtkObject *object, + GtkArg *arg, + guint arg_id); +static void gtk_table_set_arg (GtkObject *object, + GtkArg *arg, + guint arg_id); +static void gtk_table_set_child_arg (GtkContainer *container, + GtkWidget *child, + GtkArg *arg, + guint arg_id); +static void gtk_table_get_child_arg (GtkContainer *container, + GtkWidget *child, + GtkArg *arg, + guint arg_id); +static GtkType gtk_table_child_type (GtkContainer *container); + + +static void gtk_table_size_request_init (GtkTable *table); static void gtk_table_size_request_pass1 (GtkTable *table); static void gtk_table_size_request_pass2 (GtkTable *table); static void gtk_table_size_request_pass3 (GtkTable *table); @@ -53,11 +92,11 @@ static void gtk_table_size_allocate_pass2 (GtkTable *table); static GtkContainerClass *parent_class = NULL; -guint +GtkType gtk_table_get_type (void) { - static guint table_type = 0; - + static GtkType table_type = 0; + if (!table_type) { GtkTypeInfo table_info = @@ -67,13 +106,13 @@ gtk_table_get_type (void) sizeof (GtkTableClass), (GtkClassInitFunc) gtk_table_class_init, (GtkObjectInitFunc) gtk_table_init, - (GtkArgSetFunc) NULL, - (GtkArgGetFunc) NULL, + gtk_table_set_arg, + gtk_table_get_arg, }; - + table_type = gtk_type_unique (gtk_container_get_type (), &table_info); } - + return table_type; } @@ -83,145 +122,371 @@ gtk_table_class_init (GtkTableClass *class) GtkObjectClass *object_class; GtkWidgetClass *widget_class; GtkContainerClass *container_class; - + object_class = (GtkObjectClass*) class; widget_class = (GtkWidgetClass*) class; container_class = (GtkContainerClass*) class; - + parent_class = gtk_type_class (gtk_container_get_type ()); + + gtk_object_add_arg_type ("GtkTable::n_rows", GTK_TYPE_UINT, GTK_ARG_READWRITE, ARG_N_ROWS); + gtk_object_add_arg_type ("GtkTable::n_columns", GTK_TYPE_UINT, GTK_ARG_READWRITE, ARG_N_COLUMNS); + gtk_object_add_arg_type ("GtkTable::row_spacing", GTK_TYPE_UINT, GTK_ARG_READWRITE, ARG_ROW_SPACING); + gtk_object_add_arg_type ("GtkTable::column_spacing", GTK_TYPE_UINT, GTK_ARG_READWRITE, ARG_COLUMN_SPACING); + gtk_object_add_arg_type ("GtkTable::homogeneous", GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_HOMOGENEOUS); + gtk_container_add_child_arg_type ("GtkTable::left_attach", GTK_TYPE_UINT, GTK_ARG_READWRITE, CHILD_ARG_LEFT_ATTACH); + gtk_container_add_child_arg_type ("GtkTable::right_attach", GTK_TYPE_UINT, GTK_ARG_READWRITE, CHILD_ARG_RIGHT_ATTACH); + gtk_container_add_child_arg_type ("GtkTable::top_attach", GTK_TYPE_UINT, GTK_ARG_READWRITE, CHILD_ARG_TOP_ATTACH); + gtk_container_add_child_arg_type ("GtkTable::bottom_attach", GTK_TYPE_UINT, GTK_ARG_READWRITE, CHILD_ARG_BOTTOM_ATTACH); + gtk_container_add_child_arg_type ("GtkTable::x_options", GTK_TYPE_ATTACH_OPTIONS, GTK_ARG_READWRITE, CHILD_ARG_X_OPTIONS); + gtk_container_add_child_arg_type ("GtkTable::y_options", GTK_TYPE_ATTACH_OPTIONS, GTK_ARG_READWRITE, CHILD_ARG_Y_OPTIONS); + gtk_container_add_child_arg_type ("GtkTable::x_padding", GTK_TYPE_UINT, GTK_ARG_READWRITE, CHILD_ARG_X_PADDING); + gtk_container_add_child_arg_type ("GtkTable::y_padding", GTK_TYPE_UINT, GTK_ARG_READWRITE, CHILD_ARG_Y_PADDING); object_class->finalize = gtk_table_finalize; - + widget_class->map = gtk_table_map; widget_class->unmap = gtk_table_unmap; widget_class->draw = gtk_table_draw; widget_class->expose_event = gtk_table_expose; widget_class->size_request = gtk_table_size_request; widget_class->size_allocate = gtk_table_size_allocate; - + container_class->add = gtk_table_add; container_class->remove = gtk_table_remove; container_class->foreach = gtk_table_foreach; + container_class->child_type = gtk_table_child_type; + container_class->set_child_arg = gtk_table_set_child_arg; + container_class->get_child_arg = gtk_table_get_child_arg; +} + +static GtkType +gtk_table_child_type (GtkContainer *container) +{ + return GTK_TYPE_WIDGET; } static void -gtk_table_init (GtkTable *table) +gtk_table_get_arg (GtkObject *object, + GtkArg *arg, + guint arg_id) { - GTK_WIDGET_SET_FLAGS (table, GTK_NO_WINDOW | GTK_BASIC); + GtkTable *table; - table->children = NULL; - table->rows = NULL; - table->cols = NULL; - table->nrows = 0; - table->ncols = 0; - table->homogeneous = FALSE; + table = GTK_TABLE (object); + + switch (arg_id) + { + case ARG_N_ROWS: + GTK_VALUE_UINT (*arg) = table->nrows; + break; + case ARG_N_COLUMNS: + GTK_VALUE_UINT (*arg) = table->ncols; + break; + case ARG_ROW_SPACING: + GTK_VALUE_UINT (*arg) = table->row_spacing; + break; + case ARG_COLUMN_SPACING: + GTK_VALUE_UINT (*arg) = table->column_spacing; + break; + case ARG_HOMOGENEOUS: + GTK_VALUE_BOOL (*arg) = table->homogeneous; + break; + default: + arg->type = GTK_TYPE_INVALID; + break; + } } static void -gtk_table_init_rows (GtkTable *table, int start, int end) +gtk_table_set_arg (GtkObject *object, + GtkArg *arg, + guint arg_id) { - const int spacing = table->row_spacing; - int row; + GtkTable *table; + + table = GTK_TABLE (object); - for (row = start; row < end; row++) + switch (arg_id) { - table->rows[row].requisition = 0; - table->rows[row].allocation = 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; + case ARG_N_ROWS: + gtk_table_resize (table, GTK_VALUE_UINT (*arg), table->ncols); + break; + case ARG_N_COLUMNS: + gtk_table_resize (table, table->nrows, GTK_VALUE_UINT (*arg)); + break; + case ARG_ROW_SPACING: + gtk_table_set_row_spacings (table, GTK_VALUE_UINT (*arg)); + break; + case ARG_COLUMN_SPACING: + gtk_table_set_col_spacings (table, GTK_VALUE_UINT (*arg)); + break; + case ARG_HOMOGENEOUS: + gtk_table_set_homogeneous (table, GTK_VALUE_BOOL (*arg)); + break; + default: + break; } } static void -gtk_table_init_cols (GtkTable *table, int start, int end) +gtk_table_set_child_arg (GtkContainer *container, + GtkWidget *child, + GtkArg *arg, + guint arg_id) { - const int spacing = table->column_spacing; - int col; - - for (col = start; col < end; col++) + GtkTable *table; + GtkTableChild *table_child; + GList *list; + + table = GTK_TABLE (container); + table_child = NULL; + for (list = table->children; list; list = list->next) + { + table_child = list->data; + + if (table_child->widget == child) + break; + } + if (!list) + return; + + switch (arg_id) { - table->cols[col].requisition = 0; - table->cols[col].allocation = 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; + case CHILD_ARG_LEFT_ATTACH: + if (GTK_VALUE_UINT (*arg) < table_child->right_attach) + table_child->left_attach = GTK_VALUE_UINT (*arg); + break; + case CHILD_ARG_RIGHT_ATTACH: + if (GTK_VALUE_UINT (*arg) > table_child->left_attach) + table_child->right_attach = GTK_VALUE_UINT (*arg); + if (table_child->right_attach >= table->ncols) + gtk_table_resize (table, table->ncols, table_child->right_attach + 1); + break; + case CHILD_ARG_TOP_ATTACH: + if (GTK_VALUE_UINT (*arg) < table_child->bottom_attach) + table_child->top_attach = GTK_VALUE_UINT (*arg); + break; + case CHILD_ARG_BOTTOM_ATTACH: + if (GTK_VALUE_UINT (*arg) > table_child->top_attach) + table_child->bottom_attach = GTK_VALUE_UINT (*arg); + if (table_child->bottom_attach >= table->nrows) + gtk_table_resize (table, table_child->bottom_attach + 1, table->ncols); + break; + case CHILD_ARG_X_OPTIONS: + table_child->xexpand = (GTK_VALUE_FLAGS (*arg) & GTK_EXPAND) != 0; + table_child->xshrink = (GTK_VALUE_FLAGS (*arg) & GTK_SHRINK) != 0; + table_child->xfill = (GTK_VALUE_FLAGS (*arg) & GTK_FILL) != 0; + break; + case CHILD_ARG_Y_OPTIONS: + table_child->yexpand = (GTK_VALUE_FLAGS (*arg) & GTK_EXPAND) != 0; + table_child->yshrink = (GTK_VALUE_FLAGS (*arg) & GTK_SHRINK) != 0; + table_child->yfill = (GTK_VALUE_FLAGS (*arg) & GTK_FILL) != 0; + break; + case CHILD_ARG_X_PADDING: + table_child->xpadding = GTK_VALUE_UINT (*arg); + break; + case CHILD_ARG_Y_PADDING: + table_child->ypadding = GTK_VALUE_UINT (*arg); + break; + default: + break; } + if (GTK_WIDGET_VISIBLE (child) && GTK_WIDGET_VISIBLE (table)) + gtk_widget_queue_resize (GTK_WIDGET (table)); } -GtkWidget* -gtk_table_new (gint rows, - gint columns, - gint homogeneous) +static void +gtk_table_get_child_arg (GtkContainer *container, + GtkWidget *child, + GtkArg *arg, + guint arg_id) { GtkTable *table; + GtkTableChild *table_child; + GList *list; - table = gtk_type_new (gtk_table_get_type ()); + table = GTK_TABLE (container); + table_child = NULL; + for (list = table->children; list; list = list->next) + { + table_child = list->data; - table->nrows = rows; - table->ncols = columns; - table->homogeneous = (homogeneous ? TRUE : FALSE); + if (table_child->widget == child) + break; + } + if (!list) + return; + + switch (arg_id) + { + case CHILD_ARG_LEFT_ATTACH: + GTK_VALUE_UINT (*arg) = table_child->left_attach; + break; + case CHILD_ARG_RIGHT_ATTACH: + GTK_VALUE_UINT (*arg) = table_child->right_attach; + break; + case CHILD_ARG_TOP_ATTACH: + GTK_VALUE_UINT (*arg) = table_child->top_attach; + break; + case CHILD_ARG_BOTTOM_ATTACH: + GTK_VALUE_UINT (*arg) = table_child->bottom_attach; + break; + case CHILD_ARG_X_OPTIONS: + GTK_VALUE_FLAGS (*arg) = (table_child->xexpand * GTK_EXPAND | + table_child->xshrink * GTK_SHRINK | + table_child->xfill * GTK_FILL); + break; + case CHILD_ARG_Y_OPTIONS: + GTK_VALUE_FLAGS (*arg) = (table_child->yexpand * GTK_EXPAND | + table_child->yshrink * GTK_SHRINK | + table_child->yfill * GTK_FILL); + break; + case CHILD_ARG_X_PADDING: + GTK_VALUE_UINT (*arg) = table_child->xpadding; + break; + case CHILD_ARG_Y_PADDING: + GTK_VALUE_UINT (*arg) = table_child->ypadding; + break; + default: + arg->type = GTK_TYPE_INVALID; + break; + } +} + +static void +gtk_table_init (GtkTable *table) +{ + GTK_WIDGET_SET_FLAGS (table, GTK_NO_WINDOW | GTK_BASIC); + + table->children = NULL; + table->rows = NULL; + table->cols = NULL; + table->nrows = 0; + table->ncols = 0; table->column_spacing = 0; table->row_spacing = 0; - - table->rows = g_new (GtkTableRowCol, table->nrows); - table->cols = g_new (GtkTableRowCol, table->ncols); + table->homogeneous = FALSE; +} + +GtkWidget* +gtk_table_new (guint rows, + guint columns, + gboolean homogeneous) +{ + GtkTable *table; - gtk_table_init_rows (table, 0, table->nrows); - gtk_table_init_cols (table, 0, table->ncols); + g_return_val_if_fail (rows >= 1, NULL); + g_return_val_if_fail (columns >= 1, NULL); + + table = gtk_type_new (gtk_table_get_type ()); + + table->homogeneous = (homogeneous ? TRUE : FALSE); + gtk_table_resize (table, rows, columns); + return GTK_WIDGET (table); } -static void -gtk_table_expand_cols (GtkTable *table, int new_max) +void +gtk_table_resize (GtkTable *table, + guint n_rows, + guint n_cols) { - table->cols = g_realloc (table->cols, new_max * sizeof (GtkTableRowCol)); - gtk_table_init_cols (table, table->ncols, new_max); - table->ncols = new_max; -} + g_return_if_fail (table != NULL); + g_return_if_fail (GTK_IS_TABLE (table)); -static void -gtk_table_expand_rows (GtkTable *table, int new_max) -{ - table->rows = g_realloc (table->rows, new_max * sizeof (GtkTableRowCol)); - gtk_table_init_rows (table, table->nrows, new_max); - table->nrows = new_max; + n_rows = MAX (n_rows, 1); + n_cols = MAX (n_cols, 1); + + if (n_rows != table->nrows || + n_cols != table->ncols) + { + GList *list; + + for (list = table->children; list; list = list->next) + { + GtkTableChild *child; + + child = list->data; + + n_rows = MAX (n_rows, child->bottom_attach + 1); + n_cols = MAX (n_cols, child->right_attach + 1); + } + + if (n_rows != table->nrows) + { + guint i; + + i = table->nrows; + table->nrows = n_rows; + table->rows = g_realloc (table->rows, table->nrows * sizeof (GtkTableRowCol)); + + for (; i < table->nrows; i++) + { + table->rows[i].requisition = 0; + table->rows[i].allocation = 0; + table->rows[i].spacing = table->row_spacing; + table->rows[i].need_expand = 0; + table->rows[i].need_shrink = 0; + table->rows[i].expand = 0; + table->rows[i].shrink = 0; + } + } + + if (n_cols != table->ncols) + { + guint i; + + i = table->ncols; + table->ncols = n_cols; + table->cols = g_realloc (table->cols, table->ncols * sizeof (GtkTableRowCol)); + + for (; i < table->ncols; i++) + { + table->cols[i].requisition = 0; + table->cols[i].allocation = 0; + table->cols[i].spacing = table->column_spacing; + table->cols[i].need_expand = 0; + table->cols[i].need_shrink = 0; + table->cols[i].expand = 0; + table->cols[i].shrink = 0; + } + } + } } void -gtk_table_attach (GtkTable *table, - GtkWidget *child, - gint left_attach, - gint right_attach, - gint top_attach, - gint bottom_attach, - gint xoptions, - gint yoptions, - gint xpadding, - gint ypadding) +gtk_table_attach (GtkTable *table, + GtkWidget *child, + guint left_attach, + guint right_attach, + guint top_attach, + guint bottom_attach, + GtkAttachOptions xoptions, + GtkAttachOptions yoptions, + guint xpadding, + guint ypadding) { GtkTableChild *table_child; 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); + g_return_if_fail (GTK_IS_WIDGET (child)); + g_return_if_fail (child->parent == NULL); + + /* 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 >= 0); */ g_return_if_fail (top_attach < bottom_attach); - + if (right_attach >= table->ncols) - gtk_table_expand_cols (table, right_attach); - + gtk_table_resize (table, table->nrows, right_attach + 1); + if (bottom_attach >= table->nrows) - gtk_table_expand_rows (table, bottom_attach); - + gtk_table_resize (table, bottom_attach + 1, table->ncols); + table_child = g_new (GtkTableChild, 1); table_child->widget = child; table_child->left_attach = left_attach; @@ -236,11 +501,11 @@ gtk_table_attach (GtkTable *table, table_child->yshrink = (yoptions & GTK_SHRINK) != 0; table_child->yfill = (yoptions & GTK_FILL) != 0; table_child->ypadding = ypadding; - + table->children = g_list_prepend (table->children, table_child); - + gtk_widget_set_parent (child, GTK_WIDGET (table)); - + if (GTK_WIDGET_VISIBLE (GTK_WIDGET (table))) { if (GTK_WIDGET_REALIZED (GTK_WIDGET (table)) && @@ -251,18 +516,18 @@ gtk_table_attach (GtkTable *table, !GTK_WIDGET_MAPPED (child)) gtk_widget_map (child); } - + if (GTK_WIDGET_VISIBLE (child) && GTK_WIDGET_VISIBLE (table)) - gtk_widget_queue_resize (child); + gtk_widget_queue_resize (GTK_WIDGET (table)); } void gtk_table_attach_defaults (GtkTable *table, GtkWidget *widget, - gint left_attach, - gint right_attach, - gint top_attach, - gint bottom_attach) + guint left_attach, + guint right_attach, + guint top_attach, + guint bottom_attach) { gtk_table_attach (table, widget, left_attach, right_attach, @@ -274,17 +539,18 @@ gtk_table_attach_defaults (GtkTable *table, void gtk_table_set_row_spacing (GtkTable *table, - gint row, - gint spacing) + guint row, + guint spacing) { g_return_if_fail (table != NULL); g_return_if_fail (GTK_IS_TABLE (table)); - g_return_if_fail ((row >= 0) && (row < (table->nrows - 1))); - + /* g_return_if_fail ((row >= 0) && (row < (table->nrows - 1))); */ + g_return_if_fail (row < table->nrows - 1); + if (table->rows[row].spacing != spacing) { table->rows[row].spacing = spacing; - + if (GTK_WIDGET_VISIBLE (table)) gtk_widget_queue_resize (GTK_WIDGET (table)); } @@ -292,17 +558,18 @@ gtk_table_set_row_spacing (GtkTable *table, void gtk_table_set_col_spacing (GtkTable *table, - gint column, - gint spacing) + guint column, + guint spacing) { g_return_if_fail (table != NULL); g_return_if_fail (GTK_IS_TABLE (table)); - g_return_if_fail ((column >= 0) && (column < (table->ncols - 1))); - + /* g_return_if_fail ((column >= 0) && (column < (table->ncols - 1))); */ + g_return_if_fail (column < table->ncols - 1); + if (table->cols[column].spacing != spacing) { table->cols[column].spacing = spacing; - + if (GTK_WIDGET_VISIBLE (table)) gtk_widget_queue_resize (GTK_WIDGET (table)); } @@ -310,65 +577,68 @@ gtk_table_set_col_spacing (GtkTable *table, void gtk_table_set_row_spacings (GtkTable *table, - gint spacing) + guint spacing) { - gint row; - + guint row; + g_return_if_fail (table != NULL); g_return_if_fail (GTK_IS_TABLE (table)); - + table->row_spacing = spacing; for (row = 0; row < table->nrows - 1; row++) table->rows[row].spacing = spacing; - + if (GTK_WIDGET_VISIBLE (table)) gtk_widget_queue_resize (GTK_WIDGET (table)); } void gtk_table_set_col_spacings (GtkTable *table, - gint spacing) + guint spacing) { - gint col; - + guint col; + g_return_if_fail (table != NULL); g_return_if_fail (GTK_IS_TABLE (table)); - + table->column_spacing = spacing; for (col = 0; col < table->ncols - 1; col++) table->cols[col].spacing = spacing; - + if (GTK_WIDGET_VISIBLE (table)) gtk_widget_queue_resize (GTK_WIDGET (table)); } void gtk_table_set_homogeneous (GtkTable *table, - gint homogeneous) + gboolean homogeneous) { g_return_if_fail (table != NULL); g_return_if_fail (GTK_IS_TABLE (table)); - table->homogeneous = (homogeneous != 0); - - if (GTK_WIDGET_VISIBLE (table)) - gtk_widget_queue_resize (GTK_WIDGET (table)); + homogeneous = (homogeneous != 0); + if (homogeneous != table->homogeneous) + { + table->homogeneous = homogeneous; + + if (GTK_WIDGET_VISIBLE (table)) + gtk_widget_queue_resize (GTK_WIDGET (table)); + } } - static void gtk_table_finalize (GtkObject *object) { GtkTable *table; - + g_return_if_fail (object != NULL); g_return_if_fail (GTK_IS_TABLE (object)); - + table = GTK_TABLE (object); - + g_free (table->rows); g_free (table->cols); - + (* GTK_OBJECT_CLASS (parent_class)->finalize) (object); } @@ -378,22 +648,22 @@ gtk_table_map (GtkWidget *widget) GtkTable *table; GtkTableChild *child; GList *children; - + g_return_if_fail (widget != NULL); g_return_if_fail (GTK_IS_TABLE (widget)); - + table = GTK_TABLE (widget); GTK_WIDGET_SET_FLAGS (table, GTK_MAPPED); - + children = table->children; while (children) { child = children->data; children = children->next; - + if (GTK_WIDGET_VISIBLE (child->widget) && - !GTK_WIDGET_MAPPED (child->widget)) - gtk_widget_map (child->widget); + !GTK_WIDGET_MAPPED (child->widget)) + gtk_widget_map (child->widget); } } @@ -403,22 +673,22 @@ gtk_table_unmap (GtkWidget *widget) GtkTable *table; GtkTableChild *child; GList *children; - + g_return_if_fail (widget != NULL); g_return_if_fail (GTK_IS_TABLE (widget)); - + table = GTK_TABLE (widget); GTK_WIDGET_UNSET_FLAGS (table, GTK_MAPPED); - + children = table->children; while (children) { child = children->data; children = children->next; - + if (GTK_WIDGET_VISIBLE (child->widget) && - GTK_WIDGET_MAPPED (child->widget)) - gtk_widget_unmap (child->widget); + GTK_WIDGET_MAPPED (child->widget)) + gtk_widget_unmap (child->widget); } } @@ -430,20 +700,20 @@ gtk_table_draw (GtkWidget *widget, GtkTableChild *child; GList *children; GdkRectangle child_area; - + g_return_if_fail (widget != NULL); g_return_if_fail (GTK_IS_TABLE (widget)); - + if (GTK_WIDGET_VISIBLE (widget) && GTK_WIDGET_MAPPED (widget)) { table = GTK_TABLE (widget); - + children = table->children; while (children) { child = children->data; children = children->next; - + if (gtk_widget_intersect (child->widget, area, &child_area)) gtk_widget_draw (child->widget, &child_area); } @@ -451,35 +721,35 @@ gtk_table_draw (GtkWidget *widget, } static gint -gtk_table_expose (GtkWidget *widget, +gtk_table_expose (GtkWidget *widget, GdkEventExpose *event) { GtkTable *table; GtkTableChild *child; GList *children; GdkEventExpose child_event; - + g_return_val_if_fail (widget != NULL, FALSE); g_return_val_if_fail (GTK_IS_TABLE (widget), FALSE); - + if (GTK_WIDGET_VISIBLE (widget) && GTK_WIDGET_MAPPED (widget)) { table = GTK_TABLE (widget); - + child_event = *event; - + children = table->children; while (children) { child = children->data; children = children->next; - + if (GTK_WIDGET_NO_WINDOW (child->widget) && gtk_widget_intersect (child->widget, &event->area, &child_event.area)) gtk_widget_event (child->widget, (GdkEvent*) &child_event); } } - + return FALSE; } @@ -489,32 +759,32 @@ gtk_table_size_request (GtkWidget *widget, { GtkTable *table; gint row, col; - + g_return_if_fail (widget != NULL); g_return_if_fail (GTK_IS_TABLE (widget)); g_return_if_fail (requisition != NULL); - + table = GTK_TABLE (widget); - + requisition->width = 0; requisition->height = 0; - + gtk_table_size_request_init (table); gtk_table_size_request_pass1 (table); gtk_table_size_request_pass2 (table); gtk_table_size_request_pass3 (table); gtk_table_size_request_pass2 (table); - + for (col = 0; col < table->ncols; col++) requisition->width += table->cols[col].requisition; for (col = 0; col < table->ncols - 1; col++) requisition->width += table->cols[col].spacing; - + for (row = 0; row < table->nrows; row++) requisition->height += table->rows[row].requisition; for (row = 0; row < table->nrows - 1; row++) requisition->height += table->rows[row].spacing; - + requisition->width += GTK_CONTAINER (table)->border_width * 2; requisition->height += GTK_CONTAINER (table)->border_width * 2; } @@ -524,14 +794,14 @@ gtk_table_size_allocate (GtkWidget *widget, GtkAllocation *allocation) { GtkTable *table; - + g_return_if_fail (widget != NULL); g_return_if_fail (GTK_IS_TABLE (widget)); g_return_if_fail (allocation != NULL); - + widget->allocation = *allocation; table = GTK_TABLE (widget); - + gtk_table_size_allocate_init (table); gtk_table_size_allocate_pass1 (table); gtk_table_size_allocate_pass2 (table); @@ -544,7 +814,7 @@ gtk_table_add (GtkContainer *container, g_return_if_fail (container != NULL); g_return_if_fail (GTK_IS_TABLE (container)); g_return_if_fail (widget != NULL); - + gtk_table_attach_defaults (GTK_TABLE (container), widget, 0, 1, 0, 1); } @@ -555,56 +825,56 @@ gtk_table_remove (GtkContainer *container, GtkTable *table; GtkTableChild *child; GList *children; - + g_return_if_fail (container != NULL); g_return_if_fail (GTK_IS_TABLE (container)); g_return_if_fail (widget != NULL); - + table = GTK_TABLE (container); children = table->children; - + while (children) { child = children->data; children = children->next; - + if (child->widget == widget) - { + { gboolean was_visible = GTK_WIDGET_VISIBLE (widget); gtk_widget_unparent (widget); - - table->children = g_list_remove (table->children, child); - g_free (child); - - if (was_visible && GTK_WIDGET_VISIBLE (container)) - gtk_widget_queue_resize (GTK_WIDGET (container)); - break; - } + + table->children = g_list_remove (table->children, child); + g_free (child); + + if (was_visible && GTK_WIDGET_VISIBLE (container)) + gtk_widget_queue_resize (GTK_WIDGET (container)); + break; + } } } static void gtk_table_foreach (GtkContainer *container, - GtkCallback callback, - gpointer callback_data) + GtkCallback callback, + gpointer callback_data) { GtkTable *table; GtkTableChild *child; GList *children; - + g_return_if_fail (container != NULL); g_return_if_fail (GTK_IS_TABLE (container)); g_return_if_fail (callback != NULL); - + table = GTK_TABLE (container); children = table->children; - + while (children) { child = children->data; children = children->next; - + (* callback) (child->widget, callback_data); } } @@ -615,18 +885,18 @@ gtk_table_size_request_init (GtkTable *table) GtkTableChild *child; GList *children; gint row, col; - + for (row = 0; row < table->nrows; row++) table->rows[row].requisition = 0; for (col = 0; col < table->ncols; col++) table->cols[col].requisition = 0; - + children = table->children; while (children) { child = children->data; children = children->next; - + if (GTK_WIDGET_VISIBLE (child->widget)) gtk_widget_size_request (child->widget, &child->widget->requisition); } @@ -639,31 +909,31 @@ gtk_table_size_request_pass1 (GtkTable *table) GList *children; gint width; gint height; - + children = table->children; while (children) { child = children->data; children = children->next; - + if (GTK_WIDGET_VISIBLE (child->widget)) - { - /* Child spans a single column. - */ - if (child->left_attach == (child->right_attach - 1)) - { - width = child->widget->requisition.width + child->xpadding * 2; - table->cols[child->left_attach].requisition = MAX (table->cols[child->left_attach].requisition, width); - } - - /* Child spans a single row. - */ - if (child->top_attach == (child->bottom_attach - 1)) - { - height = child->widget->requisition.height + child->ypadding * 2; - table->rows[child->top_attach].requisition = MAX (table->rows[child->top_attach].requisition, height); - } - } + { + /* Child spans a single column. + */ + if (child->left_attach == (child->right_attach - 1)) + { + width = child->widget->requisition.width + child->xpadding * 2; + table->cols[child->left_attach].requisition = MAX (table->cols[child->left_attach].requisition, width); + } + + /* Child spans a single row. + */ + if (child->top_attach == (child->bottom_attach - 1)) + { + height = child->widget->requisition.height + child->ypadding * 2; + table->rows[child->top_attach].requisition = MAX (table->rows[child->top_attach].requisition, height); + } + } } } @@ -673,21 +943,21 @@ gtk_table_size_request_pass2 (GtkTable *table) gint max_width; gint max_height; gint row, col; - + if (table->homogeneous) { max_width = 0; max_height = 0; - + for (col = 0; col < table->ncols; col++) - max_width = MAX (max_width, table->cols[col].requisition); + max_width = MAX (max_width, table->cols[col].requisition); for (row = 0; row < table->nrows; row++) - max_height = MAX (max_height, table->rows[row].requisition); - + max_height = MAX (max_height, table->rows[row].requisition); + for (col = 0; col < table->ncols; col++) - table->cols[col].requisition = max_width; + table->cols[col].requisition = max_width; for (row = 0; row < table->nrows; row++) - table->rows[row].requisition = max_height; + table->rows[row].requisition = max_height; } } @@ -699,79 +969,79 @@ gtk_table_size_request_pass3 (GtkTable *table) gint width, height; gint row, col; gint extra; - + children = table->children; while (children) { child = children->data; children = children->next; - + if (GTK_WIDGET_VISIBLE (child->widget)) - { - /* Child spans multiple columns. - */ - if (child->left_attach != (child->right_attach - 1)) - { - /* Check and see if there is already enough space - * for the child. - */ - width = 0; - for (col = child->left_attach; col < child->right_attach; col++) - { - width += table->cols[col].requisition; - if ((col + 1) < child->right_attach) - width += table->cols[col].spacing; - } - - /* If we need to request more space for this child to fill - * its requisition, then divide up the needed space evenly - * amongst the columns it spans. - */ - if (width < child->widget->requisition.width + child->xpadding * 2) - { - width = child->widget->requisition.width + child->xpadding * 2 - width; - - for (col = child->left_attach; col < child->right_attach; col++) - { - extra = width / (child->right_attach - col); + { + /* Child spans multiple columns. + */ + if (child->left_attach != (child->right_attach - 1)) + { + /* Check and see if there is already enough space + * for the child. + */ + width = 0; + for (col = child->left_attach; col < child->right_attach; col++) + { + width += table->cols[col].requisition; + if ((col + 1) < child->right_attach) + width += table->cols[col].spacing; + } + + /* If we need to request more space for this child to fill + * its requisition, then divide up the needed space evenly + * amongst the columns it spans. + */ + if (width < child->widget->requisition.width + child->xpadding * 2) + { + width = child->widget->requisition.width + child->xpadding * 2 - width; + + for (col = child->left_attach; col < child->right_attach; col++) + { + extra = width / (child->right_attach - col); table->cols[col].requisition += extra; - width -= extra; - } - } - } - - /* Child spans multiple rows. - */ - if (child->top_attach != (child->bottom_attach - 1)) - { - /* Check and see if there is already enough space - * for the child. - */ - height = 0; - for (row = child->top_attach; row < child->bottom_attach; row++) - { - height += table->rows[row].requisition; - if ((row + 1) < child->bottom_attach) - height += table->rows[row].spacing; - } - - /* If we need to request more space for this child to fill - * its requisition, then divide up the needed space evenly - * amongst the columns it spans. - */ - if (height < child->widget->requisition.height + child->ypadding * 2) - { - height = child->widget->requisition.height + child->ypadding * 2 - height; - - for (row = child->top_attach; row < child->bottom_attach; row++) - { - extra = height / (child->bottom_attach - row); + width -= extra; + } + } + } + + /* Child spans multiple rows. + */ + if (child->top_attach != (child->bottom_attach - 1)) + { + /* Check and see if there is already enough space + * for the child. + */ + height = 0; + for (row = child->top_attach; row < child->bottom_attach; row++) + { + height += table->rows[row].requisition; + if ((row + 1) < child->bottom_attach) + height += table->rows[row].spacing; + } + + /* If we need to request more space for this child to fill + * its requisition, then divide up the needed space evenly + * amongst the columns it spans. + */ + if (height < child->widget->requisition.height + child->ypadding * 2) + { + height = child->widget->requisition.height + child->ypadding * 2 - height; + + for (row = child->top_attach; row < child->bottom_attach; row++) + { + extra = height / (child->bottom_attach - row); table->rows[row].requisition += extra; - height -= extra; - } - } - } - } + height -= extra; + } + } + } + } } } @@ -783,7 +1053,7 @@ gtk_table_size_allocate_init (GtkTable *table) gint row, col; gint has_expand; gint has_shrink; - + /* Initialize the rows and cols. * By default, rows and cols do not expand and do shrink. * Those values are modified by the children that occupy @@ -805,7 +1075,7 @@ gtk_table_size_allocate_init (GtkTable *table) table->rows[row].expand = FALSE; table->rows[row].shrink = TRUE; } - + /* Loop over all the children and adjust the row and col values * based on whether the children want to be allowed to expand * or shrink. This loop handles children that occupy a single @@ -816,29 +1086,29 @@ gtk_table_size_allocate_init (GtkTable *table) { child = children->data; children = children->next; - + if (GTK_WIDGET_VISIBLE (child->widget)) - { - if (child->left_attach == (child->right_attach - 1)) - { - if (child->xexpand) - table->cols[child->left_attach].expand = TRUE; - - if (!child->xshrink) - table->cols[child->left_attach].shrink = FALSE; - } - - if (child->top_attach == (child->bottom_attach - 1)) - { - if (child->yexpand) - table->rows[child->top_attach].expand = TRUE; - - if (!child->yshrink) - table->rows[child->top_attach].shrink = FALSE; - } - } + { + if (child->left_attach == (child->right_attach - 1)) + { + if (child->xexpand) + table->cols[child->left_attach].expand = TRUE; + + if (!child->xshrink) + table->cols[child->left_attach].shrink = FALSE; + } + + if (child->top_attach == (child->bottom_attach - 1)) + { + if (child->yexpand) + table->rows[child->top_attach].expand = TRUE; + + if (!child->yshrink) + table->rows[child->top_attach].shrink = FALSE; + } + } } - + /* Loop over all the children again and this time handle children * which span multiple rows or columns. */ @@ -847,97 +1117,97 @@ gtk_table_size_allocate_init (GtkTable *table) { child = children->data; children = children->next; - + if (GTK_WIDGET_VISIBLE (child->widget)) - { - if (child->left_attach != (child->right_attach - 1)) - { - if (child->xexpand) - { - has_expand = FALSE; - for (col = child->left_attach; col < child->right_attach; col++) - if (table->cols[col].expand) - { - has_expand = TRUE; - break; - } - - if (!has_expand) - for (col = child->left_attach; col < child->right_attach; col++) - table->cols[col].need_expand = TRUE; - } - - if (!child->xshrink) - { - has_shrink = TRUE; - for (col = child->left_attach; col < child->right_attach; col++) - if (!table->cols[col].shrink) - { - has_shrink = FALSE; - break; - } - - if (has_shrink) - for (col = child->left_attach; col < child->right_attach; col++) - table->cols[col].need_shrink = FALSE; - } - } - - if (child->top_attach != (child->bottom_attach - 1)) - { - if (child->yexpand) - { - has_expand = FALSE; - for (row = child->top_attach; row < child->bottom_attach; row++) - if (table->rows[row].expand) - { - has_expand = TRUE; - break; - } - - if (!has_expand) - for (row = child->top_attach; row < child->bottom_attach; row++) - table->rows[row].need_expand = TRUE; - } - - if (!child->yshrink) - { - has_shrink = TRUE; - for (row = child->top_attach; row < child->bottom_attach; row++) - if (!table->rows[row].shrink) - { - has_shrink = FALSE; - break; - } - - if (has_shrink) - for (row = child->top_attach; row < child->bottom_attach; row++) - table->rows[row].need_shrink = FALSE; - } - } - } + { + if (child->left_attach != (child->right_attach - 1)) + { + if (child->xexpand) + { + has_expand = FALSE; + for (col = child->left_attach; col < child->right_attach; col++) + if (table->cols[col].expand) + { + has_expand = TRUE; + break; + } + + if (!has_expand) + for (col = child->left_attach; col < child->right_attach; col++) + table->cols[col].need_expand = TRUE; + } + + if (!child->xshrink) + { + has_shrink = TRUE; + for (col = child->left_attach; col < child->right_attach; col++) + if (!table->cols[col].shrink) + { + has_shrink = FALSE; + break; + } + + if (has_shrink) + for (col = child->left_attach; col < child->right_attach; col++) + table->cols[col].need_shrink = FALSE; + } + } + + if (child->top_attach != (child->bottom_attach - 1)) + { + if (child->yexpand) + { + has_expand = FALSE; + for (row = child->top_attach; row < child->bottom_attach; row++) + if (table->rows[row].expand) + { + has_expand = TRUE; + break; + } + + if (!has_expand) + for (row = child->top_attach; row < child->bottom_attach; row++) + table->rows[row].need_expand = TRUE; + } + + if (!child->yshrink) + { + has_shrink = TRUE; + for (row = child->top_attach; row < child->bottom_attach; row++) + if (!table->rows[row].shrink) + { + has_shrink = FALSE; + break; + } + + if (has_shrink) + for (row = child->top_attach; row < child->bottom_attach; row++) + table->rows[row].need_shrink = FALSE; + } + } + } } - + /* Loop over the columns and set the expand and shrink values * if the column can be expanded or shrunk. */ for (col = 0; col < table->ncols; col++) { if (table->cols[col].need_expand) - table->cols[col].expand = TRUE; + table->cols[col].expand = TRUE; if (!table->cols[col].need_shrink) - table->cols[col].shrink = FALSE; + table->cols[col].shrink = FALSE; } - + /* Loop over the rows and set the expand and shrink values * if the row can be expanded or shrunk. */ for (row = 0; row < table->nrows; row++) { if (table->rows[row].need_expand) - table->rows[row].expand = TRUE; + table->rows[row].expand = TRUE; if (!table->rows[row].need_shrink) - table->rows[row].shrink = FALSE; + table->rows[row].shrink = FALSE; } } @@ -951,168 +1221,168 @@ gtk_table_size_allocate_pass1 (GtkTable *table) gint nexpand; gint nshrink; gint extra; - + /* If we were allocated more space than we requested * then we have to expand any expandable rows and columns * to fill in the extra space. */ - + real_width = GTK_WIDGET (table)->allocation.width - GTK_CONTAINER (table)->border_width * 2; real_height = GTK_WIDGET (table)->allocation.height - GTK_CONTAINER (table)->border_width * 2; - + if (table->homogeneous) { nexpand = 0; for (col = 0; col < table->ncols; col++) - if (table->cols[col].expand) - { - nexpand += 1; - break; - } - + if (table->cols[col].expand) + { + nexpand += 1; + break; + } + if (nexpand > 0) - { - width = real_width; - - for (col = 0; col < table->ncols - 1; col++) - width -= table->cols[col].spacing; - - for (col = 0; col < table->ncols; col++) - { - extra = width / (table->ncols - col); + { + width = real_width; + + for (col = 0; col < table->ncols - 1; col++) + width -= table->cols[col].spacing; + + for (col = 0; col < table->ncols; col++) + { + extra = width / (table->ncols - col); table->cols[col].allocation = MAX (1, extra); - width -= extra; - } - } + width -= extra; + } + } } else { width = 0; nexpand = 0; nshrink = 0; - + for (col = 0; col < table->ncols; col++) - { - width += table->cols[col].requisition; - if (table->cols[col].expand) - nexpand += 1; - if (table->cols[col].shrink) - nshrink += 1; - } + { + width += table->cols[col].requisition; + if (table->cols[col].expand) + nexpand += 1; + if (table->cols[col].shrink) + nshrink += 1; + } for (col = 0; col < table->ncols - 1; col++) - width += table->cols[col].spacing; - + width += table->cols[col].spacing; + /* Check to see if we were allocated more width than we requested. */ if ((width < real_width) && (nexpand >= 1)) - { - width = real_width - width; - - for (col = 0; col < table->ncols; col++) - if (table->cols[col].expand) - { - extra = width / nexpand; + { + width = real_width - width; + + for (col = 0; col < table->ncols; col++) + if (table->cols[col].expand) + { + extra = width / nexpand; table->cols[col].allocation += extra; - - width -= extra; - nexpand -= 1; - } - } - + + width -= extra; + nexpand -= 1; + } + } + /* Check to see if we were allocated less width than we requested. */ if ((width > real_width) && (nshrink >= 1)) - { - width = width - real_width; - - for (col = 0; col < table->ncols; col++) - if (table->cols[col].shrink) - { - extra = width / nshrink; + { + width = width - real_width; + + for (col = 0; col < table->ncols; col++) + if (table->cols[col].shrink) + { + extra = width / nshrink; table->cols[col].allocation = MAX (1, table->cols[col].allocation - extra); - - width -= extra; - nshrink -= 1; - } - } + + width -= extra; + nshrink -= 1; + } + } } - + if (table->homogeneous) { nexpand = 0; for (row = 0; row < table->nrows; row++) - if (table->rows[row].expand) - { - nexpand += 1; - break; - } - + if (table->rows[row].expand) + { + nexpand += 1; + break; + } + if (nexpand > 0) - { - height = real_height; - - for (row = 0; row < table->nrows - 1; row++) - height -= table->rows[row].spacing; - - - for (row = 0; row < table->nrows; row++) - { - extra = height / (table->nrows - row); + { + height = real_height; + + for (row = 0; row < table->nrows - 1; row++) + height -= table->rows[row].spacing; + + + for (row = 0; row < table->nrows; row++) + { + extra = height / (table->nrows - row); table->rows[row].allocation = MAX (1, extra); - height -= extra; - } - } + height -= extra; + } + } } else { height = 0; nexpand = 0; nshrink = 0; - + for (row = 0; row < table->nrows; row++) - { - height += table->rows[row].requisition; - if (table->rows[row].expand) - nexpand += 1; - if (table->rows[row].shrink) - nshrink += 1; - } + { + height += table->rows[row].requisition; + if (table->rows[row].expand) + nexpand += 1; + if (table->rows[row].shrink) + nshrink += 1; + } for (row = 0; row < table->nrows - 1; row++) - height += table->rows[row].spacing; - + height += table->rows[row].spacing; + /* Check to see if we were allocated more height than we requested. */ if ((height < real_height) && (nexpand >= 1)) - { - height = real_height - height; - - for (row = 0; row < table->nrows; row++) - if (table->rows[row].expand) - { - extra = height / nexpand; + { + height = real_height - height; + + for (row = 0; row < table->nrows; row++) + if (table->rows[row].expand) + { + extra = height / nexpand; table->rows[row].allocation += extra; - - height -= extra; - nexpand -= 1; - } - } - + + height -= extra; + nexpand -= 1; + } + } + /* Check to see if we were allocated less height than we requested. */ if ((height > real_height) && (nshrink >= 1)) - { - height = height - real_height; - - for (row = 0; row < table->nrows; row++) - if (table->rows[row].shrink) - { - extra = height / nshrink; + { + height = height - real_height; + + for (row = 0; row < table->nrows; row++) + if (table->rows[row].shrink) + { + extra = height / nshrink; table->rows[row].allocation = MAX (1, table->rows[row].allocation - extra); - - height -= extra; - nshrink -= 1; - } - } + + height -= extra; + nshrink -= 1; + } + } } } @@ -1126,70 +1396,69 @@ gtk_table_size_allocate_pass2 (GtkTable *table) gint x, y; gint row, col; GtkAllocation allocation; - + children = table->children; while (children) { child = children->data; children = children->next; - + if (GTK_WIDGET_VISIBLE (child->widget)) - { - x = GTK_WIDGET (table)->allocation.x + GTK_CONTAINER (table)->border_width; - y = GTK_WIDGET (table)->allocation.y + GTK_CONTAINER (table)->border_width; - max_width = 0; - max_height = 0; - - for (col = 0; col < child->left_attach; col++) - { - x += table->cols[col].allocation; - x += table->cols[col].spacing; - } - - for (col = child->left_attach; col < child->right_attach; col++) - { - max_width += table->cols[col].allocation; - if ((col + 1) < child->right_attach) - max_width += table->cols[col].spacing; - } - - for (row = 0; row < child->top_attach; row++) - { - y += table->rows[row].allocation; - y += table->rows[row].spacing; - } - - for (row = child->top_attach; row < child->bottom_attach; row++) - { - max_height += table->rows[row].allocation; - if ((row + 1) < child->bottom_attach) - max_height += table->rows[row].spacing; - } - - if (child->xfill) - { - allocation.width = MAX (1, max_width - child->xpadding * 2); - allocation.x = x + (max_width - allocation.width) / 2; - } - else - { - allocation.width = child->widget->requisition.width; - allocation.x = x + (max_width - allocation.width) / 2; - } - - if (child->yfill) - { - allocation.height = MAX (1, max_height - child->ypadding * 2); - allocation.y = y + (max_height - allocation.height) / 2; - } - else - { - allocation.height = child->widget->requisition.height; - allocation.y = y + (max_height - allocation.height) / 2; - } - + { + x = GTK_WIDGET (table)->allocation.x + GTK_CONTAINER (table)->border_width; + y = GTK_WIDGET (table)->allocation.y + GTK_CONTAINER (table)->border_width; + max_width = 0; + max_height = 0; + + for (col = 0; col < child->left_attach; col++) + { + x += table->cols[col].allocation; + x += table->cols[col].spacing; + } + + for (col = child->left_attach; col < child->right_attach; col++) + { + max_width += table->cols[col].allocation; + if ((col + 1) < child->right_attach) + max_width += table->cols[col].spacing; + } + + for (row = 0; row < child->top_attach; row++) + { + y += table->rows[row].allocation; + y += table->rows[row].spacing; + } + + for (row = child->top_attach; row < child->bottom_attach; row++) + { + max_height += table->rows[row].allocation; + if ((row + 1) < child->bottom_attach) + max_height += table->rows[row].spacing; + } + + if (child->xfill) + { + allocation.width = MAX (1, max_width - child->xpadding * 2); + allocation.x = x + (max_width - allocation.width) / 2; + } + else + { + allocation.width = child->widget->requisition.width; + allocation.x = x + (max_width - allocation.width) / 2; + } + + if (child->yfill) + { + allocation.height = MAX (1, max_height - child->ypadding * 2); + allocation.y = y + (max_height - allocation.height) / 2; + } + else + { + allocation.height = child->widget->requisition.height; + allocation.y = y + (max_height - allocation.height) / 2; + } + gtk_widget_size_allocate (child->widget, &allocation); - } + } } } - |