home *** CD-ROM | disk | FTP | other *** search
- property myDialog, myParams, myName
-
- on new me
- set myParams to [:]
- set myName to EMPTY
- return me
- end
-
- on show me, theName
- set myName to theName
- set theFile to getaProp(getaProp(myParams, myName), #file)
- set myDialog to window "dialog"
- set the windowType of myDialog to 3
- set the fileName of myDialog to the pathName & "dialog" & fileDelimiter() & theFile
- set the rect of myDialog to rect(0, 0, 288, 112)
- set the rect of myDialog to the rect of myDialog - 10000
- open(myDialog)
- centreDialogOnStage(me)
- updateStage()
- end
-
- on dispose me
- tell myDialog
- cleanup()
- end tell
- close(myDialog)
- forget(myDialog)
- set myName to EMPTY
- set myDialog to EMPTY
- dontPassEvent()
- end
-
- on hide me
- moveToBack(myDialog)
- updateStage()
- end
-
- on handle me, theButton
- set theParams to getaProp(myParams, myName)
- if not voidp(theParams) then
- set theActions to getaProp(theParams, #actions)
- do(getAt(theActions, theButton))
- end if
- end
-
- on setProperties me, theName, theFile, theAction
- set theProps to [:]
- setaProp(theProps, #file, theFile)
- setaProp(theProps, #actions, theAction)
- setaProp(myParams, theName, theProps)
- end
-
- on moveDialogWindow me
- global myDialog
- set vOrigRect to the rect of myDialog
- set vOrigHorizontal to the mouseH
- set vOrigVertical to the mouseV
- set vNewRect to rect(0, 0, 0, 0)
- repeat while the stillDown
- set vHorizontalDelta to the mouseH - vOrigHorizontal
- set vVerticalDelta to the mouseV - vOrigVertical
- set the left of vNewRect to the left of vOrigRect + vHorizontalDelta
- set the right of vNewRect to the right of vOrigRect + vHorizontalDelta
- set the top of vNewRect to the top of vOrigRect + vVerticalDelta
- set the bottom of vNewRect to the bottom of vOrigRect + vVerticalDelta
- set the rect of myDialog to vNewRect
- updateStage()
- tell myDialog
- updateStage()
- end tell
- end repeat
- end
-
- on centreDialogOnStage me
- set theRect to the rect of myDialog
- set theWidth to the right of theRect - the left of theRect
- set theHeight to the bottom of theRect - the top of theRect
- set newRect to rect(0, 0, 0, 0)
- set centreV to the stageTop + ((the stageBottom - the stageTop) / 2)
- set centreH to the stageLeft + ((the stageRight - the stageLeft) / 2)
- set the left of newRect to centreH - (theWidth / 2)
- set the right of newRect to the left of newRect + theWidth
- set the top of newRect to centreV - (theHeight / 2)
- set the bottom of newRect to the top of newRect + theHeight
- set the rect of myDialog to newRect
- end
-