[comp.windows.x.motif] A row/column or form problem

boote@bierstadt.scd.ucar.edu (Jeff W. Boote) (01/12/91)

In article <10361@bunny.GTE.COM>, xev@GTE.COM (Xev Gittler) writes:
> I tried a form, with OK and HELP attached to their respective
> sides, and CLOSE attached to OK and HELP, but then CLOSE
> grows when the form is resized, instead of the space between
> the widget growing.

Try attaching CLOSE with XmATTACH_POSITION instead of attaching it to
the other widgets.  This should give it a relative position within the
form.  See the Programmers ref under XmForm.

-- 
Jeff W. Boote                   SCD/NCAR
boote@ncar.ucar.edu           Boulder, Colo

marbru@attc.UUCP (Martin Brunecky) (01/12/91)

In article <10361@bunny.GTE.COM> xev@GTE.COM (Xev Gittler) writes:
>I'm trying to set up a box with three buttons in it, so that one 
>button is always on the left, one on the right, and one in the center,
>like:
>
>   +-----------------------------------------------+
>   |                                               |
>   |   +----+          +-------+         +------+  |
>   |   | OK |          | Close |         | Help |  |
>   |   +----+          +-------+         +------+  |
>   |                                               |
>   +-----------------------------------------------+
>

    Well, using my WsMatrixBox I set: 
    WsNmatrixLayout: row
    WsNtiled: false
    WsNspacing:  16 
    (or specify the initial size of the box) and I am DONE.


    With Motif widgets only .... --(.
    I would probably struggle with nested configurations of XmForm.
    The result is likely to be both complicated and far from what
    you want. 

    Another option is to try one of the Motif Mesage boxes.
    You would have to somehow remove (unmanage ? or unmap ?) the
    label they put above the buttons, but this may be feasible
    (though unsupported and difficult to do without source).


-- 
=*= Opinions presented here are solely of my own and not those of Auto-trol =*=
Martin Brunecky                           {...}sunpeaks!auto-trol!marbru
(303) 252-2499                        (sometimes also:  marbru@auto-trol.COM )
Auto-trol Technology Corp. 12500 North Washington St., Denver, CO 80241-2404 

colin@nbc1.nbc1.ge.com (Colin Rafferty) (01/15/91)

In article <9896@ncar.ucar.edu> boote@bierstadt.scd.ucar.edu (Jeff W. Boote) writes:
> In article <10361@bunny.GTE.COM>, xev@GTE.COM (Xev Gittler) writes:
>> I tried a form, with OK and HELP attached to their respective
>> sides, and CLOSE attached to OK and HELP, but then CLOSE
>> grows when the form is resized, instead of the space between
>> the widget growing.
>
> Try attaching CLOSE with XmATTACH_POSITION instead of attaching it to
> the other widgets.  This should give it a relative position within the
> form.  See the Programmers ref under XmForm.

Using XmATTACH_POSITION is the right idea, but if you use it for one side
of CLOSE, then it's not centered.  If you use it for both sides of CLOSE,
then you still get the button growing.

What you need to do is have a new widget called CENTER which has height and
width of 0, and uses XmATTACH_POSITION of 50.  You then use XmATTACH_WIDGET
to attach CLOSE to CENTER.  Here is the relevent uil code:

    object Center : XmSeparator widget {
        arguments {
            XmNseparatorType = XmNO_LINE;
            XmNheight = 0;
            XmNwidth = 0;
            XmNleftAttachment = XmATTACH_POSITION;
            XmNleftPosition = 50;
            XmNrightAttachment = XmATTACH_POSITION;
            XmNrightPosition = 50;
        };
    };
    
    object Close : XmPushButton widget {
        arguments {
            XmNlabelString = 'Close';
            XmNleftAttachment = XmATTACH_WIDGET;
            XmNleftWidget = XmSeparator Center;
            XmNleftOffset = - (buttonWidth / 2);
            XmNrightAttachment = XmATTACH_WIDGET;
            XmNrightWidget = XmSeparator Center;
            XmNrightOffset = - (buttonWidth / 2);
        };
    };

--

-- 
Colin Owen Rafferty                      |         "Life is so complex, parts
colin@nbc1.ge.com                        |          of it must be imaginary."
{philabs,crdgw1,ge-dab}!nbc1!colin       |                         -Tim Thiel
	    (I don't speak for NBC.  Watch Tom Brokaw for that.)
-- 

-- 
Colin Owen Rafferty                      |         "Life is so complex, parts
colin@nbc1.ge.com                        |          of it must be imaginary."

Janet.Incerpi@MIRSA.INRIA.FR (Janet Incerpi) (01/15/91)

Yes, the Xform isn't exactly the most friendly object in the widget hierarchy.
i wanted to do exactly the same thing, figuring it must be easy given what you
see for the various selection boxes (3 buttons and perfect resizing).

i considered the XmAttach_Position approach (suggested by Jeff Boote), this gets
you almost there.  Unfortunately you'd be attaching the left or right side of
an object to a fixed (percentage) position.  This doesn't work since what you 
want is the middle of the middle button attached to the middle of the form.

My messy solution is to create a dummy button in the form.  This button, which i
arrange to have half the size of the middle button, is attached to the form, say
on the right attachment using XmATTACH_POSITION=50.  i then attach the middle 
button ("Close") to the dummy button.   That is, use attach_opposite_widget so 
that the left side of the dummy and middle buttons are aligned.  Now my middle 
button is perfect, except if you change the label.  You can't have everything!

The problem is in laying out widgets one sometimes need scaffolding and this
is not provided for.  Imagine that you did a drawing of what you wanted your 
object to look like, you'd draw a line in the form and position your Close
button with the help of this line.  After completing your drawing, you'd erase
the line.  My dummy widget is my scaffolding.  It is a quick and dirty solution
since i don't even erase my scaffolding, he's always there hidden by the middle
button.  A good motif programmer would probably write/do a geometry manager or
some such.  But alas, i'm not a good motif programmer, i specify stuff in UIL
and my application is programmed in Lisp --- never a dull moment!

	--janet