jan@ECHO.CANBERRA.EDU.AU (Jan Newmarch) (11/02/90)
Frequently Asked Questions about Motif Here goes, I'm stupid enough to vounteer to maintain a frequently asked questions file for this group. It contains answers to some of the questions I have seen in this group. If your favourite question isn't here than it's probably because my record keeping isn't up to scratch. If it is an FAQ though it should get asked again and I should pick it up then. If you have any corrections, comments, suggestions or additions (but please, no flames 'cos I have a delicate disposition) send them to me and I'll see what I can do with them. 1. OSF and Motif Question: What versions of Motif are there? Answer: Motif 1.0 is based on the R3 toolkit. Motif 1.1 is based on the R4 toolkit. Motif 1.2 is not expected until after mid 1991, and will be based on the R5 toolkit. Question: Where can I get Motif? Answer: [from FAQ of comp.windows.x] 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. 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 Sun 4, The kits include varied levels of bug-fixing and support for s hared libraries. An OSF/Motif source license must be obtained from OSF before source can be obtained from the Open Software Foundation or any value-added vendor. Call the Direct Channels Desk at OSF at 617-621-7300 for ordering information. Note: Version 1.1 began shipping in late August, 1990, and is currently available only in source form. Unipalm XTech will be shipping Motif 1.1 based binaries from the end of September. Question: Where can I get public domain Motif source? Answer: You cannot. Motif source is not publically available. Question: Has anyone done a public domain Motif lookalike? Answer: Not yet. 2. Literature Question: 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 OSF/Motif Programmers Reference Manual OSF/Motif Style Guide 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 expo in ~ftp/contrib/young.motif.tar.Z] Marshall Brain at brain@adm.csc.ncsu.edu posted a set of simple and useful Motif tutorials. 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 X11R3 Intrinsics; some information on X11R4 is included. 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. 3. Mwm Question: What is the diference between Motif and mwm? Answer: mwm is a window manager. Motif is an Application Programmers Interface of `C' library routines with which to build applications with the Motif look- and-feel. In general mwm will run an application built with any X-windows API, and a Motif application will run under any window manager. Question: I have a monochrome screen, and I don't like the Motif defaults for the 3-D effect. Does anyone have a better set? 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 4. Motif generators Question: Can I write at a higher level than Motif and generate Motif code? Answer: `Prototyping tools' come in two forms: those that can be used to design the interface only (Interactive Design Tools), 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: IDTs: Builder Xcessory UIMX X Build UIMS: WINTERP Widget Creation Library Serpent TAE+ TeleUse DataViews Some contact addresses are: WINTERP: You may obtain the current source, documentation, and examples via anonymous ftp from host expo.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: Send mail to 'info@ics.com' or call ICS at 617/547-0510. 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 TAE+: From COSMIC, 382 East Broad St., Athens, GA, 404.542.3265. X Build: From Nixdorf Computer (Waltham, MA) 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 either of these ftp servers: devvax.jpl.nasa.gov (128.149.1.143) pub/Wc1_03.tar.Z expo.lcs.mit.edu (18.30.0.212) contrib/Wc1_03.tar.Z 5. Text widget Question: I have a text widget inside a bulletin board (or form) inside a dialog shell. When I press <return> nothing happens. Why not? 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); Question: When I add text to a scrolling text widget from within a program, 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) Question: I'm having trouble using 16 bit character fonts in a text widget. Does Motif support them? Answer: R5 will have support for 16 bit character sets, and Motif 1.2 will use that. You will have to wait until then. 6. Menus Question: 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. Question: 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. Question: 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. 7. Keyboard traversal Question: How can I direct the keyboard input to a particular widget? Answer: In Motif 1.1 call XmProcessTraversal(target, XmTRAVERSE_CURRENT). 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. Question: 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. 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. Boolean keep_grab = True; XEvent event; Arg args[1]; 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; } } 8. Memory and Speed Question: My application grows in size. Why? 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. Question: My application takes a long time to start up. Why? Answer: If you have a large .Xdefaults, time may be spent reading and parsing it. Question: 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. Answer: Avoid lots of widget creation and destruction. It fragments memory and slows everything down. Popup/popdown, manage/unmanage instead. Answer: Get more memory - your application, the server and the Operating System may be spending a lot of time being swapped. 9. XmString Question: 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); Question: When I use XmStringGetNextSegment() I get a core dump. Why? 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. 10. Miscellaneous Question: My manual says I need to link in libPW.a to use the File Selection Box. I can't find it on my system. What is it and do I need it? 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. Question: How can my application tell if the user has selected the "Close" item on the system menu attached to the top-level shell, so that it can clean up before exiting? Answer: 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(); } 11. Acknowledgements This list was compiled using questions and answers posed to comp.windows.x.motif. Some extracts were also taken from FAQs of comp.windows.x. To all who contributed one way or the other, thanks! I haven't 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 +--------------------------+
erc@pai.UUCP (Eric Johnson) (11/02/90)
In article <9011010505.AA00921@golf.canberra.edu.au>, jan@ECHO.CANBERRA.EDU.AU (Jan Newmarch) writes:
Frequently Asked Questions about Motif
Here goes, I'm stupid enough to vounteer to maintain a frequently asked
questions file for this group. It contains answers to some of the questions I
have seen in this group. If your favourite question isn't here than it's
probably because my record keeping isn't up to scratch. If it is an FAQ though
it should get asked again and I should pick it up then.
Thanks for taking the time to put this together. This is an un-ending
task, as I'm sure you know.
If you have any corrections, comments, suggestions or additions (but please, no
flames 'cos I have a delicate disposition) send them to me and I'll see what I
can do with them.
1. OSF and Motif
Question: Where can I get Motif?
Answer: [from FAQ of comp.windows.x]
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.
I'm also running Motif 1.0 on a Data General AViiON with X11 R3. I also
have seen a Bull Motif product, but never tried it.
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
Good luck,
-Eric
--
Eric F. Johnson phone: +1 612 894 0313 BTI: Industrial
Boulware Technologies, Inc. fax: +1 612 894 0316 automation systems
415 W. Travelers Trail email: erc@pai.mn.org and services
Burnsville, MN 55337 USA
mitch@westford.ccur.COM (Mitch Kuninsky, x2677) (11/03/90)
> 1. OSF and Motif > > Question: Where can I get Motif? > > Answer: [from FAQ of comp.windows.x] > 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. Also Concurrent Computer Corporation 5000, 6000, 8000 series machines. --------------------------------------------------------------------------- Mitch Kuninsky Concurrent Computer Corp 1 Technology Way Westford, MA 01886 508-392-2677 E-mail: mitch@westford.ccur.com
nazgul@alphalpha.com (Kee Hinckley) (11/03/90)
> > > 1. OSF and Motif > > > > Question: Where can I get Motif? Rather than attempting to list every vendor who supports Motif I suspect you are better off just listing those companies that sell it on platforms that don't normally support it (e.g. Sun). The list is somewhat shorter and won't grow as fast :-).