[futurebasic] Re: [FB] Jumpin' Jimminy

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : July 2003 : Group Archive : Group : All Groups

From: Robert Covington <artlythere@...>
Date: Wed, 23 Jul 2003 20:31:42 -0400
On Wednesday, July 23, 2003, at 07:20  PM, Ken Shmidheiser wrote:

> Okay, here is one of those "I'm too stupid, lazy, (--fill in your 
> word--) to figure this out" questions.
>
> I'm using a disclosure triangle to reveal a part of a window with 
> additional options/info. Since the window changes dimension with each 
> click of the triangle, I am attempting to maintain the present window 
> coordinates using the new Appearance WINDOW() commands on Carbon OS X.
>
> Now the problem: Each time the triangle is clicked the window jumps 
> upward. After several clicks it has moved off the screen.
>
> Could some kind soul show me the error of my ways?
>
> Thanks,
>
> Ken
>
>
> l = window(_kFBstructureLeft)
> t = window(_kFBstructureTop)
> w = window(_kFBstructureWidth)
> h = window(_kFBstructureHeight)
>
> long if value = 1
> setrect( r, l, t, l + 580, t + 460 )
> window 1,,@r
> window output 1
> xelse
> setrect( r, l, t, l + 580, t + 230 )
> window 1,,@r
> window output 1
> end if
>

The fault lies in the l and t vars...each time you use the toggle, and 
the window is rebuilt, it is changing the left and right. You must set 
L and T manually to a more static arrangement.

The below solves your problem.


'~'A
'                       Runtime : Rntm Appearance.Incl
'                           CPU : Carbon
'                      Debugger : Off
'               DIM'd Vars Only : On
'              No Re-DIM'd Vars : On
'                    CALL Req'd : Off
'                 Register Vars : On
'                MacsBug Labels : On
'           Ary Bounds Checking : On
'                     QB Labels : Off
'                 Optimize STR# : On
'         Make Line Start Table : Off
'                 Show Warnings : On
'~'B

// Appearance Only
local
dim wRefCon     as ^^FBwindowDescription
dim theElementH as ^^FBWListElem
dim w           as WindowRef
DIM Exists      As Int
Local FN WindowExists( wNum as long )
'~'1
w = 0 // default not found
theElementH = gFBWindListH
Exists = _False
while theElementH
wRefCon = fn GetWRefCon( theElementH..w )
long if wRefCon..FBwRef == wNum // found
Exists = _True
exit while
end if
theElementH = theElementH..qLink
wend
end fn = Exists


Local
DIM theWnd as Long
DIM @pt as point
Local FN GetWindowPosition(whichWnd as long,myPtr as Ptr)
long if FN WindowExists(whichWnd)
theWnd = Window(_outPutWnd)
Window OutPut whichWnd
pt.h% = 0
pt.v% = 0
localtoglobal( pt)
Long if pt.h%  > 0 and pt.v% > 0
blockmove @pt,myPtr,4
End if
Window output theWnd
End If
End FN

local fn BuildWindow
dim as rect r

setrect( r, 0, 0, 580, 460 )
appearance Window -1, "Jumpin' Jimminy", @r, ¬
_kDocumentWindowClass, _kWindowStandardFloatingAttributes

def SetWindowBackground( _kThemeActiveDialogBackgroundBrush,_zTrue)

text _applFont, 12
edit = 4
setrect( r, 20, 20, 560, 200)
edit field 1,"Doin' stuff here...", @r,_framed,_leftJust

setrect( r, 20, 240, 560, 440)
edit field 2,"...and doin' more stuff here.", @r,_framed,_leftJust

setrect( r, 10, 212, 25, 228 )
appearance button 10, _activeBtn, 0, 0, 1,¬
"",@r,_kControlTriangleAutoToggleProc

setrect( r, 0, 0 , 580, 230 )
window -1,,@r

def windowreposition( 1, 0, _kWindowCenterOnMainScreen )

edit field 0

window 1

end fn

local fn WindowToggle( btnID as long )
dim as rect   r
dim as handle btnH
dim as long   value, t, l, w, h
DIM as Point myPt

  btnH = BUTTON&( btnID )
value = FN GETCONTROLVALUE( btnH )

FN GetWindowPosition(1,@myPt)

l = myPt.h%// window(_kFBstructureLeft)
t = myPt.v%//window(_kFBstructureTop)
w = window(_kFBstructureWidth)
h = window(_kFBstructureHeight)

long if value = 1
setrect( r, l, t, l + 580, t + 460 )
window 1,,@r
window output 1
xelse
setrect( r, l, t, l + 580, t + 230 )
window 1,,@r
window output 1
end if

edit field 0

end fn

local fn DoDialog
dim as long evnt, id

evnt = dialog(0)
id = dialog(evnt)

select case( evnt )
case _wndClose
select( id )
case 1 : gFBQuit = _zTrue
end select
case _btnClick
select( id )
case 10 : fn WindowToggle( id )
end select
end select

end fn

on dialog fn DoDialog

fn BuildWindow

do
handleevents
until gFBQuit
end