Description
The frame widget is a bin that surrounds its child with a decorative
frame and an optional label. If present, the label is drawn in a gap
in the top side of the frame. The position of the label can be
controlled with gtk_frame_set_label_align().
GtkFrame as GtkBuildable
The GtkFrame implementation of the GtkBuildable interface supports
placing a child in the label position by specifying “label” as the
“type” attribute of a <child> element. A normal content child can
be specified without specifying a <child> type attribute.
An example of a UI definition fragment with GtkFrame:
CSS nodes
GtkFrame has a main CSS node named “frame” and a subnode named “border”. The
“border” node is used to draw the visible border. You can set the appearance
of the border using CSS properties like “border-style” on the “border” node.
The border node can be given the style class “.flat”, which is used by themes
to disable drawing of the border. To do this from code, call
gtk_frame_set_shadow_type() with GTK_SHADOW_NONE to add the “.flat” class or
any other shadow type to remove it.
Functions
gtk_frame_new ()
GtkWidget *
gtk_frame_new (const gchar *label);
Creates a new GtkFrame, with optional label label
.
If label
is NULL, the label is omitted.
gtk_frame_set_label_widget ()
void
gtk_frame_set_label_widget (GtkFrame *frame,
GtkWidget *label_widget);
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_frame_set_label_align ()
void
gtk_frame_set_label_align (GtkFrame *frame,
gfloat xalign,
gfloat yalign);
Sets the alignment of the frame widget’s label. The
default values for a newly created frame are 0.0 and 0.5.
gtk_frame_set_shadow_type ()
void
gtk_frame_set_shadow_type (GtkFrame *frame,
GtkShadowType type);
Sets the “shadow-type” for frame
, i.e. whether it is drawn without
(GTK_SHADOW_NONE) or with (other values) a visible border. Values other than
GTK_SHADOW_NONE are treated identically by GtkFrame. The chosen type is
applied by removing or adding the .flat class to the CSS node named border.
gtk_frame_get_label ()
const gchar *
gtk_frame_get_label (GtkFrame *frame);
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().)
Returns
the text in the label, or NULL if there
was no label widget or the lable widget was not
a GtkLabel. This string is owned by GTK+ and
must not be modified or freed.
[nullable]
Property Details
The “label” property
“label” gchar *
Text of the frame's label.
Owner: GtkFrame
Flags: Read / Write
Default value: NULL
The “label-widget” property
“label-widget” GtkWidget *
A widget to display in place of the usual frame label.
Owner: GtkFrame
Flags: Read / Write
The “label-xalign” property
“label-xalign” gfloat
The horizontal alignment of the label.
Owner: GtkFrame
Flags: Read / Write
Allowed values: [0,1]
Default value: 0
The “label-yalign” property
“label-yalign” gfloat
The vertical alignment of the label.
Owner: GtkFrame
Flags: Read / Write
Allowed values: [0,1]
Default value: 0.5
The “shadow-type” property
“shadow-type” GtkShadowType
Appearance of the frame border.
Owner: GtkFrame
Flags: Read / Write
Default value: GTK_SHADOW_ETCHED_IN