home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-11-25 | 3.9 KB | 175 lines | [TEXT/MSET] |
- \ Window+ class - a window that supports views.
-
- \ Oct 91 mrh Initial version.
- \ May 92 mrh "New-style" controls
- \ Feb 93 mrh Added sending idle: to the contView
- \ Sept 93 mrh Revised for Control now being a View subclass.
-
- need view
- need scroller
-
- rect aRect
-
- :class WINDOW+ super{ window }
- record
- { ptr ^CONTVIEW \ Points to view consisting of contents rect.
- bool ZOOMFLG
- }
-
- private
-
- :m SetContViewBounds: { \ l t r b -- }
- getRect: super -> b -> r -> t -> l
- l t r 1+ b 1+ setBounds: [ get: ^contView ]
- moved: [ get: ^contView ]
- 0 0 32000 dup put: tempRect update: tempRect
- ;m
-
- public
-
- :m SETZOOM: \ ( b -- ) Passed-in boolean indicates if this window
- \ will be zoomable.
- put: zoomFlg ;m
-
- :m SETVIEW: { ^view -- }
- ^view put: ^contView ^base setWindow: [ ^view ] ;m
-
- :m GETVIEW: get: ^contView ;m
-
-
- :m NEW: { bndsRect tAddr tLen procID vis goAway ^view \ s255 -- }
- get: alive ?EXIT \ Out if already alive
- ^view setView: self
- ?disable_actW: self
- tAddr tLen str255 -> s255
- ^base bndsrect s255
- vis 1 and
- get: zoomFlg 8 and procID +
- inFront goAway 1 and
- 0 \ default is initially in front
- get: color?
- IF NewCWindow ELSE NewWindow THEN drop
- initNewWindow: self
- setContViewBounds: self
- new: [ get: ^contView ] \ Fire up view object
- ;m
-
-
- :m GETNEW: { resID ^view -- }
- get: alive ?EXIT \ Out if already alive
- ^view setView: self
- resID getnew: super
- setContViewBounds: self
- new: [ get: ^contView ] \ Fire up view object
- ;m
-
-
- :m GROW:
- grow: super
- setContViewBounds: self ;m
-
- :m ZOOM:
- zoom: super set: super
- setContViewBounds: self ;m
-
-
- :m ENABLE:
- enable: super \ Note - we do this first to make sure the
- \ current grafPort is set before the views
- \ do anything.
- get: ^contView enable: []
- ;m
-
- :m DISABLE:
- get: ^contView disable: [] disable: super ;m
-
- :m (DRAW):
- (draw): super
- get: ^contview draw: [] ;m
-
- :m DRAW: (draw): self
- ( noclip ) ;m \ It seems that when I have scroll bars the
- \ grow icon gets clipped out unless I call
- \ noClip here. (The callLast routine
- \ windupDraw: is where it's actually drawn).
-
- \ IDLE: calls IDLE: on the contView (which will lead to it being called on
- \ all views). We ensure this window is the current Grafport, since the views
- \ might want to look at the mouse position in local coordinates.
-
- :m IDLE: idle: super
- pushPort set: self
- get: ^contView idle: []
- popPort ;m
-
-
- :m CLOSE: \ Disposes of window's controls and closes the window
- get: ^contView release: **
- close: super ;m
-
-
- :m CONTENT: \ Handles a content click
- active: self
- IF noClip get: ^contView click: ** drop
- ELSE select: self
- THEN ;m
-
-
- :m KEY: \ ( c -- ) For typed keys, we'll send a KEY: to the
- \ contView and thus to all the views. They can do
- \ whatever they like with it.
- get: ^contView key: ** ;m
-
-
- :m TEST: { ^view -- }
- screenbits true setGrow: self
- true setZoom: self
- 100 100 400 200 put: aRect \ can't use tempRect - gets clobbered
- aRect " Test" docWind true true ^view new: self ;m
-
- :m TESTR: { resID ^view -- }
- screenbits true setGrow: self
- true setZoom: self
- resID ^view getnew: self ;m
-
- ;class
-
-
- endload
-
-
- \ TESTING:
-
- window+ WW
- scroller S1 \ This will be the contview of WW
- scroller S2 \ A child of S1 - another scroller!
- 20 20 150 200 setBounds: s2
-
- view VV \ A child of S2
- 32 32 628 328 setBounds: vv
-
- screenbits true setGrow: ww
- true setZoom: ww
-
- : DRW { \ l t r b -- } \ Draws a big X across the view area.
- ( clear: temprect ) get: tempRect -> b -> r -> t -> l
- 0 0 gotoxy r b pack call LineTo
- l b gotoxy r 0 pack call LineTo ;
-
- ' drw setDraw: vv
-
-
- : CLICK1 ." clicked s1!" cr ;
- : CLICK2 ." clicked s2!" cr ;
-
- ' click1 setClick: s1 ' click2 setClick: s2
-
- : GO
- vv addView: s2 s2 addView: s1
- s1 test: ww ;
-
- : GORES
- vv addView: s2 s2 addView: s1
- 256 s1 testR: ww ;
-
-