From: jan@ECHO.CANBERRA.EDU.AU (Jan Newmarch)
Newsgroups: comp.windows.x.motif
Subject: Frequently Asked Questions about Motif (Part 1 of 4)
Summary: This posting contains a list of Frequently Asked
	Questions and their anserws about Motif.  It should
	be read by anyone with questions and problems about
	Motif before they post to the comp.windows.x.motif
	newsgroup.
Keywords: FAQ question answer
Date: 9 Apr 92 00:06:20 GMT
Expires: 8 Jun 92 15:57:59 GMT
Reply-To: jan@echo.canberra.edu.au (Jan Newmarch)
Followup-To: comp.windows.x.motif
Distribution: inet
Organization: The Internet

Archive-name: motif-faq-1
Last-modified: Wed Apr 8 1992
Version: 2.4



[Last changed: 8 Apr 1992]

This article contain the answers to some Frequently Asked Questions (FAQ) 
often seen in comp.windows.x.motif. It is posted to help reduce volume in 
this newsgroup and to provide hard-to-find information of general interest.

		Please redistribute this article!

This article includes answers to the following questions. Ones marked with
a + indicate questions new to this issue; those with changes of content since
the last issue are marked by *:

 0) TOPIC: WHAT ARE OTHER RELEVANT NEWSGROUPS?
 1) TOPIC: FTP ARCHIVES
 2)* Is the FAQ list available for FTP anywhere?
 3) Is this newsgroup archived?
 4) Is the mail list motif-talk archived?
 5) TOPIC: OSF AND MOTIF
 6) What versions of Motif are there?
 7)* Where can I get Motif?
 8)+ Is there a list of Motif bugs?
 9) Where can I get public domain Motif source?
