home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-11-24 | 4.3 KB | 228 lines | [TEXT/MSET] |
- \ QuickDraw support.
-
- 0 constant SRCCOPY \ equates for drawing modes
- 1 constant SRCOR
- 2 constant SRCXOR
-
- \ Random - returns a random number 0 - N. N is limited to an Int
- \ value. Larger than that means that numbers will be poorly distributed.
-
- : RANDOM \ ( n -- rand*N )
- word0 call Random word0 swap mod ;
-
- \ Line drawing:
-
- : HIDEPEN call HidePen ;
- : SHOWPEN call ShowPen ;
-
- \ ( horiz vert -- )
-
- : MOVEPEN pack call Move ;
- : MOVETO pack call MoveTo ;
- : LINETO pack call LineTo ;
- : LINE pack call Line ;
-
- : DEL \ Draws a downward-pointing arrow to the right of and
- \ below the current pen position.
- 11 0 line -1 1 movePen
- -9 0 line 1 1 movePen
- 7 0 line -1 1 movePen
- -5 0 line 1 1 movePen
- 3 0 line -1 1 movePen
- -1 0 line ;
-
-
- \ ============= Patterns ===============
-
-
- :class PATTERN super{ resource }
-
- record { ptr CURR }
-
- :m GETNEW: \ ( pat# -- ptr )
- 'type PAT# swap set: self getnew: super
- 3 << ptr: self 2+ + put: curr ;m
-
- :m GET: get: curr ;m
-
- ;class
-
-
- objPtr TMPPTN class_is pattern
-
- pattern SYSPATTN
-
- : SYSPAT \ ( pat# -- ^pat-obj )
- 0 getnew: sysPattn
- sysPattn ;
-
-
-
- :class POINT super{ object }
- record
- { int Y \ Vertical coordinate
- int X \ Horizontal coordinate
- }
-
- :m GETX: get: x ;m
- :m GETY: get: y ;m
-
- :m PUTX: put: x ;m
- :m PUTY: put: y ;m
-
- :m SHIFTX: +: x ;m
- :m SHIFTY: +: y ;m
- :m SHIFT: +: y +: x ;m
-
- :m GET: get: X get: Y ;m
- :m PUT: put: Y put: X ;m
-
- :m INT: inline{ obj @} ^base @ ;m
-
- :m ->: inline{ @ obj !} chksame @ ^base ! ;m
-
- ;class
-
-
- :class RECT super{ object }
-
- record
- { point TOPL
- point BOTR
- }
-
- :m GET: get: topl get: botr ;m ( -- l t r b )
- :m PUT: put: botr put: topl ;m ( l t r b -- )
-
- :m GETTOP: get: topl ;m ( -- l t )
- :m TOPINT: int: topl ;m
- :m GETTOPX: getx: topl ;m
- :m GETTOPY: gety: topl ;m
- :m PUTTOP: put: topl ;m
- :m PUTTOPX: putx: topl ;m
- :m PUTTOPY: puty: topl ;m
-
- :m GETBOT: get: botr ;m
- :m BOTINT: int: botr ;m
- :m GETBOTX: getx: botr ;m
- :m GETBOTY: gety: botr ;m
- :m PUTBOT: put: botr ;m
- :m PUTBOTX: putx: botr ;m
- :m PUTBOTY: puty: botr ;m
-
- :m SIZE: \ ( -- width height ) Calculates rect's size
- getx: botr getx: topl -
- gety: botr gety: topl - ;m
-
- :m SETSIZE: ( w h -- )
- getTopY: self + putBotY: self
- getTopX: self + putBotX: self ;m
-
- :m GETCENTER: { \ x y -- x y }
- size: self 2/ -> y 2/ -> x
- getx: topl x + gety: topl y + ;m
-
- :m INSET: \ ( dx dy -- ) Makes rect smaller by dx dy.
- pack ^base swap call insetRect ;m
-
- :m SHIFT: { dx dy -- }
- dx dy or 0EXIT
- dx dy shift: topL dx dy shift: botR ;m
-
- :m OFFSET: shift: self ;m \ Old name - for compatibility
-
- :m STRETCH: { dx dy -- } dx dy shift: botR ;m
-
- :m ->: ^base 8 aligned_move ;m
-
-
- :m DRAW: ^base call framerect ;m
- :m DISP: put: self draw: self ;m
- :m CLEAR: ^base call eraserect ;m
-
- :m FILL: \ ( ^patobj -- ) Fills rect with pattern
- -> tmpPtn
- get: tmpPtn ^base swap call fillrect ;m
-
- :m DROPSHADOW: { \ lf top rt bot -- }
- get: topL -> top -> lf
- get: botR -> bot -> rt
- draw: self
- rt top 3+ moveto
- 0 bot top - 3- line
- lf rt - 3+ 0 line ;m
-
- :m INVERT: ^base call inverrect ;m
-
- :m PAINT: ^base call paintrect ;m
-
- :m CLIP: \ Clips drawing to this rect
- ^base call clipRect ;m
-
- :m UPDATE: \ Adds rect to update region
- ^base call InvalRect ;m
-
- ;class
-
- fpRect ' rect set_class \ Make fpRect a rect object
-
-
- \ A temporary rectangle, usable by anything
-
- rect TEMPRECT
-
-
-
- \ ed-boy 951013 - revised Grafport record
-
- :class GRAFPORT super{ object }
-
- record
- { int device
- handle portPixMap
- int portVersion
- handle grafVars
- int chExtra
- int pnLocHFrac
- rect portRect
- 44 bytes graf2 \ unmapped
- var TEXT1 \ font,face,mode,size
- var TEXT2
- 32 bytes graf3 \ unmapped
- }
-
- :m SET: \ Makes this grafport current
- ^base call setPort ;m
-
- :m GETRECT: \ ( l t r b -- ) Gets values for portRect
- get: portRect ;m
-
- :m PUTRECT: \ ( l t r b -- ) Stores values for portRect
- put: portRect ;m
-
- :m GetPortPixMap: portPixMap ;m
-
-
- ;class
-
-
- : PUSHPORT 0 sp@ call GetPort ;
- : POPPORT call SetPort ;
-
-
- \ ============= Cursors ==============
-
- : CURSOR
- <builds w,
- does> 0 swap w@ makeint call GetCursor
- >ptr call SetCursor ;
-
- \ predefined cursors
-
- 1 cursor IBEAMCURS
- 2 cursor CROSSCURS
- 3 cursor PLUSCURS
- 4 cursor WATCHCURS
-
- : ARROWCURS call InitCursor ;
-