Console UI widgets

When you use Console UI in RCP mode (see Console UI) you can add controls to your display by means of widgets. Widgets are the basic elements in a graphical user interface, including buttons, radio buttons, check boxes, and combo boxes. EGL uses the Java™ standard widget toolbox (SWT) to provide these elements.

EGL treats these widgets like EGL parts. You declare variables based on them, and each has associated properties. All widgets have the following properties:
name
This is the name the Console UI program will use to recognize the widget.
bounds
This is an array of four integers specifying the location and size of the widget, in characters, as follows: [row, column, height, width].
The following widgets are available:
ConsoleButton
This creates what appears to be a raised area on the screen. When the user clicks the button, it appears to be depressed; when the user releases the click, the button returns to normal. A ConsoleButton has the following additional property:
text
A STRING whose value will appear on the button.
A ConsoleButton generates the following event:
PUSHED
This indicates that the user clicked the button.
ConsoleCheckBox
This creates a standard check box. When a blank check box is clicked, the box displays an X or check mark (depending on the platform). When a checked box is clicked, the box clears. A ConsoleCheckBox has the following additional property:
text
A STRING whose value will appear on the button.
A ConsoleCheckBox generates the following event:
STATE_CHANGED
This indicates that the user clicked the check box. Bind the check box to a BOOLEAN variable to check the state of the box. TRUE indicates the box is checked.
ConsoleCombo
This creates a standard combo box (also called a drop-down list). When the user selects a value from the expanded box, the selected value appears in the condensed form of the box. A ConsoleCheckBox has the following additional property:
items
An array of STRINGs whose values will appear in the expanded box.
A ConsoleCheckBox generates the following event:
SELECTION_CHANGED
This indicates thta the user clicked the combo box. If the user picks the same element as before, the box will still generate the event. Bind the check box to an integer variable (such as a SMALLINT or a BIN(4,0)) to get an index into the items array corresponding to the selected element.
ConsoleRadioGroup
This creates a set of standard radio buttons. Only one radio button can be selected at a time. When the user selects a value from the set, the selected button appears as filled in and the other buttons in the set are cleared. A ConsoleRadioGroup has the following additional property:
items
An array of STRINGs whose values will appear next to the buttons.
A ConsoleRadioGroup generates the following event:
SELECTION_CHANGED
This indicates that the user clicked one of the radio buttons. If the user clicks the same element as before, the group will still generate the event. Bind the group to an integer variable (such as a SMALLINT or a BIN(4,0)) to get an index into the items array corresponding to the selected element.
ConsoleList
This creates a list box, which is a list of string values from which the user can select one or more. A ConsoleList has the following additional properties:
items
An array of STRINGs whose values will appear next to the buttons.
multipleSelect
A BOOLEAN that specifies whether the user can select more than one item in the list, usually by holding the CTRL key while selecting items.
A ConsoleList generates the following event:
SELECTION_CHANGED
This indicates the user changed the selection in the list. If the user clicks the currently selected element, the list box will still generate the event. Bind the list box to an integer variable (such as a SMALLINT, INT or BIN(4,0)) to get an index into the items array corresponding to the selected elements.

If multipleSelect is set to false (as is the default), meaning that only one item in the list can be selected, the variable bound to the ConsoleList contains the index of the selected item. If the first item is selected, the variable contains the number 1; if the fifth item is selected, the variable contains the number 5.

If multipleSelect is set to true, the variable contains a binary representation of the selected items. Each item in the list is assigned a multiple of two according to its position: the first item is 1, the second is 2, the third is 4, the fourth is 8, the fifth is 16, the sixth is 32, and so on. The value of the variable is the sum of the values of all the selected items. For example, if only the first item is selected, the variable contains 1. If the first and second items are selected, the variable contains 3, which is the sum of the values for the two selected items. If the second, fifth, and sixth items are selected, the variable contains 50, or 2+16+32.

Example

The following simplified console record includes one of each type of widget.
Record ShowWidgets type ConsoleForm { formsize=[12,55] }

*    ConsoleField      { position=[2,5], value="First Name" };
firstName ConsoleField { name="firstName", position=[2,20], 
   fieldLen=15, value="", inputRequired=no };

*     ConsoleField    { position=[3,5], value="Last Name" };
lastName ConsoleField { name="lastName", position=[3,20], 
   fieldLen=8, value="", inputRequired=yes };

button1 consolebutton {
  name = "button1", bounds = [5,5,1,15], text = "Submit"
  };
  
box1 consolecheckbox {
  name = "box1", bounds = [5,6,1,15], text = "Check Me!"
  };
  
combo1 consolecombo {
  name = "combo1", bounds = [7,5,1,15]
  };
radio1 consoleradiogroup {
  name = "radio1", bounds = [5,25,3,15]
  };
list1 consoleList {
  name = "list1", bounds = [10,25,3,15]
  };
end
In the following excerpt, the console displays the selected element of the combo box.
OnEvent(ConsoleCombo.SELECTION_CHANGED: "combo1")
  writeStdOut(myForm.combo1.items[combo1var]);

For more extensive code samples, see the topics dealing with Console UI widgets in the EGL Programmer's Guide.


Feedback