10)* Are the Motif examples publically available?
11)* Has anyone done a public domain Motif lookalike?
12) Does anyone from OSF pay attention to our questions/suggestions?
13) Does OSF have an application compliance validation service?  
14)* What is the motif-talk mailing list?
15) What MIT patches do I use, and when do I use fix-osf?
16) How does Motif work with X11R5?
17) TOPIC: LITERATURE
18)* What books should I read or do I need to program using Motif?
19) TOPIC: MWM
20) What is the difference between Motif and mwm?
21) Does anyone have an alternative set of 3-D defaults for a monochrome screen?
22)  How can I modify the window manager decorations?
23)+  How can I turn off window manager functions from the system menu?
24)  How can tell I if the user has selected the "Close" item on the system menu attached to the top-level shell?
25) TOPIC: MOTIF GENERATORS
26)*  What prototyping tools are there to generate Motif code?
27) TOPIC: TEXT WIDGET
28) Why does  pressing  <return> in a text widget do nothing?
29) When I add text to a scrolling text widget how can I get the new text to show?
30) Does the text widget support 16 bit character fonts?
31) How can I stop the text widget from echoing characters typed?
32)* How can I replace characters typed with say a `*'?
33)* How can I best add a large piece of text to a scrolled text widget?
34) How can I highlight text in the Text widget?
35)*  How can I select all of the text in a widget programmatically?
36) How can I change colours of text in the Text widget?
37) How can I change the font of text in the Text widget?
38) Is there an emacs binding for the text widget?
39)* How can I use a file as the text source for a Text widget?
40) How can put Text in overstrike mode instead of insert?
41) How can make the Delete key do a backspace?
42) TOPIC: LIST WIDGET
43) How do I best put a new set of items into a list?
44)  Can I have strings with different fonts in a list?
45) Can I get a bitmap to show in a list item like I can in a Label?
46) Can I have items with different colours in a list?
47) Can I grey out an item in a list?
48) TOPIC: FILE SELECTION BOX WIDGET
49)* What is libPW.a and do I need it?
50)+ What are these compile errors: Undefined symbol _regcmp?
51) What's wrong with the Motif 1.0 File Selection Box?
52) TOPIC: FORM WIDGET
53)* Why don't labels in a Form resize when the label is changed?
54)* How can I center a widget in a form?
55)* How do I line up two columns of widgets of different types?
56) TOPIC: PUSHBUTTON WIDGET
57) Why can't I use accelerators on buttons not in a menu?
58) TOPIC: LABEL WIDGET
59) How can I align the text in a label (button, etc) widget?
60) Why doesn't label alignment work in a RowColumn?
61)* How can I set a multiline label?
62)  How can I have a vertical label?
63) TOPIC: DRAWING AREA WIDGET	
64) How can I send an expose event to a Drawing Area widget?
65)+ How can I know when a DrawingArea has been resized?
66) TOPIC: MENUS
67) What can I put inside a menu bar?
68) Can I have a cascade button without a submenu in a pulldown menu?
69) Should I have a cascade button without a submenu in a pulldown menu?
70) TOPIC: INPUT FOCUS
71) How can I direct the keyboard input to a particular widget?
72)* How can I have a modal dialog which has to be answered before the application can continue?
73) TOPIC: MEMORY AND SPEED
74)* Why does my application grow in size?
75)* Why does my application take a long time to start up?
76) My application is running too slowly. How can I speed it up?
77) TOPIC: XMSTRING
78) How can I get the Ascii text out of an XmString?
79) When can XmStrings used as resources be freed?
80) Why doesn't XmStringGetNextSegment() work properly?
81) TOPIC: DIALOGS
82) How do I stop my dialog disappearing when I press the help button?
83) How do I make my own dialog?
84) How come the title bars for my dialogs now have "_popup" or "<-popup" concatenated onto the widget name?
85) How can I force a dialog window to display?
86)* How can I control placement of a popup widget?
87) TOPIC: LANGUAGE BINDINGS
88)* Is there a C++ binding for Motif?
89) Is there a Common Lisp binding for Motif?
90)* Is there an Ada binding for Motif?
91) TOPIC: SPECIFIC PLATFORMS
92)* Is it easy to build Motif for a Sun?
93) What compile errors/warnings might I get in both Sun 3 and Sun 4?
94) On a Sun 3, what are the mwm startup error messages about?
95) Are there problems making shared libraries on a Sun?
96) Has anyone made shared libraries on an IBM RS/6000?
97) TOPIC: KEYSYMS
98) What is causing the messages "unknown keysym osfDown..."?
99) What happens if I can't install Motif Keysyms?
100) Why has OSF introduced Keysyms into Motif 1.1?
101) TOPIC: ICONS
102) How can I keep track of changes to iconic/normal window state?
103)* How can I check if my application has come up iconic?
104) How can I start my application in iconic state?
105)* How can an application iconify itself?
106)* How can an application de-iconify itself?
107) TOPIC: MISCELLANEOUS
108)+  What is IMUG and how do I join it?
109) Why does an augment translation appear to act as replace for some widgets?
110) How do you "grey" out a widget so that it cannot be activated?
111) Why doesn't the Help callback work on some widgets?
112)* Where can I get a Table widget?
113)* Has anyone done a bar graph widget?
114)* Does anyone know of a source code of a graph widget
115)*  Is there a help system available, such as in Windows 3?
116) Can I specify a widget in a resource file?
117) Why are only some of my translations are being installed?
118) Where can I get the PanHandler code?
119) What are these passive grab warnings?
120)* How do I have more buttons than three in a box?
121) TOPIC: ACKNOWLEDGEMENTS

If you have suggestions or corrections for any of these answers or any 
additional information, please send them directly to jan@ise.canberra.edu.au;
the information will be included in the next revision (or possibly the one 
after that; thanks for the many suggestions which haven't been incorporated 
yet).  The answers in this iteration are acknowledged to be partial.

This posting is intended to be distributed at approximately the beginning of 
each month.

The information contained herein has been gathered from a variety of sources. In
many cases attribution has been lost; if you would like to claim responsibility
for a particular item, please let us know. 

Conventions used below: telephone numbers tend to be Bell-system unless 
otherwise noted; prices on items are not included.







-------------------------------------------------------------------------------
Subject:  0) TOPIC: WHAT ARE OTHER RELEVANT NEWSGROUPS?

Answer: This newsgroup is comp.windows.x.motif.  The nearest related group is
comp.windows.x.  It also maintains an FAQ, which deals in all sorts of X, Xlib
and Xt questions. Look there for answers to questions such as "How do I get a
screendump of my application?", "where do I get X11R4", etc.  Other groups which
may have relevant information are comp.windows.news, comp.windows.misc and
comp.windows.open-look.

-------------------------------------------------------------------------------
Subject:  1) TOPIC: FTP ARCHIVES

-------------------------------------------------------------------------------
Subject:  2)* Is the FAQ list available for FTP anywhere?

Answer: A number of FAQ's (including this one) are available for anonymous ftp
at pit-manager.mit.edu, 18.172.1.27 under the directory pub/usenet.  (Motif is
under pub/usenet/comp.windows.x.motif) There is also a mail server called mail-
server@pit-manager.mit.edu.  To retrieve a file send mail to the server with a
subject or body similar to

        send usenet/comp.windows.x.motif/Frequently_Asked_Questions_About_Motif_(Part_1_of_3)

This service is looked after by Jonathan Kamens (jik@pit-manager.mit.edu).

It has also been placed in contrib/Motif-FAQ at export.lcs.mit.edu.

-------------------------------------------------------------------------------
Subject:  3) Is this newsgroup archived?

Answer: A number of individuals are archiving the group for their own records,
but no-one has set up an FTP-able archive yet.
[Does anyone have a free 10Meg or so?]


-------------------------------------------------------------------------------
Subject:  4) Is the mail list motif-talk archived?

Answer: If you have purchased support from OSF then you have access to their
archive server for motif-talk.

-------------------------------------------------------------------------------
Subject:  5) TOPIC: OSF AND MOTIF

-------------------------------------------------------------------------------
Subject:  6) What versions of Motif are there?

Answer: Motif 1.0 is based on the R3 toolkit.  There are patch releases to 1.0:
1.0.1, 1.0.A, 1.0.2 and 1.0.3, 1.0.4, 1.0.5. 1.0.A was a fairly major patch, as
it involved a complete re-engineering of UIL and Mrm.  Almost everyone who has
1.0.x has either 1.0.A or 1.0.3.  There are not expected to be further patches
to 1.0.

Motif 1.1 is based on the R4 toolkit.  The current version is Motif 1.1.0, plus
a couple of patches available to full support contract holders. Motif 1.1.1 has
been released as a patch to licensees with Full Support or Technical Update
service.  Motif 1.1.2 is a patch release which contains the necessary changes to
fix over 80 bugs reported against Motif. It is available to support contract
holders (including both full support and update service).  The 1.1.3 release
fixes a further 150 bugs and is available from August 1991 to support contract
holders (including both full support and update service).  Future 1.1 patch
releases are tentatively scheduled as follows:



        1.1.4   4th quarter 1991
        1.1.5   1st half 1992


Motif 1.2 is not expected until early 1992, and will be based on the R5 toolkit.

-------------------------------------------------------------------------------
Subject:  7)* Where can I get Motif?

Answer:
    Various hardware vendors produce developer's toolkits of binaries, header
files, and documentation; check your hardware vendor, particularly if that
vendor is an OSF member. Systems known to be shipping now: HP (sans UIL), Apollo
(sans UIL), SCO, ISC, Mips (RISCwindows=X11R3 + full Motif), IBM, Data General
for AViioNs (includes UIL), Bull (?), Concurrent Computer Corporation 5000,
6000, 8000 series machines, Convex, Sequent.

    In addition, independent binary vendors produce Motif toolkits . ICS makes
several binary kits, notably for Sun, DEC, Apple; Quest (408-988-8880) sells
kits for Suns, as well; IXI (+44 223 462 131) offers kits for Sun3 (SunOS 3.5 or
later, and Sun4 (SunOS 4.0.1 or later). Unipalm XTech (+44 954211797; or Aurora
Technologies 617-577-1288 in USA) offers a binary kit for Suns based on Motif
1.1, with shared libraries.  NSL (+33 (1) 43 36 77 50; requests@nsl.fr) offers
kits for the Sun 3 and Sun 4.  [An FAQ is for "personal opinions" on these
toolkits.  I don't think it is appropriate to give such opinions through this
particular posting, so I haven't included any.] In Australia, Information
Technology Consultants Pty Ltd has Motif 1.1.2 for Sun Sparc 4.1 ( phone on (02)
360 6999, fax on (02) 360 6695 or e-mail to motif@itcsyd.itc.oz.au)


  The kits include varied levels of bug-fixing and support for shared libraries.
BIM (Fax : +32(2)759.47.95) offer Motif 1.1 for Sun-3, Sun-4, Sun-386i. Includes
shared libraries.  Metrolink Inc. (+1-305-566-9586, sales@metrolink.com; in
Europe contact ADNT, (33 1) 3956 5333) ships an implementation of X11R4 and
Motif 1.1 for several 386 systems.

    An OSF/Motif source license must be obtained from OSF before source can be
obtained from the Open Software Foundation. Call the Direct Channel Desk at OSF
at 617-621-7300 or email direct@osf.org for ordering information.  In addition
to the full Motif source, "option C" allows you to purchase source for the
window manager mwm to run on X terminals.


-------------------------------------------------------------------------------
Subject:  8)+ Is there a list of Motif bugs?

Answer: With each patch release of Motif shipped, there is a list of known bugs
provided.  The filename on the tape is "./OPENBUGS".  There is also a list of
all the issues closed/resolved in that patch.  That is found as part of the
"./README-1.1.n" (where n is the patch number) file.

These are the only OSF published lists.

No-one else seems to publish a list.


-------------------------------------------------------------------------------
Subject:  9) Where can I get public domain Motif source?

Answer: You cannot.  Motif source is not publically available.


-------------------------------------------------------------------------------
Subject: 10)* Are the Motif examples publically available?

Answer: OSF has produced a list of which of the example programs can be
distributed. Call OSF Direct for a copy of it.  Most of the example programs
have been freed from distribution limitations so should be available.

In addition to these, many programs on export.lcs.mit.edu in the contrib
directory use Motif.  Source code posted to comp.sources.x often uses Motif.
The examples from Dan Heller's book are on export in
/contrib/OReilly/motif/examples.tar.Z.  The examples from Doug Young's book are
on export in /contrib/young.motif.Z The examples from Thomas Berlages's book are
on export in /contrib/berlage.motif.Z The examples from Donald L. McMinds's book
are on export in /contrib/mastering.motif.tar.Z



-------------------------------------------------------------------------------
Subject: 11)* Has anyone done a public domain Motif lookalike?

Answer: Not yet.  The specification is available (AES), and the validation suite
can be bought, but no-one has taken up the challenge.  There are some commercial
lookalikes (Looking Glass and Neuron Data), but no workalikes.  Tcl is available
for ftp from allspice.berkeley.edu, and although implemented without Xt, is
reported to look like Motif.


-------------------------------------------------------------------------------
Subject: 12) Does anyone from OSF pay attention to our questions/suggestions?

Answer: Yes, and they quite often post answers too. But they may not respond to
*your* problem because they have other things to do as well.  This newsgroup is
not run by OSF, and has no formal connection with OSF.  OSF is a member-driven
company.  The membership (and anyone can be a member) provides the primary input
for future development of Motif.

-------------------------------------------------------------------------------
Subject: 13) Does OSF have an application compliance validation service?

Answer: They have a checklist and a certification process which you can request
from them.  Ask for the Level One Certification Checklist.  The process is one
of self-certification.  It tests only the appearance and behavior of the
application against Motif style.  The product will also be put in the OSF
reference listing.  There's a one-time fee of $250.  According to the master
license agreement, you can't use any OSF identifying mark unless you have done a
certification.


-------------------------------------------------------------------------------
Subject: 14)* What is the motif-talk mailing list?

Answer: The motif-talk mailing list is only for those who have purchased a Motif
source code license. You can be placed on this list by emailing to motif-talk-
request@osf.org, citing your Company name and source license number.



-------------------------------------------------------------------------------
Subject: 15) What MIT patches do I use, and when do I use fix-osf?

Answer: The Motif 1.1.0 tape contains MIT patches 1-14. Apply these and any
others you can get.  If your MIT patch level only goes up to fix-16, you also
need to apply fix-osf.  Fix-osf was an emergency patch for a problem that
existed when the Motif 1.1 tape was cut, The MIT fix-17 completely superseded
osf-fix, so if you have applied fix-17 do not apply fix-osf.  The 1.1.1 tape
contains MIT fixes 15-18, as well as an OSF-developed fix that deals with a
subtle bug in the Selection mechanism of the Intrinsics.  Most people will have
fix-15 to 18 by now; if you don't have them:

        Back out fix-osf if you have applied it
        Apply fix-15 to 18
        Apply fix-osf-1.1.1

The Selection fix was submitted to MIT, who came up with a diferent fix.  It
will not be made into an R4 fix but should be in R5. The MIT fix was posted to
motif-talk.


-------------------------------------------------------------------------------
Subject: 16) How does Motif work with X11R5?

Answer: Motif 1.1.X is only intended to be built with X11R4.  Motif 1.2.X is for
X11R5.  however, Motif 1.1.4 has been set to also work with X11R5.

For Motif 1.1.1, 1.1.2 and 1.1.3 you will need to compile Xlib and Xt with a
MOTIF_BC flag set to YES (page 8, section 3.3 of the R5 release notes), or
you'll also have a link problem (LowerCase) and a fatal run time problem
(XContext manager).  If your applications come up with "Unknown keysym name:
osfActivate" errors, check the variable ProjectRoot. The name
/$PROJECTROOT/lib/XKeysymDB will have been wired into your Xlib.

In Motif 1.1.0, XtCallCallback uses NULL as the first argument instead of a
widget ID. This was ok under R4, but must be changed in the source for R5. It
was changed by OSF from Motif 1.1.1 onward.

Mrm won't work at all (can't link since it uses an X private variable that has
disappeared in R5).  Thre is an MIT patch that may fix this??  [I confess
ignorance of Mrm and UIL].


-------------------------------------------------------------------------------
Subject: 17) TOPIC: LITERATURE

-------------------------------------------------------------------------------
Subject: 18)* What books should I read or do I need to program using Motif?

Answer: Ken Lee of the DEC Western Software Laboratory (klee@wsl.dec.com)
regularly posts to comp.windows.x and ba.windows.x a list of reference books and
articles on X and X programming.  In FAQ comp.windows.x an extract of his list
appears. Specifically for Motif programming, though:

OSF/Motif Programmers Guide, Prentice-Hall 13-640525-8 (Motif 1.0) ISBN 0-13-
640681-5 (Motif 1.1) (NB: This makes use of the demo programs that you get with
a Motif source license.  The programs are not included and may or may not be
available on your system.)

OSF/Motif Programmers Reference Manual, Prentice-Hall 13-640517-17 (Motif 1.0)
 ISBN 0-13-640616-5 (Motif 1.1) You will need this for the system calls.

OSF/Motif Style Guide, Prentice-Hall 13-640491-X (Motif 1.0) ISBN 0-13-640673-4
(Motif 1.1) You will need this to get some idea of how to write programs with
the correct `look and feel'.

