You will notice that the program does not call gtk_signal_connect for the "delete_event", but only for the "destroy" signal. This will still perform the desired function, because an unhandled "delete_event" will result in a "destroy" signal being given to the window.
9. Miscellaneous Widgets
9.1 Labels
Labels are used a lot in GTK, and are relatively simple. Labels emit no signals as they do not have an associated X window. If you need to catch signals, or do clipping, place it inside a EventBox widget or a Button widget.
To create a new label, use:
|
The sole argument is the string you wish the label to display.
To change the label's text after creation, use the function:
|
The first argument is the label you created previously (cast using the GTK_LABEL() macro), and the second is the new string.
The space needed for the new string will be automatically adjusted if needed. You can produce multi-line labels by putting line breaks in the label string.
To retrieve the current string, use:
|
The first argument is the label you've created, and the second, the return for the string. Do not free the return string, as it is used internally by GTK.
The label text can be justified using:
|
Values for jtype are:
GTK_JUSTIFY_LEFT
GTK_JUSTIFY_RIGHT
GTK_JUSTIFY_CENTER (the default)
GTK_JUSTIFY_FILL
The label widget is also capable of line wrapping the text automatically. This can be activated using:
|
The wrap argument takes a TRUE or FALSE value.
If you want your label underlined, then you can set a pattern on the label:
|
The pattern argument indicates how the underlining should look. It consists of a string of underscore and space characters. An underscore indicates that the corresponding character in the label should be underlined. For example, the string
"__ __"
would underline the first two characters and eight and ninth characters.
Below is a short example to illustrate these functions. This example makes use of the Frame widget to better demonstrate the label styles. You can ignore this for now as the Frame widget is explained later on.
上一篇:GTK入门导引 下一篇:GDK Reference Manual 更多相关文章
|
推荐文章
精彩文章
|