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"
32 #include "gtktypebuiltins.h"
34 #include "gtkbuildable.h"
38 #define LABEL_SIDE_PAD 2
40 struct _GtkFramePrivate
43 GtkWidget *label_widget;
50 GtkAllocation child_allocation;
51 GtkAllocation label_allocation;
63 static void gtk_frame_set_property (GObject *object,
67 static void gtk_frame_get_property (GObject *object,
71 static gboolean gtk_frame_draw (GtkWidget *widget,
73 static void gtk_frame_size_allocate (GtkWidget *widget,
74 GtkAllocation *allocation);
75 static void gtk_frame_remove (GtkContainer *container,
77 static void gtk_frame_forall (GtkContainer *container,
78 gboolean include_internals,
80 gpointer callback_data);
82 static void gtk_frame_compute_child_allocation (GtkFrame *frame,
83 GtkAllocation *child_allocation);
84 static void gtk_frame_real_compute_child_allocation (GtkFrame *frame,
85 GtkAllocation *child_allocation);
88 static void gtk_frame_buildable_init (GtkBuildableIface *iface);
89 static void gtk_frame_buildable_add_child (GtkBuildable *buildable,
94 static void gtk_frame_get_preferred_width (GtkWidget *widget,
97 static void gtk_frame_get_preferred_height (GtkWidget *widget,
100 static void gtk_frame_get_preferred_height_for_width(GtkWidget *layout,
102 gint *minimum_height,
103 gint *natural_height);
104 static void gtk_frame_get_preferred_width_for_height(GtkWidget *layout,
106 gint *minimum_height,
107 gint *natural_height);
110 G_DEFINE_TYPE_WITH_CODE (GtkFrame, gtk_frame, GTK_TYPE_BIN,
111 G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE,
112 gtk_frame_buildable_init))
115 gtk_frame_class_init (GtkFrameClass *class)
117 GObjectClass *gobject_class;
118 GtkWidgetClass *widget_class;
119 GtkContainerClass *container_class;
121 gobject_class = (GObjectClass*) class;
122 widget_class = GTK_WIDGET_CLASS (class);
123 container_class = GTK_CONTAINER_CLASS (class);
125 gobject_class->set_property = gtk_frame_set_property;
126 gobject_class->get_property = gtk_frame_get_property;
128 g_object_class_install_property (gobject_class,
130 g_param_spec_string ("label",
132 P_("Text of the frame's label"),
135 GTK_PARAM_WRITABLE));
136 g_object_class_install_property (gobject_class,
138 g_param_spec_float ("label-xalign",
140 P_("The horizontal alignment of the label"),
144 GTK_PARAM_READWRITE));
145 g_object_class_install_property (gobject_class,
147 g_param_spec_float ("label-yalign",
149 P_("The vertical alignment of the label"),
153 GTK_PARAM_READWRITE));
154 g_object_class_install_property (gobject_class,
156 g_param_spec_enum ("shadow-type",
158 P_("Appearance of the frame border"),
159 GTK_TYPE_SHADOW_TYPE,
160 GTK_SHADOW_ETCHED_IN,
161 GTK_PARAM_READWRITE));
163 g_object_class_install_property (gobject_class,
165 g_param_spec_object ("label-widget",
167 P_("A widget to display in place of the usual frame label"),
169 GTK_PARAM_READWRITE));
171 widget_class->draw = gtk_frame_draw;
172 widget_class->size_allocate = gtk_frame_size_allocate;
173 widget_class->get_preferred_width = gtk_frame_get_preferred_width;
174 widget_class->get_preferred_height = gtk_frame_get_preferred_height;
175 widget_class->get_preferred_height_for_width = gtk_frame_get_preferred_height_for_width;
176 widget_class->get_preferred_width_for_height = gtk_frame_get_preferred_width_for_height;
178 container_class->remove = gtk_frame_remove;
179 container_class->forall = gtk_frame_forall;
181 class->compute_child_allocation = gtk_frame_real_compute_child_allocation;
183 g_type_class_add_private (class, sizeof (GtkFramePrivate));
187 gtk_frame_buildable_init (GtkBuildableIface *iface)
189 iface->add_child = gtk_frame_buildable_add_child;
193 gtk_frame_buildable_add_child (GtkBuildable *buildable,
198 if (type && strcmp (type, "label") == 0)
199 gtk_frame_set_label_widget (GTK_FRAME (buildable), GTK_WIDGET (child));
201 gtk_container_add (GTK_CONTAINER (buildable), GTK_WIDGET (child));
203 GTK_BUILDER_WARN_INVALID_CHILD_TYPE (GTK_FRAME (buildable), type);
207 gtk_frame_init (GtkFrame *frame)
209 GtkFramePrivate *priv;
211 frame->priv = G_TYPE_INSTANCE_GET_PRIVATE (frame,
216 priv->label_widget = NULL;
217 priv->shadow_type = GTK_SHADOW_ETCHED_IN;
218 priv->label_xalign = 0.0;
219 priv->label_yalign = 0.5;
223 gtk_frame_set_property (GObject *object,
228 GtkFrame *frame = GTK_FRAME (object);
229 GtkFramePrivate *priv = frame->priv;
234 gtk_frame_set_label (frame, g_value_get_string (value));
236 case PROP_LABEL_XALIGN:
237 gtk_frame_set_label_align (frame, g_value_get_float (value),
240 case PROP_LABEL_YALIGN:
241 gtk_frame_set_label_align (frame, priv->label_xalign,
242 g_value_get_float (value));
244 case PROP_SHADOW_TYPE:
245 gtk_frame_set_shadow_type (frame, g_value_get_enum (value));
247 case PROP_LABEL_WIDGET:
248 gtk_frame_set_label_widget (frame, g_value_get_object (value));
251 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
257 gtk_frame_get_property (GObject *object,
262 GtkFrame *frame = GTK_FRAME (object);
263 GtkFramePrivate *priv = frame->priv;
268 g_value_set_string (value, gtk_frame_get_label (frame));
270 case PROP_LABEL_XALIGN:
271 g_value_set_float (value, priv->label_xalign);
273 case PROP_LABEL_YALIGN:
274 g_value_set_float (value, priv->label_yalign);
276 case PROP_SHADOW_TYPE:
277 g_value_set_enum (value, priv->shadow_type);
279 case PROP_LABEL_WIDGET:
280 g_value_set_object (value,
282 G_OBJECT (priv->label_widget) : NULL);
285 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
292 * @label: the text to use as the label of the frame
294 * Creates a new #GtkFrame, with optional label @label.
295 * If @label is %NULL, the label is omitted.
297 * Return value: a new #GtkFrame widget
300 gtk_frame_new (const gchar *label)
302 return g_object_new (GTK_TYPE_FRAME, "label", label, NULL);
306 gtk_frame_remove (GtkContainer *container,
309 GtkFrame *frame = GTK_FRAME (container);
310 GtkFramePrivate *priv = frame->priv;
312 if (priv->label_widget == child)
313 gtk_frame_set_label_widget (frame, NULL);
315 GTK_CONTAINER_CLASS (gtk_frame_parent_class)->remove (container, child);
319 gtk_frame_forall (GtkContainer *container,
320 gboolean include_internals,
321 GtkCallback callback,
322 gpointer callback_data)
324 GtkBin *bin = GTK_BIN (container);
325 GtkFrame *frame = GTK_FRAME (container);
326 GtkFramePrivate *priv = frame->priv;
329 child = gtk_bin_get_child (bin);
331 (* callback) (child, callback_data);
333 if (priv->label_widget)
334 (* callback) (priv->label_widget, callback_data);
338 * gtk_frame_set_label:
339 * @frame: a #GtkFrame
340 * @label: (allow-none): the text to use as the label of the frame
342 * Sets the text of the label. If @label is %NULL,
343 * the current label is removed.
346 gtk_frame_set_label (GtkFrame *frame,
349 g_return_if_fail (GTK_IS_FRAME (frame));
353 gtk_frame_set_label_widget (frame, NULL);
357 GtkWidget *child = gtk_label_new (label);
358 gtk_widget_show (child);
360 gtk_frame_set_label_widget (frame, child);
365 * gtk_frame_get_label:
366 * @frame: a #GtkFrame
368 * If the frame's label widget is a #GtkLabel, returns the
369 * text in the label widget. (The frame will have a #GtkLabel
370 * for the label widget if a non-%NULL argument was passed
371 * to gtk_frame_new().)
373 * Return value: the text in the label, or %NULL if there
374 * was no label widget or the lable widget was not
375 * a #GtkLabel. This string is owned by GTK+ and
376 * must not be modified or freed.
378 G_CONST_RETURN gchar *
379 gtk_frame_get_label (GtkFrame *frame)
381 GtkFramePrivate *priv;
383 g_return_val_if_fail (GTK_IS_FRAME (frame), NULL);
387 if (GTK_IS_LABEL (priv->label_widget))
388 return gtk_label_get_text (GTK_LABEL (priv->label_widget));
394 * gtk_frame_set_label_widget:
395 * @frame: a #GtkFrame
396 * @label_widget: the new label widget
398 * Sets the label widget for the frame. This is the widget that
399 * will appear embedded in the top edge of the frame as a
403 gtk_frame_set_label_widget (GtkFrame *frame,
404 GtkWidget *label_widget)
406 GtkFramePrivate *priv;
407 gboolean need_resize = FALSE;
409 g_return_if_fail (GTK_IS_FRAME (frame));
410 g_return_if_fail (label_widget == NULL || GTK_IS_WIDGET (label_widget));
411 g_return_if_fail (label_widget == NULL || gtk_widget_get_parent (label_widget) == NULL);
415 if (priv->label_widget == label_widget)
418 if (priv->label_widget)
420 need_resize = gtk_widget_get_visible (priv->label_widget);
421 gtk_widget_unparent (priv->label_widget);
424 priv->label_widget = label_widget;
428 priv->label_widget = label_widget;
429 gtk_widget_set_parent (label_widget, GTK_WIDGET (frame));
430 need_resize |= gtk_widget_get_visible (label_widget);
433 if (gtk_widget_get_visible (GTK_WIDGET (frame)) && need_resize)
434 gtk_widget_queue_resize (GTK_WIDGET (frame));
436 g_object_freeze_notify (G_OBJECT (frame));
437 g_object_notify (G_OBJECT (frame), "label-widget");
438 g_object_notify (G_OBJECT (frame), "label");
439 g_object_thaw_notify (G_OBJECT (frame));
443 * gtk_frame_get_label_widget:
444 * @frame: a #GtkFrame
446 * Retrieves the label widget for the frame. See
447 * gtk_frame_set_label_widget().
449 * Return value: (transfer none): the label widget, or %NULL if there is none.
452 gtk_frame_get_label_widget (GtkFrame *frame)
454 g_return_val_if_fail (GTK_IS_FRAME (frame), NULL);
456 return frame->priv->label_widget;
460 * gtk_frame_set_label_align:
461 * @frame: a #GtkFrame
462 * @xalign: The position of the label along the top edge
463 * of the widget. A value of 0.0 represents left alignment;
464 * 1.0 represents right alignment.
465 * @yalign: The y alignment of the label. A value of 0.0 aligns under
466 * the frame; 1.0 aligns above the frame. If the values are exactly
467 * 0.0 or 1.0 the gap in the frame won't be painted because the label
468 * will be completely above or below the frame.
470 * Sets the alignment of the frame widget's label. The
471 * default values for a newly created frame are 0.0 and 0.5.
474 gtk_frame_set_label_align (GtkFrame *frame,
478 GtkFramePrivate *priv;
480 g_return_if_fail (GTK_IS_FRAME (frame));
484 xalign = CLAMP (xalign, 0.0, 1.0);
485 yalign = CLAMP (yalign, 0.0, 1.0);
487 g_object_freeze_notify (G_OBJECT (frame));
488 if (xalign != priv->label_xalign)
490 priv->label_xalign = xalign;
491 g_object_notify (G_OBJECT (frame), "label-xalign");
494 if (yalign != priv->label_yalign)
496 priv->label_yalign = yalign;
497 g_object_notify (G_OBJECT (frame), "label-yalign");
500 g_object_thaw_notify (G_OBJECT (frame));
501 gtk_widget_queue_resize (GTK_WIDGET (frame));
505 * gtk_frame_get_label_align:
506 * @frame: a #GtkFrame
507 * @xalign: (allow-none): location to store X alignment of frame's label, or %NULL
508 * @yalign: (allow-none): location to store X alignment of frame's label, or %NULL
510 * Retrieves the X and Y alignment of the frame's label. See
511 * gtk_frame_set_label_align().
514 gtk_frame_get_label_align (GtkFrame *frame,
518 GtkFramePrivate *priv;
520 g_return_if_fail (GTK_IS_FRAME (frame));
525 *xalign = priv->label_xalign;
527 *yalign = priv->label_yalign;
531 * gtk_frame_set_shadow_type:
532 * @frame: a #GtkFrame
533 * @type: the new #GtkShadowType
535 * Sets the shadow type for @frame.
538 gtk_frame_set_shadow_type (GtkFrame *frame,
541 GtkFramePrivate *priv;
544 g_return_if_fail (GTK_IS_FRAME (frame));
548 if ((GtkShadowType) priv->shadow_type != type)
550 widget = GTK_WIDGET (frame);
551 priv->shadow_type = type;
552 g_object_notify (G_OBJECT (frame), "shadow-type");
554 if (gtk_widget_is_drawable (widget))
556 gtk_widget_queue_draw (widget);
559 gtk_widget_queue_resize (widget);
564 * gtk_frame_get_shadow_type:
565 * @frame: a #GtkFrame
567 * Retrieves the shadow type of the frame. See
568 * gtk_frame_set_shadow_type().
570 * Return value: the current shadow type of the frame.
573 gtk_frame_get_shadow_type (GtkFrame *frame)
575 g_return_val_if_fail (GTK_IS_FRAME (frame), GTK_SHADOW_ETCHED_IN);
577 return frame->priv->shadow_type;
581 gtk_frame_draw (GtkWidget *widget,
585 GtkFramePrivate *priv;
586 GtkStyleContext *context;
588 gint x, y, width, height;
589 GtkAllocation allocation;
592 frame = GTK_FRAME (widget);
595 context = gtk_widget_get_style_context (widget);
596 state = gtk_widget_get_state_flags (widget);
597 gtk_widget_get_allocation (widget, &allocation);
599 gtk_style_context_save (context);
600 gtk_style_context_add_class (context, GTK_STYLE_CLASS_FRAME);
602 gtk_style_context_get_padding (context, state, &padding);
604 x = priv->child_allocation.x - allocation.x - padding.left;
605 y = priv->child_allocation.y - allocation.y - padding.top;
606 width = priv->child_allocation.width + padding.left + padding.right;
607 height = priv->child_allocation.height + padding.top + padding.bottom;
609 if (priv->shadow_type != GTK_SHADOW_NONE)
611 if (priv->label_widget)
617 if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR)
618 xalign = priv->label_xalign;
620 xalign = 1 - priv->label_xalign;
622 height_extra = MAX (0, priv->label_allocation.height - padding.top)
623 - priv->label_yalign * priv->label_allocation.height;
625 height += height_extra;
627 x2 = padding.left + (priv->child_allocation.width - priv->label_allocation.width - 2 * LABEL_PAD - 2 * LABEL_SIDE_PAD) * xalign + LABEL_SIDE_PAD;
628 /* If the label is completely over or under the frame we can omit the gap */
629 if (priv->label_yalign == 0.0 || priv->label_yalign == 1.0)
630 gtk_render_frame (context, cr, x, y, width, height);
632 gtk_render_frame_gap (context, cr,
635 x2 + priv->label_allocation.width + 2 * LABEL_PAD);
638 gtk_render_frame (context, cr, x, y, width, height);
641 gtk_style_context_restore (context);
643 GTK_WIDGET_CLASS (gtk_frame_parent_class)->draw (widget, cr);
649 gtk_frame_size_allocate (GtkWidget *widget,
650 GtkAllocation *allocation)
652 GtkFrame *frame = GTK_FRAME (widget);
653 GtkFramePrivate *priv = frame->priv;
654 GtkBin *bin = GTK_BIN (widget);
655 GtkAllocation new_allocation;
658 gtk_widget_set_allocation (widget, allocation);
660 gtk_frame_compute_child_allocation (frame, &new_allocation);
662 /* If the child allocation changed, that means that the frame is drawn
663 * in a new place, so we must redraw the entire widget.
665 if (gtk_widget_get_mapped (widget))
667 gdk_window_invalidate_rect (gtk_widget_get_window (widget), allocation, FALSE);
670 child = gtk_bin_get_child (bin);
671 if (child && gtk_widget_get_visible (child))
672 gtk_widget_size_allocate (child, &new_allocation);
674 priv->child_allocation = new_allocation;
676 if (priv->label_widget && gtk_widget_get_visible (priv->label_widget))
678 GtkStyleContext *context;
681 gint nat_width, width, height;
684 context = gtk_widget_get_style_context (widget);
685 state = gtk_widget_get_state_flags (widget);
687 gtk_style_context_save (context);
688 gtk_style_context_add_class (context, GTK_STYLE_CLASS_FRAME);
690 gtk_style_context_get_padding (context, state, &padding);
692 if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR)
693 xalign = priv->label_xalign;
695 xalign = 1 - priv->label_xalign;
697 gtk_widget_get_preferred_width (priv->label_widget, NULL, &nat_width);
698 width = new_allocation.width - 2 * LABEL_PAD - 2 * LABEL_SIDE_PAD;
699 width = MIN (width, nat_width);
701 gtk_widget_get_preferred_height_for_width (priv->label_widget, width,
705 priv->label_allocation.x = priv->child_allocation.x + LABEL_SIDE_PAD +
706 (new_allocation.width - width - 2 * LABEL_PAD - 2 * LABEL_SIDE_PAD) * xalign + LABEL_PAD;
708 priv->label_allocation.width = width;
710 priv->label_allocation.y = priv->child_allocation.y - MAX (height, padding.top);
711 priv->label_allocation.height = height;
713 gtk_widget_size_allocate (priv->label_widget, &priv->label_allocation);
715 gtk_style_context_restore (context);
720 gtk_frame_compute_child_allocation (GtkFrame *frame,
721 GtkAllocation *child_allocation)
723 g_return_if_fail (GTK_IS_FRAME (frame));
724 g_return_if_fail (child_allocation != NULL);
726 GTK_FRAME_GET_CLASS (frame)->compute_child_allocation (frame, child_allocation);
730 gtk_frame_real_compute_child_allocation (GtkFrame *frame,
731 GtkAllocation *child_allocation)
733 GtkFramePrivate *priv = frame->priv;
734 GtkWidget *widget = GTK_WIDGET (frame);
735 GtkAllocation allocation;
736 GtkStyleContext *context;
742 context = gtk_widget_get_style_context (widget);
743 state = gtk_widget_get_state_flags (widget);
745 gtk_style_context_save (context);
746 gtk_style_context_add_class (context, GTK_STYLE_CLASS_FRAME);
748 gtk_style_context_get_padding (context, state, &padding);
749 gtk_widget_get_allocation (widget, &allocation);
751 border_width = gtk_container_get_border_width (GTK_CONTAINER (frame));
753 if (priv->label_widget)
755 gint nat_width, width, height;
757 gtk_widget_get_preferred_width (priv->label_widget, NULL, &nat_width);
759 width = allocation.width;
760 width -= 2 * LABEL_PAD + 2 * LABEL_SIDE_PAD;
761 width -= (border_width * 2) + padding.left + padding.right;
763 width = MIN (width, nat_width);
765 gtk_widget_get_preferred_height_for_width (priv->label_widget, width,
768 top_margin = MAX (height, padding.top);
771 top_margin = padding.top;
773 child_allocation->x = border_width + padding.left;
774 child_allocation->y = border_width + top_margin;
775 child_allocation->width = MAX (1, (gint) allocation.width - (border_width * 2) -
776 padding.left - padding.right);
777 child_allocation->height = MAX (1, ((gint) allocation.height - child_allocation->y -
778 border_width - padding.bottom));
780 child_allocation->x += allocation.x;
781 child_allocation->y += allocation.y;
783 gtk_style_context_restore (context);
787 gtk_frame_get_preferred_size (GtkWidget *request,
788 GtkOrientation orientation,
792 GtkFrame *frame = GTK_FRAME (request);
793 GtkFramePrivate *priv = frame->priv;
794 GtkStyleContext *context;
797 GtkWidget *widget = GTK_WIDGET (request);
799 GtkBin *bin = GTK_BIN (widget);
800 gint child_min, child_nat;
801 gint minimum, natural;
804 context = gtk_widget_get_style_context (widget);
805 state = gtk_widget_get_state_flags (widget);
807 gtk_style_context_save (context);
808 gtk_style_context_add_class (context, GTK_STYLE_CLASS_FRAME);
809 gtk_style_context_get_padding (context, state, &padding);
811 if (priv->label_widget && gtk_widget_get_visible (priv->label_widget))
813 if (orientation == GTK_ORIENTATION_HORIZONTAL)
815 gtk_widget_get_preferred_width (priv->label_widget,
816 &child_min, &child_nat);
817 minimum = child_min + 2 * LABEL_PAD + 2 * LABEL_SIDE_PAD;
818 natural = child_nat + 2 * LABEL_PAD + 2 * LABEL_SIDE_PAD;
822 gtk_widget_get_preferred_height (priv->label_widget,
823 &child_min, &child_nat);
824 minimum = MAX (0, child_min - padding.top);
825 natural = MAX (0, child_nat - padding.top);
834 child = gtk_bin_get_child (bin);
835 if (child && gtk_widget_get_visible (child))
837 if (orientation == GTK_ORIENTATION_HORIZONTAL)
839 gtk_widget_get_preferred_width (child,
840 &child_min, &child_nat);
841 minimum = MAX (minimum, child_min);
842 natural = MAX (natural, child_nat);
846 gtk_widget_get_preferred_height (child,
847 &child_min, &child_nat);
848 minimum += child_min;
849 natural += child_nat;
853 border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
855 if (orientation == GTK_ORIENTATION_HORIZONTAL)
857 minimum += (border_width * 2) + padding.left + padding.right;
858 natural += (border_width * 2) + padding.left + padding.right;
862 minimum += (border_width * 2) + padding.top + padding.bottom;
863 natural += (border_width * 2) + padding.top + padding.bottom;
867 *minimum_size = minimum;
870 *natural_size = natural;
872 gtk_style_context_restore (context);
876 gtk_frame_get_preferred_width (GtkWidget *widget,
880 gtk_frame_get_preferred_size (widget, GTK_ORIENTATION_HORIZONTAL, minimum_size, natural_size);
884 gtk_frame_get_preferred_height (GtkWidget *widget,
888 gtk_frame_get_preferred_size (widget, GTK_ORIENTATION_VERTICAL, minimum_size, natural_size);
893 gtk_frame_get_preferred_height_for_width (GtkWidget *request,
895 gint *minimum_height,
896 gint *natural_height)
898 GtkWidget *widget = GTK_WIDGET (request);
900 GtkFrame *frame = GTK_FRAME (widget);
901 GtkFramePrivate *priv = frame->priv;
902 GtkBin *bin = GTK_BIN (widget);
903 GtkStyleContext *context;
906 gint child_min, child_nat, label_width;
907 gint minimum, natural;
910 context = gtk_widget_get_style_context (widget);
911 state = gtk_widget_get_state_flags (widget);
913 gtk_style_context_save (context);
914 gtk_style_context_add_class (context, GTK_STYLE_CLASS_FRAME);
915 gtk_style_context_get_padding (context, state, &padding);
917 border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
918 minimum = (border_width * 2) + padding.top + padding.bottom;
919 natural = (border_width * 2) + padding.top + padding.bottom;
921 width -= (border_width * 2) + padding.left + padding.right;
922 label_width = width - 2 * LABEL_PAD + 2 * LABEL_SIDE_PAD;
924 if (priv->label_widget && gtk_widget_get_visible (priv->label_widget))
926 gtk_widget_get_preferred_height_for_width (priv->label_widget,
927 label_width, &child_min, &child_nat);
928 minimum += child_min;
929 natural += child_nat;
932 child = gtk_bin_get_child (bin);
933 if (child && gtk_widget_get_visible (child))
935 gtk_widget_get_preferred_height_for_width (child,
936 width, &child_min, &child_nat);
937 minimum += child_min;
938 natural += child_nat;
942 *minimum_height = minimum;
945 *natural_height = natural;
947 gtk_style_context_restore (context);
951 gtk_frame_get_preferred_width_for_height (GtkWidget *widget,
956 GTK_WIDGET_GET_CLASS (widget)->get_preferred_width (widget, minimum_width, natural_width);