author | Claus Gittinger <cg@exept.de> |
Thu, 18 Jan 2018 19:07:03 +0100 | |
changeset 17944 | 58da3a446bc2 |
parent 17897 | d1a8350c8773 |
child 18345 | f83c69180ca0 |
permissions | -rw-r--r-- |
6772 | 1 |
" |
2 |
COPYRIGHT (c) 2006 by eXept Software AG |
|
3 |
All Rights Reserved |
|
4 |
||
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
12 |
"{ Package: 'stx:libtool' }" |
|
13 |
||
15360
480e3544af43
class: ViewWithAcceptAndCancelBar
Claus Gittinger <cg@exept.de>
parents:
14648
diff
changeset
|
14 |
"{ NameSpace: Smalltalk }" |
480e3544af43
class: ViewWithAcceptAndCancelBar
Claus Gittinger <cg@exept.de>
parents:
14648
diff
changeset
|
15 |
|
6772 | 16 |
SimpleView subclass:#ViewWithAcceptAndCancelBar |
8332 | 17 |
instanceVariableNames:'slaveView bar reallyModifiedHolder acceptAction cancelAction |
18 |
compareAction' |
|
6772 | 19 |
classVariableNames:'' |
20 |
poolDictionaries:'' |
|
21 |
category:'Views-Basic' |
|
22 |
! |
|
23 |
||
24 |
SimpleView subclass:#AcceptAndCancelBar |
|
8332 | 25 |
instanceVariableNames:'acceptButton cancelButton compareButton' |
6772 | 26 |
classVariableNames:'' |
27 |
poolDictionaries:'' |
|
28 |
privateIn:ViewWithAcceptAndCancelBar |
|
29 |
! |
|
30 |
||
6775 | 31 |
Button subclass:#ButtonWithHelpText |
32 |
instanceVariableNames:'helpText' |
|
33 |
classVariableNames:'' |
|
34 |
poolDictionaries:'' |
|
35 |
privateIn:ViewWithAcceptAndCancelBar::AcceptAndCancelBar |
|
36 |
! |
|
37 |
||
6772 | 38 |
!ViewWithAcceptAndCancelBar class methodsFor:'documentation'! |
39 |
||
40 |
copyright |
|
41 |
" |
|
42 |
COPYRIGHT (c) 2006 by eXept Software AG |
|
43 |
All Rights Reserved |
|
44 |
||
45 |
This software is furnished under a license and may be used |
|
46 |
only in accordance with the terms of that license and with the |
|
47 |
inclusion of the above copyright notice. This software may not |
|
48 |
be provided or otherwise made available to, or used by, any |
|
49 |
other person. No title to or ownership of the software is |
|
50 |
hereby transferred. |
|
51 |
" |
|
52 |
! |
|
53 |
||
54 |
documentation |
|
55 |
" |
|
56 |
experimental - self like accept/cancel bar in the browsers |
|
57 |
code view. |
|
58 |
Enable with: |
|
59 |
UserPreferences current showAcceptCancelBarInBrowser:true |
|
60 |
" |
|
61 |
! ! |
|
62 |
||
63 |
!ViewWithAcceptAndCancelBar methodsFor:'accessing'! |
|
64 |
||
65 |
acceptAction:something |
|
10919 | 66 |
"define the action to be performed when the green accept button is pressed" |
67 |
||
6772 | 68 |
acceptAction := something. |
10919 | 69 |
|
70 |
"Modified (comment): / 29-11-2011 / 12:59:18 / cg" |
|
6772 | 71 |
! |
72 |
||
73 |
cancelAction:something |
|
10919 | 74 |
"define the action to be performed when the red cancel button is pressed" |
75 |
||
6772 | 76 |
cancelAction := something. |
10919 | 77 |
|
78 |
"Modified (comment): / 29-11-2011 / 12:59:24 / cg" |
|
6772 | 79 |
! |
80 |
||
10919 | 81 |
compareAction:aBlock |
82 |
"define the action to be performed when the yellow compare button is pressed" |
|
83 |
||
84 |
compareAction := aBlock. |
|
85 |
||
86 |
"Modified (comment): / 29-11-2011 / 12:59:01 / cg" |
|
8332 | 87 |
! |
88 |
||
6772 | 89 |
reallyModifiedHolder:aValueHolder |
10919 | 90 |
"set the holder which keeps track of the real modified state; |
91 |
the modified state of the view is set with every user-input, |
|
92 |
but cleared by the master (in order to trigger future modified events). |
|
14434
a99f61cbb975
class: ViewWithAcceptAndCancelBar
Claus Gittinger <cg@exept.de>
parents:
14429
diff
changeset
|
93 |
With every modified change, the state of the reallyModified is updated" |
10919 | 94 |
|
95 |
reallyModifiedHolder notNil ifTrue:[ |
|
96 |
reallyModifiedHolder removeDependent:self. |
|
97 |
]. |
|
6772 | 98 |
reallyModifiedHolder := aValueHolder. |
10919 | 99 |
reallyModifiedHolder notNil ifTrue:[ |
100 |
reallyModifiedHolder addDependent:self. |
|
101 |
] |
|
102 |
||
103 |
"Modified: / 29-11-2011 / 13:01:02 / cg" |
|
8842 | 104 |
! |
105 |
||
106 |
scrolledView |
|
107 |
"for protocol compatibility" |
|
108 |
||
109 |
^ slaveView scrolledView |
|
6772 | 110 |
! ! |
111 |
||
8332 | 112 |
!ViewWithAcceptAndCancelBar methodsFor:'action'! |
113 |
||
114 |
accept |
|
115 |
acceptAction value |
|
116 |
! |
|
117 |
||
118 |
cancel |
|
119 |
cancelAction notNil ifTrue:[ |
|
120 |
cancelAction value |
|
121 |
] |
|
122 |
! |
|
123 |
||
124 |
compare |
|
125 |
compareAction notNil ifTrue:[ |
|
126 |
compareAction value |
|
127 |
] |
|
128 |
! ! |
|
129 |
||
6772 | 130 |
!ViewWithAcceptAndCancelBar methodsFor:'change & update'! |
131 |
||
132 |
hideBar |
|
133 |
bar unmap. |
|
134 |
bar hiddenOnRealize:true. |
|
6775 | 135 |
slaveView origin:(0.0 @ 0.0) corner:(1.0 @ 1.0). |
6772 | 136 |
! |
137 |
||
138 |
showBar |
|
6775 | 139 |
slaveView origin:(20 @ 0.0) corner:(1.0 @ 1.0). |
6772 | 140 |
bar hiddenOnRealize:false. |
141 |
bar realize. |
|
142 |
! |
|
143 |
||
144 |
update:something with:aParameter from:changedObject |
|
7309 | 145 |
|app| |
146 |
||
6772 | 147 |
slaveView notNil ifTrue:[ |
13518
049393762925
class: ViewWithAcceptAndCancelBar
Claus Gittinger <cg@exept.de>
parents:
11816
diff
changeset
|
148 |
(changedObject == reallyModifiedHolder |
049393762925
class: ViewWithAcceptAndCancelBar
Claus Gittinger <cg@exept.de>
parents:
11816
diff
changeset
|
149 |
or:[ changedObject == slaveView modifiedChannel ]) ifTrue:[ |
049393762925
class: ViewWithAcceptAndCancelBar
Claus Gittinger <cg@exept.de>
parents:
11816
diff
changeset
|
150 |
(app := self application) notNil ifTrue:[ |
049393762925
class: ViewWithAcceptAndCancelBar
Claus Gittinger <cg@exept.de>
parents:
11816
diff
changeset
|
151 |
"/ not sure if we really need to send it through the application |
049393762925
class: ViewWithAcceptAndCancelBar
Claus Gittinger <cg@exept.de>
parents:
11816
diff
changeset
|
152 |
app enqueueMessage:#updateBarVisibility for:self arguments:#(). |
049393762925
class: ViewWithAcceptAndCancelBar
Claus Gittinger <cg@exept.de>
parents:
11816
diff
changeset
|
153 |
] ifFalse:[ |
049393762925
class: ViewWithAcceptAndCancelBar
Claus Gittinger <cg@exept.de>
parents:
11816
diff
changeset
|
154 |
self sensor pushUserEvent:#updateBarVisibility for:self withArguments:#() |
049393762925
class: ViewWithAcceptAndCancelBar
Claus Gittinger <cg@exept.de>
parents:
11816
diff
changeset
|
155 |
] |
6772 | 156 |
]. |
157 |
]. |
|
158 |
super update:something with:aParameter from:changedObject |
|
7309 | 159 |
|
10919 | 160 |
"Modified: / 29-11-2011 / 12:57:55 / cg" |
6772 | 161 |
! |
162 |
||
163 |
updateBarVisibility |
|
164 |
|modified| |
|
165 |
||
10920
9228a3108da8
comment/format in: #updateBarVisibility
Claus Gittinger <cg@exept.de>
parents:
10919
diff
changeset
|
166 |
modified := reallyModifiedHolder notNil |
6772 | 167 |
ifTrue:[ reallyModifiedHolder value ] |
168 |
ifFalse:[ slaveView modifiedChannel value ]. |
|
169 |
||
170 |
modified ifTrue:[ |
|
171 |
self showBar |
|
172 |
] ifFalse:[ |
|
173 |
self hideBar |
|
174 |
]. |
|
10920
9228a3108da8
comment/format in: #updateBarVisibility
Claus Gittinger <cg@exept.de>
parents:
10919
diff
changeset
|
175 |
|
9228a3108da8
comment/format in: #updateBarVisibility
Claus Gittinger <cg@exept.de>
parents:
10919
diff
changeset
|
176 |
"Modified (format): / 29-11-2011 / 14:05:04 / cg" |
6772 | 177 |
! ! |
178 |
||
179 |
!ViewWithAcceptAndCancelBar methodsFor:'initialization'! |
|
180 |
||
181 |
initialize |
|
182 |
super initialize. |
|
183 |
||
184 |
bar := AcceptAndCancelBar in:self. |
|
185 |
bar origin:(0.0 @ 0.0) corner:(20 @ 1.0). |
|
186 |
bar hiddenOnRealize:true. |
|
187 |
||
188 |
bar acceptButton action:[ self accept ]. |
|
189 |
bar cancelButton action:[ self cancel ]. |
|
8332 | 190 |
bar compareButton action:[ self compare ]. |
6772 | 191 |
|
192 |
acceptAction := [ slaveView notNil ifTrue:[ slaveView accept ] ]. |
|
193 |
cancelAction := [ ]. |
|
194 |
||
195 |
" |
|
196 |
self new open |
|
197 |
" |
|
198 |
! |
|
199 |
||
14429
3fb66a972ee5
class: ViewWithAcceptAndCancelBar
Claus Gittinger <cg@exept.de>
parents:
13518
diff
changeset
|
200 |
setSlaveView:aView |
6772 | 201 |
slaveView := aView. |
202 |
aView origin:(0.0@0.0) corner:(1.0@1.0). |
|
203 |
aView modifiedChannel addDependent:self. |
|
204 |
||
205 |
" |
|
206 |
|v| |
|
207 |
||
208 |
v := self new. |
|
209 |
v slaveView:CodeView new. |
|
210 |
v open |
|
211 |
" |
|
14429
3fb66a972ee5
class: ViewWithAcceptAndCancelBar
Claus Gittinger <cg@exept.de>
parents:
13518
diff
changeset
|
212 |
! |
3fb66a972ee5
class: ViewWithAcceptAndCancelBar
Claus Gittinger <cg@exept.de>
parents:
13518
diff
changeset
|
213 |
|
3fb66a972ee5
class: ViewWithAcceptAndCancelBar
Claus Gittinger <cg@exept.de>
parents:
13518
diff
changeset
|
214 |
slaveView:aView |
3fb66a972ee5
class: ViewWithAcceptAndCancelBar
Claus Gittinger <cg@exept.de>
parents:
13518
diff
changeset
|
215 |
self add:aView. |
3fb66a972ee5
class: ViewWithAcceptAndCancelBar
Claus Gittinger <cg@exept.de>
parents:
13518
diff
changeset
|
216 |
self setSlaveView:aView. |
3fb66a972ee5
class: ViewWithAcceptAndCancelBar
Claus Gittinger <cg@exept.de>
parents:
13518
diff
changeset
|
217 |
|
3fb66a972ee5
class: ViewWithAcceptAndCancelBar
Claus Gittinger <cg@exept.de>
parents:
13518
diff
changeset
|
218 |
" |
3fb66a972ee5
class: ViewWithAcceptAndCancelBar
Claus Gittinger <cg@exept.de>
parents:
13518
diff
changeset
|
219 |
|v| |
3fb66a972ee5
class: ViewWithAcceptAndCancelBar
Claus Gittinger <cg@exept.de>
parents:
13518
diff
changeset
|
220 |
|
3fb66a972ee5
class: ViewWithAcceptAndCancelBar
Claus Gittinger <cg@exept.de>
parents:
13518
diff
changeset
|
221 |
v := self new. |
3fb66a972ee5
class: ViewWithAcceptAndCancelBar
Claus Gittinger <cg@exept.de>
parents:
13518
diff
changeset
|
222 |
v slaveView:CodeView new. |
3fb66a972ee5
class: ViewWithAcceptAndCancelBar
Claus Gittinger <cg@exept.de>
parents:
13518
diff
changeset
|
223 |
v open |
3fb66a972ee5
class: ViewWithAcceptAndCancelBar
Claus Gittinger <cg@exept.de>
parents:
13518
diff
changeset
|
224 |
" |
6772 | 225 |
! ! |
226 |
||
227 |
!ViewWithAcceptAndCancelBar::AcceptAndCancelBar methodsFor:'accessing'! |
|
228 |
||
229 |
acceptButton |
|
230 |
^ acceptButton |
|
231 |
! |
|
232 |
||
233 |
cancelButton |
|
234 |
^ cancelButton |
|
8332 | 235 |
! |
236 |
||
237 |
compareButton |
|
238 |
^ compareButton |
|
7761 | 239 |
! ! |
240 |
||
241 |
!ViewWithAcceptAndCancelBar::AcceptAndCancelBar methodsFor:'help'! |
|
6775 | 242 |
|
17897 | 243 |
helpTextAt:srcPoint |
6775 | 244 |
"return the helpText for aPoint (i.e. when mouse-pointer is moved over an item)." |
245 |
||
246 |
(acceptButton bounds containsPoint:srcPoint) ifTrue:[ |
|
11816 | 247 |
^ resources string:'Accept' |
6775 | 248 |
]. |
8332 | 249 |
(cancelButton bounds containsPoint:srcPoint) ifTrue:[ |
11816 | 250 |
^ resources string:'Cancel' |
6775 | 251 |
]. |
8332 | 252 |
(compareButton bounds containsPoint:srcPoint) ifTrue:[ |
11816 | 253 |
^ resources string:'Compare against Original' |
8332 | 254 |
]. |
6775 | 255 |
^ nil |
11816 | 256 |
|
257 |
"Modified: / 26-09-2012 / 14:26:14 / cg" |
|
6772 | 258 |
! ! |
259 |
||
260 |
!ViewWithAcceptAndCancelBar::AcceptAndCancelBar methodsFor:'initialization'! |
|
261 |
||
262 |
initialize |
|
16612 | 263 |
|acceptColor cancelColor compareColor order| |
15360
480e3544af43
class: ViewWithAcceptAndCancelBar
Claus Gittinger <cg@exept.de>
parents:
14648
diff
changeset
|
264 |
|
6772 | 265 |
super initialize. |
266 |
||
17323 | 267 |
acceptColor := Color greenCaringForColorBlindness. |
268 |
cancelColor := Color redCaringForColorBlindness. |
|
15360
480e3544af43
class: ViewWithAcceptAndCancelBar
Claus Gittinger <cg@exept.de>
parents:
14648
diff
changeset
|
269 |
compareColor := Color yellow. |
480e3544af43
class: ViewWithAcceptAndCancelBar
Claus Gittinger <cg@exept.de>
parents:
14648
diff
changeset
|
270 |
|
16612 | 271 |
order := UserPreferences current acceptCancelBarOrder. |
272 |
||
6775 | 273 |
acceptButton := ButtonWithHelpText new. |
8336 | 274 |
acceptButton origin:0.0 @ 0.0 corner:1.0@0.7. |
15360
480e3544af43
class: ViewWithAcceptAndCancelBar
Claus Gittinger <cg@exept.de>
parents:
14648
diff
changeset
|
275 |
acceptButton backgroundColor:acceptColor. |
480e3544af43
class: ViewWithAcceptAndCancelBar
Claus Gittinger <cg@exept.de>
parents:
14648
diff
changeset
|
276 |
acceptButton enteredBackgroundColor:acceptColor lightened. |
480e3544af43
class: ViewWithAcceptAndCancelBar
Claus Gittinger <cg@exept.de>
parents:
14648
diff
changeset
|
277 |
acceptButton activeBackgroundColor:acceptColor darkened. |
17897 | 278 |
acceptButton helpText:(resources string:'Accept'). |
6772 | 279 |
self add:acceptButton. |
280 |
||
6775 | 281 |
cancelButton := ButtonWithHelpText new. |
16612 | 282 |
order == #acceptCompareCancel ifTrue:[ |
283 |
cancelButton origin:0.0 @ 0.9 corner:1.0@1.0. |
|
284 |
] ifFalse:[ |
|
285 |
cancelButton origin:0.0 @ 0.7 corner:1.0@0.9. |
|
286 |
]. |
|
15360
480e3544af43
class: ViewWithAcceptAndCancelBar
Claus Gittinger <cg@exept.de>
parents:
14648
diff
changeset
|
287 |
cancelButton backgroundColor:cancelColor. |
480e3544af43
class: ViewWithAcceptAndCancelBar
Claus Gittinger <cg@exept.de>
parents:
14648
diff
changeset
|
288 |
cancelButton enteredBackgroundColor:cancelColor lightened. |
480e3544af43
class: ViewWithAcceptAndCancelBar
Claus Gittinger <cg@exept.de>
parents:
14648
diff
changeset
|
289 |
cancelButton activeBackgroundColor:cancelColor darkened. |
17897 | 290 |
cancelButton helpText:(resources string:'Cancel'). |
6772 | 291 |
self add:cancelButton. |
292 |
||
8332 | 293 |
compareButton := ButtonWithHelpText new. |
16612 | 294 |
order == #acceptCompareCancel ifTrue:[ |
295 |
compareButton origin:0.0 @ 0.7 corner:1.0@0.9. |
|
296 |
] ifFalse:[ |
|
297 |
compareButton origin:0.0 @ 0.9 corner:1.0@1.0. |
|
298 |
]. |
|
15360
480e3544af43
class: ViewWithAcceptAndCancelBar
Claus Gittinger <cg@exept.de>
parents:
14648
diff
changeset
|
299 |
compareButton backgroundColor:compareColor. |
480e3544af43
class: ViewWithAcceptAndCancelBar
Claus Gittinger <cg@exept.de>
parents:
14648
diff
changeset
|
300 |
compareButton enteredBackgroundColor:compareColor lightened lightened. |
480e3544af43
class: ViewWithAcceptAndCancelBar
Claus Gittinger <cg@exept.de>
parents:
14648
diff
changeset
|
301 |
compareButton activeBackgroundColor:compareColor darkened. |
17897 | 302 |
compareButton helpText:(resources string:'Compare against Original'). |
8332 | 303 |
compareButton label:'?'. |
304 |
self add:compareButton. |
|
305 |
||
6772 | 306 |
" |
307 |
AcceptAndCancelBar new open |
|
308 |
" |
|
11816 | 309 |
|
17323 | 310 |
"Modified: / 03-02-2017 / 14:04:32 / cg" |
6772 | 311 |
! ! |
312 |
||
6775 | 313 |
!ViewWithAcceptAndCancelBar::AcceptAndCancelBar::ButtonWithHelpText methodsFor:'accessing'! |
314 |
||
17897 | 315 |
helpText |
6775 | 316 |
^ helpText |
317 |
! |
|
318 |
||
17897 | 319 |
helpText:something |
6775 | 320 |
helpText := something. |
321 |
! ! |
|
322 |
||
16305 | 323 |
!ViewWithAcceptAndCancelBar::AcceptAndCancelBar::ButtonWithHelpText methodsFor:'initialization'! |
324 |
||
325 |
reinitStyle |
|
326 |
"do nothing, especially keep the background color" |
|
327 |
! ! |
|
328 |
||
6772 | 329 |
!ViewWithAcceptAndCancelBar class methodsFor:'documentation'! |
330 |
||
331 |
version |
|
16305 | 332 |
^ '$Header$' |
8842 | 333 |
! |
334 |
||
335 |
version_CVS |
|
16305 | 336 |
^ '$Header$' |
6772 | 337 |
! ! |
13518
049393762925
class: ViewWithAcceptAndCancelBar
Claus Gittinger <cg@exept.de>
parents:
11816
diff
changeset
|
338 |