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 Lesser 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 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
21 * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
22 * file for a list of people on the GTK+ Team. See the ChangeLog
23 * files for a list of changes. These files are distributed with
24 * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
31 #include "gtktypebuiltins.h"
32 #include "gtkprivate.h"
38 * @Short_description: Pack widgets in regular patterns
42 * The #GtkTable functions allow the programmer to arrange widgets in rows and
43 * columns, making it easy to align many widgets next to each other,
44 * horizontally and vertically.
46 * Tables are created with a call to gtk_table_new(), the size of which can
47 * later be changed with gtk_table_resize().
49 * Widgets can be added to a table using gtk_table_attach() or the more
50 * convenient (but slightly less flexible) gtk_table_attach_defaults().
52 * To alter the space next to a specific row, use gtk_table_set_row_spacing(),
53 * and for a column, gtk_table_set_col_spacing().
54 * The gaps between <emphasis>all</emphasis> rows or columns can be changed by
55 * calling gtk_table_set_row_spacings() or gtk_table_set_col_spacings()
56 * respectively. Note that spacing is added <emphasis>between</emphasis> the
57 * children, while padding added by gtk_table_attach() is added <emphasis>on
58 * either side</emphasis> of the widget it belongs to.
60 * gtk_table_set_homogeneous(), can be used to set whether all cells in the
61 * table will resize themselves to the size of the largest widget in the table.
64 * Note that #GtkGrid provides the same capabilities as GtkTable for arranging
65 * widgets in a rectangular grid, and additionally supports height-for-width
66 * geometry management.
71 struct _GtkTablePrivate
78 guint16 column_spacing;
83 guint homogeneous : 1;
99 CHILD_PROP_LEFT_ATTACH,
100 CHILD_PROP_RIGHT_ATTACH,
101 CHILD_PROP_TOP_ATTACH,
102 CHILD_PROP_BOTTOM_ATTACH,
103 CHILD_PROP_X_OPTIONS,
104 CHILD_PROP_Y_OPTIONS,
105 CHILD_PROP_X_PADDING,
110 static void gtk_table_finalize (GObject *object);
111 static void gtk_table_get_preferred_width (GtkWidget *widget,
114 static void gtk_table_get_preferred_height (GtkWidget *widget,
117 static void gtk_table_size_allocate (GtkWidget *widget,
118 GtkAllocation *allocation);
119 static void gtk_table_compute_expand (GtkWidget *widget,
122 static void gtk_table_add (GtkContainer *container,
124 static void gtk_table_remove (GtkContainer *container,
126 static void gtk_table_forall (GtkContainer *container,
127 gboolean include_internals,
128 GtkCallback callback,
129 gpointer callback_data);
130 static void gtk_table_get_property (GObject *object,
134 static void gtk_table_set_property (GObject *object,
138 static void gtk_table_set_child_property (GtkContainer *container,
143 static void gtk_table_get_child_property (GtkContainer *container,
148 static GType gtk_table_child_type (GtkContainer *container);
151 static void gtk_table_size_request_init (GtkTable *table);
152 static void gtk_table_size_request_pass1 (GtkTable *table);
153 static void gtk_table_size_request_pass2 (GtkTable *table);
154 static void gtk_table_size_request_pass3 (GtkTable *table);
156 static void gtk_table_size_allocate_init (GtkTable *table);
157 static void gtk_table_size_allocate_pass1 (GtkTable *table);
158 static void gtk_table_size_allocate_pass2 (GtkTable *table);
161 G_DEFINE_TYPE (GtkTable, gtk_table, GTK_TYPE_CONTAINER)
164 gtk_table_class_init (GtkTableClass *class)
166 GObjectClass *gobject_class = G_OBJECT_CLASS (class);
167 GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
168 GtkContainerClass *container_class = GTK_CONTAINER_CLASS (class);
170 gobject_class->finalize = gtk_table_finalize;
172 gobject_class->get_property = gtk_table_get_property;
173 gobject_class->set_property = gtk_table_set_property;
175 widget_class->get_preferred_width = gtk_table_get_preferred_width;
176 widget_class->get_preferred_height = gtk_table_get_preferred_height;
177 widget_class->size_allocate = gtk_table_size_allocate;
178 widget_class->compute_expand = gtk_table_compute_expand;
180 container_class->add = gtk_table_add;
181 container_class->remove = gtk_table_remove;
182 container_class->forall = gtk_table_forall;
183 container_class->child_type = gtk_table_child_type;
184 container_class->set_child_property = gtk_table_set_child_property;
185 container_class->get_child_property = gtk_table_get_child_property;
186 gtk_container_class_handle_border_width (container_class);
188 g_object_class_install_property (gobject_class,
190 g_param_spec_uint ("n-rows",
192 P_("The number of rows in the table"),
196 GTK_PARAM_READWRITE));
197 g_object_class_install_property (gobject_class,
199 g_param_spec_uint ("n-columns",
201 P_("The number of columns in the table"),
205 GTK_PARAM_READWRITE));
206 g_object_class_install_property (gobject_class,
208 g_param_spec_uint ("row-spacing",
210 P_("The amount of space between two consecutive rows"),
214 GTK_PARAM_READWRITE));
215 g_object_class_install_property (gobject_class,
217 g_param_spec_uint ("column-spacing",
218 P_("Column spacing"),
219 P_("The amount of space between two consecutive columns"),
223 GTK_PARAM_READWRITE));
224 g_object_class_install_property (gobject_class,
226 g_param_spec_boolean ("homogeneous",
228 P_("If TRUE, the table cells are all the same width/height"),
230 GTK_PARAM_READWRITE));
232 gtk_container_class_install_child_property (container_class,
233 CHILD_PROP_LEFT_ATTACH,
234 g_param_spec_uint ("left-attach",
235 P_("Left attachment"),
236 P_("The column number to attach the left side of the child to"),
238 GTK_PARAM_READWRITE));
239 gtk_container_class_install_child_property (container_class,
240 CHILD_PROP_RIGHT_ATTACH,
241 g_param_spec_uint ("right-attach",
242 P_("Right attachment"),
243 P_("The column number to attach the right side of a child widget to"),
245 GTK_PARAM_READWRITE));
246 gtk_container_class_install_child_property (container_class,
247 CHILD_PROP_TOP_ATTACH,
248 g_param_spec_uint ("top-attach",
249 P_("Top attachment"),
250 P_("The row number to attach the top of a child widget to"),
252 GTK_PARAM_READWRITE));
253 gtk_container_class_install_child_property (container_class,
254 CHILD_PROP_BOTTOM_ATTACH,
255 g_param_spec_uint ("bottom-attach",
256 P_("Bottom attachment"),
257 P_("The row number to attach the bottom of the child to"),
259 GTK_PARAM_READWRITE));
260 gtk_container_class_install_child_property (container_class,
261 CHILD_PROP_X_OPTIONS,
262 g_param_spec_flags ("x-options",
263 P_("Horizontal options"),
264 P_("Options specifying the horizontal behaviour of the child"),
265 GTK_TYPE_ATTACH_OPTIONS, GTK_EXPAND | GTK_FILL,
266 GTK_PARAM_READWRITE));
267 gtk_container_class_install_child_property (container_class,
268 CHILD_PROP_Y_OPTIONS,
269 g_param_spec_flags ("y-options",
270 P_("Vertical options"),
271 P_("Options specifying the vertical behaviour of the child"),
272 GTK_TYPE_ATTACH_OPTIONS, GTK_EXPAND | GTK_FILL,
273 GTK_PARAM_READWRITE));
274 gtk_container_class_install_child_property (container_class,
275 CHILD_PROP_X_PADDING,
276 g_param_spec_uint ("x-padding",
277 P_("Horizontal padding"),
278 P_("Extra space to put between the child and its left and right neighbors, in pixels"),
280 GTK_PARAM_READWRITE));
281 gtk_container_class_install_child_property (container_class,
282 CHILD_PROP_Y_PADDING,
283 g_param_spec_uint ("y-padding",
284 P_("Vertical padding"),
285 P_("Extra space to put between the child and its upper and lower neighbors, in pixels"),
287 GTK_PARAM_READWRITE));
289 g_type_class_add_private (class, sizeof (GtkTablePrivate));
293 gtk_table_compute_expand (GtkWidget *widget,
297 GtkTable *table = GTK_TABLE (widget);
298 GtkTablePrivate *priv = table->priv;
300 GtkTableChild *child;
307 for (list = priv->children; list; list = list->next)
312 hexpand = child->xexpand ||
313 gtk_widget_compute_expand (child->widget,
314 GTK_ORIENTATION_HORIZONTAL);
317 vexpand = child->yexpand ||
318 gtk_widget_compute_expand (child->widget,
319 GTK_ORIENTATION_VERTICAL);
321 if (hexpand && vexpand)
325 *hexpand_p = hexpand;
326 *vexpand_p = vexpand;
330 gtk_table_child_type (GtkContainer *container)
332 return GTK_TYPE_WIDGET;
336 gtk_table_get_property (GObject *object,
341 GtkTable *table = GTK_TABLE (object);
342 GtkTablePrivate *priv = table->priv;
347 g_value_set_uint (value, priv->nrows);
350 g_value_set_uint (value, priv->ncols);
352 case PROP_ROW_SPACING:
353 g_value_set_uint (value, priv->row_spacing);
355 case PROP_COLUMN_SPACING:
356 g_value_set_uint (value, priv->column_spacing);
358 case PROP_HOMOGENEOUS:
359 g_value_set_boolean (value, priv->homogeneous);
362 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
368 gtk_table_set_property (GObject *object,
373 GtkTable *table = GTK_TABLE (object);
374 GtkTablePrivate *priv = table->priv;
379 gtk_table_resize (table, g_value_get_uint (value), priv->ncols);
382 gtk_table_resize (table, priv->nrows, g_value_get_uint (value));
384 case PROP_ROW_SPACING:
385 gtk_table_set_row_spacings (table, g_value_get_uint (value));
387 case PROP_COLUMN_SPACING:
388 gtk_table_set_col_spacings (table, g_value_get_uint (value));
390 case PROP_HOMOGENEOUS:
391 gtk_table_set_homogeneous (table, g_value_get_boolean (value));
394 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
400 gtk_table_set_child_property (GtkContainer *container,
406 GtkTable *table = GTK_TABLE (container);
407 GtkTablePrivate *priv = table->priv;
408 GtkTableChild *table_child;
412 for (list = priv->children; list; list = list->next)
414 table_child = list->data;
416 if (table_child->widget == child)
421 GTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID (container, property_id, pspec);
427 case CHILD_PROP_LEFT_ATTACH:
428 table_child->left_attach = g_value_get_uint (value);
429 if (table_child->right_attach <= table_child->left_attach)
430 table_child->right_attach = table_child->left_attach + 1;
431 if (table_child->right_attach >= priv->ncols)
432 gtk_table_resize (table, priv->nrows, table_child->right_attach);
434 case CHILD_PROP_RIGHT_ATTACH:
435 table_child->right_attach = g_value_get_uint (value);
436 if (table_child->right_attach <= table_child->left_attach)
437 table_child->left_attach = table_child->right_attach - 1;
438 if (table_child->right_attach >= priv->ncols)
439 gtk_table_resize (table, priv->nrows, table_child->right_attach);
441 case CHILD_PROP_TOP_ATTACH:
442 table_child->top_attach = g_value_get_uint (value);
443 if (table_child->bottom_attach <= table_child->top_attach)
444 table_child->bottom_attach = table_child->top_attach + 1;
445 if (table_child->bottom_attach >= priv->nrows)
446 gtk_table_resize (table, table_child->bottom_attach, priv->ncols);
448 case CHILD_PROP_BOTTOM_ATTACH:
449 table_child->bottom_attach = g_value_get_uint (value);
450 if (table_child->bottom_attach <= table_child->top_attach)
451 table_child->top_attach = table_child->bottom_attach - 1;
452 if (table_child->bottom_attach >= priv->nrows)
453 gtk_table_resize (table, table_child->bottom_attach, priv->ncols);
455 case CHILD_PROP_X_OPTIONS:
459 xexpand = (g_value_get_flags (value) & GTK_EXPAND) != 0;
461 if (table_child->xexpand != xexpand)
463 table_child->xexpand = xexpand;
464 gtk_widget_queue_compute_expand (GTK_WIDGET (table));
467 table_child->xshrink = (g_value_get_flags (value) & GTK_SHRINK) != 0;
468 table_child->xfill = (g_value_get_flags (value) & GTK_FILL) != 0;
471 case CHILD_PROP_Y_OPTIONS:
475 yexpand = (g_value_get_flags (value) & GTK_EXPAND) != 0;
477 if (table_child->yexpand != yexpand)
479 table_child->yexpand = yexpand;
480 gtk_widget_queue_compute_expand (GTK_WIDGET (table));
483 table_child->yshrink = (g_value_get_flags (value) & GTK_SHRINK) != 0;
484 table_child->yfill = (g_value_get_flags (value) & GTK_FILL) != 0;
487 case CHILD_PROP_X_PADDING:
488 table_child->xpadding = g_value_get_uint (value);
490 case CHILD_PROP_Y_PADDING:
491 table_child->ypadding = g_value_get_uint (value);
494 GTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID (container, property_id, pspec);
497 if (gtk_widget_get_visible (child) &&
498 gtk_widget_get_visible (GTK_WIDGET (table)))
499 gtk_widget_queue_resize (child);
503 gtk_table_get_child_property (GtkContainer *container,
509 GtkTable *table = GTK_TABLE (container);
510 GtkTablePrivate *priv = table->priv;
511 GtkTableChild *table_child;
515 for (list = priv->children; list; list = list->next)
517 table_child = list->data;
519 if (table_child->widget == child)
524 GTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID (container, property_id, pspec);
530 case CHILD_PROP_LEFT_ATTACH:
531 g_value_set_uint (value, table_child->left_attach);
533 case CHILD_PROP_RIGHT_ATTACH:
534 g_value_set_uint (value, table_child->right_attach);
536 case CHILD_PROP_TOP_ATTACH:
537 g_value_set_uint (value, table_child->top_attach);
539 case CHILD_PROP_BOTTOM_ATTACH:
540 g_value_set_uint (value, table_child->bottom_attach);
542 case CHILD_PROP_X_OPTIONS:
543 g_value_set_flags (value, (table_child->xexpand * GTK_EXPAND |
544 table_child->xshrink * GTK_SHRINK |
545 table_child->xfill * GTK_FILL));
547 case CHILD_PROP_Y_OPTIONS:
548 g_value_set_flags (value, (table_child->yexpand * GTK_EXPAND |
549 table_child->yshrink * GTK_SHRINK |
550 table_child->yfill * GTK_FILL));
552 case CHILD_PROP_X_PADDING:
553 g_value_set_uint (value, table_child->xpadding);
555 case CHILD_PROP_Y_PADDING:
556 g_value_set_uint (value, table_child->ypadding);
559 GTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID (container, property_id, pspec);
565 gtk_table_init (GtkTable *table)
567 GtkTablePrivate *priv;
569 table->priv = G_TYPE_INSTANCE_GET_PRIVATE (table,
574 gtk_widget_set_has_window (GTK_WIDGET (table), FALSE);
575 gtk_widget_set_redraw_on_allocate (GTK_WIDGET (table), FALSE);
577 priv->children = NULL;
582 priv->column_spacing = 0;
583 priv->row_spacing = 0;
584 priv->homogeneous = FALSE;
586 gtk_table_resize (table, 1, 1);
591 * @rows: The number of rows the new table should have.
592 * @columns: The number of columns the new table should have.
593 * @homogeneous: If set to %TRUE, all table cells are resized to the size of
594 * the cell containing the largest widget.
596 * Used to create a new table widget. An initial size must be given by
597 * specifying how many rows and columns the table should have, although
598 * this can be changed later with gtk_table_resize(). @rows and @columns
599 * must both be in the range 1 .. 65535. For historical reasons, 0 is accepted
600 * as well and is silently interpreted as 1.
602 * Returns: A pointer to the the newly created table widget.
605 gtk_table_new (guint rows,
607 gboolean homogeneous)
610 GtkTablePrivate *priv;
617 table = g_object_new (GTK_TYPE_TABLE, NULL);
620 priv->homogeneous = (homogeneous ? TRUE : FALSE);
622 gtk_table_resize (table, rows, columns);
624 return GTK_WIDGET (table);
629 * @table: The #GtkTable you wish to change the size of.
630 * @rows: The new number of rows.
631 * @columns: The new number of columns.
633 * If you need to change a table's size <emphasis>after</emphasis>
634 * it has been created, this function allows you to do so.
637 gtk_table_resize (GtkTable *table,
641 GtkTablePrivate *priv;
643 g_return_if_fail (GTK_IS_TABLE (table));
644 g_return_if_fail (n_rows > 0 && n_rows <= 65535);
645 g_return_if_fail (n_cols > 0 && n_cols <= 65535);
649 n_rows = MAX (n_rows, 1);
650 n_cols = MAX (n_cols, 1);
652 if (n_rows != priv->nrows ||
653 n_cols != priv->ncols)
657 for (list = priv->children; list; list = list->next)
659 GtkTableChild *child;
663 n_rows = MAX (n_rows, child->bottom_attach);
664 n_cols = MAX (n_cols, child->right_attach);
667 if (n_rows != priv->nrows)
672 priv->nrows = n_rows;
673 priv->rows = g_realloc (priv->rows, priv->nrows * sizeof (GtkTableRowCol));
675 for (; i < priv->nrows; i++)
677 priv->rows[i].requisition = 0;
678 priv->rows[i].allocation = 0;
679 priv->rows[i].spacing = priv->row_spacing;
680 priv->rows[i].need_expand = 0;
681 priv->rows[i].need_shrink = 0;
682 priv->rows[i].expand = 0;
683 priv->rows[i].shrink = 0;
686 g_object_notify (G_OBJECT (table), "n-rows");
689 if (n_cols != priv->ncols)
694 priv->ncols = n_cols;
695 priv->cols = g_realloc (priv->cols, priv->ncols * sizeof (GtkTableRowCol));
697 for (; i < priv->ncols; i++)
699 priv->cols[i].requisition = 0;
700 priv->cols[i].allocation = 0;
701 priv->cols[i].spacing = priv->column_spacing;
702 priv->cols[i].need_expand = 0;
703 priv->cols[i].need_shrink = 0;
704 priv->cols[i].expand = 0;
705 priv->cols[i].shrink = 0;
708 g_object_notify (G_OBJECT (table), "n-columns");
715 * @table: The #GtkTable to add a new widget to.
716 * @child: The widget to add.
717 * @left_attach: the column number to attach the left side of a child widget to.
718 * @right_attach: the column number to attach the right side of a child widget to.
719 * @top_attach: the row number to attach the top of a child widget to.
720 * @bottom_attach: the row number to attach the bottom of a child widget to.
721 * @xoptions: Used to specify the properties of the child widget when the table is resized.
722 * @yoptions: The same as xoptions, except this field determines behaviour of vertical resizing.
723 * @xpadding: An integer value specifying the padding on the left and right of the widget being added to the table.
724 * @ypadding: The amount of padding above and below the child widget.
726 * Adds a widget to a table. The number of 'cells' that a widget will occupy is
727 * specified by @left_attach, @right_attach, @top_attach and @bottom_attach.
728 * These each represent the leftmost, rightmost, uppermost and lowest column
729 * and row numbers of the table. (Columns and rows are indexed from zero).
731 * To make a button occupy the lower right cell of a 2x2 table, use
732 * <informalexample><programlisting>
733 * gtk_table_attach (table, button,
734 * 1, 2, // left, right attach
735 * 1, 2, // top, bottom attach
736 * xoptions, yoptions,
737 * xpadding, ypadding);
738 * </programlisting></informalexample>
739 * If you want to make the button span the entire bottom row, use @left_attach == 0 and @right_attach = 2 instead.
742 gtk_table_attach (GtkTable *table,
748 GtkAttachOptions xoptions,
749 GtkAttachOptions yoptions,
753 GtkTablePrivate *priv;
754 GtkTableChild *table_child;
756 g_return_if_fail (GTK_IS_TABLE (table));
757 g_return_if_fail (GTK_IS_WIDGET (child));
758 g_return_if_fail (gtk_widget_get_parent (child) == NULL);
760 /* g_return_if_fail (left_attach >= 0); */
761 g_return_if_fail (left_attach < right_attach);
762 /* g_return_if_fail (top_attach >= 0); */
763 g_return_if_fail (top_attach < bottom_attach);
767 if (right_attach >= priv->ncols)
768 gtk_table_resize (table, priv->nrows, right_attach);
770 if (bottom_attach >= priv->nrows)
771 gtk_table_resize (table, bottom_attach, priv->ncols);
773 table_child = g_new (GtkTableChild, 1);
774 table_child->widget = child;
775 table_child->left_attach = left_attach;
776 table_child->right_attach = right_attach;
777 table_child->top_attach = top_attach;
778 table_child->bottom_attach = bottom_attach;
779 table_child->xexpand = (xoptions & GTK_EXPAND) != 0;
780 table_child->xshrink = (xoptions & GTK_SHRINK) != 0;
781 table_child->xfill = (xoptions & GTK_FILL) != 0;
782 table_child->xpadding = xpadding;
783 table_child->yexpand = (yoptions & GTK_EXPAND) != 0;
784 table_child->yshrink = (yoptions & GTK_SHRINK) != 0;
785 table_child->yfill = (yoptions & GTK_FILL) != 0;
786 table_child->ypadding = ypadding;
788 priv->children = g_list_prepend (priv->children, table_child);
790 gtk_widget_set_parent (child, GTK_WIDGET (table));
794 * gtk_table_attach_defaults:
795 * @table: The table to add a new child widget to.
796 * @widget: The child widget to add.
797 * @left_attach: The column number to attach the left side of the child widget to.
798 * @right_attach: The column number to attach the right side of the child widget to.
799 * @top_attach: The row number to attach the top of the child widget to.
800 * @bottom_attach: The row number to attach the bottom of the child widget to.
802 * As there are many options associated with gtk_table_attach(), this convenience
803 * function provides the programmer with a means to add children to a table with
804 * identical padding and expansion options. The values used for the #GtkAttachOptions
805 * are <literal>GTK_EXPAND | GTK_FILL</literal>, and the padding is set to 0.
808 gtk_table_attach_defaults (GtkTable *table,
815 gtk_table_attach (table, widget,
816 left_attach, right_attach,
817 top_attach, bottom_attach,
818 GTK_EXPAND | GTK_FILL,
819 GTK_EXPAND | GTK_FILL,
824 * gtk_table_set_row_spacing:
825 * @table: a #GtkTable containing the row whose properties you wish to change.
826 * @row: row number whose spacing will be changed.
827 * @spacing: number of pixels that the spacing should take up.
829 * Changes the space between a given table row and the subsequent row.
832 gtk_table_set_row_spacing (GtkTable *table,
836 GtkTablePrivate *priv;
838 g_return_if_fail (GTK_IS_TABLE (table));
842 g_return_if_fail (row < priv->nrows);
844 if (priv->rows[row].spacing != spacing)
846 priv->rows[row].spacing = spacing;
848 if (gtk_widget_get_visible (GTK_WIDGET (table)))
849 gtk_widget_queue_resize (GTK_WIDGET (table));
854 * gtk_table_get_row_spacing:
855 * @table: a #GtkTable
856 * @row: a row in the table, 0 indicates the first row
858 * Gets the amount of space between row @row, and
859 * row @row + 1. See gtk_table_set_row_spacing().
861 * Return value: the row spacing
864 gtk_table_get_row_spacing (GtkTable *table,
867 GtkTablePrivate *priv;
869 g_return_val_if_fail (GTK_IS_TABLE (table), 0);
873 g_return_val_if_fail (row < priv->nrows - 1, 0);
875 return priv->rows[row].spacing;
879 * gtk_table_set_col_spacing:
880 * @table: a #GtkTable.
881 * @column: the column whose spacing should be changed.
882 * @spacing: number of pixels that the spacing should take up.
884 * Alters the amount of space between a given table column and the following
888 gtk_table_set_col_spacing (GtkTable *table,
892 GtkTablePrivate *priv;
894 g_return_if_fail (GTK_IS_TABLE (table));
898 g_return_if_fail (column < priv->ncols);
900 if (priv->cols[column].spacing != spacing)
902 priv->cols[column].spacing = spacing;
904 if (gtk_widget_get_visible (GTK_WIDGET (table)))
905 gtk_widget_queue_resize (GTK_WIDGET (table));
910 * gtk_table_get_col_spacing:
911 * @table: a #GtkTable
912 * @column: a column in the table, 0 indicates the first column
914 * Gets the amount of space between column @col, and
915 * column @col + 1. See gtk_table_set_col_spacing().
917 * Return value: the column spacing
920 gtk_table_get_col_spacing (GtkTable *table,
923 GtkTablePrivate *priv;
925 g_return_val_if_fail (GTK_IS_TABLE (table), 0);
929 g_return_val_if_fail (column < priv->ncols, 0);
931 return priv->cols[column].spacing;
935 * gtk_table_set_row_spacings:
936 * @table: a #GtkTable.
937 * @spacing: the number of pixels of space to place between every row in the table.
939 * Sets the space between every row in @table equal to @spacing.
942 gtk_table_set_row_spacings (GtkTable *table,
945 GtkTablePrivate *priv;
948 g_return_if_fail (GTK_IS_TABLE (table));
952 priv->row_spacing = spacing;
953 for (row = 0; row < priv->nrows; row++)
954 priv->rows[row].spacing = spacing;
956 if (gtk_widget_get_visible (GTK_WIDGET (table)))
957 gtk_widget_queue_resize (GTK_WIDGET (table));
959 g_object_notify (G_OBJECT (table), "row-spacing");
963 * gtk_table_get_default_row_spacing:
964 * @table: a #GtkTable
966 * Gets the default row spacing for the table. This is
967 * the spacing that will be used for newly added rows.
968 * (See gtk_table_set_row_spacings())
970 * Return value: the default row spacing
973 gtk_table_get_default_row_spacing (GtkTable *table)
975 g_return_val_if_fail (GTK_IS_TABLE (table), 0);
977 return table->priv->row_spacing;
981 * gtk_table_set_col_spacings:
982 * @table: a #GtkTable.
983 * @spacing: the number of pixels of space to place between every column
986 * Sets the space between every column in @table equal to @spacing.
989 gtk_table_set_col_spacings (GtkTable *table,
992 GtkTablePrivate *priv;
995 g_return_if_fail (GTK_IS_TABLE (table));
999 priv->column_spacing = spacing;
1000 for (col = 0; col < priv->ncols; col++)
1001 priv->cols[col].spacing = spacing;
1003 if (gtk_widget_get_visible (GTK_WIDGET (table)))
1004 gtk_widget_queue_resize (GTK_WIDGET (table));
1006 g_object_notify (G_OBJECT (table), "column-spacing");
1010 * gtk_table_get_default_col_spacing:
1011 * @table: a #GtkTable
1013 * Gets the default column spacing for the table. This is
1014 * the spacing that will be used for newly added columns.
1015 * (See gtk_table_set_col_spacings())
1017 * Return value: the default column spacing
1020 gtk_table_get_default_col_spacing (GtkTable *table)
1022 g_return_val_if_fail (GTK_IS_TABLE (table), 0);
1024 return table->priv->column_spacing;
1028 * gtk_table_set_homogeneous:
1029 * @table: The #GtkTable you wish to set the homogeneous properties of.
1030 * @homogeneous: Set to %TRUE to ensure all table cells are the same size. Set
1031 * to %FALSE if this is not your desired behaviour.
1033 * Changes the homogenous property of table cells, ie. whether all cells are
1034 * an equal size or not.
1037 gtk_table_set_homogeneous (GtkTable *table,
1038 gboolean homogeneous)
1040 GtkTablePrivate *priv;
1042 g_return_if_fail (GTK_IS_TABLE (table));
1046 homogeneous = (homogeneous != 0);
1047 if (homogeneous != priv->homogeneous)
1049 priv->homogeneous = homogeneous;
1051 if (gtk_widget_get_visible (GTK_WIDGET (table)))
1052 gtk_widget_queue_resize (GTK_WIDGET (table));
1054 g_object_notify (G_OBJECT (table), "homogeneous");
1059 * gtk_table_get_homogeneous:
1060 * @table: a #GtkTable
1062 * Returns whether the table cells are all constrained to the same
1063 * width and height. (See gtk_table_set_homogenous ())
1065 * Return value: %TRUE if the cells are all constrained to the same size
1068 gtk_table_get_homogeneous (GtkTable *table)
1070 g_return_val_if_fail (GTK_IS_TABLE (table), FALSE);
1072 return table->priv->homogeneous;
1076 * gtk_table_get_size:
1077 * @table: a #GtkTable
1078 * @rows: (out) (allow-none): return location for the number of
1080 * @columns: (out) (allow-none): return location for the number
1081 * of columns, or %NULL
1083 * Gets the number of rows and columns in the table.
1088 gtk_table_get_size (GtkTable *table,
1092 GtkTablePrivate *priv;
1094 g_return_if_fail (GTK_IS_TABLE (table));
1099 *rows = priv->nrows;
1102 *columns = priv->ncols;
1106 gtk_table_finalize (GObject *object)
1108 GtkTable *table = GTK_TABLE (object);
1109 GtkTablePrivate *priv = table->priv;
1111 g_free (priv->rows);
1112 g_free (priv->cols);
1114 G_OBJECT_CLASS (gtk_table_parent_class)->finalize (object);
1118 gtk_table_get_preferred_width (GtkWidget *widget,
1122 GtkTable *table = GTK_TABLE (widget);
1123 GtkTablePrivate *priv = table->priv;
1126 gtk_table_size_request_init (table);
1127 gtk_table_size_request_pass1 (table);
1128 gtk_table_size_request_pass2 (table);
1129 gtk_table_size_request_pass3 (table);
1130 gtk_table_size_request_pass2 (table);
1134 for (col = 0; col < priv->ncols; col++)
1135 *minimum += priv->cols[col].requisition;
1136 for (col = 0; col + 1 < priv->ncols; col++)
1137 *minimum += priv->cols[col].spacing;
1139 *natural = *minimum;
1143 gtk_table_get_preferred_height (GtkWidget *widget,
1147 GtkTable *table = GTK_TABLE (widget);
1148 GtkTablePrivate *priv = table->priv;
1151 gtk_table_size_request_init (table);
1152 gtk_table_size_request_pass1 (table);
1153 gtk_table_size_request_pass2 (table);
1154 gtk_table_size_request_pass3 (table);
1155 gtk_table_size_request_pass2 (table);
1158 for (row = 0; row < priv->nrows; row++)
1159 *minimum += priv->rows[row].requisition;
1160 for (row = 0; row + 1 < priv->nrows; row++)
1161 *minimum += priv->rows[row].spacing;
1163 *natural = *minimum;
1167 gtk_table_size_allocate (GtkWidget *widget,
1168 GtkAllocation *allocation)
1170 GtkTable *table = GTK_TABLE (widget);
1172 gtk_widget_set_allocation (widget, allocation);
1174 gtk_table_size_allocate_init (table);
1175 gtk_table_size_allocate_pass1 (table);
1176 gtk_table_size_allocate_pass2 (table);
1180 gtk_table_add (GtkContainer *container,
1183 gtk_table_attach_defaults (GTK_TABLE (container), widget, 0, 1, 0, 1);
1187 gtk_table_remove (GtkContainer *container,
1190 GtkTable *table = GTK_TABLE (container);
1191 GtkTablePrivate *priv = table->priv;
1192 GtkTableChild *child;
1193 GtkWidget *widget_container = GTK_WIDGET (container);
1196 children = priv->children;
1200 child = children->data;
1201 children = children->next;
1203 if (child->widget == widget)
1205 gboolean was_visible = gtk_widget_get_visible (widget);
1207 gtk_widget_unparent (widget);
1209 priv->children = g_list_remove (priv->children, child);
1212 if (was_visible && gtk_widget_get_visible (widget_container))
1213 gtk_widget_queue_resize (widget_container);
1220 gtk_table_forall (GtkContainer *container,
1221 gboolean include_internals,
1222 GtkCallback callback,
1223 gpointer callback_data)
1225 GtkTable *table = GTK_TABLE (container);
1226 GtkTablePrivate *priv = table->priv;
1227 GtkTableChild *child;
1230 children = priv->children;
1234 child = children->data;
1235 children = children->next;
1237 (* callback) (child->widget, callback_data);
1242 gtk_table_size_request_init (GtkTable *table)
1244 GtkTablePrivate *priv = table->priv;
1245 GtkTableChild *child;
1249 for (row = 0; row < priv->nrows; row++)
1251 priv->rows[row].requisition = 0;
1252 priv->rows[row].expand = FALSE;
1254 for (col = 0; col < priv->ncols; col++)
1256 priv->cols[col].requisition = 0;
1257 priv->cols[col].expand = FALSE;
1260 children = priv->children;
1263 child = children->data;
1264 children = children->next;
1266 if (child->left_attach == (child->right_attach - 1) &&
1267 (child->xexpand || gtk_widget_compute_expand (child->widget, GTK_ORIENTATION_HORIZONTAL)))
1268 priv->cols[child->left_attach].expand = TRUE;
1270 if (child->top_attach == (child->bottom_attach - 1) &&
1271 (child->yexpand || gtk_widget_compute_expand (child->widget, GTK_ORIENTATION_VERTICAL)))
1272 priv->rows[child->top_attach].expand = TRUE;
1277 gtk_table_size_request_pass1 (GtkTable *table)
1279 GtkTablePrivate *priv = table->priv;
1280 GtkTableChild *child;
1285 children = priv->children;
1288 child = children->data;
1289 children = children->next;
1291 if (gtk_widget_get_visible (child->widget))
1293 GtkRequisition child_requisition;
1295 gtk_widget_get_preferred_size (child->widget, &child_requisition, NULL);
1297 /* Child spans a single column.
1299 if (child->left_attach == (child->right_attach - 1))
1301 width = child_requisition.width + child->xpadding * 2;
1302 priv->cols[child->left_attach].requisition = MAX (priv->cols[child->left_attach].requisition, width);
1305 /* Child spans a single row.
1307 if (child->top_attach == (child->bottom_attach - 1))
1309 height = child_requisition.height + child->ypadding * 2;
1310 priv->rows[child->top_attach].requisition = MAX (priv->rows[child->top_attach].requisition, height);
1317 gtk_table_size_request_pass2 (GtkTable *table)
1319 GtkTablePrivate *priv = table->priv;
1324 if (priv->homogeneous)
1329 for (col = 0; col < priv->ncols; col++)
1330 max_width = MAX (max_width, priv->cols[col].requisition);
1331 for (row = 0; row < priv->nrows; row++)
1332 max_height = MAX (max_height, priv->rows[row].requisition);
1334 for (col = 0; col < priv->ncols; col++)
1335 priv->cols[col].requisition = max_width;
1336 for (row = 0; row < priv->nrows; row++)
1337 priv->rows[row].requisition = max_height;
1342 gtk_table_size_request_pass3 (GtkTable *table)
1344 GtkTablePrivate *priv = table->priv;
1345 GtkTableChild *child;
1351 children = priv->children;
1354 child = children->data;
1355 children = children->next;
1357 if (gtk_widget_get_visible (child->widget))
1359 /* Child spans multiple columns.
1361 if (child->left_attach != (child->right_attach - 1))
1363 GtkRequisition child_requisition;
1365 gtk_widget_get_preferred_size (child->widget,
1366 &child_requisition, NULL);
1368 /* Check and see if there is already enough space
1372 for (col = child->left_attach; col < child->right_attach; col++)
1374 width += priv->cols[col].requisition;
1375 if ((col + 1) < child->right_attach)
1376 width += priv->cols[col].spacing;
1379 /* If we need to request more space for this child to fill
1380 * its requisition, then divide up the needed space amongst the
1381 * columns it spans, favoring expandable columns if any.
1383 if (width < child_requisition.width + child->xpadding * 2)
1386 gboolean force_expand = FALSE;
1388 width = child_requisition.width + child->xpadding * 2 - width;
1390 for (col = child->left_attach; col < child->right_attach; col++)
1391 if (priv->cols[col].expand)
1396 n_expand = (child->right_attach - child->left_attach);
1397 force_expand = TRUE;
1400 for (col = child->left_attach; col < child->right_attach; col++)
1401 if (force_expand || priv->cols[col].expand)
1403 extra = width / n_expand;
1404 priv->cols[col].requisition += extra;
1411 /* Child spans multiple rows.
1413 if (child->top_attach != (child->bottom_attach - 1))
1415 GtkRequisition child_requisition;
1417 gtk_widget_get_preferred_size (child->widget,
1418 &child_requisition, NULL);
1420 /* Check and see if there is already enough space
1424 for (row = child->top_attach; row < child->bottom_attach; row++)
1426 height += priv->rows[row].requisition;
1427 if ((row + 1) < child->bottom_attach)
1428 height += priv->rows[row].spacing;
1431 /* If we need to request more space for this child to fill
1432 * its requisition, then divide up the needed space amongst the
1433 * rows it spans, favoring expandable rows if any.
1435 if (height < child_requisition.height + child->ypadding * 2)
1438 gboolean force_expand = FALSE;
1440 height = child_requisition.height + child->ypadding * 2 - height;
1442 for (row = child->top_attach; row < child->bottom_attach; row++)
1444 if (priv->rows[row].expand)
1450 n_expand = (child->bottom_attach - child->top_attach);
1451 force_expand = TRUE;
1454 for (row = child->top_attach; row < child->bottom_attach; row++)
1455 if (force_expand || priv->rows[row].expand)
1457 extra = height / n_expand;
1458 priv->rows[row].requisition += extra;
1469 gtk_table_size_allocate_init (GtkTable *table)
1471 GtkTablePrivate *priv = table->priv;
1472 GtkTableChild *child;
1478 /* Initialize the rows and cols.
1479 * By default, rows and cols do not expand and do shrink.
1480 * Those values are modified by the children that occupy
1481 * the rows and cols.
1483 for (col = 0; col < priv->ncols; col++)
1485 priv->cols[col].allocation = priv->cols[col].requisition;
1486 priv->cols[col].need_expand = FALSE;
1487 priv->cols[col].need_shrink = TRUE;
1488 priv->cols[col].expand = FALSE;
1489 priv->cols[col].shrink = TRUE;
1490 priv->cols[col].empty = TRUE;
1492 for (row = 0; row < priv->nrows; row++)
1494 priv->rows[row].allocation = priv->rows[row].requisition;
1495 priv->rows[row].need_expand = FALSE;
1496 priv->rows[row].need_shrink = TRUE;
1497 priv->rows[row].expand = FALSE;
1498 priv->rows[row].shrink = TRUE;
1499 priv->rows[row].empty = TRUE;
1502 /* Loop over all the children and adjust the row and col values
1503 * based on whether the children want to be allowed to expand
1504 * or shrink. This loop handles children that occupy a single
1507 children = priv->children;
1510 child = children->data;
1511 children = children->next;
1513 if (gtk_widget_get_visible (child->widget))
1515 if (child->left_attach == (child->right_attach - 1))
1517 if (child->xexpand || gtk_widget_compute_expand (child->widget, GTK_ORIENTATION_HORIZONTAL))
1518 priv->cols[child->left_attach].expand = TRUE;
1520 if (!child->xshrink)
1521 priv->cols[child->left_attach].shrink = FALSE;
1523 priv->cols[child->left_attach].empty = FALSE;
1526 if (child->top_attach == (child->bottom_attach - 1))
1528 if (child->yexpand || gtk_widget_compute_expand (child->widget, GTK_ORIENTATION_VERTICAL))
1529 priv->rows[child->top_attach].expand = TRUE;
1531 if (!child->yshrink)
1532 priv->rows[child->top_attach].shrink = FALSE;
1534 priv->rows[child->top_attach].empty = FALSE;
1539 /* Loop over all the children again and this time handle children
1540 * which span multiple rows or columns.
1542 children = priv->children;
1545 child = children->data;
1546 children = children->next;
1548 if (gtk_widget_get_visible (child->widget))
1550 if (child->left_attach != (child->right_attach - 1))
1552 for (col = child->left_attach; col < child->right_attach; col++)
1553 priv->cols[col].empty = FALSE;
1558 for (col = child->left_attach; col < child->right_attach; col++)
1559 if (priv->cols[col].expand)
1566 for (col = child->left_attach; col < child->right_attach; col++)
1567 priv->cols[col].need_expand = TRUE;
1570 if (!child->xshrink)
1573 for (col = child->left_attach; col < child->right_attach; col++)
1574 if (!priv->cols[col].shrink)
1581 for (col = child->left_attach; col < child->right_attach; col++)
1582 priv->cols[col].need_shrink = FALSE;
1586 if (child->top_attach != (child->bottom_attach - 1))
1588 for (row = child->top_attach; row < child->bottom_attach; row++)
1589 priv->rows[row].empty = FALSE;
1594 for (row = child->top_attach; row < child->bottom_attach; row++)
1595 if (priv->rows[row].expand)
1602 for (row = child->top_attach; row < child->bottom_attach; row++)
1603 priv->rows[row].need_expand = TRUE;
1606 if (!child->yshrink)
1609 for (row = child->top_attach; row < child->bottom_attach; row++)
1610 if (!priv->rows[row].shrink)
1617 for (row = child->top_attach; row < child->bottom_attach; row++)
1618 priv->rows[row].need_shrink = FALSE;
1624 /* Loop over the columns and set the expand and shrink values
1625 * if the column can be expanded or shrunk.
1627 for (col = 0; col < priv->ncols; col++)
1629 if (priv->cols[col].empty)
1631 priv->cols[col].expand = FALSE;
1632 priv->cols[col].shrink = FALSE;
1636 if (priv->cols[col].need_expand)
1637 priv->cols[col].expand = TRUE;
1638 if (!priv->cols[col].need_shrink)
1639 priv->cols[col].shrink = FALSE;
1643 /* Loop over the rows and set the expand and shrink values
1644 * if the row can be expanded or shrunk.
1646 for (row = 0; row < priv->nrows; row++)
1648 if (priv->rows[row].empty)
1650 priv->rows[row].expand = FALSE;
1651 priv->rows[row].shrink = FALSE;
1655 if (priv->rows[row].need_expand)
1656 priv->rows[row].expand = TRUE;
1657 if (!priv->rows[row].need_shrink)
1658 priv->rows[row].shrink = FALSE;
1664 gtk_table_size_allocate_pass1 (GtkTable *table)
1666 GtkTablePrivate *priv = table->priv;
1667 GtkAllocation allocation;
1676 /* If we were allocated more space than we requested
1677 * then we have to expand any expandable rows and columns
1678 * to fill in the extra space.
1680 gtk_widget_get_allocation (GTK_WIDGET (table), &allocation);
1681 real_width = allocation.width;
1682 real_height = allocation.height;
1684 if (priv->homogeneous)
1686 if (!priv->children)
1691 for (col = 0; col < priv->ncols; col++)
1692 if (priv->cols[col].expand)
1701 for (col = 0; col + 1 < priv->ncols; col++)
1702 width -= priv->cols[col].spacing;
1704 for (col = 0; col < priv->ncols; col++)
1706 extra = width / (priv->ncols - col);
1707 priv->cols[col].allocation = MAX (1, extra);
1718 for (col = 0; col < priv->ncols; col++)
1720 width += priv->cols[col].requisition;
1721 if (priv->cols[col].expand)
1723 if (priv->cols[col].shrink)
1726 for (col = 0; col + 1 < priv->ncols; col++)
1727 width += priv->cols[col].spacing;
1729 /* Check to see if we were allocated more width than we requested.
1731 if ((width < real_width) && (nexpand >= 1))
1733 width = real_width - width;
1735 for (col = 0; col < priv->ncols; col++)
1736 if (priv->cols[col].expand)
1738 extra = width / nexpand;
1739 priv->cols[col].allocation += extra;
1746 /* Check to see if we were allocated less width than we requested,
1747 * then shrink until we fit the size give.
1749 if (width > real_width)
1751 gint total_nshrink = nshrink;
1753 extra = width - real_width;
1754 while (total_nshrink > 0 && extra > 0)
1756 nshrink = total_nshrink;
1757 for (col = 0; col < priv->ncols; col++)
1758 if (priv->cols[col].shrink)
1760 gint allocation = priv->cols[col].allocation;
1762 priv->cols[col].allocation = MAX (1, (gint) priv->cols[col].allocation - extra / nshrink);
1763 extra -= allocation - priv->cols[col].allocation;
1765 if (priv->cols[col].allocation < 2)
1768 priv->cols[col].shrink = FALSE;
1775 if (priv->homogeneous)
1777 if (!priv->children)
1782 for (row = 0; row < priv->nrows; row++)
1783 if (priv->rows[row].expand)
1791 height = real_height;
1793 for (row = 0; row + 1 < priv->nrows; row++)
1794 height -= priv->rows[row].spacing;
1796 for (row = 0; row < priv->nrows; row++)
1798 extra = height / (priv->nrows - row);
1799 priv->rows[row].allocation = MAX (1, extra);
1810 for (row = 0; row < priv->nrows; row++)
1812 height += priv->rows[row].requisition;
1813 if (priv->rows[row].expand)
1815 if (priv->rows[row].shrink)
1818 for (row = 0; row + 1 < priv->nrows; row++)
1819 height += priv->rows[row].spacing;
1821 /* Check to see if we were allocated more height than we requested.
1823 if ((height < real_height) && (nexpand >= 1))
1825 height = real_height - height;
1827 for (row = 0; row < priv->nrows; row++)
1828 if (priv->rows[row].expand)
1830 extra = height / nexpand;
1831 priv->rows[row].allocation += extra;
1838 /* Check to see if we were allocated less height than we requested.
1839 * then shrink until we fit the size give.
1841 if (height > real_height)
1843 gint total_nshrink = nshrink;
1845 extra = height - real_height;
1846 while (total_nshrink > 0 && extra > 0)
1848 nshrink = total_nshrink;
1849 for (row = 0; row < priv->nrows; row++)
1850 if (priv->rows[row].shrink)
1852 gint allocation = priv->rows[row].allocation;
1854 priv->rows[row].allocation = MAX (1, (gint) priv->rows[row].allocation - extra / nshrink);
1855 extra -= allocation - priv->rows[row].allocation;
1857 if (priv->rows[row].allocation < 2)
1860 priv->rows[row].shrink = FALSE;
1869 gtk_table_size_allocate_pass2 (GtkTable *table)
1871 GtkTablePrivate *priv = table->priv;
1872 GtkTableChild *child;
1878 GtkAllocation allocation;
1879 GtkAllocation table_allocation, widget_allocation;
1880 GtkWidget *widget = GTK_WIDGET (table);
1882 children = priv->children;
1885 child = children->data;
1886 children = children->next;
1888 if (gtk_widget_get_visible (child->widget))
1890 GtkRequisition child_requisition;
1892 gtk_widget_get_preferred_size (child->widget,
1893 &child_requisition, NULL);
1895 gtk_widget_get_allocation (GTK_WIDGET (table), &table_allocation);
1896 x = table_allocation.x;
1897 y = table_allocation.y;
1901 for (col = 0; col < child->left_attach; col++)
1903 x += priv->cols[col].allocation;
1904 x += priv->cols[col].spacing;
1907 for (col = child->left_attach; col < child->right_attach; col++)
1909 max_width += priv->cols[col].allocation;
1910 if ((col + 1) < child->right_attach)
1911 max_width += priv->cols[col].spacing;
1914 for (row = 0; row < child->top_attach; row++)
1916 y += priv->rows[row].allocation;
1917 y += priv->rows[row].spacing;
1920 for (row = child->top_attach; row < child->bottom_attach; row++)
1922 max_height += priv->rows[row].allocation;
1923 if ((row + 1) < child->bottom_attach)
1924 max_height += priv->rows[row].spacing;
1929 allocation.width = MAX (1, max_width - (gint)child->xpadding * 2);
1930 allocation.x = x + (max_width - allocation.width) / 2;
1934 allocation.width = child_requisition.width;
1935 allocation.x = x + (max_width - allocation.width) / 2;
1940 allocation.height = MAX (1, max_height - (gint)child->ypadding * 2);
1941 allocation.y = y + (max_height - allocation.height) / 2;
1945 allocation.height = child_requisition.height;
1946 allocation.y = y + (max_height - allocation.height) / 2;
1949 gtk_widget_get_allocation (widget, &widget_allocation);
1950 if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
1951 allocation.x = widget_allocation.x + widget_allocation.width
1952 - (allocation.x - widget_allocation.x) - allocation.width;
1954 gtk_widget_size_allocate (child->widget, &allocation);