Window definition table structure

The complete page() and window definition syntax is:

ExitCode = m.page(Controls[,Preview])

The function returns an ExitCode of:

drWizardContinue

drWizardNext,

drWizardPrevious,

drWizardClosed or

drWizardError

to reflect the user button press that closed the window. It's a native Lua number.

If Preview is present and TRUE, the page is just shown and callbacks are not executed. This is intended to allow the layout to be tested. When previewing, all hidden controls are shown and a message is shown in the console when a callback would have been made. NIL is returned for any extra results the callbacks would've returned.

The Controls table is used to construct the window and must contain keys as follows (the ()’d text is the data type of the key value):

Window keys:

id(str)

=

the id to use in the GXW (so its size and position can be saved/restored), if not given the window title is used.

title(str)

=

the title to use on the window (if not declared a default title of ‘Wizard’ is used)

name(str)

=

sub-title to use on the implied tab '0' (if not declared a default sub-title of ‘Make Selections’ is used), a tab ‘0’ is implied for controls declared outside of a tab structure (see below for a description of tabs)

hint(str)

=

the help to show for the window (if not declared no help button is shown for the window)

timer(int)

=

if >0 create a timer event at this centi-seconds interval.
NB: The event generation timing is approximate, do not rely on the time interval.
Also, the presence of a timer inhibits the auto-next option for wizards (i.e. the drAutoNext default is ignored)

showtabs(bool)

=

if true the tabs are exposed on a multi-tab window, default is to not show them

previous(bool)

=

if true show a ‘Back’ button (unless noback is asserted, this is implied if more than 1 tab is defined and no button is placed in the 'back' position).
This is the same as a button control with an implied 'back' callback and a 'text' property of 'Back' and a position of 'back'. The 'back' implied callback selects the previous tab if there is one, otherwise it closes the window with drWizardPrevious.

next(bool)

=

if true show a ‘Next’ button (unless nonext is asserted, this is implied if more than 1 tab is defined and no button is placed in the 'next' position).
This is the same as a button control with an implied 'next' callback and a 'text' property of 'Next' and a position of 'next'. The 'next' implied callback selects the next tab if there is one, otherwise it closes the window with drWizardNext.

finish(bool)

=

if true show a finish button (unless nonext is asserted, this is implied if only 0 or 1 tabs are defined and no button is placed in the 'next' position). This is the same as a button control with an implied 'finish' callback and a 'text' property of 'Finish' and a position of 'next'. The implied 'finish' callback closes the window with drWizardNext.

promptruler(str)

=

the default ruler to use for prompts, if not present uses: '-34p.[E].34d.[H]?' (see Ruler format for a description of rulers)

buttonruler(str)

=

the default ruler to use for buttons, if not present uses: 'L10=R!'

stringruler(str)

=

the default ruler to use for strings, if not present uses: 'L$'

textruler(str)

=

the default ruler to use for text controls, if not present uses: '-L10$74=R'

groupruler(str)

=

the default ruler to use for groups, if not present uses: '34=10..L34=R4?'

nohint1(bool)

=

if true do not draw hint line 1 or the hints bounding box (any strings placed in position drPage_HintLine1 are also ignored)

nohint2(bool)

=

if true do not draw hint line 2 or the hints bounding box (any strings placed in position drPage_HintLine2 are also ignored)

nohints(bool)

=

if true it's a shortcut for nohint1=true, nohint2=true

nonext(bool)

=

if true do not draw a 'next' or 'finish' button (any buttons placed in position drPage_Next are also ignored)

noback(bool)

=

if true do not draw a 'back' button (any buttons placed in position drPage_Back are also ignored)

noclose(bool)

=

if true do not draw the default 'close' button (you can still place your own button in position drPage_Close)

noconfirm(bool)

=

if true do not ask to confirm when closing the window, just do it (beware: unsaved changes could be lost)

bare(bool)

=

if true it's a shortcut for nohints=true, nonext=true, noback=true, noclose=true, noconfirm=true

callback(func)

=

if declared call this Lua function to process window events or child events not explicitly handled by the child

vcr(table)

=

if declared and is a table, draws the standard 'vcr' form buttons (Back, Next, New, Reset, Del, Save, Close), keys in the table are the names of the buttons (in lower case) and their value is the callback function to call when that button is pressed, the presence of this table implies noback, nonext, nohints and noclose, if a key is not present the button performs its default behaviour when pressed, the default behaviour is:

back

-

disabled

next

-

disabled

new

-

disabled

reset

-

perform a window.reset (this resets all values to as they were when the window was opened)

del

-

disabled

save

-

disabled

close

-

if the window has been touched, presses save, otherwise closes the window

prompts(table)

=

table of controls (the key name of ‘prompts’ is retained for legacy compatibility), each control can contain keys as defined in Per Control keys: below.

Per Control keys:

id(str)

=

the id (prepended by the window id) to use in the ASF (so it can have security associated with it), if not declared an id of the form ‘C#nnn’ is used, where ‘nnn’ is the control number in the window. Ids are useful to refer to controls from the prop() function (see later).

