]> Pileus Git - ~andy/gtk/blob - gtk/gtkframe.c
Patch from Matthias Clasen to remove remove all instances of
[~andy/gtk] / gtk / gtkframe.c
1 /* GTK - The GIMP Toolkit
2  * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
3  *
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.
8  *
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.
13  *
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.
18  */
19
20 /*
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/. 
25  */
26
27 #include <string.h>
28 #include "gtkframe.h"
29 #include "gtklabel.h"
30 #include "gtkintl.h"
31
32 #define LABEL_PAD 1
33 #define LABEL_SIDE_PAD 2
34
35 enum {
36   PROP_0,
37   PROP_LABEL,
38   PROP_LABEL_XALIGN,
39   PROP_LABEL_YALIGN,
40   PROP_SHADOW,
41   PROP_LABEL_WIDGET
42 };
43
44
45 static void gtk_frame_class_init    (GtkFrameClass  *klass);
46 static void gtk_frame_init          (GtkFrame       *frame);
47 static void gtk_frame_set_property (GObject      *object,
48                                     guint         param_id,
49                                     const GValue *value,
50                                     GParamSpec   *pspec);
51 static void gtk_frame_get_property (GObject     *object,
52                                     guint        param_id,
53                                     GValue      *value,
54                                     GParamSpec  *pspec);
55 static void gtk_frame_paint         (GtkWidget      *widget,
56                                      GdkRectangle   *area);
57 static gint gtk_frame_expose        (GtkWidget      *widget,
58                                      GdkEventExpose *event);
59 static void gtk_frame_size_request  (GtkWidget      *widget,
60                                      GtkRequisition *requisition);
61 static void gtk_frame_size_allocate (GtkWidget      *widget,
62                                      GtkAllocation  *allocation);
63 static void gtk_frame_map           (GtkWidget      *widget);
64 static void gtk_frame_unmap         (GtkWidget      *widget);
65 static void gtk_frame_remove        (GtkContainer   *container,
66                                      GtkWidget      *child);
67 static void gtk_frame_forall        (GtkContainer   *container,
68                                      gboolean        include_internals,
69                                      GtkCallback     callback,
70                                      gpointer        callback_data);
71
72 static void gtk_frame_compute_child_allocation      (GtkFrame      *frame,
73                                                      GtkAllocation *child_allocation);
74 static void gtk_frame_real_compute_child_allocation (GtkFrame      *frame,
75                                                      GtkAllocation *child_allocation);
76
77 static GtkBinClass *parent_class = NULL;
78
79
80 GtkType
81 gtk_frame_get_type (void)
82 {
83   static GtkType frame_type = 0;
84
85   if (!frame_type)
86     {
87       static const GtkTypeInfo frame_info =
88       {
89         "GtkFrame",
90         sizeof (GtkFrame),
91         sizeof (GtkFrameClass),
92         (GtkClassInitFunc) gtk_frame_class_init,
93         (GtkObjectInitFunc) gtk_frame_init,
94         /* reserved_1 */ NULL,
95         /* reserved_2 */ NULL,
96         (GtkClassInitFunc) NULL,
97       };
98
99       frame_type = gtk_type_unique (gtk_bin_get_type (), &frame_info);
100     }
101
102   return frame_type;
103 }
104
105 static void
106 gtk_frame_class_init (GtkFrameClass *class)
107 {
108   GObjectClass *gobject_class;
109   GtkObjectClass *object_class;
110   GtkWidgetClass *widget_class;
111   GtkContainerClass *container_class;
112
113   gobject_class = (GObjectClass*) class;
114   object_class = GTK_OBJECT_CLASS (class);
115   widget_class = GTK_WIDGET_CLASS (class);
116   container_class = GTK_CONTAINER_CLASS (class);
117
118   parent_class = gtk_type_class (gtk_bin_get_type ());
119
120   gobject_class->set_property = gtk_frame_set_property;
121   gobject_class->get_property = gtk_frame_get_property;
122
123   g_object_class_install_property (gobject_class,
124                                    PROP_LABEL,
125                                    g_param_spec_string ("label",
126                                                         _("Label"),
127                                                         _("Text of the frame's label."),
128                                                         NULL,
129                                                         G_PARAM_READABLE |
130                                                         G_PARAM_WRITABLE));
131   g_object_class_install_property (gobject_class,
132                                    PROP_LABEL_XALIGN,
133                                    g_param_spec_double ("label_xalign",
134                                                         _("Label xalign"),
135                                                         _("The horizontal alignment of the label."),
136                                                         0.0,
137                                                         1.0,
138                                                         0.5,
139                                                         G_PARAM_READABLE |
140                                                         G_PARAM_WRITABLE));
141   g_object_class_install_property (gobject_class,
142                                    PROP_LABEL_YALIGN,
143                                    g_param_spec_double ("label_yalign",
144                                                         _("Label yalign"),
145                                                         _("The vertical alignment of the label."),
146                                                         0.0,
147                                                         1.0,
148                                                         0.5,
149                                                         G_PARAM_READABLE |
150                                                         G_PARAM_WRITABLE));
151   g_object_class_install_property (gobject_class,
152                                    PROP_SHADOW,
153                                    g_param_spec_enum ("shadow",
154                                                       _("Frame shadow"),
155                                                       _("Appearance of the frame border."),
156                                                       GTK_TYPE_SHADOW_TYPE,
157                                                       GTK_SHADOW_ETCHED_IN,
158                                                       G_PARAM_READABLE | G_PARAM_WRITABLE));
159
160   g_object_class_install_property (gobject_class,
161                                    PROP_LABEL_WIDGET,
162                                    g_param_spec_object ("label_widget",
163                                                         _("Label widget"),
164                                                         _("A widget to display in place of the usual frame label."),
165                                                         GTK_TYPE_WIDGET,
166                                                         G_PARAM_READABLE | G_PARAM_WRITABLE));
167   
168   widget_class->expose_event = gtk_frame_expose;
169   widget_class->size_request = gtk_frame_size_request;
170   widget_class->size_allocate = gtk_frame_size_allocate;
171   widget_class->map = gtk_frame_map;
172   widget_class->unmap = gtk_frame_unmap;
173
174   container_class->remove = gtk_frame_remove;
175   container_class->forall = gtk_frame_forall;
176
177   class->compute_child_allocation = gtk_frame_real_compute_child_allocation;
178 }
179
180 static void
181 gtk_frame_init (GtkFrame *frame)
182 {
183   frame->label_widget = NULL;
184   frame->shadow_type = GTK_SHADOW_ETCHED_IN;
185   frame->label_xalign = 0.0;
186   frame->label_yalign = 0.5;
187 }
188
189 static void 
190 gtk_frame_set_property (GObject         *object,
191                         guint            prop_id,
192                         const GValue    *value,
193                         GParamSpec      *pspec)
194 {
195   GtkFrame *frame;
196
197   frame = GTK_FRAME (object);
198
199   switch (prop_id)
200     {
201     case PROP_LABEL:
202       gtk_frame_set_label (frame, g_value_get_string (value));
203       break;
204     case PROP_LABEL_XALIGN:
205       gtk_frame_set_label_align (frame, g_value_get_double (value), 
206                                  frame->label_yalign);
207       break;
208     case PROP_LABEL_YALIGN:
209       gtk_frame_set_label_align (frame, frame->label_xalign, 
210                                  g_value_get_double (value));
211       break;
212     case PROP_SHADOW:
213       gtk_frame_set_shadow_type (frame, g_value_get_enum (value));
214       break;
215     case PROP_LABEL_WIDGET:
216       gtk_frame_set_label_widget (frame, g_value_get_object (value));
217       break;
218     default:      
219       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
220       break;
221     }
222 }
223
224 static void 
225 gtk_frame_get_property (GObject         *object,
226                         guint            prop_id,
227                         GValue          *value,
228                         GParamSpec      *pspec)
229 {
230   GtkFrame *frame;
231
232   frame = GTK_FRAME (object);
233
234   switch (prop_id)
235     {
236     case PROP_LABEL:
237       g_value_set_string (value, gtk_frame_get_label (frame));
238       break;
239     case PROP_LABEL_XALIGN:
240       g_value_set_double (value, frame->label_xalign);
241       break;
242     case PROP_LABEL_YALIGN:
243       g_value_set_double (value, frame->label_yalign);
244       break;
245     case PROP_SHADOW:
246       g_value_set_enum (value, frame->shadow_type);
247       break;
248     case PROP_LABEL_WIDGET:
249       g_value_set_object (value,
250                           frame->label_widget ?
251                           G_OBJECT (frame->label_widget) : NULL);
252       break;
253     default:
254       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
255       break;
256     }
257 }
258
259 GtkWidget*
260 gtk_frame_new (const gchar *label)
261 {
262   GtkFrame *frame;
263
264   frame = gtk_type_new (gtk_frame_get_type ());
265
266   gtk_frame_set_label (frame, label);
267
268   return GTK_WIDGET (frame);
269 }
270
271 static void
272 gtk_frame_remove (GtkContainer *container,
273                   GtkWidget    *child)
274 {
275   GtkFrame *frame = GTK_FRAME (container);
276
277   if (frame->label_widget == child)
278     gtk_frame_set_label_widget (frame, NULL);
279   else
280     GTK_CONTAINER_CLASS (parent_class)->remove (container, child);
281 }
282
283 static void
284 gtk_frame_forall (GtkContainer *container,
285                   gboolean      include_internals,
286                   GtkCallback   callback,
287                   gpointer      callback_data)
288 {
289   GtkBin *bin = GTK_BIN (container);
290   GtkFrame *frame = GTK_FRAME (container);
291
292   if (bin->child)
293     (* callback) (bin->child, callback_data);
294
295   if (frame->label_widget)
296     (* callback) (frame->label_widget, callback_data);
297 }
298
299 void
300 gtk_frame_set_label (GtkFrame *frame,
301                      const gchar *label)
302 {
303   g_return_if_fail (GTK_IS_FRAME (frame));
304
305   if (!label)
306     {
307       gtk_frame_set_label_widget (frame, NULL);
308     }
309   else
310     {
311       GtkWidget *child = gtk_label_new (label);
312       gtk_widget_show (child);
313
314       gtk_frame_set_label_widget (frame, child);
315     }
316
317   g_object_notify (G_OBJECT (frame), "label");
318 }
319
320 /**
321  * gtk_frame_get_label:
322  * @frame: a #GtkFrame
323  * 
324  * If the frame's label widget is a #GtkLabel, return the
325  * text in the label widget. (The frame will have a #GtkLabel
326  * for the label widget if a non-%NULL argument was passed
327  * to gtk_frame_new().)
328  * 
329  * Return value: the text in the label, or %NULL if there
330  *               was no label widget or the lable widget was not
331  *               a #GtkLabel. This value must be freed with g_free().
332  **/
333 G_CONST_RETURN gchar *
334 gtk_frame_get_label (GtkFrame *frame)
335 {
336   g_return_val_if_fail (GTK_IS_FRAME (frame), NULL);
337
338   if (frame->label_widget && GTK_IS_LABEL (frame->label_widget))
339     return gtk_label_get_text (GTK_LABEL (frame->label_widget));
340   else
341     return NULL;
342 }
343
344 /**
345  * gtk_frame_set_label_widget:
346  * @frame: a #GtkFrame
347  * @label_widget: the new label widget
348  * 
349  * Set the label widget for the frame. This is the widget that
350  * will appear embedded in the top edge of the frame as a
351  * title.
352  **/
353 void
354 gtk_frame_set_label_widget (GtkFrame  *frame,
355                             GtkWidget *label_widget)
356 {
357   gboolean need_resize = FALSE;
358   
359   g_return_if_fail (GTK_IS_FRAME (frame));
360   g_return_if_fail (label_widget == NULL || GTK_IS_WIDGET (label_widget));
361   g_return_if_fail (label_widget == NULL || label_widget->parent == NULL);
362   
363   if (frame->label_widget == label_widget)
364     return;
365   
366   if (frame->label_widget)
367     {
368       need_resize = GTK_WIDGET_VISIBLE (frame->label_widget);
369       gtk_widget_unparent (frame->label_widget);
370     }
371
372   frame->label_widget = label_widget;
373     
374   if (label_widget)
375     {
376       frame->label_widget = label_widget;
377       gtk_widget_set_parent (label_widget, GTK_WIDGET (frame));
378       need_resize |= GTK_WIDGET_VISIBLE (label_widget);
379     }
380   
381   if (GTK_WIDGET_VISIBLE (frame) && need_resize)
382     gtk_widget_queue_resize (GTK_WIDGET (frame));
383
384   g_object_notify (G_OBJECT (frame), "label_widget");
385 }
386
387 /**
388  * gtk_frame_get_label_widget:
389  * @frame: a #GtkFrame
390  *
391  * Retrieves the label widget for the frame. See
392  * gtk_frame_set_label_widget().
393  *
394  * Return value: the label widget, or %NULL if there is none.
395  **/
396 GtkWidget *
397 gtk_frame_get_label_widget (GtkFrame *frame)
398 {
399   g_return_val_if_fail (GTK_IS_FRAME (frame), NULL);
400
401   return frame->label_widget;
402 }
403
404 void
405 gtk_frame_set_label_align (GtkFrame *frame,
406                            gfloat    xalign,
407                            gfloat    yalign)
408 {
409   g_return_if_fail (GTK_IS_FRAME (frame));
410
411   xalign = CLAMP (xalign, 0.0, 1.0);
412   yalign = CLAMP (yalign, 0.0, 1.0);
413
414   if (xalign != frame->label_xalign)
415     {
416       frame->label_xalign = xalign;
417       g_object_notify (G_OBJECT (frame), "label_xalign");
418     }
419
420   if (yalign != frame->label_yalign)
421     {
422       frame->label_yalign = yalign;
423       g_object_notify (G_OBJECT (frame), "label_yalign");
424     }
425
426   gtk_widget_queue_resize (GTK_WIDGET (frame));
427 }
428
429 /**
430  * gtk_frame_get_label_align:
431  * @frame: a #GtkFrame
432  * @xalign: location to store X alignment of frame's label, or %NULL
433  * @yalign: location to store X alignment of frame's label, or %NULL
434  * 
435  * Retrieves the X and Y alignment of the frame's label. See
436  * gtk_frame_set_label_align().
437  **/
438 void
439 gtk_frame_get_label_align (GtkFrame *frame,
440                            gfloat   *xalign,
441                            gfloat   *yalign)
442 {
443   g_return_if_fail (GTK_IS_FRAME (frame));
444
445   if (xalign)
446     *xalign = frame->label_xalign;
447   if (yalign)
448     *yalign = frame->label_yalign;
449 }
450
451 void
452 gtk_frame_set_shadow_type (GtkFrame      *frame,
453                            GtkShadowType  type)
454 {
455   g_return_if_fail (GTK_IS_FRAME (frame));
456
457   if ((GtkShadowType) frame->shadow_type != type)
458     {
459       frame->shadow_type = type;
460       g_object_notify (G_OBJECT (frame), "shadow");
461
462       if (GTK_WIDGET_DRAWABLE (frame))
463         {
464           gtk_widget_queue_clear (GTK_WIDGET (frame));
465         }
466       
467       gtk_widget_queue_resize (GTK_WIDGET (frame));
468     }
469 }
470
471 /**
472  * gtk_frame_get_shadow_type:
473  * @frame: a #GtkFrame
474  *
475  * Retrieves the shadow type of the frame. See
476  * gtk_frame_set_shadow_type().
477  *
478  * Return value: the current shadow type of the frame.
479  **/
480 GtkShadowType
481 gtk_frame_get_shadow_type (GtkFrame *frame)
482 {
483   g_return_val_if_fail (GTK_IS_FRAME (frame), GTK_SHADOW_ETCHED_IN);
484
485   return frame->shadow_type;
486 }
487
488 static void
489 gtk_frame_paint (GtkWidget    *widget,
490                  GdkRectangle *area)
491 {
492   GtkFrame *frame;
493   gint x, y, width, height;
494
495   if (GTK_WIDGET_DRAWABLE (widget))
496     {
497       frame = GTK_FRAME (widget);
498
499       x = frame->child_allocation.x - widget->style->xthickness;
500       y = frame->child_allocation.y - widget->style->ythickness;
501       width = frame->child_allocation.width + 2 * widget->style->xthickness;
502       height =  frame->child_allocation.height + 2 * widget->style->ythickness;
503
504       if (frame->label_widget)
505         {
506           GtkRequisition child_requisition;
507           gfloat xalign;
508           gint height_extra;
509           gint x2;
510
511           gtk_widget_get_child_requisition (frame->label_widget, &child_requisition);
512
513           if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR)
514             xalign = frame->label_xalign;
515           else
516             xalign = 1 - frame->label_xalign;
517
518           height_extra = MAX (0, child_requisition.height - widget->style->xthickness);
519           y -= height_extra * (1 - frame->label_yalign);
520           height += height_extra * (1 - frame->label_yalign);
521           
522           x2 = widget->style->xthickness + (frame->child_allocation.width - child_requisition.width - 2 * LABEL_PAD - 2 * LABEL_SIDE_PAD) * xalign + LABEL_SIDE_PAD;
523
524           
525           gtk_paint_shadow_gap (widget->style, widget->window,
526                                 GTK_STATE_NORMAL, frame->shadow_type,
527                                 area, widget, "frame",
528                                 x, y, width, height,
529                                 GTK_POS_TOP, 
530                                 x2, child_requisition.width + 2 * LABEL_PAD);
531         }
532        else
533          gtk_paint_shadow (widget->style, widget->window,
534                            GTK_STATE_NORMAL, frame->shadow_type,
535                            area, widget, "frame",
536                            x, y, width, height);
537     }
538 }
539
540 static gboolean
541 gtk_frame_expose (GtkWidget      *widget,
542                   GdkEventExpose *event)
543 {
544   if (GTK_WIDGET_DRAWABLE (widget))
545     {
546       gtk_frame_paint (widget, &event->area);
547
548       (* GTK_WIDGET_CLASS (parent_class)->expose_event) (widget, event);
549     }
550
551   return FALSE;
552 }
553
554 static void
555 gtk_frame_size_request (GtkWidget      *widget,
556                         GtkRequisition *requisition)
557 {
558   GtkFrame *frame = GTK_FRAME (widget);
559   GtkBin *bin = GTK_BIN (widget);
560   GtkRequisition child_requisition;
561   
562   if (frame->label_widget && GTK_WIDGET_VISIBLE (frame->label_widget))
563     {
564       gtk_widget_size_request (frame->label_widget, &child_requisition);
565
566       requisition->width = child_requisition.width + 2 * LABEL_PAD + 2 * LABEL_SIDE_PAD;
567       requisition->height =
568         MAX (0, child_requisition.height - GTK_WIDGET (widget)->style->xthickness);
569     }
570   else
571     {
572       requisition->width = 0;
573       requisition->height = 0;
574     }
575   
576   if (bin->child && GTK_WIDGET_VISIBLE (bin->child))
577     {
578       gtk_widget_size_request (bin->child, &child_requisition);
579
580       requisition->width = MAX (requisition->width, child_requisition.width);
581       requisition->height += child_requisition.height;
582     }
583
584   requisition->width += (GTK_CONTAINER (widget)->border_width +
585                          GTK_WIDGET (widget)->style->xthickness) * 2;
586   requisition->height += (GTK_CONTAINER (widget)->border_width +
587                           GTK_WIDGET (widget)->style->ythickness) * 2;
588 }
589
590 static void
591 gtk_frame_size_allocate (GtkWidget     *widget,
592                          GtkAllocation *allocation)
593 {
594   GtkFrame *frame = GTK_FRAME (widget);
595   GtkBin *bin = GTK_BIN (widget);
596   GtkAllocation new_allocation;
597
598   widget->allocation = *allocation;
599
600   gtk_frame_compute_child_allocation (frame, &new_allocation);
601   
602   /* If the child allocation changed, that means that the frame is drawn
603    * in a new place, so we must redraw the entire widget.
604    */
605   if (GTK_WIDGET_MAPPED (widget) &&
606       (new_allocation.x != frame->child_allocation.x ||
607        new_allocation.y != frame->child_allocation.y ||
608        new_allocation.width != frame->child_allocation.width ||
609        new_allocation.height != frame->child_allocation.height))
610     gtk_widget_queue_clear (widget);
611   
612   if (bin->child && GTK_WIDGET_VISIBLE (bin->child))
613     gtk_widget_size_allocate (bin->child, &new_allocation);
614   
615   frame->child_allocation = new_allocation;
616   
617   if (frame->label_widget && GTK_WIDGET_VISIBLE (frame->label_widget))
618     {
619       GtkRequisition child_requisition;
620       GtkAllocation child_allocation;
621       gfloat xalign;
622
623       gtk_widget_get_child_requisition (frame->label_widget, &child_requisition);
624
625       if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR)
626         xalign = frame->label_xalign;
627       else
628         xalign = 1 - frame->label_xalign;
629       
630       child_allocation.x = frame->child_allocation.x + LABEL_SIDE_PAD +
631         (frame->child_allocation.width - child_requisition.width - 2 * LABEL_PAD - 2 * LABEL_SIDE_PAD) * xalign + LABEL_PAD;
632       child_allocation.width = child_requisition.width;
633
634       child_allocation.y = frame->child_allocation.y - child_requisition.height;
635       child_allocation.height = child_requisition.height;
636
637       gtk_widget_size_allocate (frame->label_widget, &child_allocation);
638     }
639 }
640
641 static void
642 gtk_frame_map (GtkWidget *widget)
643 {
644   GtkFrame *frame = GTK_FRAME (widget);
645   
646   if (frame->label_widget &&
647       GTK_WIDGET_VISIBLE (frame->label_widget) &&
648       !GTK_WIDGET_MAPPED (frame->label_widget))
649     gtk_widget_map (frame->label_widget);
650
651   if (GTK_WIDGET_CLASS (parent_class)->map)
652     (* GTK_WIDGET_CLASS (parent_class)->map) (widget);
653 }
654
655 static void
656 gtk_frame_unmap (GtkWidget *widget)
657 {
658   GtkFrame *frame = GTK_FRAME (widget);
659
660   if (GTK_WIDGET_CLASS (parent_class)->unmap)
661     (* GTK_WIDGET_CLASS (parent_class)->unmap) (widget);
662
663   if (frame->label_widget && GTK_WIDGET_MAPPED (frame->label_widget))
664     gtk_widget_unmap (frame->label_widget);
665 }
666
667 static void
668 gtk_frame_compute_child_allocation (GtkFrame      *frame,
669                                     GtkAllocation *child_allocation)
670 {
671   g_return_if_fail (GTK_IS_FRAME (frame));
672   g_return_if_fail (child_allocation != NULL);
673
674   GTK_FRAME_GET_CLASS (frame)->compute_child_allocation (frame, child_allocation);
675 }
676
677 static void
678 gtk_frame_real_compute_child_allocation (GtkFrame      *frame,
679                                          GtkAllocation *child_allocation)
680 {
681   GtkWidget *widget = GTK_WIDGET (frame);
682   GtkAllocation *allocation = &widget->allocation;
683   GtkRequisition child_requisition;
684   gint top_margin;
685
686   if (frame->label_widget)
687     {
688       gtk_widget_get_child_requisition (frame->label_widget, &child_requisition);
689       top_margin = MAX (child_requisition.height, widget->style->ythickness);
690     }
691   else
692     top_margin = widget->style->ythickness;
693   
694   child_allocation->x = (GTK_CONTAINER (frame)->border_width +
695                          widget->style->xthickness);
696   child_allocation->width = MAX(1, (gint)allocation->width - child_allocation->x * 2);
697   
698   child_allocation->y = (GTK_CONTAINER (frame)->border_width + top_margin);
699   child_allocation->height = MAX (1, ((gint)allocation->height - child_allocation->y -
700                                       (gint)GTK_CONTAINER (frame)->border_width -
701                                       (gint)widget->style->ythickness));
702   
703   child_allocation->x += allocation->x;
704   child_allocation->y += allocation->y;
705 }