#include <string.h>
#include "gtkframe.h"
#include "gtklabel.h"
+#include "gtkprivate.h"
#include "gtkintl.h"
+#include "gtkalias.h"
#define LABEL_PAD 1
#define LABEL_SIDE_PAD 2
(GInstanceInitFunc) gtk_frame_init,
};
- frame_type = g_type_register_static (GTK_TYPE_BIN, "GtkFrame",
+ frame_type = g_type_register_static (GTK_TYPE_BIN, I_("GtkFrame"),
&frame_info, 0);
}
P_("Label"),
P_("Text of the frame's label"),
NULL,
- G_PARAM_READABLE |
- G_PARAM_WRITABLE));
+ GTK_PARAM_READABLE |
+ GTK_PARAM_WRITABLE));
g_object_class_install_property (gobject_class,
PROP_LABEL_XALIGN,
- g_param_spec_float ("label_xalign",
+ g_param_spec_float ("label-xalign",
P_("Label xalign"),
P_("The horizontal alignment of the label"),
0.0,
1.0,
0.5,
- G_PARAM_READABLE |
- G_PARAM_WRITABLE));
+ GTK_PARAM_READWRITE));
g_object_class_install_property (gobject_class,
PROP_LABEL_YALIGN,
- g_param_spec_float ("label_yalign",
+ g_param_spec_float ("label-yalign",
P_("Label yalign"),
P_("The vertical alignment of the label"),
0.0,
1.0,
0.5,
- G_PARAM_READABLE |
- G_PARAM_WRITABLE));
+ GTK_PARAM_READWRITE));
g_object_class_install_property (gobject_class,
PROP_SHADOW,
g_param_spec_enum ("shadow", NULL,
P_("Deprecated property, use shadow_type instead"),
GTK_TYPE_SHADOW_TYPE,
GTK_SHADOW_ETCHED_IN,
- G_PARAM_READABLE | G_PARAM_WRITABLE));
+ GTK_PARAM_READWRITE));
g_object_class_install_property (gobject_class,
PROP_SHADOW_TYPE,
- g_param_spec_enum ("shadow_type",
+ g_param_spec_enum ("shadow-type",
P_("Frame shadow"),
P_("Appearance of the frame border"),
GTK_TYPE_SHADOW_TYPE,
GTK_SHADOW_ETCHED_IN,
- G_PARAM_READABLE | G_PARAM_WRITABLE));
+ GTK_PARAM_READWRITE));
g_object_class_install_property (gobject_class,
PROP_LABEL_WIDGET,
- g_param_spec_object ("label_widget",
+ g_param_spec_object ("label-widget",
P_("Label widget"),
P_("A widget to display in place of the usual frame label"),
GTK_TYPE_WIDGET,
- G_PARAM_READABLE | G_PARAM_WRITABLE));
+ GTK_PARAM_READWRITE));
widget_class->expose_event = gtk_frame_expose;
widget_class->size_request = gtk_frame_size_request;
}
}
+/**
+ * gtk_frame_new:
+ * @label: the text to use as the label of the frame
+ *
+ * Creates a new #GtkFrame, with optional label @label.
+ * If @label is %NULL, the label is omitted.
+ *
+ * Return value: a new #GtkFrame widget
+ **/
GtkWidget*
gtk_frame_new (const gchar *label)
{
(* callback) (frame->label_widget, callback_data);
}
+/**
+ * gtk_frame_set_label:
+ * @frame: a #GtkFrame
+ * @label: the text to use as the label of the frame
+ *
+ * Sets the text of the label. If @label is %NULL,
+ * the current label is removed.
+ **/
void
gtk_frame_set_label (GtkFrame *frame,
const gchar *label)
* gtk_frame_get_label:
* @frame: a #GtkFrame
*
- * If the frame's label widget is a #GtkLabel, return the
+ * If the frame's label widget is a #GtkLabel, returns the
* text in the label widget. (The frame will have a #GtkLabel
* for the label widget if a non-%NULL argument was passed
* to gtk_frame_new().)
* @frame: a #GtkFrame
* @label_widget: the new label widget
*
- * Set the label widget for the frame. This is the widget that
+ * Sets the label widget for the frame. This is the widget that
* will appear embedded in the top edge of the frame as a
* title.
**/
gtk_widget_queue_resize (GTK_WIDGET (frame));
g_object_freeze_notify (G_OBJECT (frame));
- g_object_notify (G_OBJECT (frame), "label_widget");
+ g_object_notify (G_OBJECT (frame), "label-widget");
g_object_notify (G_OBJECT (frame), "label");
g_object_thaw_notify (G_OBJECT (frame));
}
return frame->label_widget;
}
+/**
+ * gtk_frame_set_label_align:
+ * @frame: a #GtkFrame
+ * @xalign: The position of the label along the top edge
+ * of the widget. A value of 0.0 represents left alignment;
+ * 1.0 represents right alignment.
+ * @yalign: The y alignment of the label. A value of 0.0 aligns under
+ * the frame; 1.0 aligns above the frame.
+ *
+ * Sets the alignment of the frame widget's label. The
+ * default values for a newly created frame are 0.0 and 0.5.
+ **/
void
gtk_frame_set_label_align (GtkFrame *frame,
gfloat xalign,
if (xalign != frame->label_xalign)
{
frame->label_xalign = xalign;
- g_object_notify (G_OBJECT (frame), "label_xalign");
+ g_object_notify (G_OBJECT (frame), "label-xalign");
}
if (yalign != frame->label_yalign)
{
frame->label_yalign = yalign;
- g_object_notify (G_OBJECT (frame), "label_yalign");
+ g_object_notify (G_OBJECT (frame), "label-yalign");
}
g_object_thaw_notify (G_OBJECT (frame));
*yalign = frame->label_yalign;
}
+/**
+ * gtk_frame_set_shadow_type:
+ * @frame: a #GtkFrame
+ * @type: the new #GtkShadowType
+ *
+ * Sets the shadow type for @frame.
+ **/
void
gtk_frame_set_shadow_type (GtkFrame *frame,
GtkShadowType type)
if ((GtkShadowType) frame->shadow_type != type)
{
frame->shadow_type = type;
- g_object_notify (G_OBJECT (frame), "shadow_type");
+ g_object_notify (G_OBJECT (frame), "shadow-type");
if (GTK_WIDGET_DRAWABLE (frame))
{
frame = GTK_FRAME (widget);
x = frame->child_allocation.x - widget->style->xthickness;
- y = frame->child_allocation.y; - widget->style->ythickness;
+ y = frame->child_allocation.y - widget->style->ythickness;
width = frame->child_allocation.width + 2 * widget->style->xthickness;
height = frame->child_allocation.height + 2 * widget->style->ythickness;
xalign = 1 - frame->label_xalign;
height_extra = MAX (0, child_requisition.height - widget->style->ythickness);
- y -= height_extra * (1 - frame->label_yalign);
- height += height_extra * (1 - frame->label_yalign);
+ height_extra *= (1 - frame->label_yalign);
+ y -= height_extra;
+ height += height_extra;
x2 = widget->style->xthickness + (frame->child_allocation.width - child_requisition.width - 2 * LABEL_PAD - 2 * LABEL_SIDE_PAD) * xalign + LABEL_SIDE_PAD;
gtk_paint_shadow_gap (widget->style, widget->window,
- GTK_STATE_NORMAL, frame->shadow_type,
+ widget->state, frame->shadow_type,
area, widget, "frame",
x, y, width, height,
GTK_POS_TOP,
}
else
gtk_paint_shadow (widget->style, widget->window,
- GTK_STATE_NORMAL, frame->shadow_type,
+ widget->state, frame->shadow_type,
area, widget, "frame",
x, y, width, height);
}
child_allocation->x += allocation->x;
child_allocation->y += allocation->y;
}
+
+#define __GTK_FRAME_C__
+#include "gtkaliasdef.c"