GRIDPLUS2 - Spinbox Grid
Home Reference Manpage Examples Download License Contact

GRIDPLUS Spinbox Grid

In order to simplify creation of screen layouts, GRIDPLUS provides a GRIDPLUS spinbox command mode. This command mode is a "short cut" method to invoke the GRIDPLUS widget command mode with the default widget set create spinboxes. All of the normal widget command mode functionality can be used. For example creating other widget types.

This uses a simple syntax to create a grid of boxes. The syntax is closely based on the GRIDPLUS Grid and Widget.

GRIDPLUS Spinbox Specific Item Options/Functionality

See GRIDPLUS Widget Grid for a full list of item options/functionality.

=default
Specifies the default value to be used for a spinbox when the widget is created (Example: "=default").

+number1/number2/number3/format
Specifies three floating point numbers and a format string. number1 is the from value, number2 the to value, number3 the increment value and format a valid format string (See below).

Setting Spinbox Value Limits and Options

The spinbox value limits and options will normally be set using the widget option as shown above.

Default values can be set using either the option database or widget grid options:-

Widget OptionGrid OptionDatabase NameDefault
number1-fromGridplus.from{}
number2-toGridplus.to{}
number3-incrementGridplus.increment1
format-spinformatGridplus.spinFormat{}

NOTE: The minimum requirement is to specify valid -from and -to values.

Example

This section contains an example which illustrates the main GRIDPLUS spinbox command mode features.

The following example assumes that the reader is familiar with the contents of the Grid/Layout and Widget pages. Information given on those pages will not be duplicated here.

Note: The example assumes that the GRIDPLUS package has already been "required" and the commands imported.


Spinbox Example

Window:

Source Code:

gridplus spinbox .mygrid -wtitle Example {
   {"My Spin One"   .myspin1 +1/20}
   {"My Spin Two"   .myspin2 {+one two "and three" four}}
   {"My Spin Three" .myspin3 {+one two "and three" four} =two}
   {"My Spin Four"  .myspin4 +00/59//%02.0f}
   {"My Spin Five"  .myspin5 +-5/5 =0}
   {"My Spin Six"   .myspin6 +2/10/2}
}

pack .mygrid

Comments:

When using the GRIDPLUS spinbox command mode the "label" defines the text that will appear as a label to the associated spinbox. The cell item begining with a dot is the widget (spinbox) ID. The spinboxes are created with names based on the name of the containing Grid and the widget ID.

The widget option begining with a plus sign (+) defines the minimum, maximum,increment and format values -or- a list of values for the spinbox. This option is mandatory, minimum and maximum values -or- a value list must be set. The default inital value for the spinbox is the minimum value -or- the first list value. A specific initial value can be set using the = option.

This example creates six spinboxes:-

Widget NameMinimum Value / ListMaximum ValueIncrement FormatInitial Value
.mygrid,myspin11201{}1
.mygrid,myspin2one two "and three" fourN/AN/AN/Aone
.mygrid,myspin3one two "and three" fourN/AN/AN/Atwo
.mygrid,myspin400591%02.0f00
.mygrid,myspin5-551{}0
.mygrid,myspin62102{}2

Reading and Setting GRIDPLUS Spinbox Values

The values of the GRIDPLUS widgets are stored in a global array with a null name.

For Example:

global {}

For GRIDPLUS spinbox widgets the array element has the same name as the widget: Thus the value of ".myspin1" in ".mygrid" is referenced as "$(.mygrid,myspin1)".

The recommended method to set GRIDPLUS spinbox values is to use the gpset command.

For Example:

gpset .mygrid,myspin1 5


Copyright © 2013 Adrian Davis.