338
|
1 |
SimpleView subclass:#UpDownButton
|
|
2 |
instanceVariableNames:'upButton downButton'
|
|
3 |
classVariableNames:''
|
|
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]
|
|
38 |
"
|
|
39 |
|
|
40 |
! !
|
|
41 |
|
|
42 |
!UpDownButton class methodsFor:'defaults'!
|
|
43 |
|
|
44 |
downButtonForm
|
|
45 |
"return the down-buttons image"
|
|
46 |
|
|
47 |
<resource: #style (#upDownButtonDownForm #upDownButtonDownFormFile)>
|
|
48 |
|
|
49 |
|fileName form|
|
|
50 |
|
|
51 |
form := StyleSheet at:'upDownButtonDownForm' default:nil.
|
|
52 |
form isNil ifTrue:[
|
|
53 |
fileName := StyleSheet at:'upDownButtonDownFormFile' default:'ComboDnB_win.xbm'.
|
|
54 |
form := Image fromFile:fileName.
|
|
55 |
].
|
|
56 |
form isNil ifTrue:[
|
|
57 |
form := Form width:16 height:7
|
|
58 |
fromArray:#[
|
|
59 |
2r00000000 2r00000000
|
|
60 |
2r00111111 2r11111100
|
|
61 |
2r00011111 2r11111000
|
|
62 |
2r00001111 2r11110000
|
|
63 |
2r00000111 2r11100000
|
|
64 |
2r00000011 2r11000000
|
|
65 |
2r00000001 2r10000000
|
|
66 |
]
|
|
67 |
on:Display.
|
|
68 |
].
|
|
69 |
form notNil ifTrue:[
|
|
70 |
^ form on:Display
|
|
71 |
].
|
|
72 |
^ nil
|
|
73 |
|
|
74 |
"Created: 1.4.1997 / 11:53:39 / cg"
|
|
75 |
"Modified: 1.4.1997 / 11:54:17 / cg"
|
|
76 |
!
|
|
77 |
|
|
78 |
upButtonForm
|
|
79 |
"return the up-buttons image"
|
|
80 |
|
|
81 |
<resource: #style (#upDownButtonUpForm #upDownButtonUpFormFile)>
|
|
82 |
|
|
83 |
|fileName form|
|
|
84 |
|
|
85 |
form := StyleSheet at:'upDownButtonUpForm' default:nil.
|
|
86 |
form isNil ifTrue:[
|
|
87 |
fileName := StyleSheet at:'upDownButtonUpFormFile' default:'ComboUpB_win.xbm'.
|
|
88 |
form := Image fromFile:fileName.
|
|
89 |
].
|
|
90 |
form isNil ifTrue:[
|
|
91 |
form := Form width:16 height:7
|
|
92 |
fromArray:#[
|
|
93 |
2r00000001 2r10000000
|
|
94 |
2r00000011 2r11000000
|
|
95 |
2r00000111 2r11100000
|
|
96 |
2r00001111 2r11110000
|
|
97 |
2r00011111 2r11111000
|
|
98 |
2r00111111 2r11111100
|
|
99 |
2r00000000 2r00000000
|
|
100 |
]
|
|
101 |
on:Display.
|
|
102 |
].
|
|
103 |
form notNil ifTrue:[
|
|
104 |
^ form on:Display
|
|
105 |
].
|
|
106 |
^ nil
|
|
107 |
|
|
108 |
"Modified: 29.3.1997 / 11:36:55 / cg"
|
|
109 |
"Created: 1.4.1997 / 11:54:13 / cg"
|
|
110 |
! !
|
|
111 |
|
|
112 |
!UpDownButton methodsFor:'accessing-behavior'!
|
|
113 |
|
|
114 |
downAction:aBlock
|
|
115 |
downButton action:aBlock
|
|
116 |
|
|
117 |
"Created: 1.4.1997 / 11:56:33 / cg"
|
|
118 |
!
|
|
119 |
|
|
120 |
upAction:aBlock
|
|
121 |
upButton action:aBlock
|
|
122 |
|
|
123 |
"Created: 1.4.1997 / 11:56:28 / cg"
|
|
124 |
! !
|
|
125 |
|
|
126 |
!UpDownButton methodsFor:'accessing-components'!
|
|
127 |
|
|
128 |
downButton
|
|
129 |
^ downButton
|
|
130 |
|
|
131 |
"Created: 1.4.1997 / 11:56:05 / cg"
|
|
132 |
!
|
|
133 |
|
|
134 |
upButton
|
|
135 |
^ upButton
|
|
136 |
|
|
137 |
"Created: 1.4.1997 / 11:55:52 / cg"
|
|
138 |
"Modified: 1.4.1997 / 11:56:02 / cg"
|
|
139 |
! !
|
|
140 |
|
|
141 |
!UpDownButton methodsFor:'initialization'!
|
|
142 |
|
|
143 |
initialize
|
|
144 |
super initialize.
|
|
145 |
self initializeButtons
|
|
146 |
|
|
147 |
"Created: 1.4.1997 / 11:58:07 / cg"
|
|
148 |
!
|
|
149 |
|
|
150 |
initializeButtons
|
|
151 |
upButton := ArrowButton upIn:self.
|
|
152 |
upButton label:(self class upButtonForm).
|
|
153 |
upButton origin:0@0.
|
|
154 |
upButton action:[self countUp].
|
|
155 |
upButton autoRepeat:true.
|
|
156 |
|
|
157 |
downButton := ArrowButton downIn:self.
|
|
158 |
downButton label:(self class downButtonForm).
|
|
159 |
downButton origin:(0 @ upButton preferredExtent y).
|
|
160 |
downButton action:[self countDown].
|
|
161 |
downButton autoRepeat:true.
|
|
162 |
|
|
163 |
self preferredExtent:(upButton preferredExtent x
|
|
164 |
@
|
|
165 |
(upButton preferredExtent y
|
|
166 |
+
|
|
167 |
downButton preferredExtent y)).
|
|
168 |
|
|
169 |
"Created: 1.4.1997 / 11:58:11 / cg"
|
|
170 |
"Modified: 1.4.1997 / 11:58:43 / cg"
|
|
171 |
! !
|
|
172 |
|
|
173 |
!UpDownButton class methodsFor:'documentation'!
|
|
174 |
|
|
175 |
version
|
|
176 |
^ '$Header: /cvs/stx/stx/libwidg2/UpDownButton.st,v 1.1 1997-04-01 10:03:05 cg Exp $'
|
|
177 |
! !
|