Programmer Guide/Shell Items/Dialog/Dialog Controls: Difference between revisions
Line 330: | Line 330: | ||
With commands containing the option <code>/Read</code>, the selection status is copied to the tag flags of the table entries, but the entry content remains unchanged. Dialog commands with the option <code>/Write</code> write both table data and selection status to the control. Table entries are displayed in show format (see the <code>SET TABLE CONFIG</code> command in [[Programmer_Guide/Shell_Items/Table/SET_TABLE#Configuring_a_table_field|Configuring a table field]]). | With commands containing the option <code>/Read</code>, the selection status is copied to the tag flags of the table entries, but the entry content remains unchanged. Dialog commands with the option <code>/Write</code> write both table data and selection status to the control. Table entries are displayed in show format (see the <code>SET TABLE CONFIG</code> command in [[Programmer_Guide/Shell_Items/Table/SET_TABLE#Configuring_a_table_field|Configuring a table field]]). | ||
{|class="keinrahmen" | |||
| <var>var1</var> | |||
| The name of the variable to store the index or the counter in. | |||
|- | |||
| <var>var2</var> | |||
| The name of a table item (/Table) or variable containing a blank separated list of items. | |||
|- | |||
| <code>/Table</code> | |||
| You must specify this option if <var>var2</var> is the name of a table containing the list items. | |||
|- | |||
| <code>/X</code> | |||
| The option <code>/X</code> stands for eXtended selection. Multiple items may be selected, and <var>var1</var> is set to the number of selected items. This option is only applicable with the <code>/Table</code> option. If this option is not specified, only one item may be selected and, <var>var1</var> contains the ''index'' of the selected item. | |||
See [[Programmer_Guide/Shell_Items/Dialog/Dialog_Controls#Common_arguments|Common arguments]] for a description of the parameters not described here. | See [[Programmer_Guide/Shell_Items/Dialog/Dialog_Controls#Common_arguments|Common arguments]] for a description of the parameters not described here. |
Revision as of 23:22, 1 June 2012
The STx dialog implementation supports the control types listed below.
Contents
Common arguments
The following parameters have the same meaning for all the SET DIALOG
control commands.
index | The control index (a number in the range 0 …999 ). The index is used in other setup commands and in messages to identify the control within the dialog.
|
row | The position of the upper left corner of the control on the y-axis in dialog units |
col | The position of the upper left corner of the control on the x-axis in dialog units. |
text | The control caption. This is displayed inside or near to the control depending on the control type and the caption positioning. |
var1 | The name of the first variable or item which is bound the the control. See the individual control syntax for more details. |
width | The width of the control in dialog characters. |
height | The height of the control in dialog characters. |
var2 | The name of the second variable or item which is bound the the control. See the individual control syntax for more details. |
fg | The foreground (text) color. |
bg | The background color. This is only used for captions and STATIC controls.
|
font | The font to use for this control. This overrides the dialog font. |
/A , /L , /R , /B or /C
|
For controls with a caption, you can set the position of the caption in relation to the control. |
/Above , /Left , /Right , /Below or /Center
|
A dialog can coexist with graphs inside a display (dialog+graphs) or can be the attached exclusively to a display (dialog-only). If an undefined command is applied to a dialog, the command is directly forwarded to the display owning the dialog. This means that all commands defined for display items can also be applied to dialog items. |
Dialog Caption Position
For the control types STATIC
, BUTTON
and GROUPBOX
the caption is displayed inside the control window. For all other types, the position of the caption can be set by one of the options /Above, /Left (default) or /Right. The same options plus the option /Center are used to set the text alignment for STATIC
controls.
For controls without their own caption (inside the control), the caption is implemented as a separate static control which is bound to the control.
Dialog Control Resizing And Positioning
If the size of the display window is changed, the control positions and sizes remain unchanged. The option /Window can be used to enable resizing/repositioning for some controls (changes are relative to the change in the display window):
Format 1: /Window=xy
x and y are single characters; each addresses two control window attributes of one dimension
Value for x | Meaning |
---|---|
x
|
50% change of x position |
X
|
100% change of x position |
w
|
50% change of width |
W
|
100%change of width |
b
|
50% change of x position and width |
B
|
100% change of x position and width |
Value for y | Meaning |
---|---|
y
|
50% change of y position |
Y
|
100% change of y position |
h
|
50% change of height |
H
|
100% change of height |
b
|
50% change of y position and height |
B
|
100% change of y position and height |
Format2: /Window=xywh
Each of the characters x, y, w and h addresses one attribute of the control window (x/y position, width, height) and can be set to h
(half change), f
(full change) or a
(automatic alignment).
For example, if you want to include an edit box in a dialog within a resizeable display, and you want the edit box to resize with the display, you can use the combination /W=**ff
as follows:
$#dlg $#index edit $#row $#col 'caption' $#tEdit $#width $#height /W=**ff
Available Dialog Controls
BUTTON
SET dialog index BUTTON row col text [* width height * fg bg font] [ /D ]
/Defaultbutton
|
Make the button the default button (activated when the dialog is displayed for the first time). A more general way (for all controls) to activate a control is implemented through the command: SET dialog index FOCUS
|
See Common arguments for a description of the parameters not described here.
Note that you may display an image in a button using the SET dialog BITMAP
command.
CHECKBOX
SET dialog index CHECKBOX row col text var1 [width height * fg bg font][ /L|R ]
A checkbox control. The checkbox sends an UPDATE
message when it is checked or unchecked.
var1 | The name of the checkbox status variable (0 =unchecked, 1 =checked, 2 =checked+grayed).
|
/3
|
Enable third state (checked+grayed); a normal checkbox supports only the states checked and unchecked. |
See Common arguments for a description of the parameters not described here.
COMBOBOX
SET dialog index COMBOBOX row col text var1 w h var2 [fg bg font] [ /E [ /I|N ]] [ /T ] [ /A|L|R ]
var1 | The name of the variable to contain the input field text (/Editenabled) or the name of the variable to contain the index of selected item in the list. |
var2 | The name of the table item (if /Table is specified) containing the combobox list (with one item per entry) or a variable containing a blank or tab separated list of words. |
/Editenable
|
Allow input field editing. If this option is used, the combobox entry can be edited and the string is stored in var1. |
/Integer or /Number
|
Only available if /Edit is specified. See /Edit/ |
/Table | If specified, var2 must be the id of a simple table item containing the list to be displayed (one entry per row). |
See Common arguments for a description of the parameters not described here.
EDIT
SET dialog index EDIT row col caption var1 [ width height var2|* fg bg font ] [ /A|L|R ] [ /F[=PCAFS] ]
var1 | The name of the variable or table (for multiline edit; /Multiline ) to store the edit string in.
|
var2 | This is an optional table setting advanced properties of the edit control (see below). If you don't need to set advanced properties, you may indicate so by supplying the asterisk, "* ", instead of a table.
|
Advanced properties of the EDIT control
A large number of advanced properties (i.e., settings) for an edit control may be set using a parameter table supplied as the var2 argument (see above). If you don't need these advanced features, you may indicate so by supplying an asterisk, "*
", instead of a table.
The parameter table used for setting the advanced properties of an edit control must be an extended table containing exactly two string columns that, in turn, must be named "parameter" and "string". You may create such a table using the following STx statement:
#tab := new table * * /E string:parameter string:string
For each advanced property to set, you need to store a respective entry (i.e., row) in the table, and tag the entry (see Tagging table entries). Each such entry has to contain the name of the respective property in the name
column, and its desired value in the string
column.
The following advanced parameters are supported:
Parameter | Value(s) |
---|---|
name field | string field |
append
|
on or off
|
breakpoints
|
on or off
|
caret
|
on or off
|
clear
|
If specified, clears the contents of the edit control. There is no argument to this parameter.
Example: |
colorOutput
|
sets the color for the shell output (only for edit controls with a type property set to cli )
|
colorInput
|
sets the color for the input (only for edit controls with a type property set to cli )
|
colorPrompt
|
sets the color for the prompt (only for edit controls with a type property set to cli )
|
colorBackground
|
Sets the color for the background (only for edit controls with a type property set to cli )
|
colorCaret
|
Sets the color (only for edit controls with a type property set to cli )
Example: |
currentLine
|
lineNumber
|
lineNumbers
|
on or off
|
outputMode
|
The following values are supported:
Example: |
outputLineLimit
|
If set to a number higher than zero, the control will limit the number of lines displayed. This is particularly useful when using a "log " type edit box.
|
prompt
|
the CLI prompt, e.g. "> " or "# "
|
readonly
|
on or off
|
showLine
|
lineNumber
|
type
|
The following values are supported:
|
waitforinput
|
If set to "on ", key messages will be passed on to the shell without the CLI processing them in any other way. This can, e.g., be used by the console getc command to wait for the user to input a character. When the key processing should continue, this parameter should be set to "off ".
|
Note again that parameters you supply in the control table are ignored unless tagged.
Important: Once a setting has been applied, the tag will be removed. So, if you want to change the setting at a later time, you need to tag it again.
Additional options for the EDIT control
Option | Meaning |
---|---|
/Integer or /Number
|
Input field must contain a valid floating-pont number (/Number ) or an integer (/Integer/<ocde>), or a numeric expression of the respective type; expressions are evaluated before assigned to var1 (not applicable/available if var1 is a table).
|
/Password
|
Input is hidden; an asterisk, "* " is displayed for each entered character
|
/Multiline
|
Allow multiline input. |
/Keystroke
|
Send UPDATE message to shell for each entered character; otherwise the update message is only sent if the input is completed (another control is selected).The enter key is a special case; for /Multiline edit boxes, the enter key is used for line breaks, whilst for single line edit boxes, the enter key sends a COMMAND message (since STx version 3.6.0). Note that the enter key for a single line edit box also sends the same command as the default button (if one is defined - see BUTTON ).
|
/F[=PCAFS]
|
If no modifier is specified, all keys are forwarded. Otherwise, the listed modifiers will come into effect. Any combination of the modifiers is allowed. The modifiers have the following meaning:
|
See Common arguments for a description of the parameters not described here.
GROUPBOX
SET dialog index GROUPBOX row col text [ * w h * fg bg font [first last]]
The groupbox control draws a frame around the area row/col, row+h/col+w, or around the specified controls first to last. If the controls first and last are specified, they must already be defined. In this case, row and col are used as margins (row for the top/bottom margin, col for the left/right margin) and not as positions. The caption is displayed inside the top line of the frame.
See Common arguments for a description of the parameters not described here.
LISTBOX
SET dialog index LISTBOX row col text var1 width height var2 [fg bg font] [ /Table [ /X ]][ /A|L|R ]
With commands containing the option /Read
, the selection status is copied to the tag flags of the table entries, but the entry content remains unchanged. Dialog commands with the option /Write
write both table data and selection status to the control. Table entries are displayed in show format (see the SET TABLE CONFIG
command in Configuring a table field).
var1 | The name of the variable to store the index or the counter in. |
var2 | The name of a table item (/Table) or variable containing a blank separated list of items. |
/Table
|
You must specify this option if var2 is the name of a table containing the list items. |
/X
|
The option /X stands for eXtended selection. Multiple items may be selected, and var1 is set to the number of selected items. This option is only applicable with the /Table option. If this option is not specified, only one item may be selected and, var1 contains the index of the selected item.
See Common arguments for a description of the parameters not described here. LISTVIEW
The
See Dialog Controls for a description of parameters not described here. Note that a lot of the listview's configuration is read from the var2 table. You can configure the table using theSET TABLE CONFIG command.[macro TestListView] // create table data #t := new table * /E * string:s1 string:s2 if '$#t[?]' != 'table' em -1 ; failed to create the table $#t config s1 1 1 1 %s 0 '' '' 'heading1' * 0 1 $#t config s2 1 1 1 %s 0 '' '' '' * 0 1 // no heading specified. field name will be used for #i := 0 to $#i < 100 step #i := int $#i + 1 $#t * s1 's1str$#i' s2 's2str$#i' end // create the dialog item #dlg := $(createmenu frame * ListView Text Dialog) #map := CDlgMap $#dlg $#dlg $($#map ci ok) button 0 0 '&OK' * 10 1 $#dlg $($#map ci cancel) button 0 10 '&Cancel' * 10 1 $#dlg $($#map ci) listview 1 0 '' #i 20 10 $#t /X /J /Header /Sort /Center // update dialog controls $#dlg * /Write // begin the modal mode domodaldialog begin $#dlg $#dlg 1 focus do forever // enter message loop // update the control $#dlg * /Write // get next dialog message domodaldialog loop $#dlg $($#map ci ok) $($#map ci cancel) // id and parameter only are returned readvar result #id #par // update the variables $#dlg * /Read // process messages if '$#id' == COMMAND then #ctl := set $($#map cn $#par) if '$#ctl' == 'ok' || '$#ctl' == 'cancel'then break // leave message loop end end end domodaldialog end // end modal mode // clean up delete $#t $#dlg $#map exit A further example can be found in the example script file
Sets the dialog focus to the specified cell and enters edit mode. If the user presses ESC, Return or Enter, the control leaves edit mode. col and row are zero-based indices addressing the field and entry. See the example script PROGRESS
The progress control can be used to display the progress of a process. It could also be used to simulate a level-meter or other value displays. The position (fill status) of a progress control is updated on each command specifying the option /Write. If a hash '
See Dialog Controls for a description of parameters not described here. RADIOBUTTON
The radio buttons are the only controls where one variable is bound to multiple controls. A new radio button group is started when a variable name var1 is specified. For all other radio buttons of the group the argument var1 must be set to '
See Dialog Controls for a description of parameters not described here. Using radio buttons may lead to problems because the function searching for the first button in a group does not always work correctly. It only works if no other control (e.g. a groupbox or a static) is placed between the buttons of the group. SLIDER
Slider controls can be used to enter values by setting the slider position and/or the display values (similar to progress controls). Normally the slider position is defined by one value. If option /2 is specified the slider can be used to select a range. A scale can optional be displayed and configured (option /Scale and value
See Dialog Controls for a description of parameters not described here. SPIN
The spin control is a button with two arrows (horizontal: left/right, vertical:up|down) which increment (right|up) or decrement (left|down) the position variable in steps of stepwidth. If a hash '
See Dialog Controls for a description of parameters not described here. STATIC
You can connect a value item to a static control using the command
See Dialog Controls for a description of parameters not described here. You can display an image in a static control using the TREEVIEW
With commands containing the option /Read, the selection status is copied to the tag flags of the table entries, but the entry content remains unchanged. Dialog commands with the option /Write writes table data and selection status to the control. Table entries are displayed in show format (see See Dialog Controls for a description of parameters not described here. |