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

GTK v1.2 Tutorial(英文)

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

  Now that we have a combo box, tailored to look and act how we want it, all that remains is being able to get data from the combo box. This is relatively straightforward. The majority of the time, all you are going to care about getting data from is the entry. The entry is accessed simply by GTK_ENTRY(GTK_COMBO(combo)->entry). The two principal things that you are going to want to do with it are attach to the activate signal, which indicates that the user has pressed the Return or Enter key, and read the text. The first is accomplished using something like:


gtk_signal_connect(GTK_OBJECT(GTK_COMB(combo)->entry), "activate",
GTK_SIGNAL_FUNC (my_callback_function), my_data);

  Getting the text at any arbitrary time is accomplished by simply using the entry function:


gchar *gtk_entry_get_text(GtkEntry *entry);

  Such as:


char *string;
string = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(combo)->entry));
That's about all there is to it. There is a function 
void gtk_combo_disable_activate(GtkCombo *combo);

  that will disable the activate signal on the entry widget in the combo box. Personally, I can't think of why you'd want to use it, but it does exist.

9.12 Calendar

  The Calendar widget is an effective way to display and retrieve monthly date related information. It is a very simple widget to create and work with.

  Creating a GtkCalendar widget is a simple as:


GtkWidget *gtk_calendar_new();

  There might be times where you need to change a lot of information within this widget and the following functions allow you to make multiple change to a Calendar widget without the user seeing multiple on-screen updates.


void gtk_calendar_freeze( GtkCalendar *Calendar );
void gtk_calendar_thaw( GtkCalendar *Calendar );

  They work just like the freeze/thaw functions of every other widget.

  The Calendar widget has a few options that allow you to change the way the widget both looks and operates by using the function


void gtk_calendar_display_options( GtkCalendar *calendar,
GtkCalendarDisplayOptionsflags );

  The flags argument can be formed by combining either of the following five options using the logical bitwise OR (|) operation:

  GTK_CALENDAR_SHOW_HEADING - this option specifies that the month and year should be shown when drawing the calendar.

  GTK_CALENDAR_SHOW_DAY_NAMES - this option specifies that the three letter descriptions should be displayed for each day (eg MON,TUE...).

  GTK_CALENDAR_NO_MONTH_CHANGE - this option states that the user should not and can not change the currently displayed month. This can be good if you only need to display a particular month such as if you are displaying 12 calendar widgets for every month in a particular year.

  GTK_CALENDAR_SHOW_WEEK_NUMBERS - this option specifies that the number for each week should be displayed down the left side of the calendar. (eg. Jan 1 = Week 1,Dec 31 = Week 52).

  GTK_CALENDAR_WEEK_START_MONDAY - this option states that the calander week will start on Monday instead of Sunday which is the default. This only affects the order in which days are displayed from left to right.

  The following functions are used to set the the currently displayed date:


gint gtk_calendar_select_month( GtkCalendar *calendar, 
guintmonth,guintyear );
void gtk_calendar_select_day( GtkCalendar *calendar,guintday );

  The return value from gtk_calendar_select_month() is a boolean value indicating whether the selection was successful.

  With gtk_calendar_select_day() the specified day number is selected within the current month, if that is possible. A day value of 0 will deselect any current selection.

  In addition to having a day selected, any number of days in the month may be "marked". A marked day is highlighted within the calendar display. The following functions are provided to manipulate marked days:



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



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

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