📄 gtkbox.html
字号:
<HTML><HEAD><TITLE>GtkBox</TITLE><METANAME="GENERATOR"CONTENT="Modular DocBook HTML Stylesheet Version 1.61"><LINKREL="HOME"TITLE="GTK+ Reference Manual"HREF="index.html"><LINKREL="UP"TITLE="GTK+ Widgets and Objects"HREF="gtkobjects.html"><LINKREL="PREVIOUS"TITLE="GtkBin"HREF="gtkbin.html"><LINKREL="NEXT"TITLE="GtkButton"HREF="gtkbutton.html"></HEAD><BODYCLASS="REFENTRY"BGCOLOR="#FFFFFF"TEXT="#000000"LINK="#0000FF"VLINK="#840084"ALINK="#0000FF"><DIVCLASS="NAVHEADER"><TABLEWIDTH="100%"BORDER="0"BGCOLOR="#000000"CELLPADDING="1"CELLSPACING="0"><TR><THCOLSPAN="4"ALIGN="center"><FONTCOLOR="#FFFFFF"SIZE="5">GTK+ Reference Manual</FONT></TH></TR><TR><TDWIDTH="25%"BGCOLOR="#C00000"ALIGN="left"><AHREF="gtkbin.html"><FONTCOLOR="#FFFFFF"SIZE="3"><B><<< Previous Page</B></FONT></A></TD><TDWIDTH="25%"BGCOLOR="#0000C0"ALIGN="center"><FONTCOLOR="#FFFFFF"SIZE="3"><B><AHREF="index.html"><FONTCOLOR="#FFFFFF"SIZE="3"><B>Home</B></FONT></A></B></FONT></TD><TDWIDTH="25%"BGCOLOR="#00C000"ALIGN="center"><FONTCOLOR="#FFFFFF"SIZE="3"><B><AHREF="gtkobjects.html"><FONTCOLOR="#FFFFFF"SIZE="3"><B>Up</B></FONT></A></B></FONT></TD><TDWIDTH="25%"BGCOLOR="#C00000"ALIGN="right"><AHREF="gtkbutton.html"><FONTCOLOR="#FFFFFF"SIZE="3"><B>Next Page >>></B></FONT></A></TD></TR></TABLE></DIV><H1><ANAME="GTKBOX">GtkBox</A></H1><DIVCLASS="REFNAMEDIV"><ANAME="AEN14097"></A><H2>Name</H2>GtkBox -- a base class for box containers</DIV><DIVCLASS="REFSYNOPSISDIV"><ANAME="AEN14100"></A><H2>Synopsis</H2><TABLEBORDER="0"BGCOLOR="#D6E8FF"WIDTH="100%"CELLPADDING="6"><TR><TD><PRECLASS="SYNOPSIS"> #include <gtk/gtk.h>struct <AHREF="gtkbox.html#GTKBOX-STRUCT">GtkBox</A>;struct <AHREF="gtkbox.html#GTKBOXCHILD">GtkBoxChild</A>;void <AHREF="gtkbox.html#GTK-BOX-PACK-START">gtk_box_pack_start</A> (<AHREF="gtkbox.html">GtkBox</A> *box, <AHREF="gtkwidget.html">GtkWidget</A> *child, <AHREF=../glib/glib-basic-types.html#GBOOLEAN>gboolean</A> expand, <AHREF=../glib/glib-basic-types.html#GBOOLEAN>gboolean</A> fill, <AHREF=../glib/glib-basic-types.html#GUINT>guint</A> padding);void <AHREF="gtkbox.html#GTK-BOX-PACK-END">gtk_box_pack_end</A> (<AHREF="gtkbox.html">GtkBox</A> *box, <AHREF="gtkwidget.html">GtkWidget</A> *child, <AHREF=../glib/glib-basic-types.html#GBOOLEAN>gboolean</A> expand, <AHREF=../glib/glib-basic-types.html#GBOOLEAN>gboolean</A> fill, <AHREF=../glib/glib-basic-types.html#GUINT>guint</A> padding);void <AHREF="gtkbox.html#GTK-BOX-PACK-START-DEFAULTS">gtk_box_pack_start_defaults</A> (<AHREF="gtkbox.html">GtkBox</A> *box, <AHREF="gtkwidget.html">GtkWidget</A> *widget);void <AHREF="gtkbox.html#GTK-BOX-PACK-END-DEFAULTS">gtk_box_pack_end_defaults</A> (<AHREF="gtkbox.html">GtkBox</A> *box, <AHREF="gtkwidget.html">GtkWidget</A> *widget);void <AHREF="gtkbox.html#GTK-BOX-SET-HOMOGENEOUS">gtk_box_set_homogeneous</A> (<AHREF="gtkbox.html">GtkBox</A> *box, <AHREF=../glib/glib-basic-types.html#GBOOLEAN>gboolean</A> homogeneous);void <AHREF="gtkbox.html#GTK-BOX-SET-SPACING">gtk_box_set_spacing</A> (<AHREF="gtkbox.html">GtkBox</A> *box, <AHREF=../glib/glib-basic-types.html#GINT>gint</A> spacing);void <AHREF="gtkbox.html#GTK-BOX-REORDER-CHILD">gtk_box_reorder_child</A> (<AHREF="gtkbox.html">GtkBox</A> *box, <AHREF="gtkwidget.html">GtkWidget</A> *child, <AHREF=../glib/glib-basic-types.html#GINT>gint</A> position);void <AHREF="gtkbox.html#GTK-BOX-QUERY-CHILD-PACKING">gtk_box_query_child_packing</A> (<AHREF="gtkbox.html">GtkBox</A> *box, <AHREF="gtkwidget.html">GtkWidget</A> *child, <AHREF=../glib/glib-basic-types.html#GBOOLEAN>gboolean</A> *expand, <AHREF=../glib/glib-basic-types.html#GBOOLEAN>gboolean</A> *fill, <AHREF=../glib/glib-basic-types.html#GUINT>guint</A> *padding, <AHREF="gtk-standard-enumerations.html#GTKPACKTYPE">GtkPackType</A> *pack_type);void <AHREF="gtkbox.html#GTK-BOX-SET-CHILD-PACKING">gtk_box_set_child_packing</A> (<AHREF="gtkbox.html">GtkBox</A> *box, <AHREF="gtkwidget.html">GtkWidget</A> *child, <AHREF=../glib/glib-basic-types.html#GBOOLEAN>gboolean</A> expand, <AHREF=../glib/glib-basic-types.html#GBOOLEAN>gboolean</A> fill, <AHREF=../glib/glib-basic-types.html#GUINT>guint</A> padding, <AHREF="gtk-standard-enumerations.html#GTKPACKTYPE">GtkPackType</A> pack_type); </PRE></TD></TR></TABLE></DIV><DIVCLASS="REFSECT1"><ANAME="AEN14147"></A><H2>Object Hierarchy</H2><TABLEBORDER="0"BGCOLOR="#D6E8FF"WIDTH="100%"CELLPADDING="6"><TR><TD><PRECLASS="SYNOPSIS"> <AHREF="gtkobject.html">GtkObject</A> +----<AHREF="gtkwidget.html">GtkWidget</A> +----<AHREF="gtkcontainer.html">GtkContainer</A> +----GtkBox</PRE></TD></TR></TABLE></DIV><DIVCLASS="REFSECT1"><ANAME="AEN14153"></A><H2>Args</H2><TABLEBORDER="0"BGCOLOR="#D6E8FF"WIDTH="100%"CELLPADDING="6"><TR><TD><PRECLASS="SYNOPSIS"> "<AHREF="gtkbox.html#GTKBOX--SPACING">spacing</A>" <AHREF=../glib/glib-basic-types.html#GINT>gint</A> : Read / Write "<AHREF="gtkbox.html#GTKBOX--HOMOGENEOUS">homogeneous</A>" <AHREF=../glib/glib-basic-types.html#GBOOLEAN>gboolean</A> : Read / Write</PRE></TD></TR></TABLE></DIV><DIVCLASS="REFSECT1"><ANAME="AEN14160"></A><H2>Description</H2><P> GtkBox is an abstract widget which encapsulates functionallity for aparticular kind of container, one that organizes a variable number ofwidgets into a rectangular area. GtkBox currently has two derivedclasses, <AHREF="gtkhbox.html">GtkHBox</A> and <AHREF="gtkvbox.html">GtkVBox</A>. </P><P> The rectangular area of a GtkBox is organized into either a single rowor a single column of child widgets depending upon whether the box isof type <AHREF="gtkhbox.html">GtkHBox</A> or <AHREF="gtkvbox.html">GtkVBox</A>, respectively. Thus, all children of aGtkBox are allocated one dimension in common, which is the height of arow, or the width of a column. </P><P> GtkBox uses a notion of <ICLASS="EMPHASIS">packing</I>. Packing refers toadding widgets with reference to a particular position in a<AHREF="gtkcontainer.html">GtkContainer</A>. For a GtkBox, there are two reference positions: the<ICLASS="EMPHASIS">start</I> and the <ICLASS="EMPHASIS">end</I> of the box. For a<AHREF="gtkvbox.html">GtkVBox</A>, the start is defined as the top of the box and the end isdefined as the bottom. For a <AHREF="gtkhbox.html">GtkHBox</A> the start is defined as theleft side and the end is defined as the right side. </P><P> Use repeated calls to <AHREF="gtkbox.html#GTK-BOX-PACK-START">gtk_box_pack_start</A>() to pack widgets into aGtkBox from start to end. Use <AHREF="gtkbox.html#GTK-BOX-PACK-END">gtk_box_pack_end</A>() to add widgets fromend to start. You may intersperse these calls and add widgets fromboth ends of the same GtkBox. </P><P> Use <AHREF="gtkbox.html#GTK-BOX-PACK-START-DEFAULTS">gtk_box_pack_start_defaults</A>() or <AHREF="gtkbox.html#GTK-BOX-PACK-END-DEFAULTS">gtk_box_pack_end_defaults</A>()to pack widgets into a GtkBox if you do not need to specify the<TTCLASS="STRUCTFIELD"><I>expand</I></TT>, <TTCLASS="STRUCTFIELD"><I>fill</I></TT>, or<TTCLASS="STRUCTFIELD"><I>padding</I></TT> attributes of the child to beadded. </P><P> Because GtkBox is a <AHREF="gtkcontainer.html">GtkContainer</A>, you may also use<AHREF="gtkcontainer.html#GTK-CONTAINER-ADD">gtk_container_add</A>() to insert widgets into the box, and they will bepacked as if with <AHREF="gtkbox.html#GTK-BOX-PACK-START-DEFAULTS">gtk_box_pack_start_defaults</A>(). Use<AHREF="gtkcontainer.html#GTK-CONTAINER-REMOVE">gtk_container_remove</A>() to remove widgets from the GtkBox. </P><P> Use <AHREF="gtkbox.html#GTK-BOX-SET-HOMOGENEOUS">gtk_box_set_homogeneous</A>() to specify whether or not all childrenof the GtkBox are forced to get the same amount of space. </P><P> Use <AHREF="gtkbox.html#GTK-BOX-SET-SPACING">gtk_box_set_spacing</A>() to determine how much space will beminimally placed between all children in the GtkBox. </P><P> Use <AHREF="gtkbox.html#GTK-BOX-REORDER-CHILD">gtk_box_reorder_child</A>() to move a GtkBox child to a differentplace in the box. </P><P> Use <AHREF="gtkbox.html#GTK-BOX-SET-CHILD-PACKING">gtk_box_set_child_packing</A>() to reset the<TTCLASS="STRUCTFIELD"><I>expand</I></TT>, <TTCLASS="STRUCTFIELD"><I>fill</I></TT>,and <TTCLASS="STRUCTFIELD"><I>padding</I></TT> attributes of any GtkBox child.Use <AHREF="gtkbox.html#GTK-BOX-QUERY-CHILD-PACKING">gtk_box_query_child_packing</A>() to query these fields. </P></DIV><DIVCLASS="REFSECT1"><ANAME="AEN14201"></A><H2>Details</H2><DIVCLASS="REFSECT2"><ANAME="AEN14203"></A><H3><ANAME="GTKBOX-STRUCT"></A>struct GtkBox</H3><TABLEBORDER="0"BGCOLOR="#D6E8FF"WIDTH="100%"CELLPADDING="6"><TR><TD><PRECLASS="PROGRAMLISTING">struct GtkBox;</PRE></TD></TR></TABLE><P> The <AHREF="gtkbox.html#GTKBOX-STRUCT">GtkBox</A> describes an instance of GtkBox and contains the following fields.(These fields should be considered read-only. They should never be set byan application.)<DIVCLASS="INFORMALTABLE"><ANAME="AEN14209"></A><P></P><TABLEBORDER="0"WIDTH="100%"BGCOLOR="#FFF0D0"CELLSPACING="0"CELLPADDING="4"CLASS="CALSTABLE"><TBODY><TR><TDWIDTH="20%"ALIGN="LEFT"VALIGN="TOP"><AHREF=../glib/glib-doubly-linked-lists.html#GLIST>GList</A> * <TTCLASS="STRUCTFIELD"><I>children</I></TT>;</TD><TDWIDTH="80%"ALIGN="LEFT"VALIGN="TOP">a list of children belonging the GtkBox. The data is a list ofstructures of type GtkBoxChild.</TD></TR><TR><TDWIDTH="20%"ALIGN="LEFT"VALIGN="TOP"><AHREF=../glib/glib-basic-types.html#GINT16>gint16</A> <TTCLASS="STRUCTFIELD"><I>spacing</I></TT>;</TD><TDWIDTH="80%"ALIGN="LEFT"VALIGN="TOP">the number of pixels to put between children of the GtkBox, zeroby default. Use <AHREF="gtkbox.html#GTK-BOX-SET-SPACING">gtk_box_set_spacing</A>() to set this field.</TD></TR><TR><TDWIDTH="20%"ALIGN="LEFT"VALIGN="TOP"><AHREF=../glib/glib-basic-types.html#GUINT>guint</A> <TTCLASS="STRUCTFIELD"><I>homogeneous</I></TT>;</TD><TDWIDTH="80%"ALIGN="LEFT"VALIGN="TOP">a flag that if <TTCLASS="LITERAL">TRUE</TT> forces all children to get equal space inthe GtkBox; <TTCLASS="LITERAL">FALSE</TT> by default. Use <AHREF="gtkbox.html#GTK-BOX-SET-HOMOGENEOUS">gtk_box_set_homogeneous</A>() to set thisfield.</TD></TR></TBODY></TABLE><P></P></DIV></P></DIV><HR><DIVCLASS="REFSECT2"><ANAME="AEN14234"></A><H3><ANAME="GTKBOXCHILD"></A>struct GtkBoxChild</H3><TABLEBORDER="0"BGCOLOR="#D6E8FF"WIDTH="100%"CELLPADDING="6"><TR><TD><PRECLASS="PROGRAMLISTING">struct GtkBoxChild{ GtkWidget *widget; guint16 padding; guint expand : 1; guint fill : 1; guint pack : 1;};</PRE></TD></TR></TABLE><P> The GtkBoxChild holds a child widget of GtkBox and describeshow the child is to be packed into the GtkBox. Use<AHREF="gtkbox.html#GTK-BOX-QUERY-CHILD-PACKING">gtk_box_query_child_packing</A>() and <AHREF="gtkbox.html#GTK-BOX-SET-CHILD-PACKING">gtk_box_set_child_packing</A>() to queryand reset the <TTCLASS="STRUCTFIELD"><I>padding</I></TT>,<TTCLASS="STRUCTFIELD"><I>expand</I></TT>, <TTCLASS="STRUCTFIELD"><I>fill</I></TT>,and <TTCLASS="STRUCTFIELD"><I>pack</I></TT> fields. </P><P> GtkBoxChild contains the following fields. (These fieldsshould be considered read-only. They should never be directly set by anapplication.)<DIVCLASS="INFORMALTABLE"><ANAME="AEN14248"></A><P></P><TABLEBORDER="0"WIDTH="100%"BGCOLOR="#FFF0D0"CELLSPACING="0"CELLPADDING="4"CLASS="CALSTABLE"><TBODY><TR><TDWIDTH="20%"ALIGN="LEFT"VALIGN="TOP"><AHREF="gtkwidget.html">GtkWidget</A> * <TTCLASS="STRUCTFIELD"><I>widget</I></TT>;</TD><TDWIDTH="80%"ALIGN="LEFT"VALIGN="TOP">the child widget, packed into the GtkBox.</TD></TR><TR><TDWIDTH="20%"ALIGN="LEFT"VALIGN="TOP"><AHREF=../glib/glib-basic-types.html#GUINT16>guint16</A> <TTCLASS="STRUCTFIELD"><I>padding</I></TT>;</TD><TDWIDTH="80%"ALIGN="LEFT"VALIGN="TOP">the number of extra pixels to put between this child and itsneighbors, set when packed, zero by default.</TD></TR><TR><TDWIDTH="20%"ALIGN="LEFT"VALIGN="TOP"><AHREF=../glib/glib-basic-types.html#GUINT>guint</A> <TTCLASS="STRUCTFIELD"><I>expand</I></TT>;</TD><TDWIDTH="80%"ALIGN="LEFT"VALIGN="TOP">flag indicates whether extra space should be given to thischild. Any extra space given to the parent GtkBox is divided up amongall children with this attribute set to <TTCLASS="LITERAL">TRUE</TT>; set when packed, <TTCLASS="LITERAL">TRUE</TT> bydefault.</TD></TR><TR><TDWIDTH="20%"ALIGN="LEFT"VALIGN="TOP"><AHREF=../glib/glib-basic-types.html#GUINT>guint</A> <TTCLASS="STRUCTFIELD"><I>fill</I></TT>;</TD><TDWIDTH="80%"ALIGN="LEFT"VALIGN="TOP">flag indicates whether any extra space given to this child due to its<TTCLASS="STRUCTFIELD"><I>expand</I></TT> attribute being set is actuallyallocated to the child, rather than being used as paddingaround the widget; set when packed, <TTCLASS="LITERAL">TRUE</TT> by default.</TD></TR><TR><TDWIDTH="20%"ALIGN="LEFT"VALIGN="TOP"><AHREF=../glib/glib-basic-types.html#GUINT>guint</A> <TTCLASS="STRUCTFIELD"><I>pack</I></TT>;</TD><TDWIDTH="80%"ALIGN="LEFT"VALIGN="TOP">one of<AHREF="gtk-standard-enumerations.html#GTKPACKTYPE">GtkPackType</A> indicating whether the child is packed with reference tothe start (top/left) or end (bottom/right) of the GtkBox.</TD></TR></TBODY></TABLE><P></P></DIV> </P></DIV><HR><DIVCLASS="REFSECT2"><ANAME="AEN14283"></A><H3><ANAME="GTK-BOX-PACK-START"></A>gtk_box_pack_start ()</H3><TABLEBORDER="0"BGCOLOR="#D6E8FF"WIDTH="100%"CELLPADDING="6"><TR><TD><PRECLASS="PROGRAMLISTING">void gtk_box_pack_start (<AHREF="gtkbox.html">GtkBox</A> *box, <AHREF="gtkwidget.html">GtkWidget</A> *child, <AHREF=../glib/glib-basic-types.html#GBOOLEAN>gboolean</A> expand, <AHREF=../glib/glib-basic-types.html#GBOOLEAN>gboolean</A> fill, <AHREF=../glib/glib-basic-types.html#GUINT>guint</A> padding);</PRE></TD></TR></TABLE><P
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -