Generate dialog

The Generate dialog is used to generate code from your design. At present, the supported generate options include C, C++ and UIL source code, XPM and UIL Pixmap files, X resource files, and Java. You can also ask for Makefiles to be generated.

In Microsoft Windows mode, you may also generate a Microsoft Windows resource file. If you have created any pixmaps, these will be automatically converted into Microsoft Windows Bitmaps or Icons (depending on whether the selected widget is a Button or Label respectively) at this time. Each one is written into a separate file using the name of the pixmap object as the filename.

The dialog has two basic sections: an output file selection area at the top of the panel, and a code generation control area at the bottom.

You can enter the name of the destination output file directly into the Selection field; or you can select a file from the file system using the Filter field, Directories and Files lists.

At the bottom of the panel is an option menu which allows you to specify the type of language which is to be generated into your output file; Simply choose the language you require. For the case of C, there is an extra toggle you can set to specify whether generated code is to be ANSI C, or older 'K and R' (Kernigan and Ritchie) C.

In Microsoft Windows mode, there is an option menu which allows you to specify the flavor of code to be generated. You may generate Motif flavour, which is the same as non-Windows mode, or Motif XP or Microsoft Windows MFC flavour.

The code generation area contains a number of toggles. These are of three basic sorts: Type toggles, which control the generation of resources according to whether they are of a given type (for example, the Strings, Fonts, Colors, Integers, and Reals toggles) ; Mask toggles, which control and modify the meaning of the Type toggles ; Lastly, Compilation and Test Support toggles (for example, the Includes, Main program, and Link toggles): these may not be needed by your application, but are provided for rapid prototyping and testing of your designs.

You can control exactly which of the resources that may have been set for any widget are to be generated into your output file using the Type toggles. Simply decide which types of resources are to be coded into the output file, and which are not. These toggles therefore set up a general rule: all resources of a particular type are to be generated, or not.

The Mask Widget Resources toggle, and the Mask Only Global Resources toggle refine the process. Although in principle you may have decided, for example, that all Fonts are to be hard coded into your C output file, you might want to override this general rule in the case of some individual widgets.

In order to do this, you must have marked the individual resources on the relevant widgets as deserving special treatment. Each resource in every resource panel has a toggle just for this purpose. For example, in the Label Resource panel, there is a column of these toggles right down the center of the Display page.

The Mask Widget Resources toggle causes a resource to be generated if EITHER you have specified in the Generate dialog that resources of the given Type are to be generated, OR you have marked the individual resource for a given widget in the relevant widget resource panel, BUT NOT BOTH.

The Mask Only Global Resources toggle disables the Type toggles: ONLY resources which have been explicitly marked in the various resource panels will be generated into your output file.

By default, the Type toggle settings for generating an X resource file are the inverse of those used for generating a code file: this will ensure that a matching pair of files is produced, and any given resource will exist either hard coded into your source, or will be in the X resource file.

The Include toggle can be turned off if you intend to embed the generated source into a larger module which already contains the correct header file specifications. With the toggle on, X-Designer will work out exactly which header files are needed to compile the generated source, and generate code accordingly.

X-Designer can generate a main procedure for you, or you can provide the main procedure yourself. A hand-written main procedure would be required, for example, if there are initialization tasks not associated with the user interface, such as opening a database.

The Links and Link functions toggles are basically provided for rapid prototyping purposes: the Links toggle will cause code to be generated so that any link events you have specified in X-Designer will also be raised in your compiled application. The Links functions toggle will result in actual link function generation, as opposed to generating simple external declarations for the functions (which you must either provide yourself, or have X-Designer generate them in some other module).

The X Application Class name can be specified in the field provided: the default is 'XApplication'. The Application class name is used in generating source and X resource output, and controls how and which resources are loaded for your application at run time: refer to your OSF/Motif Programming Manual for more information concerning X resources.

The Type declarations field allows you to specify the name of any file which contains specifications or declarations for any user-defined types you have used in your design (for example, pointers to structures which have been used as parameters to callbacks, or again private or external data declared as User Data for a widget). For C, this will result in a simple #include statement for the file near the top of the generated code, underneath any #include statements which X-Designer has been asked to automatically generate.

Pixmap data and associated declarations can be imported from other files rather than generated inline. These files can be created within X-Designer using the Pixmaps and Externs generate options; you can import such a file using the Pixmap file field.

It is also possible to specify a particular flavor of Motif; the default is to generate Motif 2.1 code, but if code is required for a Motif 1.2 platform, appropriately mapped code will be generated on request.

X-Designer can also generate Makefiles for you. There are two kinds of Makefile generation: simple, and with templates. The simple method only takes the current design into account, and the Template method can merge make rules for the current design into any previous template rules. X-Designer uses information supplied to the Generate dialog when generating source - the name of the output file, C externs file, stubs files, whether you are generating a main procedure, etc - in order to deduce the make rules required. Set the 'Makefile template' toggle if you want to generate a template; you can set the 'New Makefile' toggle as well if you do not want to merge rules from previous designs into the current template. A number of targets are supplied - for example, all (to build everything), depend (X-Designer does not generate a dependency graph; this target will call the makedepend utility), and clean (to remove intermediate and final objects produced by the build.

By default, the Makefiles contain generated rules for all the various languages you may have generated code for. That is, if you generate C code followed by C++, rules for building both applications in each of the languages will be generated to the Makefile. If you only want to have rules for a specific language in the Makefile, perhaps because you are prototyping or just trying out the various generation options, select the "current language only" toggle: the generated Makefile will only contain rules for the currently visible language page, and not those for any sources generated from hidden language pages. If the "current language only" toggle is off, you will be warned if your Makefile is to contain mixed language rules.

NOTES

When generating 'Stubs', X-Designer creates a function prototype for callbacks within your design, which you can use as the basis for writing the rest of your application code. The Stubs file will also contain generated prototypes for all the other X procedures registered in the design: event handlers, work procedures, and so forth.

The 'Externs' options cause X-Designer to generate external declarations for all global interface data within the design: for example, widgets declared of global scope (using the Core Resources panel), global pixmap data, and any functions which X-Designer generates (example: shell creation procedures). You can use this as the basis of an interface module header file.

See also: