Newsgroups: comp.lang.smalltalk
Path: cantaloupe.srv.cs.cmu.edu!das-news2.harvard.edu!news2.near.net!howland.reston.ans.net!pipex!bnr.co.uk!bcarh8ac.bnr.ca!bcarh189.bnr.ca!nott!cunews!dbuck
From: dbuck@superior.carleton.ca (Dave Buck)
Subject: Re: Smalltalk/V framingRatio: question
Message-ID: <D4C1xF.2p4@cunews.carleton.ca>
Sender: news@cunews.carleton.ca (News Administrator)
Organization: Carleton University, Ottawa, Canada
References: <3iall9$12k@maverick.tad.eds.com>
Date: Tue, 21 Feb 1995 04:32:03 GMT
Lines: 62

In article <3iall9$12k@maverick.tad.eds.com>,
David Beaulieu <beaulieu@cae.atg.gmeds.com> wrote:
>However, I recently bought Dan Schafer's book, "Smalltalk                 
>Programming for Windows".  (I THINK that's the title).                    
>                                                                          
>In one application, he creates a TopPane with 3 SubPanes,                 
>and each SubPane is sent the framingRatio: message.                       
>                                                                          
>Schafer glosses over the "details" of the framingRatio                    
>method, promising to describe it in a later chapter, then                 
>conveniently forgetting to do so.                                         
>                                                                          
>Can anyone tell me how this method uses its parameter (a Rectangle)       
>to calculate the resulting area of the TopPane to use for the             
>SubPane?  Any help or pointers to other references would be               
>appreciated!                                                              
>

There are two ways to have Smalltalk/V automatically re-position and
re-size subpanes when the parent window changes size.  The first is,
as you say, to specify a framing ratio.  The framing ratio is a
rectangle that indicates what fraction of the total window will be
used by this pane.  The coordinates of the rectangle range from 0@0 to
1@1.  For example:

    framingRatio: (0@0 corner: 1@1)    "Take up the whole window"
    framingRatio: (0@0 corner: 0.5@0.5) "Take up the top left quarter"
    framingRatio: (0.5@0.5 corner: 1@1) "Take up the bottom right
quarter"

(Note, these examples are for V/Windows.  V/PM would be upside-down
from this).

This is ok if you always want your subpanes to scale uniformly with
the window size.

If you want to have a pane fixed relative to the sides or the bottom,
a simple framing ratio doesn't work.  At that point, you need to
specify a framing block.  A framing block is a block that takes one
parameter (the actual window size).  When evaluated, the block returns
the size of the pane.

Eg.
    framingBlock: [:rect | rect origin corner: rect corner - (10@0)]

This makes the pane take up all of the window except a 10 pixel strip
on the right hand side.  Note that you shouldn't put a '^' in to
return the value from the block.

Having said all this, I would recommend that you not worry about
framing block or framing ratios by using window layout tools such as
WindowBuilder from ObjectShare or the Parts Workbench.  You'll find
programming windows in V much more enjoyable with these tools.

David Buck
dbuck@ccs.carleton.ca

_________________________________
| David K. Buck                 |
| dbuck@ccs.carleton.ca         |
| The Object People             |
|_______________________________|
