* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
*/
+/**
+ * SECTION:gtkalignment
+ * @Short_description: A widget which controls the alignment and size of its child
+ * @Title: GtkAlignment
+ *
+ * The #GtkAlignment widget controls the alignment and size of its child widget.
+ * It has four settings: xscale, yscale, xalign, and yalign.
+ *
+ * The scale settings are used to specify how much the child widget should
+ * expand to fill the space allocated to the #GtkAlignment.
+ * The values can range from 0 (meaning the child doesn't expand at all) to
+ * 1 (meaning the child expands to fill all of the available space).
+ *
+ * The align settings are used to place the child widget within the available
+ * area. The values range from 0 (top or left) to 1 (bottom or right).
+ * Of course, if the scale settings are both set to 1, the alignment settings
+ * have no effect.
+ */
+
#include "config.h"
#include "gtkalignment.h"
+ #include "gtkextendedlayout.h"
#include "gtkprivate.h"
#include "gtkintl.h"
#include "gtkalias.h"
{
child = children->data;
children = children->next;
-
+
- if ((child->pack == GTK_PACK_START) && gtk_widget_get_visible (child->widget))
+ if (gtk_widget_get_visible (child->widget))
{
- if (box->homogeneous)
- {
- if (nvis_children == 1)
- {
- child_width = width;
- child_height = height;
- }
- else
- {
- child_width = extra;
- child_height = extra;
- }
-
- nvis_children -= 1;
- width -= extra;
- height -= extra;
- }
- else
- {
- GtkRequisition child_requisition;
-
- gtk_widget_get_child_requisition (child->widget, &child_requisition);
-
- child_width = child_requisition.width + child->padding * 2;
- child_height = child_requisition.height + child->padding * 2;
-
- if (child->expand)
- {
- if (nexpand_children == 1)
- {
- child_width += width;
- child_height += height;
- }
- else
- {
- child_width += extra;
- child_height += extra;
- }
-
- nexpand_children -= 1;
- width -= extra;
- height -= extra;
- }
- }
-
- if (child->fill)
- {
- if (private->orientation == GTK_ORIENTATION_HORIZONTAL)
- {
- child_allocation.width = MAX (1, (gint) child_width - (gint) child->padding * 2);
- child_allocation.x = x + child->padding;
- }
- else
- {
- child_allocation.height = MAX (1, child_height - (gint)child->padding * 2);
- child_allocation.y = y + child->padding;
- }
- }
+ if (private->orientation == GTK_ORIENTATION_HORIZONTAL)
+ gtk_extended_layout_get_width_for_height (GTK_EXTENDED_LAYOUT (child->widget),
+ allocation->height,
+ &sizes[i].minimum_size,
+ &sizes[i].natural_size);
else
- {
- GtkRequisition child_requisition;
-
- gtk_widget_get_child_requisition (child->widget, &child_requisition);
- if (private->orientation == GTK_ORIENTATION_HORIZONTAL)
- {
- child_allocation.width = child_requisition.width;
- child_allocation.x = x + (child_width - child_allocation.width) / 2;
- }
- else
- {
- child_allocation.height = child_requisition.height;
- child_allocation.y = y + (child_height - child_allocation.height) / 2;
- }
- }
-
- if (direction == GTK_TEXT_DIR_RTL &&
- private->orientation == GTK_ORIENTATION_HORIZONTAL)
- {
- child_allocation.x = allocation->x + allocation->width - (child_allocation.x - allocation->x) - child_allocation.width;
- }
-
- gtk_widget_size_allocate (child->widget, &child_allocation);
-
- x += child_width + box->spacing;
- y += child_height + box->spacing;
+ gtk_extended_layout_get_height_for_width (GTK_EXTENDED_LAYOUT (child->widget),
+ allocation->width,
+ &sizes[i].minimum_size,
+ &sizes[i].natural_size);
+
+
+ /* Assert the api is working properly */
+ if (sizes[i].minimum_size < 0)
+ g_error ("GtkBox child %s minimum %s: %d < 0 for %s %d",
+ gtk_widget_get_name (GTK_WIDGET (child->widget)),
+ (private->orientation == GTK_ORIENTATION_HORIZONTAL) ? "width" : "height",
+ sizes[i].minimum_size,
+ (private->orientation == GTK_ORIENTATION_HORIZONTAL) ? "height" : "width",
+ (private->orientation == GTK_ORIENTATION_HORIZONTAL) ? allocation->height : allocation->width);
+
+ if (sizes[i].natural_size < sizes[i].minimum_size)
+ g_error ("GtkBox child %s natural %s: %d < minimum %d for %s %d",
+ gtk_widget_get_name (GTK_WIDGET (child->widget)),
+ (private->orientation == GTK_ORIENTATION_HORIZONTAL) ? "width" : "height",
+ sizes[i].natural_size,
+ sizes[i].minimum_size,
+ (private->orientation == GTK_ORIENTATION_HORIZONTAL) ? "height" : "width",
+ (private->orientation == GTK_ORIENTATION_HORIZONTAL) ? allocation->height : allocation->width);
+
+ size -= sizes[i].minimum_size;
+ size -= child->padding * 2;
+
+ spreading[i].index = i;
+ spreading[i].child = child;
+
+ i += 1;
}
}