[comp.windows.x.motif] Resizing

cindy@dlb.uucp (Cindy Holstrom) (10/20/90)

I would like to know what strategies you may have used to handle
resizing of your application.

I (will) have a Motif application which contains:

BulletinBoard                      ------------------------------------
   MenuBar                         | Menu bar                         |
   DrawingArea                     ------------------------------------
   ScrollBar (horizontal)          |  Drawing Area                | ^ |
   ScrollBar (vertical)            |                              | " |
   RowColumn (children undefined)  |                              | " |
   Label                           |                              | v |
                                   | _____________________________|
                                   |  <==========================>    |
                                   ------------------------------------
                                   |  Row column                      |
                                   ------------------------------------
                                   |  Label                           |
                                   ------------------------------------

I want resizing of the window to effect only the drawing area. That is, up to
a maximum size, the expanding of the window will cause more of the drawing
area to be exposed.  This means that the scroll bars will have to be adjusted
to indicate how much of the drawing area is exposed. 

If my application had just the drawing area, I could use the Main Window.
But, with the additional widgets (Row column and label), I needed to put 
them all in one container.  I chose BulletinBoard (rather than Form) 
because I have not had very good results trying to construct this using Form.

I have a couple questions.

1. How does the application get notified that the windows/widgets have
   been resized?  There doesn't appear to be any callbacks for this. Do
   I need to have an event handler invoked?

2. Once the application has been informed that the windows/widgets have
   been resized, I assume it is possible to set new values for height, width,
   x, and y of some of the widgets. Have others gone through this process
   and what were the results?

Any help you can give me is appreciated.
-- 
Cindy Holstrom	{aeras,amdahl,ames,ardent,daver,netcom,sun,zygot}!dlb!cindy
D. L. Buck and Associates, Inc.; San Jose, California 95119; (408)972-2825

nazgul@alphalpha.com (Kee Hinckley) (10/20/90)

> I want resizing of the window to effect only the drawing area. That is, up to

At 1.1 Form can do things like this pretty well.  Otherwise the easiest thing
to do is use a David Harrison's Table widget (I have Motifized version if anyone
wants it).  It allows you to specify which widgets should stay their minimum
size and which may grow.
					-kee

argv@turnpike.Eng.Sun.COM (Dan Heller) (10/23/90)

In article <1990Oct19.175154.28038@dlb.uucp> cindy@dlb.UUCP (Cindy Holstrom) writes:
> BulletinBoard                      ------------------------------------
>    MenuBar                         | Menu bar                         |
>    DrawingArea                     ------------------------------------
>    ScrollBar (horizontal)          |  Drawing Area                | ^ |
>    ScrollBar (vertical)            |                              | " |
>    RowColumn (children undefined)  |                              | " |
>    Label                           |                              | v |
>                                    | _____________________________|
>                                    |  <==========================>    |
>                                    ------------------------------------
>                                    |  Row column                      |
>                                    ------------------------------------
>                                    |  Label                           |
>                                    ------------------------------------
>
> I want resizing of the window to effect only the drawing area. That is, up to
> a maximum size, the expanding of the window will cause more of the drawing
> area to be exposed.  This means that the scroll bars will have to be adjusted
> to indicate how much of the drawing area is exposed. 

There's no reason hypothetically that you can't use a MainWindow widget.
The drawing area can be set to be the "work area" and the other stuff can
simply be added as you would add any widget as a child of a parent.
However, in reality you are going to have other problems because the
MainWindow (and many of he other constraint widgets) do not ask children
what sizes they would like to be.  If they did, everything would work
out ok.

You could attempt a workaround by creating a resize() action for the
RowColumn and the Label to call XtQueryGeomtry() and resize those
widgets explicitly in case the MainWindow got resized.  You will probably
get several resizing flashes--your milage may vary.  The problem is,
you're going to have a hard time providing a MenuBar without the MainWindow
widget without it being resized weirdly.

You could try to use a PanedWindow and set the min and max sizes for
the RowColumn and Labels -- resizes will therefore affect only the
drawing area.

Note: your "label" at the bottom could be used as the "message area"
of the MainWindow, if you like.

I don't recommend using BulletinBoard widgets unless you want to write
your own resize routine for it to manage the sizes of the children
(which may not be difficult).  You could easly use a form and specify
the edges (left/right) of each of the widgets be XmATTACH_FORM and the
tops set to the widget above using XmNtopAttachment, XmATTACH_WIDGET.

> 1. How does the application get notified that the windows/widgets have
>    been resized?  There doesn't appear to be any callbacks for this. Do
>    I need to have an event handler invoked?

Use translations and specify action procedures (you write) to be called
when the <Resize> event takes place.

This is not intended to answer your question directly --you're going to
have to do some homework w.r.t. looking into XtAppAddActions().
--
dan
----------------------------------------------------
O'Reilly && Associates   argv@sun.com / argv@ora.com
Opinions expressed reflect those of the author only.