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_finalize (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,
73 table_type = gtk_type_unique (gtk_container_get_type (), &table_info);
80 gtk_table_class_init (GtkTableClass *class)
82 GtkObjectClass *object_class;
83 GtkWidgetClass *widget_class;
84 GtkContainerClass *container_class;
86 object_class = (GtkObjectClass*) class;
87 widget_class = (GtkWidgetClass*) class;
88 container_class = (GtkContainerClass*) class;
90 parent_class = gtk_type_class (gtk_container_get_type ());
92 object_class->finalize = gtk_table_finalize;
94 widget_class->map = gtk_table_map;
95 widget_class->unmap = gtk_table_unmap;
96 widget_class->draw = gtk_table_draw;
97 widget_class->expose_event = gtk_table_expose;
98 widget_class->size_request = gtk_table_size_request;
99 widget_class->size_allocate = gtk_table_size_allocate;
101 container_class->add = gtk_table_add;
102 container_class->remove = gtk_table_remove;
103 container_class->foreach = gtk_table_foreach;
107 gtk_table_init (GtkTable *table)
109 GTK_WIDGET_SET_FLAGS (table, GTK_NO_WINDOW | GTK_BASIC);
111 table->children = NULL;
116 table->homogeneous = FALSE;
120 gtk_table_init_rows (GtkTable *table, int start, int end)
122 const int spacing = table->row_spacing;
125 for (row = start; row < end; row++)
127 table->rows[row].requisition = 0;
128 table->rows[row].allocation = 0;
129 table->rows[row].spacing = spacing;
130 table->rows[row].need_expand = 0;
131 table->rows[row].need_shrink = 0;
132 table->rows[row].expand = 0;
133 table->rows[row].shrink = 0;
138 gtk_table_init_cols (GtkTable *table, int start, int end)
140 const int spacing = table->column_spacing;
143 for (col = start; col < end; col++)
145 table->cols[col].requisition = 0;
146 table->cols[col].allocation = 0;
147 table->cols[col].spacing = spacing;
148 table->cols[col].need_expand = 0;
149 table->cols[col].need_shrink = 0;
150 table->cols[col].expand = 0;
151 table->cols[col].shrink = 0;
156 gtk_table_new (gint rows,
162 table = gtk_type_new (gtk_table_get_type ());
165 table->ncols = columns;
166 table->homogeneous = (homogeneous ? TRUE : FALSE);
167 table->column_spacing = 0;
168 table->row_spacing = 0;
170 table->rows = g_new (GtkTableRowCol, table->nrows);
171 table->cols = g_new (GtkTableRowCol, table->ncols);
173 gtk_table_init_rows (table, 0, table->nrows);
174 gtk_table_init_cols (table, 0, table->ncols);
176 return GTK_WIDGET (table);
180 gtk_table_expand_cols (GtkTable *table, int new_max)
182 table->cols = g_realloc (table->cols, new_max * sizeof (GtkTableRowCol));
183 gtk_table_init_cols (table, table->ncols, new_max);
184 table->ncols = new_max;
188 gtk_table_expand_rows (GtkTable *table, int new_max)
190 table->rows = g_realloc (table->rows, new_max * sizeof (GtkTableRowCol));
191 gtk_table_init_rows (table, table->nrows, new_max);
192 table->nrows = new_max;
196 gtk_table_attach (GtkTable *table,
207 GtkTableChild *table_child;
209 g_return_if_fail (table != NULL);
210 g_return_if_fail (GTK_IS_TABLE (table));
211 g_return_if_fail (child != NULL);
213 g_return_if_fail (left_attach >= 0);
214 g_return_if_fail (left_attach < right_attach);
215 g_return_if_fail (top_attach >= 0);
216 g_return_if_fail (top_attach < bottom_attach);
218 if (right_attach >= table->ncols)
219 gtk_table_expand_cols (table, right_attach);
221 if (bottom_attach >= table->nrows)
222 gtk_table_expand_rows (table, bottom_attach);
224 table_child = g_new (GtkTableChild, 1);
225 table_child->widget = child;
226 table_child->left_attach = left_attach;
227 table_child->right_attach = right_attach;
228 table_child->top_attach = top_attach;
229 table_child->bottom_attach = bottom_attach;
230 table_child->xexpand = (xoptions & GTK_EXPAND) != 0;
231 table_child->xshrink = (xoptions & GTK_SHRINK) != 0;
232 table_child->xfill = (xoptions & GTK_FILL) != 0;
233 table_child->xpadding = xpadding;
234 table_child->yexpand = (yoptions & GTK_EXPAND) != 0;
235 table_child->yshrink = (yoptions & GTK_SHRINK) != 0;
236 table_child->yfill = (yoptions & GTK_FILL) != 0;
237 table_child->ypadding = ypadding;
239 table->children = g_list_prepend (table->children, table_child);
241 gtk_widget_set_parent (child, GTK_WIDGET (table));
243 if (GTK_WIDGET_VISIBLE (GTK_WIDGET (table)))
245 if (GTK_WIDGET_REALIZED (GTK_WIDGET (table)) &&
246 !GTK_WIDGET_REALIZED (child))
247 gtk_widget_realize (child);
249 if (GTK_WIDGET_MAPPED (GTK_WIDGET (table)) &&
250 !GTK_WIDGET_MAPPED (child))
251 gtk_widget_map (child);
254 if (GTK_WIDGET_VISIBLE (child) && GTK_WIDGET_VISIBLE (table))
255 gtk_widget_queue_resize (child);
259 gtk_table_attach_defaults (GtkTable *table,
266 gtk_table_attach (table, widget,
267 left_attach, right_attach,
268 top_attach, bottom_attach,
269 GTK_EXPAND | GTK_FILL,
270 GTK_EXPAND | GTK_FILL,
275 gtk_table_set_row_spacing (GtkTable *table,
279 g_return_if_fail (table != NULL);
280 g_return_if_fail (GTK_IS_TABLE (table));
281 g_return_if_fail ((row >= 0) && (row < (table->nrows - 1)));
283 if (table->rows[row].spacing != spacing)
285 table->rows[row].spacing = spacing;
287 if (GTK_WIDGET_VISIBLE (table))
288 gtk_widget_queue_resize (GTK_WIDGET (table));
293 gtk_table_set_col_spacing (GtkTable *table,
297 g_return_if_fail (table != NULL);
298 g_return_if_fail (GTK_IS_TABLE (table));
299 g_return_if_fail ((column >= 0) && (column < (table->ncols - 1)));
301 if (table->cols[column].spacing != spacing)
303 table->cols[column].spacing = spacing;
305 if (GTK_WIDGET_VISIBLE (table))
306 gtk_widget_queue_resize (GTK_WIDGET (table));
311 gtk_table_set_row_spacings (GtkTable *table,
316 g_return_if_fail (table != NULL);
317 g_return_if_fail (GTK_IS_TABLE (table));
319 table->row_spacing = spacing;
320 for (row = 0; row < table->nrows - 1; row++)
321 table->rows[row].spacing = spacing;
323 if (GTK_WIDGET_VISIBLE (table))
324 gtk_widget_queue_resize (GTK_WIDGET (table));
328 gtk_table_set_col_spacings (GtkTable *table,
333 g_return_if_fail (table != NULL);
334 g_return_if_fail (GTK_IS_TABLE (table));
336 table->column_spacing = spacing;
337 for (col = 0; col < table->ncols - 1; col++)
338 table->cols[col].spacing = spacing;
340 if (GTK_WIDGET_VISIBLE (table))
341 gtk_widget_queue_resize (GTK_WIDGET (table));
345 gtk_table_set_homogeneous (GtkTable *table,
348 g_return_if_fail (table != NULL);
349 g_return_if_fail (GTK_IS_TABLE (table));
351 table->homogeneous = (homogeneous != 0);
353 if (GTK_WIDGET_VISIBLE (table))
354 gtk_widget_queue_resize (GTK_WIDGET (table));
359 gtk_table_finalize (GtkObject *object)
363 g_return_if_fail (object != NULL);
364 g_return_if_fail (GTK_IS_TABLE (object));
366 table = GTK_TABLE (object);
368 g_free (table->rows);
369 g_free (table->cols);
371 (* GTK_OBJECT_CLASS (parent_class)->finalize) (object);
375 gtk_table_map (GtkWidget *widget)
378 GtkTableChild *child;
381 g_return_if_fail (widget != NULL);
382 g_return_if_fail (GTK_IS_TABLE (widget));
384 table = GTK_TABLE (widget);
385 GTK_WIDGET_SET_FLAGS (table, GTK_MAPPED);
387 children = table->children;
390 child = children->data;
391 children = children->next;
393 if (GTK_WIDGET_VISIBLE (child->widget) &&
394 !GTK_WIDGET_MAPPED (child->widget))
395 gtk_widget_map (child->widget);
400 gtk_table_unmap (GtkWidget *widget)
403 GtkTableChild *child;
406 g_return_if_fail (widget != NULL);
407 g_return_if_fail (GTK_IS_TABLE (widget));
409 table = GTK_TABLE (widget);
410 GTK_WIDGET_UNSET_FLAGS (table, GTK_MAPPED);
412 children = table->children;
415 child = children->data;
416 children = children->next;
418 if (GTK_WIDGET_VISIBLE (child->widget) &&
419 GTK_WIDGET_MAPPED (child->widget))
420 gtk_widget_unmap (child->widget);
425 gtk_table_draw (GtkWidget *widget,
429 GtkTableChild *child;
431 GdkRectangle child_area;
433 g_return_if_fail (widget != NULL);
434 g_return_if_fail (GTK_IS_TABLE (widget));
436 if (GTK_WIDGET_VISIBLE (widget) && GTK_WIDGET_MAPPED (widget))
438 table = GTK_TABLE (widget);
440 children = table->children;
443 child = children->data;
444 children = children->next;
446 if (gtk_widget_intersect (child->widget, area, &child_area))
447 gtk_widget_draw (child->widget, &child_area);
453 gtk_table_expose (GtkWidget *widget,
454 GdkEventExpose *event)
457 GtkTableChild *child;
459 GdkEventExpose child_event;
461 g_return_val_if_fail (widget != NULL, FALSE);
462 g_return_val_if_fail (GTK_IS_TABLE (widget), FALSE);
464 if (GTK_WIDGET_VISIBLE (widget) && GTK_WIDGET_MAPPED (widget))
466 table = GTK_TABLE (widget);
468 child_event = *event;
470 children = table->children;
473 child = children->data;
474 children = children->next;
476 if (GTK_WIDGET_NO_WINDOW (child->widget) &&
477 gtk_widget_intersect (child->widget, &event->area, &child_event.area))
478 gtk_widget_event (child->widget, (GdkEvent*) &child_event);
486 gtk_table_size_request (GtkWidget *widget,
487 GtkRequisition *requisition)
492 g_return_if_fail (widget != NULL);
493 g_return_if_fail (GTK_IS_TABLE (widget));
494 g_return_if_fail (requisition != NULL);
496 table = GTK_TABLE (widget);
498 requisition->width = 0;
499 requisition->height = 0;
501 gtk_table_size_request_init (table);
502 gtk_table_size_request_pass1 (table);
503 gtk_table_size_request_pass2 (table);
504 gtk_table_size_request_pass3 (table);
505 gtk_table_size_request_pass2 (table);
507 for (col = 0; col < table->ncols; col++)
508 requisition->width += table->cols[col].requisition;
509 for (col = 0; col < table->ncols - 1; col++)
510 requisition->width += table->cols[col].spacing;
512 for (row = 0; row < table->nrows; row++)
513 requisition->height += table->rows[row].requisition;
514 for (row = 0; row < table->nrows - 1; row++)
515 requisition->height += table->rows[row].spacing;
517 requisition->width += GTK_CONTAINER (table)->border_width * 2;
518 requisition->height += GTK_CONTAINER (table)->border_width * 2;
522 gtk_table_size_allocate (GtkWidget *widget,
523 GtkAllocation *allocation)
527 g_return_if_fail (widget != NULL);
528 g_return_if_fail (GTK_IS_TABLE (widget));
529 g_return_if_fail (allocation != NULL);
531 widget->allocation = *allocation;
532 table = GTK_TABLE (widget);
534 gtk_table_size_allocate_init (table);
535 gtk_table_size_allocate_pass1 (table);
536 gtk_table_size_allocate_pass2 (table);
540 gtk_table_add (GtkContainer *container,
543 g_return_if_fail (container != NULL);
544 g_return_if_fail (GTK_IS_TABLE (container));
545 g_return_if_fail (widget != NULL);
547 gtk_table_attach_defaults (GTK_TABLE (container), widget, 0, 1, 0, 1);
551 gtk_table_remove (GtkContainer *container,
555 GtkTableChild *child;
558 g_return_if_fail (container != NULL);
559 g_return_if_fail (GTK_IS_TABLE (container));
560 g_return_if_fail (widget != NULL);
562 table = GTK_TABLE (container);
563 children = table->children;
567 child = children->data;
568 children = children->next;
570 if (child->widget == widget)
572 gtk_widget_unparent (widget);
574 table->children = g_list_remove (table->children, child);
577 if (GTK_WIDGET_VISIBLE (widget) && GTK_WIDGET_VISIBLE (container))
578 gtk_widget_queue_resize (GTK_WIDGET (container));
585 gtk_table_foreach (GtkContainer *container,
586 GtkCallback callback,
587 gpointer callback_data)
590 GtkTableChild *child;
593 g_return_if_fail (container != NULL);
594 g_return_if_fail (GTK_IS_TABLE (container));
595 g_return_if_fail (callback != NULL);
597 table = GTK_TABLE (container);
598 children = table->children;
602 child = children->data;
603 children = children->next;
605 (* callback) (child->widget, callback_data);
610 gtk_table_size_request_init (GtkTable *table)
612 GtkTableChild *child;
616 for (row = 0; row < table->nrows; row++)
617 table->rows[row].requisition = 0;
618 for (col = 0; col < table->ncols; col++)
619 table->cols[col].requisition = 0;
621 children = table->children;
624 child = children->data;
625 children = children->next;
627 if (GTK_WIDGET_VISIBLE (child->widget))
628 gtk_widget_size_request (child->widget, &child->widget->requisition);
633 gtk_table_size_request_pass1 (GtkTable *table)
635 GtkTableChild *child;
640 children = table->children;
643 child = children->data;
644 children = children->next;
646 if (GTK_WIDGET_VISIBLE (child->widget))
648 /* Child spans a single column.
650 if (child->left_attach == (child->right_attach - 1))
652 width = child->widget->requisition.width + child->xpadding * 2;
653 table->cols[child->left_attach].requisition = MAX (table->cols[child->left_attach].requisition, width);
656 /* Child spans a single row.
658 if (child->top_attach == (child->bottom_attach - 1))
660 height = child->widget->requisition.height + child->ypadding * 2;
661 table->rows[child->top_attach].requisition = MAX (table->rows[child->top_attach].requisition, height);
668 gtk_table_size_request_pass2 (GtkTable *table)
674 if (table->homogeneous)
679 for (col = 0; col < table->ncols; col++)
680 max_width = MAX (max_width, table->cols[col].requisition);
681 for (row = 0; row < table->nrows; row++)
682 max_height = MAX (max_height, table->rows[row].requisition);
684 for (col = 0; col < table->ncols; col++)
685 table->cols[col].requisition = max_width;
686 for (row = 0; row < table->nrows; row++)
687 table->rows[row].requisition = max_height;
692 gtk_table_size_request_pass3 (GtkTable *table)
694 GtkTableChild *child;
700 children = table->children;
703 child = children->data;
704 children = children->next;
706 if (GTK_WIDGET_VISIBLE (child->widget))
708 /* Child spans multiple columns.
710 if (child->left_attach != (child->right_attach - 1))
712 /* Check and see if there is already enough space
716 for (col = child->left_attach; col < child->right_attach; col++)
718 width += table->cols[col].requisition;
719 if ((col + 1) < child->right_attach)
720 width += table->cols[col].spacing;
723 /* If we need to request more space for this child to fill
724 * its requisition, then divide up the needed space evenly
725 * amongst the columns it spans.
727 if (width < child->widget->requisition.width)
729 width = child->widget->requisition.width - width;
731 for (col = child->left_attach; col < child->right_attach; col++)
733 extra = width / (child->right_attach - col);
734 table->cols[col].requisition += extra;
740 /* Child spans multiple rows.
742 if (child->top_attach != (child->bottom_attach - 1))
744 /* Check and see if there is already enough space
748 for (row = child->top_attach; row < child->bottom_attach; row++)
750 height += table->rows[row].requisition;
751 if ((row + 1) < child->bottom_attach)
752 height += table->rows[row].spacing;
755 /* If we need to request more space for this child to fill
756 * its requisition, then divide up the needed space evenly
757 * amongst the columns it spans.
759 if (height < child->widget->requisition.height)
761 height = child->widget->requisition.height - height;
763 for (row = child->top_attach; row < child->bottom_attach; row++)
765 extra = height / (child->bottom_attach - row);
766 table->rows[row].requisition += extra;
776 gtk_table_size_allocate_init (GtkTable *table)
778 GtkTableChild *child;
784 /* Initialize the rows and cols.
785 * By default, rows and cols do not expand and do shrink.
786 * Those values are modified by the children that occupy
789 for (col = 0; col < table->ncols; col++)
791 table->cols[col].allocation = table->cols[col].requisition;
792 table->cols[col].need_expand = FALSE;
793 table->cols[col].need_shrink = TRUE;
794 table->cols[col].expand = FALSE;
795 table->cols[col].shrink = TRUE;
797 for (row = 0; row < table->nrows; row++)
799 table->rows[row].allocation = table->rows[row].requisition;
800 table->rows[row].need_expand = FALSE;
801 table->rows[row].need_shrink = TRUE;
802 table->rows[row].expand = FALSE;
803 table->rows[row].shrink = TRUE;
806 /* Loop over all the children and adjust the row and col values
807 * based on whether the children want to be allowed to expand
808 * or shrink. This loop handles children that occupy a single
811 children = table->children;
814 child = children->data;
815 children = children->next;
817 if (GTK_WIDGET_VISIBLE (child->widget))
819 if (child->left_attach == (child->right_attach - 1))
822 table->cols[child->left_attach].expand = TRUE;
825 table->cols[child->left_attach].shrink = FALSE;
828 if (child->top_attach == (child->bottom_attach - 1))
831 table->rows[child->top_attach].expand = TRUE;
834 table->rows[child->top_attach].shrink = FALSE;
839 /* Loop over all the children again and this time handle children
840 * which span multiple rows or columns.
842 children = table->children;
845 child = children->data;
846 children = children->next;
848 if (GTK_WIDGET_VISIBLE (child->widget))
850 if (child->left_attach != (child->right_attach - 1))
855 for (col = child->left_attach; col < child->right_attach; col++)
856 if (table->cols[col].expand)
863 for (col = child->left_attach; col < child->right_attach; col++)
864 table->cols[col].need_expand = TRUE;
870 for (col = child->left_attach; col < child->right_attach; col++)
871 if (!table->cols[col].shrink)
878 for (col = child->left_attach; col < child->right_attach; col++)
879 table->cols[col].need_shrink = FALSE;
883 if (child->top_attach != (child->bottom_attach - 1))
888 for (row = child->top_attach; row < child->bottom_attach; row++)
889 if (table->rows[row].expand)
896 for (row = child->top_attach; row < child->bottom_attach; row++)
897 table->rows[row].need_expand = TRUE;
903 for (row = child->top_attach; row < child->bottom_attach; row++)
904 if (!table->rows[row].shrink)
911 for (row = child->top_attach; row < child->bottom_attach; row++)
912 table->rows[row].need_shrink = FALSE;
918 /* Loop over the columns and set the expand and shrink values
919 * if the column can be expanded or shrunk.
921 for (col = 0; col < table->ncols; col++)
923 if (table->cols[col].need_expand)
924 table->cols[col].expand = TRUE;
925 if (!table->cols[col].need_shrink)
926 table->cols[col].shrink = FALSE;
929 /* Loop over the rows and set the expand and shrink values
930 * if the row can be expanded or shrunk.
932 for (row = 0; row < table->nrows; row++)
934 if (table->rows[row].need_expand)
935 table->rows[row].expand = TRUE;
936 if (!table->rows[row].need_shrink)
937 table->rows[row].shrink = FALSE;
942 gtk_table_size_allocate_pass1 (GtkTable *table)
952 /* If we were allocated more space than we requested
953 * then we have to expand any expandable rows and columns
954 * to fill in the extra space.
957 real_width = GTK_WIDGET (table)->allocation.width - GTK_CONTAINER (table)->border_width * 2;
958 real_height = GTK_WIDGET (table)->allocation.height - GTK_CONTAINER (table)->border_width * 2;
960 if (table->homogeneous)
963 for (col = 0; col < table->ncols; col++)
964 if (table->cols[col].expand)
974 for (col = 0; col < table->ncols - 1; col++)
975 width -= table->cols[col].spacing;
977 for (col = 0; col < table->ncols; col++)
979 extra = width / (table->ncols - col);
980 table->cols[col].allocation = MAX (1, extra);
991 for (col = 0; col < table->ncols; col++)
993 width += table->cols[col].requisition;
994 if (table->cols[col].expand)
996 if (table->cols[col].shrink)
999 for (col = 0; col < table->ncols - 1; col++)
1000 width += table->cols[col].spacing;
1002 /* Check to see if we were allocated more width than we requested.
1004 if ((width < real_width) && (nexpand >= 1))
1006 width = real_width - width;
1008 for (col = 0; col < table->ncols; col++)
1009 if (table->cols[col].expand)
1011 extra = width / nexpand;
1012 table->cols[col].allocation += extra;
1019 /* Check to see if we were allocated less width than we requested.
1021 if ((width > real_width) && (nshrink >= 1))
1023 width = width - real_width;
1025 for (col = 0; col < table->ncols; col++)
1026 if (table->cols[col].shrink)
1028 extra = width / nshrink;
1029 table->cols[col].allocation = MAX (1, table->cols[col].allocation - extra);
1037 if (table->homogeneous)
1040 for (row = 0; row < table->nrows; row++)
1041 if (table->rows[row].expand)
1049 height = real_height;
1051 for (row = 0; row < table->nrows - 1; row++)
1052 height -= table->rows[row].spacing;
1055 for (row = 0; row < table->nrows; row++)
1057 extra = height / (table->nrows - row);
1058 table->rows[row].allocation = MAX (1, extra);
1069 for (row = 0; row < table->nrows; row++)
1071 height += table->rows[row].requisition;
1072 if (table->rows[row].expand)
1074 if (table->rows[row].shrink)
1077 for (row = 0; row < table->nrows - 1; row++)
1078 height += table->rows[row].spacing;
1080 /* Check to see if we were allocated more height than we requested.
1082 if ((height < real_height) && (nexpand >= 1))
1084 height = real_height - height;
1086 for (row = 0; row < table->nrows; row++)
1087 if (table->rows[row].expand)
1089 extra = height / nexpand;
1090 table->rows[row].allocation += extra;
1097 /* Check to see if we were allocated less height than we requested.
1099 if ((height > real_height) && (nshrink >= 1))
1101 height = height - real_height;
1103 for (row = 0; row < table->nrows; row++)
1104 if (table->rows[row].shrink)
1106 extra = height / nshrink;
1107 table->rows[row].allocation = MAX (1, table->rows[row].allocation - extra);
1117 gtk_table_size_allocate_pass2 (GtkTable *table)
1119 GtkTableChild *child;
1125 GtkAllocation allocation;
1127 children = table->children;
1130 child = children->data;
1131 children = children->next;
1133 if (GTK_WIDGET_VISIBLE (child->widget))
1135 x = GTK_WIDGET (table)->allocation.x + GTK_CONTAINER (table)->border_width;
1136 y = GTK_WIDGET (table)->allocation.y + GTK_CONTAINER (table)->border_width;
1140 for (col = 0; col < child->left_attach; col++)
1142 x += table->cols[col].allocation;
1143 x += table->cols[col].spacing;
1146 for (col = child->left_attach; col < child->right_attach; col++)
1148 max_width += table->cols[col].allocation;
1149 if ((col + 1) < child->right_attach)
1150 max_width += table->cols[col].spacing;
1153 for (row = 0; row < child->top_attach; row++)
1155 y += table->rows[row].allocation;
1156 y += table->rows[row].spacing;
1159 for (row = child->top_attach; row < child->bottom_attach; row++)
1161 max_height += table->rows[row].allocation;
1162 if ((row + 1) < child->bottom_attach)
1163 max_height += table->rows[row].spacing;
1168 allocation.width = MAX (1, max_width - child->xpadding * 2);
1169 allocation.x = x + (max_width - allocation.width) / 2;
1173 allocation.width = child->widget->requisition.width;
1174 allocation.x = x + (max_width - allocation.width) / 2;
1179 allocation.height = MAX (1, max_height - child->ypadding * 2);
1180 allocation.y = y + (max_height - allocation.height) / 2;
1184 allocation.height = child->widget->requisition.height;
1185 allocation.y = y + (max_height - allocation.height) / 2;
1188 gtk_widget_size_allocate (child->widget, &allocation);