- top_margin = widget->style->ythickness;
-
- child_allocation->x = (GTK_CONTAINER (frame)->border_width +
- widget->style->xthickness);
- child_allocation->width = MAX(1, (gint)allocation->width - child_allocation->x * 2);
-
- child_allocation->y = (GTK_CONTAINER (frame)->border_width + top_margin);
- child_allocation->height = MAX (1, ((gint)allocation->height - child_allocation->y -
- (gint)GTK_CONTAINER (frame)->border_width -
- (gint)widget->style->ythickness));
-
- child_allocation->x += allocation->x;
- child_allocation->y += allocation->y;
+ top_margin = padding.top;
+
+ child_allocation->x = border_width + padding.left;
+ child_allocation->y = border_width + top_margin;
+ child_allocation->width = MAX (1, (gint) (allocation.width - (border_width * 2) -
+ padding.left - padding.right));
+ child_allocation->height = MAX (1, (gint) (allocation.height - child_allocation->y -
+ border_width - padding.bottom));
+
+ child_allocation->x += allocation.x;
+ child_allocation->y += allocation.y;
+}
+
+static void
+gtk_frame_get_preferred_size (GtkWidget *request,
+ GtkOrientation orientation,
+ gint *minimum_size,
+ gint *natural_size)
+{
+ GtkFrame *frame = GTK_FRAME (request);
+ GtkFramePrivate *priv = frame->priv;
+ GtkBorder padding;
+ GtkWidget *widget = GTK_WIDGET (request);
+ GtkWidget *child;
+ GtkBin *bin = GTK_BIN (widget);
+ gint child_min, child_nat;
+ gint minimum, natural;
+ guint border_width;
+
+ get_padding_and_border (frame, &padding);
+ border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
+
+ if (priv->label_widget && gtk_widget_get_visible (priv->label_widget))
+ {
+ if (orientation == GTK_ORIENTATION_HORIZONTAL)
+ {
+ gtk_widget_get_preferred_width (priv->label_widget,
+ &child_min, &child_nat);
+ minimum = child_min + 2 * LABEL_PAD + 2 * LABEL_SIDE_PAD;
+ natural = child_nat + 2 * LABEL_PAD + 2 * LABEL_SIDE_PAD;
+ }
+ else
+ {
+ gtk_widget_get_preferred_height (priv->label_widget,
+ &child_min, &child_nat);
+ minimum = MAX (0, child_min - padding.top);
+ natural = MAX (0, child_nat - padding.top);
+ }
+ }
+ else
+ {
+ minimum = 0;
+ natural = 0;
+ }
+
+ child = gtk_bin_get_child (bin);
+ if (child && gtk_widget_get_visible (child))
+ {
+ if (orientation == GTK_ORIENTATION_HORIZONTAL)
+ {
+ gtk_widget_get_preferred_width (child,
+ &child_min, &child_nat);
+ minimum = MAX (minimum, child_min);
+ natural = MAX (natural, child_nat);
+ }
+ else
+ {
+ gtk_widget_get_preferred_height (child,
+ &child_min, &child_nat);
+ minimum += child_min;
+ natural += child_nat;
+ }
+ }
+
+ if (orientation == GTK_ORIENTATION_HORIZONTAL)
+ {
+ minimum += (border_width * 2) + padding.left + padding.right;
+ natural += (border_width * 2) + padding.left + padding.right;
+ }
+ else
+ {
+ minimum += (border_width * 2) + padding.top + padding.bottom;
+ natural += (border_width * 2) + padding.top + padding.bottom;
+ }
+
+ if (minimum_size)
+ *minimum_size = minimum;
+
+ if (natural_size)
+ *natural_size = natural;
+}
+
+static void
+gtk_frame_get_preferred_width (GtkWidget *widget,
+ gint *minimum_size,
+ gint *natural_size)
+{
+ gtk_frame_get_preferred_size (widget, GTK_ORIENTATION_HORIZONTAL, minimum_size, natural_size);