home *** CD-ROM | disk | FTP | other *** search
Text File | 1993-05-13 | 5.4 KB | 188 lines | [TEXT/ttxt] |
- \ Dialog support
- \ 12/22/84 cbd Version 1
- \ 7/23/85 cbd Fixed get:, added ReturnToModal
- \ 9/06/85 cdn putText & getText made to work with Control items
- \ 9/20/85 cdn Added draw:, disp: & ParamText
- \ 7/10/86 cdn Fixed ReturnToModal, added setProc:
- \ 7/21/86 cdn Added togItem
- \ 10/10/86 cdn Added hilite:
- \ 5/20/90 rfl the actual hilite is now a frame: method
- \ 11/21/90 rfl added setUserItem and UserItem class
- \ 12/24/90 rfl dialog items now match array items. First item in
- \ dialog array is at position 1. Position 0 does nothing. Actions: replaced
- \ 10/31/91 rfl modifed userItem to set its rectangle at set time
- \ 12/13/91 rfl SP added alive:
- \ 9/28/92 rfl added portBit: to make consistent with portBit: window
- \ 5/13/93 rfl protected getnew
- Decimal
-
- : Closer close: caller ;
-
- Int theItem
- Var itemHandle
- Int itemType
-
- 0 value rtm
-
- :CLASS Dialog <Super X-Array
-
- Int Resid
- Var dialPtr
- Var procPtr
- Int boldItem
-
- \ ( -- )
- :M CLOSE: get: dialPtr call DisposDialog clear: dialPtr ;M
-
- :M ALIVE: ( -- b) get: dialPtr 0 <> ;M
-
- :M SET: get: dialPtr call setPort ;M
-
- :M PORTBIT: ( -- abs) get: dialPtr 2+ ;M
-
- \ ( item# -- hndl ) get handle for item#
- :M HANDLE: { item# -- hndl } get: dialPtr item# makeInt
- abs: itemType abs: itemHandle abs: tempRect
- call GetDItem get: itemHandle ;M
-
- \ draws the frame around the hilit item
- :M FRAME: get: boldItem -dup
- IF savePort get: dialPtr call SetPort 3 3 pack call PenSize
- handle: self drop -4 -4 inset: tempRect
- abs: tempRect 16 16 pack call FrameRoundRect call penNormal restPort
- THEN ;M
-
- \ ( -- ) create dialog from resID
- :M GETNEW: 0 int: resid 0 -1 call GetNewDialog dup put: dialPtr
- 0= classErr" 170
- frame: self ;M
-
- :M SHOW: get: dialPtr call showWindow frame: self ;M
-
- \ ( cfa -- ) set dialog proc
- :M SETPROC: >body put: procPtr ;M
-
- \ ( -- ) display as modal dialog
- :M MODAL:
- BEGIN
- get: procPtr dup IF +base THEN abs: theItem call ModalDialog
- get: theItem ( 1-) exec: super
- rtm
- WHILE
- 0 -> rtm \ iterate every time ReturnToModal is executed
- REPEAT
- ;M
-
- \ ( act0 ... actN -- ) set the dialog's action handlers starting at element 1
- :M ACTIONS: ?ixobj limit 1- 0
- DO limit i- 1- (^elem) !
- LOOP ;M
-
- \ ( val item# -- )
- :M PUT: handle: self swap makeInt call SetCtlValue ;M
-
- \ ( item# -- val ) get value for an item#
- :M GET: handle: self >R word0 R>
- call GetCtlValue word0 ;M \ added word0 cbd 7/17/85
-
- \ ( resID -- ) Associate object with it's resource
- :M INIT: put: resID ;M
-
- :M PUTRESID: put: resID ;M
-
- \ ( item# -- ) Causes bold outline of the specified item
- :M HILITE: put: boldItem ;M
-
- \ ( item# -- addr len ) return a text item's text
- :M GETTEXT: handle: self buf255 +base get: ItemType dup 24 and
- IF drop call GetIText
- ELSE 4 and
- IF call GetCTitle
- ELSE 2drop 0 buf255 c! \ user item has no text
- THEN
- THEN
- buf255 count ;M
-
- \ ( addr len item# -- ) store an item's text
- :M PUTTEXT: { addr len item# -- } item# handle: self
- addr len str255 get: ItemType dup 24 and
- IF drop call SetIText
- ELSE 4 and
- IF call SetCTitle
- ELSE 2drop \ user item has no text
- THEN
- THEN ;M
-
- \ ( start end item# ) set selection range for text item
- :M SETSELECT: { start end item# -- } get: dialPtr
- item# makeInt start end pack call SeliText ;M
-
- \ ( -- ) force drawing of dialog before going to modal:
- :M DRAW: get: dialPtr call DrawDialog ;M
-
- \ set user item into dialog; userItem must start with rectangle data
- :M SETUSERITEM: { userItem -- } item: useritem handle: self drop
- get: tempRect put: userItem
- get: itemType $ 80 and
- IF disable: userItem ELSE enable: userItem THEN
- get: dialPtr getParms: userItem abs: userItem call setDItem ;M
-
- \ ( -- ) Initialize default handlers to close the dialog box
- :M CLASSINIT: limit 0 DO 'c closer i to: self LOOP ;M
-
- ;CLASS
-
- \ signal modal method to re-enter ModalDialog
- : ReturnToModal
- 1 -> rtm ;
-
- \ Toggle the check box or radio button
- : togItem
- get: theItem 1 over get: caller - swap put: caller
- ReturnToModal
- ;
-
- \ ( addr0 len0 addr1 len1 addr2 len2 addr3 len3 -- ) Substitute Dialog text
- : ParamText { \ p1 p2 p3 -- }
- str255 dup -> p3 -base count +
- >str255 dup -> p2 -base count +
- >str255 dup -> p1 -base count +
- >str255 p1 p2 p3 call ParamText
- ;
-
-
- \ 11.21.90 rfl User Item class for use in dialogs. The proc definition should conform
- \ to IM where the proc draws the item; for example, if the item is a clock,
- \ it wil draw the clock with the current time displayed. When this procedure
- \ is called, the current port will have been set by the Dialog Manager to the
- \ dialog window's grafport. The procedure must have two parameters, a
- \ window pointer and an item number. If the procedure draws in more than
- \ one dialog window, the ptr tells it which one to draw in. The item number
- \ tells it which item to draw, if it draws more than one. Since itemNo
- \ is an integer, must add word0 to make long.
-
- :CLASS userItem <super rect
-
- var myProc
- int disabled
- int itemNo
-
- :M item: ( -- n) get: itemNo ;M
- :M putItem: ( n --) put: itemNo ;M
-
- :M disabled?: ( -- int) int: disabled ;M
-
- :M disable: ( --) 128 put: disabled ;M
-
- :M enable: ( --) clear: disabled ;M
-
- :M setProc: ( cfaproc --) >body put: myProc ;M
-
- :M getParms: ( -- int int proc) int: itemNo int: disabled get: myProc +base ;M
-
- ;CLASS
-
-
- \ example proc to draw Rectangle
- \ :PROC drawRect word0 2drop draw: myUserItem ;PROC
-