You should read at least one of the the non-OSF books on Motif:

Young, Doug. "The X Window System: Applications and Programming with Xt (Motif
Version)," Prentice Hall, 1989 (ISBN 0-13-497074-8). The excellent tutorial "X
Window Systems Programming and Applications with Xt," (ISBN 0-13-972167-3)
updated for Motif. [The examples from the Motif version are available on export
in ~ftp/contrib/young.motif.tar.Z]

Marshall Brain at brain@adm.csc.ncsu.edu posted a set of simple and useful Motif
tutorials.

Berlage, Thomas Berlage, OSF/Motif: Concepts and Programming, Addison-Wesley,
UK, 1991. ISBN 0-201-55792-4.

Johnson, Eric F. and Kevin Reichard, Power Programming Motif, MIS: Press,
Portland, OR, 1991. ISBN 1-55828-059-6. Book with disk, ISBN 1-55828-061-8.

Heller, Dan, The Motif Programming Manual, Volume 6 of the O'Reilly series on X.
This is the most complete volume on Motif programming available.

Barkakati, Nabajyoti, W Window System Programming, SAMS. ISBN 0-672-22750-9.
This contains a section on Motif.

You will also need books and references on Xt such as:

Asente, Paul J., and Swick, Ralph R., "X Window System Toolkit, The Complete
Programmer's Guide and Specification", Digital Press, 1990.  The bible on Xt. A
treasury of information, excellent and invaluable.  Distributed by Digital
Press, ISBN 1-55558-051-3, order number EY-E757E-DP; and by Prentice- Hall, ISBN
0-13-972191-6.

