SAT/DL Using Borders as Contianers for Display Items
S@
Home SATGUI SATSHELL SATFORM SATFILTER SATREPORT SATMYSQL License Download Examples Contact


Overview

As well as providing a facility to draw outlines on the application screen, Borders can also be used as containers for display items. This allows display items to be grouped so that they may be hidden or removed with a single command.

When used in combination with the hide facility, groups of items can be displayed, removed from the display and re-displayed at will without the need to destroy and re-add the items. The Notebook example below shows one way in which this facility may be used.


Creating Items in a Container

A colon (":") separated prefix for an item has the effect of grouping items into a border. If an item is created with a colon prefix, and the prefix is the name of an existing Border item, the new item will be created in the border. The position for the new item will be relative to the top left of the border (not the top left of the screen).

Example:

addBorder {b1 1,3 30x5}
addButton {b1:Test1 1,1 8}
...Will create a button (with label text "Test1") inside border item "b1".


Removing Contained Items

When the remove command is used to delete a border item, any items created inside it are also removed.

Example:

remove b1

...Using the above "create" example, this will delete the border "b1" and the contained button "b1:test1".


Example: "Notebook"

Using border containers with hide, placeItem and a TCL procedure, it is possible to create a "tabbed notebook" effect.

Example:

Pressing the "Group1", "Group2" and "Group3" radiobuttons will display the appropriate contained items in the "sunken" border.

Source Code:

proc notebook {name} {hide "group1 group2 group3"; placeItem "$name 1,6"}
setSize 50x15

addButton {Test1 1,1 8}

addRadioButtons {rb1 1,4 {+Group1 Group2 Group3} horizontal outline {:notebook rb1}}

addBorder {group1 1,6 40x7 sunken}
addButton {group1:Test2 1,1 8}
addEntry  {group1:Test3 1,4 5,25}

addBorder {group2 hide 40x7 sunken}
addButton {group2:Test4 1,1 8}
addEntry  {group2:Test5 1,4 5,25}

addBorder {group3 hide 40x7 sunken}
addButton {group3:Test6 1,1 8}
addEntry  {group3:Test7 1,4 5,25}

setItems {
   {group1:test3 "This is Group One"}
   {group2:test5 "This is Group Two"}
   {group3:test7 "This is Group Three"}
}

Comments:

proc notebook {name} {hide "group1 group2 group3"; placeItem "$name 1,6"}

Define a TCL procedure called notebook which accepts one parameter known as name within the procedure. The procedure runs two commands hide and placeItem. This procedure will hide items group1, group2 and group3, then place the item named by the parameter at position 1,6.

Note: Parameters for the commands must be enclosed in double quotes if variable substitution is required. In this case $name.

setSize 50x15

Set the main window screen size to 50 columns by 15 lines.

addButton {Test1 1,1 8}

Create a button in the main window screen.

addRadioButtons {rb1 1,4 {+Group1 Group2 Group3} horizontal outline {:notebook rb1}}

Create a group of radio buttons called rb1.

Note: The action, which will run the notebook procedure defined above, passing the name of the selected button as a parameter.

addBorder {group1 1,6 40x7 sunken}
addButton {group1:Test2 1,1 8}
addEntry  {group1:Test3 1,4 5,25}
Create a border (group1) containing a button (group1:test2) and an entry (group1:test3. The border, and its contents, will be displayed at position 1,6.

Note: The position of the button and the entry are relative to the top left of the border (group1).

addBorder {group2 hide 40x7 sunken}
addButton {group2:Test4 1,1 8}
addEntry  {group2:Test5 1,4 5,25}
Create a border (group2) containing a button (group2:test4) and an entry (group2:test5. The hide position for the border causes the border, and its contents, to be hidden (not displayed) when first created.

Note: The position of the button and the entry are relative to the top left of the border (group2).

addBorder {group3 hide 40x7 sunken}
addButton {group3:Test6 1,1 8}
addEntry  {group3:Test7 1,4 5,25}
Create a border (group3) containing a button (group3:test6) and an entry (group3:test7. The hide position for the border causes the border, and its contents, to be hidden (not displayed) when first created.

Note: The position of the button and the entry are relative to the top left of the border (group2).

setItems {
   {group1:test3 "This is Group One"}
   {group2:test5 "This is Group Two"}
   {group3:test7 "This is Group Three"}
}
Set initial values for the entry items. This demonstrates that item values can be set even if the items are not currently displayed.


Copyright © 2003 Adrian Davis.