Code Generation Options dialog

This dialog lets you control where, and whether, the code for links is generated, specify the application class name and control where individual resource types should be generated. These are dealt with separately below.

Application Class Name

The application class name is used to identify resource settings when you generate an Xresource file. Assigning a name other than the default "XApplication" prevents confusion of your resource values with system-wide X resources.

Links Code Generation

Using the option menu labelled "Links", you can choose whether the links are generated into the primary source file, into the stubs file or not generated at all. Alternatively, you could choose to generate the links code declarations only.

The code created as part of the links functionality consists of a set of generic functions (one for each of the four types of link) and the declarations of these functions. Because the functions are always the same, you only need to generate one set of the functions for your whole application. If you are generating code from more than one design, each of which contains links, you only need to generate the functions once but you will need to generate the declarations for each design. The declarations are always generated into the primary source file.

Default Storage

By default, X-Designer generates each widget as a variable local to the function in which it is created. If you name a widget, however, X-Designer makes the variable global. This default behavior, for named widgets, can be controlled in the Code Options dialog, by changing the "Default storage" option menu.

If a widget belongs to a class (i.e. is the child of a widget which has been made a class), however, it will remain a variable of that class, regardless of the storage option chosen in the Code Options dialog.

The default storage for named widgets is "global". You can change this default by setting the following resource:

XDesigner.defaultStorageType: static

The possible values of this resource are:

default
global
static

Comment Preludes

This option menu refers to the special comments which appear in the generated code around the areas where preludes can be added. You can choose whether you wish comments to be added "Always" (whether a prelude has been specified or not), "When Defined" (i.e. only when a prelude has been specified) or "Never". The default is "Never".

The example below shows a comment for a shell pre-manage prelude. Because there is no prelude inside the comment we must assume that "Always" was the selected option:


	/* XDesigner: prelude for shell1: pre-manage >>> */

	/* <<< pre-manage ends. */
	XtSetArg(al[ac], XmNallowShellResize, TRUE); ac++;
	shell1 = XmCreateDialogShell ( parent, "shell1", al, ac );
	ac = 0;
	/* XDesigner: prelude for form1: pre-create >>> */

	/* <<< pre-create ends. */
	XtSetArg(al[ac], XmNautoUnmanage, FALSE); ac++;
	form1 = XmCreateForm ( shell1, "form1", al, ac );

Motif Flavor

For reasons of backwards compatability, or because a target platform does not support the Motif 2.1 toolkit, it is possible to generate code for either Motif 1.2 or Motif 2.1 variants of the toolkit.

If the flavor is set to Motif 1.2, any Motif 2.1 specific resource is ignored in the code generation, and any Motif 2.1 specific widget classes are mapped backwards onto reasonable alternatives.

If the flavor is set to Motif 2.1, all Motif 2.1 specific resources will be generated, and where possible deprecated Motif 1.2 code will be replaced with newer variants.

The preferred Motif flavor is saved with the design.

Control of Resources

The panel in the middle of the Options dialog contains references to each type of resource.

Motif defines the following resource types:

You can specify into which file each resource type should be generated. If a resource is generated into the source code it is then hard-coded and cannot be modified through the resource file. Typically, any resources which are not generated into the source code are generated into the X resource file, where they can be edited by the end user.

The option menu labelled "Callbacks" differs from the others. This is only used for UIL and lets you choose whether callbacks are registered in the UIL code or the C code. By default, they are registered in the UIL. If you use client data, however, you should generate the callbacks into the C code, because structure types cannot be defined in UIL.

Masking Resources

If you look at any resource panel, you will see that it contains unlabeled toggles next to each resource.

These work in combination with the "Mask widget resources" and "Mask only global resources" radio buttons in the Generate Options dialog. Using all these gives you control over the generation of resources on an individual basis.

Mask Widget Resources

The following description applies when the "Mask widget resources" is set:

If an individual resource does not have its resource panel toggle set, the resource is generated according to the option menu for its type in the Generate Dialog - i.e. a Label string with the resource panel toggle off will be generated to the file specified by the option menu labelled "Strings".

If an individual resource does have its resource panel toggle set, the resource is generated to the opposite file from the one specified for its type by the option menu in the Generate dialog - i.e. an integer resource with the resource panel toggle on will be generated to the resource file if the "Integers" option menu is set to "Code" and to the code file if the option menu is set to "Resource file".

Mask Only Global Resources

The following description applies when the "Mask only global resources" is set:

The option menus in the Generate dialog now apply only to global objects (font, color and pixmap objects). These (and only these) are controlled exactly as discussed for all resources in the Mask Widget Resources section above.

All other resources are controlled only by their individual resource panel toggles. They are generated into the code file if the resource panel toggle is off and into the resource file if the resource panel toggle is on.

Windows Mode

In Windows mode an additional two toggles are visible and relate to the Windows MFC code generation. These are:

  1. Generate as Resources

    This option generates the windows components into a resource file readable by Visual C++. Through the use of resource templates we can now create real dialog based applications. Manipulating the resource file on windows however means that if you re-generate you will lose any changes, so modifications to the interface are best done through X-Designer.

  2. Generate Project Files

    This toggle generates project files for use in Microsoft Visual C++. This means that you do not need to generate the project files every time you generate code for your design. The toggle is set by default.

See also: