[futurebasic] Zoom by window menu

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : October 2006 : Group Archive : Group : All Groups

From: Yoshiyuki Hasegawa <hase44@...>
Date: Sun, 22 Oct 2006 05:08:54 +0900
Hi.

How is the main window prevented from entering under the palette  
window when the zoom is selected from the window menu?
It is not good for the current state to resize the window.

My best regards.

Yoshiyuki;

Test code
'-------------------------
include "Tlbx CarbonEvents.incl"

local fn InstallWindowBoundsChangingHandler( wNum as long, wRect as  
^rect )
'~'1
dim as EventTypeSpec   evnt
dim as WindowRef     @ w
begin globals
dim as proc            sBoundsChangingUPP
end globals

long if ( sBoundsChangingUPP == _nil )
sBoundsChangingUPP = fn NewEventHandlerUPP( ツ
   [proc "WindowBoundsChangingHandler" + _FBprocToProcPtrOffset] )
end if

evnt.eventClass = _kEventClassWindow
evnt.eventKind  = _kEventWindowBoundsChanging
get window wNum, w
end fn = fn InstallEventHandler( fn GetWindowEventTarget( w ),ツ
                 sBoundsChangingUPP, 1, @evnt, #wRect, #0 )

long if 0
"WindowBoundsChangingHandler"
enterproc fn WindowBoundsChangingHandler( ツ
     nextHandler as EventHandlerCallRef,ツ
     theEvent as EventRef,ツ
     userData as ^rect ) = OSStatus
'~'1
dim as Rect         r
dim as long         wTop, wWidth
dim as UInt32     @ changeAttribute

call GetEventParameter( theEvent, _kEventParamAttributes,ツ
     _typeUInt32, #0, sizeof( UInt32 ), #0, @changeAttribute )
call GetEventParameter( theEvent, _kEventParamCurrentBounds,ツ
     _typeQDRectangle, #0, sizeof( Rect ), #0, @r )

long if ( changeAttribute and _kWindowBoundsChangeSizeChanged )
///Window resized

wWidth  = userData.right
wTop    = userData.top
r.right = r.left + wWidth
r.top   = r.top - 44 + wTop

call SetEventParameter( theEvent, _kEventParamCurrentBounds,ツ
     _typeQDRectangle, sizeof( Rect ), @r )

xelse
//Window moved
end if
exitproc = _noErr
end if

local fn FloatingPalette
'~'1
dim as Rect    r
SetRect(r, 12, 22, 600, 70)
appearance window -1, "", @r, _kFloatingWindowClass,  
_kWindowSideTitlebarAttribute
appearance window 1
end fn

local fn MainWindow
'~'1
dim as WindowAttributes wa
dim as Rect r
wa = _kWindowStandardDocumentAttributes _kWindowLiveResizeAttribute
SetRect(r, 0, 94, 600, 500)
appearance window -2, "MainWindow", @r, _kDocumentWindowClass, wa

fn InstallWindowBoundsChangingHandler( 2, r )

appearance window 2
end fn

dim as MenuRef @ windowMenu

call CreateStandardWindowMenu( 0, windowMenu )
InsertMenu( windowMenu, 0 )

fn FloatingPalette
fn MainWindow

do
HandleEvents
until 0
'---------------------------------