Widgets in Cross-Platform Programs

IDL's user interface toolkit is designed to provide a "native" look and feel to widget-based IDL applications. Where possible, widget toolkit elements are built around the operating system's native dialogs and controls; as a result, there are instances where the toolkit behaves differently from operating system to operating system. This section describes a number of platform-dependencies in the IDL widget toolkit. Consult the descriptions of the individual DIALOG and WIDGET routines in the IDL Reference Guide for complete details.

Dialog Routines

IDL's DIALOG_ routines (DIALOG_PICKFILE, etc.) rely on operating system native dialogs for most of their functionality. This means, for example, that when you use DIALOG_PICKFILE in an IDL application, Windows users will see the Windows-native file selection dialog and Motif users will see the Motif file selection dialog. Consult the descriptions of the individual DIALOG routines in the IDL Reference Guide for notes on the platform dependencies.

Base Widgets

Base widgets (created with the WIDGET_BASE routine) play an especially important role in creating widget-based IDL applications because their behavior controls the way the application and its components are iconized, layered, and destroyed. See Iconizing, Layering, and Destroying Groups of Top-Level Bases under "WIDGET_BASE" (IDL Reference Guide) for details about the platform-dependent behavior.

Positioning Widgets within a Base Widget

The widget geometry management keywords to the WIDGET_BASE routine allow a great deal of flexibility in positioning child widgets within a base widget. When building cross-platform applications, however, making use of IDL's explicit positioning features can be counterproductive.

Because IDL attempts to provide a platform-native look on each platform, widgets depend on the platform's current settings for font, font size, and "window dressing" (things like the thickness of borders and three-dimensional appearance of controls). As a result of the platform-specific appearance of each widget, attempting to position individual widgets manually within a base will seldom give satisfactory results on all platforms.

Instead, insert widgets inside base widgets that have the ROW or COLUMN keywords set, and let IDL determine the correct geometry for the current platform automatically. You can gain a finer degree of control over the layout by placing groups of widgets within sub-base widgets (that is, base widgets that are the children of other base widgets). This allows you to control the column or row layout of small groups of widgets within the larger base widget.

In particular, refrain from using the X/YSIZE and X/YOFFSET keywords in cross-platform applications. Using the COLUMN and ROW keywords instead will cause IDL to calculate the proper (platform-specific) size for the base widget based on the size and layout of the child widgets.

Fonts Used in Widget Applications

You can specify the font used in a widget via the FONT keyword. In general, the default fonts used by IDL widgets will most closely approximate the look of a platform-native application. If you choose to specify the fonts used in your widget application, however, note that the different platforms have different font-naming schemes for device fonts. While device fonts will provide the best performance for your application, specifying device fonts for your widgets requires that you write platform-dependent code as described in Which Operating System is Running?. You can avoid the need for platform-dependent code by using the TrueType fonts supplied with IDL; there may be a performance penalty when the fonts are initially rendered. See Fonts (IDL Reference Guide) for details.

Motif Resources

Use the RESOURCE_NAME keyword to apply standard X Window System resources to a widget on a Motif system. Resources specified via the RESOURCE_NAME keyword will be quietly ignored on Windows systems. See RESOURCE_NAME under "WIDGET_BASE" (IDL Reference Guide) for details. In general, you should not expect to be able to duplicate the level of control available via X Window System resources on other platforms.

WIDGET_STUB

On Motif platforms, you can use the WIDGET_STUB routine to include widgets created outside IDL (that is, with the Motif widget toolkit) in your IDL applications. The WIDGET_STUB mechanism is only available under Unix, and is thus not suitable for use in cross-platform applications that will run under Microsoft Windows. WIDGET_STUB is described in the External Development Guide.

Widget Event Inconsistencies

Different windowing systems provide different types of events when graphical items are displayed and manipulated. IDL attempts to provide consistent functionality on all windowing systems, but is not always completely successful. For example, enter/exit tracking events are not generated by some windowing systems. IDL attempts to provide appropriate enter/exit events, but behaviors may differ on different platforms.

Handle individual widget events carefully, and be sure to test your code on all platforms supported by your application.