Motif provides widget writers with several dozen convenience routines known collectively as the Xme functions. Motif provides these to simplify widget writing. Widget writers should use these Xme functions whenever possible.
The Xme routines perform the following kinds of widget-writing services:
Render Motif-style geometric objects
Implement resolution independence
Implement data transfer between and within widgets
Handle traits
Handle other miscellaneous services pertaining to widget writing
This chapter provides an overview of the Xme functions. Chapter 17 contains reference documentation for each Xme function.
Xme functions were not available in releases of Motif prior to Release 2.0. Prior to Release 2.0, Motif provided several dozen undocumented _Xm routines for widget writers and for internal use. Motif strongly recommends that you not use any of these _Xm routines in your widgets.
Many of the _Xm routines have Xme equivalents. For example, _XmClearBorder is equivalent to XmeClearBorder . To help users make the transition from _Xm routines to Xme routines, the Motif Release 2.0 XmP.h header file contains #define statements that convert some of the old _Xm calls into their new Xme equivalents. Thus, if your code calls any of the _Xm routines listed in these #define statements, and you compile against the Release 2.0 header files, the C preprocessor will automatically convert the _Xm calls to the proper Xme calls. However, Motif does not guarantee that these #define statements will continue to be available in future releases.
The Xme functions are bound into the standard Motif library (typically stored in file libXm.a). Therefore, you do not need to bind your widget with any special libraries in order to call an Xme function. Similarly, you do not need a Motif source license in order to call an Xme function.
You call an Xme function just as you would call any Xm convenience function. That is, you must include the appropriate header file, and you must provide the correct type and number of arguments to the call. The reference pages in Chapter 17 detail the required information for each Xme function.
Motif provides two Xme functions for handling traits. These functions are summarized in Table 8-1. See Chapter 5 for details on traits.
Table 8-1. Xme Trait Functions
Xme Function | What It Does: |
XmeTraitGet | Returns the trait record associated with a given object |
XmeTraitSet | Installs a trait on a specified widget class |
Motif provides several Xme functions for rendering geometric objects (arrows, diamonds, and so on). Whenever possible, your Motif widgets should render geometric objects with these Xme routines. By using the Xme functions, you are ensuring that the geometric objects in your Motif widget will look like the geometric objects in other Motif widgets.
Table 8-2 lists the Xme functions pertaining to drawing.
Table 8-2. Xme Drawing Functions
Xme Function | What It Does: |
XmeClearBorder | Clears any rectangular area (such as a widget border) |
XmeDrawArrow | Draws a Motif-style, three-dimensional arrow |
XmeDrawCircle | Draws a Motif-style, three-dimensional circle |
XmeDrawDiamond | Draws a Motif-style, three-dimensional diamond |
XmeDrawHighlight | Draws a Motif-style highlight around a widget's border |
XmeDrawIndicator | Draws a Motif-style cross or check mark |
XmeDrawPolygonShadow | Draws a Motif-style, three-dimensional shadow around a polygon |
XmeDrawSeparator | Draws a Motif-style, three-dimensional line to separate two visual components |
XmeDrawShadows | Draws a Motif-style, three-dimensional shadow around a rectangle |
For example, the ExmSimple widget calls the XmeDrawShadows function to draw its border shadows. In order to make this call, the Simple.c file includes the header file for the Xme drawing functions as follows:
#include <Xm/DrawP.h> |
The call to XmeDrawShadows appears as follows:
XmeDrawShadows (XtDisplay (sw), XtWindow (sw), sw->primitive.top_shadow_GC, sw->primitive.bottom_shadow_GC, sw->primitive.highlight_thickness, sw->primitive.highlight_thickness, sw->core.width - (2 * sw->primitive.highlight_thickness), sw->core.height - (2 * sw->primitive.highlight_thickness), sw->primitive.shadow_thickness, XmSHADOW_ETCHED_OUT); |
Most Motif widgets inherit routines to draw and erase window decorations. However, if your widget takes the responsibility for its own window decorations, then your widget will draw the decorations with XmeDrawHighlight and XmeDrawShadows and clear the decorations with XmeClearBorders. Actually, the XmeClearBorders call can be used to clear out any rectangular area, not just window decorations.
If you want to draw shadows around any polygon (instead of just a rectangle), call XmeDrawPolygonShadows instead of XmeDrawShadows.
XmeDrawDiamond, XmeDrawCircle, and XmeDrawIndicator are particularly useful for creating toggle indicators.
Motif provides four Xme functions that govern resolution independence. (See Chapter 6 for information about resolution independence.)
The four functions shown in Table 8-3 are typically called from a synthetic resource table rather than from a widget method.
Table 8-3. Xme Resolution Independence Functions
Xme Function | What It Does: |
XmeFromHorizontalPixels | Converts from pixels to real-world dimensions based on horizontal resolution of the screen |
XmeFromVerticalPixels | Converts from pixels to real-world dimensions based on vertical resolution of the screen |
XmeToHorizontalPixels | Converts from real-world dimensions to pixels based on horizontal resolution of the screen |
XmeToVerticalPixels | Converts from real-world dimensions to pixels based on vertical resolution of the screen |
Table 8-4 contains a list of Xme functions that are useful for manipulating strings.
Table 8-4. Xme String Functions
Xme Function | What It Does: |
XmeGetDefaultRenderTable | Returns the default render table associated with a specified widget |
XmeGetDirection | A compound string parse procedure ( XmParseProc) to insert a direction component |
XmeGetLocalizedString | Returns a localized version of the input string |
XmeGetNextCharacter | A compound string parse procedure ( XmParseProc) to insert a character |
XmeNamesAreEqual | Compares two strings for equality |
XmeRenderTableGetDefaultFont | Gets information on the default font associated with a specified render table |
See Chapter 9 for complete details on using these functions.
Motif provides widget writers with several Xme functions for implementing the Uniform Transfer Model (UTM). UTM is a mechanism for transferring data between and within widgets. UTM was introduced in Motif Release 2.0. (See Chapter 10 for details.)
Table 8-5 summarizes the Xme functions useful for transferring data between and within widgets.
Table 8-5. Xme Data Transfer Functions
Xme Function | What It Does: |
XmeClipboardSink | Transfers data from the clipboard to a widget |
XmeClipboardSource | Places data on the clipboard |
XmeConvertMerge | Merges data converted during a transfer operation |
XmeDragSource | Starts a drag and drop operation |
XmeDropSink | Establishes a widget as a drop site |
XmeGetLocaleAtom | Returns the encoding of the locale |
XmeGetTextualDragIcon | Returns an icon widget symbolizing a textual drag operation in progress |
XmeNamedSink | Transfers data from the named selection to a widget |
XmeNamedSource | Takes ownership of a named selection |
XmePrimarySink | Transfers data from the primary selection to a widget |
XmePrimarySource | Takes ownership of the primary selection |
XmeSecondarySink | Establishes a widget as the destination for secondary transfer |
XmeSecondarySource | Takes ownership of the secondary selection |
XmeSecondaryTransfer | Transfers data from the secondary selection to the destination widget |
XmeStandardConvert | Converts selections to standard targets |
XmeStandardTargets | Returns a list of standard Motif targets |
XmeTransferAddDoneProc | Establishes a procedure to be called when data transfer is complete |
In addition to the list of Xme routines shown in the previous table, Motif provides many Xm data transfer routines. The Xm routines are detailed in the Motif Programmer's Reference.
Motif provides the Xme calls shown in Table 8-6 to help widget writers manage geometry:
Table 8-6. Xme Geometry Functions
Xme Function | What It Does: |
XmeConfigureObject | Changes a child's position, size, or border width |
XmeRedisplayGadgets | Redisplays all the gadget children of a manager |
XmeReplyToQueryGeometry | Handles standard geometry requests |
See Chapter 12 for examples involving these functions.
Motif provides the Xme calls shown in Table 8-7 to help widget writers handle focus changes.
Table 8-7. Xme Focus Functions
Xme Function | What It Does: |
XmeAddFocusChangeCallback | Registers a callback for focus changes |
XmeNavigChangeManaged | Helps a change_managed method establish the correct keyboard traversal policy |
XmeRemoveFocusChangeCallback | Removes a focus change callback |
Motif also provides the Xme functions shown in Table 8-8.
Table 8-8. Xme Miscellaneous Functions
Xme Function | What It Does: |
XmeCreateClassDialog | Creates a dialog shell containing the specified widget |
XmeGetDefaultPixel | Finds a color associated with the given widget |
XmeGetNullCursor | Returns the null cursor associated with a given display |
XmeGetPixmapData | Returns details about a cached pixmap |
XmeMicroSleep | Suspends execution for a specified number of microseconds |
XmeGetHomeDirName | Returns the pathname of the user's home directory |
XmeQueryBestCursorSize | Finds the best cursor size |
XmeResolvePartOffsets | Allows writing of binary-compatible applications and widgets |
XmeSetWMShellTitle | A compound string function that updates the window manager title |
XmeVirtualToActualKeysyms | Finds the physical keysyms associated with a given virtual keysym |
XmeWarning | Writes a warning message to the standard error stream |