hide(bool)

=

true if the control is hidden, it exists but is not visible

readonly(bool)

=

true if the control is read-only, on a prompt this prevents its value from being changed, on groups, buttons, strings and tabs it disables them (disabled controls are visible but cannot be selected)

password(bool)

=

if true on a 'prompt' control, the value is displayed as asterisk (*) characters so user entry cannot be overseen

nulls(bool)

=

if true on a ‘prompt’ control, the value is allowed to be blank

default(bool)

=

if true on a ‘button’ control, the button is the default button, pressing the shift-Enter key presses the default button, behaviour is undefined if more than one default button is specified

nochevron(bool)

=

if true on a 'prompt' control, a chevron (») is not prepended when the control has been touched, if true on a save button, chevrons (»...«) are not placed around the button text when any control on the window has been touched

type(int)

=

the type of the control, one of:

drPage_Prompt

-

an LType editor

drPage_Button

-

a button

drPage_String

-

a (small) text string - up to 256 characters

drPage_Text

-

a (large) text string, formatted as RTF - up to 2048 characters, the string must start with the RTF header '{\rtf1' and finish with the footer '}', the paragraph terminator is '\par'.

drPage_List

-

a container for a list and its action buttons, only 1 allowed per tab, maximum of 4 per window

drPage_Tab

-

a container for any of the above (all tabs are peers), up to 9 tabs allowed per window

drPage_Group

-

a container for prompts, buttons and strings (only), use a ruler to set its size and position
NB: Unlike other controls, a group does NOT move the Y drawing position, its the window designers responsibility to prevent overlaps/overflows.

position(int)

=

where the control is to be placed, one of (see window layout):

drPage_First

-

on the front of the (next) line (forced for List and List buttons)

drPage_InLine

-

follow on from the previous control (default for strings)

drPage_Back

-

over the ‘Back’ button (ignored if noback is set), only 1 allowed per tab, the last declared takes precedence, if declared outside a tab, they are global (show for all tabs), otherwise they only show when the enclosing tab is selected, this position is not available if a vcr table is present

drPage_Next

-

over the ‘Next’ button (ignored if nonext is set), only 1 allowed per tab, the last declared takes precedence, if declared outside a tab, they are global, otherwise tab specific, this position is not available if a vcr table is present

drPage_Save

-

over the ‘Save’ button, only 1 allowed per tab, the last declared takes precedence, if declared outside a tab, they are global, otherwise tab specific, this position is not available if a vcr table is present

drPage_Close

-

over the 'Close' button, only 1 allowed per tab, the last declared takes precedence, if declared outside a tab, they are global, otherwise tab specific, this position is not available if a vcr table is present

drPage_HintLine1

-

over “hint line 1”, only 1 allowed per tab, the last declared takes precedence, if declared outside a tab, they are global, otherwise tab specific, this position is not available if nohints is set

drPage_HintLine2

-

over “hint line 2”, only 1 allowed per tab, the last declared takes precedence, if declared outside a tab, they are global, otherwise tab specific, this position is not available if nohints is set

drPage_VCRback

-

over the VCR 'Back' button, this position is only available if the vcr table is present

drPage_VCRnext

-

over the VCR 'Next' button, this position is only available if the vcr table is present

drPage_VCRnew

-

over the VCR 'New' button, this position is only available if the vcr table is present

drPage_VCRreset

-

over the VCR 'Reset' button, this position is only available if the vcr table is present

drPage_VCRdel

-

over the VCR 'Del' button, this position is only available if the vcr table is present

drPage_VCRsave

-

over the VCR 'Save' button, this position is only available if the vcr table is present

drPage_VCRclose

-

over the VCR 'Close' button, this position is only available if the vcr table is present

ask(bool)

=

if present and true same as type = drPage_Prompt (the type key must be nil) (for legacy 'page' compatibility)

show(bool)

=

if present and true same as type = drPage_Prompt + readonly=true (the type key must be nil) (for legacy 'page' compatibility)

option(bool)

=

if present and true same as type = drPage_Prompt + nulls=true (the type key must be nil) (for legacy 'page' compatibility)

text(str)

=

the visible text for the control (including any hot key designation preceded by an ampersand, e.g. ‘&Save’ makes the ‘S’ a hot-key, pressing the Alt key and the hot-key together will select the control). For a prompt, if text is not declared the default is 'Select a <typename>' where <typename> is the name of the LType for the prompt. For a group, if text is not declared the group is drawn without a box.

hint(str)

=

the What’s This? help for the control. For a prompt, the first line becomes its tool-tip, pressing the [?] button shows the help. The [?] is not dawn if there is no help.

name(str)

=

the sub-title to use on a tab or list (if not declared, no sub-title is shown)

callback(func)

=

if declared call this Lua function to process the controls events, otherwise use the callback associated with its parent (see below)

value(LType)

=

for a prompt, it's the LType object to be shown/edited, the presence of this key when type is not declared implies a drPage_Prompt control

