************************************* * * * DB/C Newsletter * * July 1995 * * * ************************************* Editor's Notes We were very interested to read the announcement that IBM has licensed Mac OS (the Apple Macintosh operating system). IBM, Apple and Motorola have been developing the PowerPC chip for several years. It is an impressive piece of silicon. One question comes to mind - if IBM is going to sell Mac OS based PowerPCs, what is the future of OS/2 Warp? IBM's licensing of Mac OS provides one more reason to use DB/C for your GUI programming - complete run-time portability. No matter what happens in the GUI/OS wars, if you write applications using DB/C, your programs will run in the popular operating environments. This month's article provides details of the new GUI features of DB/C 9. It is important to note that DB/C 9 also includes the Fast Development Environment - integrated editors, compiler, and debugger. FDE will be the topic of next month's newsletter. Several special painter/editors included with FDE automatically create the code described in this month's article. So don't be dismayed by the complexity of GUI programming - with DB/C 9, you won't need to write DB/C statements like those described this month. don.wills@swc.com GUI Features New in DB/C 9 There are many new features in the GUI versions of DB/C 9. Most of these features are portable between each of the GUI versions of DB/C 9 - Windows (95 & NT), Mac OS, UNIX X-Windows and OS/2. This article will describe each of the portable features and how to write programs using these features. The window device has been enhanced. Window devices no longer need to be named "WINDOW01", "WINDOW02", etc. When creating a window, the first parameter in the second operand of the prepare statement must have the value 'WINDOW=windowname'. Here an example of the creation of a window device named "MAINWIN ": WIN DEVICE PREP WIN, "window=MAINWIN, noclose" When used in the prepare statement for a window device, the new parameter 'FULLSCREEN' causes a window to be created that fills the primary screen. There are no title bars, sizing buttons, etc. in a window defined with the 'FULLSCREEN' parameter. There are three new change functions associated with a window device. The new change functions are 'STATUSBAR', 'NOSTATUSBAR' and 'POINTER'. 'STATUSBAR' causes a status bar and message to be displayed at the bottom of the window. The list of variables after the semi-colon contains the message to be displayed in the status bar. For example: CHANGE WIN, "statusbar"; "Printing in progress" 'NOSTATUSBAR' hides the displayed status bar. If there is not a status bar being displayed, 'NOSTATUSBAR' is ignored. 'POINTER' causes a particular pointer to be shown when the cursor is on top of the window. The type of pointer is specified by the variable following the semi-colon in the change statement. Currently, these types of pointers are allowed: 'ARROW', 'WAIT', 'CROSS' and 'IBEAM'. 'ARROW' is the default. Here is an example the displays the 'WAIT' pointer: CHANGE WIN, "pointer"; "wait" When linked with a queue variable, a window device produces these four new messages: 'CHAR', 'NKEY', 'WACT' and 'WSIZ'. 'CHAR' and 'NKEY' report keystrokes. These messages are only sent when the window has focus and no panel is displayed in the window. 'CHAR' reports a printable character in position 18 of the message. 'NKEY' reports the numeric value of an extended character or keyboard combination (for example ALT+A). The value is reported as a five character numeric value that follows the same convention that the getendkey statement uses in conjunction with the keyin statement. The 'WACT' message is sent when the window receives keyboard focus. The 'WSIZ' message is sent when the operator resizes the window with any of the sizing buttons. The horizontal and vertical values at positions 18-22 and 23-27 of the message are set to the new size of the window. There is a new device called a timer device. A timer device allows the programmer to set alarms, etc. using a device variable which can be linked to a queue variable. The 'TIMER=timername' parameter is all that is required and allowed in the creation of a timer device. Here is an example: TMR DEVICE PREP TMR, "timer=TIMER" There are three change functions associated with a timer device. These functions are 'SET', 'CLEAR' and 'MSETnnn'. The 'SET' function causes a timer to be set. The time of expiration of the timer is specified by the variable list following the semi-colon. Here is an example: CHANGE TMR, "set"; "19950704111500" Note that the value of the timer is specified in the YYYYMMDDHHMMSSPP format. The 'CLEAR' function clears the timer. The 'MSETnnn' function sets a recurring (or multiple) timer. If a timestamp is specified (in the same manner as for 'SET'), then the first timer expiration will occur then and subsequent timer expirations will occur 'nnn' seconds apart. If a timestamp is not specified, then the first expiration will occur 'nnn' seconds from now. When linked with a queue variable, a timer device sends a 'TICK' message whenever it expires. Positions 18-33 of the message contain the timestamp in the YYYYMMDDHHMMSSPP format. There are two new types of resources - icons and toolbars. Here is an example of a definition of each of these new resources: ICN RESOURCE BAR RESOURCE PREP ICN, "icon=start, h=16, v=16, colorbits=4, pixels=": "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF": "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFAAAAFFFFFFFFFFFFAAAAFFFFFF": "FFFFFFAAAAFFFFFFFFFFFFAAAAFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF": "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" PREP BAR, "toolbar=maintool, pushbutton=1:start:Start Engine,": "pushbutton=2:stop:Stop Engine" For an icon resource, 'ICON=icon' must be the first parameter. 'icon' is the name of the icon resource. The 'H', 'V' and 'COLORBITS' parameters are optional. 'H' and 'V' specify the number of columns and rows in the icon. Valid values are 8, 16 and 32. If not specified, 'H' and 'V' default to 16. 'COLORBITS' specifies the number of bits per pixel of color. Valid values are 1, 4 and 24. If not specified, 'COLORBITS' defaults to 4. The 'PIXEL' parameter contains values that are the actual color values of the pixels. For 1 and 4 color bits per pixel, each character specifies one pixel. For 1 color bit per pixel, the value '0' specifies black and '1' specifies white. For 4 color bits per pixel, the values '0' through 'F' (hexadecimal representation) specify the colors in using standard VGA values (values '8' through 'F' are bright colors). For 24 color bits per pixel, each 6 characters represents a 24 bit value as 6 hexadecimal digits. The first pair represent the blue intensity, the second pair represent the green intensity and the third pair represent the red intensity. For a toolbar resource, 'TOOLBAR=toolbarname' must be the first parameter. 'toolbarname' is the name of the toolbar resource. All other parameters are optional. Toolbars consist of two kinds of buttons - pushbuttons and locking pushbuttons. These buttons are defined by the 'PUSHBUTTON=item:icon:text' and 'LOCKBUTTON=item:icon:text' parameters. By default buttons are adjacent to each other. The 'SPACE' parameter causes there to be extra space between buttons. In the button parameters, 'item' is the item number, 'icon' is the name of an icon resource to be displayed in the button, and 'text' is the help text associated with a button. Toolbar resources can also be manipulated with the change statement. The 'MARKnnnnn' and 'UNMARKnnnnn' change functions cause a toolbar lockbutton to be locked and unlocked, respectively. The 'TEXTnnnnn' change function changes the text associated with a button. The 'ICONnnnnn' change function changes the icon associated with a button. For the 'ICONnnnnn' function, the list of variables specifies the name of the icon. The 'DELETEnnnnn' change function causes a button to be deleted. The 'ADDPUSHBUTTONnnnnn', 'ADDLOCKBUTTONnnnnn' and 'ADDSPACE' functions add new buttons and space between buttons. For the add button functions, the list variable is the name of the icon associated with the button. Buttons and spaces are added after the last button. This is modified with the 'INSERTPOSBEFOREnnnnn' and 'INSERTPOSAFTERnnnnn' change functions. In these two functions, 'nnnnn' is optional and specifies the button before or after which adds will occur. If 'nnnnn' is not specified, the add takes place with respect to the first button in the toolbar. Here is another example that creates a toolbar: ICN1 RESOURCE ICN2 RESOURCE BAR RESOURCE Q QUEUE SIZE=64 PREP ICN1, "icon=icon1, h=16, v=16, colorbits=4, pixels=": "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF": "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFAAAAFFFFFFFFFFFFAAAAFFFFFF": "FFFFFFAAAAFFFFFFFFFFFFAAAAFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF": "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" PREP ICN2, "icon=icon2, h=16, v=16, colorbits=4, pixels=": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFFFFAAAAAAAAAAAAFFFFAAAAAA": "AAAAAAFFFFAAAAAAAAAAAAFFFFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" PREP BAR, "toolbar=maintbar" CHANGE BAR, "addpushbutton1"; "icon1" CHANGE BAR, "text1"; "Pushbutton 1" CHANGE BAR, "addspace" CHANGE BAR, "addpushbutton2"; "icon2" CHANGE BAR, "text2"; "Pushbutton 2" LINK BAR WITH Q Several controls and new features have been added to panel and dialog resources. Here is a list of the new controls and features, along with the syntax used in the prepare statement: 'RTEXT=text' 'VTEXT=item:text' 'RVTEXT=item:text' 'CTEXT=text:horzsize' 'MEDIT=item:text:horzsize:vertsize' 'FEDIT=item:text:text:horzsize' 'PEDIT=item:text:horzsize' 'BOXALPHA' 'BOXAPPEND' 'BOXTABS=nn:nn: ... nn' 'PROGRESSBAR=item:horzsize:vertsize' 'ICON=icon' 'ICONPUSHBUTTON=item:icon:horzsize:vertsize' 'ICONDEFPUSHBUTTON=item:icon:horzsize:vertsize' 'ICONESCPUSHBUTTON=item:icon:horzsize:vertsize' 'RTEXT' is right justified text. It is just like 'TEXT', except the text is right justified such that the current position is the upper right corner of the text, not the upper left corner. In addition, the current position is not altered. 'VTEXT' is variable text. It is just like 'TEXT', except that it may be changed the a change statement. That is why the 'item' number is included. 'RVTEXT' is right justified variable text. It is the combination of 'RTEXT' and 'VTEXT'. 'CTEXT' is centered text. Text is centered in the field whose left side is defined by the current position and whose width is specified by 'horzsize'. 'MEDIT' is a multiple line edit box control. It is just like 'EDIT', except the 'vertsize' value specifies the vertical size of the edit box. Automatic word wrapping occurs when text is entered into an 'MEDIT' control. 'FEDIT' is the formatted edit box control. It is similar to 'EDIT', but in addition a user specified edit mask (the first 'text' field) controls what characters are allowed and how the field should be displayed. The edit mask special characters are 'A', 'U', 'L', 'Z', '9', '.', and '~'. 'A' means allow any character to be entered. 'U' and 'L' mean allow any character, but force it to be upper or lower case, respectively. 'Z' and '9' mean only allow digits and right justify automatically when the control loses focus. When the control loses focus, any unfilled '9' characters are replaced by '0' and any unfilled 'Z' characters are replaced by blanks. The '.' character acts as a forcing and alignment character for decimal value alignment. '~' is the forcing character. Here is an example: DLG RESOURCE PREP DLG, "dialog=dlg1,fedit=1:999-99-9999::110" 'PEDIT' is the password edit control. It is the same as an 'EDIT' control, except that asterisks or big dots are shown instead of the character that are typed. 'BOXALPHA' and 'BOXAPPEND' control the order in which entries are shown in list box and drop box controls. Each of these parameters controls all of the list box and drop box controls that follow. 'BOXALPHA' is the default. 'BOXALPHA' means that the entries are displayed in alphbetic sequence. 'BOXAPPEND' means the the entries are displayed in the order in which they were added to the control. 'BOXTABS' controls the column positions in all following list box controls. Each of the 'nn' entries is the horizontal pixel position of the tab stop associated with each column. Note that columns are left justified. 'PROGRESSBAR' is a progress indicator control. It is usually a horizontal control that fills from left to right. The change statement is used to change its filled value. 'ICON' displays an icon in the dialog or panel. The 'icon' value is the name of the icon resource that is displayed. The upper left corner of the icon is located at the current pixel position. 'ICONPUSHBUTTON' is an icon pushbutton. It is the same as a regular 'PUSHBUTTON' control, except an icon is displayed inside the button instead of text. 'ICONDEFPUSHBUTTON' and 'ICONESCPUSHBUTTON' are icon versions of the 'DEFPUSHBUTTON' and 'ESCPUSHBUTTON' controls. There are many new resource operations available with the change statement. Here is a list of them: 'ADDLOCKBUTTONnnnnn' 'ADDPUSHBUTTONnnnnn' 'ADDSPACEnnnnn' 'ICONnnnnn' 'DELETELINEnnnnn' 'LOCATELINEnnnnn' 'INSERTPOSBEFOREnnnnn' 'INSERTPOSAFTERnnnnn' 'INSERTPOSLINEBEFOREnnnnn' 'INSERTPOSLINEAFTERnnnnn' 'JUSTIFYLEFTnnnnn' 'JUSTIFYCENTERnnnnn' 'JUSTIFYRIGHTnnnnn' 'FOCUSON' 'FOCUSOFF' 'LINEON' 'LINEOFF' As described above, 'ADDPUSHBUTTON', 'ADDLOCKBUTTON', and 'ADDSPACE' work in conjunction with toolbar resources. 'ICON' allows the icon associated with an icon control or icon button control to be altered. The list of variables following the semi-colon is the name of the new icon resource. 'DELETELINE' causes an entry of a list box or drop box to be deleted. The entry is identified by line number which is specified by the variable following the semi-colon. 'LOCATELINE' causes an entry of a list box or drop box to be highlighted. The entry is identified by line number which is specified by the variable following the semi-colon. With respect to list and drop box controls, 'INSERTPOSBEFORE' and 'INSERTPOSAFTER' causes 'INSERT' operations to insert lines at particular locations the control. If text is specified by the variable or variables following the semi-colon, inserts will occur before or after the entry whose text matches the specified text. If no text is specified, then inserts will occur before the first entry in the control or after the last entry in the control. These two change operations also affect toolbar resources as described above. 'INSERTPOSLINEBEFORE' and 'INSERTPOSLINEAFTER' cause insert operations on list and drop box controls to occur with respect to an entry identified by a line number. The line number is contained in the variable following the semi-colon. 'JUSTIFYLEFT', 'JUSTIFYCENTER' and 'JUSTIFYRIGHT' affect the display of text within edit controls. The justification occurs when a control loses focus. 'FOCUSON' and 'FOCUSOFF' toggle the transmission of FOCS type messages. FOCS messages are sent whenever a control gains focus. 'LINEON' and 'LINEOFF' toggle the transmission of ITEM and LIST type messages from list and drop box controls. When linked with a queue variable, panel and resources send messages with the value 'FOCS' at character positions 9-12 whenever a control gains focus. Character positions 13-17 of the message contain the control number. GUI programming in DB/C entails many details. The positive effect of all of these details is to give the programmer ultimate control, at run-time, with the entire user interface. The negative affects are mitigated by tools such as FDE that provide automatic source code generation. DB/C Class Schedule The next DB/C class is not yet scheduled.