GRIDPLUS - Link Grid
Home Reference Manpage Examples Download License Contact

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
The name of the link (Example: .b1).

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

!
Specifies that entry validations are to be perfomed (for the window containing the link) prior to evaluating the command.

|
Specifies that a vertical bar separator be created.

+
Specifies that a "bullet" should be displayed.

-
Specifies that the link is indented.

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.


Link Example

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 -title "Link Example" {
   .mygrid1:ew  -           -        .mygrid2:ew
   .mygrid3:ew  .mygrid4:ew .mygrid5 .mygrid6
}

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.


Copyright © 2004 Adrian Davis.