[futurebasic] Re: [FB] Live window resizing (with control moves and other updating)

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : December 2008 : Group Archive : Group : All Groups

From: Brian Stevens <bstevens33@...>
Date: Sat, 13 Dec 2008 09:20:15 -0700
On Dec 13, 2008, at 4:15 AM, Robert Covington wrote:

> Can somebody tell or show me how to get this thingie below to work  
> as to live resizing...with control relocation? The basic window  
> making function is below, I stripped it all to the minimums.

RC - I've sent a simple example backchannel that shows how to do this  
with a nib. You can make the calls to set the layout, as some of  
Steve's sample calls showed, but it is much easier in the nib. The  
other example worth looking at is "FBShell" in the FBtoC examples.

>
> I need to be able to live grow the window (user pulling grow box)  
> and move the cancel and print buttons (and a couple others not seen)  
> to the margins while they do, while maintaining the same aspect  
> ratio as the initial build proportions

The example sent does this.



> , as well as making sure it cannot go below the minimum size, same  
> as built

Setting minimum and maximum sizes, while related, is another matter.  
I'm using carbon events and not FB events, so you will have to  
translate. In my Windowhandler when a window activate event  
( _kEventWindowActivated ---- should be _wndActivate in FB events ) is  
received, a function is called to set minimum and maximum window  
sizes. Most of my windows can be enlarged to screen size ( but not  
allowed to cover the dock or the menu bar ). To get the maximums call:  
fn GetAvailableWindowPositioningBounds( fn GetMainDevice(), @r ) where  
'r' is a Rect structure. This returned Rect will not include the menu  
bar and dock ( like it would if the FB system screenwidth/screenheight  
calls are used ). Minimums are hard coded if they are needed ( this is  
just what I do not necessarily the best idea ). Once the min/max sizes  
are set in the vars,  call fn SetWindowResizeLimits( w, min, max )  
where 'w' is a WindowRef and min max are HISize to actually establish  
those limits for the window.




> . I'd need at the same time, to update a display rect (not shown, in  
> the middle), which I copy a preview to...live, so would need an  
> entry and exit point.

Anytime something has to be done ( aside from the resizing which is  
handled automatically via the layout settings in the nib ) when the  
size changes, I typically install a bounds changed handler to  
intercept the event.  I can post bounds changed handler code but it  
has been posted many times and is the examples. Let me know if you  
need it.




>
>
> Example below...Any help appreciated. I've always hacked into Fn  
> FBWindowGrow in the runtime for stuff like this, but can only get  
> one aspect ratio to stay constant...which is fine for a palette, but  
> not for a print preview...

Hacking into the runtime is a sure way to make your code break with  
FBtoC. My suggestion is to avoid this method.



>
>
> I know you can lock things when using a NIB, and they'll auto  
> relocate at least in IB, and Cocoa, but not sure how in FB.
>
> _preWndGrow is only a one time notice apparently...does not  
> repeat...I need a new _whileWndGrowing dialog event. ;)

See comment earlier on bounds changed handler....that is what you are  
describing.


Brian S.