[futurebasic] Re: [FB] How to zoom the Window

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : November 1998 : Group Archive : Group : All Groups

From: "Osamu Shigematsu" <shige@...>
Date: Wed, 11 Nov 1998 15:37:43 +0900
Thanks for your advice.

>Osamu wrote:
>> >I'm now writing a paint program and I want to set the zoomed window size to
>> >it's picture size, to show whole image when clicked the zoom button, such as
>> >Photoshop and other paint soft do.
>
>jonathan replied:
>> You will have to use the toolbox call SETWINDOWSIZE.
>> You will also need to find out the size of your image, full size,
>> pass that, and a window pointer to SETWINDOWSIZE and then
>> do an CALL INVALRGN on the part of the window that you make
>> visible.
>
>Or better yet, just use FB's SETZOOM statement.

I wrote following routine for calculate the best zoom monitor, however, I
found the other problem.
FN BestMonitor needs zooming window's size, not image size. Doc windows of
System 7.x do not have frame, but OS 8's window have it.

In PG, I'm going to do that.

CASE _windowZoomIn
  rect;8 = [myRecHndl&] + _myImageRect'"Load Image Rect
  CALL OFFSETRECT (rect,-rect.left%,-rect.top%)
  scale% = myRecHndl&..myImageScale%
  rect.right%  = rect.right%  * scale% / 256
  rect.bottom% = rect.bottom% * scale% / 256
  '" I get image size (rect) on screen, but not window rect....
  FN BestMonitor(rect)
  WINDOW gActiveDoc%,,@rect'"resize it

usage: FN BestMonitor(windowRect)
windowRect: Zooming Window's Size, NOT IMAGE SIZE

CLEAR LOCAL FN CalcWrapArea(@rect1Ptr&,@rect2Ptr&)
DIM rect1;0,t1%,l1%,b1%,r1%
DIM rect2;0,t2%,l2%,b2%,r2%
DIM a%,b%,c%,d%
DIM wd%,ht%

rect1;8 = rect1Ptr&
rect2;8 = rect2Ptr&
a% = l1% : b% = r1% : c% = l2% : d% = r2%
IF a% > c% THEN SWAP a%,c% : SWAP b%,d%
SELECT CASE
CASE b% <= c% : wd% = 0
CASE b% >= d% : wd% = d% - c%
CASE ELSE     : wd% = b% - c%
END SELECT
'
a% = t1% : b% = b1% : c% = t2% : d% = b2%
IF a% > c% THEN SWAP a%,c% : SWAP b%,d%
SELECT CASE
CASE b% <= c% : ht% = 0
CASE b% >= d% : ht% = d% - c%
CASE ELSE     : ht% = b% - c%
END SELECT
END FN = wd% * ht%

CLEAR LOCAL FN BestMonitor(@rectPtr&)
DIM err%,state%,mBarH%
DIM rect;0,t%,l%,b%,r%
DIM Mrect;0,Mt%,Ml%,Mb%,Mr%
DIM Drect;0,Dt%,Dl%,Db%,Dr%
DIM MDrect;8
DIM gdH&,count%,scan%,area&,newArea&

rect;8 = rectPtr&
CALL OFFSETRECT(rect,-l%,-t%)
'
`     SUBQ.W    #$2,SP
`     DC.W      $3EB8,$0BAA
`     MOVE.W    (SP)+,^mBarH%
'
gdH&   = FN GETDEVICELIST
count% = 0
area&  = 0
'
WHILE gdH& <> 0
state%  = FN HGETSTATE(gdH&)
err%    = FN HLOCK(gdH&)
Drect;8 = [gdH&] + _gdRect                          '"Load rectangle of the
device
err%    = FN HSETSTATE(gdH&,state%)
INC(count%)                                         '"increment number of
the founded device
LONG IF {[gdH&] + _gdFlags} AND _mainScreen%
'" the current device is main monitor,
'" so get rid of the menu bar area
Dt% = Dt% + mBarH%
'" Load to MDrect (Main Device rect),
'" in order to use Main Device rect in case of we can not find the best
device.
MDrect;8 = @Mrect    
END IF
'" calc wrap area between rect and Drect
newArea& = FN CalcWrapArea(rect,Drect)
LONG IF area& < newArea&
area&   = newArea&
Mrect;8 = @Drect
END IF
gdH& = FN GETNEXTDEVICE(gdH&)                       '" search next
WEND
'
IF area& = 0 THEN Mrect;8 = @MDrect                 '" we can not find best
monitor // use main monitor
CALL INSETRECT (Mrect,20,20)                        '" inset 20 pixels as a
margin
'" move (and resize) window into the best monitor
LONG IF t% < Mt%
CALL OFFSETRECT(rect,0,Mt%-t%)
END IF
LONG IF b% > Mb%
CALL OFFSETRECT(rect,0,Mb%-b%)
END IF
'
LONG IF l% < Ml%
CALL OFFSETRECT(rect,Ml%-l%,0)
END IF
LONG IF r% > Mr%
CALL OFFSETRECT(rect,Mr%-r%,0)
END IF
'
BLOCKMOVE @t%,rectPtr&,8
END FN