From: cek@sdc.boeing.com (Conrad Kimball)
Newsgroups: comp.windows.x.motif
Subject: Re: Motif File Selection box!
Date: 11 Aug 92 19:07:52 GMT
Organization: Boeing Computer Services, Seattle, WA

In article <l85giuINNrot@male.EBay.Sun.COM>, lohia@prathvi.EBay.Sun.COM (Raj Lohia) writes:
|> 
|> Hi,
|> 
|> Does anyone has idea how can I modify motif file selection 
|> box to select multiple files? I will appreciate any help/info.

I used the following techniques to create such an alternate file selection
box behavior:

1.  Create the standard file selection box (FSB) as usual.

2.  Look up an application resource for the FSB to control the selection
    behavior, and use it to set the selection behavior of the scrolled file
    list within the FSB.  I used the same resource name that a scrolled list
    does, XmNselectionPolicy.  I.e., something like:

	Widget fsbw; /* file selection box widget */
	Widget flw;  /* file list widget within file selection box */

	typedef struct {
	    unsigned char selection_policy;
	} AltFSBResourceStruct;

	static AltFSBResourceStruct fsb_resources;

	#define AltFSBOffset(field) XtOffset(AltFSBResourceStruct *, field)

	static XtResource fsb_resourceSpec[] =
	{
	    {
		XmNselectionPolicy, XmCSelectionPolicy, XmRSelectionPolicy,
		sizeof(unsigned char), AltFSBOffset(selection_policy),
		XmRImmediate, (caddr_t) XmBROWSE_SELECT
	    }
	};

	XtGetApplicationResources(fsbw, (caddr_t) &fsb_resources,
					fsb_resourceSpec,
					XtNumber(fsb_resource_spec),
					NULL,
					0);
	flw = XmFileSelectionBoxGetChild(fsbw, XmDIALOG_LIST);
	XtVaSetValues(flw, XmNselectionPolicy,
			   fsb_resources.selection_policy,
			   NULL);

3.  Now that you can use resources to specify the full range of list
    selection behaviors for your FSB, you face the problem of how to
    display multiple selections in the FSB's selection window, which
    is a single-line text widget.

    In my case, if the resultant FSB selection policy from above is
    XmMULTIPLE_SELECT or XmEXTENDED_SELECT, I replace the standard
    selection text widget and its label widget with my own work widget,
    which is a form enclosing a label and a multi-line text widget inside
    a scrolled window.

    Why not use an XmScrolledText instead of an XmText within an
    XmScrolledWindow?  It had problems that I don't completely recall
    just now (something about I wanted to choose some combination of
    of scrolling policy, visual policy, and/or scrollbar display policy
    that XmScrolledText wouldn't accommodate).

    I unmanage the standard FSB selection text widget and its label, and
    I change the standard FSB text widget's type to multi-line.  (Even
    though it is unmanaged, it still exists, and the FSB still wants
    to use it internally).

    I override the translations of my new multi-line text widget so
    <Key>Return maps to a newline() action, and I add a value-changed
    callback to it, to propagate its value to the unmanaged standard FSB
    text widget.

    I add callbacks to the FSB file scrolled list to handle all the forms
    of selection callbacks, to propagate the selections to my new multi-line
    text widget (and thence, via its value-changed callback, to the unmanaged
    standard FSB text widget).

4.  Voila!  I have an FSB that appears to have a new XmNselectionPolicy
    resource, and which honors all the legitimate values that resource
    can assume.

--
Conrad Kimball		| Unix Server Tech Services, Boeing Computer Services
cek@sdc.boeing.com	| P.O. Box 24346, MS 7A-35
(206) 865-6410		| Seattle, WA  98124-0346