Wiki

Changes between Version 3 and Version 4 of GtkSimpleWidgets

Show
Ignore:
Timestamp:
11/02/11 17:48:15 (6 years ago)
Author:
callisto
Comment:

added spin button to GtkSimpleWidgets

Legend:

Unmodified
Added
Removed
Modified
  • GtkSimpleWidgets

    v3 v4  
    11= Gtk Simple Widgets = 
    22 
    3 These are widgets that can be clicked or otherwise react to a user's request.  Gtk provides many different types of widgets, and only a selection is illustrated here. 
     3These are widgets that can be clicked or otherwise react to a user's request.  Gtk provides many different types of widgets, and only some are illustrated here.  Also, within each widget type, only a small amount of the supported behaviour is shown 
    44 
    55== Buttons == 
     
    114114 
    115115 
    116 == Spin Boxes == 
     116== Spin Buttons == 
    117117 
     118A spin button is used to select a number from within a numeric range.  The user may click on the up/down arrows to the side of the field to change the value. 
     119 
     120Using a spin button means first creating an instance of the 'Adjustment' class: this holds the min/max values for the range, as well as information on how large a jump the user can make.  The 'Adjustment' class takes 6 float parameters: 
     121 
     122 * the initial value 
     123 * the minimum value 
     124 * the maximum value 
     125 * the increment for a single step (e.g. one click on an arrow) 
     126 * the increment for a page-up or page-down keypress 
     127 * page size (but cobra tells me using any value other than 0 for this parameter is deprecated) 
     128 
     129The spin button takes three parameters: 
     130 
     131 * an instance of the 'Adjustment' class 
     132 * the 'climb rate', which affects the acceleration when you hold a button down 
     133 * the number of decimal places to show 
     134 
     135The 'value' attribute of the spin button is used to retrieve the current value. 
     136 
     137To create a spin box which covers the numbers 0 to 100, and produces integer values: 
     138 
     139{{{ 
     140#!cobra 
     141                model = Adjustment(50.0f, 0.0f, 100.0f, 1.0f, 10.0f, 0f) 
     142                _spinbutton = SpinButton(model, 1.0f, 0) 
     143}}} 
     144 
     145To create a spin box which covers a floating point range -10.000 to 10.000, producing float values at intervals of 0.001: 
     146{{{ 
     147#!cobra 
     148                model = Adjustment(0.0f, -10.0f, 10.0f, 0.001f, 1.0f, 0f) 
     149                _spinbutton = SpinButton(model, 1.0f, 3) 
     150                _spinbutton.snapToTicks = true # used to round entries such as 1.2341 to 1.234 
     151}}} 
     152 
     153 
     154[[Image(spinbutton.png)]]