Nye, Adrian, and Tim O'Reilly, "X Toolkit Programming Manual, Volume 4,"
O'Reilly and Associates, 1989. The folks at O'Reilly give their comprehensive
treatment to programming with the MIT Intrinsics; R4 versions are now available,
as is a Motif 1.1 version (Volume 4M).


O'Reilly, Tim, ed.,  "X Toolkit Reference Manual, Volume 5," O'Reilly and
Associates, 1989.  A professional reference manual for the MIT X11R3 Xt; some
information on X11R4 is included.

Books and reference manuals on Xlib may also be useful.



-------------------------------------------------------------------------------
Subject: 19) TOPIC: MWM

-------------------------------------------------------------------------------
Subject: 20) What is the difference between Motif and mwm?

Answer: mwm is a window manager. Motif itself is made up of four parts: a User-
Interface Guideline, an API toolkit of `C' routines which helps in the building
of applications which conform to the Guideline, the window manager mwm, and a
language UIL which is designed to ease user interface development.  In general
mwm will run an application built with any X-windows API, and in general an
application built using the Motif toolkit will run under any window manager.


-------------------------------------------------------------------------------
Subject: 21) Does anyone have an alternative set of 3-D defaults for a
monochrome screen?

Answer: This is obviously a matter of taste. Some alternatives suggested include

!Benjamin Schreiber, bs@osf.osf.org, bs@cs.brandeis.edu
Mwm*foreground:                 black           ! Actually, when a window is
Mwm*background:                 white           ! deactivated, the background
Mwm*backgroundPixmap:           50_foreground   ! becomes white, insted of
Mwm*topShadowPixmap:            white           ! 50% foreground (grey)

Mwm*activeForeground:           black
Mwm*activeBackground:           white
Mwm*activeBackgroundPixmap:     50_foreground
Mwm*activeTopShadowPixmap:      white

Mwm*menu*backgroundPixmap:      background
Mwm*menu*topShadowPixmap:       50_foreground

Mwm*title*foreground:                   black
Mwm*title*background:                   white
Mwm*title*backgroundPixmap:             white
Mwm*title*topShadowPixmap:              50_foreground
Mwm*title*activeForeground:             white
Mwm*title*activeBackground:             black
Mwm*title*activeBackgroundPixmap:       black
Mwm*title*activeBottomShadowPixmap:     50_foreground

Mwm*feedback*backgroundPixmap:          white

or

! From: tsang@isi.com (Kam C. Tsang)
Mwm*background:                      White
Mwm*activeBackground:                White
Mwm*activeBackgroundPixmap:          25_foreground
Mwm*foreground:                      Black
Mwm*activeForeground:                Black
Mwm*menu*background:                 white
Mwm*menu*foreground:                 black
xterm*Foreground:                    black
xterm*Background:                    white


or

! From: ucsd.edu!usc!snorkelwacker!paperboy!yee  (Michael K. Yee)
Mwm*cleanText:                          True

Mwm*activeBackground:           white
Mwm*activeForeground:           black
Mwm*background:                 white
Mwm*foreground:                 black

Mwm*client*activeBackgroundPixmap:      50_foreground
Mwm*client*activeTopShadowPixmap:       foreground
Mwm*client*activeBottomShadowPixmap:    background

!Mwm*client*background:                 white
!Mwm*client*foreground:                 black
Mwm*client*backgroundPixmap:            75_foreground
Mwm*client*topShadowPixmap:             foreground
Mwm*client*bottomShadowPixmap:          background

!Mwm*feedback*background:               white
!Mwm*feedback*foreground:               black
Mwm*feedback*backgroundPixmap:          50_foreground
!Mwm*feedback*topShadowPixmap:          25_foreground
!Mwm*feedback*bottomShadowPixmap:       background

!Mwm*menu*background:                   white
!Mwm*menu*foreground:                   black
Mwm*menu*backgroundPixmap:              foreground
!Mwm*menu*topShadowPixmap:              foreground
!Mwm*menu*bottomShadowPixmap:           background

!Mwm*icon*background:                   white
!Mwm*icon*foreground:                   black
Mwm*icon*activeBackgroundPixmap:        50_foreground
Mwm*icon*activeBottomShadowPixmap:      foreground
Mwm*icon*backgroundPixmap:              75_foreground



-------------------------------------------------------------------------------
Subject: 22)  How can I modify the window manager decorations?

Answer: In resource files, use the window manager's client resource (which is
the application) and the resource clientDecoration:

Mwm*XClock.clientDecoration:   none

turns off all clock decorations.  See the mwm(1) entry for other possibilites.

Programmatically, set the VendorShell resource XmNmwmDecorations to appropriate
values: MWM_DECOR_NONE (or a bitwise or of values).

-------------------------------------------------------------------------------
Subject: 23)+  How can I turn off window manager functions from the system menu?

Answer: The user of an application can control functions in the system menu for
an application using the mwm resource clientFunctions:

        mwm.application_name.clientFunctions: -resize -close


Answer: The writer of an application can only remove items.  Be warned that your
users will probably gnash their teeth, swear furiously at your product and stop
using it if they discover that you have done this.  (Especially if you have
removed the Close button, your application has hung and it has taken up all of
memory and swap so it can't be killed.) Much better is to catch the action
gracefully as in the next question.

        XtVaGetValues(shell, XmNmwmFunctions, &int_val, NULL);
        int_val &= ~MWM_FUNC_CLOSE;
        XtVaSetValues(shell, XmNmwmFunctions, int_val, NULL);



-------------------------------------------------------------------------------
Subject: 24)  How can tell I if the user has selected the "Close" item on the
system menu attached to the top-level shell?  I need to do some clean up before
exiting.

Answer:          This works with R4 Intrinsics

        void FinalCleanupCB(w, client_data, call_data)
        Widget   w;
        caddr_t  client_data, call_data;
        {
                /* tidy up stuff here */
                ...
                /* exit if you want to */
                exit (0);
        }

        main()
        {
                Atom wm_delete_window;

                ...
                XtRealizeWidget(toplevel);
                ...
                wm_delete_window =
                        XmInternAtom(XtDisplay(toplevel),
                                "WM_DELETE_WINDOW", False);
                XmAddWMProtocolCallback(toplevel, wm_delete_window,
                        FinalCleanupCB, NULL);
                XtMainLoop();
        }

This will still kill the application.  To turn this behaviour off so that the
application is not killed, set the shell resource XmNdeleteResponse to
XmDO_NOTHING.  This means that users cannot kill your application via the system
menu, and may be a bad thing.

If you are running R3, Bob Hays (bobhays@spss.com) has suggested this: "Trapping
on the delete window atom does not work as I cannot force my action routine to
the top of the action list for the activity desired, so the window manager kills
my window anyway BEFORE I can do anything about it.  And, to make matters worse,
the window manager (Motif in this case) tacks its atoms and handlers onto the
window at some unknown point down the line after the creation of the shell
widget as far as I can tell.  So....

I have a procedure as an action routine for ClientMessage.  Then, if I get a
property change event on the window manager protocols, I then tack on
WM_SAVE_YOURSELF.  If I get this request, I clean up (it seems to happen on
WM_DELETE_WINDOW, BTW, if you remove WM_DELETE_WINDOW from the WM protocols
atom) and exit.  Works great and is less filling overall:-)."

-------------------------------------------------------------------------------
Subject: 25) TOPIC: MOTIF GENERATORS

-------------------------------------------------------------------------------
Subject: 26)*  What prototyping tools are there to generate Motif code?


Answer: [An FAQ is for "personal opinions" on these tools.  I don't think it is
appropriate to give such opinions through this particular posting, so I haven't
included any.]

`Prototyping tools' come in two forms: those that can be used to design the
interface only (GUI builder), and those that go beyond this to give support for
application code (User Interface Management Systems).  There are a number of
commercial and non-commercial tools of both kinds that will support the Motif
interface.  They include:

