GtkFrame — A widget with a decorative frame and optional label
GtkWidget * | gtk_frame_new () |
void | gtk_frame_set_child () |
GtkWidget * | gtk_frame_get_child () |
void | gtk_frame_set_label () |
const char * | gtk_frame_get_label () |
void | gtk_frame_set_label_widget () |
GtkWidget * | gtk_frame_get_label_widget () |
void | gtk_frame_set_label_align () |
float | gtk_frame_get_label_align () |
GtkWidget * | child | Read / Write |
char * | label | Read / Write |
GtkWidget * | label-widget | Read / Write |
float | label-xalign | Read / Write |
struct | GtkFrame |
struct | GtkFrameClass |
GObject ╰── GInitiallyUnowned ╰── GtkWidget ╰── GtkFrame
GtkFrame implements GtkAccessible, GtkBuildable and GtkConstraintTarget.
#include <gtk/gtk.h>
The frame widget is a widget 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()
.
GtkFrame clips its child. You can use this to add rounded corners to widgets, but be aware that it also cuts off shadows.
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:
<object class="GtkFrame"> <child type="label"> <object class="GtkLabel" id="frame_label"/> </child> <child> <object class="GtkEntry" id="frame_content"/> </child> </object>
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.
GtkWidget *
gtk_frame_new (const char *label
);
Creates a new GtkFrame, with optional label label
. If label
is NULL
, the label is omitted.
label | the text to use as the label of the frame. | [allow-none] |
a new GtkFrame widget
void gtk_frame_set_child (GtkFrame *frame
,GtkWidget *child
);
Sets the child widget of frame
.
frame | a GtkFrame | |
child | the child widget. | [allow-none] |
GtkWidget *
gtk_frame_get_child (GtkFrame *frame
);
Gets the child widget of frame
.
frame | a GtkFrame |
the child widget of frame
.
[nullable][transfer none]
void gtk_frame_set_label (GtkFrame *frame
,const char *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”.
frame | a GtkFrame | |
label | the text to use as the label of the frame. | [allow-none] |
const char *
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()
.)
frame | a GtkFrame |
the text in the label, or NULL
if there was no label widget or the label widget was not a GtkLabel. This string is owned by GTK+ and must not be modified or freed.
[nullable]
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.
frame | a GtkFrame | |
label_widget | the new label widget. | [nullable] |
GtkWidget *
gtk_frame_get_label_widget (GtkFrame *frame
);
Retrieves the label widget for the frame. See gtk_frame_set_label_widget()
.
frame | a GtkFrame |
the label widget, or NULL
if there is none.
[nullable][transfer none]
void gtk_frame_set_label_align (GtkFrame *frame
,float 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. |
float
gtk_frame_get_label_align (GtkFrame *frame
);
Retrieves the X alignment of the frame’s label. See gtk_frame_set_label_align()
.
frame | a GtkFrame |
struct GtkFrame;
struct GtkFrameClass { GtkWidgetClass parent_class; void (*compute_child_allocation) (GtkFrame *frame, GtkAllocation *allocation); };
|
“label”
property“label” char *
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” float
The horizontal alignment of the label.
Owner: GtkFrame
Flags: Read / Write
Allowed values: [0,1]
Default value: 0
© 2005–2020 The GNOME Project
Licensed under the GNU Lesser General Public License version 2.1 or later.
https://developer.gnome.org/gtk4/4.0/GtkFrame.html