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 "gtkprivate.h"
33 #include "gtkbuildable.h"
37 #define LABEL_SIDE_PAD 2
39 struct _GtkFramePrivate
42 GtkWidget *label_widget;
49 GtkAllocation child_allocation;
50 GtkAllocation label_allocation;
62 static void gtk_frame_set_property (GObject *object,
66 static void gtk_frame_get_property (GObject *object,
70 static gboolean gtk_frame_draw (GtkWidget *widget,
72 static void gtk_frame_size_allocate (GtkWidget *widget,
73 GtkAllocation *allocation);
74 static void gtk_frame_remove (GtkContainer *container,
76 static void gtk_frame_forall (GtkContainer *container,
77 gboolean include_internals,
79 gpointer callback_data);
81 static void gtk_frame_compute_child_allocation (GtkFrame *frame,
82 GtkAllocation *child_allocation);
83 static void gtk_frame_real_compute_child_allocation (GtkFrame *frame,
84 GtkAllocation *child_allocation);
87 static void gtk_frame_buildable_init (GtkBuildableIface *iface);
88 static void gtk_frame_buildable_add_child (GtkBuildable *buildable,
93 static void gtk_frame_get_preferred_width (GtkWidget *widget,
96 static void gtk_frame_get_preferred_height (GtkWidget *widget,
99 static void gtk_frame_get_preferred_height_for_width(GtkWidget *layout,
101 gint *minimum_height,
102 gint *natural_height);
103 static void gtk_frame_get_preferred_width_for_height(GtkWidget *layout,
105 gint *minimum_height,
106 gint *natural_height);
109 G_DEFINE_TYPE_WITH_CODE (GtkFrame, gtk_frame, GTK_TYPE_BIN,
110 G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE,
111 gtk_frame_buildable_init))
114 gtk_frame_class_init (GtkFrameClass *class)
116 GObjectClass *gobject_class;
117 GtkWidgetClass *widget_class;
118 GtkContainerClass *container_class;
120 gobject_class = (GObjectClass*) class;
121 widget_class = GTK_WIDGET_CLASS (class);
122 container_class = GTK_CONTAINER_CLASS (class);
124 gobject_class->set_property = gtk_frame_set_property;
125 gobject_class->get_property = gtk_frame_get_property;
127 g_object_class_install_property (gobject_class,
129 g_param_spec_string ("label",
131 P_("Text of the frame's label"),
134 GTK_PARAM_WRITABLE));
135 g_object_class_install_property (gobject_class,
137 g_param_spec_float ("label-xalign",
139 P_("The horizontal alignment of the label"),
143 GTK_PARAM_READWRITE));
144 g_object_class_install_property (gobject_class,
146 g_param_spec_float ("label-yalign",
148 P_("The vertical alignment of the label"),
152 GTK_PARAM_READWRITE));
153 g_object_class_install_property (gobject_class,
155 g_param_spec_enum ("shadow-type",
157 P_("Appearance of the frame border"),
158 GTK_TYPE_SHADOW_TYPE,
159 GTK_SHADOW_ETCHED_IN,
160 GTK_PARAM_READWRITE));
162 g_object_class_install_property (gobject_class,
164 g_param_spec_object ("label-widget",
166 P_("A widget to display in place of the usual frame label"),
168 GTK_PARAM_READWRITE));
170 widget_class->draw = gtk_frame_draw;
171 widget_class->size_allocate = gtk_frame_size_allocate;
172 widget_class->get_preferred_width = gtk_frame_get_preferred_width;
173 widget_class->get_preferred_height = gtk_frame_get_preferred_height;
174 widget_class->get_preferred_height_for_width = gtk_frame_get_preferred_height_for_width;
175 widget_class->get_preferred_width_for_height = gtk_frame_get_preferred_width_for_height;
177 container_class->remove = gtk_frame_remove;
178 container_class->forall = gtk_frame_forall;
180 class->compute_child_allocation = gtk_frame_real_compute_child_allocation;
182 g_type_class_add_private (class, sizeof (GtkFramePrivate));
186 gtk_frame_buildable_init (GtkBuildableIface *iface)
188 iface->add_child = gtk_frame_buildable_add_child;
192 gtk_frame_buildable_add_child (GtkBuildable *buildable,
197 if (type && strcmp (type, "label") == 0)
198 gtk_frame_set_label_widget (GTK_FRAME (buildable), GTK_WIDGET (child));
200 gtk_container_add (GTK_CONTAINER (buildable), GTK_WIDGET (child));
202 GTK_BUILDER_WARN_INVALID_CHILD_TYPE (GTK_FRAME (buildable), type);
206 gtk_frame_init (GtkFrame *frame)
208 GtkFramePrivate *priv;
210 frame->priv = G_TYPE_INSTANCE_GET_PRIVATE (frame,
215 priv->label_widget = NULL;
216 priv->shadow_type = GTK_SHADOW_ETCHED_IN;
217 priv->label_xalign = 0.0;
218 priv->label_yalign = 0.5;
222 gtk_frame_set_property (GObject *object,
227 GtkFrame *frame = GTK_FRAME (object);
228 GtkFramePrivate *priv = frame->priv;
233 gtk_frame_set_label (frame, g_value_get_string (value));
235 case PROP_LABEL_XALIGN:
236 gtk_frame_set_label_align (frame, g_value_get_float (value),
239 case PROP_LABEL_YALIGN:
240 gtk_frame_set_label_align (frame, priv->label_xalign,
241 g_value_get_float (value));
243 case PROP_SHADOW_TYPE:
244 gtk_frame_set_shadow_type (frame, g_value_get_enum (value));
246 case PROP_LABEL_WIDGET:
247 gtk_frame_set_label_widget (frame, g_value_get_object (value));
250 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
256 gtk_frame_get_property (GObject *object,
261 GtkFrame *frame = GTK_FRAME (object);
262 GtkFramePrivate *priv = frame->priv;
267 g_value_set_string (value, gtk_frame_get_label (frame));
269 case PROP_LABEL_XALIGN:
270 g_value_set_float (value, priv->label_xalign);
272 case PROP_LABEL_YALIGN:
273 g_value_set_float (value, priv->label_yalign);
275 case PROP_SHADOW_TYPE:
276 g_value_set_enum (value, priv->shadow_type);
278 case PROP_LABEL_WIDGET:
279 g_value_set_object (value,
281 G_OBJECT (priv->label_widget) : NULL);
284 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
291 * @label: the text to use as the label of the frame
293 * Creates a new #GtkFrame, with optional label @label.
294 * If @label is %NULL, the label is omitted.
296 * Return value: a new #GtkFrame widget
299 gtk_frame_new (const gchar *label)
301 return g_object_new (GTK_TYPE_FRAME, "label", label, NULL);
305 gtk_frame_remove (GtkContainer *container,
308 GtkFrame *frame = GTK_FRAME (container);
309 GtkFramePrivate *priv = frame->priv;
311 if (priv->label_widget == child)
312 gtk_frame_set_label_widget (frame, NULL);
314 GTK_CONTAINER_CLASS (gtk_frame_parent_class)->remove (container, child);
318 gtk_frame_forall (GtkContainer *container,
319 gboolean include_internals,
320 GtkCallback callback,
321 gpointer callback_data)
323 GtkBin *bin = GTK_BIN (container);
324 GtkFrame *frame = GTK_FRAME (container);
325 GtkFramePrivate *priv = frame->priv;
328 child = gtk_bin_get_child (bin);
330 (* callback) (child, callback_data);
332 if (priv->label_widget)
333 (* callback) (priv->label_widget, callback_data);
337 * gtk_frame_set_label:
338 * @frame: a #GtkFrame
339 * @label: (allow-none): the text to use as the label of the frame
341 * Sets the text of the label. If @label is %NULL,
342 * the current label is removed.
345 gtk_frame_set_label (GtkFrame *frame,
348 g_return_if_fail (GTK_IS_FRAME (frame));
352 gtk_frame_set_label_widget (frame, NULL);
356 GtkWidget *child = gtk_label_new (label);
357 gtk_widget_show (child);
359 gtk_frame_set_label_widget (frame, child);
364 * gtk_frame_get_label:
365 * @frame: a #GtkFrame
367 * If the frame's label widget is a #GtkLabel, returns the
368 * text in the label widget. (The frame will have a #GtkLabel
369 * for the label widget if a non-%NULL argument was passed
370 * to gtk_frame_new().)
372 * Return value: the text in the label, or %NULL if there
373 * was no label widget or the lable widget was not
374 * a #GtkLabel. This string is owned by GTK+ and
375 * must not be modified or freed.
377 G_CONST_RETURN gchar *
378 gtk_frame_get_label (GtkFrame *frame)
380 GtkFramePrivate *priv;
382 g_return_val_if_fail (GTK_IS_FRAME (frame), NULL);
386 if (GTK_IS_LABEL (priv->label_widget))
387 return gtk_label_get_text (GTK_LABEL (priv->label_widget));
393 * gtk_frame_set_label_widget:
394 * @frame: a #GtkFrame
395 * @label_widget: the new label widget
397 * Sets the label widget for the frame. This is the widget that
398 * will appear embedded in the top edge of the frame as a
402 gtk_frame_set_label_widget (GtkFrame *frame,
403 GtkWidget *label_widget)
405 GtkFramePrivate *priv;
406 gboolean need_resize = FALSE;
408 g_return_if_fail (GTK_IS_FRAME (frame));
409 g_return_if_fail (label_widget == NULL || GTK_IS_WIDGET (label_widget));
410 g_return_if_fail (label_widget == NULL || gtk_widget_get_parent (label_widget) == NULL);
414 if (priv->label_widget == label_widget)
417 if (priv->label_widget)
419 need_resize = gtk_widget_get_visible (priv->label_widget);
420 gtk_widget_unparent (priv->label_widget);
423 priv->label_widget = label_widget;
427 priv->label_widget = label_widget;
428 gtk_widget_set_parent (label_widget, GTK_WIDGET (frame));
429 need_resize |= gtk_widget_get_visible (label_widget);
432 if (gtk_widget_get_visible (GTK_WIDGET (frame)) && need_resize)
433 gtk_widget_queue_resize (GTK_WIDGET (frame));
435 g_object_freeze_notify (G_OBJECT (frame));
436 g_object_notify (G_OBJECT (frame), "label-widget");
437 g_object_notify (G_OBJECT (frame), "label");
438 g_object_thaw_notify (G_OBJECT (frame));
442 * gtk_frame_get_label_widget:
443 * @frame: a #GtkFrame
445 * Retrieves the label widget for the frame. See
446 * gtk_frame_set_label_widget().
448 * Return value: (transfer none): the label widget, or %NULL if there is none.
451 gtk_frame_get_label_widget (GtkFrame *frame)
453 g_return_val_if_fail (GTK_IS_FRAME (frame), NULL);
455 return frame->priv->label_widget;
459 * gtk_frame_set_label_align:
460 * @frame: a #GtkFrame
461 * @xalign: The position of the label along the top edge
462 * of the widget. A value of 0.0 represents left alignment;
463 * 1.0 represents right alignment.
464 * @yalign: The y alignment of the label. A value of 0.0 aligns under
465 * the frame; 1.0 aligns above the frame. If the values are exactly
466 * 0.0 or 1.0 the gap in the frame won't be painted because the label
467 * will be completely above or below the frame.
469 * Sets the alignment of the frame widget's label. The
470 * default values for a newly created frame are 0.0 and 0.5.
473 gtk_frame_set_label_align (GtkFrame *frame,
477 GtkFramePrivate *priv;
479 g_return_if_fail (GTK_IS_FRAME (frame));
483 xalign = CLAMP (xalign, 0.0, 1.0);
484 yalign = CLAMP (yalign, 0.0, 1.0);
486 g_object_freeze_notify (G_OBJECT (frame));
487 if (xalign != priv->label_xalign)
489 priv->label_xalign = xalign;
490 g_object_notify (G_OBJECT (frame), "label-xalign");
493 if (yalign != priv->label_yalign)
495 priv->label_yalign = yalign;
496 g_object_notify (G_OBJECT (frame), "label-yalign");
499 g_object_thaw_notify (G_OBJECT (frame));
500 gtk_widget_queue_resize (GTK_WIDGET (frame));
504 * gtk_frame_get_label_align:
505 * @frame: a #GtkFrame
506 * @xalign: (allow-none): location to store X alignment of frame's label, or %NULL
507 * @yalign: (allow-none): location to store X alignment of frame's label, or %NULL
509 * Retrieves the X and Y alignment of the frame's label. See
510 * gtk_frame_set_label_align().
513 gtk_frame_get_label_align (GtkFrame *frame,
517 GtkFramePrivate *priv;
519 g_return_if_fail (GTK_IS_FRAME (frame));
524 *xalign = priv->label_xalign;
526 *yalign = priv->label_yalign;
530 * gtk_frame_set_shadow_type:
531 * @frame: a #GtkFrame
532 * @type: the new #GtkShadowType
534 * Sets the shadow type for @frame.
537 gtk_frame_set_shadow_type (GtkFrame *frame,
540 GtkFramePrivate *priv;
543 g_return_if_fail (GTK_IS_FRAME (frame));
547 if ((GtkShadowType) priv->shadow_type != type)
549 widget = GTK_WIDGET (frame);
550 priv->shadow_type = type;
551 g_object_notify (G_OBJECT (frame), "shadow-type");
553 if (gtk_widget_is_drawable (widget))
555 gtk_widget_queue_draw (widget);
558 gtk_widget_queue_resize (widget);
563 * gtk_frame_get_shadow_type:
564 * @frame: a #GtkFrame
566 * Retrieves the shadow type of the frame. See
567 * gtk_frame_set_shadow_type().
569 * Return value: the current shadow type of the frame.
572 gtk_frame_get_shadow_type (GtkFrame *frame)
574 g_return_val_if_fail (GTK_IS_FRAME (frame), GTK_SHADOW_ETCHED_IN);
576 return frame->priv->shadow_type;
580 gtk_frame_draw (GtkWidget *widget,
584 GtkFramePrivate *priv;
585 GtkStyleContext *context;
587 gint x, y, width, height;
588 GtkAllocation allocation;
591 frame = GTK_FRAME (widget);
594 context = gtk_widget_get_style_context (widget);
595 state = gtk_widget_get_state_flags (widget);
596 gtk_widget_get_allocation (widget, &allocation);
598 gtk_style_context_save (context);
599 gtk_style_context_add_class (context, GTK_STYLE_CLASS_FRAME);
601 gtk_style_context_get_padding (context, state, &padding);
603 x = priv->child_allocation.x - allocation.x - padding.left;
604 y = priv->child_allocation.y - allocation.y - padding.top;
605 width = priv->child_allocation.width + padding.left + padding.right;
606 height = priv->child_allocation.height + padding.top + padding.bottom;
608 if (priv->shadow_type != GTK_SHADOW_NONE)
610 if (priv->label_widget)
616 if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR)
617 xalign = priv->label_xalign;
619 xalign = 1 - priv->label_xalign;
621 height_extra = MAX (0, priv->label_allocation.height - padding.top)
622 - priv->label_yalign * priv->label_allocation.height;
624 height += height_extra;
626 x2 = padding.left + (priv->child_allocation.width - priv->label_allocation.width - 2 * LABEL_PAD - 2 * LABEL_SIDE_PAD) * xalign + LABEL_SIDE_PAD;
627 /* If the label is completely over or under the frame we can omit the gap */
628 if (priv->label_yalign == 0.0 || priv->label_yalign == 1.0)
629 gtk_render_frame (context, cr, x, y, width, height);
631 gtk_render_frame_gap (context, cr,
634 x2 + priv->label_allocation.width + 2 * LABEL_PAD);
637 gtk_render_frame (context, cr, x, y, width, height);
640 gtk_style_context_restore (context);
642 GTK_WIDGET_CLASS (gtk_frame_parent_class)->draw (widget, cr);
648 gtk_frame_size_allocate (GtkWidget *widget,
649 GtkAllocation *allocation)
651 GtkFrame *frame = GTK_FRAME (widget);
652 GtkFramePrivate *priv = frame->priv;
653 GtkBin *bin = GTK_BIN (widget);
654 GtkAllocation new_allocation;
657 gtk_widget_set_allocation (widget, allocation);
659 gtk_frame_compute_child_allocation (frame, &new_allocation);
661 /* If the child allocation changed, that means that the frame is drawn
662 * in a new place, so we must redraw the entire widget.
664 if (gtk_widget_get_mapped (widget))
666 gdk_window_invalidate_rect (gtk_widget_get_window (widget), allocation, FALSE);
669 child = gtk_bin_get_child (bin);
670 if (child && gtk_widget_get_visible (child))
671 gtk_widget_size_allocate (child, &new_allocation);
673 priv->child_allocation = new_allocation;
675 if (priv->label_widget && gtk_widget_get_visible (priv->label_widget))
677 GtkStyleContext *context;
680 gint nat_width, width, height;
683 context = gtk_widget_get_style_context (widget);
684 state = gtk_widget_get_state_flags (widget);
686 gtk_style_context_save (context);
687 gtk_style_context_add_class (context, GTK_STYLE_CLASS_FRAME);
689 gtk_style_context_get_padding (context, state, &padding);
691 if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR)
692 xalign = priv->label_xalign;
694 xalign = 1 - priv->label_xalign;
696 gtk_widget_get_preferred_width (priv->label_widget, NULL, &nat_width);
697 width = new_allocation.width - 2 * LABEL_PAD - 2 * LABEL_SIDE_PAD;
698 width = MIN (width, nat_width);
700 gtk_widget_get_preferred_height_for_width (priv->label_widget, width,
704 priv->label_allocation.x = priv->child_allocation.x + LABEL_SIDE_PAD +
705 (new_allocation.width - width - 2 * LABEL_PAD - 2 * LABEL_SIDE_PAD) * xalign + LABEL_PAD;
707 priv->label_allocation.width = width;
709 priv->label_allocation.y = priv->child_allocation.y - MAX (height, padding.top);
710 priv->label_allocation.height = height;
712 gtk_widget_size_allocate (priv->label_widget, &priv->label_allocation);
714 gtk_style_context_restore (context);
719 gtk_frame_compute_child_allocation (GtkFrame *frame,
720 GtkAllocation *child_allocation)
722 g_return_if_fail (GTK_IS_FRAME (frame));
723 g_return_if_fail (child_allocation != NULL);
725 GTK_FRAME_GET_CLASS (frame)->compute_child_allocation (frame, child_allocation);
729 gtk_frame_real_compute_child_allocation (GtkFrame *frame,
730 GtkAllocation *child_allocation)
732 GtkFramePrivate *priv = frame->priv;
733 GtkWidget *widget = GTK_WIDGET (frame);
734 GtkAllocation allocation;
735 GtkStyleContext *context;
741 context = gtk_widget_get_style_context (widget);
742 state = gtk_widget_get_state_flags (widget);
744 gtk_style_context_save (context);
745 gtk_style_context_add_class (context, GTK_STYLE_CLASS_FRAME);
747 gtk_style_context_get_padding (context, state, &padding);
748 gtk_widget_get_allocation (widget, &allocation);
750 border_width = gtk_container_get_border_width (GTK_CONTAINER (frame));
752 if (priv->label_widget)
754 gint nat_width, width, height;
756 gtk_widget_get_preferred_width (priv->label_widget, NULL, &nat_width);
758 width = allocation.width;
759 width -= 2 * LABEL_PAD + 2 * LABEL_SIDE_PAD;
760 width -= (border_width * 2) + padding.left + padding.right;
762 width = MIN (width, nat_width);
764 gtk_widget_get_preferred_height_for_width (priv->label_widget, width,
767 top_margin = MAX (height, padding.top);
770 top_margin = padding.top;
772 child_allocation->x = border_width + padding.left;
773 child_allocation->y = border_width + top_margin;
774 child_allocation->width = MAX (1, (gint) allocation.width - (border_width * 2) -
775 padding.left - padding.right);
776 child_allocation->height = MAX (1, ((gint) allocation.height - child_allocation->y -
777 border_width - padding.bottom));
779 child_allocation->x += allocation.x;
780 child_allocation->y += allocation.y;
782 gtk_style_context_restore (context);
786 gtk_frame_get_preferred_size (GtkWidget *request,
787 GtkOrientation orientation,
791 GtkFrame *frame = GTK_FRAME (request);
792 GtkFramePrivate *priv = frame->priv;
793 GtkStyleContext *context;
796 GtkWidget *widget = GTK_WIDGET (request);
798 GtkBin *bin = GTK_BIN (widget);
799 gint child_min, child_nat;
800 gint minimum, natural;
803 context = gtk_widget_get_style_context (widget);
804 state = gtk_widget_get_state_flags (widget);
806 gtk_style_context_save (context);
807 gtk_style_context_add_class (context, GTK_STYLE_CLASS_FRAME);
808 gtk_style_context_get_padding (context, state, &padding);
810 if (priv->label_widget && gtk_widget_get_visible (priv->label_widget))
812 if (orientation == GTK_ORIENTATION_HORIZONTAL)
814 gtk_widget_get_preferred_width (priv->label_widget,
815 &child_min, &child_nat);
816 minimum = child_min + 2 * LABEL_PAD + 2 * LABEL_SIDE_PAD;
817 natural = child_nat + 2 * LABEL_PAD + 2 * LABEL_SIDE_PAD;
821 gtk_widget_get_preferred_height (priv->label_widget,
822 &child_min, &child_nat);
823 minimum = MAX (0, child_min - padding.top);
824 natural = MAX (0, child_nat - padding.top);
833 child = gtk_bin_get_child (bin);
834 if (child && gtk_widget_get_visible (child))
836 if (orientation == GTK_ORIENTATION_HORIZONTAL)
838 gtk_widget_get_preferred_width (child,
839 &child_min, &child_nat);
840 minimum = MAX (minimum, child_min);
841 natural = MAX (natural, child_nat);
845 gtk_widget_get_preferred_height (child,
846 &child_min, &child_nat);
847 minimum += child_min;
848 natural += child_nat;
852 border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
854 if (orientation == GTK_ORIENTATION_HORIZONTAL)
856 minimum += (border_width * 2) + padding.left + padding.right;
857 natural += (border_width * 2) + padding.left + padding.right;
861 minimum += (border_width * 2) + padding.top + padding.bottom;
862 natural += (border_width * 2) + padding.top + padding.bottom;
866 *minimum_size = minimum;
869 *natural_size = natural;
871 gtk_style_context_restore (context);
875 gtk_frame_get_preferred_width (GtkWidget *widget,
879 gtk_frame_get_preferred_size (widget, GTK_ORIENTATION_HORIZONTAL, minimum_size, natural_size);
883 gtk_frame_get_preferred_height (GtkWidget *widget,
887 gtk_frame_get_preferred_size (widget, GTK_ORIENTATION_VERTICAL, minimum_size, natural_size);
892 gtk_frame_get_preferred_height_for_width (GtkWidget *request,
894 gint *minimum_height,
895 gint *natural_height)
897 GtkWidget *widget = GTK_WIDGET (request);
899 GtkFrame *frame = GTK_FRAME (widget);
900 GtkFramePrivate *priv = frame->priv;
901 GtkBin *bin = GTK_BIN (widget);
902 GtkStyleContext *context;
905 gint child_min, child_nat, label_width;
906 gint minimum, natural;
909 context = gtk_widget_get_style_context (widget);
910 state = gtk_widget_get_state_flags (widget);
912 gtk_style_context_save (context);
913 gtk_style_context_add_class (context, GTK_STYLE_CLASS_FRAME);
914 gtk_style_context_get_padding (context, state, &padding);
916 border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
917 minimum = (border_width * 2) + padding.top + padding.bottom;
918 natural = (border_width * 2) + padding.top + padding.bottom;
920 width -= (border_width * 2) + padding.left + padding.right;
921 label_width = width - 2 * LABEL_PAD + 2 * LABEL_SIDE_PAD;
923 if (priv->label_widget && gtk_widget_get_visible (priv->label_widget))
925 gtk_widget_get_preferred_height_for_width (priv->label_widget,
926 label_width, &child_min, &child_nat);
927 minimum += child_min;
928 natural += child_nat;
931 child = gtk_bin_get_child (bin);
932 if (child && gtk_widget_get_visible (child))
934 gtk_widget_get_preferred_height_for_width (child,
935 width, &child_min, &child_nat);
936 minimum += child_min;
937 natural += child_nat;
941 *minimum_height = minimum;
944 *natural_height = natural;
946 gtk_style_context_restore (context);
950 gtk_frame_get_preferred_width_for_height (GtkWidget *widget,
955 GTK_WIDGET_GET_CLASS (widget)->get_preferred_width (widget, minimum_width, natural_width);