Guides/Window Driver/ChildClasses

From J Wiki
Jump to navigation Jump to search

Child Classes

wd provides a rich set of controls based on Qt widget classes. Controls are placed on a form using the cc (child create) command with the format

wd'cc id type styles '

where id is the identifier for the control, type is the control type, and styles is an optional list of styles for the control. Many, though not all, of the underlying Qt widget's properties are exposed by styles specified in the cc command or through wd set commands:

wd'set id property data '

The above set command modifies the 'property' of the id control using data. If id is a string _, it stands for the control of the previous command. In addition to the set commands, several controls also have cmd commands.

If a control does not contain a QWidget, then it is invisible and some set commands will be no-op.

The number of parameters accepted in data depends on the property and the type of control. Trailing whitespace may be parsed as a separate parameter and thus may affect the result.

There are several set commands that apply to all control types. These commands are summarized first, and not repeated for each control.

Styles and set commands common to all controls

The only optional style common to all controls is flush.

flush: wd'cc id type flush'; removes spacing around the control to which it is applied, as well as all other controls in the same innermost container (bin). For example, wd'cc id editm flush' will remove the padding around the editm control id.

For the set commands below, optional or alternative parameters are enclosed within brackets.

cursor: wd'set id cursor n '; sets mouse cursor for the control. Values are defined as IDC_... in gl2.ijs.

enable: wd'set id enable [0|1]'; disables [0] or enables [1] a control. The parameter 1 may be elided.

focus: wd'set id focus'; sets focus on id.