GUI builders:

Builder Xcessory
X Build
ExoCODE/xm


UIMS:

WINTERP
Widget Creation Library
UIMX
Serpent
TeleUse
X-Designer
XFaceMaker2
MOTIFATION


Some contact addresses are:

WINTERP: You may obtain the current source, documentation, and examples via
anonymous ftp from host export.lcs.mit.edu: in directory contrib/winterp you
will find the compress(1)'d tar(1) file winterp.tar.Z. If you do not have
Internet access you may request the source code to be mailed to you by sending a
message to winterp-source%hplnpm@hplabs.hp.com or hplabs!hplnpm!winterp-source.

Serpent: The S/W is free (anonymous ftp) from ftp.sei.cmu.edu.  For more info
contact erik/robert at serpent-info@sei.cmu.edu.

TeleUse: In the U.K., send mail to xtech@unipalm.co.uk or call +44 954 211862.
In the US call Telesoft at (619) 457-2700 or write TeleSoft, 5959 Cornerstone
Court West, San Diego, California 92121.

Builder Xcessory from ICS.  More details are available by sending a request to
info@ics.com.  617.547.0510

X-Designer: From Imperial Software Technology in the UK.  Email address is
sales@ist.co.uk.  (+44) 743 587055

Recently, V.I. Corporation have become the distributor for the X-Designer
product in the United States.  In addition, IST and V.I. Corporation have
developed a product called DVX-Designer that merges X-Designer with their GUI
product called DataViews.  Other merged products are in the works.  For more
information, people can contact:

        V.I. Corporation
        47 Pleasant Street
        Northampton, MA  01060
        Phone: (413) 586-4144
        Fax: (413) 586-3805
        Email: vi@vicorp.com


