author | tz |
Thu, 09 Apr 1998 15:19:05 +0200 | |
changeset 852 | 89c5dd6f6809 |
parent 818 | fbd05e92d506 |
child 868 | 0fa479aee842 |
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 |
|
338 | 193 |
!UpDownButton methodsFor:'initialization'! |
194 |
||
195 |
initialize |
|
788
826f9374823b
take forms from the ArrowButton + resizing behavior added
tz
parents:
779
diff
changeset
|
196 |
|
340
c02e5db9b6f5
added left-right orientation.
Claus Gittinger <cg@exept.de>
parents:
338
diff
changeset
|
197 |
orientation := #vertical. |
c02e5db9b6f5
added left-right orientation.
Claus Gittinger <cg@exept.de>
parents:
338
diff
changeset
|
198 |
|
338 | 199 |
super initialize. |
200 |
self initializeButtons |
|
340
c02e5db9b6f5
added left-right orientation.
Claus Gittinger <cg@exept.de>
parents:
338
diff
changeset
|
201 |
! |
c02e5db9b6f5
added left-right orientation.
Claus Gittinger <cg@exept.de>
parents:
338
diff
changeset
|
202 |
|
c02e5db9b6f5
added left-right orientation.
Claus Gittinger <cg@exept.de>
parents:
338
diff
changeset
|
203 |
initializeButtonDimensions |
788
826f9374823b
take forms from the ArrowButton + resizing behavior added
tz
parents:
779
diff
changeset
|
204 |
|
340
c02e5db9b6f5
added left-right orientation.
Claus Gittinger <cg@exept.de>
parents:
338
diff
changeset
|
205 |
orientation == #vertical ifTrue:[ |
788
826f9374823b
take forms from the ArrowButton + resizing behavior added
tz
parents:
779
diff
changeset
|
206 |
upButton origin: 0@0. |
826f9374823b
take forms from the ArrowButton + resizing behavior added
tz
parents:
779
diff
changeset
|
207 |
upButton corner: (self extent x - 1)@(self extent y//2). |
826f9374823b
take forms from the ArrowButton + resizing behavior added
tz
parents:
779
diff
changeset
|
208 |
downButton origin: 0@(self extent y//2 + 1). |
826f9374823b
take forms from the ArrowButton + resizing behavior added
tz
parents:
779
diff
changeset
|
209 |
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
|
210 |
] ifFalse:[ |
788
826f9374823b
take forms from the ArrowButton + resizing behavior added
tz
parents:
779
diff
changeset
|
211 |
upButton origin:0@0. |
826f9374823b
take forms from the ArrowButton + resizing behavior added
tz
parents:
779
diff
changeset
|
212 |
upButton corner: (self extent x//2)@(self extent y - 1). |
826f9374823b
take forms from the ArrowButton + resizing behavior added
tz
parents:
779
diff
changeset
|
213 |
downButton origin: (self extent x//2 + 1)@0. |
826f9374823b
take forms from the ArrowButton + resizing behavior added
tz
parents:
779
diff
changeset
|
214 |
downButton corner: (self extent x - 1)@(self extent y - 1) |
826f9374823b
take forms from the ArrowButton + resizing behavior added
tz
parents:
779
diff
changeset
|
215 |
] |
826f9374823b
take forms from the ArrowButton + resizing behavior added
tz
parents:
779
diff
changeset
|
216 |
! |
340
c02e5db9b6f5
added left-right orientation.
Claus Gittinger <cg@exept.de>
parents:
338
diff
changeset
|
217 |
|
788
826f9374823b
take forms from the ArrowButton + resizing behavior added
tz
parents:
779
diff
changeset
|
218 |
initializeButtonForms |
826f9374823b
take forms from the ArrowButton + resizing behavior added
tz
parents:
779
diff
changeset
|
219 |
|
826f9374823b
take forms from the ArrowButton + resizing behavior added
tz
parents:
779
diff
changeset
|
220 |
orientation == #vertical ifTrue:[ |
826f9374823b
take forms from the ArrowButton + resizing behavior added
tz
parents:
779
diff
changeset
|
221 |
upButton label:ArrowButton UpArrowForm. |
826f9374823b
take forms from the ArrowButton + resizing behavior added
tz
parents:
779
diff
changeset
|
222 |
downButton label:ArrowButton DownArrowForm. |
826f9374823b
take forms from the ArrowButton + resizing behavior added
tz
parents:
779
diff
changeset
|
223 |
] ifFalse:[ |
826f9374823b
take forms from the ArrowButton + resizing behavior added
tz
parents:
779
diff
changeset
|
224 |
upButton label:ArrowButton LeftArrowForm. |
826f9374823b
take forms from the ArrowButton + resizing behavior added
tz
parents:
779
diff
changeset
|
225 |
downButton label:ArrowButton RightArrowForm. |
340
c02e5db9b6f5
added left-right orientation.
Claus Gittinger <cg@exept.de>
parents:
338
diff
changeset
|
226 |
]. |
338 | 227 |
! |
228 |
||
229 |
initializeButtons |
|
779
0abab228a8fd
do not define callbacks in action blocks which do not exist
tz
parents:
651
diff
changeset
|
230 |
|
338 | 231 |
upButton := ArrowButton upIn:self. |
232 |
upButton autoRepeat:true. |
|
233 |
||
234 |
downButton := ArrowButton downIn:self. |
|
235 |
downButton autoRepeat:true. |
|
236 |
||
788
826f9374823b
take forms from the ArrowButton + resizing behavior added
tz
parents:
779
diff
changeset
|
237 |
self initializeButtonDimensions. |
826f9374823b
take forms from the ArrowButton + resizing behavior added
tz
parents:
779
diff
changeset
|
238 |
self initializeButtonForms |
338 | 239 |
! ! |
240 |
||
241 |
!UpDownButton class methodsFor:'documentation'! |
|
242 |
||
243 |
version |
|
852 | 244 |
^ '$Header: /cvs/stx/stx/libwidg2/UpDownButton.st,v 1.8 1998-04-09 13:19:05 tz Exp $' |
338 | 245 |
! ! |