focuspolicy: wd'set id focuspolicy [click|strong|no]'; changes the focus policy (https://doc.qt.io/qt-5/qwidget.html#focusPolicy-prop) for the control, which is normally set by default when the widget is constructed.

font: wd'set id font fontspec '; sets the font for the control to fontspec, for example, Arial 10 bold. Note that fonts set with stylesheet take precedence.

invalid: wd'set id invalid'; updates the display of the control.

maxwh: wd'set id maxwh x y '; sets the maximum width and height (in pixels) for the control, which will not grow to larger than that size.

minwh: wd'set id minwh x y '; sets the minimum width and height (in pixels) for the control, which will not shrink to smaller than that size. Note that if x y is smaller than the smallest possible dimensions for a control (which is dependent on the layout and other controls present), it may not be possible to reduce its size to that level.

nofocus: wd'set id nofocus'; changes the focus policy for the control to no.

show or visible: wd'set id [show|visible] [0|1]'; hides [0] or shows [1] the control. The parameter 1 may be elided.

sizepolicy: wd'set id sizepolicy horizontal [vertical] '; changes the default layout behavior. Parameter horizontal and vertical are [fixed|maximum|minimum|preferred|expanding|minimumexpanding|ignored]. If vertical is elided, it is taken to be the same as horizontal. (https://doc.qt.io/qt-5/qsizepolicy.html) for the control, which is normally set by default when the widget is constructed.

Constant Description
fixed The QWidget::sizeHint() is the only acceptable alternative, so the widget can never grow or shrink (e.g. the vertical direction of a push button).
minimum The sizeHint() is minimal, and sufficient. The widget can be expanded, but there is no advantage to it being larger (e.g. the horizontal direction of a push button). It cannot be smaller than the size provided by sizeHint().
maximum The sizeHint() is a maximum. The widget can be shrunk any amount without detriment if other widgets need the space (e.g. a separator line). It cannot be larger than the size provided by sizeHint().
preferred The sizeHint() is best, but the widget can be shrunk and still be useful. The widget can be expanded, but there is no advantage to it being larger than sizeHint() (the default QWidget policy).
expanding The sizeHint() is a sensible size, but the widget can be shrunk and still be useful. The widget can make use of extra space, so it should get as much space as possible (e.g. the horizontal direction of a horizontal slider).
minimumexpanding The sizeHint() is minimal, and sufficient. The widget can make use of extra space, so it should get as much space as possible (e.g. the horizontal direction of a horizontal slider).
ignored The sizeHint() is ignored. The widget will get as much space as possible.

where sizeHint can be modified using set maxwh and minwh commands.

stylesheet: wd'set id stylesheet styleinfo ' sets properties of the control using a stylesheet. Qt allows the use of css-inspired stylesheets (http://doc.qt.io/qt-5/stylesheet.html) to set many of the visual display properties of a control. For example, to set a QTextEdit control to have dark blue text on a yellow background, with 12pt Georgia as the font, styleinfo would be *QTextEdit {color:#00007f;background-color:#ffffee; font: 12pt "Georgia";}.

tooltip: wd'set id tooltip text '; sets tooltip text for the control.

wh: wd'set id wh x y '; sets the width of the control to x pixels and its height to y pixels. The control is set to a fixed size, which will not change as the form size is altered. A value of _1 (or 1) for either x or y will allow the control to grow or shrink in that dimension.

Alternative, deprecated syntax compatible with wd in J6

The "set id property data" syntax described above differs from that used by wd in J6, which typically followed the form "setproperty id data". Several of the set commands allow this alternative syntax to ease the transition from J6 to J8, but use of this alternative form is deprecated. Commands allowing this alternative syntax include setcaption, setenable, setfocus, setfont, setinvalid, setreadonly, setselect, and setshow. Applicability to specific child controls and the required parameters for these alternate commands are identical to those for the standard "set id property" commands.

Get commands common to all controls

wd'get id property [parameters] '

The above get command retrieve the 'property' of the id control with optional parameters. If id is a string _, it stands for the control of the previous command.

If a control does not contain a QWidget, then it is invisible and some get commands may return an empty string.

There are several get commands that apply to all control types. These commands are summarized first, and not repeated for each control.

For the get commands below, optional or alternative parameters are enclosed within brackets.

enable: wd'get id enable '; returns [0|1] for disabled or enabled.

extent: wd'get id extent text '; returns width, height in pixels if text is rendered using the current font of the control.

focuspolicy: wd'get id focuspolicy '; returns the focus policy [click|strong|no] (http://doc.qt.io/qt-5/qwidget.html#focusPolicy-prop) for the control.

font: wd'get id font '; returns the fontspec of the control.

hasfocus: wd'get id hasfocus '; returns [0|1], whether this control has the keyboard input focus.

hwnd: wd'get id hwnd '; same as the wd qhwndc command.

id: wd'get id id '; returns the id of the control.

maxwh: wd'get id maxwh '; returns the maximum width and height (in pixels) for the control.

minwh: wd'get id minwh '; returns the minimum width and height (in pixels) for the control.

nextfocus: wd'get id nextfocus '; returns the next control in this control's focus chain, or an empty string if there is none.

parent: wd'get id parent '; returns the id of the parent form.

prevfocus: wd'get id prevfocus '; returns the previous control in this control's focus chain, or an empty string if there is none.

property: wd'get id property '; returns a LF terminated list of all attributes which can be used in get commands.

sizepolicy: wd'get id sizepolicy '; returns both horizontal and vertical size policy. They are [fixed|maximum|minimum|preferred|expanding|minimumexpanding|ignored].

state: wd'get id state '; returns the state of the control. Format is similar to that in wd q command.

stylesheet: wd'get id stylesheet '; return stylesheet of the control.

tooltip: wd'get id tooltip '; returns tooltip text of the control.

type: wd'get id type '; returns the class name of the control. eg. button, edit.

wh: wd'get id wh '; returns the width and height in pixels of the control.

xywh: wd'get id xywh '; same as the wd qxywhchild command.

visible: wd'get id visible '; returns [0|1] for visible or hidden.

Controls

Documentation for all of the child classes is provided below, including the styles available for each child class and the set, cmd, and get commands for the control. The corresponding Qt widget class is also given for each; it may be helpful to read the documentation at http://doc.qt.io/qt-5/ for more details regarding the widget's behavior. Some additional notes regarding usage for some controls is also provided. See addons/ide/qt/demo for examples.

Some aspects of the appearance of these classes are OS dependent.


button

A standard push button control.

Qt class: QPushButton (http://doc.qt.io/qt-5/qpushbutton.html).

Create: wd'cc id button [default];cn "Push me!";' generates a button named id that displays the text "Push me!". The optional default style enables activation of the button code by pressing the enter key when the button has focus. Note that on OSX, buttons are not included in the tab order by default, but this capability can be enabled by setting Full keyboard access from the System Preferences > Keyboard and shortcuts panel within OSX.

Set commands:

caption or text - Alters the text displayed on the button. E.g., wd'set id [caption|text] "New text"'.

icon - wd'set id icon image [wxh]'. Alters the icon displayed on the button. image is the path to the icon image file. Icon images may be in a variety of formats, including bmp, png,gif, jpg, and svg. An optional wxh sets the maximum icon size. Note that the image will not resize to the maximum size.

Events:

formname_childname_button when the button is pressed

Names Created When Any Event Is Signaled:

None.

Notes:

Button appearance depends on the OS and typically will expand in width but not height as the window is resized. To insure that button width is maintained at the OS default, use a "bin s" command in the layout.


checkbox

A standard checkbox control.

Qt class: QCheckBox (http://doc.qt.io/qt-5/qcheckbox.html).

Create: wd'cc id checkbox;cn "CB name";' yields a checkbox named id with label "CB name".

Set commands:

caption or text - wd'set id [text|caption] "checkbox label"' sets the caption for the checkbox to "checkbox label".

icon - wd'set id icon image [wxh]'. Alters the icon displayed on the checkbox. image is the path to the icon image file. Icon images may be in a variety of formats, including bmp, png,gif, jpg, and svg. An optional wxh sets the maximum icon size. Note that the image will not resize to the maximum size.

value - wd'set id value [0|1]' checks [1] or unchecks [0] the box. The [0] may be elided.

Events:

formname_childname_button when the box is checked or unchecked

Names Created When Any Event Is Signaled:

childname is '1' if the box is checked, '0' if not.

Notes:

The label is always displayed to the right of the checkbox. To have a left-displayed label, use a static control to the left and set the checkbox text to "".


combobox, combolist

Editable (combobox) and readonly (combolist) drop down lists.

Qt class: QComboBox (http://doc.qt.io/qt-5/qcombobox.html).

Create: wd'cc id combo[box|list]' generates a combobox or combolist with name id. For combobox, the value in the control is editable, while that for combolist is readonly.

Set commands:

items - wd'set id items One Two Three' clears the combobox or combolist and adds the three items. An asterisk (*) preceding the list is allowed, but not necessary. The list of items is split on whitespace, but spaces within quotes are ignored. For example, the lists a and b are equivalent and add three items to the control.

a=.'"Item one" "Item two" "Item three"'

b=. '"Item one"',LF,'"Item two"',LF,'"Item three"'

select - wd'set id select n ' selects the nth item in the control, indexed from 0. If n is outside the range of items, the value displayed by the control is blank.

Get commands:

allitems - wd'get id items' returns an LF-delimited list of all items.

Events:

formname_childname_select when the control is activated (by selecting a value, or by typing a nonempty value and pressing ENTER)

Names Created When Any Event Is Signaled:

childname has the text of the selected item

childname_select is a string which, when converted to numeric, is the number of the selected item.

Notes:

Using boxed lists for entries

It is often convenient to generate combobox entries as boxed lists. For example, we have the boxed list a=: 'Item one';'Item two';'Item three'. This list can be set as the items in the control using the command

wd'set id items ', ; '"' ,each a ,each <'" '

The items in the control appear in the order provided by the wd command. To apply a case-insensitive sort use

wd'set id items ', ; '"' ,each (listsort a) ,each <'" '

where

listsort=: sort tolower each

New items typed by the user

If the user types into the combobox, Qt will offer autocompletion for the name, to suggest one of the items. If in spite of this the user types a name that is not in the list, it will be added at the end of list of items, in conformance with the default insertPolicy.


dial

A dial control (added in J804).

Qt class: QDial (http://doc.qt.io/qt-5/qdial.html).

Create: wd'cc id dial [w] [v] [min step page max pos]' creates a non-wrapping, invisible-notches dial control unless w or v is specified. The remaining parameters are all integer values. The min and max determine the range of dial positions, step specifies the increment when an arrow key is pressed, page the increment for page up/page down, and pos the current position of the dial.

Set commands:

min - wd'set id min minval ' sets the minimum for the dial range.

max - wd'set id max maxval ' sets the maximum for the dial range.

step - wd'set id step stepval ' sets the step value for the dial.

page - wd'set id page pageval ' sets the increment for page up/page down.

pos or value - wd'set id [pos|value] curpos ' specifies the current position for the dial.

notchesvisible - wd'set id notchesvisible [0|1]' notehes visible [1] or invisible [0]. The [1] may be elided.

wrap - wd'set id wrap [0|1]' wrapping [1] or non-wrapping [0] mode. The [1] may be elided.

Events:

formname_childname_changed when the value is changed

Names Created When Any Event Is Signaled:

childname is a string which, when converted to numeric, gives the dial position.


dateedit

A spinbox control for inputting dates in a variety of formats.

Qt class: QDateEdit (http://doc.qt.io/qt-5/qdateedit.html).

Create: wd'cc id dateedit [mindate maxdate initdate]' where the optional parameters are the minimum date, maximum date, and inital date for the control, with the numeric format yyyymmdd.

Set commands:

format - wd'set id format displayformat ' sets the date format for the control. A wide variety of formats may be used, summarized in the table below taken from the Qt documentation.

Expression Output
d the day as number without a leading zero (1 to 31)
dd the day as number with a leading zero (01 to 31)
ddd the abbreviated localized day name (e.g. 'Mon' to 'Sun'). Uses QDate::shortDayName().
dddd the long localized day name (e.g. 'Monday' to 'Sunday'). Uses QDate::longDayName().
M the month as number without a leading zero (1-12)
MM the month as number with a leading zero (01-12)
MMM the abbreviated localized month name (e.g. 'Jan' to 'Dec'). Uses QDate::shortMonthName().
MMMM the long localized month name (e.g. 'January' to 'December'). Uses QDate::longMonthName().
yy the year as two digit number (00-99)
yyyy the year as four digit number

For example, displayformat "dddd, MMMM dd, yyyy" would display Tuesday, June 04, 2013.

min - wd'set id min yyyymmdd ' sets the minimum date.

max - wd'set id max yyyymmdd ' sets the maximum date.

readonly - wd'set id readonly [0|1]' makes the control readonly [1] or editable [0]. The 1 can be elided.

value - wd'set id value yyyymmdd ' sets the displayed date.

Events:

formname_childname_changed when the value is changed

Names Created When Any Event Is Signaled:

childname is a string containing the selected date, in yyyymmdd format (ex: 20141105)

Notes:

Use the tab key to move among the various elements of the control and the spin control at the right to change values, or the keyboard arrow keys. The various elements are always kept true; for example, changing the day number will also change the day name to the appropriate value.


dspinbox

A spinbox control for real numeric values.

Qt class: QDoubleSpinBox (http://doc.qt.io/qt-5/qdoublespinbox.html).

Create: wd'cc id dspinbox [dec min step max val]' creates a real-value spinbox that displays dec decimal places, starting with min, increasing by step, to a value of max, with val as the starting value.

Set commands:

decimals - wd'set id decimals dec ' change display to dec decimal places.

min - wd'set id min minval ' changes the minimum value to minval.

max - wd'set id max maxval ' changes the maximum value to maxval.

readonly - wd'set id readonly [0|1]' makes the control readonly [1] or editable [0]. The 1 can be elided.

step - wd'set id step stepval ' changes the step size to stepval.

value - wd'set id value val ' displays the value val in the control.

Events:

formname_childname_changed when the value is changed

Names Created When Any Event Is Signaled:

childname is a character string that, when converted to numeric, gives the selected value


edit

A standard edit box control.

Qt class: QLineEdit (http://doc.qt.io/qt-5/qlineedit.html).

Create: wd'cc id edit [password|readonly|left|right|center]' creates a standard edit box. The password style displays dots instead of characters typed into the control, while readonly makes it non-editable. The left, right, and center styles control the alignment of the text in the edit box; note that these styles are mutually exclusive.

Set commands:

alignment - wd'set id alignment [left|right|center]' set text alignment.

text - wd'set id text "Some text"' places "Some text" in the edit box.

cursorposition - wd'set id cursorposition pos' sets the cursor position.

readonly - wd'set id readonly [0|1]' makes the control readonly [1] or editable [0]. The 1 can be elided.

limit - wd'set id limit n ' limits the edit box to containing n characters.

select - wd'set id select ' selects the contents of the edit box.

focusselect - wd'set id focusselect [0|1]' highlights and selects all text of the control if focus is set [1] or not [0]. The 1 can be elided.

inputmask - wd'set id inputmask pattern ' set input mask, see (http://doc.qt.io/qt-5/qlineedit.html#inputMask-prop)

The input mask will be unset if the parameter is an empty string.

The table below shows the characters that can be used in an input mask. A space character, the default character for a blank, is needed for cases where a character is permitted but not required.

Character Meaning
A ASCII alphabetic character required. A-Z, a-z.
a ASCII alphabetic character permitted but not required.
N ASCII alphanumeric character required. A-Z, a-z, 0-9.
n ASCII alphanumeric character permitted but not required.
X Any character required.
x Any character permitted but not required.
9 ASCII digit required. 0-9.
0 ASCII digit permitted but not required.
D ASCII digit required. 1-9.
d ASCII digit permitted but not required (1-9).
# ASCII digit or plus/minus sign permitted but not required.
H Hexadecimal character required. A-F, a-f, 0-9.
h Hexadecimal character permitted but not required.
B Binary character required. 0-1.
b Binary character permitted but not required.
> All following alphabetic characters are uppercased.
All following alphabetic characters are lowercased.
! Switch off case conversion.
\ Use \ to escape the special characters listed above to use them as separators.

The mask consists of a string of mask characters and separators, optionally followed by a semicolon and the character used for blanks. The blank characters are always removed from the text after editing.

doublevalidator - wd'set id doublevalidator min max decimals ' set double validator, see (http://doc.qt.io/qt-5/qdoublevalidator.html)

intvalidator - wd'set id intvalidator min max ' set integer validator, see (http://doc.qt.io/qt-5/qintvalidator.html)

regexpvalidator - wd'set id regexpvalidator pattern ' set regular expression validator, see (http://doc.qt.io/qt-5/qdoublevalidator.html)

Only the last validator set will be effective. The validator will be unset if the parameter is an empty string.

Events:

formname_childname_button if the ENTER key is pressed in the control

formname_childname_char (added in J804) if a key is pressed in the control. No event is raised if CTRL is down when the key is pressed. No char event is raised for function keys, tab, backtab, or ENTER. sysdata is set to the key value, as a UTF8 byte string. Special keys defined by Qt are described in ~addons/ide/qt/keys.ijs. The table there shows the faux-Unicode code points for the key values. (uucp sysdata) will match an entry in keys.ijs. This event is not signaled if the Ctrl key is down when the key is pressed, or for function keys.

Names Created When Any Event Is Signaled:

childname has the contents of the edit box

childname_select is a string which, when converted to numeric, is a list of 2 numbers giving the starting point and the ending point of the selection, as follows:

   'b e' =. 0 ". childname_select
   selection =. b }. e {. childname

If no selection has been made, b and e are the same, and indicate the cursor position.

Note: the numbers in childname_select are character numbers rather than byte numbers. The difference is important if the control contains UTF-8 characters that are encoded using multiple bytes. If your control may contain UTF-8 and you want to use childname_select as indexes into childname, convert childname into a list of characters using (7 u: childname) or (uucp childname).

(uucp childname) always converts to unicode, while (7 u: childname) does so only if childname contains non-ASCII characters.

Notes:

The readonly style does not change the background color for the edit box. To make the background light gray, use wd'set id stylesheet *background-color:#eeeeee'. To make an edit box with a fixed width of w pixels, use wd'set id wh w _1'.


edith

A multi-line edit control that displays html formatted text.

Qt class: QTextEdit (http://doc.qt.io/qt-5/qtextedit.html).

Create: wd'cc id edith' displays html formatted text based on a large subset of html formatting code, including tables and images (http://doc.qt.io/qt-5/richtext-html-subset.html).

Set commands:

edit - wd'set id edit [0|1]' makes the control editable [1] and display the html code, or readonly [0] and display the formatted text. The 1 can be elided.

text - wd'set id text *',somehtml loads the html-formatted text in the variable somehtml into the control. This command also sets the control to readonly.

select - wd'set id select [start end]' highlights and selects the text from start to end. The starting and ending positions refer to the formatted text and do not include any html markup. If both start and end are elided, the entire document is selected.

scroll - wd'set id scroll [min|max|pos]' moves the scrollbar to the top (min), bottom (max), or pos pixels from the top.

wrap - wd'set id wrap [0|1]' makes the contents of the control wrap [1] at the width of the control or not wrap [0]. The 1 can be elided.

Cmd commands

print - wd'cmd id print' prints the contents of the control to the default printer. The font and formatting of the contents are maintained in the print out. The margin and orientation can be set by the wd'defprint' command.

Events:

None

Names Created When Any Event Is Signaled:

childname has the contents of the control

childname_select is a string which, when converted to numeric, is a list of 2 numbers giving the starting point and the ending point of the selection, as follows:

   'b e' =. 0 ". childname_select
   selection =. b }. e {. childname

If no selection has been made, b and e are the same, and indicate the cursor position.

Note: the numbers in childname_select are character numbers rather than byte numbers. The difference is important if the control contains UTF-8 characters that are encoded using multiple bytes. If your control may contain UTF-8 and you want to use childname_select as indexes into childname, convert childname into a list of characters using (7 u: childname) or (uucp childname).

(uucp childname) always converts to unicode, while (7 u: childname) does so only if childname contains non-ASCII characters.

childname_scroll is a string which, when converted to numeric, gives the scroll value in pixels

Notes:

This control is intended to display richtext, with the formatting specified by html code. The webview widget (see below) provides a complete web browser. The flush style is useful when the edith control is the sole control on the form other than menus, toolbars and/or statusbars. Portions of the control may be selected using the mouse and copied to the clipboard from a right-click popup menu, but any html formatting in the selected text is lost.


editm

A multi-line edit control that displays plain text.

Qt class: QTextEdit (http://doc.qt.io/qt-5/qtextedit.html).

Create: wd'cc id editm [readonly]' creates a control for displaying unformatted text. The readonly style prevents editing of the contents.

Set commands:

limit - wd'set id limit nlines ' limits the control to containing nlines LF delimited paragraphs.

readonly - wd'set id readonly [0|1]' makes the control readonly [1] or editable [0]. The 1 can be elided.

text - wd'set id text *',sometext loads the text in the variable sometext into the control.

select - wd'set id select [start end]' highlights and selects the text from start to end. If both start and end are elided, the entire document is selected.

scroll - wd'set id scroll [min|max|pos]' moves the scrollbar to the top (min), bottom (max), or pos pixels from the top.

wrap - wd'set id wrap [0|1]' makes the contents of the control wrap [1] at the width of the control or not wrap [0]. The 1 can be elided.

Cmd commands

print - wd'cmd id print' prints the contents of the control to the default printer. The font set for the control is maintained in the print out. The margin and orientation can be set by the wd'defprint' command.

Events:

formname_childname_button when the ENTER key is pressed (with neither CTRL nor SHIFT pressed), but only if the control is readonly. The name sysmodifiers is set to '0'.

Names Created When Any Event Is Signaled:

childname has the contents of the control

childname_select is a string which, when converted to numeric, is a list of 2 numbers giving the starting point and the ending point of the selection, as follows:

   'b e' =. 0 ". childname_select
   selection =. b }. e {. childname

If no selection has been made, b and e are the same, and indicate the cursor position.

Note: the numbers in childname_select are character numbers rather than byte numbers. The difference is important if the control contains UTF-8 characters that are encoded using multiple bytes. If your control may contain UTF-8 and you want to use childname_select as indexes into childname, convert childname into a list of characters using (7 u: childname) or (uucp childname).

(uucp childname) always converts to unicode, while (7 u: childname) does so only if childname contains non-ASCII characters.

childname_scroll is a string which, when converted to numeric, gives the scroll value in pixels

Notes:

The readonly style does not change the background color for the editm control; to do so, use the setstyle command. The flush style is useful when the editm control is the sole control on the form other than menus, toolbars and/or statusbars. Portions of the control may be selected using the mouse and copied to the clipboard from a right-click popup menu.


groupbox

A group box for related controls.

Qt class: QGroupBox (http://doc.qt.io/qt-5/qgroupbox.html).

Create: wd'groupbox "Group title"' will group subsequent controls into a box labeled "Group title". The command wd'groupboxend' signals the end of the group box controls.


image

A pixmap image control.

Qt class: QWidget (http://doc.qt.io/qt-5/qwidget.html)

Create: wd'cc id image [transparent] [ignore|keep|expand]' creates a control that will display a bitmapped image where the optional parameters (added in J804) are the background and aspect ratio.

Set commands:

image - wd'set id image filename ' displays the image contained in the fully qualified filename in the control.

Notes:

If the set image command is run prior to wd'pshow', the control is sized to just contain the image, or with dimensions approximately 450x300, whichever is smaller. Scrollbars are added to the control when necessary if no aspect ratio style [ignore|keep|expand] has been set. A variety of bitmapped formats are supported, notably bmp, gif, jpg, and png.


isidraw

Target for gl2 commands. This control does not issue a paint event, and can be drawn to at any time. Use glpaint or glpaintx to complete a drawing.

Qt class: QWidget (http://doc.qt.io/qt-5/qwidget.html)

Create: wd'cc id isidraw' creates a generic widget as target for J's gl2 commands.

Events:

Event name Meaning Variables set
resize resize event (window was resized)

Note: this handler may be called immediately by wd pshow, before it returns

None
focus focus
focuslost focuslost
char key press sysmodifiers: #. (Ctrl was down (always 0)),(Shift was down)

sysdata: the key value, as a UTF8 byte string. Special keys defined by Qt are described in ~addons/ide/qt/keys.ijs. The table there shows the faux-Unicode code points for the key values. (uucp sysdata) will match an entry in keys.ijs. This event is not signaled if the Ctrl key is down when the key is pressed, or for function keys.

mwheel mouse wheel sysmodifiers: #. (Ctrl was down),(Shift was down)

sysdata: a string of bytes which should be converted to a numeric list using 0&". The numbers in the list mean:
0 cursor x position
1 cursor y position
2 x width of the isidraw control
3 y height of the isidraw control
4 boolean: Left button was down
5 boolean: Middle button was down
6 boolean: CTRL was down
7 boolean: SHIFT was down
8 boolean: Right button was down
9 always 0
10 always 0
11 mouse-wheel movement, in degrees (negative if toward the user)

Note: bits 5 and 8 were reversed in earlier versions of J

mmove mouse move event
mbldown mouse button left down
mbldbl mouse button left double-click
mblup mouse button left up
mbmdown mouse middle down
mbmdbl mouse middle double-click
mbmup mouse middle up
mbrdown mouse button right down
mbrdbl mouse button right double-click
mbrup mouse button right up

Names Created When Any Event Is Signaled:

None, except for sysmodifiers and sysdata, which are set as described in the table above.


isigraph

Target for gl2 commands. Changes to this control, such as resizing, issues a paint event. All drawing must be done in the paint event handler, and the results are automatically displayed when the handler completes (glpaint or glpaintx in the handler are ignored).

Outside the handler, glpaint or glpaintx trigger a paint event, and drawing is not allowed.

Qt class: QWidget (http://doc.qt.io/qt-5/qwidget.html)

Create: wd'cc id isigraph' creates a generic widget as target for J's gl2 commands.

Events:

Event name Meaning Variables set
paint paint event None
focus focus
focuslost focuslost
char key press sysmodifiers: #. (Ctrl was down (always 0)),(Shift was down)

sysdata: the key value, as a UTF8 byte string. Special keys defined by Qt are described in ~addons/ide/qt/keys.ijs. The table there shows the faux-Unicode code points for the key values. (uucp sysdata) will match an entry in keys.ijs. This event is not signaled if the Ctrl key is down when the key is pressed, or for function keys.

mwheel mouse wheel sysmodifiers: #. (Ctrl was down),(Shift was down)

sysdata: a string of bytes which should be converted to a numeric list using 0&". The numbers in the list mean:
0 cursor x position
1 cursor y position
2 x width of the isigraph control
3 y height of the isigraph control
4 boolean: Left button was down
5 boolean: Middle button was down
6 boolean: CTRL was down
7 boolean: SHIFT was down
8 boolean: Right button was down
9 always 0
10 always 0
11 mouse-wheel movement, in degrees (negative if toward the user)

Note: bits 5 and 8 were reversed in earlier versions of J

mmove mouse move event
mbldown mouse button left down
mbldbl mouse button left double-click
mblup mouse button left up
mbmdown mouse middle down
mbmdbl mouse middle double-click
mbmup mouse middle up
mbrdown mouse button right down
mbrdbl mouse button right double-click
mbrup mouse button right up

Names Created When Any Event Is Signaled:

None, except for sysmodifiers and sysdata, which are set as described in the table above.


isigrid

A grid control, see isigrid.


listbox

A standard listbox control.

Qt class: QListWidget (http://doc.qt.io/qt-5/qlistwidget.html)

Create: wd'cc id listbox [multiple]' generates a listbox with name id. The multiple style enables extended selection mode for the listbox. When multiple is enabled, the variable id contains an LF-delimited list of the selected items.

Set commands:

items - wd'set id items One Two Three' clears the listbox and adds the three items. An asterisk (*) preceding the list is allowed, but not necessary. The list of items is split on whitespace, but spaces within quotes are ignored. For example, the lists a and b are equivalent and add three items to the control.

a=.'"Item one" "Item two" "Item three"'

b=. '"Item one"',LF,'"Item two"',LF,'"Item three"'

select - wd'set id select n ' selects the nth item in the control, indexed from 0. If n is outside the range of items, no item is selected.

Get commands:

allitems - wd'get id allitems' returns an LF-delimited list of all items.

items - wd'get id items' returns an LF-delimited list of the selected item(s).

Events:

formname_childname_select when the selection is changed

formname_childname_button when the control is activated. What action activates the listbox is system dependent. Clicking or double-clicking the listbox may activate it; or pressing ENTER (On Windows or X11) or Ctrl+0 (on Mac OSX).

Names Created When Any Event Is Signaled:

childname has the selected text, or '' if no selection has been made

childname_select is a string which, when converted to numeric, is a list of the selections (_1 if no selections have been made)

Notes:

See Notes for combolist control.


menu

A menubar control.

Qt class: QMenuBar (http://doc.qt.io/qt-5/qmenubar.html).

Create: wd'menupop "&Menuname"' places a new menu with name Menuname in the menubar. An ampersand in the name will use the following character as a hotkey for navigation. Items are added to the menu with the command wd'menu id "Itemname" ["controlkey"]'. The Itemname may include an ampersand which is used as a hotkey. An optional controlkey, for example Ctrl+Q, can be assigned to the menu item. The command wd'menusep' will place a separator within the menu. When all of the menu items have been added, the menu is closed with wd'menupopz'. Note that submenus may be nested within menus by following the above sequence of commands.

Set commands:

caption or text - wd'set id [caption|text] text ' sets the text displayed for the menu item.

checked or value - wd'set id [checked|value] [0|1]' sets the menu item id as checked [1] or unchecked [0].

enable - wd'set id enable [0|1]' enables [1] or disables [0] the menu item. In contrast to other controls, the parameter 0 or 1 is required.

Events:

formname_childname_button when the menu item is selected

Names Created When Any Event Is Signaled:

None.

Notes:

Menu items and toolbar buttons with identical id can be checked or enabled independently but yield the same action when pressed.


multimedia

A standard multimedia player control (added in J804).

Qt class: QMediaPlayer (http://doc.qt.io/qt-5/qmediaplayer.html).

Create: wd'cc id multimedia [video]' creates a standard multimedia player control. The video style displays a video QWidget, otherwise there will be no QWidget and the control is invisible.

Set commands:

media - wd'set id media "Some file"' set file name or URL of media to be played.

play - wd'set id play' start playing

pause - wd'set id pause' pause playing

stop - wd'set id stop' stop playing

mute - wd'set id mute [0|1]' muted [1] or not muted [0]. The 1 can be elided.

position - wd'set id position n ' set position to n millisecond.

volume - wd'set id volume n ' set volume to n (range between 0 and 100)

playbackrate - wd'set id playbackrate n ' set playbackrate to n (n is a floating number, default to 1)

The following only apply to multimedia control with video style

brightness - wd'set id brightness n ' set brightness to n (range between _100 and 100)

contrast - wd'set id contrast n ' set contrast to n (range between _100 and 100)

hue - wd'set id hue n ' set hue to n (range between _100 and 100)

saturation - wd'set id saturation n ' set saturation to n (range between _100 and 100)

aspectratio - wd'set id aspectratio [ignore|keep|expand]' set aspect ratio mode.

fullscreen - wd'set id fullscreen [0|1]' fullscreen [1] or confined to a window [0]. The 1 can be elided.

Events:

Event name Meaning Value set into sysdata
bufferstatus buffer status changed percentage of buffer filled*
duration duration of media changed duration (in milliseconds) of media.* Use this event to retrieve duration because duration is unavailable until media has started to play.
error error occurred string describing the error
mediastatus media status changed string describing the new media status
playstate media playing state changed stopped, playing or paused
position reports current position, approximately once per second current position (in milliseconds)*
volume volume changed volume (range between 0 and 100)*
  • sysdata is always a byte string. (0 ". sysdata) gives the numeric value described in the table.

Names Created When Any Event Is Signaled:

sysdata, as described in the table above.

Notes:

Both audio and video formats are supported, but depending on platforms. Android does not support video style.


opengl

A target for OpenGL rendering context. The minimum version supported are OpenGL 2 and OpenGL ES 2.

Qt class: QOpenGLWidget (http://doc.qt.io/qt-5/qopenglwidget.html)

Create: wd'cc id opengl [version major.minor]' creates a widget for OpenGL rendering context. The major and minor parameters set the desired OpenGL versions.

Events:

Event name Meaning Variables set
paint paint event None
focus focus
focuslost focuslost
char key press sysmodifiers: #. (Ctrl was down (always 0)),(Shift was down)

sysdata: the key value, as a UTF8 byte string. Special keys defined by Qt are described in ~addons/ide/qt/keys.ijs. The table there shows the faux-Unicode code points for the key values. (uucp sysdata) will match an entry in keys.ijs. This event is not signaled if the Ctrl key is down when the key is pressed, or for function keys.

initialize initialize OpenGL context
mwheel mouse wheel sysmodifiers: #. (Ctrl was down),(Shift was down)

sysdata: a string of bytes which should be converted to a numeric list using 0&". The numbers in the list mean:
0 cursor x position
1 cursor y position
2 x width of the isigraph control
3 y height of the isigraph control
4 boolean: Left button was down
5 boolean: Middle button was down
6 boolean: CTRL was down
7 boolean: SHIFT was down
8 boolean: Right button was down
9 always 0
10 always 0
11 mouse-wheel movement, in degrees (negative if toward the user)

Note: bits 5 and 8 were reversed in earlier versions of J

mmove mouse move event
mbldown mouse button left down
mbldbl mouse button left double-click
mblup mouse button left up
mbmdown mouse middle down
mbmdbl mouse middle double-click
mbmup mouse middle up
mbrdown mouse button right down
mbrdbl mouse button right double-click
mbrup mouse button right up

Names Created When Any Event Is Signaled:

None.

Notes:

see OpenGL ES.


progressbar

A standard progressbar control.

Qt class: QProgressBar (http://doc.qt.io/qt-5/qprogressbar.html).

Create: wd'cc id progressbar [v] [min] [max] [cur]' creates a horizontal progressbar unless the v style is specified. The min, max, and cur parameters are all integer values that specify the minimum, maximum, and current value, respectively.

Set commands:

min - wd'set id min minval ' sets the minimum value for the progressbar to minval.

max - wd'set id max maxval ' sets the maximum value for the progressbar to maxval.

pos or value - wd'set id [pos|value] curval ' sets the position of the progressbar to curval. If curval is outside the range for the progressbar, the command is ignored.

Events:

None.


quickwidget

A widget for displaying a Qt Quick user interface.

Qt class: QQuickWidget (http://doc.qt.io/qt-5/qquickwidget.html).

Create: wd'cc id quickwidget [mode] [version major.minor]' creates a quickwidget control. The size of the control may be set by preceding with a minwh command. The mode parameter is [0] or [1] (default) determines whether the view should resize the window contents. The major and minor parameters set the desired OpenGL versions.

Set commands:

source - wd'set id source url ' displays the QML component at url in the control.

resizemode - wd'set id resizemode [0|1] ' determines whether the view should resize the window contents.

Events:

None.

Notes:

See Guides/Window Driver/QtQuick for further details.


radiobutton

Mutually exclusive radio buttons.

Qt class: QRadioButton (http://doc.qt.io/qt-5/qradiobutton.html).

Create: wd'cc id radiobutton [group]' defines a radiobutton; all members of a radiobutton group except the first should include the group style.

Set commands:

caption or text - wd'set id [caption|text] "Button name"' sets the text for the radiobutton.

icon - wd'set id icon image [wxh]'. Alters the icon displayed on the button. image is the path to the icon image file. Icon images may be in a variety of formats, including bmp, png,gif, jpg, and svg. An optional wxh sets the maximum icon size. Note that the image will not resize to the maximum size.

value - wd'set id value 1' selects the radiobutton id. The "1" in the command is required.

Events:

formname_childname_button when the button is pressed.

Names Created When Any Event Is Signaled:

childname is '1' if the box is checked, '0' if not.


scrollbar

A scrollbar control (added in J804).

Qt class: QScrollbar (http://doc.qt.io/qt-5/qscrollbar.html).

Create: wd'cc id scrollbar [v] [min step page max pos]' creates a horizontal scrollbar control unless v is specified. The remaining parameters are all integer values. The min and max determine the range of scrollbar positions, step specifies the increment when an arrow key is pressed, page the increment for page up/page down, and pos the current position of the scrollbar.

Set commands:

min - wd'set id min minval ' sets the minimum for the scrollbar range.

max - wd'set id max maxval ' sets the maximum for the scrollbar range.

step - wd'set id step stepval ' sets the step value for the scrollbar.

page - wd'set id page pageval ' sets the increment for page up/page down.

pos or value - wd'set id [pos|value] curpos ' specifies the current position for the scrollbar.

Events:

formname_childname_changed when the value is changed

Names Created When Any Event Is Signaled:

childname is a string which, when converted to numeric, gives the scrollbar position.


slider

A slider control.

Qt class: QSlider (http://doc.qt.io/qt-5/qslider.html).

Create: wd'cc id slider [v] [tickstyle min step page max pos]' creates a horizontal slider control unless v is specified. The remaining parameters are all integer values. The tickstyle must be 0=no ticks, 1=above/left, 2=below/right, or 3=both sides. The min and max determine the range of slider positions, step specifies the increment when an arrow key is pressed, page the increment for page up/page down, and pos the current position of the slider.

Set commands:

tic - wd'set id tic ticval ' sets the tick style with ticval as noted in the create command.

min - wd'set id min minval ' sets the minimum for the slider range.

max - wd'set id max maxval ' sets the maximum for the slider range.

step - wd'set id step stepval ' sets the step value for the slider.

page - wd'set id page pageval ' sets the increment for page up/page down.

pos or value - wd'set id [pos|value] curpos ' specifies the current position for the slider.

Events:

formname_childname_changed when the value is changed

Names Created When Any Event Is Signaled:

childname is a string which, when converted to numeric, gives the slider position.

Notes:

The appearance of the slider thumb will change with the value of tickstyle.


spinbox

A spinbox control for integer numeric values.

Qt class: QSpinBox (http://doc.qt.io/qt-5/qspinbox.html).

Create: wd'cc id spinbox [min step max val]' creates a integer-value spinbox that starts with min, increases by step, to a value of max, with val as the starting value.

Set commands:

min - wd'set id min minval ' changes the minimum value to minval.

max - wd'set id max maxval ' changes the maximum value to maxval.

readonly - wd'set id readonly [0|1]' makes the control readonly [1] or editable [0]. The 1 can be elided.

step - wd'set id step stepval ' changes the step size to stepval.

value - wd'set id value val ' displays the value val in the control.

Events:

formname_childname_changed when the value is changed

Names Created When Any Event Is Signaled:

childname is a string which, when converted to numeric, gives the spinbox position.


static

A label widget. The text can be plain text or HTML (see http://doc.qt.io/qt-5/richtext-html-subset.html for the supported subset of HTML).

Qt class: QLabel (http://doc.qt.io/qt-5/qlabel.html).

Create: wd'cc id static [staticbox] [left|right|center] [nowrap] [sunken|raised|panel];cn "Label text"' places a static label with name id and text "Label text" on the form. If the cc command is not followed by a cn command, staticbox prevents the id name from showing on the form. Alignment is specified by [left|right|center], with left as the default. The appearance of the label is determined by [sunken|raised|panel].

Set commands:

caption or text - wd'set id text Some new label text' sets the text for the static control. Note that the parameter does not need to be quoted; all of the information after the word text is used for the label.

Events:

None.

Names Created When Any Event Is Signaled:

None.

Notes:

The size of the static label is set to be the minimum required for the specified text, given its position and that of other elements on the form. Word wrapping is enabled. Precede the cc command with a wh command, or use set minwh, to specifiy a minimum size to be occupied by the label.

The HTML subset supported by Qt does not support entities (items beginning with &, such as &nbsp;)


statusbar

StatusBar.png

Qt class: QStatusBar (http://doc.qt.io/qt-5/qstatusbar.html).

Create: wd'cc id statusbar' takes no parameters. The set commands are used to define the elements of the statusbar.

Set commands:

addlabel - wd'set id addlabel sbname ' adds a region with name sbname to the left side of the statusbar. Successive addlabel commands define regions building from the left.

addlabelp - wd'set id addlabelp sbnamep ' adds a region with name sbnamep to the far right side of the statusbar. Successive addlabelp commands define regions building to the far right side of the statusbar.

setlabel - wd'set id setlabel sbname "Statusbar text"' sets the text (Statusbar text) for a region sbname identified by an addlabel or addlabelp command.

show - wd'set id show "Temporary text" [duration]' places a temporary message (Temporary text) at the left end of the statusbar for duration milliseconds. The temporary message will obscure regions defined by addlabel commands, but will not cover up those specified in addlabelp commands. If no duration is specified, the temporary message will remain on the statusbar until set clear is called.

clear - wd'set id clear' clears temporary statusbar messages.

Events:

None.

Names Created When Any Event Is Signaled:

None.

Notes:

Although statusbars typically are placed at the bottom of the form, other positions can be specified in the form layout.


tab

Horizontal or vertical form tabs.

Qt class: QTabWidget (http://doc.qt.io/qt-5/qtabwidget.html).

Create: wd'cc id tab [documentmode] [movable] [closable] [east|west|south] [nobar]' creates a tab bar. The documentmode style controls the appearance of the tabs in an OS-dependent way. The movable and closable styles allow the tabs to be reordered or closed, respectively. The default location of the tab bar is at the top of the subsequent layout, but it may be set to appear in a different position by specifying east, west, or south. The nobar style hides the tab bar, but individual tabs may still be shown using the set active command. After the cc command, a wd'tabnew Tab name' command starts the layout for a tab (with label "Tab new"), which is concluded with a wd'tabend' command.

Set commands:

active - wd'set id active tabindex ' displays the tab specified by tabindex, which has a zero origin.

tabclose - wd'set id tabclose tabindex ' closes the specified tab.

label - wd'set id label tabindex newlabel ' changes the label for the specified tab. Quotes must be used if newlabel contains spaces.

Events:

formname_childname_select when the tab selection is changed

formname_childname_tabclose when a tab is closed

Names Created When Any Event Is Signaled:

childname is a string containing all the tab labels, concatenated into one string with a DEL character (255{a.) after each label (including the last if there is one).

childname_select is a string which, when converted to numeric, gives the number of the selected tab, or _1 if no tab is selected.


table

A grid control based on QTableWidget, see table.


timeedit

A spin control for displaying time.

Qt class: QTimeEdit (http://doc.qt.io/qt-5/qtimeedit.html).

Create: wd'cc id timeedit [mintime maxtime curtime]' creates a time control with minimum, maximum, and displayed time, respectively. The time values are formatted based on a 24-hour clock as hhmmss.mil where the value after the decimal point is the number of milliseconds

Set commands:

format - wd'set id format displayformat ' where displayformat is constructed according to the following table (taken from the Qt documentation):

Expression Output
h the hour without a leading zero (0 to 23 or 1 to 12 if AM/PM display)
hh the hour with a leading zero (00 to 23 or 01 to 12 if AM/PM display)
m the minute without a leading zero (0 to 59)
mm the minute with a leading zero (00 to 59)
s the second without a leading zero (0 to 59)
ss the second with a leading zero (00 to 59)
z the milliseconds without leading zeroes (0 to 999)
zzz the milliseconds with leading zeroes (000 to 999)
AP use AM/PM display. AP will be replaced by either "AM" or "PM".
ap use am/pm display. ap will be replaced by either "am" or "pm".

min - wd'set id min mintime ' minimum time for the control with the same format as in cc.

max - wd'set id max maxtime ' maximum time for the control with the same format as in cc.

readonly - wd'set id readonly [0|1]' makes the control readonly [1] or editable [0]. The 1 can be elided.

value - wd'set id value curtime ' displayed time with the same format as in cc.

Events:

formname_childname_changed when the value is changed

Names Created When Any Event Is Signaled:

childname is a string containing the selected time, in hhmmss.sss format (ex: 81520.23)


toolbar

ToolBar.png

Qt class: QToolBar (http://doc.qt.io/qt-5/qtoolbar.html).

Create: wd'cc id toolbar [wxh] [vertical]' creates a toolbar with buttons w width by h height. The format for the button size must include the x, for example, 32x32. The vertical style makes the toolbar orientation vertical as opposed to the default horizontal orientation. If both button size and vertical styles are specified, the button size must come first.

Set commands:

add - wd'set id add idname text image ' adds a button to the toolbar. The parameter idname is the name of the toolbar button, text is the tooltip text (use quotes if it includes spaces), and image is the path to the icon image file. Icon images may be in a variety of formats, including bmp, png,gif, jpg, and svg.

addsep - wd'set id addsep' adds a separator to the toolbar.

checkable - wd'set id checkable idname [0|1]' makes button idname checkable [1] or not [0]. The parameter 1 may be elided.

checked - wd'set id checked idname [0|1]' gives the idname button checked status [1] (button must have been made checkable), or unchecks it [0]. The parameter 1 may be elided.

enable - wd'set id enable [0|1]' or wd'set id enable idname [0|1] The first form enables [1] or disables [0] the entire toolbar. The second form enables [1] or disables [0] the button idname on the toolbar. The 1 may be elided in either case.

icon - wd'set id icon idname image [wxh]'. Alters the icon displayed on the button. image is the path to the icon image file. Icon images may be in a variety of formats, including bmp, png,gif, jpg, and svg. An optional wxh sets the maximum icon size. Note that the image will not resize to the maximum size.

Events:

formname_idname_button when the value is changed. Note that the ID of the checked button, rather than the name of the child control, is in the name of the event.

Notes:

Menu items and toolbar buttons with identical id can be checked or enabled independently but yield the same action when pressed. In the add command, the full path to the image must be provided if the image file is not in the current working directory. Because the path may not be known until runtime, it may be preferable to group all of the add commands in a function run after initialization.


webview

A fully functional web-browser widget based on WebKit.

Qt class: QWebView (https://doc.qt.io/qt-5/qtwebview-index.html).

Create: wd'cc id webview [transparent]' creates a web browser control. The size of the control may be set by preceding with a minwh command. The transparent option makes the background transparent.

Set commands:

url - wd'set id url dispurl ' displays the information at dispurl (e.g., http://www.jsoftware.com) in the control.

baseurl - wd'set id baseurl base ' defines as base the baseurl for any subsequent set html commands.

html - wd'set id html htmlcode ' loads html code specified by htmlcode into the browser window. References within the code are resolved relative to the baseurl.

Events:

Event name Meaning Variables set
focus focus
focuslost focuslost
char key press sysmodifiers: #. (Ctrl was down (always 0)),(Shift was down)

sysdata: the key value, as a UTF8 byte string. Special keys defined by Qt are described in ~addons/ide/qt/keys.ijs. The table there shows the faux-Unicode code points for the key values. (uucp sysdata) will match an entry in keys.ijs. This event is not signaled if the Ctrl key is down when the key is pressed, or for function keys.

curl URL was changed
mwheel mouse wheel sysmodifiers: #. (Ctrl was down),(Shift was down)

sysdata: a string of bytes which should be converted to a numeric list using 0&". The numbers in the list mean:
0 cursor x position
1 cursor y position
2 x width of the isigraph control
3 y height of the isigraph control
4 boolean: Left button was down
5 boolean: Middle button was down
6 boolean: CTRL was down
7 boolean: SHIFT was down
8 boolean: Right button was down
9 always 0
10 always 0
11 mouse-wheel movement, in degrees (negative if toward the user)

Note: bits 5 and 8 were reversed in earlier versions of J

mmove mouse move event
mbldown mouse button left down
mbldbl mouse button left double-click
mblup mouse button left up
mbmdown mouse middle down
mbmdbl mouse middle double-click
mbmup mouse middle up
mbrdown mouse button right down
mbrdbl mouse button right double-click
mbrup mouse button right up

Names Created When Any Event Is Signaled:

None, except for sysmodifiers and sysdata, which are set as described in the table above.



Contributed by Norman Drinkwater, 6/2013