[Comp.Sci.Dept, Utrecht] Note from archiver<at>cs.uu.nl: This page is part of a big collection of Usenet postings, archived here for your convenience. For matters concerning the content of this page, please contact its author(s); use the source, if all else fails. For matters concerning the archive as a whole, please refer to the archive description or contact the archiver.

Subject: Motif FAQ (Part 5 of 9)

This article was archived around: 23 May 2006 04:24:20 GMT

All FAQs in Directory: motif-faq
All FAQs posted in: comp.windows.x.motif
Source: Usenet Version

Archive-name: motif-faq/part5 Last-modified: 1 FEB 2002 Posting-Frequency: irregular Organization: Kenton Lee, X/Motif Consultant, http://www.rahul.net/kenton/ URL: http://www.rahul.net/kenton/mfaq.html Version: 8.1
----------------------------------------------------------------------------- Subject: 108) TOPIC: LIST WIDGET ----------------------------------------------------------------------------- Subject: 109) Should I create an XmList widget as a child of automatic XmScrolledWindow or use the XmCreateScrolledList() convenience function? Answer: With most implementations, the convenience function use internal hooks to give somewhat better scrolling performance. Ken Lee, http://www.rahul.net/kenton/ ----------------------------------------------------------------------------- Subject: 110) 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); or similarly with XtVaSetValues: XtVaSetValues (w, XmNitemCount, list_size, XmNitems, list, NULL); 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: 111) Can I have strings with different fonts in a list? [Last modified: Sept 95] Answer: Yes. The strings are XmStrings. Each one can be created using a different character set using a different font. However, arjav@caip.rutgers.edu (ARJAV PARIKH) wrote: If a string is added to the listbox, the font in the listbox overrides the font set using XmCreateString. The Command widget label retains the font set using XmCreateString. I read in the MOTIF FAQ that it is possible to add strings with multiple fonts to the listbox. I learned from one of the tech support persons that internal code of the listbox overrides the font. Madhusudan Poolu (madhu@corp.sgi.com) replied: You need to create a fontlist for your font and add it to your listbox widget using XtVaSetValues ( wList, XmNfontList, yourFontList, NULL). This technique can also be used to display multi-font strings in a list box. ----------------------------------------------------------------------------- Subject: 112) 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. [Last modified: Jun 2000] Answer: Andrew Lister (lister@bain.oz.au) writes: The XbaeMatrix widget allows a bitmaps in a cell. There will be support for colour pixmaps to be displayed in version 4.4 which should be available very soon. (The XbaeMatrix can be made to look and behave like a list widget. The widget is compatible with Motif 1.2 and Motif 2.0.) Beginning with version 4.7, XbaeMatrix is being maintained by the Lesstif project. The current version is version 4.8. Source code and a FAQ are available from: http://www.lesstif.org/Xbae.html http://www.lesstif.org/Lessdox/XbaeFAQ.html Alan Peery (peery@isc.tamu.edu) writes: Motif 2.0 introduced the "container" widget, which offers 2-D icon and text layout similar to that found in many file management programs. It could probably be used as a 1-D list widget also. A previous source wrote: In Motif 1.x, you cannot do this. 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: 113) Can I have items with different colors in a list widget? [Last modified: Jun 2000] Answer: Andrew Lister (lister@bain.oz.au) writes: The XbaeMatrix widget can have a different foreground and background in each cell, row or column. (The XbaeMatrix can be made to look and behave like a list widget. The widget is compatible with Motif 1.2 and Motif 2.0.) You can get the latest version of XbaeMatrix from: http://www.lesstif.org/Xbae.html Ken Lee wrote: Not in Motif 1.x. The list contains XmStrings, and these only allow text in various character sets. However, in Motif 2.0 you _can_ have multiple colors in the same list since colored XmStrings are supported. Thanks to Ken Lee, http://www.rahul.net/kenton/, for the update. If you're using Motif 1.2, another possibility is to use SCO Premier Motif (1.2) library has this extension built into the List widget, along with a few others. See http://www.premier.sco.com/ Thanks to Richard Offer (offer@sgi.com) ----------------------------------------------------------------------------- Subject: 114) How can I line up columns in a list widget? [Last modified: Jun 2000] Answer: The simplest answer is to use fixed-width fonts and spaces to line up columns. There are also some more general solutions follow. David Kaelbling <drk@sgi.com> writes: Motif 2.x supports tab components in XmStrings. Insert XmSTRING_COMPONENT_TAB segments into your XmStrings, either with XmStringComponentCreate() and XmStringConcatAndFree(), or with the XmStringParseText() api). Then use XmStringTableProposeTabList() to get a default set of non-overlapping tabs. Put that XmNtabList into a rendition in the list's render table. Andrew Lister (lister@bain.oz.au) writes: The XbaeMatrix can do this too, for both fixed and non fixed width fonts. (The XbaeMatrix can be made to look and behave like a list widget. The widget is compatible with Motif 1.2 and Motif 2.0.) You can get the latest version of XbaeMatrix from: http://www.lesstif.org/Xbae.html Ken Lee writes: Other Motif-compatible and matrix grid and matrix widgets are available. See the widgets FAQ for pointers. ----------------------------------------------------------------------------- Subject: 115) Can I grey out an item in a list widget? I want to make insensitive items in a list so that they cannot be selected. [Last modified: Feb 98] Answer: W. Scott Meeks of OSF wrote: 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. Ken Lee adds: Motif 2.0 allows you to create multi-color XmStrings. You can use this feature to grey out specific list items. ----------------------------------------------------------------------------- Subject: 116) Can I have multi-line items in a list? [Last modified: August 92] Answer: Motif 1.0 and 1.1 both have problems with multi-line items in a list. They should work okay in Motif 1.2. ----------------------------------------------------------------------------- Subject: 117) How can I tell the position of selected items in a list? [Last modified: Oct 92] Answer: W. Scott Meeks wrote: 1) All XmList selection callbacks get an XmListCallbackStruct which includes the item selected and its position. In addition, the multiple and extended selection callbacks also get a list of the selected items. This approach requires that your application saves this information if you need it outside of the immediate callback. 2) At any time you can XtGetValues the XmNselectedItems and XmNselectedItemCount resources. The problem with this approach is that identical items may or may not show up in multiple times in this list and the position in the selectedItems list may not relate directly to the position in the items list. 3) You can call XmListGetSelectedPos on the list widget. This will return a list of the positions of all selected items. ----------------------------------------------------------------------------- Subject: 118) How can I configure a scrolled list widget to show a horizontal scrollbar when some list items are wider than the window? [Last modified: May 97] Answer: Set *XmList.listSizePolicy: XmCONSTANT Ken Lee ----------------------------------------------------------------------------- Subject: 119) How can I programatically select all of the items in an XmList? [Last modified: May 98] Answer: Invoke the same action that "C-/" uses for selecting everything. Try something like: XtCallActionProc(list, "ListKbdSelectAll", event, NULL, 0); If you don't have an event handy passing NULL for it will probably work too. The lack of an XmListSelectAllItems() api was just an oversight. David KAELBLING <drk@sgi.com> ----------------------------------------------------------------------------- Subject: 120) TOPIC: FILE SELECTION BOX WIDGET ----------------------------------------------------------------------------- Subject: 121) 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. [Last modified: Sept 94] Answer: The libPW.a is the Programmers 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 (regcmp, regex). 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. Casper H.S. Dik (asper@fwi.uva.nl), Faculty of Mathematics & Computer Science, University of Amsterdam, sent this update for Solaris 2.x users: The regex and regcmp function are part of libgen in SVR4. Motif applications should be linked with -lgen. (However, some SVR4 implementations, especially those of vendors that once shipped SVR3 still contain libPW.) On Solaris 2.x system, you'll need libgen which is located in /usr/ccs/lib. ----------------------------------------------------------------------------- Subject: 122) What are these compile errors: Undefined symbol _regcmp and _regex? [Last modified: Sept 94] Answer: You need to link in the libPW or libgen library - see previous question. ----------------------------------------------------------------------------- Subject: 123) 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 regular 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: 124) How can I keep my file selection boxes from resizing when I change directories or filters? [Last modified: May 97] Answer: Set XmNresizePolicy (XmFileSelectionDialog is a subclass of XmBulletinBoard) to XmRESIZE_NONE. ----------------------------------------------------------------------------- Subject: 125) What's wrong with the FileSelectionBox under Solaris? [Last modified: May 97] Answer: Jim Guyton (guyton@burton.cs.colorado.edu) writes: While not strictly a Motif problem, this one had me confused for [awhile]. If under Solaris the entries in a FileSelectionBox look strange and seem to be missing the first two characters of many filenames, then be sure you're linking -lc before -lucb. If on the other hand, the filenames look strange and seem to have two garbage characters in front of every filename, be sure to link -lucb before -lc. There are two versions of readdir(). The one in -lucb returns a structure that has the filename at an offset of 8 bytes (which matches /usr/ucbinclude/sys/dir.h). But the version in -lc returns the filename at an offset of 10 bytes (which matches /usr/include/dirent.h). So depending on how Motif was built for your Solaris, vs. how you link your application, your filenames could be two bytes off in either direction. Harry Cohen (hbcohen@bell.tds-eagan.lmco.com) writes: I also had this problem (the missing horizontal scroll bar with Solaris 2.5.1 and 2.4) and have talked with Sun. This is a problem with the Sun Motif library in /usr/dt/lib. You need to install the following Sun patches to correct this problem: For Solaris 2.5.1: patch 103461-03 For Solaris 2.4: patch 102226-19 Note: For Solaris 2.4, the horizontal scroll problem existed in a previous patch release, so most people haven't seen it. Scott W. Sadler (sws@iti-oh.com) writes: We had this same problem, and it took a while to figure it out. If you use the Motif libraries out of /usr/dt/lib, the file selection box gives the problem you indicate. However, if you use the Motif libraries out of /opt/SUNWspro/Motif_Solaris24/dt/lib, all is fine. Make sure your LD_LIBRARY_PATH, is set correctly to pick up the right shared libraries at run time. Also check out the "-R" option to the linker to encode the library search paths. Finally use the "ldd" program to make sure that you are picking up the correct libraries. ----------------------------------------------------------------------------- Subject: 126) TOPIC: FORM WIDGET ----------------------------------------------------------------------------- Subject: 127) 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. db@sunbim.be (Danny Backx) wrote: Basically what you have to do is set the XmNresizePolicy on the Form to XmRESIZE_NONE. The facts seem to be that XmRESIZE_NONE does NOT mean "do not allow resizes". You may also have to set XmNresizable on the form to True. ----------------------------------------------------------------------------- Subject: 128) How can I center a widget in a form? [Last modified: Nov 96] 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. A hack free solution is from Dan Heller: /* Written by Dan Heller. Copyright 1991, O'Reilly && Associates. * This program is freely distributable without licensing fees and * is provided without guarantee or warranty expressed or implied. * This program is -not- in the public domain. This program is * taken from the Motif Programming Manual, O'Reilly Volume 6. */ /* corners.c -- demonstrate widget layout management for a * BulletinBoard widget. There are four widgets each labeled * top-left, top-right, bottom-left and bottom-right. Their * positions in the bulletin board correspond to their names. * Only when the widget is resized does the geometry management * kick in and position the children in their correct locations. */ #include <Xm/BulletinB.h> #include <Xm/PushBG.h> char *corners[] = { "Top-Left", "Top-Right", "Bottom-Left", "Bottom-Right", }; static void resize(); main(argc, argv) int argc; char *argv[]; { Widget toplevel, bboard; XtAppContext app; XtActionsRec rec; int i; /* Initialize toolkit and create toplevel shell */ toplevel = XtVaAppInitialize(&app, "Demos", NULL, 0, &argc, argv, NULL, NULL); /* Create your standard BulletinBoard widget */ bboard = XtVaCreateManagedWidget("bboard", xmBulletinBoardWidgetClass, toplevel, NULL); /* Set up a translation table that captures "Resize" events * (also called ConfigureNotify or Configure events). If the * event is generated, call the function resize(). */ rec.string = "resize"; rec.proc = resize; XtAppAddActions(app, &rec, 1); /******** WARNING! Next statement is questionable in 1996. See ******** "Can you reuse the return value from XtParseTranslationTable?" ******** If someone corrects this code, send it to kenton@nojunk.rahul.net ********/ XtOverrideTranslations(bboard, XtParseTranslationTable("<Configure>: resize()")); /* Create children of the dialog -- a PushButton in each corner. */ for (i = 0; i < XtNumber(corners); i++) XtVaCreateManagedWidget(corners[i], xmPushButtonGadgetClass, bboard, NULL); XtRealizeWidget(toplevel); XtAppMainLoop(app); } /* resize(), the routine that is automatically called by Xt upon the * delivery of a Configure event. This happens whenever the widget * gets resized. */ static void resize(w, event, args, num_args) CompositeWidget w; /* The widget (BulletinBoard) that got resized */ XConfigureEvent *event; /* The event struct associated with the event */ String args[]; /* unused */ int *num_args; /* unused */ { WidgetList children; int width = event->width; int height = event->height; Dimension w_width, w_height; short margin_w, margin_h; /* get handle to BulletinBoard's children and marginal spacing */ XtVaGetValues(w, XmNchildren, &children, XmNmarginWidth, &margin_w, XmNmarginHeight, &margin_h, NULL); /* place the top left widget */ XtVaSetValues(children[0], XmNx, margin_w, XmNy, margin_h, NULL); /* top right */ XtVaGetValues(children[1], XmNwidth, &w_width, NULL); /* To Center a widget in the middle of the BulletinBoard (or Form), * simply call: * XtVaSetValues(widget, XmNx, (width - w_width)/2, XmNy, (height - w_height)/2, NULL); * and return. */ XtVaSetValues(children[1], XmNx, width - margin_w - w_width, XmNy, margin_h, NULL); /* bottom left */ XtVaGetValues(children[2], XmNheight, &w_height, NULL); XtVaSetValues(children[2], XmNx, margin_w, XmNy, height - margin_h - w_height, NULL); /* bottom right */ XtVaGetValues(children[3], XmNheight, &w_height, XmNwidth, &w_width, NULL); XtVaSetValues(children[3], XmNx, width - margin_w - w_width, XmNy, height - margin_h - w_height, NULL); } b. No uil solution has been suggested, because of the widget size problem. c. Cameron Hayne (hayne@crim.ca) suggests another solution: Attach the widget with XmATTACH_POSITION but offset it by half of its width. You will likely have to create the widget first and then query it to find out its width. Thus the following function is useful - you can call it immediately after the widget is created. void center_it(Widget wgt) { Dimension width; XtVaGetValues(wgt, XmNwidth, &width, NULL); XtVaSetValues(wgt, XmNleftAttachment, XmATTACH_POSITION, XmNleftPosition, 50, /* assumes fractionBase is 100 */ XmNleftOffset, -width/2, NULL); } The idea is: get the size of the widget and then offset it by half that much from position 50. The above function will likely only work for primitive widgets if you call it immediately after the widget is created. For manager widgets you will likely have to wait to call the center_it() function until after the widget has been realized since it is only then that a manager widget's size is finally determined. (Refer to discussion by Daniel Dardailler "Application's Geometry Management Advanced Guidelines" in this FAQ.) ----------------------------------------------------------------------------- Subject: 129) 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. If you want the geometry to look like this ------------------------------------- | -------------------------- | |a label |Some text || | -------------------------- | ------------------- | |a longer label |Some more text || | ------------------- | | ---------------- | |a very long label |Even more text || | ---------------- | ------------------------------------- try /* Written by Dan Heller. Copyright 1991, O'Reilly && Associates. * This program is freely distributable without licensing fees and * is provided without guarantee or warranty expressed or implied. * This program is -not- in the public domain. This program is * taken from the Motif Programming Manual, O'Reilly Volume 6. */ /* text_form.c -- demonstrate how attachments work in Form widgets. * by creating a text-entry form type application. */ #include <Xm/PushB.h> #include <Xm/PushBG.h> #include <Xm/LabelG.h> #include <Xm/Text.h> #include <Xm/Form.h> char *prompts[] = { "Name:", "Phone:", "Address:", "City:", "State:", "Zip:", }; main(argc, argv) int argc; char *argv[]; { Widget toplevel, mainform, subform, label, text; XtAppContext app; char buf[32]; int i; toplevel = XtVaAppInitialize(&app, "Demos", NULL, 0, &argc, argv, NULL, NULL); mainform = XtVaCreateWidget("mainform", xmFormWidgetClass, toplevel, NULL); for (i = 0; i < XtNumber(prompts); i++) { subform = XtVaCreateWidget("subform", xmFormWidgetClass, mainform, /* first one should be attached for form */ XmNtopAttachment, i? XmATTACH_WIDGET : XmATTACH_FORM, /* others are attached to the previous subform */ XmNtopWidget, subform, XmNleftAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM, NULL); label = XtVaCreateManagedWidget(prompts[i], xmLabelGadgetClass, subform, XmNtopAttachment, XmATTACH_FORM, XmNbottomAttachment, XmATTACH_FORM, XmNleftAttachment, XmATTACH_FORM, XmNalignment, XmALIGNMENT_BEGINNING, NULL); sprintf(buf, "text_%d", i); text = XtVaCreateManagedWidget(buf, xmTextWidgetClass, subform, XmNtopAttachment, XmATTACH_FORM, XmNbottomAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM, XmNleftAttachment, XmATTACH_WIDGET, XmNleftWidget, label, NULL); XtManageChild(subform); } /* Now that all the forms are added, manage the main form */ XtManageChild(mainform); XtRealizeWidget(toplevel); XtAppMainLoop(app); } If you resize horizontally it stretches the text widgets. If you resize vertically it leaves space under the bottom (if you don't resize, this is not problem). If you want the text widgets to be lined up on the left, as in ---------------------------------------- | ------------------- | | a label |Some text || | ------------------- | ------------------- | | a longer label |Some more text || | ------------------- | | ------------------- | |a very long label |Even more text || | ------------------- | ---------------------------------------- try this /* Written by Dan Heller. Copyright 1991, O'Reilly && Associates. * This program is freely distributable without licensing fees and * is provided without guarantee or warranty expressed or implied. * This program is -not- in the public domain. This program is * taken from the Motif Programming Manual, O'Reilly Volume 6. */ /* text_entry.c -- This demo shows how the RowColumn widget can be * configured to build a text entry form. It displays a table of * right-justified Labels and Text widgets that extend to the right * edge of the Form. */ #include <Xm/LabelG.h> #include <Xm/RowColumn.h> #include <Xm/Text.h> char *text_labels[] = { "Name:", "Phone:", "Address:", "City:", "State:", "Zip:", }; main(argc, argv) int argc; char *argv[]; { Widget toplevel, rowcol; XtAppContext app; char buf[8]; int i; toplevel = XtVaAppInitialize(&app, "Demos", NULL, 0, &argc, argv, NULL, NULL); rowcol = XtVaCreateWidget("rowcolumn", xmRowColumnWidgetClass, toplevel, XmNpacking, XmPACK_COLUMN, XmNnumColumns, XtNumber(text_labels), XmNorientation, XmHORIZONTAL, XmNisAligned, True, XmNentryAlignment, XmALIGNMENT_END, NULL); /* simply loop thru the strings creating a widget for each one */ for (i = 0; i < XtNumber(text_labels); i++) { XtVaCreateManagedWidget(text_labels[i], xmLabelGadgetClass, rowcol, NULL); sprintf(buf, "text_%d", i); XtVaCreateManagedWidget(buf, xmTextWidgetClass, rowcol, NULL); } XtManageChild(rowcol); XtRealizeWidget(toplevel); XtAppMainLoop(app); } This makes all objects exactly the same size. It does not resize in nice ways. If you want the text widgets lined up on the left, and the labels to be the size of the longest string, resizing nicely both horizontally and vertically, as in ------------------------------------- | ---------------- | | a label |Some text || | ---------------- | ---------------- | | a longer label |Some more text || | ---------------- | | ---------------- | |a very long label |Even more text || | ---------------- | ------------------------------------- Answer: Do this: 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: 130) TOPIC: PUSHBUTTON WIDGET ----------------------------------------------------------------------------- Subject: 131) Why doesn't the enter or return key activate the button with focus? [Last modified: Sep 98] Answer: Motif uses the return key to activate the default button on dialogs, bulletin boards, and forms. You can use the space key to activate the focus button. These are they same keyboard shortcuts as MS-Windows. ----------------------------------------------------------------------------- Subject: 132) Why can't I use accelerators on buttons not in a menu? [Last modified: Sept 94] 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. one workaround suggested 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. Another method is described below and was contributed by Harald Albrecht of Institute of Geometry and Practical Mathematics Rhine Westphalia Technical University Aachen (RWTH Aachen), Germany albrecht@igpm.rwth-aachen.de wrote (Jul 8, 1993): NOTE: Pointers to a more recent solution by the same author follow this code sample. My work-around of this problem looks like this: (I've written that code for a Motif Object Library in C++ so please forgive me for being object orientated!) The hack consists of a rewritten message loop which checks for keypresses <MAlt>+<key>. If MessageLoop() finds such a keypress HandleAcc() ist called and the widget tree is searched for a suitable widget with the right mnemonic. // -------------------------------------------------------------------------- // traverse the widget tree starting with the given widget. // BOOL TraverseWidgetTree(Widget w, char *pMnemonic, XKeyEvent *KeyEvent) { Widget wChild; WidgetList ChildList; int NumChilds, Child; KeySym LabelMnemonic; char *pMnemonicString; // Check if the widget is a subclass of label -- then it may have an // accelerator attached... if ( XtIsSubclass(w, xmLabelWidgetClass) ) { // ok. Now: get the widget's mnemonic, convert it to ASCII and compare // it with the Key we're looking for. XtVaGetValues(w, XmNmnemonic, &LabelMnemonic, NULL); pMnemonicString = XKeysymToString(LabelMnemonic); if ( pMnemonicString && (strcasecmp(pMnemonicString, pMnemonic) == 0) ) { // stimulate the keypress XmProcessTraversal((Widget)w, XmTRAVERSE_CURRENT); KeyEvent->type = KeyPress; KeyEvent->window = XtWindow(w); KeyEvent->subwindow = XtWindow(w); KeyEvent->state = 0; KeyEvent->keycode = XKeysymToKeycode(XtDisplay(w), XK_space); XSendEvent(XtDisplay(w), XtWindow(w), True, ButtonPressMask, (XEvent*) KeyEvent); KeyEvent->type = KeyRelease; XSendEvent(XtDisplay(w), XtWindow(w), True, ButtonReleaseMask, (XEvent*) KeyEvent); return True; } } // if this widget is a subclass of Composite check all the widget's // childs. if ( XtIsSubclass(w, compositeWidgetClass) ) { // if we're in a menu (or something like that) forget this leaf of the // widget tree! if ( XtIsSubclass(w, xmRowColumnWidgetClass) ) { unsigned char RowColumnType; XtVaGetValues(w, XmNrowColumnType, &RowColumnType, NULL); if ( RowColumnType != XmWORK_AREA ) return False; } XtVaGetValues(w, XmNchildren, &ChildList, XmNnumChildren, &NumChilds, NULL); for ( Child = 0; Child < NumChilds; ++Child ) { wChild = ChildList[Child]; if ( TraverseWidgetTree(wChild, pMnemonic, KeyEvent) ) return True; } } return False; } // TraverseWidgetTree // -------------------------------------------------------------------------- // handle accelerators (keypress MAlt + key) // #define MAX_MAPPING 10 BOOL HandleAcc(Widget w, XEvent *event) { Widget widget, OldWidget; static char keybuffer[MAX_MAPPING]; int CharCount; static XComposeStatus composeStatus; // convert KeyPress to ASCII CharCount = XLookupString((XKeyEvent*) event, keybuffer, sizeof(keybuffer), NULL, &composeStatus); keybuffer[CharCount] = 0; // Only one char is alright -- then search the widget tree for a widget // with the right mnemonic if ( CharCount == 1 ) { keybuffer[0] = tolower(keybuffer[0]); widget = w; while ( (widget != NULL) && !XtIsSubclass(widget, shellWidgetClass) ) { OldWidget = widget; widget = XtParent(widget); } if ( !widget ) widget = OldWidget; return TraverseWidgetTree(widget, keybuffer, (XKeyEvent*) event); } return False; // no-one found. } // HandleAcc // -------------------------------------------------------------------------- // modified message loop // loops until the Boolean pFlag points to is set to False void MessageLoop(Boolean *pFlag) { XEvent nextEvent; while ( *pFlag ) { if ( XtAppPending(AppContext) ) { XtAppNextEvent(AppContext, &nextEvent); if ( nextEvent.type == KeyPress ) { // Falls es ein Tastendruck ist, bei dem auch noch die ALT-Taste // (=Modifier 1) gedrueckt ist, koennte es ein Accelerator sein! if ( nextEvent.xkey.state & Mod1Mask ) if ( HandleAcc(XtWindowToWidget(nextEvent.xkey.display, nextEvent.xkey.window), &nextEvent) ) continue; // Mitteilung konnte ausgeliefert werden // und darf daher nicht den ueblichen // Weg gehen! } XtDispatchEvent(&nextEvent); } } } // TApplication::MessageLoop Harald Albrecht albrecht@igpm.rwth-aachen.de Institute of Geometry and Practical Mathematics Rhine Westphalia Technical University Aachen (RWTH Aachen), Germany NOTE: Harald Albrecht has re-designed his solution so that you can assign hotkeys to *every* widget by placing a label near that widget. Get the code from: ftp.informatik.rwth-aachen.de ( in: /pub/packages/Mnemonic/Mnemonic.tar.gz or from the WWW: file:// ----------------------------------------------------------------------------- Subject: 133) TOPIC: TOGGLEBUTTON WIDGET ----------------------------------------------------------------------------- Subject: 134) What widgets give the look of push buttons, but behavior of toggle buttons? Answer: Use the XmToggleButton widget, setting XmNindicatorOn to False and XmNshadowThickness to 2. Also set XmNfillOnSelect to True. Otherwise, the background color of the button will not stay in the "armed" state. In Motif 1.2 (and later), if you specify a XmNselectColor and set XmNindicatorOn to False, then you need to set XmNfillOnSelect to True. XmNfillOnSelect is not necessary if you are not setting a XmNselectColor. Glenn McMillen, mcmillen@meadow.mdso.vf.ge.com and Ken Lee ----------------------------------------------------------------------------- Subject: 135) Can I customize XmToggleButton to use my own indicator graphic (e.g., a check mark)? [Last modified: Nov 96] Answer: There is no direct resource for the graphic. One way to work around this is to disable the indicator (XmNindicatorOn False) and then install selected/unselected pixmaps containing both your graphic and your text (XmNselectPixmap and XmNselectPixmap). Also disable the button shadows (XmNshadowThickness 0) if you don't want those. Ken Lee ----------------------------------------------------------------------------- Subject: 136) TOPIC: ICON WIDGET and PIXMAPS ----------------------------------------------------------------------------- Subject: 137) What is XPM? [Last modified: Sept 98] Answer: XPM is file format for color images. A programming libary is also available. XPM is based on the standard XBM monochrome file format and Xlib related convenience functions. The XPM home page is: http://www.inria.fr/koala/lehors/xpm.html It has pointes to the source code and detailed documentation. Ken Lee ----------------------------------------------------------------------------- Subject: 138) How do I convert my XPM file into a Pixmap? [Last modified: Sept 98] Answer: Motif 2.0 and later contain an XPM-to-pixmap resource converter, so you can specify your pixmaps as resources. In Motif 1.2, you have to use the XPM library to load the XPM files. Ken Lee ----------------------------------------------------------------------------- Subject: 139) How can I display a multi-color image in a widget? [Last modified: Sept 95] Answer: Get the XPM library and read the documentation. Get xpaint from ftp.x.org, also get the jpeg and tiff libraries on the internet. From these you can easily create the code to read in gif, jpeg, and tiff. Read the images into and XpmImage format. Then use one of the Xpm conveneince functions to create wither an XImage or a Pixmap from your data. The xpm lib will take care of the color allocation and Pixmap/XImage creation, then you can just use expose routines to copy the Pixmap into a dialog or any window.... Thanks to Ramiro Estrugo (restrugo@fateware.com) ----------------------------------------------------------------------------- Subject: 140) Can I use XmGetPixmap in Motif 1.2 to create colored images? [Last modified: Oct 95] Answer: Doug Rand (drand@sgi.com) writes: XmGetPixmap only converts XBM [X bitmap] files in 1.2. In 2.0 it supports XPM [X Pixmap] files. You can register a more capable converter and set the pixmap via resources as a workaround. You can also use libXpm directly...[Note that] even now there isn't a "standard" color pixmap file format. There are several. It is relatively recently that many people have settled on XPM. But even so not everyone has done this. ----------------------------------------------------------------------------- Subject: 141) Why does XpmCreatePixmapFromData fail with a pixmap containing a large number of colors? XpmCreatePixmapFromData gives me a -4 errno (which is XpmColorFailed) when I try using a pixmap with 242 colors [Last modified: Oct 95] Answer: Ramiro Estrugo (restrugo@fateware.com) writes: If you are allocating 242 colors in an 8 bit display, then you are likely to run out of colors. If you carefully read the Xpm manual, you will notice that one of the Xpm values that you can modify is the "closeness". This value will control the actual closness of the colors allocated by the Xpm library. According to the Xpm manual: o The "closeness" field(s) (when set) control if and how colors are found when they failed to be allocated. If the color cannot be allocated, Xpm looks in the colormap for a color that matches the desired closeness. o The value is an integer in the range 0 (black) - 65535 (white) o A closeness of less than 10000 will cause only "close" colors to match. o A cliseness of more than 50000 will allow quite disimilar colors to match. o A closeness of more than 65535 will allow any color to match. o A value of 40000 seems reasonable for many situations requiring reasonable but not perfect color matches. Try it and your application is less likely to die or look "ugly" due to the lack of colors. The worst that can happed is that the colors you get are not 100% what you wanted them to be. Most of the time, you might not even notice the difference. This is usually due to badly designed icons or duplicate color entries (close rgb values) in .xpm files. NOTE: for even more control over Xpm color allocation, you can control the closeness of each RGB color component individually. For example: XpmAttributes attrib; int valuemask; attrib.valuemask |= XpmCloseness; attrib.closeness = 40000; /* also */ attrib.valuemask |= XpmRGBCloseness; attrib.red_closeness = RED_CLOSENESS; attrib.green_closeness = GREEN_CLOSENESS; attrib.blue_closeness = BLUE_CLOSENESS; pix = XpmCreateXYZFromABC(...,&attrib); Also, look in the Xpm documentation for more color control parameters. ----------------------------------------------------------------------------- Subject: 142) How can I convert a Sun/GIF/TIFF image to a pixmap? [Last modified: Oct 94] Answer: An application called "xv" (interactive image display for the X Window System) is useful for displaying and converting many image formats. From the man page: xv is an X11 program that displays images in the GIF, JPEG, TIFF, PBM, PGM, PPM, X11 bitmap, PDS/VICAR, Sun Rasterfile, and PM formats on 1-, 2-, 4-, 6-, 8-, 16-, 24-, and 32-bit X displays. xv will also read compress-ed versions of these files. You can get "xv" (shareware by John Bradley et al) from: ftp://ftp.cis.upenn.edu/pub/xv or: ftp://ftp.x.org/R5contrib/xv-3.01.tar.gz Another useful conversion package is "pbm" (portable bitmap file format) by Jef Poskanzer et al, available from: ftp://ftp.x.org/R5contrib/netpbm-1mar1994.tar.gz or: ftp://ftp.x.org/R5contrib/pbmplus10dec91.tar.Z (much older :-) You might also want to check the X11 FAQ for additional conversion options: ftp://ftp.x.org/contrib/faqs/FAQ ----------------------------------------------------------------------------- Subject: 143) How can I use Motif's pre-defined pixmaps? [Last modified: May 97] Answer: Motif 1.2 loads the following into its image cache: background, 25_foreground, 50_foreground, 75_foreground, horizontal, vertical, slant_right, and slant_left. These are defined in "man XmInstallImage". You can retrieve them with XmGetPixmap or XmGetPixmapByDepth. Ken Lee ----------------------------------------------------------------------------- Subject: 144) TOPIC: SCALE AND SCROLLBAR WIDGET ----------------------------------------------------------------------------- Subject: 145) Can the XmScale widget have arrows or tick marks in Motif 2.0? [Last modified: Sep 97] Answer: Daniel Dardailler (danield@w3.org) writes: In 2.0 and 2.1, Scale gets arrows (on both sides or same side), thermometer look, thumb slider option, tick marks, and editable resource. ----------------------------------------------------------------------------- Subject: 146) How can I set the color of a XmScale widget's trough? [Last modified: May 95] Answer: Ken Lee wrote: There is no direct API for setting this, but you can set it through resource files with "*XmScale*troughColor: red". Ken Sall, ksall@cen.com, adds: If you need to do this at runtime, you can use XtGetValues to get the scale's children, find the scrollbar, and set the XmNtroughColor: #include <Xm/ScrollBar.h> // for XmIsScrollBar Pixel selectColor; // assume this is set to the desired color WidgetList *kids; int nkids; Arg argList[1], tmpargs[2]; int i, s, t ; i = 0; XtSetArg ( argList[i], XmNtroughColor, selectColor ); i++; // Unfortunately, scale does not have a direct way // to get its scrollbar widget, so use Composite resources s = 0; XtSetArg (tmpargs[s], XmNnumChildren, &nkids ); s++ ; XtSetArg (tmpargs[s], XmNchildren, &kids ); s++ ; XtGetValues ( widgetId, tmpargs, s ); for ( t = 0; t < nkids; t++ ) { if ( XmIsScrollBar ( (Widget) kids[t]) ) // from ScrollBar.h { XtSetValues ( (Widget) kids[t], argList, i ); } } ----------------------------------------------------------------------------- Subject: 147) How does Motif implement mouse button auto-repeat on the scrollbar's arrow buttons? [Last modified: May 97] Answer: It installs a timer and checks the button state at each timeout. If the button is still down, it repeats the action. You can do this in your application, too. Ken Lee ----------------------------------------------------------------------------- Subject: 148) TOPIC: LABEL WIDGET ----------------------------------------------------------------------------- Subject: 149) 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 XmRowColumn, and XmNisAligned is True (the default), the XmRowColumn 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: 150) Why doesn't label alignment work in a XmRowColumn? Answer: XmRowColumn 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: 151) How can I set a multi-line label? [Last modified: Mar 96] Answer: In .Xdefaults *XmLabel*labelString: Here\nis\nthe\nLabel This method does not seem to work in some of the older Motif 1.0 versions. In code, char buf[128]; XmString msg; strcpy(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. Here's another approach from Jean-Philippe Martin-Flatin <syj@ecmwf.int> #include <Xm/Xm.h> #include <string.h> /*----------------------------------------------------- Create a new XmString from a char* This function can deal with embedded 'newline' and is equivalent to XmStringCreateLtoR, except it does not use non AES compliant charset XmSTRING_DEFAULT_CHARSET ----------------------------------------------------*/ XmString xec_NewString(char *s) { XmString xms1; XmString xms2; XmString line; XmString separator; char *p; char *t = XtNewString(s); /* Make a copy for strtok not to */ /* damage the original string */ separator = XmStringSeparatorCreate(); p = strtok(t,"\n"); xms1 = XmStringCreateLocalized(p); while (p = strtok(NULL,"\n")) { line = XmStringCreateLocalized(p); xms2 = XmStringConcat(xms1,separator); XmStringFree(xms1); xms1 = XmStringConcat(xms2,line); XmStringFree(xms2); XmStringFree(line); } XmStringFree(separator); XtFree(t); return xms1; } Do not use XmStringCreateLocalized() - it does not process the newline character in the way you want. In Motif 1.x, XmStringCreateLocalized() does NOT process newlines, but XmStringCreateLtoR() does. Thanks to Paul Tomblin (ptomblin@xcski.com) for the newline clarification. ----------------------------------------------------------------------------- Subject: 152) How can I have a vertical label? Answer: Make a multi-line 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: 153) How can I have a Pixmap in a Label? Answer: Bob Hays (bobhays@spss.com) wrote: Pixmap px_disarm, px_disarm_insens; Widget Label1; Pixel foreground, background; Arg args[4]; Arg arg[] = { { XmNforeground, &foreground }, { XmNbackground, &background } }; Label1 = XmCreateLabel ( Shell1, "Label1", (Arg *) NULL, (Cardinal) 0 ); XtGetValues ( Label1, arg, XtNumber ( arg ) ); px_disarm = XCreatePixmapFromBitmapData(display, DefaultRootWindow(display), mtn_bits, mtn_width, mtn_height, foreground, background, DefaultDepth(display,DefaultScreen(display))); px_disarm_insens = XCreatePixmapFromBitmapData(display, DefaultRootWindow(display), mtn_ins_bits, mtn_ins_width, mtn_ins_height, foreground, background, DefaultDepth(display,DefaultScreen(display))); n = 0; XtSetArg(args[n], XmNlabelType, XmPIXMAP); n++; XtSetArg(args[n], XmNlabelPixmap, px_disarm); n++; XtSetArg(args[n], XmNlabelInsensitivePixmap, px_disarm_insens ); n++; XtSetValues ( Label1, args, n ); XtManageChild(Label1); That will cause the foreground and background of your pixmap to be inherited from the one that would be used by OSF/Motif when the label is displayed. The advantage is that this will utilize any resource values the user may have requested without looking explicitly into the resource database. And, you will have a pixmap handy if the application insensitizes the label (without an XmNlabelInsensitivePixmap your label will go empty if made insensitive). [Bob's original code was for a PushButton. Just change all Label to PushButton for them.] ----------------------------------------------------------------------------- Subject: 154) Why doesn't the XmLabel widget obey the XmNwith and XmNheight that I give it? [Last modified: May 95] Answer: By default, XmLabel ignores these resources and instead computes a size based on the size of the label string or pixmap. You can change this behavior by setting XmNrecomputeSize to False. (Note that setting XmNrecomputeSize to False can dramatically improve performance if you have alot of labels or change them frequently.) Ken Lee ----------------------------------------------------------------------------- Subject: 155) How do you set the background color of a label widget using XtVaTypedArg? [Last modified: July 96] Answer: Use the XmNbackground resource to control the background color, e.g. strcpy(bgcolor, "yellow"); XtVaSetValues(widget, XtVaTypedArg, XmNbackground, XtRString, bgcolor, strlen(bgcolor) + 1, NULL); The length of the color string is plus one to include the null character. XtRString is the type to be converted. The conversion is required because XmNbackground expects a Pixel type. Thanks to Martin Squicciarini (msquicci@resd.vf.ge.com). ----------------------------------------------------------------------------- END OF PART FIVE