[comp.windows.x.motif] Laying out widgets in rows and columns

koff@hpfcbig.SDE.HP.COM (Caroline Koff) (08/15/90)

I have a question about how to go about setting up the following
layout of XmStrings within a dialog box:

	----------------------------------------------------------
	|							 |
	| 0:  00000000  1:  00000000  2:  00000000  3:  00000000 |
	| 4:  00000000  5:  00000000  6:  00000000  7:  00000000 |
	| 8:  00000000  9:  00000000  10: 00000000  11: 00000000 |
	| 12: 00000000  13: 00000000  14: 00000000  15: 00000000 |
	|							 |
	|   ------------					 |
	|   |  Close   |					 |
	|   ------------					 |
	|							 |
	----------------------------------------------------------

Items like "1:" are labels, and the items like "00000000" are values
that can change in width.  Their types are XmStrings.  The box around
the word "Close" indicates a button labeled close.

Here is one solution: 
	- create a rowColumn widget with the form of the dialog
	  box as its parent.  I'll call this widget "rcm".
	- create the individual labels and values with rcm as 
	  their parent.
	- do the following resource settings:
		rcm*orientation:   horizontal
		rcm*packing:	   pack_column
		rcm*numColumns:	   4

This solution almost works.  It creates something like this:

 --------------------------------------------------------------------------
 |							 	   	  |
 | 0:      00000000  1:      00000000  2:      00000000  3:      00000000 |
 | 4:      00000000  5:      00000000  6:      00000000  7:      00000000 |
 | 8:      00000000  9:      00000000  10:     00000000  11:     00000000 |
 | 12:     00000000  13:     00000000  14:     00000000  15:     00000000 |
 |							                  |
 |   ------------					                  |
 |   |  Close   |					                  |
 |   ------------					                  |
 |							                  |
 --------------------------------------------------------------------------

Notice that there are huge gaps between the labels like "0:" and the
values like "00000000".  This is because XmNpacking set to pack_column
will resize the size of each child to the largest child's size.
(Please see the man page of XmRowColumn for a better explanation.)
Therefore in this case, all of the "0:" and "1:" type of label sizes
are as big/wide as the width of "00000000".

How can I make this dialog box look more like what I drew at the
beginning of this message?  Use a rowColumn widget for each of the
eight columns?  Don't use rowColumn at all and stick to forms and/or
bulletins?

I would appreciate any ideas!  Thanks!

--Caroline Koff
Software Engineering Systems Division, HP Ft. Collins.
koff@hpfclp.sde.hp.com

david@jpl-devvax.JPL.NASA.GOV (David E. Smyth) (09/21/90)

Easy: don't use the XmRowColumn, use the Table widget.

Available with the Widget Creation Library distribution.
You can get Wcl from devvax.jpl.nasa.gov in /pub or
from expo.lcs.mit.edu in /contrib.  The name of the
compressed tar file in both cases is the same:
Wc1_03.tar.Z

This version REQUIRES that clients be linked against
an ANSI C library (Wcl uses strstr).  The next version
due out in October does not make this requirement.

The Wcl distribution includes several examples of
using Table widgets for complex matrix layouts.

-------------------------------------------------------------------------
David Smyth                             david@jpl-devvax.jpl.nasa.gov
Senior Software Engineer,               seismo!cit-vax!jpl-devvax!david
X and Object Guru.                      (818)393-0983
Jet Propulsion Lab, M/S 230-103, 4800 Oak Grove Drive, Pasadena, CA 91109
-------------------------------------------------------------------------
Life is tough: vacation in the South Pacific, work in Southern California.
                Tomorrow I'm off to EXUG in England!
-------------------------------------------------------------------------