With the introduction of Motif 2.0, the Open Software Foundation, now The Open Group, cleaned up the APIs. Most of the public (that is, intended for application use) API was left as it was, but the private (needed by Widget writers) was completely changed. Before 2.0, there were two types of symbols, public (prefixed by Xm), and private (prefixed by _Xm). Motif 2.0 introduced a new type, (prefixed by Xme), and renamed most of the _Xm symbols to be Xme. There are still some _Xm symbols, but these are internal to the library and are not guaranteed to be exported.
Some symbols (EditDone, EditError, EditReject, XmTextStatus) have been moved from a private header file (Xm/TextStrsoP.h) to a public one (Xm/Xm.h). This can cause some problems with applications and libraries which use those symbols themselves. In these cases, there is a namespace conflict at compile time due to redefinition. The problem can be acute because some of these symbols do not have a Xm prefix.
Because these symbols can break existing applications, they have been moved back to their old, private locations as the default. To get the standard OSF behavior (with these symbols in the public header file), define _SGI_OSF_PUBLIC_SYMBOLS before any Motif header file is included.
The Table 2-1 lists symbols that were in Motif 1.2 but are not in 2.1, along with any replacement.
Table 2-1. OSF Obsoleted Symbols
Motif 1.2 Symbol | Motif 2.1 Symbol |
---|---|
| |
XmGetColors()[a] | |
_XmDrawShadows() | |
| |
[a] API has changed. |
Motif 2.x makes use of the Xpm library for colored pixmaps (implemented internally to the library). ViewKit 1.2 distributed its own copy of this library as well. Silicon Graphics has consolidated this and now ships a standalone copy of libXpm.so as part of the Motif 2.1 images. Documentation, in the form of the original PostScript report and examples, may be found in /usr/share/src/X/motif-2.1/xpm.
With IRIX 6.5, Silicon Graphics moved the Motif archive libraries (that is, libXm.a) out of the default installation images. With Motif 2.1, archive libraries are no longer shipped; all the required libraries are shipped as shared objects (DSOs) in the standard execution environment.
Considerable effort has been made toward tidying up the various Silicon Graphics APIs. Some symbols have been renamed to better highlight which APIs have been added by Silicon Graphics. In the past, some of these symbols were mistakenly prefixed with Xm. These have now been renamed to have a prefix of Sg. Table 2-2 lists these symbols.
To help in porting older code that may have used these APIs, the old symbol names can be activated by defining _SGIMOTIF_OBSOLETE_API before any Motif header file is included. By default, this flag is not enabled.
Table 2-2. New Names for Silicon Graphics Symbols
Silicon Graphics Motif 1.2 Symbol | Silicon Graphics Motif 2.1 Symbol |
---|---|
Table 2-3 lists three basic #define statements used in the various libraries and applications. They are listed here primarily for information value. The only one that can be turned off is _SGIMOTIFAPI. _SGIMOTIF and _SGIBUGFIX should never be turned off.
Table 2-3. Silicon Graphics #define Statements
Statement | Effect |
---|---|
All Silicon Graphics look and feel changes. This should not be turned off at application compile time, because internal structures will be incorrectly sized. NOTE: If _SGIMOTIF is defined, the application should be able to count on the full Silicon Graphics look and feel (that is, Schemes/desktop integration, and so forth). However, because this has not been fully tested, be cautious in making this assumption. | |
A change that has either been sent to TOG for inclusion into the standard source base, or a change that is required for the Silicon Graphics build environment that is not directly related to the look and feel. This is also something that should not be touched by an application. | |
Wraps extensions to the Motif API. This can be turned off by an application program by using the following statement before any Motif headers are included: #define _NO_SGIMOTIFAPI Note: Using the #undefine statement with _SGIMOTIFAPI does not work. |
To further help in porting, Silicon Graphics has added a new resource SgNshowVersion (type Boolean). If SgNshowVersion is True (the default is False), a message will be printed out to stdout indicating that the application is linking against Motif version 2.1 library. The following message will be printed out:
SGI Irix Indigo Magic 2.1, based on OSF/Motif 2.1.10 |
For a quick introduction to the new widgets, compile and run either sampler2_0 demo (in /usr/share/src/X/motif-2.1/osf_demos/programs/sampler2_0) or periodic (in /usr/share/src/X/motif-2.1/osf_demos/programs/periodic). Each shows the new widgets, and how they can be used. (Sampler2_0 is probably preferable, because it is straight C code, rather than a mix of C and UIL.)
The following sections give a brief overview of the new widgets:
The Notebook is the Motif version of a tabbed-dialog (in Windows terms) widget. It is a generic solution, where any widget that holds the XmQactivatable trait can be used as the button. Currently, XmPushButton, XmDrawnButton, XmArrowButton, XmPushButtonGadget, and XmArrowButtonGadget hold this trait.
The container is a layout widget suitable for use as an outliner (where it is possible to expand or contract individual items). It may also be used as a base on which to place icons that can then be dragged around.
The file /usr/share/src/X/motif-2.1/osf_demos/programs/sampler2_0 shows an example of how to use this widget.
The following sections briefly describe changes to existing widgets.
IRIX 6.2 (and later) allow an application to use vertical writing (for use by Asian languages). This is set with the XmNlayoutDirection resource.
The code fragments in Example 2-1 illustrate the use of these widgets. Figure A-2 (in Appendix A) shows the resulting dialog box.
/* vertical text widget */ vert = XtVaCreateManagedWidget(“vertical”,xmTextWidgetClass,form, XmNtopAttachment, XmATTACH FORM, XmNleftAttachment, XmATTACH FORM, XmNbottomAttachment, XmATTACH FORM, XmNlayoutDirection, XmTOP TO BOTTOM, XmNrows, 10, NULL); /* horizontal text widget */ horiz = XtVaCreateManagedWidget(“horizontal”,xmTextWidgetClass,form, XmNtopAttachment, XmATTACH FORM, XmNleftAttachment, XmATTACH WIDGET, XmNleftWidget, vert, XmNrightAttachment, XmATTACH FORM, NULL); |