ExoCODE/xm: From Expert Object Corp., 7250 Cicero Avenue, Lincolnwood, IL 60646
(708)676-5555.

X Build: From Nixdorf Computer (Waltham, MA) xbuild@nixdorf.com


ExoCode: From EXOC (Chicago, IL)

UIMX: Visual Edge Software Limited, 3870 Cote Vertu, St Laurent, Quebec, H4R
1V4, Phone: (514) 332-6430, Fax:   (514) 332-5914, or: Visual Edge Software
Ltd., 101 First Street, Suite 443, Los Altos, CA 94022, Phone: (415) 948-0753,
Fax:   (415) 948-0843

The Widget Creation Library: The distribution is available in several ways.  The
preferred approach it for you to get the compressed tar file using anonymous ftp
from:

    export.lcs.mit.edu    (18.30.0.238) /contrib/Wcl.1.06.tar.Z


XFaceMaker2: NSL -  Non Standard Logics S.A., 57-59, rue Lhomond, 75005  Paris -
France, Phone: +33 (1) 43.36.77.50, Fax:   +33 (1) 43.36.59.78 email:
requests@nsl.fr or requests%nsl.fr@inria.fr for information.

Their North American office: Non Standard Logics, Inc., 4141 State Street, Suite
B-11, Santa Barbara CA 93110, Tel: 805 964 9599, Fax: 805 964 4367


MOTIFATION: AKA EDV, Universitaetsstrasse 125, 4630 Bochum, Germany, Tel: +49
(0) 234 / 33397-0, Fax: +49 (0) 234 / 33397-40



-------------------------------------------------------------------------------
Subject: 27) TOPIC: TEXT WIDGET

-------------------------------------------------------------------------------
Subject: 28) Why does  pressing  <return> in a text widget do nothing?  This
happens using Motif 1.0 when I have a text widget inside a bulletin board (or
form) inside a dialog shell. (In Motif 1.1 it is fixed for both text and list
widgets.)

Answer: In single line mode, pressing the <return> key usually invokes the
activate() action, and in multi-line mode, the newline() action.  However,
whenever a widget is the child of a bulletin board widget which is the child of
a dialog shell, the bulletin board forces all of its children to translate
<return> to the bulletin board action Return() which is usually associated with
the default button of the dialog.  To restore the text actions of activate() or
newline(), you need to overide the Return() action of the bulletin board.


        /* declarations */
        /* for a single line widget */
        char newTrans[] = "<Key>Return : activate()";
        /* for a multi line widget */
        char newTrans[] = "<Key>Return : newline()";
        XtTranslations transTable;

        /* in executable section */

        transTable = XtParseTranslationTable(newTrans);

        /* after creating but before managing text widget */

        XtOverrideTranslations(textWidget, transTable);


-------------------------------------------------------------------------------
Subject: 29) When I add text to a scrolling text widget how can I get the new
text to show?

Answer: Use the call undocumented in Motif 1.0

        void XmTextShowPosition(w, position)
        Widget w;
        XmTextPosition position;

where the position is the number of characters from the beginning of the buffer
of the text to be displayed. If you don't know how many characters are in the
buffer, use another call undocumented in Motif 1.0

        position = XmTextGetLastPosition(w)


-------------------------------------------------------------------------------
Subject: 30) Does the text widget support 16 bit character fonts?

Answer: R5 will have support for 16 bit character sets, and Motif 1.2 will use
that. You will have to wait until then.

-------------------------------------------------------------------------------
Subject: 31) How can I stop the text widget from echoing characters typed?  I
need to turn off echo for password input.

Answer: Use the modifyVerifyCallback to tell when input is received. Set the
`doit' field in the XmTextVerifyCallbackStruct to False to stop the echo. In
Motif 1.0 this will cause a beep per character: Live with it, because at 1.1 you
can turn it off.  Note that password hiding is inherently insecure in X -
someone may have an X grab on the keyboard and be reading all characters typed
in anyway.

Another solution often proposed is to set the foreground and background colours
to be the same, effectively hiding the text.  This has a major flaw: someone may
select the text (triple click the mouse to get the line), and then paste the
password into say an xterm with *different* foreground and background colours.
This immediately shows the password.

-------------------------------------------------------------------------------
Subject: 32)* How can I replace characters typed with say a `*'?  I want to
replace input for password entry.

Answer: In Motif 1.1  set text->ptr in the callback structure to '*'. This does
not work under 1.0 because of an oversight in which changes to this are ignored.
In Motif 1.0, what you can do is set the doit flag to 'false' so the text is not
displayed. Then set a static boolean to True to prevent re-entrance.  Next call
XmTextReplace() to display your '*'.  then reset your re-entrance flag to False.
XmTextReplace() will call the XmNmodifyVerify callback.  To prevent getting into
an infinite loop, you need the re-entrance flag.

The following program from Dan Heller illustrates this:

----------------
/* Written by Dan Heller.  Copyright 1991, O'Reilly && Associates.
 * This program is freely distributable without licensing fees and
 * is provided without guarantee or warrantee expressed or implied.
 * This program is -not- in the public domain.  This program appears
 * in the Motif Programming Manual, O'Reilly Volume 6.
 */

/* passwd.c -- prompt for a passwd.  Meaning, all input looks like
 * a series of *'s.  Store the actual data typed by the user in
 * an internal variable.  Don't allow paste operations.  Handle
 * backspacing by deleting all text from insertion point to the
 * end of text.
 */
#include <Xm/Text.h>
#include <Xm/LabelG.h>
#include <Xm/RowColumn.h>
#include <ctype.h>

