A framework (Frames) can be used to encapsulate one or a set of artifacts in a box, and the framework itself can have a label. The position of the label and the style of the box can be changed flexibly.
The framework can be created with the following function:
Gtkwidget *gtk_frame_new (const Gchar *label);
The label is placed by default in the upper-left corner of the frame. When you pass a null value as a label parameter, the frame does not display a label. The label text can be changed with the following function.
void Gtk_frame_set_label (Gtkframe *frame,
Const Gchar *label);
The position of the label can be changed with the following function:
void Gtk_frame_set_label_align (Gtkframe *frame,
Gfloat Xalign,
Gfloat yalign);
The xalign and yalign parameter values range between 0.0 and 1.0. XALIGN Specifies the position of the label on the upper horizontal line of the frame member. Yalign has not been used yet. The default value of Xalign is 0.0, which places the label at the leftmost end of the frame widget.
The following function changes the style of the box to show the outline of the frame.
void Gtk_frame_set_shadow_type (Gtkframe *frame,
Gtkshadowtype type);
The type parameter can take one of the following values:
Gtk_shadow_none
Gtk_shadow_in
Gtk_shadow_out
Gtk_shadow_etched_in (default value)
Gtk_shadow_etched_out.
1 /*Create a Frame*/2frame =gtk_frame_new (NULL);3 Gtk_container_add (Gtk_container (window), frame);4 5 /*set the label for a frame*/6Gtk_frame_set_label (Gtk_frame (frame),"GTK Frame Widget");7 8 /*position the label to the right of the frame*/9Gtk_frame_set_label_align (Gtk_frame (frame),1.0,0.0);Ten One /*set the style of the frame*/ AGtk_frame_set_shadow_type (Gtk_frame (frame), gtk_shadow_etched_out);
Today's box experience is the highlight of the window.
GTK + Learning Notes (eight)