NB: While the window is open, this value must NOT be changed by directly assigning to it, it should only be changed by using the assign operation. Failure to observe this rule will result in memory corruption and undefined behaviour (which will be bad).

alias(str)

=

for a prompt, it refers to the id of another prompt whose value is to be used here, it must be declared before the alias, if the id is not unique in the window, which one is referenced is not defined, this provides an alternative prompt to view/edit the same value

context(LType)

=

for a prompt, it's the context to pass to the LType editor. Not all LType editors expect a context, for those that don't this property is ignored. For those that do, this property if present must be of the LType expected or an equivalent LType. A context is used by an LType editor to give it a hint when there are choices, for example with the ClassMat LType the hint specifies the material class to select from when an example material is not given.

ruler(str)

=

for a group, prompt, button or string, this defines how to render the control elements (see below)

tab(table)

=

for a tab, it's a table of controls to place in the tab, controls outside of any tab are placed in the implied tab '0', tabs cannot be nested, i.e. a tab cannot be placed inside another tab, the presence of this key when type is not declared implies a drPage_Tab control

file(file)

=

on a list, the file the list is looking at (it must be open), it may be a physical file or a virtual file

keys(table)

=

on a list, a table of keys the file is being browsed on, when more than 1 key is declared, a key change tab sheet is shown, if only 1 key is declared, no key change sheet is shown, if not declared the RecNoKey is implied (i.e. key number 1), on a virtual file only 1 key is allowed and key must be a field number in the file that has unique values or 0 for physical order, each entry must be a table with the following keys:

key(key)

=

a key number the file can be browsed on

text(str)

=

text to show on the key tab (including its hot-key designation)

id(str)

=

the key id, if omitted, use the text, useful to reference the key via the prop() function (see below)

fixed(field)

=

the field number the key is fixed on or 0 if not fixed, the key must already be loaded in the file buffer

callback(func)

=

if declared call this Lua function to process the keys events, otherwise use the callback associated with its parent (see below)

paged(bool)

=

on a list, true if the list is page loaded, otherwise it's fully loaded (default is paged)

vsize(int)

=

on a list, the minimum number of rows to show, if not declared 16 is used (which is enough to fill the default tab height), the minimum is 4

bsize(int)

=

on a list, the size of the button area to reserve to its right in Dialog Units (a Dialog Unit, or DU, is approximately a quarter of a character width), the default is the default button width (40 DU) when there are buttons or 0 when not

buttons(table)

=

on a list, a table of list buttons, each entry must be a button control, these are drawn vertically to the right of the main list browse area, buttons may also be grouped using a group control

columns(bool)

=

on a list, if true individual columns in a row are selectable in the list, otherwise only the whole row is selectable

group(table)

=

on a group, a table of prompt, button and string controls in the group, the presence of this key when type is not declared implies a drPage_Group control

role(int)

=

as a list button on a list with multi-select enabled, this sets the function of the button in a multi-select context, up to 4 such buttons can be defined, omitted buttons just remove that action, the role of each must be one of:

drPage_SelectAll

=

select all records in the browse that pass whatever filters are prevalent

drPage_SelectNone

=

clear all selections

drPage_SelectInclude

=

include the currently highlighted line in the selected list

drPage_SelectExclude

=

exclude the currently highlighted line from the selected list

selected(RecNoQ)

=

on a list with multi-select enabled, use this RecNoQ instead of creating one to hold the selections (use NewQ to create it, the type must be compatible with the file being browsed), ignored if multi-select not enabled, default is to auto create a RecNoQ but it will be destroyed when the window closes, so set your own if you need it beyond that scope

list(table)

=

on a list, a list of fields to be shown in the list, the presence of this key when type is not declared implies a drPage_List control, each field is a table with the following keys:

name(str)

=

the column name, if omitted use the field name of the data from the file

role(int)

=

if present and set to drPage_SelectMarker it turns on the multi-select facility and marks this field as the 'include marker', it must be a calculated field of type Str, any callbacks on this are ignored

width(int)

=

the initial width of the column in characters (users can change this is in the usual way by dragging the column edge), if omitted the width of the column name is used

id(str)

=

the id (prepended by the window id) to use in the ASF (so it can have security associated with it), if omitted use the name

data(str)

=

the field name in the file to show, it's formatted according to its LType, if blank the field is calculated via a callback, for physical files, this may refer to a physical field or a qualifier on the file being browsed

ltype(type)

=

when the column is calculated, the LType of the result expected from the callback

callback(func)

=

if declared call this Lua function to process the columns events, otherwise use the callback associated with its parent (see below)

hint(str)

=

the What’s This? help for the column

If none of type, ask, show, option is given but value is given, then type = drPage_Prompt is assumed.

If none of type, ask, show, option is given but list is given, then type = drPage_List is assumed.

If none of type, ask, show, option is given but tab is given, then type = drPage_Tab is assumed.

If none of type, ask, show, option is given but group is given, then type = drPage_Group is assumed.

If more than one of these is given, the behaviour is undefined.