GRIDPLUS2 - Link Grid | ![]() |
||||||
|
GRIDPLUS Link Grid |
The "Link" widget is something I created for GRIDPLUS. It is a text string (which may have an associated icon) which behaves something like a hypertext link as commonly found in Web pages. The text string is highlighted when the mouse pointer is over the text (By default the text becomes underlined), clicking on the text will invoke an associated command. If the text also has an icon, clicking on the icon will also invoke the command.
In order to simplify creation of screens GRIDPLUS provides a GRIDPLUS link command mode. This uses a simple syntax to create a grid of links. The syntax is closely based on the GRIDPLUS Grid.
GRIDPLUS Link Item Options |
Name of Command Invoked When a Link is Selected |
By default the name of the command invoked when a link is selected is based on the name of the toplevel (if appropriate), the grid which contains the link and the link ID.
grid,link_id
...or...
toplevel:grid,link_id
grid | Name of grid without leading dot. |
toplevel | Name of toplevel window without leading dot. |
link_id | Link ID without leading dot. |
Examples assuming a link with ID ".saveperson" in grid ".actions":-
Main/Root Window: | actions,saveperson |
Toplevel Window: | mywindow:actions,saveperson |
Note: It is possible to override the default by explicitly specifying the name of a command by using the ~command widget option.
Example |
This section contains an example which illustrates the main GRIDPLUS link 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.
Window:
Source Code:
gridplus link .mygrid1 -title "My Grid 1" { {"Link One" .1} {"Link Two" .2} {"Link Three" .3} {"Link Four" .4} {"Link Five" .5} {"Link Six" .6} {"Link Seven" .7} {"Link Eight" .8} {"Link Nine" .9} } gridplus link .mygrid2 -linkcolor /red -linkstyle /normal -title "My Grid 2" { {"Link One" .1} {"Link Two" .2} {"Link Three" .3} } gridplus link .mygrid3 -title "My Grid 3" { {+ "Link1" .1} {+ "Link2" .2} {+ "Link3" .3} {+ "Link4" .4} } gridplus link .mygrid4 -icon navforward16 -title "My Grid 4" { {: "Link1" .1} {: "Link2" .2} {: "Link3" .3} {: "Link4" .4} } gridplus link .mygrid5 -labelstyle bold/ -title "My Grid 5" { {"Label One"} {- "Link One" .1} {- "Link Two" .2} {- "Link Three" .3} } gridplus link .mygrid6 -title "My Grid 6" { {:filenew16 "New File" .new} {:fileopen16 "Open File" .open} {:fileprint16 "Print File" .print} {:filesave16 "Save File" .save} } gridplus layout .main -wtitle "Link Example" { .mygrid1:ew - - .mygrid2:ew .mygrid3:nsew .mygrid4:nsew .mygrid5:nsew .mygrid6:nsew } pack .main
Comments:
When using the GRIDPLUS link command mode the "label" defines the Link text. The cell item begining with a dot is the widget (link) ID.
".mygrid1" is a simple Grid of Links. When the mouse pointer moves over the Link the Link text will be highlighted (by default the text becomes underlined). In the following example the mouse pointer is over "Link Two"":-
Clicking on one of the Links will invoke a command based on the name of the the Grid and the widget ID.
For Example: "{"Link Two" .2}"
In this case a the name of the command invoked when the Link is clicked will be "mygrid1,2".
".mygrid2" uses the -linkcolor /red and -linkstyle /normal options to override the default highlighting behavior. When the mouse pointer moves over the Link the Link text will be highlighted by changing the Link text color to red, the "normal" style turns off the underline. In the following example the mouse pointer is over "Link Two"":-
In ".mygrid3" the cell definitions begin with a plus sign (+) . This causes the Links to be indented with a "bullet".
In ".mygrid4" the cell definitions begin with a colon (:) . This causes the Links to be indented with an icon. The icon to be displayed is specified by the -icon navforward16 option. Clicking on the icon will invoke the command associated with the Link.
In ".mygrid5" the cell definitions begin with a minus sign (+) . This causes the Links to be indented with a space. ".mygrid5" also demonstrates that text labels can also be created. In this case the -labelstyle bold/ option is applied to the label text.
".mygrid6" demonstrates that each link can have an individually specified icon. As in ".mygrid4" clicking on the icon invokes the associated command.
For Example: "{:filesave16 "Save File" .save}"
Will invoke the "mygrid6,save" command when clicking on either the Link text -or- the icon.