New Tool: Universal Resource Editor
by Matt Smith, Prominare, Inc.
As you may have already discovered while exploring The Developer Connection for OS/2 CD-ROMs that have been issued this year, they include a new tool for building your Graphical User Interface (GUI) for OS/2 Presentation Manager applications. The tool is the Universal Resource Editor (URE), and it's in the Developer's Toolkit for OS/2 Warp. (You might have thought that URE was only for use with OS/2 Warp Connect (PowerPC Edition) because it appeared in that toolkit initially, but if you had taken a closer look, you would have seen that you can use it to create and maintain any of your OS/2 applications.)
The Universal Resource Editor is a derivation of the Prominare Designer tool from Prominare, Inc. URE not only lets you create and maintain dialog boxes as you do with the Dialog Editor (included in the Developer's Toolkit for OS/2 Warp), but it also lets you create and maintain the other resources used in your application, such as menus, accelerators, help tables, bitmaps, icon, pointers, and the remaining resource types.
Unlike the Dialog Editor, URE lets you maintain all of your resources from within one development tool and effectively puts to an end the need to edit your resource script files. As a bonus, you can also bypass the .RC file, because URE can save directly to the final binary resource (.RES). Not only do you save space by not having the ASCII script file, you can save time because you won't have to wait for the OS/2 Resource Compiler to do its job.
A Quick Tour
Beyond allowing you to create and maintain the resources for your application, URE provides a host of other useful features that make the creation of the GUI for your OS/2 Presentation Manager applications easier than before. The following table compares the features found in URE with those of the Dialog Editor:
|Importing - OS/2 binary resouces||X||X|
|Importing - OS/2 script resources||X|
|Importing - Windows binary resources||X|
|Importing - Windows Script resources||X|
|Extracting OS/2 resources from .EXEs and .DLLs||X|
|Extracting Windows resources from .EXEs and .DLLs||X|
|Cutting/pasting windows, dialog boxes, and controls||X||X|
|Fonts and colors||X||X|
|Bidirectional (NLS) support||X|
|Pasting from file||X|
|Search and replace of controls||X|
|Base PM controls||X||X|
|Pen for OS/2 controls||X||X|
|PMCX - custom control facility||X|
|Define defaults for control creation||X|
|CUA compliance checking||X|
|Default usage of tool||X|
|Autolabeling of constants||X|
|Dialogue font metrics||X|
URE's toolbar gives you easy access to frequently used features. Notice in Figure 1 that the toolbar has two rows of buttons:
Figure 1. The URE toolbar
First, let's take a quick look at some of the significant features found on the File menu.
- URE can import the following types of files:
- OS/2 1.x, 2.x, and 3.x .RC script files
- OS/2 1.x, 2.x, and 3.x .RES binary files
- Windows 3.0, 3.1, and NT .RC script files
- Windows 3.0 and 3.1 .RES binary files
- Windows NT resource binary files
- It can extract the following types of files:
- OS/2 1.x, 2.x, and 3.x resources from .EXE and .DLL files
- Windows 3.0, 3.1, and NT resources from .EXE and .DLL files
- The Merge Design function lets you combine two or more designs into one.
- The Print function lets you print either individual panels or a complete design, including specific details such as panel IDs, distribution, and invocation. You can also scale the images to fit the page to which you are printing.
From URE's Edit menu, you can cut, copy, and paste windows, dialog boxes, and controls. You can also paste elements from other design files into the one on which you are working.
The Find menu helps you search within your current design for symbols or text, similar to the way a word processor does.
You can use the Control menu or the Tools window to create OS/2 Presentation Manager controls. (URE supports all OS/2 Presentation Manager controls, including those for MMPM/2 and Pen for OS/2.)
You can define different resources through the Resource menu. URE provides support for every resource type except RCDATA. Because of this, you do not necessarily have to create an .RC file that must be compiled using the existing OS/2 Resource Compiler. With URE, you can save the resources directly to binary, either in OS/2 1.x/2.x format or directly to OS/2 Warp Connect (PowerPC Edition) object file format.
The Configure menu lets you customize URE. You can define default styles for the controls to use when they are added to a window or dialog box, as well as the size (both height and width), default text, default ID (if desired), default control data, font and colors, and bi-directional support. This lets you quickly and easily define a working style for your windows and dialog boxes.
For example, you can specify that all push buttons be 50 dialog units wide by 12 units high. Normally, the OS/2 Dialog Editor creates push buttons that are always 38 dialog units wide by 12 units high.
Another example, and the reason why this feature exists, is that check boxes and radio buttons are created by the Dialog Editor as simple check boxes and radio buttons. However, most developers like to use the auto-checking feature for check boxes/radio buttons, and have previously had to change the style from simple to auto (because the Dialog Editor doesn't allow the user to specify that they want to use the auto-select feature). URE lets you define the default style for check boxes and radio buttons to always be the auto style, so you don't have to change the style of the button.
URE also lets you define the autosave frequency, initial startup dialog, alignment margins, control spacing, grid values, and push button spacing. You can define the prefixes for the ID symbols and the auto-generation of the ID symbol using/not using the prefix. You can prevent or enable the checking of duplicate controls within a window or dialog box (to some, this is a welcome relief). You can also define the mouse/keyboard control combinations that perform actions on controls and such.
One of the more unique features of URE is its ability to determine if the text within a dialog box or window will be clipped when displayed on different resolutions. URE can accurately show what the font limits will be for one display type versus another. For example, while designing on a system with 1024 x 768 resolution, you can make sure that the dialog text will properly display in 640 x 480 VGA resolution. This is an open-ended facility - when new display types and resolutions become available in the future, the metrics will still accurately show the limits of the display types. URE has a utility that will let you determine the metrics of the new monitor and/or adapter, which can then be used by URE.
URE and Control Extensions
URE lets you use PM Control Extensions (PMCX) compliant controls in your design. This particular feature provides a dialog box from which you can easily define the characteristics of the custom control you are using.
Generally, you arrange controls to set the Z-order. The Z-order is the imaginary third axis within a dialog box that "comes out" of the display towards you. OS/2 Presentation Manager uses this to determine how to show the various controls that you create. Therefore, a control created first within a dialog box is lower in the Z-order than a control created later on. The current Dialog Editor only allows you to select one control at a time to change its position related to its "siblings." URE goes beyond this by letting you rearrange more than one control at a time.
It is possible for URE to distribute parts of the resources to various locations. This is useful when creating a multi-faceted application that has many different resource DLLs.
URE lets you define which control should receive the initial focus when a dialog box is displayed. This feature has been part of the binary dialog templates in Presentation Manager since OS/2 Version 1.1, but until now no tools could take advantage of it because they would only emit to resource script format. Now with URE, you can use this feature if you save the resources in their binary format. You don't have to programmatically set the initial focus within the processing of WM_INITDLG. URE also helps you ensure that the correct control receives focus, even if you are using C++ class libraries that don't let you set the focus.
There is good reason to save your resources directly to binary format. One of the fastest and easiest ways to immediately improve productivity with URE is to save the resources to the final binary .RES file (rather than saving them to the standard .RC resource script file). This can save you a significant amount of time. It has been observed that with large resource script files (400 Kbytes+), the script file save time of 10 seconds and compile time of 50 seconds has been reduced to a save time of only 5 seconds.
Keeping Track of IDs
URE has a feature that lets you display a dialog ID or symbol on top of the control that uses that ID or symbol. This can be useful when you want to know the IDs of controls within a dialog box. To make your programming process even easier, you can combine this feature with the print facility to create a hard copy image that shows both the controls and the corresponding ideas.
URE provides its alignment facility in the form of a notebook. You can align controls easily, in just one move (instead of four or more moves if you use the Dialog Editor).
In a future issue of The Developer Connection News, I will talk about the makeup and construction of a PM Control Extension custom control. You will be able to see just how easy it is, with URE, to take your own custom controls and create PMCX-compliant controls that can be easily referenced within your designs.
Reprint Courtesy of International Business Machines Corporation, © International Business Machines Corporation