Guides/Window Driver/Window Controls

From J Wiki
Jump to navigation Jump to search


JQt supports several types of graphic controls that can be included in the user interface. All these controls are accessed using the Window Driver.

This chapter describes each control, plus other Window Driver commands used in developing user interfaces. For an example illustrating the main types of control, run menu Help|Studio|Demos|controls

All controls are displayed in a window called the parent window. The parent window is created first, and controls are then added to it. The controls in a parent window are referred to as child controls.

The parent window and child controls have names, referred to as their ids, that are set when created. These start with an alphabetic character and consist of alphanumeric characters. Ids are case-sensitive. For example:

   wd 'pc abc'

creates a parent window with id abc.

Several parent windows may be created at a time. Only one parent window may be selected at a time: wd 'psel abc' selects the parent with id abc. The wd commands affect the selected parent.

Parent Windows

The parent window is the display area for the menus and child windows required by a user interface. The command pc, optionally followed by various styles, creates a new parent window:

  • pc creates a standard parent window
  • pc owner creates a parent window that is owned by the currently selected window. The owner is disabled until the new parent is closed.
  • pc dialog creates a window that has a dialog box frame, that is, it cannot be resized.
  • pc closeok creates a window that closes without an event when the user selects the window control menu item: Close.

Parent windows are initially not visible. They can be displayed in various ways using the pshow command, for example pshow maximized shows the parent window maximized (to fit the available screen). Typically, a parent window and all its children are created first, then the pshow command is given.

See also Window Driver Parent for further details.

Location and Size

Both location and size of controls are calculated automatically by Qt layout algorithm. Relative position of child controls are controlled by container boxes. See Window Driver Layout for further details.

The size of controls computed by Qt layout algorithm should already be sensible in most cases, but it can also be further fine tuned by setting size hint and size policy.

Size Hint

The maxwh and minwh commands set maximum and minimum values for the bounding rectangle.

2 integers define the rectangle:

  • w pixels in width
  • h pixels in height

For example:

   wd 'minwh 100 160;cc e edit'

sets the minimum size of a control to be 100 pixels wide; and 160 pixels high. Note that maxwh and minwh will reset after each cc command.

see also set maxwh, set minwh and set wh command.

Child Controls

Child controls are created in the currently selected parent window. A parent window may have several child controls. wd commands affect the child controls of the selected parent window.

Child controls are created with a given class and styles. The class defines the type of control, the styles customize the control. Some styles are specific to a particular type of control, other styles can be used with most or all controls. Style names reflect their use, for example password is a style applicable only to edit boxes.

The command cc creates child controls. Typical syntax is:

   cc id class style1 style2 ...

See Window Driver ChildClasses for further details.