void check_passwd();
char *passwd; /* store user-typed passwd here. */

main(argc, argv)
int argc;
char *argv[];
{
    Widget        toplevel, text_w, rowcol;
    XtAppContext  app;

    toplevel = XtVaAppInitialize(&app, "Demos",
        NULL, 0, &argc, argv, NULL, NULL);

    rowcol = XtVaCreateWidget("rowcol",
        xmRowColumnWidgetClass, toplevel,
        XmNorientation, XmHORIZONTAL,
        NULL);

    XtVaCreateManagedWidget("Password:",
        xmLabelGadgetClass, rowcol, NULL);
    text_w = XtVaCreateManagedWidget("text_w",
        xmTextWidgetClass, rowcol, NULL);

    XtAddCallback(text_w, XmNmodifyVerifyCallback, check_passwd, NULL);
    XtAddCallback(text_w, XmNactivateCallback, check_passwd, NULL);

    XtManageChild(rowcol);
    XtRealizeWidget(toplevel);
    XtAppMainLoop(app);
}

void
check_passwd(text_w, unused, cbs)
Widget        text_w;
XtPointer     unused;
XmTextVerifyCallbackStruct *cbs;
{
    char *new;
    int len;

    if (cbs->reason == XmCR_ACTIVATE) {
        printf("Password: %s0, passwd);
        return;
    }

    if (cbs->text->ptr == NULL) { /* backspace */
        cbs->endPos = strlen(passwd); /* delete from here to end */
        passwd[cbs->startPos] = 0; /* backspace--terminate */
        return;
    }

    if (cbs->text->length > 1) {
        cbs->doit = False; /* don't allow "paste" operations */
        return; /* make the user *type* the password! */
    }

    new = XtMalloc(cbs->endPos + 2); /* new char + NULL terminator */
    if (passwd) {
        strcpy(new, passwd);
        XtFree(passwd);
    } else
        new[0] = NULL;
    passwd = new;
    strncat(passwd, cbs->text->ptr, cbs->text->length);
    passwd[cbs->endPos + cbs->text->length] = 0;

    for (len = 0; len < cbs->text->length; len++)
        cbs->text->ptr[len] = '*';
}


-------------------------------------------------------------------------------
Subject: 33)* How can I best add a large piece of text to a scrolled text
widget?  In some versions of Motif 1.0 even using XmTextSetString, it insists on
adding the text one line at a time, adjusting the scroll bar each time. It looks
awful and is slow.

Answer: If you don't have this problem, use XmTextSetString to set all of the
text in the widget.  If you do have this slowdown problem even using
XmTextSetString, unmanage the widget, add the text and then manage it again.
This may cause the window to blink, but you have to put up with that or switch
to a different version of Motif.

-------------------------------------------------------------------------------
Subject: 34) How can I highlight text in the Text widget?

Answer: From: argv@zipcode.com (Dan Heller)

If you don't need font or color changes, you can do all this using a Text widget
very easily [in Motif 1.1, anyway].

        loop() {
            pos = offset_of_pattern_in_text_widget(pattern, text_w);
            search_len = strlen(pattern);
            XmTextSetHighlight(text_w, pos, pos+search_len,
                        XmHIGHLIGHT_SELECTED);
        }


There are two choices for highlighting: reverse video (HIGHLIGHT_SELECTED) and
underlined (HIGHLIGHT_SECONDARY_SELECTED).  Be careful that your users won't
confuse your highlights with actual selections!

-------------------------------------------------------------------------------
Subject: 35)*  How can I select all of the text in a widget programmatically?
So that some initial text is displayed, but anything typed replaces it.

Answer: XmTextSetSelection(Text1, 0, XmTextGetLastPosition(Text1), event-
>xbutton.time);

where Text1 is the widget in question (obviously) and event is some event that
triggered this call.  You can use XtLastTimestampProcessed( display) instead of
xbutton.time if you don't happen to have an event pointer handy.




-------------------------------------------------------------------------------
Subject: 36) How can I change colours of text in the Text widget?  I want some
of the text in one colour, some in another.

Answer: You can't.  Text stores an ordinary string, and points where
`highlights' of various types begin and end.  These highlights are all the
control you have over components of the text.  See the previous question.


-------------------------------------------------------------------------------
Subject: 37) How can I change the font of text in the Text widget?  I want some
of the text in one font, some in another.

Answer: You can't in Text (see the previous question).  If you wanted readonly
text, you could do it by using a label instead.  Label uses XmStrings, which can
contain multiple character sets in the one string.

-------------------------------------------------------------------------------
Subject: 38) Is there an emacs binding for the text widget?

Answer: This set is due to Kee Hinckley (nazgul@alfalfa.com):
*XmText.translations: #override\n\
        Ctrl <Key>b:            backward-character()\n\
        Alt <Key>b:             backward-word()\n\
        Meta <Key>b:            backward-word()\n\
        Shift Alt <Key>b:       backward-word(extend)\n\
        Shift Meta <Key>b:      backward-word(extend)\n\
        Alt <Key>[:             backward-paragraph()\n\
        Meta <Key>[:            backward-paragraph()\n\
        Shift Alt <Key>[:       backward-paragraph(extend)\n\
        Shift Meta <Key>[:      backward-paragraph(extend)\n\
        Alt <Key><:             beginning-of-file()\n\
        Meta <Key><:            beginning-of-file()\n\
        Ctrl <Key>a:            beginning-of-line()\n\
        Shift Ctrl <Key>a:      beginning-of-line(extend)\n\
        Ctrl <Key>osfInsert:    copy-clipboard()\n\
        Shift <Key>osfDelete:   cut-clipboard()\n\
        Shift <Key>osfInsert:   paste-clipboard()\n\
        Alt <Key>>:             end-of-file()\n\
        Meta <Key>>:            end-of-file()\n\
        Ctrl <Key>e:            end-of-line()\n\
        Shift Ctrl <Key>e:      end-of-line(extend)\n\
        Ctrl <Key>f:            forward-character()\n\
        Alt <Key>]:             forward-paragraph()\n\
        Meta <Key>]:            forward-paragraph()\n\
        Shift Alt <Key>]:       forward-paragraph(extend)\n\
        Shift Meta <Key>]:      forward-paragraph(extend)\n\
        Ctrl Alt <Key>f:        forward-word()\n\
        Ctrl Meta <Key>f:       forward-word()\n\
        Ctrl <Key>d:            kill-next-character()\n\
        Alt <Key>BackSpace:     kill-previous-word()\n\
        Meta <Key>BackSpace:    kill-previous-word()\n\
        Ctrl <Key>w:            key-select() kill-selection()\n\
        Ctrl <Key>y:            unkill()\n\
        Ctrl <Key>k:            kill-to-end-of-line()\n\
        Alt <Key>Delete:        kill-to-start-of-line()\n\
        Meta <Key>Delete:       kill-to-start-of-line()\n\
        Ctrl <Key>o:            newline-and-backup()\n\
        Ctrl <Key>j:            newline-and-indent()\n\
        Ctrl <Key>n:            next-line()\n\
        Ctrl <Key>osfLeft:      page-left()\n\
        Ctrl <Key>osfRight:     page-right()\n\
        Ctrl <Key>p:            previous-line()\n\
        Ctrl <Key>g:            process-cancel()\n\
        Ctrl <Key>l:            redraw-display()\n\
        Ctrl <Key>osfDown:      next-page()\n\
        Ctrl <Key>osfUp:        previous-page()\n\
        Ctrl <Key>space:        set-anchor()\n


! If you'd like the Delete key to work like backspace instead of deleting
! backwards, add the following definition to the lines above.
!       <Key>osfDelete: delete-previous-character()\n\

! These aren't included because they could intefere with menu accelerators (or vice versa)
!       Alt <Key>p:             backward-paragraph()\n\
!       Meta <Key>p:            backward-paragraph()\n\
!       Shift Alt<Key>p:        backward-paragraph(extend)\n\
!       Shift Meta<Key>p:       backward-paragraph(extend)\n\
!       Alt <Key>w:             copy-clipboard()\n\
!       Meta <Key>w:            copy-clipboard()\n\
!       Ctrl Alt <Key>w:        cut-clipboard()\n\
!       Ctrl Meta <Key>w:       cut-clipboard()\n\
!       Alt <Key>y:             paste-clipboard()\n\
!       Meta <Key>y:            paste-clipboard()\n\
!       Alt <Key>f:             forward-word()\n\
!       Meta <Key>f:            forward-word()\n\
!       Alt <Key>n:             forward-paragraph()\n\
!       Meta <Key>n:            forward-paragraph()\n\
!       Shift Alt <Key>n:       forward-paragraph(extend)\n\
!       Shift Meta <Key>n:      forward-paragraph(extend)\n\
!       Shift Alt <Key>f:       forward-word(extend)\n\
!       Shift Meta <Key>f:      forward-word(extend)\n\
!       Alt <Key>d:             kill-next-word()\n\
!       Meta <Key>d:            kill-next-word()\n\
!       Alt <Key>h:             select-all()\n\
!       Meta <Key>h:            select-all()\n\

Similar sets of translations have been suggested by others.

-------------------------------------------------------------------------------
Subject: 39)* How can I use a file as the text source for a Text widget?

Answer: You can't do it directly like you can with the Athena Text widget.
Instead, read the text from the file into a string (all of it!) and then use
XmTextSetString.  Alternatively, read blocks of characters and add them at the
end of the text using XmTextInsertString.  The following is an excerpt from Dan
Heller's "file_browser.c":

    /* file_browser.c -- use a ScrolledText object to view the
     * contents of arbitrary files chosen by the user from a
     * FileSelectionDialog or from a single-line text widget.
     */

    ...
    struct stat statb;

    /* make sure the file is a regular text file and open it */
    if (stat(filename, &statb) == -1 ||
            (statb.st_mode & S_IFMT) != S_IFREG ||
            !(fp = fopen(filename, "r"))) {
        if ((statb.st_mode & S_IFMT) == S_IFREG)
            perror(filename); /* send to stderr why we can't read it */
        else
            fprintf(stderr, "%s: not a regular file0, filename);
        XtFree(filename);
        return;
    }

    /* put the contents of the file in the Text widget by allocating
     * enough space for the entire file, reading the file into the
     * allocated space, and using XmTextFieldSetString() to show the file.
     */
    if (!(text = XtMalloc((unsigned)(statb.st_size+1)))) {
        fprintf(stderr, "Can't alloc enough space for %s", filename);
        XtFree(filename);
        fclose(fp);
        return;
    }

    if (!fread(text, sizeof(char), statb.st_size+1, fp))
        fprintf(stderr, "Warning: may not have read entire file!0);

    text[statb.st_size] = 0; /* be sure to NULL-terminate */

    /* insert file contents in Text widget */
    XmTextSetString(text_w, text);




-------------------------------------------------------------------------------
Subject: 40) How can put Text in overstrike mode instead of insert?

Answer: There is no direct way. This was posted by Edmond Pitt
(ejp@bohra.cpg.oz) The correct answer to the question is to put the following in
a modifyVerify callback, where 'mvcb' is the XmTextVerifyCallbackStruct, and
'overstriking' is defined by you:

    if (overstriking && mvcb->text->length == 1)
    {
        _XmTextDisableRedisplay(w,FALSE);
        XtCallActionProc(w,"delete-next-character",mvcb->event,0);
        _XmTextEnableRedisplay(w);
    }

_XmText{Dis,En}ableRedisplay() are XmText{Dis,En}ableRedisplay() in 1.0, but
X11R3 has no XtCallActionProc() anyway. For this environment you need my 1.0.3
Text widget patches posted last year & available on request.


-------------------------------------------------------------------------------
Subject: 41) How can make the Delete key do a backspace?

Answer: Put this in your .Xdefaults

    *XmText.translations: #override <Key>osfDelete: delete-previous-character()


Newsgroups: comp.windows.x.motif