GRIDPLUS2 - Widget Grid
Home Reference Manpage Examples Download License Contact

GRIDPLUS Widget Grid

In order to simplify creation of screen layouts, GRIDPLUS provides a GRIDPLUS widget command mode.

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

Note: Each item in a GRIDPLUS Widget Grid can contain an Embedded Widget Grid.

GRIDPLUS Widget Specific Item Options/Functionality

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

&type
The type of the widget (Example: &e). Acceptable values are b (Button), c (Checkbutton), d (Dropdown "combobox"), D (Dropdown "date selector"), e (Entry), l (Link), m (Menubutton), r (Radiobutton), s (Spinbox).

&type:style/optionset
As above but with specified style/optionset.

.name
The name of the widget (Example: .b1).

.proc=parameter
The name of the widget. This is an optional way to define a widget name for buttons. Using the example: .myproc=myparameter, the widget will be called ".myproc=myparameter", the procedure called when the button is pressed will be "myproc" to which will be passed a parameter, in this case "myparameter".

:icon
The name of the icon to be used for button (button) -or node (tree) (Example: :navback16). The icon name can also be null (button), in which case the icon specified by the -icon option is used.

%group
The name of the group to which widget belongs (Example: %mygroup1).

<
Create widget with disabled state. Overrides -state option.

<group
Specifies that widgets belonging to group will have state set to "disabled" when the widget content is modified.

>
Create widget with normal state. Overrides -state option.

>group
Specifies that widgets belonging to group will have state set to "normal" when the widget content is modified.

@name
Insert specfied grid/layout/widget -or- "defined" widget (Example: @myoptions).

?helptext
Specifies text to be used for button pop-up/balloon help (Example: ?Print). If the text contains spaces double quotes must be used (Example: "?Exit Application").

!name
Specifies name of validation to be used for entry (Example: !int) -or- When "!" is used alone this indicates that entry validations are to be perfomed (for the window containing the button/link/menu) prior to evaluating the callback.

|
Specifies that a vertical bar separator be created.

=
Specifies that a horizontal bar separator be created.

+value
Specifies that the widget should be created in selected mode (checkbutton/radiobutton) -or- have focus (button/entry) -or- the dropdown list should be set to the specified list (dropdown) -or- a "bullet" should be displayed (link) -or- the from/to/increment/format set (spinbox). The use of value is for dropdowns where the dropdown list should be set to the specified list with the widget value set to the first item in the list -and- radiobuttons where it specifies the value of the radiobutton Grid when this radiobutton is selected -and- spinboxes where is specifies the from/to/increment/format values.

-value
Specifies that the widget should be created in deselected mode (checkbutton/radiobutton), a separator line is displayed (menu) -or- widget is indented (link). The use of value is for radiobuttons only an dspecifies the value of the radiobutton Grid when this radiobutton is selected.

*
Specifies that the widget should display "*" for each character entered (entry).

~command
Specifies that a command is invoked when the enter key is pressed while the widget has focus (entry), that a command is invoked when a checkbutton/radiobutton is selected -or- that a command is invoked when a list item is selected (dropdown). The command name is optional. If not specified command name is based on the name of widget. This option may also be used to specify the name of the command to be invoked for buttons and menu items.

integer
Specifies a positive integer which overrides the default width for the widget.

text
Specifies text to be used as widget label. The text may also have an optional colon (":") delimited sticky indicator: n, s, e, w (Default) or c (Centre) (Example: "First Name:e").

Notes:

Example

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

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

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


Widget Example 1

Window:

Source Code:

gridplus widget .mygrid1 -title "My Grid 1" {
  {&b "Label1" .1} {&e "Label2" .2}
  {&e "Label3" .3} {&d "Label4" .4}
  {&d "Label5" .5} {&b "Label6" .6}
}

gridplus widget .mygrid2 -title "My Grid 2" {
  {&b .1 "Label1"}
  {&c .2 "Label2"}
  {&l .3 "Label3"}
  {&m .4 "Label4"}
}

gridplus widget .mygrid3 -widget radiobutton -title "My Grid 3" {
  {}         {"Label A:c"}  {"Label B:c"}
  {"Label1"} {.:c +myval1} {&c .1:c}
  {"Label2"} {.:c -myval2} {&c .2:c}
  {"Label3"} {.:c -myval3} {&c .3:c}
  {"Label4"} {.:c -myval4} {&c .4:c}
}

gridplus layout .main -wtitle "Widget Example" {
   .mygrid1:ew  -
   .mygrid2:ns  .mygrid3:ew
}

pack .main

Comments:

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

For example: The for the ".mygrid1" cell defined by "{&e "Label2" .2}" an entry widget is created with the name ".mygrid1,2". Please note that the widget name does contain a comma - this is not a misprint!!

In ".mygrid2" the widget IDs are to the left of the label text. Where appropriate (checkbutton, entry, radiobutton) - This will create widgets which are to the left of the label text.

In ".mygrid3" the -widget option is used to set the default widget type to "radiobutton". This has exactly the same effect as creating a radiobutton grid. Some of the cells simply contain labels. The widgets under "Label A", as no widget type is specified, will be created as radiobuttons. The widgets under "Label B" will be created as checkbuttons as the widget type "&c" is specified.

The column labels ("Label A" and "Label B"), and the widgets in those columns, have a :c suffix - This causes the labels/widgets to be centred in the containing cell.


Copyright © 2013 Adrian Davis.