Linux中国 Linux中国门户站!
设为主页 设为主页
收藏本站 收藏本站
 
当前位置 :首页 ->Linux技术 ->系统管理 ->正文

GTK v1.2 Tutorial(英文)

来源:Linux-cn.com 作者:Webmaster 时间:2007-05-05 点击: [收藏] [投稿]


void gtk_clist_set_foreground( GtkCList *clist,gintrow,GdkColor *color );
void gtk_clist_set_background( GtkCList *clist,gintrow,GdkColor *color );

  Please note that the colors must have been previously allocated.

11.5 Adding rows to the list

  We can add rows in three ways. They can be prepended or appended to the list using


gint gtk_clist_prepend( GtkCList *clist,gchar*text[] );
gint gtk_clist_append( GtkCList *clist,gchar*text[] );

  The return value of these two functions indicate the index of the row that was just added. We can insert a row at a given place using


void gtk_clist_insert( GtkCList *clist,gintrow,gchar*text[] );

  In these calls we have to provide a collection of pointers that are the texts we want to put in the columns. The number of pointers should equal the number of columns in the list. If the text[] argument is NULL, then there will be no text in the columns of the row. This is useful, for example, if we want to add pixmaps instead (something that has to be done manually).

  Also, please note that the numbering of both rows and columns start at 0.

  To remove an individual row we use


void gtk_clist_remove( GtkCList *clist,gintrow );

  There is also a call that removes all rows in the list. This is a lot faster than calling gtk_clist_remove once for each row, which is the only alternative.


void gtk_clist_clear( GtkCList *clist );

  There are also two convenience functions that should be used when a lot of changes have to be made to the list. This is to prevent the list flickering while being repeatedly updated, which may be highly annoying to the user. So instead it is a good idea to freeze the list, do the updates to it, and finally thaw it which causes the list to be updated on the screen.


void gtk_clist_freeze( GtkCList * clist );
void gtk_clist_thaw( GtkCList * clist );

11.6 Setting text and pixmaps in the cells

  A cell can contain a pixmap, text or both. To set them the following functions are used.


void gtk_clist_set_text( GtkCList*clist,
gint row,gint column,const gchar *text );
void gtk_clist_set_pixmap( GtkCList*clist,
gint row,gint column,GdkPixmap *pixmap,GdkBitmap *mask );
void gtk_clist_set_pixtext( GtkCList*clist,gint row,gint column,
gchar *text,guint8 spacing,GdkPixmap *pixmap,GdkBitmap *mask );

  It's quite straightforward. All the calls have the CList as the first argument, followed by the row and column of the cell, followed by the data to be set. The spacing argument in gtk_clist_set_pixtext is the number of pixels between the pixmap and the beginning of the text. In all cases the data is copied into the widget.

  To read back the data, we instead use


gint gtk_clist_get_text( GtkCList*clist,
gint row,gint column,gchar**text );
gint gtk_clist_get_pixmap( GtkCList *clist,
gintrow,gintcolumn,GdkPixmap **pixmap,GdkBitmap **mask );
gint gtk_clist_get_pixtext( GtkCList *clist,
gintrow,gintcolumn,gchar **text,
guint8 *spacing,GdkPixmap **pixmap,GdkBitmap **mask );

  The returned pointers are all pointers to the data stored within the widget, so the referenced data should not be modified or released. It isn't necessary to read it all back in case you aren't interested. Any of the pointers that are meant for return values (all except the clist) can be NULL. So if we want to read back only the text from a cell that is of type pixtext, then we would do the following, assuming that clist, row and column already exist:


gchar *mytext;
gtk_clist_get_pixtext(clist, row, column, &mytext, NULL, NULL, NULL);

  There is one more call that is related to what's inside a cell in the clist, and that's


GtkCellType gtk_clist_get_cell_type( GtkCList *clist,
gintrow,gintcolumn );


 如果您对本文有任何疑问或者建议,请到讨论区发表您的意见: >> 论坛入口 <<



上一篇:GTK入门导引   下一篇:GDK Reference Manual

文章评论】 【收藏本文】 【推荐好友】 【打印本文】 【我要投稿】 【论坛讨论
更多相关文章