home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.uv.es
/
2014.11.ftp.uv.es.tar
/
ftp.uv.es
/
doc
/
FAQ-Motif
< prev
next >
Wrap
Internet Message Format
|
1992-02-11
|
114KB
From: jan@PANDONIA.CANBERRA.EDU.AU (Jan Newmarch)
Newsgroups: comp.windows.x.motif
Subject: (none)
Message-ID: <9201312205.AA26286@pandonia.canberra.edu.au>
Date: 1 Feb 92 14:05:04 GMT
Sender: daemon@ucbvax.BERKELEY.EDU
Distribution: inet
Organization: The Internet
Lines: 968
Subject: Frequently Asked Questions about Motif
Expires: Fri, 6 Mar 92 00:00:00 GMT
[Last changed: 11 Nov 91]
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) Where can I get public domain Motif source?
9) Are the Motif examples publically available?
10) Has anyone done a public domain Motif lookalike?
11) Does anyone from OSF pay attention to our questions/suggestions?
12) Does OSF have an application compliance validation service?
13) What is the motif-talk mailing list?
14) What MIT patches do I use, and when do I use fix-osf?
15) How does Motif work with X11R5?
16) TOPIC: LITERATURE
17) What books should I read or do I need to program using Motif?
18) TOPIC: MWM
19) What is the difference between Motif and mwm?
20) Does anyone have an alternative set of 3-D defaults for a monochrome screen?
21)+ How can I modify the window manager decorations?
22) TOPIC: MOTIF GENERATORS
23)* What prototyping tools are there to generate Motif code?
24) TOPIC: TEXT WIDGET
25) Why does pressing <return> in a text widget do nothing?
26) When I add text to a scrolling text widget how can I get the new text to show?
27) Does the text widget support 16 bit character fonts?
28) How can I stop the text widget from echoing characters typed?
29) How can I replace characters typed with say a `*'?
30) How can I best add a large piece of text to a scrolled text widget?
31) How can I highlight text in the Text widget?
32)+ How can I select all of the text in a widget programmatically?
33) How can I change colours of text in the Text widget?
34) How can I change the font of text in the Text widget?
35) Is there an emacs binding for the text widget?
36) How can I use a file as the text source for a Text widget?
37) How can put Text in overstrike mode instead of insert?
38) How can make the Delete key do a backspace?
39) TOPIC: LIST WIDGET
40) How do I best put a new set of items into a list?
41)+ Can I have strings with different fonts in a list?
42) Can I get a bitmap to show in a list item like I can in a Label?
43) Can I have items with different colours in a list?
44) Can I grey out an item in a list?
45) TOPIC: FILE SELECTION BOX WIDGET
46) What is libPW.a and do I need it?
47) What's wrong with the Motif 1.0 File Selection Box?
48) TOPIC: FORM WIDGET
49) Why don't labels in a Form resize when the label is changed?
50) How can I center a widget in a form?
51) How do I line up two columns of widgets of different types?
52) TOPIC: PUSHBUTTON WIDGET
53) Why can't I use accelerators on buttons not in a menu?
54) TOPIC: LABEL WIDGET
55) How can I align the text in a label (button, etc) widget?
56) Why doesn't label alignment work in a RowColumn?
57) How can I set a multiline label?
58)+ How can I have a vertical label?
59) TOPIC: DRAWING AREA WIDGET
60) How can I send an expose event to a Drawing Area widget?
61) TOPIC: MENUS
62) What can I put inside a menu bar?
63) Can I have a cascade button without a submenu in a pulldown menu?
64) Should I have a cascade button without a submenu in a pulldown menu?
65) TOPIC: INPUT FOCUS
66) How can I direct the keyboard input to a particular widget?
67) How can I have a modal dialog which has to be answered before the application can continue?
68) TOPIC: MEMORY AND SPEED
69) Why does my application grow in size?
70) Why does my application take a long time to start up?
71) My application is running too slowly. How can I speed it up?
72) TOPIC: XMSTRING
73) How can I get the Ascii text out of an XmString?
74) When can XmStrings used as resources be freed?
75) Why doesn't XmStringGetNextSegment() work properly?
76) TOPIC: DIALOGS
77) How do I stop my dialog disappearing when I press the help button?
78) How do I make my own dialog?
79) How come the title bars for my dialogs now have "_popup" or "<-popup" concatenated onto the widget name?
80) How can I force a dialog window to display?
81) How can I control placement of a popup widget?
82) TOPIC: LANGUAGE BINDINGS
83) Is there a C++ binding for Motif?
84) Is there a Common Lisp binding for Motif?
85) Is there an Ada binding for Motif?
86) TOPIC: SPECIFIC PLATFORMS
87) Is it easy to build Motif for a Sun?
88) What compile errors/warnings might I get in both Sun 3 and Sun 4?
89) On a Sun 3, what are the mwm startup error messages about?
90) Are there problems making shared libraries on a Sun?
91) Has anyone made shared libraries on an IBM RS/6000?
92) TOPIC: KEYSYMS
93) What is causing the messages "unknown keysym osfDown..."?
94) What happens if I can't install Motif Keysyms?
95) Why has OSF introduced Keysyms into Motif 1.1?
96) TOPIC: ICONS
97) How can I keep track of changes to iconic/normal window state?
98) How can I check if my application has come up iconic?
99) How can I start my application in iconic state?
100) How can an application iconify itself?
101) How can an application de-iconify itself?
102) TOPIC: MISCELLANEOUS
103)* How can tell I if the user has selected the "Close" item on the system menu attached to the top-level shell?
104) Why does an augment translation appear to act as replace for some widgets?
105) How do you "grey" out a widget so that it cannot be activated?
106) Why doesn't the Help callback work on some widgets?
107) Where can I get a Table widget?
108) Has anyone done a bar graph widget?
109) Does anyone know of a source code of a graph widget
110)* Is there a help system available, such as in Windows 3?
111) Can I specify a widget in a resource file?
112) Why are only some of my translations are being installed?
113) Where can I get the PanHandler code?
114) What are these passive grab warnings?
115) How do I have more buttons than three in a box?
116) 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.72.1.58 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 954211862; 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) Where can I get public domain Motif source?
Answer: You cannot. Motif source is not publically available.
-------------------------------------------------------------------------------
Subject: 9) 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.
-------------------------------------------------------------------------------
Subject: 10) 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.
-------------------------------------------------------------------------------
Subject: 11) 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: 12) 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: 13) 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, citing your Company name and source license number.
-------------------------------------------------------------------------------
Subject: 14) 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: 15) 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 versions of Motif before this 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.
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].
In Motif 1.1, 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.
-------------------------------------------------------------------------------
Subject: 16) TOPIC: LITERATURE
-------------------------------------------------------------------------------
Subject: 17) 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.
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: 18) TOPIC: MWM
-------------------------------------------------------------------------------
Subject: 19) 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: 20) 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: 21)+ 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: 22) TOPIC: MOTIF GENERATORS
-------------------------------------------------------------------------------
Subject: 23)* 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-commnercial 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 fg.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
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: 24) TOPIC: TEXT WIDGET
-------------------------------------------------------------------------------
Subject: 25) 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: 26) 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: 27) 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: 28) 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: 29) 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.
-------------------------------------------------------------------------------
Subject: 30) How can I best add a large piece of text to a scrolled text widget?
It insists on adding the text one line at a time, adjusting the scroll bar each
time. It looks awful and is slow.
Answer: Unmanage the widget, add the text and then manage it again.
-------------------------------------------------------------------------------
Subject: 31) 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: 32)+ 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.
-------------------------------------------------------------------------------
Subject: 33) 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: 34) 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: 35) 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: 36) 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.
-------------------------------------------------------------------------------
Subject: 37) 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: 38) How can make the Delete key do a backspace?
Answer: Put this in your .Xdefaults
*XmText.translations: #override <Key>osfDelete: delete-previous-character()
-------------------------------------------------------------------------------
Subject: 39) TOPIC: LIST WIDGET
-------------------------------------------------------------------------------
Subject: 40) How do I best put a new set of items into a list?
Answer: Set the new list count and list by XtSetArgs and install them by
XtSetValues.
XmString list[SIZE];
int list_size;
XtSetArg (args[n], XmNitemCount, list_size); n++;
XtSetArg (args[n], XmNitems, list); n++;
XtSetValues (w, args, n);
Each time the list is reset by this the old contents are freed by the widget and
the new supplied list is copied. Do *not* free the old list of items yourself
as this would result in the space being freed twice. It is not necessary to
remove the items one at a time, nor to "zero" out the list first.
-------------------------------------------------------------------------------
Subject: 41)+ Can I have strings with different fonts in a list?
Answer: Yes. The strings are XmStrings. Each one can be created using a
different character set using a different font.
-------------------------------------------------------------------------------
Subject: 42) Can I get a bitmap to show in a list item like I can in a Label? I
want to place a bitmap along with some normal text in my list items.
Answer: No. The list contains XmStrings, and these only allow text in various
character sets. The workaround is to define your font containing the icons you
want. Then you can create a fontlist containing your icon font and the font you
want the text in, and then make your items multi-segment XmStrings where the
first segment contains the code of the icon you want with a charset that matches
the icon font in your fontlist and the second segment with a charset matching
the text font.
-------------------------------------------------------------------------------
Subject: 43) Can I have items with different colours in a list?
Answer: No. The list contains XmStrings, and these only allow text in various
character sets. Since the items are XmStrings, you can already change the font
of an item by replacing it with an item with the same text and a different
charset tag. Adding support for color would require modification of the
internal data structure in XmList as well as modification to the drawing
routines. A possible workaround is to use a rowcolumn of buttons which can be
individually set. However, you would have to do all list functionality
yourself.
-------------------------------------------------------------------------------
Subject: 44) Can I grey out an item in a list? I want to make insensitive items
in a list so that they cannot be selected.
Answer:
From W. Scott Meeks of OSF:
Unfortunately, you can't do it directly since the list items aren't individual
widgets. We've had other requests for this technology, but it didn't make the
cut for 1.2; it should be in some future release.
However, you can probably fake it in your application with some difficulty.
First, a list item is an XmString, so you can specify a different charset for
the item than for other items in the list and then specify a font in the list's
fontlist that matches the charset and gives you the visual you want. The next
problem is making the item unselectable. One idea would be to have the
application keep track of the insensitive items and the items currently
selected. Then you would set up a selection callback that when called would
check the item selected against the list of insensitive items and if the
selected item matched would deselect that item and reselect the previously
selected items. Otherwise it would just update the application's list of
selected items. The major drawback with this approach is that you'll get
flashing whenever the list selects an item and your application immediately de-
selects. Unfortunately I can't think of a way around this without mucking with
the list internals.
Another alternative suggested is to use instead a column of say read only text
widgets which you can make insensitive.
-------------------------------------------------------------------------------
Subject: 45) TOPIC: FILE SELECTION BOX WIDGET
-------------------------------------------------------------------------------
Subject: 46) What is libPW.a and do I need it? My manual says I need to link in
libPW.a to use the File Selection Box. I can't find it on my system.
Answer: The libPW.a is the Programers Workbench library which is an ATT product
not included in Berkeley based systems, hence it is not found in SunOS or
Ultrix, but is found on HP-UX (a Berkeley/ATT hybrid which chose ATT in this
case). It contains the regex(3) routines. Some systems which don't have these
in the libc.a need to link with -lPW. Some systems which have the regex(3)
routines in there also have the libPW.a. If you have regex(3) in libc, and it
works, don't link with libPW. If you don't have regex(3) in libc, and you don't
have a libPW, then check some sites on the net for public domain replacements
(several exist), or call your vendor.
In most versions of Motif (see the doco), you can compile FileSB.c with
-DNO_REGEX if you don't have it.
-------------------------------------------------------------------------------
Subject: 47) What's wrong with the Motif 1.0 File Selection Box? I can't set
the directory, change the directory or get the file mask to work.
Answer: The 1.0 File Selection Box is broken, and these don't work. They
weren't fixed until Motif 1.04. Use these later versions of 1.0 or switch to
Motif 1.1 where it changed a lot.
Joe Hildebrand has a work-around for some of this: Before popping up an
XmFileSelectionDialog, change to the directory you want. When a file is
selected, check if it is a directory, so that we can change to it. i.e.
static void show_file_box_CB(w, client_data, call_data)
Widget w;
Widget client_data;
XmAnyCallbackStruct *call_data;
{
chdir("/users/hildjj/files");
XtManageChild(client_data);
}
static void val_save(w, client_data, call_data)
Widget w;
Widget client_data;
XmSelectionBoxCallbackStruct *call_data;
{
struct stat buf; /* struct stat is defined in stat.h */
char *filename;
/* get the file name from the FileSelectionBox */
filename = SmX(call_data->value);
/* get the status of the file named filename, and put it into buf */
if (!stat(filename, &buf))
{
/* if it's a directory */
/* if it's a directory */
if(S_ISDIR(buf.st_mode))
{
/* change to that directory, and update the FileSelectionBox */
chdir(filename);
XmFileSelectionDoSearch(w, NULL);
}
else
/* if it's a regualr file */
if(S_ISREG(buf.st_mode))
/* ask if it should be overwritten */
XtManageChild(valbox);
else
/* it's another kind of file. What type, i can't think of,
but it might happen */
pop_up_error_box(client_data, "Error saving file");
}
else /* we couldn't get the file status */
{
/* if it's because the file doesn't exist, we're golden */
if (errno == ENOENT)
save_file();
else /* there is some other problem getting the status.
e.g. bad path */
pop_up_error_box(client_data, "Error saving file");
}
}
this still doesn't implement the file masking stuff.
-------------------------------------------------------------------------------
Subject: 48) TOPIC: FORM WIDGET
-------------------------------------------------------------------------------
Subject: 49) Why don't labels in a Form resize when the label is changed? I've
got some labels in a form. The labels don't resize whenever the label string
resource is changed. As a result, the operator has to resize the window to see
the new label contents. I am using Motif 1.1.
Answer: This problem may happen to any widget inside a Form widget. The problem
was that the Form will resize itself when it gets geometry requests from its
children. If its preferred size is not allowed, the Form will disallow all
geometry requests from its children. The workaround is that you should set any
ancestor of the Form to be resizable. For the shell which contains the Form you
should set the shell resource XmNallowShellResize to be True (by default, it is
set to FALSE). There is currently an inconsistency on how resizing is being
done, and it may get fixed in Motif 1.2.
-------------------------------------------------------------------------------
Subject: 50) How can I center a widget in a form?
Answer: One of Motif's trickier questions. The problems are that: Form gives no
support for centering, only for edge attachments, and the widget must stay in
the center if the form or the widget is resized. Just looking at horizontal
centering (vertical is similar) some solutions are:
a. Use the table widget instead of Form.
b. This is complex, but can be used for arbitrary placement. It is an amalgam
of several suggestions, and all bits seem to be needed. Create an `anchor'
in the middle of the form. Use a widget of zero width and height for this
(e.g. a separator). Place this anchor in the form where you want it to
stay (attach position to 50 for centering). You want the middle of the
widget to be over the anchor (and stay there even if the form is resized).
You don't know where the middle of the widget is until you know its size,
and you won't know that until you manage it. So create and manage the
widget and use XtGetValues to find its width. Then attach its left
position to half the width from the anchor. Doing this will move the
widget. Depending upon the order in which widgets are managed and realized
the widget may be visible after it has been managed and so will `flicker'
when it is moved. If this happens, set mappedWhenManaged to False so that
it doesn't show until you map it yourself.
n = 0;
XtSetArg (args[n], XmNseparatorType, XmNO_LINE); n++;
XtSetArg (args[n], XmNleftAttachment, XmATTACH_POSITION); n++;
XtSetArg (args[n], XmNleftPosition, 50); n++;
anchor = XmCreateSeparator (form, "anchor", args, n);
XtManageChild (anchor);
n = 0;
XtSetArg (args[n], XmNmappedWhenManaged, False); n++;
button = XmCreatePushButton (form, "Center Button", args, n);
XtManageChild (button);
n = 0;
XtSetArg (args[n], XmNwidth, (Dimension *) &width); n++;
XtGetValues (button, args, n);
n = 0;
XtSetArg (args[n], XmNleftAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
XtSetArg (args[n], XmNleftWidget, anchor); n++;
XtSetArg (args[n], XmNleftOffset, -width/2); n++;
XtSetValues (button, args, n);
XtMapWidget (button);
This does not center the widget correctly if it is resized by the
application (say by changing its label) - you have to fix it up yourself by
resetting the left offset.
c. Attach the things you want centered to the middle of the form (attach
position to 50%), and then set the offest to half the width or height
(calculated as in the previous solution). The documentation for Form
states that this will not work. I can't get it to work (Motif 1.1.0), but
some people say that it works just fine (Motif 1.1.1, 1.1.2).
d. No uil solution has been suggested, because of the wieget size problem
-------------------------------------------------------------------------------
Subject: 51) How do I line up two columns of widgets of different types? I have
a column of say label widgets, and a column of text widgets and I want to have
them lined up horizontally. The problem is that they are of different heights.
Just putting them in a form or rowcolumn doesn't line them up properly because
the label and text widgets are of different height. I also want the labels to
be right adjusted e.g.
-------------------------------------
| ---------------- |
| a label |Some text ||
| ---------------- |
---------------- |
| a longer label |Some more text ||
| ---------------- |
| ---------------- |
|a very long label |Even more text ||
| ---------------- |
-------------------------------------
Answer: To get the widgets lined up horizontally, use a form but place the
widgets using XmATTACH_POSITION. In the example, attach the top of the first
label to the form, the bottomPosition to 33 (33% of the height). Attach the
topPosition of the second label to 33 and the bottomPosition to 66. Attach the
topPosition of the third label to 66 and the bottom of the label to the form.
Do the same with the text widgets.
To get the label widgets lined up vertically, use the right attachment of
XmATTACH_OPPOSITE_WIDGET: starting from the one with the longest label, attach
widgets on the right to each other. In the example, attach the 2nd label to the
third, and the first to the second. To get the text widgets lined up, just
attach them on the left to the labels. To get the text in the labels aligned
correctly, use XmALIGNMENT_END for the XmNalignment resource.
/* geometry for label 2
*/
n = 0;
XtSetArg (args[n], XmNalignment, XmALIGNMENT_END); n++;
XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
XtSetArg (args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
XtSetArg (args[n], XmNtopAttachment, XmATTACH_POSITION); n++;
XtSetArg (args[n], XmNtopPosition, 66); n++;
XtSetValues (label[2], args, n);
/* geometry for label 1
*/
n = 0;
XtSetArg (args[n], XmNalignment, XmALIGNMENT_END); n++;
XtSetArg (args[n], XmNbottomAttachment, XmATTACH_POSITION); n++;
XtSetArg (args[n], XmNbottomPosition, 66); n++;
XtSetArg (args[n], XmNtopAttachment, XmATTACH_POSITION); n++;
XtSetArg (args[n], XmNtopPosition, 33); n++;
XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
XtSetArg (args[n], XmNrightAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
XtSetArg (args[n], XmNrightWidget, label[2]); n++;
XtSetValues (label[1], args, n);
/* geometry for label 0
*/
n = 0;
XtSetArg (args[n], XmNalignment, XmALIGNMENT_END); n++;
XtSetArg (args[n], XmNbottomAttachment, XmATTACH_POSITION); n++;
XtSetArg (args[n], XmNbottomPosition, 33); n++;
XtSetArg (args[n], XmNtopAttachment, XmATTACH_FORM); n++;
XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
XtSetArg (args[n], XmNrightAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
XtSetArg (args[n], XmNrightWidget, label[1]); n++;
XtSetValues (label[0], args, n);
/* geometry for text 0
*/
n = 0;
XtSetArg (args[n], XmNtopAttachment, XmATTACH_FORM); n++;
XtSetArg (args[n], XmNbottomAttachment, XmATTACH_POSITION); n++;
XtSetArg (args[n], XmNbottomPosition, 33); n++;
XtSetArg (args[n], XmNrightAttachment, XmATTACH_FORM); n++;
XtSetArg (args[n], XmNleftAttachment, XmATTACH_WIDGET); n++;
XtSetArg (args[n], XmNleftWidget, label[0]); n++;
XtSetValues (text[0], args, n);
/* geometry for text 1
*/
XtSetArg (args[n], XmNtopAttachment, XmATTACH_POSITION); n++;
XtSetArg (args[n], XmNtopPosition, 33); n++;
XtSetArg (args[n], XmNbottomAttachment, XmATTACH_POSITION); n++;
XtSetArg (args[n], XmNbottomPosition, 66); n++;
XtSetArg (args[n], XmNrightAttachment, XmATTACH_FORM); n++;
XtSetArg (args[n], XmNleftAttachment, XmATTACH_WIDGET); n++;
XtSetArg (args[n], XmNleftWidget, label[1]); n++;
XtSetValues (text[1], args, n);
/* geometry for text 2
*/
XtSetArg (args[n], XmNtopAttachment, XmATTACH_POSITION); n++;
XtSetArg (args[n], XmNtopPosition, 66); n++;
XtSetArg (args[n], XmNrightAttachment, XmATTACH_FORM); n++;
XtSetArg (args[n], XmNleftAttachment, XmATTACH_WIDGET); n++;
XtSetArg (args[n], XmNleftWidget, label[2]); n++;
XtSetArg (args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
XtSetValues (text[2], args, n);
-------------------------------------------------------------------------------
Subject: 52) TOPIC: PUSHBUTTON WIDGET
-------------------------------------------------------------------------------
Subject: 53) Why can't I use accelerators on buttons not in a menu?
Answer: It is apparently a difficult feature to implement, but OSF are
considering this for the future. It is problematic trying to use the Xt
accelerators since the Motif method interferes with this. The workaround
suggested so far is to duplicate your non-menu button by a button in a menu
somewhere, which does have a menu-accelerator installed. When the user invokes
what they think is the accelerator for the button they can see Motif actually
invokes the button on the menu that they can't see at the time.
-------------------------------------------------------------------------------
Subject: 54) TOPIC: LABEL WIDGET
-------------------------------------------------------------------------------
Subject: 55) How can I align the text in a label (button, etc) widget?
Answer: The alignment for the label widget is controlled by the resource
XmNalignment, and the default centers the text. Use this resource to change it
to left or right alignment. However, when the label (or any descendant) is in a
row column, and XmNisAligned is True (the default), the row column aligns text
using its resource XmNentryAlignment. If you want simultaneous control over all
widgets use this, but otherwise turn XmNisAligned off and do it individually.
-------------------------------------------------------------------------------
Subject: 56) Why doesn't label alignment work in a RowColumn?
Answer: RowColumn has a resource XmNisAligned (default True) and and
XmNentryAlignment (default XmALIGNMENT_BEGINNING). These control alignment of
the labelString in Labels and descendants. Set XmNisAligned to False to turn
this off.
-------------------------------------------------------------------------------
Subject: 57) How can I set a multiline label?
Answer: In .Xdefaults
*Label*labelString: Here\nis\nthe\nLabel
In code,
char buf[128];
XmString msg;
sprintf(buf, "Here\nis\nthe\nLabel");
msg = XmStringCreateLtoR(buf, XmSTRING_DEFAULT_CHARSET);
XtSetArg (args[n], XmNlabelString, msg);
Gives a four line label, using the escape sequence \n for a newline.
-------------------------------------------------------------------------------
Subject: 58)+ How can I have a vertical label?
Answer: Make a multiline label with one character per line, as in the last
question. There is no way to make the text rotated by 90 degrees though.
-------------------------------------------------------------------------------
Subject: 59) TOPIC: DRAWING AREA WIDGET
-------------------------------------------------------------------------------
Subject: 60) How can I send an expose event to a Drawing Area widget? (or any
other, come to that). I want to send an expose event so that it will redraw
itself.
Answer: Use the Xlib call
XClearArea(XtDisplay(w), XtWindow(w), 0, 0, 0, 0, True)
This clears the widget's window and generates an expose event in doing so. The
widgets expose action will then redraw it. This uses a round trip request. An
alternative, without the round trip is
From schulert@alfalfa.com Mon Apr 29 17:31:55 1991
Widget da;
XmDrawingAreaCallbackStruct da_struct;
da_struct.reason = XmCR_EXPOSE;
da_struct.event = (XEvent *) NULL;
da_struct.window = XtWindow(da);
XtCallCallbacks(da, XmNexposeCallback, (XtPointer) da_struct);
-------------------------------------------------------------------------------
Subject: 61) TOPIC: MENUS
-------------------------------------------------------------------------------
Subject: 62) What can I put inside a menu bar?
Answer: You can only put cascade buttons in menu bars. No pushbuttons, toggle
buttons or gadgets are allowed. When you create a pulldown menu with parent a
menu bar, its real parent is a shell widget.
-------------------------------------------------------------------------------
Subject: 63) Can I have a cascade button without a submenu in a pulldown menu?
Answer: Yes you can. A cascade button has an activate callback which is called
when you click on it and it doesn't have a submenu. It can have a mnemonic, but
keyboard traversal using the arrow keys in the menu will skip over it.
-------------------------------------------------------------------------------
Subject: 64) Should I have a cascade button without a submenu in a pulldown
menu?
Answer: No. This is forbidden by the style guide. Technically you can do it (see
previous question) but if you do it will not be Motif style compliant. This is
unlikely to change - if a "button" is important enough to be in a pulldown menu
bar with no pulldown, it should be a button elsewhere. (Mind you, you won't be
able to put accelerators on it elsewhere though.)
-------------------------------------------------------------------------------
Subject: 65) TOPIC: INPUT FOCUS
-------------------------------------------------------------------------------
Subject: 66) How can I direct the keyboard input to a particular widget?
Answer: In Motif 1.1 call XmProcessTraversal(target, XmTRAVERSE_CURRENT). The
widget (and all of its ancestors) does need to be realized BEFORE you call this.
Otherwise it has no effect. XmProcessTraversal is reported to have many bugs,
so it may not work right. A common occurrence is that it doesn't move to the
widget, but if you call XmProcessTraversal *twice* in a row, it will. If you
can't get it to work, try this from Kee Hinckley:
// This insane sequence is as follows:
// On manage set up a focus callback
// On focus callback set up a timer (and get rid of focus callback!)
// On timer set the focus (which only works if the parent
// has the focus,
// which is why we went through all of this garbage)
// There may be a better way, but I haven't time to try it now.
//
static void focusTO(void *data, XtIntervalId *) {
XmProcessTraversal((Widget) data, XmTRAVERSE_CURRENT);
}
static void focusCB(Widget w, XtPointer data, XtPointer) {
XtRemoveCallback(w, XmNfocusCallback, focusCB, data);
XtAppAddTimeOut(XtWidgetToApplicationContext(w), 0, focusTO, data);
}
void OmXSetFocus(Widget parent, Widget w) {
XtAddCallback(parent, XmNfocusCallback, focusCB, w);
}
In Motif 1.0 call the undocumented _XmGrabTheFocus(target).
Do not use the X or Xt calls such as XtSetKeyboardFocus since this bypasses the
Motif traversal layer and can cause it to get confused. This can lead to odd
keyboard behaviour elsewhere in your application.
-------------------------------------------------------------------------------
Subject: 67) How can I have a modal dialog which has to be answered before the
application can continue?
Answer: The answer depends on whether you are using the Motif window manager mwm
or not. If you are, there is a simple solution. If not (or you don't know
whether you are or not), you have to use a slightly harder method. Test for
this by XmIsMotifWMRunning.
The window manager mwm knows how to control event passing to dialog widgets
declared as modal. If the dialog is set to application modal, then no
interaction with the rest of the application can occur until the dialog is
destroyed or unmanaged. This can be done through one of the callbacks of the
dialog:
block_dialog(parent)
Widget parent;
{
Arg args[2];
XtSetArg(args[0], XmNmessageString,
XmStringCreateLtoR("....", charset));
XtSetArg(args[1], XmNdialogStyle,
XmDIALOG_APPLICATION_MODAL);
dialog = XmCreateMessageDialog(parent, NULL, args, 2);
XtAddCallback(dialog, XmNokCallback, responseCB, NULL);
XtAddCallback(dialog, XmNcancelCallback, responseCB, NULL);
XtAddCallback(dialog, XmNhelpCallback, responseCB, NULL);
XtManageChild(dialog);
}
void responseCB(w, client_data, reason)
Widget w;
caddr_t client_data;
XmAnyCallbackStruct *reason;
{ int why = reason->reason;
XtUnmanageChild(w);
/* if you won't use it again */
XtDestroyWidget(XtParent(w));
switch (why) {
case XmCR_OK:
/* process ok action */
break;
case XmCR_CANCEL:
/* process cancel action */
break;
case XmCR_HELP:
/* process help action */
break;
}
}
Without using mwm, the basic version goes like this: You have to set an Xt grab
to the dialog and run your own event processing loop. This loop finishes when
the user invokes a callback from a button press. The boolean `keep_grab' is
passed to the callback as client data which sets it to false when the callback
is executed.
static Boolean keep_grab; /* static required to stop some optimisers
discarding it as unused */
XEvent event;
Arg args[1];
keep_grab = True;
XtSetArg(args[0], XmNmesssageString, ...);
dialog = XmCreateMessageDialog(parent, NULL, args, 1);
XtAddCallback(dialog, XmNokCallback, responseCB, &keep_grab);
XtAddCallback(dialog, XmNcancelCallback, responseCB, &keep_grab);
XtAddCallback(dialog, XmNhelpCallback, responseCB, &keep_grab);
XtManageChild(dialog);
XtAddGrab(XtParent(dialog), True, False);
while (keep_grab || XtPending()) {
XtNextEvent(&event);
XtDispatchEvent(&event);
}
The "client_data" for the function (in each case) is &keep_grab. The function
sets this to False and unmanages the dialog before continuing to process the
callback.
void
responseCB(w, keep_grab, reason)
Widget w;
Boolean *keep_grab;
XmAnyCallbackStruct *reason;
{ int why = reason->reason;
*keep_grab = False;
XtRemoveGrab(XtParent(w));
XtUnmanageChild(w);
/* If you don't want to reuse it */
XtDestroyWidget(XtParent(w));
switch (why) {
case XmCR_OK:
/* process ok action */
break;
case XmCR_CANCEL:
/* process cancel action */
break;
case XmCR_HELP:
/* process help action */
break;
}
}
-------------------------------------------------------------------------------
Subject: 68) TOPIC: MEMORY AND SPEED
-------------------------------------------------------------------------------
Subject: 69) Why does my application grow in size?
Answer: Motif 1.0 has many memory leaks, particularly in XmString manipulation.
Switch to Motif 1.1.
Answer: The Intrinsics have a memory leak in accelerator table management, and
Motif uses this heavily. Avoid this by mapping/unmapping widgets rather than
creating/destroying them, or get X11R4 fix-15/16/17.
Answer: The server may grow in size due to its own memory leaks. Switch to a
later server.
Answer: You are responsible for garbage collection in `C'. Some common cases
where a piece of memory becomes garbage are
a. Memory is allocated for a character string by Motif in XmStringGetLtoR().
After using the string, XtFree() it.
b. If you have set the label in a label, pushbutton, etc widget, free it after
calling XtSetValues() or the widget creation routine by XmStringFree().
c. If you have set text in a text widget, reclaim the string afterwards - the
text widget makes its own copy.
d. If you have set the strings in a list widget, reclaim the space. The list
widget makes its own copy.
-------------------------------------------------------------------------------
Subject: 70) Why does my application take a long time to start up?
Answer: If you have a large .Xdefaults, time may be spent reading and parsing
it.
-------------------------------------------------------------------------------
Subject: 71) My application is running too slowly. How can I speed it up?
Answer: Use the R4 rather than R3 server. It is much faster.
Answer: The standard memory allocator is not well tuned to Motif, and can
degrade performance. Use a better allocator. e.g. with SCO Unix, link with
libmalloc.a; use the allocator from GNU emacs; use the allocator from Perl.
Answer: Avoid lots of widget creation and destruction. It fragments memory and
slows everything down. Popup/popdown, manage/unmanage instead.
Answer: Set mappedWhenManaged to FALSE, and then call XtMapWidget()
XtUnmapWidget() rather than managing.
Answer: Get more memory - your application, the server and the Operating System
may be spending a lot of time being swapped.
Answer: If you are doing much XmString work yourself, such as heavy use of
XmStringCompare, speed may deteriorate due to the large amount of internal
conversions and malloc'ing. Try using XmStringByteCompare if appropriate or
ordinary Ascii strings if you can.
-------------------------------------------------------------------------------
Subject: 72) TOPIC: XMSTRING
-------------------------------------------------------------------------------
Subject: 73) How can I get the Ascii text out of an XmString?
Answer: To get the first line of text from a string created left-to-right
char *str;
XmString xmstr;
/* stuff to create xmstr */
...
/* set str to point to the text */
XmStringGetLtoR(xmstr, XmSTRING_DEFAULT_CHARSET, &str);
/* use the string */
...
/* and reclaim space */
XtFree(str);
-------------------------------------------------------------------------------
Subject: 74) When can XmStrings used as resources be freed?
Answer: The policy OSF have been trying to enforce is that if you set an
XmString or XmStringTable resource, the application is responsible for freeing
the XmStrings used because the widget makes a copy. If you get an XmString
resource, then the application must free the value gotten. If you get an
XmStringTable, then the application should NOT free the value gotten. If the
application wants to manipulate it, it should make a copy first. This policy
appears to be implemented progressively, so may be less true for Motif 1.0 than
1.1.
-------------------------------------------------------------------------------
Subject: 75) Why doesn't XmStringGetNextSegment() work properly?
Answer: The documentation in Motif 1.0 is in error. Instead of
XmStringGetnextSegment(context, ...)
XmStringContext * context;
it should be
XmStringGetnextSegment(context, ...)
XmStringContext context;
i.e. with no indirection.
-------------------------------------------------------------------------------
Subject: 76) TOPIC: DIALOGS
-------------------------------------------------------------------------------
Subject: 77) How do I stop my dialog disappearing when I press the help button?
Answer: Bulletin board has the resource autoUnmanage which defaults to True.
This unmanages the widget when any button child is activated - including the
help button. Set this to False to stop it disappearing. Note that you then have
to unmanage the bulletin board yourself when any other button is activated.
-------------------------------------------------------------------------------
Subject: 78) How do I make my own dialog? I want a dialog with my own set of
buttons that stretch and shrink like the ones in e.g. PromptDialog and its own
contents.
Answer: Start off with say a PromptDialog. Unmanage the buttons you don't want
or manage the Apply button if you want another. Unmanage the other bits of the
selection box you don't want. You can add another WorkArea child to the
selection box for any extra stuff you want.
/* Copyright 1990, Kee Hinckley and Brian Holt Hawthorne */
/* Permission granted for any use, provided this copyright */
/* notice is maintained. */
/* Create a dialog box */
argcount = setArgs(&args, XmNautoUnmanage, False, NULL);
SomeDialog = XmCreatePromptDialog(mainShell, "someDialog", args, argcount);
/* Now get rid of the things we don't want */
child = XmSelectionBoxGetChild(SomeDialog, XmDIALOG_SELECTION_LABEL);
XtUnmanageChild(child);
child = XmSelectionBoxGetChild(SomeDialog, XmDIALOG_TEXT);
XtUnmanageChild(child);
/* set the callbacks, and make sure the buttons we want are there */
child = XmSelectionBoxGetChild(SomeDialog, XmDIALOG_OK_BUTTON);
XtAddCallback(child, XmNactivateCallback, callSomeFunc, someArg);
XtAddCallback(child, XmNactivateCallback, unManage, SomeDialog);
XtManageChild(child);
child = XmSelectionBoxGetChild(SomeDialog, XmDIALOG_APPLY_BUTTON);
XtAddCallback(child, XmNactivateCallback, callSomeFunc, someOtherArg);
XtManageChild(child);
child = XmSelectionBoxGetChild(SomeDialog, XmDIALOG_CANCEL_BUTTON);
XtAddCallback(child, XmNactivateCallback, dialogUnmanage, SomeDialog);
XtManageChild(child);
/* Add a new work area. This can be any manager. */
child = XmCreateForm(SomeDialog, "someForm", NULL, 0);
XtManageChild(child);
/* and fill it up... */
something = doYourStuff(child);
-------------------------------------------------------------------------------
Subject: 79) How come the title bars for my dialogs now have "_popup" or "<-
popup" concatenated onto the widget name?
Answer: Motif 1.0.3 (?) "fixed" things such that title bars without an explicit
dialogTitle setting use the widget name with "_popup" or whatever added on. Set
the dialogTitle resource explicitly if you don't want this new default naming
scheme.
-------------------------------------------------------------------------------
Subject: 80) How can I force a dialog window to display? I manage a "working"
dialog, and do some computing, but the dialog window appears blank until the
work has finished. How can I force it to be displayed?
Answer: Use this. (David Brooks, Systems Engineering, Open Software Foundation)
/*
* This procedure will ensure that, if a dialog window is being mapped,
* its contents become visible before returning. It is intended to be
* used just before a bout of computing that doesn't service the display.
* You should still call XmUpdateDisplay() at intervals during this
* computing if possible.
*
* The monitoring of window states is necessary because attempts to map
* the dialog are redirected to the window manager (if there is one) and
* this introduces a significant delay before the window is actually mapped
* and exposed. This code works under mwm, twm, uwm, and no-wm. It
* doesn't work (but doesn't hang) with olwm if the mainwindow is iconified.
*
* The argument to ForceDialog is any widget in the dialog (often it
* will be the BulletinBoard child of a DialogShell).
*/
ForceDialog(w)
Widget w;
{
Widget diashell, topshell;
Window diawindow, topwindow;
Display *dpy;
XWindowAttributes xwa;
XEvent event;
XtAppContext cxt;
/* Locate the shell we are interested in. In a particular instance, you
* may know these shells already.
*/
for (diashell = w;
!XtIsShell(diashell);
diashell = XtParent(diashell))
;
/* Locate its primary window's shell (which may be the same) */
for (topshell = diashell;
!XtIsTopLevelShell(topshell);
topshell = XtParent(topshell))
;
if (XtIsRealized(diashell) && XtIsRealized(topshell)) {
dpy = XtDisplay(topshell);
diawindow = XtWindow(diashell);
topwindow = XtWindow(topshell);
cxt = XtWidgetToApplicationContext(diashell);
/* Wait for the dialog to be mapped. It's guaranteed to become so unless... */
while (XGetWindowAttributes(dpy, diawindow, &xwa),
xwa.map_state != IsViewable) {
/* ...if the primary is (or becomes) unviewable or unmapped, it's
probably iconified, and nothing will happen. */
if (XGetWindowAttributes(dpy, topwindow, &xwa),
xwa.map_state != IsViewable)
break;
/* At this stage, we are guaranteed there will be an event of some kind.
Beware; we are presumably in a callback, so this can recurse. */
XtAppNextEvent(cxt, &event);
XtDispatchEvent(&event);
}
}
/* The next XSync() will get an expose event if the dialog was unmapped. */
XmUpdateDisplay(topshell);
}
-------------------------------------------------------------------------------
Subject: 81) How can I control placement of a popup widget? Each time a popup
is created, it is placed in or over the middle of its parent. How can I make it
obey the XmNx and XmNy values?
Answer: Set the resource XmNdefaultPosition for the popup to False. Set the
position of the popup by the resource values of XmNx and XmNy. Do not use
XtMoveWidget, as this is for widget writers only.
-------------------------------------------------------------------------------
Subject: 82) TOPIC: LANGUAGE BINDINGS
-------------------------------------------------------------------------------
Subject: 83) Is there a C++ binding for Motif?
Answer: The University of Lowell has a C++ binding. The software is available
on any system running X11R3. Currently it is available for both the GNU's C++
compiler g++ v 1.37.1 and the AT&T C++ v 2.0 translator. The software is
available through either ftp or a 9 track reel magnetic tape for $250. A license
must be purchased first. For additional information and license forms contact :
University of Lowell
Graphics Research Laboratory/Motif
Computer Science Department
One University Avenue
Lowell, MA 01854
attn : Fran Ward
(phone 508-934-3628)
Once you have the license you can legitimately ftp it from 129.63.1.1 in file
graphics/MotifC++/Motif1.1-g++.tar.Z
Answer: WWL is a library which defines C++ classes around X Toolkit Widgets. It
is intended to simplify the task of C++ code writers when using the Toolkit by
providing them with C++ objects, methods, type checking and several utility
functions and classes.
WWL has been tested under SunOs4.0.3 on sun3 and sun4, HPUX version 6.5 and 7.0
and Ultrix 4.0 on DECstation 3100 and 5000. It is expected to work on most other
UNIX systems without too many problems.
WWL is distributed as a tar file with all the source, documentation and example.
The file is available using anonymous ftp from
export.lcs.mit.edu (18.30.0.238 contrib/WWL-1.0.tar.Z
lri.lri.fr (129.175.15.1) pub/WWL-1.0.tar.Z
-------------------------------------------------------------------------------
Subject: 84) Is there a Common Lisp binding for Motif? Answer: Try CLM. This
includes a toolkit demon (in C) that takes a widget description (with
callbacks), and forks a new process for each Motif application (which can be
just a single menu, or whatever). Lisp can then continue running, with a
separate lightweight lisp process handling the connection & callbacks. In North
America & net environs, CLM-2.0beta is available from export.lcs.mit.edu.
-------------------------------------------------------------------------------
Subject: 85) Is there an Ada binding for Motif?
Answer: The situation is getting better.
From Todd W. Lainhart: Take a look at THINGS, a VAPI with Ada bindings that was
written by the US Air Force (SAC). It's in the public domain, and available
from export or gatekeeper.dec.com. It implements Motif or OL look-and-feel. [I
had a look and it seemed to be missing documentation - Jan]
From David Lewis: A company called Rational appears to be making an Xm
implementation. Also GHG in Texas has most other Xlib and Xt bindings for Ada.
From comp.windows.x FAQ: Ada bindings to Motif, explicitly, will eventually be
made available by the Jet Propulsion Laboratories, probably through the normal
electronic means. Advance information can be obtained from
dsouleles@dsfvax.jpl.nasa.gov, who may respond as time permits. Another set of
bindings for Motif is being done by the University of Lowell; information is
available from osfri@osf.org.[11/90]
Telesoft is reported to be in the process of negotiating an agreement to license
and distribute OSF/Motif Ada bindings with delivieries beginning in June
(anticipated). The person to contact is:
Bruce Sherman
Vice President
Corporate Communications for Telesoft
5959 Conerstone Court West
San Diego, CA 92121-9891
(619)457-2700
Fax (619)452-1334
email: ucsd!telesoft!bds
TAE Plus will generate either Ada or C. Contact
Goddard Space Flight Center
TAE Suppport Office
Code 522
Attn: Arleen Yeager
Greenbelt, MD 20771
301-286-6034
FTS 888-6034
e-mail: taeso@postman.gsfc.nasa.gov
TELEMAIL from a NASA facility: TELEMAIL outside of NASA:
[TAESO/GSFCMAIL]GSFC [TAESO/GSFCMAIL]GSFC/USA
SPAN is 6162::TAESO
-------------------------------------------------------------------------------
Subject: 86) TOPIC: SPECIFIC PLATFORMS
-------------------------------------------------------------------------------
Subject: 87) Is it easy to build Motif for a Sun?
Answer: No pattern has emerged to problems about compiling Motif on the Sun
(although people seem to have a lot of different minor problems), and many
reports are that it is straightforward. Read the Motif install instructions
(which often have specific reference to Sun installation), light the blue touch
paper and just standback. [My experience was that I had to add -D_NO_PROTO for
1.1 on a Sparc OS 4.1, and that was all].
-------------------------------------------------------------------------------
Subject: 88) What compile errors/warnings might I get in both Sun 3 and Sun 4?
Answer:
make: Warning: Too many rules defined for target
make: Warning: Too many rules defined for target
"callbacks.c", line 1530: warning: illegal combination of pointer
and integer, op =
"callbacks.c", line 1531: warning: illegal combination of pointer
and integer, op =
"callbacks.c", line 1532: warning: illegal combination of pointer
and integer, op =
"utils.c", line 73: warning: illegal combination of pointer and integer, op =
"utils.c", line 74: warning: illegal combination of pointer and integer, op =
"utils.c", line 122: warning: illegal combination of pointer and integer, op =
"utils.c", line 123: warning: illegal combination of pointer and integer, op =
"utils.c", line 191: warning: illegal combination of pointer and integer, op =
"utils.c", line 194: warning: illegal combination of pointer and integer, op =
"utils.c", line 195: warning: illegal combination of pointer and integer, op =
"utils.c", line 196: warning: illegal combination of pointer and integer, op =
"utils.c", line 316: warning: illegal combination of pointer and integer, op =
"utils.c", line 334: warning: illegal combination of pointer and integer, op =
"utils.c", line 338: warning: illegal combination of pointer and integer, op =
"utils.c", line 341: warning: illegal combination of pointer and integer, op =
"xmdialogs.c", line 838: warning: illegal combination of pointer
and integer, op =
"xmeditor.c", line 1152: warning: illegal combination of pointer
and integer, op =
These warning messages can be ignored. OSF is aware of these warnings.
-------------------------------------------------------------------------------
Subject: 89) On a Sun 3, what are the mwm startup error messages about? I get
mwm: Invalid accelerator specification on line 7 of
specification string
mwm: Invalid accelerator specification on line 31 of
configuration file
Answer: This is because some Sun keyboards do not have an F10 key and some sun
workstations which have an F10 key do not have X-servers which recognize it.
The F10 key is used by mwm. If the machine does have an F10 key, the user
should use xmodmap to tell the server it exists. Otherwise, change the
definition of the DefaultWindowMenu in /usr/lib/X11/system.mwmrc (after
installation) or in /lib/clients/mwm/system.mwmrc (before installation). Change
the accelerator of "Maximize" (it is "Alt<Key>F10)" to something else. Also, you
should change the definition of DEFAULTSYSTEMMENU in the file
/clients/mwm/WmResource.c in a similar fashion. There is as yet no standard
redefinition for F10.
-------------------------------------------------------------------------------
Subject: 90) Are there problems making shared libraries on a Sun?
Answer: If you use the -pic option you may run out of offset table space. use
the -PIC option instead.
You may get the message "ld.so: Undefined symbol: __XtInherit" when executing
UIL. There is a problem in shared library build when you compare a function
variable to a routine name, but don't call the routine. Either, you can build
the Xt library nonshared, or you can put a reference to XtToolkitInitialize in
the UIL main program (or even include a module that references it). The routine
doesn't even have to be called; it just has to be there.
-------------------------------------------------------------------------------
Subject: 91) Has anyone made shared libraries on an IBM RS/6000?
Answer: From Sakari Jalovaara: There is a problem: Xm redefines VendorShell and
the AIX linker put _both_ Xm's and Xt's VendorShell into programs. When an AIX
shared library is created as many references inside the library are resolved as
possible. If the symbol vendorShellClassRec is defined in libXt and referenced,
say, from a function XtFoo() also in libXt, the "ld" run that creates the shared
library resolves the reference:
XtFoo() -> vendorShellClassRec
Then I create the Motif library that has its own vendorShellClassRec and an
XmBar() function that uses it; libXm will also contain a resolved reference to
vendorShellClassRec:
XmBar() -> vendorShellClassRec
Finally, I link a program that uses both XtFoo() and XmBar() and the program
will end up with _two_ independent "vendorShellClassRec"s:
XtFoo() -> vendorShellClassRec [Xt version]
XmBar() -> vendorShellClassRec [Xm version]
Instand schizo zaphod mode. In reality, vendorShellClassRec is not referenced
from functions but from other widget class records.
I can't just pull Vendor.o out from the shared Xt (Vendor.o appears to define
the only external symbols redefined by libXm) because AIX shared libraries
apparently can't contain unresolved external references. If I take out Vendor.o
I have to take out every other file that uses symbols defined there - and then
files that need those files, etc. I tried it and ended up with three or four
object files in libXt and the res non-sharable.
I kludged around this by putting all of libXt (minus Vendor.o) into the shared
libXm. It isn't a pretty solution but it works - and beats having a statically
linked two-megabyte "periodic" demo...
-------------------------------------------------------------------------------
Subject: 92) TOPIC: KEYSYMS
-------------------------------------------------------------------------------
Subject: 93) What is causing the messages "unknown keysym osfDown..."? It
happens when I run an application under Motif 1.1
Answer: There is an OSF supplied addition to the /usr/lib/X11/XKeysymDB file.
It is found on the release tape and should have been automatically installed if
the installation procedure was followed in the Release Notes.
You have to copy (or append) lib/Xm/XKeysymDB into /usr/lib/X11. This may
require root permission. It is not clear how to fix the problem if you can't do
this. The error comes from Xt translation table parsing and can't be fixed in
Motif, so if you can't get root permission you may be stuck. The file is not
copyrighted so you can install it on other systems.
XKeysymDB simply contains the registered keysym values for the OSF keysyms. The
OSF values are server-independent. And, all registered keysyms will be included
in an XKeysymDB file to be shipped with X11R5.
In the meantime (till all systems are X11R5+), a list of the registered keysyms
can be found in the X11R4 release in mit/doc/Registry/Xregistry.
-------------------------------------------------------------------------------
Subject: 94) What happens if I can't install Motif Keysyms?
From: tessi!george@nosun.West.Sun.COM (George Mitchell)
Here's what appears to happen if you don't have XKeysymDB in place to define
OSF's virtual keysyms:
1. At class initialize time, for a widget (such as XmText) that uses virtual
keysyms in its event translation table, all entries which refer to those keysyms
fail to parse correctly. In the case of XmText, instead of ending up with a
translation table with roughly 90 entries, you end up with one that has 29.
2. XKeysymDB doesn't exist, so you'd assume that KeyPress events will get
translated to plain vanilla keysyms, right? WRONG! All Motif widgets install a
virtual keysym translator ANYWAY! Consequently, the backspace key (for example)
gets translated to the keysym osfBackSpace.
3. Therefore, if you augment or override your widget's translations with
translations that refer to plain vanilla BackSpace, they will never be
triggered, because you will NEVER see plain vanilla BackSpace, only
osfBackSpace.
4. But you can't use osfBackSpace in an event translation entry, because you
don't have XKeysymDB installed!
Here's how I'm "dealing" with the problem right now: Motif installs its virtual
keysym translator by calling XtSetKeyTranslator every time a VendorShell (or
subclass) widget is created. So every time I create a shell, I immediately call
XtSetKeyTranslator (display, XtTranslateKey) to restore the default translator.
No more funny virtual keysyms! Now I can reinstall non-osfKeySym translations
and have them work the way I expect.
-------------------------------------------------------------------------------
Subject: 95) Why has OSF introduced Keysyms into Motif 1.1? They weren't there
in Motif 1.0.
Answer: From: ellis@osf.org
Virtual Keysyms are meant to provide a consistent keyboard model for Motif
applications running in a heterogeneous environment in which proprietary (i.e.
vendor specific) non-Motif applications may also be running.
First of all, for the sake of the rest of the readers, let's explain why this is
an issue:
It would be lovely if Motif's translation tables could just use the obvious
keysyms predefined by X. For example, there are keysyms for XK_BackSpace,
XK_Delete, XK_Left, XK_Right, etc. Shouldn't these be the ones that are used in
our translations? Unfortunately, the problem is not so simple. Some specific
examples:
While most vendors bind XK_BackSpace to the key at the top right
of the standard keyboard (often engraved with a leftwards
pointing arrow), not all do. In fact, some vendors (including DEC)
bind that key to XK_Delete.
While most vendors bind the arrow keys to XK_Up, etc, a number of
vendors (including Sun, on some servers) bind them to function key
keysyms.
A simplistic solution would require the use of xmodmap to change the offending
bindings. That would work swell in an all Motif environment. However, OSF's
goal (not always pefectly achieved) is interoperability. That is, we'd like to
make sure that both Motif and non-Motif programs can happily run in the same
environment.
It is expected that a vendor may have a wide variety of existing X-based
software that uses the keysyms as established by that vendor for specific
purposes. It is expected that these applications may run at the same time as
Motif-based software. Using xmodmap to change keysyms on the server side could
"break" the existing applications (or at the very least their documentation) by
making some keys unavailable, or by moving the location.
So, we chose not to use xmodmap. By the way, though OpenLook uses a different
implementation (they recompile their virtual translation tables into actual
translation tables), they basically adopted the same approach, presumably for
similar reasons.
To work properly, the virtual keysym model we implemented depends on Xlib
finding XKeysymDB installed appropriately (which standard Motif installation
does). This simply defines the keysyms (not the key they are bound to). This
unfortunate piece of stupidity is necessary because MIT only includes standard
keysyms in keysymdef.h. It should be said that our lives would be made easier
if MIT would also see fit to include registered keysyms in keysymdef.h as well.
Motif applications determine how to bind virtual to actual keys by looking for
either a resource or a property on the root window which describes what to do.
Note that this information is on the server side, so that all applications use
the same virtual bindings regrdless of where they are running. Mwm will happily
create the property if it finds a .motifbind file in your home directory when it
starts up. (Actually, things generally work even if none of this is done, since
if all else fails, the Motif toolkit chooses a virtual bindings table to use
based on the identification of the server).
The actual implmentation of virtual keys is made possible by a hook in the
Intrinsics. Undoubtably, the implementation would be simpler and cleaner if
virtual key support was more directly supported by the Intrinsics. We will be
exploring this possibility in the future.
-- Ellis
-------------------------------------------------------------------------------
Subject: 96) TOPIC: ICONS
Iconification/de-iconification is a co-operative process between a client and a
window manager. The relevant standards are set by ICCCM. Mwm is ICCCM
compliant. The toplevel (non-override-redirect) windows of an application may
be in three states: WithdrawnState (neither the window nor icon visible),
NormalState (the window visible) or IconicState (the icon window or pixmap
visible). This information is contained in the WM_STATE property but ordinary
clients are not supposed to look at that. Movement between the three states is
standardised by ICCCM.
-------------------------------------------------------------------------------
Subject: 97) How can I keep track of changes to iconic/normal window state?
Answer: You can look at the WM_STATE property, but this breaks ICCCM guidelines.
ICCCM compliant window managers will map windows in changing them to normal
state and unmap them in changing them to iconic state. Look for StructureNotify
events and check the event type:
XtAddEventHandler (toplevel_widget,
StructureNotifyMask,
False,
StateWatcher,
(Opaque) NULL);
....
void StateWatcher (w, unused, event)
Widget w;
caddr_t unused;
XEvent *event;
{
if (event->type == MapNotify)
printf ("normal0);
else if (event->type == UnmapNotify)
printf ("iconified0);
else printf ("other event0);
}
If you insist on looking at WM_STATE, here is some code (from Ken Sall) to do
it:
/*
------------------------------------------------------------------
Try a function such as CheckWinMgrState below which returns one of
IconicState | NormalState | WithdrawnState | NULL :
------------------------------------------------------------------
*/
#define WM_STATE_ELEMENTS 1
unsigned long *CheckWinMgrState (dpy, window)
Display *dpy;
Window window;
{
unsigned long *property = NULL;
unsigned long nitems;
unsigned long leftover;
Atom xa_WM_STATE, actual_type;
int actual_format;
int status;
xa_WM_STATE = XInternAtom (dpy, "WM_STATE", False);
status = XGetWindowProperty (dpy, window,
xa_WM_STATE, 0L, WM_STATE_ELEMENTS,
False, xa_WM_STATE, &actual_type, &actual_format,
&nitems, &leftover, (unsigned char **)&property);
if ( ! ((status == Success) &&
(actual_type == xa_WM_STATE) &&
(nitems == WM_STATE_ELEMENTS)))
{
if (property)
{
XFree ((char *)property);
property = NULL;
}
}
return (property);
} /* end CheckWinMgrState */
-------------------------------------------------------------------------------
Subject: 98) How can I check if my application has come up iconic? I want to
delay initialisation code and other processing.
Answer: According to ICCCM, a client window starts up with WM_STATE set to
WithdrawnState and then will move to IconicState. No specific events are
generated (not even an UnmapNotify). Ordinary clients aren't supposed to look
at WM_STATE so there seems to be no way of catching this change of state.
However, if what you really want is to do nothing while in the initial iconic
state, set a global variable `doInitialise' set to True and do no other
initialisation. Look for MapNotify events which will occur when the client is
de-iconified, perform initialisation stuff only when the variable is True, and
then set the variable to False.
-------------------------------------------------------------------------------
Subject: 99) How can I start my application in iconic state?
Answer: From the command line
application -iconic
Using the resource mechanism, set the resource XmNinitialState to IconicState of
the toplevel shell widget (the one returned from XtInitialise).
-------------------------------------------------------------------------------
Subject: 100) How can an application iconify itself?
Answer: Send an event to the root window with a type of WM_CHANGE_STATE and data
IconicState.
void
IconifyMe (dpy, win)
Display *dpy;
Window win; /* toplevel window to iconify */
{
Atom xa_WM_CHANGE_STATE;
XClientMessageEvent ev;
xa_WM_CHANGE_STATE = XInternAtom (dpy,
"WM_CHANGE_STATE", False);
ev.type = ClientMessage;
ev.display = dpy;
ev.message_type = xa_WM_CHANGE_STATE;
ev.format = 32;
ev.data.l[0] = IconicState;
ev.window = win;
XSendEvent (dpy,
RootWindow (dpy, DefaultScreen(dpy)),
True,
(SubstructureRedirectMask | SubstructureNotifyMask),
&ev);
XFlush (dpy);
}
-------------------------------------------------------------------------------
Subject: 101) How can an application de-iconify itself?
Answer: XMapWindow (XtWindow (toplevel_widget)).
-------------------------------------------------------------------------------
Subject: 102) TOPIC: MISCELLANEOUS
-------------------------------------------------------------------------------
Subject: 103)* 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: 104) Why does an augment translation appear to act as replace for some
widgets? When I use either augment or override translations in .Xdefaults it
seems to act as replace in both Motif 1.0 and 1.1
Answer: By default, the translation table is NULL. If there is nothing
specified (either in resource file, or in args), the widget's Initialize finds:
Oh, there is NULL in translations, lets use our default ones. If, however, the
translations have become non-NULL, the default translations are NOT used at all.
Thus, using #augment, #override or a new table has identical effect: defines the
new translations. The only way you can augment/override Motif's default
translations is AFTER Initialize, using XtSetValues. Note, however, that Motif
managers do play with translation tables as well ... so that results are not
always easy to predict.
From OSF: A number of people have complained about not being able to
augment/override translations from the .Xdefaults. This is due to the
complexity of the menu system/keyboard traversal and the necessary translations
changes required to support the Motif Style Guide in menus. It cannot be fixed
in a simple way. Fixing it requires re-design of the menus/buttons and it is
planned to be fixed in 1.2.
-------------------------------------------------------------------------------
Subject: 105) How do you "grey" out a widget so that it cannot be activated?
Answer: Use XtSetSensitive(widget, False). Do not set the XmNsensitive resource
directly yourself (by XtSetvalues) since the widget may need to talk to parents
first.
-------------------------------------------------------------------------------
Subject: 106) Why doesn't the Help callback work on some widgets?
Answer: If you press the help key the help callback of the widget with the
keyboard focus is called (not the one containing the mouse). You can't get the
help callback of a non-keyboard-selectable widget called. To get `context
sensitive' help on these, you have to find the mouse, associate its position
with a widget and then do the help.
-------------------------------------------------------------------------------
Subject: 107) Where can I get a Table widget?
Answer: Send email to Kee Hinckley (nazgul@alfalfa.com) asking for a copy of his
table widget. The Widget Creation Library also has one. See under Motif
protyping tools for the contact.
-------------------------------------------------------------------------------
Subject: 108) Has anyone done a bar graph widget?
Answer: You can fake one by using for each bar a scroll bar or even a label
which changes in size, put inside a container of some kind.
Try the StripChart widget in the Athena widget set. Set the XtNupdate resource
to 0 to keep it from automatically updating.
The comp.windows.x FAQ mentions a bar graph widget.
-------------------------------------------------------------------------------
Subject: 109) Does anyone know of a source code of a graph widget where you can
add vertices and edges and get an automated updating?
Answer: No Motif one has been reported. The XUG FAQ in comp.windows.x includes
information on graph display widgets. There is also an implementation in the
Asente/Swick book.
From Martin Janzen: "You could have a look at DataViews, from V.I.
Corporation. This package is used mainly to display a variety of graph
drawings (eg. bar, line, pie, high/low, and other charts), and to update
the graphs as information is received from "data sources" such as files,
processes (through pipes), or devices.
However, it also provides "node" and "edge" objects which can be used
when working with network graphs. The DV-Tools function library
provides routines which traverse a graph, count visits to each node or
edge, mark nodes or edges of interest, and so on. A node or edge object
can have an associated "geometry object" (such as a symbol or a line),
which represents that node or edge.
Drawbacks: There's no automatic positioning algorithm; when you add a
node or edge, you have to create and position its geometry object
yourself. Also, this isn't a set of add-on widgets; you can either have
DataViews create an X window (ie. a separate shell), or you can create
your own XmDrawingArea and use DataViews to update its window when
expose events are received. Finally, the package is quite expensive,
and there is a run-time charge.
The vendor's address is:
V.I. Corporation,
47 Pleasant Street,
Northampton, MA 01060,
Email: vi@vicorp.com, Phone: (413) 586-4144, Fax: (413) 584-2649
or
V.I. Corporation (Europe) Ltd.,
First Base, Beacontree Plaza,
Gillette Way, Email: viesales@eurovi.uucp
Reading, Berkshire RG2 0BP"
Phone: +44 734 756010, Fax: +44 734 756104
From Craig Timmerman: Just wanted others to know that there is a third
competitor in what may be come a big market for generic APIs. The product is
called Open Interface and Neuron Data is the vendor. Neuron has added some
extra, more complex widgets to their set. The two most notable are a table and
network widget. [...] I believe that the network widget got its name from its
ability to display expert system networks that Neuron's AI tools needed. It
would be more aptly named the graph widget. It can display and manipulate
graphs of various types (trees, directed graphs, etc). Contact is
Neuron Data
156 University Avenue
Palo Alto, CA 94301
(415) 321-4488
-------------------------------------------------------------------------------
Subject: 110)* Is there a help system available, such as in Windows 3? Or any
Motif based hypertext system.
Answer: % Dave Brennan (brennan@dg-rtp.dg.com) has written a Motif based %
hypertext document viewing system for Data General software products.
Bristol Technology have a hypertext system with the look-and-feel of either
Motif or OpenLook. It should be available from january 31, 1992. Contact
Bristol Technology Inc.
898 Ethan Allen Highway
Ridgefield, CT 06877
203-438-6969 (phone)
203-438-5013 (fax)
uunet.uu.net!bristol!keith
-------------------------------------------------------------------------------
Subject: 111) Can I specify a widget in a resource file?
Answer: This answer, which uses the Xmu library, is due to David Elliott. If
the converter is added, then the name of a widget (a string) can be used in
resource files, and will be converted to the appropriate widget.
This code, which was basically stolen from the Athena Form widget, adds a String
to Widget converter. I wrote it as a general routine that I call at the
beginning of all of my programs, and made it so I could add other converters as
needed (like String to Unit Type ;-).
#include <X11/Intrinsic.h>
#include <X11/StringDefs.h>
#include <Xm/Xm.h>
#include <X11/Xmu/Converters.h>
#include <X11/IntrinsicP.h>
#include <X11/CoreP.h>
void
setupConverters()
{
static XtConvertArgRec parentCvtArgs[] = {
{XtBaseOffset, (caddr_t)XtOffset(Widget, core.parent),
sizeof(Widget)}
};
XtAddConverter(XmRString, XmRWindow, XmuCvtStringToWidget,
parentCvtArgs, XtNumber(parentCvtArgs));
}
-------------------------------------------------------------------------------
Subject: 112) Why are only some of my translations are being installed? I have
a translation table like the following, but only the first ones are getting
installed and the rest are ignored.
*Text.translations: #override \
Ctrl<Key>a: beginning-of-line() \n\
Ctrl<Key>e: end-of-line() \n\
Ctrl<Key>f: forward-character() \n\
Answer: Most likely, you have a space at the end of one of the lines (the first
in this case).
Ctrl<Key>a: beginning-of-line() \n\
^ space here
The second backslash in each line is there to protect the real newline character
and so you must not follow it with anything other than the newline itself.
Otherwise it acts as the end of the resource definition and the remaining lines
are not added.
-------------------------------------------------------------------------------
Subject: 113) Where can I get the PanHandler code?
Answer: It is available by email from Chuck Ocheret: chuck@fid.Morgan.COM.
-------------------------------------------------------------------------------
Subject: 114) What are these passive grab warnings? When I destroy certain
widgets I get a stream of messages
Warning: Attempt to remove non-existant passive grab
Answer: They are meaningless, and you want to ignore them. Do this (from Kee
Hinckley) by installing an XtWarning handler that explicitly looks for them and
discards them:
static void xtWarnCB(String message) {
if (asi_strstr(message, "non-existant passive grab", TRUE)) return;
...
They come from Xt, and (W. Scott Meeks): "it's something that the designers of
Xt decided the toolkit should do. Unfortunately, Motif winds up putting passive
grabs all over the place for the menu system. On the one hand, we want to
remove all these grabs when menus get destroyed so that they don't leak memory;
on the other hand, it's almost impossible to keep track of all the grabs, so we
have a conservative strategy of ungrabbing any place where a grab could have
been made and we don't explicitly know that there is no grab. The unfortunate
side effect is the little passive grab warning messages. We're trying to clean
these up where possible, but there are some new places where the warning is
generated. Until we get this completely cleaned up (1.2 maybe), your best bet
is probably to use a warning handler."
-------------------------------------------------------------------------------
Subject: 115) How do I have more buttons than three in a box? I want to have
something like a MessageBox (or other widget) with more than three buttons, but
with the same nice appearance.
Answer: A SelectionBox is created with four buttons, but the fourth (the Apply
button) is unmanaged. To manage it get its widget ID via
XmSelectionBoxGetChild(parent, XmDIALOG_APPLY_BUTTON) and then XtManage it.
Unmanage all of the other bits in the SelectionBox that you don't want. If you
want more than four buttons, try two SelectionBoxes (or similar) together in a
container, where all of the unwanted parts of the widgets are unmanaged.
-------------------------------------------------------------------------------
Subject: 116) TOPIC: ACKNOWLEDGEMENTS
This list was compiled using questions and answers posed to comp.windows.x.motif
and motif-talk. Some extracts were also taken from FAQs of comp.windows.x. To
all who contributed one way or the other, thanks! I haven't often given
individual references, but you may recognise contributions. If I have mangled
them too much, let me know.
That's all folks!
+----------------------+---+
Jan Newmarch, Information Science and Engineering,
University of Canberra, PO Box 1, Belconnen, Act 2616
Australia. Tel: (Aust) 6-2522422. Fax: (Aust) 6-2522999
ACSnet: jan@ise.canberra.edu.au
ARPA: jan%ise.canberra.edu.au@uunet.uu.net
UUCP: {uunet,ukc}!munnari!ise.canberra.edu.au!jan
JANET: jan%au.edu.canberra.ise@EAN-RELAY
+--------------------------+