[comp.windows.x] Geometry management philosophy/procedure

coltoff@PRC.Unisys.COM (Joel Coltoff) (01/07/89)

I have a question or two about geometry management. The interface we
are using has a form that contains three horizontally stacked text
widgets and another form at the bottom of the whole mess. In the bottom
form are a row of label widgets and two row of buttons. There are 10
buttons placed side by side.

What I want to happen is the that the size of the application is
controlled by the text in the largest button. That means make all the
buttons the same size then make the text widgets the same size as the
form that encloses the buttons. My problem is that I'm not sure how to
do this properly. What I did was realize the entire widget tree with
mappedWhenManaged set to false. Once all the widgets are realized I
find the largest button and then set sizes and positions of all the
other widgets. When this is done I do XtMapWidget(toplevel). Is this
the correct approach? If not what is a better way to do it?

Another feature I would like that complicates things a little more is
have my text widget be a fixed number of lines in height instead of a
fixed number of pixels. Even if it is a hack under R3 to get the the
font a widget is using it can be done. I can then configure the widgets
to the new size. It get a little messy because the y coordinates of the
widgets below the current one are likely to change based on the number
of lines displayed. Any hints on a good way to do this?

Thanks in advance.
-- 
	- Joel
		{psuvax1,sdcrdcf}!burdvax!coltoff	(UUCP)
		coltoff@burdvax.prc.unisys.com		(ARPA)

kit@ATHENA.MIT.EDU (Chris D. Peterson) (01/12/89)

> ...has a form that contains three horizontally stacked text
> widgets and another form at the bottom of the whole mess. In the bottom
> form are a row of label widgets and two row of buttons. There are 10
> buttons placed side by side.

I assume that you mean vertically stacked labels?  If this is the case then
you may gain better behavior by using a vpaned widget instead of a form for 
your topmost widget in the tree.

> What I want to happen is the that the size of the application is
> controlled by the text in the largest button.

???

I assume you are trying to get this?

----------    ----------    ----------    ----------
| label  |    |  foo   |    |   a    |    |long one|    
----------    ----------    ----------    ----------

----------    ----------    ----------    ----------
| button |    | button |    | button |    | button |    
----------    ----------    ----------    ----------

----------    ----------    ----------    ----------
| button |    | button |    | button |    | button |    
----------    ----------    ----------    ----------


There is not currently a widget in the athena widget set that will allow this
to happen, I have found that an application widget that makes all children
the same width as the longest child will do the proper thing, although it is
a hack.  Make sure to tell all the buttons not to automatically resize 
themselves (there is a resource for this in X11R3).

> Another feature I would like that complicates things a little more is
> have my text widget be a fixed number of lines in height instead of a
> fixed number of pixels.

The "right" solution is to be able to specify the height of the text widget
in lines as well as pixels, but since the Athena text widget does not
let you do this you must either hack it in, or do something like the following:

Specify a default font in an application defaults file, and the height of
the text widget (in pixels) that give you the number of lines that you want.
This will work correctly as long as the user does not change the font.  If
he does he is also able to change the height of the text widget so that it
will look right.  The advantage to this method is that is allows the user
to display a different number of lines than the default, (i.e  this not
as friendly, but more flexible).

						Chris D. Peterson     
						MIT X Consortium /
						Project Athena 

Net:	kit@athena.mit.edu		
Phone: (617) 253 - 1326			
USMail: MIT - Room E40-321
	77 Massachusetts Ave.		
	Cambridge, MA 02139		

meo@stiatl.UUCP (Miles O'Neal) (01/12/89)

In article <8901112355.AA18650@DORA.MIT.EDU> kit@ATHENA.MIT.EDU (Chris D. Peterson) writes:
>> Another feature I would like that complicates things a little more is
>> have my text widget be a fixed number of lines in height instead of a
>> fixed number of pixels.
>
>The "right" solution is to be able to specify the height of the text widget
>in lines as well as pixels, but since the Athena text widget does not
>let you do this you must either hack it in, or do something like the following:

This will certainly work; I used it until we ran into yet another stone wall
in the text widget. So we have written a replacement. It doesn't have all
the capability of the textWidget (ie, cut/paste, etc) yet; we just adds as
we goes. I suggest writing a macro or function that you pass a widget or
part of it's data structure, and the # of lines you want, that returns the
proper # of pixels. I can't get to mine right now, as we are downgrading
our OS (sigh), but if you want, I can send the macros & functions. Just drop
me email.

-Miles
(gatech!stiatl!meo)