GRIDPLUS2 - Embedded Widget Grids | ![]() |
||||||
|
GRIDPLUS Embedded Widget Grids |
GRIDPLUS has a facility to create a widget grid inside a cell of another widget grid. Examples 2, 4, 5 and 6 make use of this facility.
A new, much simpler, syntax for creating Embedded Widget Grids has been introduced in GRIDPLUS 2.4. For backwards compatibility the "old" syntax is still supported (Please refer to the GRIDPLUS 2.3 documentation for details of the "old" syntax).
NOTE: For those converting applications from the old syntax to the new please note that it is now not possible to specify the name of the embedded grid. The name of the grid is automatically generated. The names of the "null" array data items and the default names of the invoked procedures are now based on the parent grid. I believe that this makes for a much more sensible/consistant naming.
Syntax |
Any GRIDPLUS widget grid cell which contains any of the above items will cause an Embedded Grid to be created.
The following rules are applied:
Using Widget Option Substitution |
Widget options allows the same set of options to be applied to all columns in the grid.
The options are added to each column before the item begining with "."
Example:
{"^Category " || |(&r *category) . "Business" -business |: . "Personal" -personal |: . "All" +%}
...is equvalent to...
{"^Category " || &r *category . "Business" -business |: &r *category . "Personal" -personal |: &r *category . "All" +%}
Embedded Grid/Widget/Command Naming |
The embedded grids have names derived from the name of the Grid in which they are embedded.
The names are in the format:-
.mygrid-number
Where ".mygrid" is the name of the parent grid and "number" is an integer which is incremented for each Embedded Grid.
The names used for Embedded Grid Widgets and the names of commands invoked by Embedded Grid widgets follow the rules of the -basename option. In effect, they are based on the name of the parent Grid.
Examples |
Window:
Source Code:
gridplus optionset Toolbutton { -padding 0 -space 0 -takefocus 0 -widget button } gridplus entry .example -width 50 -wtitle "Example" { {|#Toolbutton :navback16 .back |: :navforward16 .forward} = {"Field One" .field-one} {"Field Two" .field-two} {"Radio Buttons" || |&r . "Button One" +rb1 *rbutton |: . "Button Two" -rb2 *rbutton} {"Mixed Widgets" || &c .cbutton-1 "Check Button" |> |&b "Button One" .button-1 |: "Button Two" .button-2} {"More Mixed Widgets " || &d .dropdown1 |> &b "Button Three" .button-3} {"Two Buttons " || |&b "Button Four" .button-4 |: "Button Five" .button-5 |:} = {|&e "This is a Much Longer Label Text " .field-three 35} } pack .example
Comments:
NOTE: In this example, additional spaces have been used to layout the elements of the entry/widget grid into aligned columns. This is not neccessary for the functioning of this facility - it is simply for clarity. It is also assumed that the reader is already familiar with the GRIDPLUS2 grid, widget, button, dropdown, entry and radiobutton.
gridplus optionset Toolbutton { -padding 0 -space 0 -takefocus 0 -widget button }
gridplus entry .example -width 50 -wtitle "Example" {
{|#Toolbutton :navback16 .back |: :navforward16 .forward}
{"Field One" .field-one} {"Field Two" .field-two}
{"Radio Buttons" || |&r . "Button One" +rb1 *rbutton |: . "Button Two" -rb2 *rbutton}
{"Mixed Widgets" || &c .cbutton-1 "Check Button" |> |&b "Button One" .button-1 |: "Button Two" .button-2}
This Embedded Grid contains three widgets: A checkbutton and two buttons. The "|>" item specifies that the link between the checkbutton and the first button will stretch and implies that the content of the Embedded Grid will be attached to the left -and- right of the containing cell.
The "|:" item specifies that the link between the buttons will not stretch. The buttons are separated from each other by the default space.
{"More Mixed Widgets " || &d .dropdown1 |> &b "Button Three" .button-3}
This Embedded Grid contains two widgets: A dropdown and a button. The "|>" item specifies that the link between the dropdown and the button will stretch and implies that the content of the Embedded Grid will be attached to the left -and- right of the containing cell.
{"Two Buttons " || |&b "Button Four" .button-4 |: "Button Five" .button-5 |:}
This Embedded Grid contains two button widgets. The first "|:" item specifies that the link between the buttons will not stretch. The buttons are separated from each other by the default space. The final "|:" item specifies that the righthand button will be attached the right of the containing cell.
{|&e "This is a Much Longer Label Text " .field-three 35}
Window:
Source Code:
gridplus widget .example -wtitle "Vertical Bar Example" { {"^This is an example of the various Embedded Grid vertical bar options."} {"Column1" |:| "Column2"} {"Column1" |>| "Column2"} {"Column1" |<| "Column2"} {"Column1" |=| "Column2"} } pack .example
Comments:
This example demonstrates the various Embedded Grid vertical bar separator options.
Window:
Source Code:
proc example,folder-select {} { gpset .example,folder [tk_chooseDirectory] } gridplus entry .example -wtitle "Example" { {"Field One" .field-one:ew} {"Folder" || |#. &e .folder 30 |: &b " ... " .folder-select 3} {"Field Two" .field-two:ew} } pack .example
Comments:
{"Folder" || |#. &e .folder 30 |: &b " ... " .folder-select 3}The "|#." element in this line sets the style to "." which applies the pre-defined optionset with the same name, in this case to create a "folder selection field". Pressing the "..." button will invoke the "example,folder-select" procedure to display a tk_chooseDirectory dialog. The selected directory will set the value of the ".example,folder" field.