📄 gtktable.html
字号:
<p>The <a class="link" href="GtkTable.html" title="GtkTable"><span class="type">GtkTable</span></a> functions allow the programmer to arrange widgets in rows andcolumns, making it easy to align many widgets next to each other,horizontally and vertically.</p><p>Tables are created with a call to <a class="link" href="GtkTable.html#gtk-table-new"><code class="function">gtk_table_new()</code></a>, the size of which canlater be changed with <a class="link" href="GtkTable.html#gtk-table-resize"><code class="function">gtk_table_resize()</code></a>.</p><p>Widgets can be added to a table using <a class="link" href="GtkTable.html#gtk-table-attach"><code class="function">gtk_table_attach()</code></a> or the moreconvenient (but slightly less flexible) <a class="link" href="GtkTable.html#gtk-table-attach-defaults"><code class="function">gtk_table_attach_defaults()</code></a>.</p><p>To alter the space next to a specific row, use <a class="link" href="GtkTable.html#gtk-table-set-row-spacing"><code class="function">gtk_table_set_row_spacing()</code></a>,and for a column, <a class="link" href="GtkTable.html#gtk-table-set-col-spacing"><code class="function">gtk_table_set_col_spacing()</code></a>.</p><p>The gaps between <span class="emphasis"><em>all</em></span> rows or columns can be changed by calling<a class="link" href="GtkTable.html#gtk-table-set-row-spacings"><code class="function">gtk_table_set_row_spacings()</code></a> or <a class="link" href="GtkTable.html#gtk-table-set-col-spacings"><code class="function">gtk_table_set_col_spacings()</code></a> respectively.</p><p><a class="link" href="GtkTable.html#gtk-table-set-homogeneous"><code class="function">gtk_table_set_homogeneous()</code></a>, can be used to set whether all cells in thetable will resize themselves to the size of the largest widget in the table.</p></div><div class="refsect1" lang="en"><a name="id4101542"></a><h2>Details</h2><div class="refsect2" lang="en"><a name="id4101552"></a><h3><a name="GtkTable-struct"></a>GtkTable</h3><a class="indexterm" name="id4101565"></a><pre class="programlisting">typedef struct _GtkTable GtkTable;</pre><p>The <span class="structname">GtkTable</span> structure holds the data for the actual table itself. <em class="structfield"><code>children</code></em> is a <ahref="/usr/share/gtk-doc/html/glib/glib-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a> of all the widgets the table contains. <em class="structfield"><code>rows</code></em> and <em class="structfield"><code>columns</code></em> are pointers to <a class="link" href="GtkTable.html#GtkTableRowCol"><span class="type">GtkTableRowCol</span></a> structures, which contain the default spacing and expansion details for the <a class="link" href="GtkTable.html" title="GtkTable"><span class="type">GtkTable</span></a>'s rows and columns, respectively.</p><p><em class="structfield"><code>nrows</code></em> and <em class="structfield"><code>ncols</code></em> are 16bit integers storing the number of rows and columns the table has. </p></div><hr><div class="refsect2" lang="en"><a name="id4101635"></a><h3><a name="GtkTableChild"></a>GtkTableChild</h3><a class="indexterm" name="id4101648"></a><pre class="programlisting">typedef struct { GtkWidget *widget; guint16 left_attach; guint16 right_attach; guint16 top_attach; guint16 bottom_attach; guint16 xpadding; guint16 ypadding; guint xexpand : 1; guint yexpand : 1; guint xshrink : 1; guint yshrink : 1; guint xfill : 1; guint yfill : 1;} GtkTableChild;</pre><p>The <em class="structfield"><code>widget</code></em> field is a pointer to the widget that this <a class="link" href="GtkTable.html#GtkTableChild"><code class="literal">GtkTableChild</code></a> structure is keeping track of.The <em class="structfield"><code>left_attach</code></em>,<em class="structfield"><code>right_attach</code></em>,<em class="structfield"><code>top_attach</code></em>, and<em class="structfield"><code>bottom_attach</code></em> fields specify the row and columnnumbers which make up the invisible rectangle that the child widget is packed into.</p><p><em class="structfield"><code>xpadding</code></em> and <em class="structfield"><code>ypadding</code></em>specify the space between this widget and the surrounding table cells.</p></div><hr><div class="refsect2" lang="en"><a name="id4101712"></a><h3><a name="GtkTableRowCol"></a>GtkTableRowCol</h3><a class="indexterm" name="id4101725"></a><pre class="programlisting">typedef struct { guint16 requisition; guint16 allocation; guint16 spacing; guint need_expand : 1; guint need_shrink : 1; guint expand : 1; guint shrink : 1; guint empty : 1;} GtkTableRowCol;</pre><p>These fields should be considered read-only and not be modified directly.</p></div><hr><div class="refsect2" lang="en"><a name="id4101744"></a><h3><a name="gtk-table-new"></a>gtk_table_new ()</h3><a class="indexterm" name="id4101757"></a><pre class="programlisting"><a class="link" href="GtkWidget.html" title="GtkWidget">GtkWidget</a>* gtk_table_new (<ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#guint">guint</a> rows, <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#guint">guint</a> columns, <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean">gboolean</a> homogeneous);</pre><p>Used to create a new table widget. An initial size must be given byspecifying how many rows and columns the table should have, althoughthis can be changed later with <a class="link" href="GtkTable.html#gtk-table-resize"><code class="function">gtk_table_resize()</code></a>. <em class="parameter"><code>rows</code></em> and <em class="parameter"><code>columns</code></em>must both be in the range 0 .. 65535.</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><em class="parameter"><code>rows</code></em> :</span></p></td><td>The number of rows the new table should have.</td></tr><tr><td><p><span class="term"><em class="parameter"><code>columns</code></em> :</span></p></td><td>The number of columns the new table should have.</td></tr><tr><td><p><span class="term"><em class="parameter"><code>homogeneous</code></em> :</span></p></td><td>If set to <ahref="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a>, all table cells are resized to the size of the cellcontaining the largest widget.</td></tr><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td><td>A pointer to the the newly created table widget.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id4101897"></a><h3><a name="gtk-table-resize"></a>gtk_table_resize ()</h3><a class="indexterm" name="id4101909"></a><pre class="programlisting">void gtk_table_resize (<a class="link" href="GtkTable.html" title="GtkTable">GtkTable</a> *table, <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#guint">guint</a> rows, <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#guint">guint</a> columns);</pre><p>If you need to change a table's size <span class="emphasis"><em>after</em></span> it has been created, this function allows you to do so.</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><em class="parameter"><code>table</code></em> :</span></p></td><td>The <a class="link" href="GtkTable.html" title="GtkTable"><span class="type">GtkTable</span></a> you wish to change the size of.</td></tr><tr><td><p><span class="term"><em class="parameter"><code>rows</code></em> :</span></p></td><td>The new number of rows.</td></tr><tr><td><p><span class="term"><em class="parameter"><code>columns</code></em> :</span></p></td><td>The new number of columns.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id4102013"></a><h3><a name="gtk-table-attach"></a>gtk_table_attach ()</h3><a class="indexterm" name="id4102025"></a><pre class="programlisting">void gtk_table_attach (<a class="link" href="GtkTable.html" title="GtkTable">GtkTable</a> *table, <a class="link" href="GtkWidget.html" title="GtkWidget">GtkWidget</a> *child, <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#guint">guint</a> left_attach, <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#guint">guint</a> right_attach, <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#guint">guint</a> top_attach, <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#guint">guint</a> bottom_attach, <a class="link" href="gtk-Standard-Enumerations.html#GtkAttachOptions">GtkAttachOptions</a> xoptions, <a class="link" href="gtk-Standard-Enumerations.html#GtkAttachOptions">GtkAttachOptions</a> yoptions, <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#guint">guint</a> xpadding, <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#guint">guint</a> ypadding);</pre><p>Adds a widget to a table. The number of 'cells' that a widget will occupy isspecified by <em class="parameter"><code>left_attach</code></em>, <em class="parameter"><code>right_attach</code></em>, <em class="parameter"><code>top_attach</code></em> and <em class="parameter"><code>bottom_attach</code></em>.These each represent the leftmost, rightmost, uppermost and lowest columnand row numbers of the table. (Columns and rows are indexed from zero).</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><em class="parameter"><code>table</code></em> :</span></p></td><td>The <a class="link" href="GtkTable.html" title="GtkTable"><span class="type">GtkTable</span></a> to add a new widget to.</td></tr><tr><td><p><span class="term"><em class="parameter"><code>child</code></em> :</span></p></td><td>The widget to add.</td></tr><tr><td><p><span class="term"><em class="parameter"><code>left_attach</code></em> :</span></p></td><td>the column number to attach the left side of a child widget to.</td></tr><tr><td><p><span class="term"><em class="parameter"><code>right_attach</code></em> :</span></p></td><td>the column number to attach the right side of a child widget to.</td></tr><tr><td><p><span class="term"><em class="parameter"><code>top_attach</code></em> :</span></p></td><td>the row number to attach the top of a child widget to.</td></tr><tr><td><p><span class="term"><em class="parameter"><code>bottom_attach</code></em> :</span></p></td><td>the row number to attach the bottom of a child widget to.</td></tr><tr><td><p><span class="term"><em class="parameter"><code>xoptions</code></em> :</span></p></td><td>Used to specify the properties of the child widget when the table is resized.</td></tr><tr><td><p><span class="term"><em class="parameter"><code>yoptions</code></em> :</span></p></td><td>The same as xoptions, except this field determines behaviour of vertical resizing.</td></tr><tr><td><p><span class="term"><em class="parameter"><code>xpadding</code></em> :</span></p></td><td>An integer value specifying the padding on the left and right of the widget being added to the table.</td></tr><tr><td><p><span class="term"><em class="parameter"><code>ypadding</code></em> :</span></p></td><td>The amount of padding above and below the child widget.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id4102313"></a><h3><a name="gtk-table-attach-defaults"></a>gtk_table_attach_defaults ()</h3><a class="indexterm" name="id4102327"></a><pre class="programlisting">void gtk_table_attach_defaults (<a class="link" href="GtkTable.html" title="GtkTable">GtkTable</a> *table,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -