GUI Terminology and Overview
Terminology
Term | Definition |
---|---|
Context | In Visual PRO/5, each graphical window is created with its own context. All objects and events associated with a window are referenced using its context. |
Control | A control is an object that is used as part of a graphical interface. Some typical controls include push buttons, text boxes, list buttons, and radio buttons. |
Dialog | A dialog is a special window that requires a response from the user. In most languages, dialogs and graphical windows are each created through a discrete syntax. Visual PRO/5 offers a simple, uniform syntax for creating dialogs and windows. In Visual PRO/5, dialogs are created by assigning dialog attributes to windows. |
Event | An event is the report of a graphical object or device being operated or manipulated by the user. Some examples are: clicking on a mouse button, choosing a menu item, or pressing a key on the keyboard. |
GUI | GUI is an acronym for Graphical User Interface. |
Mnemonic | A mnemonic us an abbreviated reference intended to trigger memory to some command or concept. This term has been adapted into traditional Business BASIC languages for some classes of I/O commands. Visual PRO/5 has extended the mnemonic classes to include the creation and management of graphical objects. |
Object | An object consists of data and specific rules that control operations performed on that data. |
SYSGUI | The SYSGUI device, defined in the configuration file, provides a method of communicating with the graphic-based screen interface provided with Visual PRO/5. |
SYSWINDOW | The SYSWINDOW is a device, defined in the configuration that represents the character-based screen interface provided by Visual PRO/5. It represents an extension to the traditional BBx terminal device. |
Window | A window is a logical screen used for many purposes. Graphical windows created via the SYSGUI device differ from the character-based windows created with the SYSWINDOW device. Both devices, however, use windows. |
Graphical User Interfaces
Visual PRO/5 provides two system devices for the definition of graphical interfaces:
-
SYSWINDOW
-
SYSGUI
The SYSWINDOW Device
The SYSWINDOW provides a character-cell oriented display with significant graphical capabilities. With the SYSWINDOW, the developer can:
-
Select from several pitched fonts
-
Define mouse-sensitive areas on the screen
-
Minimize and maximize the window
-
Activate operating system standard File Open and File Save dialogs
-
Ask questions or prompt the user for a character string in a graphical dialog
-
Play sound files on supported platforms
-
Customize colors using a color map
-
Utilize the clipboard for cut and paste operations
-
Send the window contents to a printer
Multiple SYSWINDOWs can be opened. Each SYSWINDOW requires an alias line in the config.bbx file.
The SYSWINDOW device offers a bridge for traditional, character-based applications. Older applications can run in this environment without modification, and can be modified gradually to include or be replaced by programs that interact with the graphical environment.
The SYSGUI Device
The SYSGUI device provides an environment that accepts a full range of graphical commands. This is the environment where full-featured graphical applications will be designed. The SYSGUI device supports:
-
Windows
-
Child Windows
-
Dialogs
-
Model Dialogs
-
Standard graphical controls (such as buttons and scroll bars)
-
User Cues
-
Toolbars
-
Status Bars
-
Drawing and Plotting
-
Special Purpose Controls
The SYSGUI device requires an alias line like the following in the config.bbx file:
ALIAS X0 SYSGUI
This line is normally provided during installation. A standard I/O channel is then used to communicate with the SYSGUI device. Just open X0 and start interacting with it. For example, the following code fragment will open X0, retrieve a resource from a resource file, and then display it:
0010 OPEN (1) "X0"
0020 LET H=RESOPEN("myfile.brf")
0030 LET R$=RESGET(H,1,1)
0040 PRINT (1) 'RESOURCE' (LEN(R$)),R$
Commands are sent to the SYSGUI device driver in the form of print mnemonics. Traditional Business BASIC programmers will find this format of command to be familiar and similar in concept to the mnemonics they have used in character-based environments, such as `CS' (clear screen) and `SB' (start background or dim mode).
Programmers that are new to Visual PRO/5 and its predecessor languages will find it easy to use mnemonics. Most of the SYSGUI mnemonics are structured in the form of procedure calls with lists of parameters. Visual PRO/5 employs concepts familiar in other graphical languages. It inherits from traditional Business BASICs the compact and powerful I/O verbs, which have made rapid application development a reality. Business BASIC programmers are accustomed to using I/O verbs and functions that do not require extensive supporting code, and this ease of use and simplicity has been extended wherever possible to the SYSGUI device.
In particular, the distinction between windows and dialogs as known in other languages has been blurred to the point where Visual PRO/5 windows can be designed to exploit some of the best of both windows and dialogs simultaneously. This simplified approach reduces the set of commands required to support full-featured applications.
Because applications will frequently need to work with several windows at a time, Visual PRO/5 uses the concept of contexts to differentiate between windows. Each window has its own context and events are returned from the SYSGUI device with a context ID. If only one graphical window is needed at a time, setting the context is not necessary. However, if you want to display one window, then display another window, and manipulate them simultaneously, the programs will have to be made context aware.
Valid context IDs are integers from 0 to 32676. When the SYSGUI device is first opened, the context is automatically assigned an ID of 0. If it is not changed, the first window created is associated with context 0. If another window is needed, a new context is created by first using the 'CONTEXT' mnemonic with an unused ID. When the window is created, it will be associated with the context ID just specified.
Although many contexts may be created, only one context may be current. Many commands operate on the current context while others specify the context ID as a parameter. To switch contexts, issue the `CONTEXT' mnemonic with the desired context ID.
It is possible to query the SYSGUI device for an unused context ID to avoid run-time errors or logic problems. Programs written for use as "add-on" modules for other applications should be written to make use of this feature. To query the SYSGUI device, use the FIN() and CTRL() functions. Refer to the CTRL() and FIN() documentation for more information.
Units of Measure
Because the SYSGUI device contains so much information, two coordinate systems are needed. One is for the placement and manipulation of GUI object such as the controls and the windows themselves. The other is for the drawing and plotting commands. Each has its own set of measurement units.
All operations that manipulate GUI objects, such as controls and windows, are performed with coordinates in the CONTROL coordinate system. CONTROL coordinates have their origin (0,0) at the upper-left corner of the window. The units of measure in the CONTROL coordinate system are specified by the 'PIXELS', 'CHARS', and 'SEMICHARS' mnemonics. 'PIXELS' are the default unit of measure.
Use of screen pixels as the unit of measure for controls is not portable because of the way text is displayed in the controls. Suppose a control is defined in pixels and sized so that the text is correctly displayed inside the control for the system font. If the system font changes, the text will probably not look right. Going from a small system font to a large system font often leads to text being truncated.
Visual PRO/5 supports chars and semichars as units of measure to enable portability between different system fonts. These units are based on the Windows system fonts. Since the system font is determined by the Windows display driver, these units, by extension, are determined by the display driver and the font chosen by the user in the Windows setup.
Chars are cells in which the height is always the height of the system font. The width is the width of an average character in the system font. Semichars, contrary to their name, are not half the size of a char, but are defined as a cell that is one-quarter the width of the char and one-eighth of its height. While both chars and semichars are scalable, semichars are more commonly used because it is a smaller unit that enables finer control.
Because chars and semichars are based on a unit that scales with the system font, these units can be used for portable programs. When a window and its controls are defined in chars or semichars, the sizes of the window and controls will be adjusted properly for whatever system font is used.
The CONTROL coordinate system can be scaled to adjust for different requirements. The 'SCALE' mnemonic allows specification of a multiplier to apply to the basic unit of measure, whether pixels, chars, or semichars. For example, if a user wants to double the size of a window and its components, the 'WINDOW' mnemonic could be used to create a window 200 x 150 pixels in size at pixel location (100,100). Then, a 'SCALE'(2,2) issued prior to the 'WINDOW' command will result in the window being positioned at pixel location (200,200) with a size of 400 x 300 pixels.