author | Claus Gittinger <cg@exept.de> |
Tue, 21 Apr 1998 19:57:01 +0200 | |
changeset 868 | 0fa479aee842 |
parent 852 | 89c5dd6f6809 |
child 899 | 68770c9d162d |
permissions | -rw-r--r-- |
338 | 1 |
SimpleView subclass:#UpDownButton |
340
c02e5db9b6f5
added left-right orientation.
Claus Gittinger <cg@exept.de>
parents:
338
diff
changeset
|
2 |
instanceVariableNames:'orientation upButton downButton' |
788
826f9374823b
take forms from the ArrowButton + resizing behavior added
tz
parents:
779
diff
changeset
|
3 |
classVariableNames:'' |
338 | 4 |
poolDictionaries:'' |
5 |
category:'Views-Interactors' |
|
6 |
! |
|
7 |
||
8 |
!UpDownButton class methodsFor:'documentation'! |
|
9 |
||
10 |
documentation |
|
11 |
" |
|
12 |
an up/down button - simply two buttons in one view. |
|
13 |
||
14 |
[author:] |
|
15 |
Claus Gittinger |
|
16 |
||
17 |
[see also:] |
|
18 |
ArrowButton |
|
19 |
ComboUpDownView |
|
20 |
" |
|
21 |
! |
|
22 |
||
23 |
examples |
|
24 |
" |
|
25 |
[exBegin] |
|
26 |
|top ud| |
|
27 |
||
28 |
top := StandardSystemView new. |
|
29 |
top extent:(300 @ 200). |
|
30 |
||
31 |
ud := UpDownButton in:top. |
|
32 |
ud origin:(10 @ 10). |
|
33 |
||
34 |
ud upAction:[Transcript showCR:'up']. |
|
35 |
ud downAction:[Transcript showCR:'down']. |
|
36 |
top open. |
|
37 |
[exEnd] |
|
340
c02e5db9b6f5
added left-right orientation.
Claus Gittinger <cg@exept.de>
parents:
338
diff
changeset
|
38 |
|
c02e5db9b6f5
added left-right orientation.
Claus Gittinger <cg@exept.de>
parents:
338
diff
changeset
|
39 |
[exBegin] |
c02e5db9b6f5
added left-right orientation.
Claus Gittinger <cg@exept.de>
parents:
338
diff
changeset
|
40 |
|top ud| |
c02e5db9b6f5
added left-right orientation.
Claus Gittinger <cg@exept.de>
parents:
338
diff
changeset
|
41 |
|
c02e5db9b6f5
added left-right orientation.
Claus Gittinger <cg@exept.de>
parents:
338
diff
changeset
|
42 |
top := StandardSystemView new. |
c02e5db9b6f5
added left-right orientation.
Claus Gittinger <cg@exept.de>
parents:
338
diff
changeset
|
43 |
top extent:(300 @ 200). |
c02e5db9b6f5
added left-right orientation.
Claus Gittinger <cg@exept.de>
parents:
338
diff
changeset
|
44 |
|
c02e5db9b6f5
added left-right orientation.
Claus Gittinger <cg@exept.de>
parents:
338
diff
changeset
|
45 |
ud := UpDownButton in:top. |
c02e5db9b6f5
added left-right orientation.
Claus Gittinger <cg@exept.de>
parents:
338
diff
changeset
|
46 |
ud orientation:#horizontal. |
c02e5db9b6f5
added left-right orientation.
Claus Gittinger <cg@exept.de>
parents:
338
diff
changeset
|
47 |
ud origin:(10 @ 10). |
c02e5db9b6f5
added left-right orientation.
Claus Gittinger <cg@exept.de>
parents:
338
diff
changeset
|
48 |
|
c02e5db9b6f5
added left-right orientation.
Claus Gittinger <cg@exept.de>
parents:
338
diff
changeset
|
49 |
ud upAction:[Transcript showCR:'up']. |
c02e5db9b6f5
added left-right orientation.
Claus Gittinger <cg@exept.de>
parents:
338
diff
changeset
|
50 |
ud downAction:[Transcript showCR:'down']. |
c02e5db9b6f5
added left-right orientation.
Claus Gittinger <cg@exept.de>
parents:
338
diff
changeset
|
51 |
top open. |
c02e5db9b6f5
added left-right orientation.
Claus Gittinger <cg@exept.de>
parents:
338
diff
changeset
|
52 |
[exEnd] |
338 | 53 |
" |
54 |
||
55 |
! ! |
|
56 |
||
57 |
!UpDownButton methodsFor:'accessing-behavior'! |
|
58 |
||
818 | 59 |
disable |
60 |
||
61 |
upButton disable. |
|
62 |
downButton disable. |
|
63 |
! |
|
64 |
||
338 | 65 |
downAction:aBlock |
788
826f9374823b
take forms from the ArrowButton + resizing behavior added
tz
parents:
779
diff
changeset
|
66 |
|
338 | 67 |
downButton action:aBlock |
68 |
! |
|
69 |
||
818 | 70 |
enable |
71 |
||
72 |
upButton enable. |
|
73 |
downButton enable. |
|
74 |
! |
|
75 |
||
76 |
showFocus:explicit |
|
77 |
||
78 |
upButton enabled ifTrue: [super showFocus:explicit] |
|
79 |
! |
|
80 |
||
338 | 81 |
upAction:aBlock |
788
826f9374823b
take forms from the ArrowButton + resizing behavior added
tz
parents:
779
diff
changeset
|
82 |
|
338 | 83 |
upButton action:aBlock |
84 |
! ! |
|
85 |
||
818 | 86 |
!UpDownButton methodsFor:'accessing-channels'! |
87 |
||
88 |
backgroundChannel |
|
89 |
||
90 |
upButton backgroundChannel |
|
91 |
! |
|
92 |
||
93 |
backgroundChannel: aValueHolder |
|
94 |
||
95 |
upButton backgroundChannel: aValueHolder. |
|
96 |
downButton backgroundChannel: aValueHolder |
|
97 |
! |
|
98 |
||
99 |
enableChannel |
|
100 |
||
101 |
upButton enableChannel |
|
102 |
! |
|
103 |
||
104 |
enableChannel: aValueHolder |
|
105 |
||
106 |
upButton enableChannel: aValueHolder. |
|
107 |
downButton enableChannel: aValueHolder |
|
108 |
! |
|
109 |
||
110 |
foregroundChannel |
|
111 |
||
112 |
upButton foregroundChannel |
|
113 |
! |
|
114 |
||
115 |
foregroundChannel: aValueHolder |
|
116 |
||
117 |
upButton foregroundChannel: aValueHolder. |
|
118 |
downButton foregroundChannel: aValueHolder |
|
119 |
! ! |
|
120 |
||
121 |
!UpDownButton methodsFor:'accessing-colors'! |
|
122 |
||
123 |
backgroundColor |
|
124 |
||
852 | 125 |
^upButton backgroundColor |
818 | 126 |
|
127 |
! |
|
128 |
||
129 |
backgroundColor:aColor |
|
130 |
||
131 |
aColor ~~ upButton backgroundColor ifTrue:[ |
|
132 |
upButton backgroundColor:aColor. |
|
133 |
downButton backgroundColor:aColor. |
|
134 |
shown ifTrue:[self invalidate] |
|
135 |
] |
|
136 |
! |
|
137 |
||
138 |
foregroundColor |
|
139 |
||
852 | 140 |
^upButton foregroundColor |
818 | 141 |
|
142 |
! |
|
143 |
||
144 |
foregroundColor:aColor |
|
145 |
||
146 |
aColor ~~ upButton foregroundColor ifTrue:[ |
|
147 |
upButton foregroundColor:aColor. |
|
148 |
downButton foregroundColor:aColor. |
|
149 |
shown ifTrue:[self invalidate] |
|
150 |
] |
|
151 |
! |
|
152 |
||
153 |
model:aModel |
|
154 |
"ignore models" |
|
155 |
! ! |
|
156 |
||
338 | 157 |
!UpDownButton methodsFor:'accessing-components'! |
158 |
||
159 |
downButton |
|
788
826f9374823b
take forms from the ArrowButton + resizing behavior added
tz
parents:
779
diff
changeset
|
160 |
|
338 | 161 |
^ downButton |
162 |
! |
|
163 |
||
164 |
upButton |
|
788
826f9374823b
take forms from the ArrowButton + resizing behavior added
tz
parents:
779
diff
changeset
|
165 |
|
338 | 166 |
^ upButton |
167 |
! ! |
|
168 |
||
340
c02e5db9b6f5
added left-right orientation.
Claus Gittinger <cg@exept.de>
parents:
338
diff
changeset
|
169 |
!UpDownButton methodsFor:'accessing-look'! |
c02e5db9b6f5
added left-right orientation.
Claus Gittinger <cg@exept.de>
parents:
338
diff
changeset
|
170 |
|
c02e5db9b6f5
added left-right orientation.
Claus Gittinger <cg@exept.de>
parents:
338
diff
changeset
|
171 |
orientation |
788
826f9374823b
take forms from the ArrowButton + resizing behavior added
tz
parents:
779
diff
changeset
|
172 |
|
340
c02e5db9b6f5
added left-right orientation.
Claus Gittinger <cg@exept.de>
parents:
338
diff
changeset
|
173 |
^ orientation |
c02e5db9b6f5
added left-right orientation.
Claus Gittinger <cg@exept.de>
parents:
338
diff
changeset
|
174 |
! |
c02e5db9b6f5
added left-right orientation.
Claus Gittinger <cg@exept.de>
parents:
338
diff
changeset
|
175 |
|
c02e5db9b6f5
added left-right orientation.
Claus Gittinger <cg@exept.de>
parents:
338
diff
changeset
|
176 |
orientation:aSymbol |
788
826f9374823b
take forms from the ArrowButton + resizing behavior added
tz
parents:
779
diff
changeset
|
177 |
|
340
c02e5db9b6f5
added left-right orientation.
Claus Gittinger <cg@exept.de>
parents:
338
diff
changeset
|
178 |
orientation := aSymbol. |
788
826f9374823b
take forms from the ArrowButton + resizing behavior added
tz
parents:
779
diff
changeset
|
179 |
|
826f9374823b
take forms from the ArrowButton + resizing behavior added
tz
parents:
779
diff
changeset
|
180 |
self initializeButtonDimensions. |
826f9374823b
take forms from the ArrowButton + resizing behavior added
tz
parents:
779
diff
changeset
|
181 |
self initializeButtonForms |
826f9374823b
take forms from the ArrowButton + resizing behavior added
tz
parents:
779
diff
changeset
|
182 |
! ! |
340
c02e5db9b6f5
added left-right orientation.
Claus Gittinger <cg@exept.de>
parents:
338
diff
changeset
|
183 |
|
788
826f9374823b
take forms from the ArrowButton + resizing behavior added
tz
parents:
779
diff
changeset
|
184 |
!UpDownButton methodsFor:'change & update'! |
826f9374823b
take forms from the ArrowButton + resizing behavior added
tz
parents:
779
diff
changeset
|
185 |
|
826f9374823b
take forms from the ArrowButton + resizing behavior added
tz
parents:
779
diff
changeset
|
186 |
sizeChanged:how |
826f9374823b
take forms from the ArrowButton + resizing behavior added
tz
parents:
779
diff
changeset
|
187 |
|
826f9374823b
take forms from the ArrowButton + resizing behavior added
tz
parents:
779
diff
changeset
|
188 |
super sizeChanged:how. |
826f9374823b
take forms from the ArrowButton + resizing behavior added
tz
parents:
779
diff
changeset
|
189 |
|
826f9374823b
take forms from the ArrowButton + resizing behavior added
tz
parents:
779
diff
changeset
|
190 |
self initializeButtonDimensions |
340
c02e5db9b6f5
added left-right orientation.
Claus Gittinger <cg@exept.de>
parents:
338
diff
changeset
|
191 |
! ! |
c02e5db9b6f5
added left-right orientation.
Claus Gittinger <cg@exept.de>
parents:
338
diff
changeset
|
192 |
|
868 | 193 |
!UpDownButton methodsFor:'event handling'! |
194 |
||
195 |
keyPress:aKey x:x y:y |
|
196 |
"simulate a buttonPress/release" |
|
197 |
||
198 |
|theButton theController| |
|
199 |
||
200 |
((aKey == #CursorUp) |
|
201 |
or:[aKey == #CursorRight |
|
202 |
or:[aKey == $+]]) ifTrue:[ |
|
203 |
theButton := upButton |
|
204 |
] ifFalse:[ |
|
205 |
((aKey == #CursorDown) |
|
206 |
or:[aKey == #CursorLeft |
|
207 |
or:[aKey == $-]]) ifTrue:[ |
|
208 |
theButton := downButton |
|
209 |
]. |
|
210 |
]. |
|
211 |
theButton notNil ifTrue:[ |
|
212 |
theController := theButton controller. |
|
213 |
theController pressed:true. |
|
214 |
theController pressed:false. |
|
215 |
^ self |
|
216 |
]. |
|
217 |
^ super keyPress:aKey x:x y:y |
|
218 |
||
219 |
"Created: / 21.4.1998 / 19:48:28 / cg" |
|
220 |
"Modified: / 21.4.1998 / 19:56:28 / cg" |
|
221 |
! ! |
|
222 |
||
338 | 223 |
!UpDownButton methodsFor:'initialization'! |
224 |
||
225 |
initialize |
|
788
826f9374823b
take forms from the ArrowButton + resizing behavior added
tz
parents:
779
diff
changeset
|
226 |
|
340
c02e5db9b6f5
added left-right orientation.
Claus Gittinger <cg@exept.de>
parents:
338
diff
changeset
|
227 |
orientation := #vertical. |
c02e5db9b6f5
added left-right orientation.
Claus Gittinger <cg@exept.de>
parents:
338
diff
changeset
|
228 |
|
338 | 229 |
super initialize. |
230 |
self initializeButtons |
|
340
c02e5db9b6f5
added left-right orientation.
Claus Gittinger <cg@exept.de>
parents:
338
diff
changeset
|
231 |
! |
c02e5db9b6f5
added left-right orientation.
Claus Gittinger <cg@exept.de>
parents:
338
diff
changeset
|
232 |
|
c02e5db9b6f5
added left-right orientation.
Claus Gittinger <cg@exept.de>
parents:
338
diff
changeset
|
233 |
initializeButtonDimensions |
788
826f9374823b
take forms from the ArrowButton + resizing behavior added
tz
parents:
779
diff
changeset
|
234 |
|
340
c02e5db9b6f5
added left-right orientation.
Claus Gittinger <cg@exept.de>
parents:
338
diff
changeset
|
235 |
orientation == #vertical ifTrue:[ |
788
826f9374823b
take forms from the ArrowButton + resizing behavior added
tz
parents:
779
diff
changeset
|
236 |
upButton origin: 0@0. |
826f9374823b
take forms from the ArrowButton + resizing behavior added
tz
parents:
779
diff
changeset
|
237 |
upButton corner: (self extent x - 1)@(self extent y//2). |
826f9374823b
take forms from the ArrowButton + resizing behavior added
tz
parents:
779
diff
changeset
|
238 |
downButton origin: 0@(self extent y//2 + 1). |
826f9374823b
take forms from the ArrowButton + resizing behavior added
tz
parents:
779
diff
changeset
|
239 |
downButton corner: (self extent x - 1)@(self extent y - 1) |
340
c02e5db9b6f5
added left-right orientation.
Claus Gittinger <cg@exept.de>
parents:
338
diff
changeset
|
240 |
] ifFalse:[ |
788
826f9374823b
take forms from the ArrowButton + resizing behavior added
tz
parents:
779
diff
changeset
|
241 |
upButton origin:0@0. |
826f9374823b
take forms from the ArrowButton + resizing behavior added
tz
parents:
779
diff
changeset
|
242 |
upButton corner: (self extent x//2)@(self extent y - 1). |
826f9374823b
take forms from the ArrowButton + resizing behavior added
tz
parents:
779
diff
changeset
|
243 |
downButton origin: (self extent x//2 + 1)@0. |
826f9374823b
take forms from the ArrowButton + resizing behavior added
tz
parents:
779
diff
changeset
|
244 |
downButton corner: (self extent x - 1)@(self extent y - 1) |
826f9374823b
take forms from the ArrowButton + resizing behavior added
tz
parents:
779
diff
changeset
|
245 |
] |
826f9374823b
take forms from the ArrowButton + resizing behavior added
tz
parents:
779
diff
changeset
|
246 |
! |
340
c02e5db9b6f5
added left-right orientation.
Claus Gittinger <cg@exept.de>
parents:
338
diff
changeset
|
247 |
|
788
826f9374823b
take forms from the ArrowButton + resizing behavior added
tz
parents:
779
diff
changeset
|
248 |
initializeButtonForms |
826f9374823b
take forms from the ArrowButton + resizing behavior added
tz
parents:
779
diff
changeset
|
249 |
|
826f9374823b
take forms from the ArrowButton + resizing behavior added
tz
parents:
779
diff
changeset
|
250 |
orientation == #vertical ifTrue:[ |
826f9374823b
take forms from the ArrowButton + resizing behavior added
tz
parents:
779
diff
changeset
|
251 |
upButton label:ArrowButton UpArrowForm. |
826f9374823b
take forms from the ArrowButton + resizing behavior added
tz
parents:
779
diff
changeset
|
252 |
downButton label:ArrowButton DownArrowForm. |
826f9374823b
take forms from the ArrowButton + resizing behavior added
tz
parents:
779
diff
changeset
|
253 |
] ifFalse:[ |
826f9374823b
take forms from the ArrowButton + resizing behavior added
tz
parents:
779
diff
changeset
|
254 |
upButton label:ArrowButton LeftArrowForm. |
826f9374823b
take forms from the ArrowButton + resizing behavior added
tz
parents:
779
diff
changeset
|
255 |
downButton label:ArrowButton RightArrowForm. |
340
c02e5db9b6f5
added left-right orientation.
Claus Gittinger <cg@exept.de>
parents:
338
diff
changeset
|
256 |
]. |
338 | 257 |
! |
258 |
||
259 |
initializeButtons |
|
779
0abab228a8fd
do not define callbacks in action blocks which do not exist
tz
parents:
651
diff
changeset
|
260 |
|
338 | 261 |
upButton := ArrowButton upIn:self. |
262 |
upButton autoRepeat:true. |
|
263 |
||
264 |
downButton := ArrowButton downIn:self. |
|
265 |
downButton autoRepeat:true. |
|
266 |
||
788
826f9374823b
take forms from the ArrowButton + resizing behavior added
tz
parents:
779
diff
changeset
|
267 |
self initializeButtonDimensions. |
826f9374823b
take forms from the ArrowButton + resizing behavior added
tz
parents:
779
diff
changeset
|
268 |
self initializeButtonForms |
338 | 269 |
! ! |
270 |
||
271 |
!UpDownButton class methodsFor:'documentation'! |
|
272 |
||
273 |
version |
|
868 | 274 |
^ '$Header: /cvs/stx/stx/libwidg2/UpDownButton.st,v 1.9 1998-04-21 17:57:01 cg Exp $' |
338 | 275 |
! ! |