From: snail@lsl.co.uk
Newsgroups: comp.windows.x.motif
Subject: Re: Help with RowColumn alignment
Date: 2 Sep 92 14:14:55 GMT
Organization: Laser-Scan Ltd., Cambridge

In article <1992Sep1.102453.13839@rks.se>, vaxtosv@rks.se writes:
> In article <5572@ucsbcsl.ucsb.edu>, 6500mack@ucsbuxa.ucsb.edu (Michael P. Mack) writes:
>> I'm trying to create an input section of a program that that has
>> a Label and a Text widget side-by-side.  Since there are many inputs,
>> I decided to use a RowColumn container for alignment.  This turned
>> out to be unacceptable since the Text widgets were created as large
>> as the largest Label in the first column:
>> 
>>     -----------------------------------------------------------
>>     |  -------------------------   -------------------------  |
>>     |  |                       |   |                       |  |
>>     |  |       Label 1         |   |        Text 1         |  |
>>     |  |                       |   |                       |  |
>>     |  -------------------------   -------------------------  |
>>     |                                                         |
>>     |  -------------------------   -------------------------  |
>>     |  |                       |   |                       |  |
>>     |  |       Label 2         |   |        Text 2         |  |
>>     |  |                       |   |                       |  |
>>     |  -------------------------   -------------------------  |
>>     |                                                         |
>>     |  -------------------------   -------------------------  |
>>     |  |                       |   |                       |  |
>>     |  |       Label 3         |   |        Text 3         |  |
>>     |  |                       |   |                       |  |
>>     |  -------------------------   -------------------------  |
>>     -----------------------------------------------------------
>> 
>> So instead of using a single RowColumn, I used two and have run into
>> a different problem which has become rather annoying.  Now the Text
>> widgets are of the correct width, but the Labels no longer line up
>> with the Text widget that they refer to:
>> 
>>   -----------------------------------------------------------
>>   | ------------------------------- ----------------------- |
>>   | |  -------------------------  | |  -----------------  | |
>>   | |  |       Label 1         |  | |  |               |  | |
>>   | |  -------------------------  | |  |    Text 1     |  | |
>>   | |  -------------------------  | |  |               |  | |
>>   | |  |       Label 2         |  | |  -----------------  | |
>>   | |  -------------------------  | |                     | |
>>   | |  -------------------------  | |  -----------------  | |
>>   | |  |       Label 3         |  | |  |               |  | |
>>   | |  -------------------------  | |  |    Text 2     |  | |
>>   | |                             | |  |               |  | |
>>   | |                             | |  -----------------  | |
>>   | |                             | |                     | |
>>   | |                             | |  -----------------  | |
>>   | |                             | |  |               |  | |
>>   | |                             | |  |    Text 3     |  | |
>>   | |                             | |  |               |  | |
>>   | |                             | |  -----------------  | |
>>   | ------------------------------- ----------------------- |
>>   -----------------------------------------------------------
>> 
>> Both RowColumn widgets are children of a Form with attachments set to
>> XmATTACH_FORM on all sides (except the inner attachment where RowCol2
>> is attached to RowCol1).  I tried setting up RowCol1 as XmHORIZONTAL
>> with 3 columns, but the result was that Label3 expanded to fill all of
>> the space below Label2 which was left unchanged.  I expected this to
>> work since XmNpacking is set to XmPACK_COLUMN which says it puts all
>> the children into identically sized boxes.
>> 
>> Does anybody know how to fix this?
>> 
>> 
>> Mike Mack
>> 6500mack@ucsbuxa.ucsb.edu
>> 
> Your problem lies in the fact that the height of your Label's windows
> are much smaller that your TextField's windows.
> There are quite many resources that makes up the size of primitive widget
> windows, if you are using the same font in both your labels and text widgets 
> you should be able to align labels and texts in two diffrent RowColumns
> providing you modify some of their resources.
> I'll supply you with a list of the resources that makes up the total height
> of windows for Labels, PushButtons and TextFields, and include the default
> values.
> 
> Resource             Label       Pb     Text
> -------------------  -----    -----    -----
> borderWidth:             0        0        0  	(* 2)  (Added outside window)
> marginBottom:            0        0      N.A. 	(* 1)
> marginTop:               0        0      N.A. 	(* 1)
> marginHeigh:             2        2        5  	(* 2)
> shadowThickness:         0        2        2  	(* 2)
> highlightThickness:      0        2        2  	(* 2)
> 
> Total height             
> exluding font height:    4       12       18
> 
> As you can see a Text widget's window is quite much higher. 
> I would suggest you set XmNmarginHeight on your labels to 9 which will
> make them equal.

No, No, No. 
Do it like this. I've done it many time sand it's a doddle.

One vertical XmRowColumn.
All it's children are XmForms.
The XmForms hold an XmLabel and an XmText (and whatever else you want).
Once everything is managed, you can determine the widest XmLabel and widest
XmText and widest (whatever). Add them all up and set the XmNfractionBase of
every XmForm (which is a child of teh XmRowColumn) to this value. Then just
set all the attachments of the XmForm children to XmATTACH_POSITION and the
XmN(left/right)Position to the appropriate value determined from the
widest values of each appropriate resource. ie:-
For all children of each XmForm set the top and bottom attachments to 
XmATTACH_FORM.

For the Label:

XmNleftPosition = 0;
XmNrightPosition = widest XmLabel width;

For the Text

XmNleftPosition = widest XmLabel width;
XmNrightPosition = widest XmLabel width + widest XmText width;

For the whatever

XmNleftPosition = widest XmLabel width + widest XmText width;
XmNrightPosition = you get the picture....

BUT OSF, IT WOULD BE NICE TO HAVE A ROWCOLUMN WHICH DOES DO GENUINE ROWS AND
COLUMNS WITHOUT ME HAVING TO FART ABOUT LIKE ABOVE.

No I haven't used the Xbae matrix widget. Maybe I should.

snail@lsl.co.uk      

Interviewer: "What's the most satisfying thing about being in
              The Sisters Of Mercy?"
Eldritch:    "When I collapse at the end of it..."
Interviewer: "Do you mean that?"
Eldritch:    "Yeah...."

Vote for Bill Clinton. Vote for Bill Clinton. Vote for Bill Clinton.
Newsgroups: comp.windows.x.motif,comp.windows.x