1 /* GTK - The GIMP Toolkit
2 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the Free
16 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 static void gtk_table_class_init (GtkTableClass *klass);
22 static void gtk_table_init (GtkTable *table);
23 static void gtk_table_destroy (GtkObject *object);
24 static void gtk_table_map (GtkWidget *widget);
25 static void gtk_table_unmap (GtkWidget *widget);
26 static void gtk_table_draw (GtkWidget *widget,
28 static gint gtk_table_expose (GtkWidget *widget,
29 GdkEventExpose *event);
30 static void gtk_table_size_request (GtkWidget *widget,
31 GtkRequisition *requisition);
32 static void gtk_table_size_allocate (GtkWidget *widget,
33 GtkAllocation *allocation);
34 static void gtk_table_add (GtkContainer *container,
36 static void gtk_table_remove (GtkContainer *container,
38 static void gtk_table_foreach (GtkContainer *container,
40 gpointer callback_data);
42 static void gtk_table_size_request_init (GtkTable *table);
43 static void gtk_table_size_request_pass1 (GtkTable *table);
44 static void gtk_table_size_request_pass2 (GtkTable *table);
45 static void gtk_table_size_request_pass3 (GtkTable *table);
47 static void gtk_table_size_allocate_init (GtkTable *table);
48 static void gtk_table_size_allocate_pass1 (GtkTable *table);
49 static void gtk_table_size_allocate_pass2 (GtkTable *table);
52 static GtkContainerClass *parent_class = NULL;
58 static guint table_type = 0;
62 GtkTypeInfo table_info =
66 sizeof (GtkTableClass),
67 (GtkClassInitFunc) gtk_table_class_init,
68 (GtkObjectInitFunc) gtk_table_init,
72 table_type = gtk_type_unique (gtk_container_get_type (), &table_info);
79 gtk_table_class_init (GtkTableClass *class)
81 GtkObjectClass *object_class;
82 GtkWidgetClass *widget_class;
83 GtkContainerClass *container_class;
85 object_class = (GtkObjectClass*) class;
86 widget_class = (GtkWidgetClass*) class;
87 container_class = (GtkContainerClass*) class;
89 parent_class = gtk_type_class (gtk_container_get_type ());
91 object_class->destroy = gtk_table_destroy;
93 widget_class->map = gtk_table_map;
94 widget_class->unmap = gtk_table_unmap;
95 widget_class->draw = gtk_table_draw;
96 widget_class->expose_event = gtk_table_expose;
97 widget_class->size_request = gtk_table_size_request;
98 widget_class->size_allocate = gtk_table_size_allocate;
100 container_class->add = gtk_table_add;
101 container_class->remove = gtk_table_remove;
102 container_class->foreach = gtk_table_foreach;
106 gtk_table_init (GtkTable *table)
108 GTK_WIDGET_SET_FLAGS (table, GTK_NO_WINDOW | GTK_BASIC);
110 table->children = NULL;
115 table->homogeneous = FALSE;
119 gtk_table_new (gint rows,
126 table = gtk_type_new (gtk_table_get_type ());
129 table->ncols = columns;
130 table->homogeneous = (homogeneous ? TRUE : FALSE);
132 table->rows = g_new (GtkTableRowCol, table->nrows);
133 table->cols = g_new (GtkTableRowCol, table->ncols);
135 for (row = 0; row < table->nrows; row++)
137 table->rows[row].requisition = 0;
138 table->rows[row].allocation = 0;
139 table->rows[row].spacing = 0;
140 table->rows[row].need_expand = 0;
141 table->rows[row].need_shrink = 0;
142 table->rows[row].expand = 0;
143 table->rows[row].shrink = 0;
146 for (col = 0; col < table->ncols; col++)
148 table->cols[col].requisition = 0;
149 table->cols[col].allocation = 0;
150 table->cols[col].spacing = 0;
151 table->cols[col].need_expand = 0;
152 table->cols[col].need_shrink = 0;
153 table->cols[col].expand = 0;
154 table->cols[col].shrink = 0;
157 return GTK_WIDGET (table);
161 gtk_table_attach (GtkTable *table,
172 GtkTableChild *table_child;
174 g_return_if_fail (table != NULL);
175 g_return_if_fail (GTK_IS_TABLE (table));
176 g_return_if_fail (child != NULL);
178 g_return_if_fail ((left_attach >= 0) && (left_attach < table->ncols));
179 g_return_if_fail ((left_attach < right_attach) && (right_attach <= table->ncols));
180 g_return_if_fail ((top_attach >= 0) && (top_attach < table->nrows));
181 g_return_if_fail ((top_attach < bottom_attach) && (bottom_attach <= table->nrows));
183 table_child = g_new (GtkTableChild, 1);
184 table_child->widget = child;
185 table_child->left_attach = left_attach;
186 table_child->right_attach = right_attach;
187 table_child->top_attach = top_attach;
188 table_child->bottom_attach = bottom_attach;
189 table_child->xexpand = (xoptions & GTK_EXPAND) != 0;
190 table_child->xshrink = (xoptions & GTK_SHRINK) != 0;
191 table_child->xfill = (xoptions & GTK_FILL) != 0;
192 table_child->xpadding = xpadding;
193 table_child->yexpand = (yoptions & GTK_EXPAND) != 0;
194 table_child->yshrink = (yoptions & GTK_SHRINK) != 0;
195 table_child->yfill = (yoptions & GTK_FILL) != 0;
196 table_child->ypadding = ypadding;
198 table->children = g_list_prepend (table->children, table_child);
200 gtk_widget_set_parent (child, GTK_WIDGET (table));
202 if (GTK_WIDGET_VISIBLE (GTK_WIDGET (table)))
204 if (GTK_WIDGET_REALIZED (GTK_WIDGET (table)) &&
205 !GTK_WIDGET_REALIZED (child))
206 gtk_widget_realize (child);
208 if (GTK_WIDGET_MAPPED (GTK_WIDGET (table)) &&
209 !GTK_WIDGET_MAPPED (child))
210 gtk_widget_map (child);
213 if (GTK_WIDGET_VISIBLE (child) && GTK_WIDGET_VISIBLE (table))
214 gtk_widget_queue_resize (child);
218 gtk_table_attach_defaults (GtkTable *table,
225 gtk_table_attach (table, widget,
226 left_attach, right_attach,
227 top_attach, bottom_attach,
228 GTK_EXPAND | GTK_FILL,
229 GTK_EXPAND | GTK_FILL,
234 gtk_table_set_row_spacing (GtkTable *table,
238 g_return_if_fail (table != NULL);
239 g_return_if_fail (GTK_IS_TABLE (table));
240 g_return_if_fail ((row >= 0) && (row < (table->nrows - 1)));
242 if (table->rows[row].spacing != spacing)
244 table->rows[row].spacing = spacing;
246 if (GTK_WIDGET_VISIBLE (table))
247 gtk_widget_queue_resize (GTK_WIDGET (table));
252 gtk_table_set_col_spacing (GtkTable *table,
256 g_return_if_fail (table != NULL);
257 g_return_if_fail (GTK_IS_TABLE (table));
258 g_return_if_fail ((column >= 0) && (column < (table->ncols - 1)));
260 if (table->cols[column].spacing != spacing)
262 table->cols[column].spacing = spacing;
264 if (GTK_WIDGET_VISIBLE (table))
265 gtk_widget_queue_resize (GTK_WIDGET (table));
270 gtk_table_set_row_spacings (GtkTable *table,
275 g_return_if_fail (table != NULL);
276 g_return_if_fail (GTK_IS_TABLE (table));
278 for (row = 0; row < table->nrows - 1; row++)
279 table->rows[row].spacing = spacing;
281 if (GTK_WIDGET_VISIBLE (table))
282 gtk_widget_queue_resize (GTK_WIDGET (table));
286 gtk_table_set_col_spacings (GtkTable *table,
291 g_return_if_fail (table != NULL);
292 g_return_if_fail (GTK_IS_TABLE (table));
294 for (col = 0; col < table->ncols - 1; col++)
295 table->cols[col].spacing = spacing;
297 if (GTK_WIDGET_VISIBLE (table))
298 gtk_widget_queue_resize (GTK_WIDGET (table));
303 gtk_table_destroy (GtkObject *object)
306 GtkTableChild *child;
309 g_return_if_fail (object != NULL);
310 g_return_if_fail (GTK_IS_TABLE (object));
312 table = GTK_TABLE (object);
314 children = table->children;
317 child = children->data;
318 children = children->next;
320 child->widget->parent = NULL;
321 gtk_object_unref (GTK_OBJECT (child->widget));
322 gtk_widget_destroy (child->widget);
326 g_list_free (table->children);
327 g_free (table->rows);
328 g_free (table->cols);
330 if (GTK_OBJECT_CLASS (parent_class)->destroy)
331 (* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
335 gtk_table_map (GtkWidget *widget)
338 GtkTableChild *child;
341 g_return_if_fail (widget != NULL);
342 g_return_if_fail (GTK_IS_TABLE (widget));
344 table = GTK_TABLE (widget);
345 GTK_WIDGET_SET_FLAGS (table, GTK_MAPPED);
347 children = table->children;
350 child = children->data;
351 children = children->next;
353 if (GTK_WIDGET_VISIBLE (child->widget) &&
354 !GTK_WIDGET_MAPPED (child->widget))
355 gtk_widget_map (child->widget);
360 gtk_table_unmap (GtkWidget *widget)
363 GtkTableChild *child;
366 g_return_if_fail (widget != NULL);
367 g_return_if_fail (GTK_IS_TABLE (widget));
369 table = GTK_TABLE (widget);
370 GTK_WIDGET_UNSET_FLAGS (table, GTK_MAPPED);
372 children = table->children;
375 child = children->data;
376 children = children->next;
378 if (GTK_WIDGET_VISIBLE (child->widget) &&
379 GTK_WIDGET_MAPPED (child->widget))
380 gtk_widget_unmap (child->widget);
385 gtk_table_draw (GtkWidget *widget,
389 GtkTableChild *child;
391 GdkRectangle child_area;
393 g_return_if_fail (widget != NULL);
394 g_return_if_fail (GTK_IS_TABLE (widget));
396 if (GTK_WIDGET_VISIBLE (widget) && GTK_WIDGET_MAPPED (widget))
398 table = GTK_TABLE (widget);
400 children = table->children;
403 child = children->data;
404 children = children->next;
406 if (gtk_widget_intersect (child->widget, area, &child_area))
407 gtk_widget_draw (child->widget, &child_area);
413 gtk_table_expose (GtkWidget *widget,
414 GdkEventExpose *event)
417 GtkTableChild *child;
419 GdkEventExpose child_event;
421 g_return_val_if_fail (widget != NULL, FALSE);
422 g_return_val_if_fail (GTK_IS_TABLE (widget), FALSE);
424 if (GTK_WIDGET_VISIBLE (widget) && GTK_WIDGET_MAPPED (widget))
426 table = GTK_TABLE (widget);
428 child_event = *event;
430 children = table->children;
433 child = children->data;
434 children = children->next;
436 if (GTK_WIDGET_NO_WINDOW (child->widget) &&
437 gtk_widget_intersect (child->widget, &event->area, &child_event.area))
438 gtk_widget_event (child->widget, (GdkEvent*) &child_event);
446 gtk_table_size_request (GtkWidget *widget,
447 GtkRequisition *requisition)
452 g_return_if_fail (widget != NULL);
453 g_return_if_fail (GTK_IS_TABLE (widget));
454 g_return_if_fail (requisition != NULL);
456 table = GTK_TABLE (widget);
458 requisition->width = 0;
459 requisition->height = 0;
461 gtk_table_size_request_init (table);
462 gtk_table_size_request_pass1 (table);
463 gtk_table_size_request_pass2 (table);
464 gtk_table_size_request_pass3 (table);
465 gtk_table_size_request_pass2 (table);
467 for (col = 0; col < table->ncols; col++)
468 requisition->width += table->cols[col].requisition;
469 for (col = 0; col < table->ncols - 1; col++)
470 requisition->width += table->cols[col].spacing;
472 for (row = 0; row < table->nrows; row++)
473 requisition->height += table->rows[row].requisition;
474 for (row = 0; row < table->nrows - 1; row++)
475 requisition->height += table->rows[row].spacing;
477 requisition->width += GTK_CONTAINER (table)->border_width * 2;
478 requisition->height += GTK_CONTAINER (table)->border_width * 2;
482 gtk_table_size_allocate (GtkWidget *widget,
483 GtkAllocation *allocation)
487 g_return_if_fail (widget != NULL);
488 g_return_if_fail (GTK_IS_TABLE (widget));
489 g_return_if_fail (allocation != NULL);
491 widget->allocation = *allocation;
492 table = GTK_TABLE (widget);
494 gtk_table_size_allocate_init (table);
495 gtk_table_size_allocate_pass1 (table);
496 gtk_table_size_allocate_pass2 (table);
500 gtk_table_add (GtkContainer *container,
503 g_return_if_fail (container != NULL);
504 g_return_if_fail (GTK_IS_TABLE (container));
505 g_return_if_fail (widget != NULL);
507 gtk_table_attach_defaults (GTK_TABLE (container), widget, 0, 1, 0, 1);
511 gtk_table_remove (GtkContainer *container,
515 GtkTableChild *child;
518 g_return_if_fail (container != NULL);
519 g_return_if_fail (GTK_IS_TABLE (container));
520 g_return_if_fail (widget != NULL);
522 table = GTK_TABLE (container);
523 children = table->children;
527 child = children->data;
528 children = children->next;
530 if (child->widget == widget)
532 gtk_widget_unparent (widget);
534 table->children = g_list_remove (table->children, child);
537 if (GTK_WIDGET_VISIBLE (widget) && GTK_WIDGET_VISIBLE (container))
538 gtk_widget_queue_resize (GTK_WIDGET (container));
545 gtk_table_foreach (GtkContainer *container,
546 GtkCallback callback,
547 gpointer callback_data)
550 GtkTableChild *child;
553 g_return_if_fail (container != NULL);
554 g_return_if_fail (GTK_IS_TABLE (container));
555 g_return_if_fail (callback != NULL);
557 table = GTK_TABLE (container);
558 children = table->children;
562 child = children->data;
563 children = children->next;
565 (* callback) (child->widget, callback_data);
570 gtk_table_size_request_init (GtkTable *table)
572 GtkTableChild *child;
576 for (row = 0; row < table->nrows; row++)
577 table->rows[row].requisition = 0;
578 for (col = 0; col < table->ncols; col++)
579 table->cols[col].requisition = 0;
581 children = table->children;
584 child = children->data;
585 children = children->next;
587 if (GTK_WIDGET_VISIBLE (child->widget))
588 gtk_widget_size_request (child->widget, &child->widget->requisition);
593 gtk_table_size_request_pass1 (GtkTable *table)
595 GtkTableChild *child;
600 children = table->children;
603 child = children->data;
604 children = children->next;
606 if (GTK_WIDGET_VISIBLE (child->widget))
608 /* Child spans a single column.
610 if (child->left_attach == (child->right_attach - 1))
612 width = child->widget->requisition.width + child->xpadding * 2;
613 table->cols[child->left_attach].requisition = MAX (table->cols[child->left_attach].requisition, width);
616 /* Child spans a single row.
618 if (child->top_attach == (child->bottom_attach - 1))
620 height = child->widget->requisition.height + child->ypadding * 2;
621 table->rows[child->top_attach].requisition = MAX (table->rows[child->top_attach].requisition, height);
628 gtk_table_size_request_pass2 (GtkTable *table)
634 if (table->homogeneous)
639 for (col = 0; col < table->ncols; col++)
640 max_width = MAX (max_width, table->cols[col].requisition);
641 for (row = 0; row < table->nrows; row++)
642 max_height = MAX (max_height, table->rows[row].requisition);
644 for (col = 0; col < table->ncols; col++)
645 table->cols[col].requisition = max_width;
646 for (row = 0; row < table->nrows; row++)
647 table->rows[row].requisition = max_height;
652 gtk_table_size_request_pass3 (GtkTable *table)
654 GtkTableChild *child;
660 children = table->children;
663 child = children->data;
664 children = children->next;
666 if (GTK_WIDGET_VISIBLE (child->widget))
668 /* Child spans multiple columns.
670 if (child->left_attach != (child->right_attach - 1))
672 /* Check and see if there is already enough space
676 for (col = child->left_attach; col < child->right_attach; col++)
678 width += table->cols[col].requisition;
679 if ((col + 1) < child->right_attach)
680 width += table->cols[col].spacing;
683 /* If we need to request more space for this child to fill
684 * its requisition, then divide up the needed space evenly
685 * amongst the columns it spans.
687 if (width < child->widget->requisition.width)
689 width = child->widget->requisition.width - width;
690 extra = width / (child->right_attach - child->left_attach);
692 for (col = child->left_attach; col < child->right_attach; col++)
694 if ((col + 1) < child->right_attach)
695 table->cols[col].requisition += extra;
697 table->cols[col].requisition += width;
703 /* Child spans multiple rows.
705 if (child->top_attach != (child->bottom_attach - 1))
707 /* Check and see if there is already enough space
711 for (row = child->top_attach; row < child->bottom_attach; row++)
713 height += table->rows[row].requisition;
714 if ((row + 1) < child->bottom_attach)
715 height += table->rows[row].spacing;
718 /* If we need to request more space for this child to fill
719 * its requisition, then divide up the needed space evenly
720 * amongst the columns it spans.
722 if (height < child->widget->requisition.height)
724 height = child->widget->requisition.height - height;
725 extra = height / (child->bottom_attach - child->top_attach);
727 for (row = child->top_attach; row < child->bottom_attach; row++)
729 if ((row + 1) < child->bottom_attach)
730 table->rows[row].requisition += extra;
732 table->rows[row].requisition += height;
742 gtk_table_size_allocate_init (GtkTable *table)
744 GtkTableChild *child;
750 /* Initialize the rows and cols.
751 * By default, rows and cols do not expand and do shrink.
752 * Those values are modified by the children that occupy
755 for (col = 0; col < table->ncols; col++)
757 table->cols[col].allocation = table->cols[col].requisition;
758 table->cols[col].need_expand = FALSE;
759 table->cols[col].need_shrink = TRUE;
760 table->cols[col].expand = FALSE;
761 table->cols[col].shrink = TRUE;
763 for (row = 0; row < table->nrows; row++)
765 table->rows[row].allocation = table->rows[row].requisition;
766 table->rows[row].need_expand = FALSE;
767 table->rows[row].need_shrink = TRUE;
768 table->rows[row].expand = FALSE;
769 table->rows[row].shrink = TRUE;
772 /* Loop over all the children and adjust the row and col values
773 * based on whether the children want to be allowed to expand
774 * or shrink. This loop handles children that occupy a single
777 children = table->children;
780 child = children->data;
781 children = children->next;
783 if (GTK_WIDGET_VISIBLE (child->widget))
785 if (child->left_attach == (child->right_attach - 1))
788 table->cols[child->left_attach].expand = TRUE;
791 table->cols[child->left_attach].shrink = FALSE;
794 if (child->top_attach == (child->bottom_attach - 1))
797 table->rows[child->top_attach].expand = TRUE;
800 table->rows[child->top_attach].shrink = FALSE;
805 /* Loop over all the children again and this time handle children
806 * which span multiple rows or columns.
808 children = table->children;
811 child = children->data;
812 children = children->next;
814 if (GTK_WIDGET_VISIBLE (child->widget))
816 if (child->left_attach != (child->right_attach - 1))
821 for (col = child->left_attach; col < child->right_attach; col++)
822 if (table->cols[col].expand)
829 for (col = child->left_attach; col < child->right_attach; col++)
830 table->cols[col].need_expand = TRUE;
836 for (col = child->left_attach; col < child->right_attach; col++)
837 if (!table->cols[col].shrink)
844 for (col = child->left_attach; col < child->right_attach; col++)
845 table->cols[col].need_shrink = FALSE;
849 if (child->top_attach != (child->bottom_attach - 1))
854 for (row = child->top_attach; row < child->bottom_attach; row++)
855 if (table->rows[row].expand)
862 for (row = child->top_attach; row < child->bottom_attach; row++)
863 table->rows[row].need_expand = TRUE;
869 for (row = child->top_attach; row < child->bottom_attach; row++)
870 if (!table->rows[row].shrink)
877 for (row = child->top_attach; row < child->bottom_attach; row++)
878 table->rows[row].need_shrink = FALSE;
884 /* Loop over the columns and set the expand and shrink values
885 * if the column can be expanded or shrunk.
887 for (col = 0; col < table->ncols; col++)
889 if (table->cols[col].need_expand)
890 table->cols[col].expand = TRUE;
891 if (!table->cols[col].need_shrink)
892 table->cols[col].shrink = FALSE;
895 /* Loop over the rows and set the expand and shrink values
896 * if the row can be expanded or shrunk.
898 for (row = 0; row < table->nrows; row++)
900 if (table->rows[row].need_expand)
901 table->rows[row].expand = TRUE;
902 if (!table->rows[row].need_shrink)
903 table->rows[row].shrink = FALSE;
908 gtk_table_size_allocate_pass1 (GtkTable *table)
918 /* If we were allocated more space than we requested
919 * then we have to expand any expandable rows and columns
920 * to fill in the extra space.
923 real_width = GTK_WIDGET (table)->allocation.width - GTK_CONTAINER (table)->border_width * 2;
924 real_height = GTK_WIDGET (table)->allocation.height - GTK_CONTAINER (table)->border_width * 2;
926 if (table->homogeneous)
929 for (col = 0; col < table->ncols; col++)
930 if (table->cols[col].expand)
940 for (col = 0; col < table->ncols - 1; col++)
941 width -= table->cols[col].spacing;
943 extra = width / table->ncols;
945 for (col = 0; col < table->ncols; col++)
947 if ((col + 1) == table->ncols)
948 table->cols[col].allocation = width;
950 table->cols[col].allocation = extra;
962 for (col = 0; col < table->ncols; col++)
964 width += table->cols[col].requisition;
965 if (table->cols[col].expand)
967 if (table->cols[col].shrink)
970 for (col = 0; col < table->ncols - 1; col++)
971 width += table->cols[col].spacing;
973 /* Check to see if we were allocated more width than we requested.
975 if ((width < real_width) && (nexpand >= 1))
977 width = real_width - width;
978 extra = width / nexpand;
980 for (col = 0; col < table->ncols; col++)
981 if (table->cols[col].expand)
984 table->cols[col].allocation += width;
986 table->cols[col].allocation += extra;
993 /* Check to see if we were allocated less width than we requested.
995 if ((width > real_width) && (nshrink >= 1))
997 width = width - real_width;
998 extra = width / nshrink;
1000 for (col = 0; col < table->ncols; col++)
1001 if (table->cols[col].shrink)
1004 table->cols[col].allocation -= width;
1006 table->cols[col].allocation -= extra;
1014 if (table->homogeneous)
1017 for (row = 0; row < table->nrows; row++)
1018 if (table->rows[row].expand)
1026 height = real_height;
1028 for (row = 0; row < table->nrows - 1; row++)
1029 height -= table->rows[row].spacing;
1031 extra = height / table->nrows;
1033 for (row = 0; row < table->nrows; row++)
1035 if ((row + 1) == table->nrows)
1036 table->rows[row].allocation = height;
1038 table->rows[row].allocation = extra;
1050 for (row = 0; row < table->nrows; row++)
1052 height += table->rows[row].requisition;
1053 if (table->rows[row].expand)
1055 if (table->rows[row].shrink)
1058 for (row = 0; row < table->nrows - 1; row++)
1059 height += table->rows[row].spacing;
1061 /* Check to see if we were allocated more height than we requested.
1063 if ((height < real_height) && (nexpand >= 1))
1065 height = real_height - height;
1066 extra = height / nexpand;
1068 for (row = 0; row < table->nrows; row++)
1069 if (table->rows[row].expand)
1072 table->rows[row].allocation += height;
1074 table->rows[row].allocation += extra;
1081 /* Check to see if we were allocated less height than we requested.
1083 if ((height > real_height) && (nshrink >= 1))
1085 height = height - real_height;
1086 extra = height / nshrink;
1088 for (row = 0; row < table->nrows; row++)
1089 if (table->rows[row].shrink)
1092 table->rows[row].allocation -= height;
1094 table->rows[row].allocation -= extra;
1104 gtk_table_size_allocate_pass2 (GtkTable *table)
1106 GtkTableChild *child;
1112 GtkAllocation allocation;
1114 children = table->children;
1117 child = children->data;
1118 children = children->next;
1120 if (GTK_WIDGET_VISIBLE (child->widget))
1122 x = GTK_WIDGET (table)->allocation.x + GTK_CONTAINER (table)->border_width;
1123 y = GTK_WIDGET (table)->allocation.y + GTK_CONTAINER (table)->border_width;
1127 for (col = 0; col < child->left_attach; col++)
1129 x += table->cols[col].allocation;
1130 x += table->cols[col].spacing;
1133 for (col = child->left_attach; col < child->right_attach; col++)
1135 max_width += table->cols[col].allocation;
1136 if ((col + 1) < child->right_attach)
1137 max_width += table->cols[col].spacing;
1140 for (row = 0; row < child->top_attach; row++)
1142 y += table->rows[row].allocation;
1143 y += table->rows[row].spacing;
1146 for (row = child->top_attach; row < child->bottom_attach; row++)
1148 max_height += table->rows[row].allocation;
1149 if ((row + 1) < child->bottom_attach)
1150 max_height += table->rows[row].spacing;
1155 allocation.width = max_width - child->xpadding * 2;
1156 allocation.x = x + (max_width - allocation.width) / 2;
1160 allocation.width = child->widget->requisition.width;
1161 allocation.x = x + (max_width - allocation.width) / 2;
1166 allocation.height = max_height - child->ypadding * 2;
1167 allocation.y = y + (max_height - allocation.height) / 2;
1171 allocation.height = child->widget->requisition.height;
1172 allocation.y = y + (max_height - allocation.height) / 2;
1175 gtk_widget_size_allocate (child->widget, &allocation);