GTK学习个人笔记

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

推荐

可是目前GTK+的stable版式 2.18 ,unstable版是2.19.3

哪里跑出来的2.8和2.4呀。原来↓:

GtkWidget* gtk_button_new_from_stock (const gchar *stock_id)

从一个"常备项目/固化词条/glib提供的固有原料"(stock item),创建一个GtkButton包含图像和文本. 一些stock ids具有预处理宏,例如GTK_STOCK_OK和GTK_STOCK_APPLY.

如果遇到不识别的stock_id, 那么他们将被视为mnemonic label

(参见gtk_button_new_with_mnemonic()).

stock_id :the name of the stock item

Returns:a new GtkButton

gtk_button_new ()

GtkWidget* gtk_button_new (void)

创建一个新的GtkButton构件(widget). 用gtk_container_add()为button构件添加一个子构件。

Returns :The newly created GtkButton widget.

gtk_box_pack_start ()

void gtk_box_pack_start (GtkBox *box,

GtkWidget *child,

gboolean expand,

gboolean fill,

guint padding)

为BOX添加child, 从box的起点开始装入child. 这个child被装入后,其他的任何child装入时都将从起点装入child。(从左向右,从上到下)

box :一个GtkBox

child :被添加到box中的GtkWidget

expand :

TRUE if the new child is to be given extra space allocated to box. The extra space will be divided evenly between all children of box that use this option

fill :

TRUE if space given to child by the expand option is actually allocated to child, rather than just padding it. 如果expand 被设为FLASE的时候,这个属性将无效. A child is allocated the full height of a GtkHBox and the full width of a GtkVBox. This option affects the other dimension

padding :

extra space in pixels to put between this child and its neighbors, over and above the global amount specified by "spacing" property. If child is a widget at o reference ends of box, then padding pixels are also put between child and the reference edge of box

----------------------------

gtk_box_pack_end ()

void gtk_box_pack_end (GtkBox *box,

GtkWidget *child,

gboolean expand,

gboolean fill,

guint padding)

为BOX添加child, 从box的尾部(end)开始装入child. 这个child被装入后,其他的任何child装入时都将从尾部(end)装入child。(从右向左,从下到上)

其他同上记gtk_box_pack_start()。

expand / fill / padding 参数的动作,基本如下图

gtk_widget_set_size_request ()

设置widget的最小尺寸(拉动窗口的话,到这个最小size为止,不能在小了); 也就是说,要求这个wideget的尺寸高度宽度. 你可以用这个函数来强制设定widget的尺寸,比通常的size大或小.

In most cases, gtk_window_set_default_size() is a better choice for toplevel windows than this function; setting the default size will still allow users to shrink the window size request will force them to leave the window at least as large as the size request. When dealing with window sizes, gtk_window_set_geometry_hints() can be a usefu well.

Note the inherent danger of setting any fixed size - themes, translations into other languages, different fonts, and user action can all change the appropriate size for So, it's basically impossible to hardcode a size that will always be correct.

The size request of a widget is the smallest size a widget can accept while still functioning well and drawing itself correctly. However in some strange cases a widget less than its requested size, and in many cases a widget may be allocated more space than it requested.

If the size request in a given direction is -1 (unset), then the "natural" size request of the widget will be used instead.

如果这个size给定了一个'-1'的值的话,那么这个widget就会利用'自然值'。(我觉得就是,可随窗口的拉伸而自由的放大缩小)

Widgets can't actually be allocated a size less than 1 by 1, but you can pass 0,0 to this function to mean "as small as possible."

widget:a GtkWidget

width:width widget should request, or -1 to unset

height:height widget should request, or -1 to unset

相关文档
最新文档