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

GTK v1.2 Tutorial(英文)

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

9.10 Spin Buttons

  The Spin Button widget is generally used to allow the user to select a value from a range of numeric values. It consists of a text entry box with up and down arrow buttons attached to the side. Selecting one of the buttons causes the value to "spin" up and down the range of possible values. The entry box may also be edited directly to enter a specific value.

  The Spin Button allows the value to have zero or a number of decimal places and to be incremented/decremented in configurable steps. The action of holding down one of the buttons optionally results in an acceleration of change in the value according to how long it is depressed.

  The Spin Button uses an Adjustment object to hold information about the range of values that the spin button can take. This makes for a powerful Spin Button widget.

  Recall that an adjustment widget is created with the following function, which illustrates the information that it holds:


GtkObject *gtk_adjustment_new( gfloat value,gfloat lower,gfloat upper,
gfloat step_increment,gfloat page_increment,gfloat page_size );

  These attributes of an Adjustment are used by the Spin Button in the following way:

  value: initial value for the Spin Button

  lower: lower range value

  upper: upper range value

  step_increment: value to increment/decrement when pressing mouse button 1 on a button

  page_increment: value to increment/decrement when pressing mouse button 2 on a button

  page_size: unused

  Additionally, mouse button 3 can be used to jump directly to the upper or lower values when used to select one of the buttons. Lets look at how to create a Spin Button:


GtkWidget *gtk_spin_button_new( GtkAdjustment *adjustment,
gfloat climb_rate,guintdigits );

  The climb_rate argument take a value between 0.0 and 1.0 and indicates the amount of acceleration that the Spin Button has. The digits argument specifies the number of decimal places to which the value will be displayed.

  A Spin Button can be reconfigured after creation using the following function:


void gtk_spin_button_configure( GtkSpinButton *spin_button,
GtkAdjustment *adjustment,gfloat climb_rate,guintdigits );

  The spin_button argument specifies the Spin Button widget that is to be reconfigured. The other arguments are as specified above.

  The adjustment can be set and retrieved independantly using the following two functions:


void gtk_spin_button_set_adjustment( GtkSpinButton*spin_button,
GtkAdjustment*adjustment );
GtkAdjustment *gtk_spin_button_get_adjustment( GtkSpinButton *spin_button );

  The number of decimal places can also be altered using:


void gtk_spin_button_set_digits( GtkSpinButton *spin_button,guintdigits);

  The value that a Spin Button is currently displaying can be changed using the following function:


void gtk_spin_button_set_value( GtkSpinButton *spin_button,gfloat value );

  The current value of a Spin Button can be retrieved as either a floating point or integer value with the following functions:


gfloat gtk_spin_button_get_value_as_float( GtkSpinButton *spin_button );
gint gtk_spin_button_get_value_as_int( GtkSpinButton *spin_button );

  If you want to alter the value of a Spin Value relative to its current value, then the following function can be used:


void gtk_spin_button_spin( GtkSpinButton *spin_button,
GtkSpinTypedirection,gfloat increment );

  The direction parameter can take one of the following values:

  GTK_SPIN_STEP_FORWARD

  GTK_SPIN_STEP_BACKWARD

1

  GTK_SPIN_PAGE_FORWARD

  GTK_SPIN_PAGE_BACKWARD

  GTK_SPIN_HOME

  GTK_SPIN_END

  GTK_SPIN_USER_DEFINED

  This function packs in quite a bit of functionality, which I will attempt to clearly explain. Many of these settings use values from the Adjustment object that is associated with a Spin Button.

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

上一页 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 3031 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 下一页


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

文章评论】 【收藏本文】 【推荐好友】 【打印本文】 【我要投稿】 【论坛讨论
更多相关文章
·Motorola微处理器bootloader分析与应用
·Fedora Core5 NFS服务器搭建过程介绍
·Linux系统:让内存不再泄漏的实用技巧
·新手看招 手把手教你安装VMware虚拟机
·“侵权事件” 红帽称微软企图干扰用户
·删除Linux后 如何找回Windows启动菜单
·菜鸟乐园 Linux中常见文件系统格式介绍
·Linux操作系统下IPTables配置方法详解
·实用技巧 Linux系统的经典使用技巧八则
·Linux系统文件优化及磁盘检查方法介绍
推荐文章
·Linux技巧:bz2文件如何解压缩
·用MRTG检测Linux网络性能
·红帽宣布开放JBoss中核心系统管理软
·如何设定与维持准确的电脑时钟
·Linux系统中找出并解决程序错误方法
·在Linux下成功运行最新的QQ和MSN
·如何重新规划分割区
·Webmin---Linux下的用户管理工具
精彩文章
·起步走 二十五步跟我搞定Linux系统
·几个JSP应用模板
·浅析:从xml生成Java类
·Linux下ip隧道研究(1)
·CORBA及MICO简介
·用Linux防火墙构建DMZ
·linux汉化大全(六)
·用Java Mail API查看邮件
·在Linux Shell程序中进行身份验证
·Linux指令大全(2)
·rootkit综述
·在linux7.1上安装jdk+tomcat+orac
·Linux御敌策略谈
·巧用KDE
·Linux 网管 123 --- 第8章. 备份及
·Socket建立连接的过程
·Linux命令Man解释:ftpaccess(5) :ft
·和luster一起学习系统调用(3)
·文件系统安全--EXT2文件系统的属性
·打造完美Linux系统:疑难杂症的解决
·Bean管理持续化实例
·Linux 每次启动时钟日期就多了 8 小
·基于Linux的Web服务器性能测试
·JDK开发工具包(三)
·Linux平台C++类库tinycxx使用说明
·和luster一起学习java编程(4)
Power by linux-cn.com 粤ICP备05006655号