GRIDPLUS2 - Optionset
Home Reference Manpage Examples Download License Contact

GRIDPLUS Optionset

GRIDPLUS provides a command/mode to create GRIDPLUS optionsets. A GRIDPLUS optionset is simply a named set of options.

Optionsets can be very useful where you wish to use the same set of options for many GRIDPLUS elements. The optionset needs to be set only once (Probably as part of an application initialisation procedure/process), the optionset is then available for any part of the application.

Optionsets can save duplication of effort, make code more readable -and- make code easier to change as changing the optionset will change all GRIDPLUS elements using the optionset.

Notes: If a -style option is specified which has the same name as an existing optionset, and -optionset has not been specified, the optionset with the same name as the style will be applied. This behaviour can be disabled using "option add *Gridplus.optionSetStyle 0"

It is possible to use the "|#style" option to set an optionset for an embedded grid as, if there is an optionset with the same name as the style, this will also be applied. It is also possible to use this option to set an optionset only for the embedded grid, in which case it is necessary to specify a "-style" option in the optionset if there is no style with the same name as the optionset. In order to simplify this, using "option add *Gridplus.optionDefaultStyle 1" will cause "-style {}" to automatically be added to all optionsets where a "-style" option is not explicitly specified.

Example:-

gridplus optionset toolbar {
    -style     Toolbutton
    -padding   0
    -space     0
    -takefocus 0 
}

gridplus button .edit.toolbar -optionset toolbar {
   {.save :filesave16 "?Save Record" !} {.close :fileclose16 "?Close"}
}

...is the same as...

gridplus button .edit.toolbar -style Toolbutton -padding 0 -space 0 -takefocus 0 {
   {.save :filesave16 "?Save Record" !} {.close :fileclose16 "?Close"}
}

Pre-Defined Optionsets

Currently there is one pre-defined optionset: "."

This optionset is intended to be used in embedded grids as a shorthand where -space 0 needs to be used with the default style (See Embedded Widget Grids Example 3).

It is defined as:-

gridplus optionset . {
 -space  0
 -style {}
}

Note: This optionset can be redefined if required.


Copyright © 2012 Adrian Davis.