5 The controls Library

The controls library contains a series of subpatterns of windowItem, intended primarily to be used in dialog boxes (e.g. buttons, check boxes, etc.).

These subpatterns are called controls, and the inheritance tree of controls in the controls library is:

[3kb 420x167 GIF]

To illustrate the facilities, we have included the Macintosh graphical elements associated with these classes. Naturally, the graphical elements will appear differently on the Motif and Win32 platforms:

Control pattern name

Image

Description

scrollbar

[1kb 96x19 GIF]

Used for various scrolling purposes.

staticText

[919 bytes 50x19 GIF]

Used to specify permanent text in the dialog (usually explanatory text).

editText

[946 bytes 38x26 GIF]

Used to allow the user to enter some text.

pushButton

[1kb 74x54 GIF]

A button is used to specify some actions to be taken.

optionButton

[1011 bytes 120x18 GIF]

Used to specify a button with associated pop-up menu.

checkBox

[1kb 135x29 GIF]

A check box is usually used together with other check boxes to present the user with a group of non-exclusive options.

radioButton

[1kb 75x27 GIF]

A radio box is usually used together with other radio boxes to present the user with a group of exclusive options.

iconButton

[1007 bytes 43x35 GIF]

An icon is used to show a minor picture in the dialog.

Control is the superclass of all classes in the controls hierarchy. Most facilities of this class are intended for the implementation of the subclasses, and not relevant for most users of Lidskjalv.

Scrollbars are dials which the user can control to specify a value between 0 and some maximum value. The scrollbar pattern has attributes for controlling the scroll step (scrollAmount) and the maximum value of the scrollbar (maxValue). The current value of the scrollbar can be obtained and changed by the value attribute.

The event handling of scrollbar defines several new events, e.g. onThumbMoved which is invoked when the scroll thumb have been moved by the user, and onPageUp which is invoked when the user presses the pageUp area in the scrollbar.

The orientation of the scrollbar is controlled by the vertical attribute (binding vertical to trueObject sets the orientation to vertical). The length of the scrollbar is manipulated through the length attribute.

EditText is a very single line text editor, primarily usable for small amounts of text (such as file names etc.) in dialogs. The text must be in the same text style.

Button is the general superpattern for all controls that may act as buttons (i.e. react to menu button clicks), and may have a label associated with them.

Button has attributes for accessing and changing the label (label), and for accessing and changing the text style of the label (style).

PushButton is a simple button that reacts to mouse clicks. PushButton does not define additional attributes. The label of a pushButton is shown inside the button.

StaticText is a simple text label, and mostly used for informative text in dialogs and for labeling editText fields. StaticText does not define any additional attributes.

IconButton is a simple button with a icon defining its appearance. The label of an icon button may be shown centered below the icon, The showLabel attribute is used for controlling whether the label should be shown or not.

An optionButton has an associated menu, that pops up when the user clicks at the optionButton. The button text of the optionButton is automatically updated to display the currently selected item in the menu. The currently selected menu item is accessible through the currentItem attribute. The menu connected to this optionButton is an instance of the menu pattern defined in guienv. The menu is connected through the popUpMenu attribute.

ToggleButton is the general superpattern for on/off buttons.

RadioButton is a kind of toggleButton mostly used in a radio button cluster (several radioButtons of which only one can be on at any time - this must however be ensured by the application programmer in the current version). No additional attributes are defined.

CheckBox is mostly used for setting options in e.g. dialog boxes. Is intended to be used in checkbox groups. No additional attributes are defined.

DefaultButton is used for specifying the button to act as the default button (i.e. be activated by a carriage return). DefaultButton takes a reference to the button to be used as default as enter parameter. Currently not implemented on Motif.

5.1 Using the controls Library

Remember that in order to utilize this extension to Lidskjalv, the fragment controls must be included as follows:

ORIGIN '~beta/guienv/guienv';
INCLUDE '~beta/guienv/controls'
--- program: descriptor ---
guienv(# pb: @pushButton;
         ...
      do ...
         ... -> pb.label;
         ...
      #)

5.2 Examples of Use of the controls Fragment

This example illustrates how to create a window with two pushbuttons, and give a button a new size at runtime.

Program 4: button.bet

ORIGIN '~beta/guienv/guienv';
INCLUDE '~beta/guienv/controls';
(* This demo shows how to create a window with two pushButtons, and
 *  how to give a button a new size on runtime.
 *)
--- program: descriptor ---
guienv
(# theWindow: @window
     (# menubarType::
          (# testMenu: @menu
               (# sizeItem: @menuItem
                    (# open::
                         (# do 'Set size' -> name #);
                       eventHandler::
                         (# onSelect::
                              (# do (200,200)->helloButton.size #);
                         #);
                    #);
                  quitItem: @menuItem
                    (# open::
                         (# do 'Quit' -> name #);
                       eventHandler::
                         (# onSelect::
                              (# do terminate #);
                         #);
                    #);
                  open::
                    (# 
                    do sizeItem.open; sizeItem[] -> append;
                       quitItem.open; quitItem[] -> append
                    #)
               #);
             open::
               (# 
               do testMenu.open; testMenu[] -> append
               #)
          #);
        quitButton: @pushButton
          (# eventHandler::
               (# onMouseUp::
                    (# 
                    do 'Good bye, World' -> putline;
                       terminate
                    #)
               #);
             open::
               (# 
               do (40,40) -> position;
                  (100,30) -> size;
                  'Quit' -> label
               #)
          #);
        helloButton: @pushButton
          (# eventHandler::
               (# onLabelChanged::
                    (# 
                    do 'helloButton.onLabelChanged' -> putline
                    #);
                  onMouseUp::
                    (# 
                    do 'Hello, World - My name is ' -> puttext;
                       label -> putline
                    #)
               #);
             open::
               (# 
               do (40,80) -> position;
                  (100,30) -> size; 
                  'hello,world' -> putline;
                  'Hello' -> label
               #)
          #);
        eventhandler::
          (# onAboutToClose:: (# do terminate #) #);
        open::
          (# 
          do (400,400) -> size;
             quitButton.open;
             helloButton.open;
             contents -> target
          #)
     #)
do theWindow.open
#)
[16kb 411x465 GIF]


Lidskjalv: User Interface Framework - Reference Manual
© 1994-2004 Mjølner Informatics
[Modified: Friday October 27th 2000 at 14:56]