7.2.6. Table

学习gtkmm有几周了,英语太烂了,硬着头皮边看边记,还没把握,发上来,大家斧正

7.2.6. Table

Tables allows us to place widgets in a grid, similar toGtk::Grid.

Tables允许我们可以将控件放置在grid中,与Gtk::Grid类似。

§  7.2.6.1. Constructor /构造

§  7.2.6.2. Adding widgets /添加控件

§  7.2.6.3. Other methods /其他方法

§  7.2.6.4. 示例

7.2.6.1. Constructor/构造

The grid's dimensions need to be specified in the constructor:

网格的行列数要在构造函数中指定:

Gtk::Table(int rows = 1, int columns = 1, bool homogeneous = false);

The first argument is the number of rows to make in the table, while the second, obviously, is the number of columns. Ifhomogeneousistrue, the table cells will all be the same size (the size of the largest widget in the table).

第一个参数是要指定Table中的行数,而第二个,很明显,是Table的列数。homogeneoustrue时,Table所有单元格将具有相同的大小(表中的最大控件的大小)。

The rows and columns are indexed starting at 0. If you specifyrows= 2 andcolumns= 2, the layout would look something like this:

行和列索引从0开始。如果您指定行rows= 2和列columns= 2,布局将看起来像这样:

 0          1          2

0+----------+----------+

 |          |          |

1+----------+----------+

 |          |          |

2+----------+----------+

Note that the coordinate system starts in the upper left hand corner.

请注意,坐标系统从左上角开始。

7.2.6.2. Adding widgets/添加控件

To place a widget into a box, use the following method:

若要放入一个控件到格子里去,请使用下面的方法:

void Gtk::Table::attach(Gtk::Widget& child,

                        guint left_attach, guint right_attach,

                        guint top_attach, guint bottom_attach,

                        guint xoptions = Gtk::FILL | Gtk::EXPAND,

                        guint yoptions = Gtk::FILL | Gtk::EXPAND,

                        guint xpadding = 0, guint ypadding = 0);

The first argument is the widget you wish to place in the table.

第一个参数是要放置在Table中的控件。

Theleft_attachandright_attacharguments specify where to place the widget, and how many boxes to use. For example, if you want a button in the lower-right cell of a 2 x 2 table, and want it to occupy that cell only, thenleft_attachwould be 1,right_attach2,top_attach1, andbottom_attach2. If, on the other hand, you wanted a widget to take up the entire top row of our 2 x 2 table, you'd setleft_attach= 0,right_attach= 2,top_attach= 0, andbottom_attach= 1.

Left_attachright_attach参数指定放置控件的位置和要占用几个格子。例如,如果您希望占用2 x 2表中右下角的格子。则left_attach将为1right_attach2top_attach1,和bottom_attach2。另如,如果您想要占用整个的最上面一行,我们2 x 2表的构件,您将设置left_attach = 0right_attach = 2top_attach = 0bottom_attach = 1。(我的理解:left_attachright_attachtop_attachbottom_attach分别为控件占用格子的左右上下的网格坐标

xoptionsandyoptionsare used to specify packing options and may be bitwise ORed together to allow multiple options. These options are:

xoptionsyoptions用来指定包装放置选项,允许多个选项按位取或(OR)。这些选项包括:

Gtk::FILL

If the table box is larger than the widget, andGtk::FILLis specified, the widget will expand to use all the room available.

如果在表框中大于该控件,并且指定了Gtk::FILL,该控件将扩展到可用的所有格子空间。

Gtk::SHRINK

If the table widget is allocated less space than it requested (because the user resized the window), then the widgets will normally just disappear off the bottom of the window. IfGtk::SHRINKis specified, the widgets will shrink with the table.

如果表格分配的空间比控件请求的空间少(因为用户调整窗口的大小),控件的底部通常会消失。如果指定了Gtk::SHRINK,则控件可随Table缩小。

Gtk::EXPAND

This will cause the table to expand to use up anyremainingspace in the window.

这将导致窗口中Table扩大到任何空余的空间。

The padding arguments work just as they do forpack_start().

Padding参数pack_start()中的相同。

7.2.6.3. Other methods/其它方法

set_row_spacing()andset_col_spacing()set the spacing between the rows at the specified row or column. Note that for columns, the space goes to the right of the column, and for rows, the space goes below the row.

set_row_spacing()set_col_spacing()设置在指定的行或列的行之间的间距。请注意,对于列、间隔定位于列的右侧,如为行,间隔定位于该行下面。

You can also set a consistent spacing for all rows and/or columns withset_row_spacings()andset_col_spacings(). Note that with these calls, the last row and last column do not get any spacing.

此外,您还可以用set_row_spacings()set_col_spacings()设置所有行或列间统一的间距。请注意,最后一行和最后一列没有效果。

参考

7.2.6.4. 示例

In the following example, we make a window with three buttons in a 2 x 2 table. The first two buttons will be placed in the upper row. A third button is placed in the lower row, spanning both columns.

在下面的示例中,我们在2 x 2 Table中放置三个按钮。先将两个按钮将放在上面一行。第三个按钮被放在下一行中,占两个列。

7-11 Table


源代码

 

微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码
微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值