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