Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!cronkite!exodus!spot.Eng.Sun.COM!watson From: watson@spot.Eng.Sun.COM (Robert Watson) Newsgroups: comp.windows.open-look Subject: Re: HELP! I need tool to make tools Message-ID: <15853@exodus.Eng.Sun.COM> Date: 26 Jun 91 21:05:06 GMT References: Sender: news@exodus.Eng.Sun.COM Organization: Sun Microsystems Inc. Lines: 172 > Is anyone at Sun listening ? As there seems to be some interest in the design of our new code generators, our marketing dept. put togther this piece. -bob watson -manager Devguide Dear developers: tHE OpenWindows Developer's Guide (Devguide) 3.0 now has code generator support for all the OPEN LOOK toolkits provided by OpenWindows. The Xview code generators, gxv and gxv++, have both been enhanced to take advantage of the enhancements to XView (i.e. internationalization). In addition there are two new code generators, golit for the OPEN LOOK Intrinsics Toolkit (OLIT), and gnt for the NeWS Toolkit (TNT). Each code generator has been specifically designed to enhance the strengths and design of the toolkits, and to address the needs of the specific developers. Hence the output of each code generator is uniquely designed to best support its specific toolkit. This white paper will highlight the design goal of each of the code generators as well as specify issues to consider when using each of the code generators. GXV, GXV++ The Devguide gxv and gxv++ code generators are designed to generate C and C++ compliant C code respectively for the XView toolkit. The generated code is much like code a programmer would write, therefore it is very readable. The generated code is not "machine generated", or in a proprietary format that is difficult to decode and understand. The files that are created contain user interface code as well as some application specific code, such as the code found in the stubs.c file which contains the XView main loop with the stub call back procedures. Developers should only need to modify the stubs.c file to add their application specific code. This file is maintained and updated whenever the developer modifies the user interface and regenerates the code. A code generator that generates real toolkit code for the application has both advantages and disadvantages. One of the advantages is that it generates real code that can be easily be read, modified and maintained. In fact, developers who are unfamiliar with XView can easily take the generated code to learn XView. The disadvantage is that the code generator can generate voluminous amounts of code. For example, gxv generates both executable code and resource data that grows in proportion to the complexity of the user interface implementation. In an application that contains a large or intricate user interface, the ui.c file can contain thousands of lines of code. This code, which is frequently only executed once during the user interface intialization, takes a long while to compile and creates a very large executable file. In addition the user interface is not easily separated from the application so user interface modifications cannot be dynamically made. Both gxv and gxv++ support the internationalization (I18N) features of XView, producing code which allows the resulting application binary to be localized. There are two flags which enable this feature: -g causes "dgettext" wrappers to be placed around all strings associated with the interface, allowing easy extraction of the text by the "xgettext" utility. "xgettext" produces a portable object file (.po file) that can be localized, compiled into a text database, and supplied at runtime. The localized database string values will override the string values in the binary code, presenting the user with a localized version of the product. -r Devguide, by default, uses an absolute layout scheme for all user interface objects. This layout scheme can cause problems when the localized strings are not the same length as the original text strings (i.e. buttons can overlap). The developer can use Devguide to relay out the user interface, using the new localized text strings, and then set the -r flag to invoke the XView XV_USE_DB wrapper around object attributes associated with object size and positioning. These wrappers cause the application to check the resource database file for object size and position information when the localized application is run. Note that Devguide provides a group layout features that eliminates the need to use the -r flag. Group layout allows for relative layout at runtime. The group layout is the preferred and recommonded method to use for applications that will be localized. GOLIT The Devguide golit code generator for the OLIT toolkit was designed to provide an OLIT programmer with a fast and efficient method to implement a user interface with OLIT. Golit was not designed to teach novice programmers how to program in OLIT. Instead of generating toolkit code, golit generates data structures which define the user interface widget hierarchy and their associated resources. A small runtime component enumerates this widget table and instantiates the hierarchy when the application is intialized. This particular approach has the following advantages and disadvantages: 1. The executeable code size is invariant with the complexity of the user interface. 2. The description of a particular user interface object (widget) is highly efficient relative to the equivalent hand written code needed to create a similar specified object. However the specification of some attributes in the user interface cannot be customized externally from the X defaults because of the relative priorities of resource application to objects during instantiation. 3. The concise API to libgolit provides the developer with a very simple to understand/use collection of functions that also enable great flexibility in the manipulation and control of the instantiation of user interface elements within the hierarchy. 4. The user interface is more easily separated from the application. GNT The Devguide gnt code generator for the TNT toolkit follows the model of the gxv code generator for XView in that it generates toolkit code. TNT and NeWS is an environment with a fairly steep initial learning curve. Once that learning curve is topped, the benefits of the environment can be fully utilized. Gnt assists in that learning curve. It not only generates the user interface code, it also provides assistance to the developer learning TNT and NeWS by providing example code. Gnt opens the door to TNT and provides enhancements to the toolkit (i.e. internationalization support and linking of controls). The gnt design allows for the following advantages and disadvantages: 1. Gnt allows for flexibility in the client server split. Callbacks can be defined as either client side or server (PostScript) only). 2. Gnt supports incremental downloading of windows to the server. Using Devguide's project organization, gnt only downloads interface files which contain open windows. When a new window is requested gnt checks to see if the interface has been downloaded and if required, downloads the interface (including all internationalization). 3. Gnt supports subclassing of OPEN LOOK objects. To replace a menu with a pie shaped menu, turn on subclassing, define the pie shaped menu subclass, and gnt automatically utilizes the new subclass. 4. Gnt assists the developer by minimizing the modifications which have to be made when the interface changes. The user interface which is downloaded to the server consists of three separate files, of which only one is changed when the interface is modified. The other two files define subclassing and initialization routines and therefore do not need to be changed. 5. Gnt provides control areas in "border bags" which allow text or graphics panes to resize both vertically and horizontally. 6. Gnt computes the layout of control objects so that the objects can move logically upon resize of the window. This scheme also allows for string substitution for easy internationalization/localization. For more technical information on each of the code genertors please refer to the OpenWindows Developer's Guide 3.0 User's Guide and the appendices for each of the toolkit code generators that is included with the beta software.