# Widget Edit Dialog

The widget edit dialog is used to describe a particular widget class. The fields are:-

Include file:

The file which you would include in a program which uses the widget class, for instance . This must normally be specified.

Defined name function:

WorkShop Visual has to convert internal resource names back to symbolic names which are usually defined in the header file with #define. For instance, it has to convert the internal name "foreground" to the symbol "XtNforeground". By default, it does this by adding the prefix "XtN" to the internal name, but this does not always work. For instance, the Athena clock widget has a resource "hands" whose symbolic name is "XtNhand". The defined name function allows you to override WorkShop Visual's default name conversion where needed. This need not normally be specified. If you need it, and have not specified it, compiling code generated by WorkShop Visual will fail, complaining that "XtN is undefined". See the XDconfig User Manual for an example.

Can add child function:

Each widget icon in the WorkShop Visual widget palette is enabled only if the widget is a permissible child of the currently selected widget in the widget hierarchy. For the Motif widgets, knowledge of the children which can be accepted by various parents is built into WorkShop Visual. WorkShop Visual can provide some of this functionality for user-defined widgets (for instance, it will not allow you to add a child to a primitive widget), but there are some restrictions which WorkShop Visual cannot determine (for instance, a menu bar will only accept cascade button children). The can add child function is used to provide this information for user-defined widgets. This need not be specified. However, it may be needed to prevent creation of invalid widget hierarchies which may cause failures in WorkShop Visual or in the code generated by WorkShop Visual. See the XDconfig User Manual for an example.

Appropriate parent function:

The appropriate parent function is the converse of the can add child function. It is used to disable the icon in the widget palette if the currently selected widget in the widget hierarchy is not a suitable parent for this user-defined widget. This need not be specified. However, it may be needed to prevent creation of invalid widget hierarchies which may cause failures in WorkShop Visual or in the code generated by WorkShop Visual. See the XDconfig User Manual for an example.

Realize function:

When you click on an icon in the widget palette, WorkShop Visual creates and realizes a widget of the appropriate type. WorkShop Visual does not normally set any resource values when it creates the widget, but accepts the toolkit defaults. Sometimes this can cause problems. For instance, some container widgets are, by default, created with zero width and height, which will cause X to complain. The realize function allows you to specify a function which is called before the widget is realized, typically to do initialization. This function is only called when a widget is created within WorkShop Visual. If the same initialization is required in the generated code, it should be added as a code prelude. This is often not necessary. Problems with containers occur because WorkShop Visual realizes them before they have any children. In the generated code, the children will be added before realization, forcing the width and height to a non-zero value and eliminating the complaints from X. The realize function is not normally required. See the XDconfig User Manual for an example.

Icons:

The icons are bitmaps used by WorkShop Visual to represent the widget in the widget palette and the widget hierarchy. The small icon (20by20 pixels) is used on VGA resolution screens (that is, when visu.smallscreen is true) and the large icon (32 by 32 pixels) on workstation-type screens. If no small icon is specified, the large one will always be used. If no icons are specified, WorkShop Visual will use a button with the widget class name on it in the palette, and a box with a cross in the hierarchy. For each of the two icons, you should specify the include file where it is defined (eg X11/bitmaps/woman) and the name used in that file. The first line of a bitmap definition is usually

#define _width 32

In our example, the bitmap in the file /usr/openwin/include/bitmaps/woman is 'sorceress'. You should normally specify at least the large icon. You can create an icon using the X utility 'bitmap' (and others).

Disable foreground swapping:

When a widget is selected in the hierarchy, WorkShop Visual normally swaps the foreground and background colors, so that the widget highlights in the design window. WorkShop Visual only does this if the widget has a foreground resource. Some widgets with foreground resources (notably the OLIT widgets) cannot handle a change of the resource value after the widget has been managed. When you select such a widget in the hierarchy, WorkShop Visual will fail when it attempts to swap the foreground and background. Setting this toggle will disable the swapping of foregrounds and background, and so prevent the failure. It should not normally be set.

Can create widgets:

If this toggle is set (the default) there will be an icon for the user-defined widget in the WorkShop Visual icon palette, and it will be possible for the user to create instances of this widget class in WorkShop Visual. If the toggle is reset, there will be no icon in the palette and the user will not be able to instantiate this widget class. However, a resource panel for the class will still be generated, and any user-defined widgets which are subclasses of this widget class will use that resource panel to set inherited resources. This is normally only used when a hierarchy of user-defined widget classes is being added, and you want the resources of an abstract class in the hierarchy to be treated in a way similar to WorkShop Visual's treatment of Core resources.

See also: