![]() |
![]() |
![]() |
![]() |
gchar * | label | Read / Write |
GtkWidget * | label-widget | Read / Write |
gfloat | label-xalign | Read / Write |
GtkShadowType | shadow-type | Read / Write |
GObject ╰── GInitiallyUnowned ╰── GtkWidget ╰── GtkContainer ╰── GtkBin ╰── GtkFrame ╰── GtkAspectFrame
The frame widget is a bin that surrounds its child with a decorative
frame and an optional label. If present, the label is drawn inside
the top edge of the frame. The horizontal position of the label can
be controlled with gtk_frame_set_label_align()
.
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:
1 2 3 4 5 6 7 8 |
<object class="GtkFrame"> <child type="label"> <object class="GtkLabel" id="frame_label"/> </child> <child> <object class="GtkEntry" id="frame_content"/> </child> </object> |
1 2 3 |
frame[.flat] ├── <label widget> ╰── <child> |
GtkFrame has a main CSS node with name “frame”, which is used to draw the visible border. You can set the appearance of the border using CSS properties like “border-style” on this node.
The 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.
GtkWidget *
gtk_frame_new (const gchar *label
);
Creates a new GtkFrame, with optional label label
.
If label
is NULL
, the label is omitted.
void gtk_frame_set_label (GtkFrame *frame
,const gchar *label
);
Removes the current “label-widget”. If label
is not NULL
, creates a
new GtkLabel with that text and adds it as the “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.
void gtk_frame_set_label_align (GtkFrame *frame
,gfloat xalign
);
Sets the X alignment of the frame widget’s label. The default value for a newly created frame is 0.0.
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. |
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 main CSS node, frame.
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()
.)
gfloat
gtk_frame_get_label_align (GtkFrame *frame
);
Retrieves the X alignment of the frame’s label. See
gtk_frame_set_label_align()
.
GtkWidget *
gtk_frame_get_label_widget (GtkFrame *frame
);
Retrieves the label widget for the frame. See
gtk_frame_set_label_widget()
.
GtkShadowType
gtk_frame_get_shadow_type (GtkFrame *frame
);
Retrieves the shadow type of the frame. See
gtk_frame_set_shadow_type()
.
“label”
property“label” gchar *
Text of the frame’s label.
Owner: GtkFrame
Flags: Read / Write
Default value: NULL
“label-widget”
property“label-widget” GtkWidget *
A widget to display in place of the usual frame label.
Owner: GtkFrame
Flags: Read / Write
“label-xalign”
property“label-xalign” gfloat
The horizontal alignment of the label.
Owner: GtkFrame
Flags: Read / Write
Allowed values: [0,1]
Default value: 0
“shadow-type”
property“shadow-type” GtkShadowType
Appearance of the frame.
Owner: GtkFrame
Flags: Read / Write
Default value: GTK_SHADOW_ETCHED_IN