Goals for this chapter:
|
rpm packages covered in this chapter:
|
|
|
|
Like a "Chef" select the ingredients to create a particular food, in the same mode, you need to "cook" the graphical application selecting the containers, the display widgets, fixing colors, fonts and other resources.
From a mask or dialog written on "paper" we can create "beautiful" applications.
Motif widget may classified as follows:
Therefore formerly Display Widgets are:| XmArrowButton
XmList XmSeparator XmScale |
XmDrawButton
XmPushButton XmText XmCascadeButton |
XmLabel
XmScrollBar XmToggleButton XmTextField |
![]() |
![]() |
![]() |
![]() |
![]() |
| The ArrowButton
Check: arrow.c |
The List
Check: list.c |
The drawbutton
Check: drawn.c |
The PushButton
Check: hello.c |
The Label and Text
Check: formedit.c |
Other widget may be visualized in Periodic Motif Widget table.
The Motif Container Widgets are:
| XmDrawingArea
XmRowColumn XmPanedWindow |
XmFrame
XmForm XmBulletinBoard |
XmMainWindow
XmScrolledWindow |
The following application uses a form and a RowColumn widget to set the layout.

Motif offers a complete set of dialog. A dialog is a widget that support User interaction.
This may be a simple button (like a message to inform the user), a triple
button like "OK, Cancel, Help" to request a user decision, or more complex
dialog where the user.
| BulletingBoardDialog
MessageDialog SelectDialog FormDialog |
ErrorDialog
PromptDialog WarningDialog InformationDialog |
FileSelectionDialog
QuestionDialog WorkingDialog |
We present here two common dialogs:
![]() |
![]() |
Motif supports also Menus. Netscape is a classical example about Motif
programming. There are basically three menu types:
| XmCreatePopupMenu | XmCreatePulldownMenu | XmCreateOptionMenu |
We present here an example with menus and cascade menu (submenus).

Motif support also Gadgets. Gadget are no Widget, but a different graphical
object. Gadget are nearly the same as widget, except that they have no
windows of their own.
| XmArrowButtonGadget
XmSeparatorGadget |
XmPushButtonGadget
XmCascadeButtonGadget |
XmLabelGadget
XmToggleButtonGadget |
Gadget requerie less memory, than the widget and are used in some cases.
Graphically Gadget are widget are the same, declarations are different,
as we can note from the previous table.
We present here two important generation of Motif 1.2 and 2.2. I work with Motif 1.0, in 1989, and with Motif 1.1 in 1991. Only in 1998 was released Motif 1.2. Then was 2.0, 2.1 and 2.2 in Feb 2002.
There are planned released of Motif 2.3 and 3.0 on MotifZone.org.
We note in these programs combobox, menus, pushbutton ... and in Motif
2.2 also the Notebook widget.
|
|
![]() |
| Periodic table for OSF/Motif 2.2
|
![]() |
The latest OpenMotif version is 2.2.1, offers the following release.
[root@ftosx1 openMotif-2.2.1]# ls -F
acinclude.m4 CLOSEDBUGS
config.sub* Imakefile
libtool* Makefile.imake-pure RELEASE
aclocal.m4 config/
configure* include/
LICENSE Makefile.in
RELNOTES
bindings/ config.cache
configure.in INSTALL.configure localized/
missing*
themes/
bitmaps/ config.guess*
COPYRIGHT.MOTIF INSTALL.imake ltmain.sh
mkinstalldirs* tools/
BUGREPORT config.log
demos/ install-sh*
Makefile OPENBUGS
xmthemes/
clients/ config.status*
doc/
lib/
Makefile.am README
[root@ftosx1 openMotif-2.2.1]#
The Motif three moves from "make world" based on a "xmkmf" approach to a "configure" GNU approach.
Motif is excellent ... but it closed behaviour probably will sign Motif for ever. Is clear that efforts must be payed, and Motif is a great effort, incredible. New customers and programmers suppose that Motif is "another" window manager or another GUI. No, Motif is the standard development toolkit and CDE it GUI.
As we tell before, probably the years that Motif was closed, not public, delay the final release and development to choose a Graphical GUI. The Troll Qt was available under payment for MS Windows/UNIX, but free for X 11 Development, if the developed source will continue to be free.
Request money for great software, is obvious, but sometimes may destroy completely the excellent effort. Actually the latest update on Motif Themes that was introduced with Qt
This is a clear example because OpenSource is probably the 'only' mode for software sucess. Another two components are clear: Innovation and Quality. Is also important to fix clear rules without to re-invent the wheel. NeXT is another of this examples of expensive software without results.
Motif 2.2.1, presents the following hierarchy:
[root@ftosx1 root]# cd openMotif-2.2.1/
[root@ftosx1 openMotif-2.2.1]# ls -F
acinclude.m4 BUGREPORT config.cache
config.sub* demos/
INSTALL.configure libtool* Makefile
missing* RELEASE
xmthemes/
aclocal.m4 clients/ config.guess*
configure* doc/
INSTALL.imake LICENSE
Makefile.am mkinstalldirs*
RELNOTES
bindings/ CLOSEDBUGS config.log
configure.in Imakefile install-sh*
localized/ Makefile.imake-pure OPENBUGS
themes/
bitmaps/ config/
config.status* COPYRIGHT.MOTIF include/ lib/
ltmain.sh Makefile.in
README tools/
[root@ftosx1 openMotif-2.2.1]#
Basically, Motif 2.2.1, is an updated version of the 2.1. The Motif version 2.1, was the major update in ten years.
Motif source tree includes three important components:

