1682
|
1 |
"{ Package: 'stx:libview2' }"
|
|
2 |
|
|
3 |
View subclass:#PluggableView
|
|
4 |
instanceVariableNames:'redrawAction buttonPressAction keyPressAction'
|
|
5 |
classVariableNames:''
|
|
6 |
poolDictionaries:''
|
|
7 |
category:'Views-Basic'
|
|
8 |
!
|
|
9 |
|
|
10 |
!PluggableView class methodsFor:'documentation'!
|
|
11 |
|
|
12 |
documentation
|
|
13 |
"
|
|
14 |
a view for which the redraw, button and key-actions can be plugged as
|
|
15 |
blocks.
|
|
16 |
Mostly useful for little examples (where we dont want to add a full-blown class
|
|
17 |
for.
|
|
18 |
|
|
19 |
[author:]
|
|
20 |
Claus Gittinger (cg@alan)
|
|
21 |
|
|
22 |
[instance variables:]
|
|
23 |
|
|
24 |
[class variables:]
|
|
25 |
|
|
26 |
[see also:]
|
|
27 |
|
|
28 |
"
|
|
29 |
!
|
|
30 |
|
|
31 |
examples
|
|
32 |
"
|
|
33 |
|
|
34 |
a simple lissajous figure
|
|
35 |
[exBegin]
|
|
36 |
|v|
|
|
37 |
|
|
38 |
v := PluggableView new openAndWait.
|
|
39 |
v redrawAction:[
|
|
40 |
|offsX offsY scaleX scaleY|
|
|
41 |
|
|
42 |
scaleX := scaleY := 40.
|
|
43 |
offsX := offsY := 50.
|
|
44 |
|
|
45 |
0 to:360 do:[:degrees |
|
|
46 |
|radians x y|
|
|
47 |
|
|
48 |
radians := degrees degreesToRadians.
|
|
49 |
x := (radians * 3 ) cos.
|
|
50 |
y := (radians * 5 ) sin.
|
|
51 |
|
|
52 |
x := x * scaleX + offsX.
|
|
53 |
y := y * scaleY + offsY.
|
|
54 |
v atX:x y:y put:Color red.
|
|
55 |
].
|
|
56 |
].
|
|
57 |
v redraw
|
|
58 |
[exEnd]
|
|
59 |
"
|
|
60 |
! !
|
|
61 |
|
|
62 |
!PluggableView methodsFor:'accessing'!
|
|
63 |
|
|
64 |
buttonPressAction:something
|
|
65 |
"set the value of the instance variable 'buttonPressAction' (automatically generated)"
|
|
66 |
|
|
67 |
buttonPressAction := something.
|
|
68 |
!
|
|
69 |
|
|
70 |
keyPressAction:something
|
|
71 |
"set the value of the instance variable 'keyPressAction' (automatically generated)"
|
|
72 |
|
|
73 |
keyPressAction := something.
|
|
74 |
!
|
|
75 |
|
|
76 |
redrawAction:something
|
|
77 |
"set the value of the instance variable 'redrawAction' (automatically generated)"
|
|
78 |
|
|
79 |
redrawAction := something.
|
|
80 |
! !
|
|
81 |
|
|
82 |
!PluggableView methodsFor:'events'!
|
|
83 |
|
|
84 |
buttonPress:button x:x y:y
|
|
85 |
buttonPressAction notNil ifTrue:[
|
|
86 |
buttonPressAction value:button value:(x @ y)
|
|
87 |
]
|
|
88 |
!
|
|
89 |
|
|
90 |
keyPress:key x:x y:y
|
|
91 |
keyPressAction notNil ifTrue:[
|
|
92 |
keyPressAction value:key value:(x @ y)
|
|
93 |
]
|
|
94 |
!
|
|
95 |
|
|
96 |
redraw
|
|
97 |
super redraw.
|
|
98 |
redrawAction notNil ifTrue:[
|
|
99 |
redrawAction value
|
|
100 |
]
|
|
101 |
! !
|
|
102 |
|
|
103 |
!PluggableView class methodsFor:'documentation'!
|
|
104 |
|
|
105 |
version
|
|
106 |
^ '$Header: /cvs/stx/stx/libview2/PluggableView.st,v 1.1 2003-01-09 16:55:11 cg Exp $'
|
|
107 |
! !
|