These programs are located in

Motif supports also Themes, available originally in KDE, and then in GNOME. Here, in Motif the approach to develop themes, is using the Pixmap. However, the project actually is stopped at March 2001. Here we present the Acqua Motif theme on Periodic.

Motif does not support PNG format image format. This will be supported only on Motif 2.3 (please check: http://www.openmotif.org/openmotif/?cont=timeline). Next year First Quater (Q1) 2003, is planned the release of Motif 2.4 including a support for antialias. Motif 2.5, Q3 2003, is planned to support also C++ binding.
There are basically two methods for development. One is start a project from scratch and the second is modify or update a "similar" project to get the expected result.
Here we will introduce both methods.
The first step is to setup the goal.
We will develop a program that create a Notebook, using the Motif Notebook widget.
We will write the Imakefile from the Makefile:
[root@ftosx1 scratch]# more Imakefile
SYS_LIBRARIES = -lXm -lXt -lSM -lICE -lX11
AllTarget(scratch)
NormalProgramTarget(scratch,scratch.o,,,)
[root@ftosx1 scratch]#
A motif source basically start with program description and includes files.
Therefore, on a primary analysis we will have:
[root@ftosx1 scratch]# more scratch.c
//
// Program: A simple project to use the Notebook
Widget
//
// Author: Dr. Giovanni A. Orlando
// Data: 2002-05-14
#include <Xm/Xm.h>
#include <Xm/Notebook.h>
main (int argc, char **argv)
{
Widget
toplevel, notebook;
XtAppContext app;
toplevel = XtVaOpenApplication (&app, "scratch",
NULL, 0, &argc, argv,
NULL, sessionShellWidgetClass, NULL);
// Now we create the Notebook
notebook = XmCreateNotebook (toplevel, "notebook",
NULL, 0);
// The standard functions to release the program
XtManageChild (notebook);
XtRealizeWidget (toplevel);
XtAppMainLoop (app);
}
[root@ftosx1 scratch]#
Compiling this code, we get the following result.

Now, we will add the pages, that will be displayed on the program:
In this program we will includes "fixed" data, however, the program
may be updated to display for example the processes on the local network,
the week appointment, etc.
| #include <Xm/Xm.h>
#include <Xm/Notebook.h> #include <Xm/RowColumn.h> #include <Xm/Label.h> /* Arbitrary data for the first "page" */
/* Arbitrary data for the second "page" */
/* Arbitrary data for the third "page" */
/* Arbitrary data for the fourth "page" */
/* Arbitrary data for the fifth "page" */
/* Arbitrary data for the fifth "page" */
/* A pointer to all the "page" data */
void main (int argc, char **argv)
XtSetLanguageProc (NULL, NULL, NULL);
/* Create the Notebook */
/* Create the "pages" */
for (j = 0; courses[i][j] != (char *) 0; j++) {
n = 0;
XtManageChild (notebook);
|
Compiling this second complete release we get the following figure:
|
Here are displayed all the FTLinuxCourse Complete chapters.
The previous is a modified version from an example included in Notebook chapter in Volume 6A.
The original source is the following:
[root@ftosx1 multi_font2]# more multi_font.c
/* multi_font.c -- create three compound strings using 12, 14
and 18
** point fonts. The user can specify resources so that each
of the strings
** use different fonts by setting resources similar to that
shown
** by the fallback resources.
*/
#include <Xm/Label.h>
String fallbacks[] =
{
"*.renderTable: TAG1,
TAG2, TAG3",
"*.fontType: FONT_IS_FONT",
"*TAG1.fontName:
-*-courier-*-r-*--*-120-*",
"*TAG2.fontName:
-*-courier-bold-o-*--*-140-*",
"*TAG3.fontName:
-*-courier-medium-r-*--*-180-*",
NULL
};
main (int argc, char *argv[])
{
Widget
toplevel, label;
XtAppContext app;
XmString
s1, s2, s3, text, tmp;
Arg
args[2];
String string1 =
"This is a string ",
string2 = "that contains three ",
string3 = "separate fonts.";
XtSetLanguageProc
(NULL, NULL, NULL);
toplevel = XtVaOpenApplication
(&app, "Demo", NULL, 0, &argc, argv, fallbacks,
sessionShellWidgetClass, NULL);
s1 = XmStringGenerate
((XtPointer) string1, NULL, XmCHARSET_TEXT, "TAG1");
s2 = XmStringGenerate
((XtPointer) string2, NULL, XmCHARSET_TEXT, "TAG2");
s3 = XmStringGenerate
((XtPointer) string3, NULL, XmCHARSET_TEXT, "TAG3");
/* concatenate the
3 strings on top of each other, but we can only
** do two at a time.
So do s1 and s2 onto tmp and then do s3.
*/
tmp = XmStringConcatAndFree
(s1, s2);
text = XmStringConcatAndFree
(tmp, s3);
XtSetArg (args[0],
XmNlabelString, text);
label = XmCreateLabel
(toplevel, "widget_name", args, 1);
XtManageChild (label);
XmStringFree (text);
XtRealizeWidget (toplevel);
XtAppMainLoop (app);
}
[root@ftosx1 multi_font2]#
Now, we want to remove the multiple fonts and use only one. In about three minutes we will have:
[root@ftosx1 multi_font2]# more multi_font2.c
/* multi_font.c -- create three compound strings using 12, 14
and 18
** point fonts. The user can specify resources so that each
of the strings
** use different fonts by setting resources similar to that
shown
** by the fallback resources.
*/
#include <Xm/Label.h>
#include <Xm/PushB.h>
String fallbacks[] =
{
"*.renderTable: TAG1,
TAG2, TAG3",
"*.fontType: FONT_IS_FONT",
"*TAG1.fontName:
-*-helvetica-*-r-*--*-120-*",
"*TAG2.fontName:
-*-helvetica-bold-o-*--*-140-*",
"*TAG3.fontName:
-*-helvetica-bold-r-*--*-180-*",
NULL
};
main (int argc, char *argv[])
{
Widget
toplevel, button;
XtAppContext app;
XmString
s1, s2, s3, text, tmp;
Arg
args[2];
String string1 =
"Next",
string2 = "-",
string3 = ">";
XtSetLanguageProc
(NULL, NULL, NULL);
toplevel = XtVaOpenApplication
(&app, "Demo", NULL, 0, &argc, argv, fallbacks,
sessionShellWidgetClass, NULL);
s1 = XmStringGenerate
((XtPointer) string1, NULL, XmCHARSET_TEXT, "TAG1");
s2 = XmStringGenerate
((XtPointer) string2, NULL, XmCHARSET_TEXT, "TAG2");
s3 = XmStringGenerate
((XtPointer) string3, NULL, XmCHARSET_TEXT, "TAG3");
/* concatenate the
3 strings on top of each other, but we can only
** do two at a time.
So do s1 and s2 onto tmp and then do s3.
*/
tmp = XmStringConcatAndFree (s1, s2);
text = XmStringConcatAndFree (tmp, s3);
XtSetArg (args[0], XmNlabelString, text);
//label = XmCreateLabel (toplevel, "widget_name", args, 1);
button = XmCreatePushButton
(toplevel, "button", args, 1);
XtManageChild (button);
XmStringFree (text);
XtRealizeWidget (toplevel);
XtAppMainLoop (app);
}
Note that we change the string2 and string3 and also use another sense in the tmp string construction.
We present here both sources:
![]() |
![]() |
In this case is a simplification. Changes or updates may be possible
changing variable names, variable content, etc.
Browsing the openmotif 2.2.1, we get:
[root@ftosx1 root]# cd openMotif-2.2.1/
[root@ftosx1 openMotif-2.2.1]# ls
acinclude.m4 CLOSEDBUGS config.sub
Imakefile libtool
Makefile.imake-pure RELEASE
aclocal.m4 config
configure include
LICENSE Makefile.in
RELNOTES
bindings config.cache
configure.in INSTALL.configure localized
missing
themes
bitmaps config.guess
COPYRIGHT.MOTIF INSTALL.imake ltmain.sh
mkinstalldirs tools
BUGREPORT config.log
demos
install-sh Makefile
OPENBUGS
xmthemes
clients config.status
doc
lib
Makefile.am README
[root@ftosx1 openMotif-2.2.1]# cd demos/
[root@ftosx1 demos]# ls
Imakefile lib Makefile Makefile.am Makefile.in
programs unsupported
[root@ftosx1 demos]#
Going to periodic directory we will have:
[root@ftosx1 periodic]# ls -al
total 166
drwxrwxrwx 2 7560
200 344 May
14 21:18 .
drwxrwxrwx 35 7560 200
1040 Apr 19 10:16 ..
-rw-rw-r-- 1 root
root 2167 Jan 4 23:24
Imakefile
-rw-r--r-- 1 root
root 10138 Apr 19 10:16 Makefile
-rw-rw-r-- 1 root
root 518 Jan 29 19:38
Makefile.am
-rw-rw-r-- 1 root
root 10069 Jan 29 21:03 Makefile.in
-rw-rw-r-- 1 root
root 23974 Jan 9 04:19
periodic.c
-rw-rw-r-- 1 root
root 25619 Apr 19 11:14 periodic_l.uil
-rw-rw-r-- 1 root
root 69427 Apr 19 11:02 periodic.uil
-rw-rw-r-- 1 root
root 962 Jan
4 23:24 README
-rw-r--r-- 1 root
root 3741 Apr 19 11:33
XmdPeriodic.ad
Compiling we get:
[root@ftosx1 periodic]# make
gcc -DHAVE_CONFIG_H -I. -I. -I../../../include -I./../../../lib
-I/usr/X11R6/include -g -O2 -Wall -Wno-unused -Wno-comment
-c periodic.c
/bin/sh ../../../libtool --mode=link gcc -g -O2 -Wall
-Wno-unused -Wno-comment -o periodic periodic.o ../../../lib/Xm/libXm.la
../../../lib/Mrm/libMrm.la
mkdir .libs
gcc -g -O2 -Wall -Wno-unused -Wno-comment -o .libs/periodic
periodic.o ../../../lib/Xm/.libs/libXm.so -L/usr/X11R6/lib ../../../lib/Mrm/.libs/libMrm.so
/root/openMotif-2.2.1/lib/Xm/.libs/libXm.so -lXmu -lXext -lXp -lXt -lSM
-lICE -lX11 -Wl,--rpath -Wl,/usr/X11R6/lib
creating periodic
../../../clients/uil/uil -o periodic.uid periodic.uil -I./../../../clients/uil
-I../../../clients/uil
[root@ftosx1 periodic]#
Therefore, is created a shared library, and then used in combination of the UIL source to create the binary.
The UIL manual explain these matter. In fact, running the command:
[root@ftosx1 root]# man uil
we get:
uil(user cmd) uil(user cmd)
NAME
uil -- The user interface
language compiler
SYNOPSIS
uil [options ] [file]
DESCRIPTION
The uil command
invokes the UIL compiler. The User Interface Language (UIL) is a specification
language for describing
the initial state of a user interface for a Motif application. The speci
fication describes the
objects (menus, dialog boxes, labels, push buttons, and so on) used in
the
interface and specifies
the routines to be called when the interface changes state as a result
of
user interaction.
file Specifies the file to be compiled through the UIL compiler.
options Specifies one or more of the following options:
-Ipathname
This option causes the compiler to look for include files
in the directory
specified if the include files have not been found in the paths that
already
were searched. Specify this option followed by a pathname, with no
interven
ing spaces.
-m Machine code is listed. This
directs the compiler to place in the listing
file a description of the records that
it added to the User Interface
Database (UID). This helps you isolate errors. The default
is no machine
code.
-o file
Directs the compiler to produce a UID. By default,
UIL creates a UID with
the name a.uid. The file specifies the filename for the UID.
No UID is pro
duced if the compiler issues any diagnostics categorized as error
or severe.
UIDs are portable only across same-size machine architectures.
-s Directs the compiler to set
the locale before compiling any files.
The
locale is set in an implementation-dependent manner.
On ANSI C-based sys
tems, the locale is usually set by calling setlocale(LC_ALL, "").
If this
option is not specified, the compiler does not set the locale.
-v file Directs the compiler to generate a listing.
The file specifies the filename
for the listing. If the -v option is not present, no listing is generated
by
the compiler. The default is no listing.
-w Specifies that the compiler
suppress all warning and informational messages.
If this option is not present, all messages are generated, regardless of
the
severity.
-wmd file Specifies a binary widget meta-language description file
to be used in place
of the default WML description.
RELATED INFORMATION
X(1) and Uil(3).
uil(user cmd)
(END)
UIL is the right choice for large volumes of source. OSF includes a
specific manual for this purpose. If you are evaluating the right choice
for X Window Development, please read the Conclusion at the end of the
course.
The author start to work with UNIX as a Motif and X Windows programmer,
in 1989. In those days a builder, specially for a company that needs to
develop grafical interface motif based, were fundamental.
Can you imagine ten programmers working everyday to develop masks ... manually ?
The MS-Windows equivalent, was called "dialog" that generate a ".rc" (resouce file) to create the masks and the exe. Under the UNIX side, first builders start to cost US$ 5,000.
Also, actually we have builders used on Motif, that generate Motif code.
The ICS BX Pro
ICS or Integrated Computer Solution Incorporated offers, probably the
better builder available. Also the OpenGroup includes this builder in demo
version, where we present here some screenshoots.
![]() |
![]() |
Note how the container are visible and available in a clear form. Using Drag-and-drop techniques is possible to create applications in a fly. The same is valid for other widgets
The CDE dtbuilder
Xi Graphics continue to offer the CDE builder, inside it DeXtop GUI. We will cover the Xi Graphics CDE for Linux (not available anymore), in the next chapter.

One of this methods regards another mode, similar (and probably more easy than UIL). This method is called "Xmt".
Originally Xmt was supported O'Reilly in a book called "Motif Tools". This book is actually Out-of-Print (OOP). However, there are new releases available from: http://www.motiftools.org/
We cover here the version Xmt 4.00
After download the version we will have:
[root@ftosx1 xmt400]# pwd
/root/xmt400
[root@ftosx1 xmt400]# ls -F
AUTHOR
clients/ DEVELOPMENT-TEAM Imakefile
LICENSE NEW-FILE-TEMPLATE PLATFORMS
README tests/
Xmt/
CHANGE-LOG contrib/
examples/ INSTALLATION
Makefile NO_WARRANTY PROBLEM-REPORT-FORM
README.210 THANKS Xmt.tmpl
CHANGES-HISTORY COPYRIGHT FAQ
KNOWNBUGS man/ OVERVIEW
QUICK-START-ME RELEASE-NOTES
VERSION
[root@ftosx1 xmt400]#
After the classical commands, we will get great results with few efforts:
[root@ftosx1 xmt400]# xmkmf
[root@ftosx1 xmt400]# make Makefiles
[root@ftosx1 xmt400]# make
[root@ftosx1 xmt400]# make install
After the installation procedure we may run the test (there are also examples), and get the following result:
[root@ftosx1 ProgressWidget]# mockup progress1

These manuals are also included The Single UNIX Specification - v3 - Jan 2002 and are the following:

We have:
Check the Interactive Exam Cram X Window:
Internet Resources for this Chapter.