author | Claus Gittinger <cg@exept.de> |
Thu, 05 Mar 2020 11:18:04 +0100 | |
changeset 19547 | 63ae485b071a |
parent 19454 | 6195b98dafdd |
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 |
19454 | 20 |
compareAction barShown' |
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 |
|
19454 | 135 |
barShown ifTrue:[ |
136 |
bar unmap. |
|
137 |
bar hiddenOnRealize:true. |
|
138 |
slaveView origin:(0.0 @ 0.0) corner:(1.0 @ 1.0). |
|
139 |
barShown := false. |
|
140 |
] |
|
6772 | 141 |
! |
142 |
||
143 |
showBar |
|
19454 | 144 |
barShown ifFalse:[ |
145 |
slaveView origin:(20 @ 0.0) corner:(1.0 @ 1.0). |
|
146 |
bar hiddenOnRealize:false. |
|
147 |
bar realize. |
|
148 |
barShown := true. |
|
149 |
]. |
|
6772 | 150 |
! |
151 |
||
152 |
update:something with:aParameter from:changedObject |
|
7309 | 153 |
|app| |
154 |
||
6772 | 155 |
slaveView notNil ifTrue:[ |
13518
049393762925
class: ViewWithAcceptAndCancelBar
Claus Gittinger <cg@exept.de>
parents:
11816
diff
changeset
|
156 |
(changedObject == reallyModifiedHolder |
049393762925
class: ViewWithAcceptAndCancelBar
Claus Gittinger <cg@exept.de>
parents:
11816
diff
changeset
|
157 |
or:[ changedObject == slaveView modifiedChannel ]) ifTrue:[ |
049393762925
class: ViewWithAcceptAndCancelBar
Claus Gittinger <cg@exept.de>
parents:
11816
diff
changeset
|
158 |
(app := self application) notNil ifTrue:[ |
049393762925
class: ViewWithAcceptAndCancelBar
Claus Gittinger <cg@exept.de>
parents:
11816
diff
changeset
|
159 |
"/ not sure if we really need to send it through the application |
049393762925
class: ViewWithAcceptAndCancelBar
Claus Gittinger <cg@exept.de>
parents:
11816
diff
changeset
|
160 |
app enqueueMessage:#updateBarVisibility for:self arguments:#(). |
049393762925
class: ViewWithAcceptAndCancelBar
Claus Gittinger <cg@exept.de>
parents:
11816
diff
changeset
|
161 |
] ifFalse:[ |
049393762925
class: ViewWithAcceptAndCancelBar
Claus Gittinger <cg@exept.de>
parents:
11816
diff
changeset
|
162 |
self sensor pushUserEvent:#updateBarVisibility for:self withArguments:#() |
18345 | 163 |
]. |
164 |
^ self. |
|
6772 | 165 |
]. |
166 |
]. |
|
167 |
super update:something with:aParameter from:changedObject |
|
7309 | 168 |
|
10919 | 169 |
"Modified: / 29-11-2011 / 12:57:55 / cg" |
18345 | 170 |
"Modified: / 22-08-2018 / 10:39:33 / Claus Gittinger" |
6772 | 171 |
! |
172 |
||
173 |
updateBarVisibility |
|
174 |
|modified| |
|
175 |
||
10920
9228a3108da8
comment/format in: #updateBarVisibility
Claus Gittinger <cg@exept.de>
parents:
10919
diff
changeset
|
176 |
modified := reallyModifiedHolder notNil |
6772 | 177 |
ifTrue:[ reallyModifiedHolder value ] |
178 |
ifFalse:[ slaveView modifiedChannel value ]. |
|
179 |
||
180 |
modified ifTrue:[ |
|
181 |
self showBar |
|
182 |
] ifFalse:[ |
|
183 |
self hideBar |
|
184 |
]. |
|
10920
9228a3108da8
comment/format in: #updateBarVisibility
Claus Gittinger <cg@exept.de>
parents:
10919
diff
changeset
|
185 |
|
9228a3108da8
comment/format in: #updateBarVisibility
Claus Gittinger <cg@exept.de>
parents:
10919
diff
changeset
|
186 |
"Modified (format): / 29-11-2011 / 14:05:04 / cg" |
6772 | 187 |
! ! |
188 |
||
189 |
!ViewWithAcceptAndCancelBar methodsFor:'initialization'! |
|
190 |
||
191 |
initialize |
|
192 |
super initialize. |
|
193 |
||
194 |
bar := AcceptAndCancelBar in:self. |
|
195 |
bar origin:(0.0 @ 0.0) corner:(20 @ 1.0). |
|
196 |
bar hiddenOnRealize:true. |
|
19454 | 197 |
barShown := false. |
6772 | 198 |
|
199 |
bar acceptButton action:[ self accept ]. |
|
200 |
bar cancelButton action:[ self cancel ]. |
|
8332 | 201 |
bar compareButton action:[ self compare ]. |
6772 | 202 |
|
203 |
acceptAction := [ slaveView notNil ifTrue:[ slaveView accept ] ]. |
|
204 |
cancelAction := [ ]. |
|
205 |
||
206 |
" |
|
207 |
self new open |
|
208 |
" |
|
209 |
! |
|
210 |
||
14429
3fb66a972ee5
class: ViewWithAcceptAndCancelBar
Claus Gittinger <cg@exept.de>
parents:
13518
diff
changeset
|
211 |
setSlaveView:aView |
6772 | 212 |
slaveView := aView. |
213 |
aView origin:(0.0@0.0) corner:(1.0@1.0). |
|
214 |
aView modifiedChannel addDependent:self. |
|
215 |
||
216 |
" |
|
217 |
|v| |
|
218 |
||
219 |
v := self new. |
|
220 |
v slaveView:CodeView new. |
|
221 |
v open |
|
222 |
" |
|
14429
3fb66a972ee5
class: ViewWithAcceptAndCancelBar
Claus Gittinger <cg@exept.de>
parents:
13518
diff
changeset
|
223 |
! |
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 |
slaveView:aView |
3fb66a972ee5
class: ViewWithAcceptAndCancelBar
Claus Gittinger <cg@exept.de>
parents:
13518
diff
changeset
|
226 |
self add:aView. |
3fb66a972ee5
class: ViewWithAcceptAndCancelBar
Claus Gittinger <cg@exept.de>
parents:
13518
diff
changeset
|
227 |
self setSlaveView:aView. |
3fb66a972ee5
class: ViewWithAcceptAndCancelBar
Claus Gittinger <cg@exept.de>
parents:
13518
diff
changeset
|
228 |
|
3fb66a972ee5
class: ViewWithAcceptAndCancelBar
Claus Gittinger <cg@exept.de>
parents:
13518
diff
changeset
|
229 |
" |
3fb66a972ee5
class: ViewWithAcceptAndCancelBar
Claus Gittinger <cg@exept.de>
parents:
13518
diff
changeset
|
230 |
|v| |
3fb66a972ee5
class: ViewWithAcceptAndCancelBar
Claus Gittinger <cg@exept.de>
parents:
13518
diff
changeset
|
231 |
|
3fb66a972ee5
class: ViewWithAcceptAndCancelBar
Claus Gittinger <cg@exept.de>
parents:
13518
diff
changeset
|
232 |
v := self new. |
3fb66a972ee5
class: ViewWithAcceptAndCancelBar
Claus Gittinger <cg@exept.de>
parents:
13518
diff
changeset
|
233 |
v slaveView:CodeView new. |
3fb66a972ee5
class: ViewWithAcceptAndCancelBar
Claus Gittinger <cg@exept.de>
parents:
13518
diff
changeset
|
234 |
v open |
3fb66a972ee5
class: ViewWithAcceptAndCancelBar
Claus Gittinger <cg@exept.de>
parents:
13518
diff
changeset
|
235 |
" |
6772 | 236 |
! ! |
237 |
||
238 |
!ViewWithAcceptAndCancelBar::AcceptAndCancelBar methodsFor:'accessing'! |
|
239 |
||
240 |
acceptButton |
|
241 |
^ acceptButton |
|
242 |
! |
|
243 |
||
244 |
cancelButton |
|
245 |
^ cancelButton |
|
8332 | 246 |
! |
247 |
||
248 |
compareButton |
|
249 |
^ compareButton |
|
7761 | 250 |
! ! |
251 |
||
252 |
!ViewWithAcceptAndCancelBar::AcceptAndCancelBar methodsFor:'help'! |
|
6775 | 253 |
|
17897 | 254 |
helpTextAt:srcPoint |
6775 | 255 |
"return the helpText for aPoint (i.e. when mouse-pointer is moved over an item)." |
256 |
||
257 |
(acceptButton bounds containsPoint:srcPoint) ifTrue:[ |
|
11816 | 258 |
^ resources string:'Accept' |
6775 | 259 |
]. |
8332 | 260 |
(cancelButton bounds containsPoint:srcPoint) ifTrue:[ |
11816 | 261 |
^ resources string:'Cancel' |
6775 | 262 |
]. |
8332 | 263 |
(compareButton bounds containsPoint:srcPoint) ifTrue:[ |
11816 | 264 |
^ resources string:'Compare against Original' |
8332 | 265 |
]. |
6775 | 266 |
^ nil |
11816 | 267 |
|
268 |
"Modified: / 26-09-2012 / 14:26:14 / cg" |
|
6772 | 269 |
! ! |
270 |
||
271 |
!ViewWithAcceptAndCancelBar::AcceptAndCancelBar methodsFor:'initialization'! |
|
272 |
||
273 |
initialize |
|
16612 | 274 |
|acceptColor cancelColor compareColor order| |
15360
480e3544af43
class: ViewWithAcceptAndCancelBar
Claus Gittinger <cg@exept.de>
parents:
14648
diff
changeset
|
275 |
|
6772 | 276 |
super initialize. |
277 |
||
17323 | 278 |
acceptColor := Color greenCaringForColorBlindness. |
279 |
cancelColor := Color redCaringForColorBlindness. |
|
15360
480e3544af43
class: ViewWithAcceptAndCancelBar
Claus Gittinger <cg@exept.de>
parents:
14648
diff
changeset
|
280 |
compareColor := Color yellow. |
480e3544af43
class: ViewWithAcceptAndCancelBar
Claus Gittinger <cg@exept.de>
parents:
14648
diff
changeset
|
281 |
|
16612 | 282 |
order := UserPreferences current acceptCancelBarOrder. |
283 |
||
6775 | 284 |
acceptButton := ButtonWithHelpText new. |
8336 | 285 |
acceptButton origin:0.0 @ 0.0 corner:1.0@0.7. |
15360
480e3544af43
class: ViewWithAcceptAndCancelBar
Claus Gittinger <cg@exept.de>
parents:
14648
diff
changeset
|
286 |
acceptButton backgroundColor:acceptColor. |
480e3544af43
class: ViewWithAcceptAndCancelBar
Claus Gittinger <cg@exept.de>
parents:
14648
diff
changeset
|
287 |
acceptButton enteredBackgroundColor:acceptColor lightened. |
480e3544af43
class: ViewWithAcceptAndCancelBar
Claus Gittinger <cg@exept.de>
parents:
14648
diff
changeset
|
288 |
acceptButton activeBackgroundColor:acceptColor darkened. |
17897 | 289 |
acceptButton helpText:(resources string:'Accept'). |
6772 | 290 |
self add:acceptButton. |
291 |
||
6775 | 292 |
cancelButton := ButtonWithHelpText new. |
16612 | 293 |
order == #acceptCompareCancel ifTrue:[ |
294 |
cancelButton origin:0.0 @ 0.9 corner:1.0@1.0. |
|
295 |
] ifFalse:[ |
|
296 |
cancelButton origin:0.0 @ 0.7 corner:1.0@0.9. |
|
297 |
]. |
|
15360
480e3544af43
class: ViewWithAcceptAndCancelBar
Claus Gittinger <cg@exept.de>
parents:
14648
diff
changeset
|
298 |
cancelButton backgroundColor:cancelColor. |
480e3544af43
class: ViewWithAcceptAndCancelBar
Claus Gittinger <cg@exept.de>
parents:
14648
diff
changeset
|
299 |
cancelButton enteredBackgroundColor:cancelColor lightened. |
480e3544af43
class: ViewWithAcceptAndCancelBar
Claus Gittinger <cg@exept.de>
parents:
14648
diff
changeset
|
300 |
cancelButton activeBackgroundColor:cancelColor darkened. |
17897 | 301 |
cancelButton helpText:(resources string:'Cancel'). |
6772 | 302 |
self add:cancelButton. |
303 |
||
8332 | 304 |
compareButton := ButtonWithHelpText new. |
16612 | 305 |
order == #acceptCompareCancel ifTrue:[ |
306 |
compareButton origin:0.0 @ 0.7 corner:1.0@0.9. |
|
307 |
] ifFalse:[ |
|
308 |
compareButton origin:0.0 @ 0.9 corner:1.0@1.0. |
|
309 |
]. |
|
15360
480e3544af43
class: ViewWithAcceptAndCancelBar
Claus Gittinger <cg@exept.de>
parents:
14648
diff
changeset
|
310 |
compareButton backgroundColor:compareColor. |
480e3544af43
class: ViewWithAcceptAndCancelBar
Claus Gittinger <cg@exept.de>
parents:
14648
diff
changeset
|
311 |
compareButton enteredBackgroundColor:compareColor lightened lightened. |
480e3544af43
class: ViewWithAcceptAndCancelBar
Claus Gittinger <cg@exept.de>
parents:
14648
diff
changeset
|
312 |
compareButton activeBackgroundColor:compareColor darkened. |
17897 | 313 |
compareButton helpText:(resources string:'Compare against Original'). |
8332 | 314 |
compareButton label:'?'. |
315 |
self add:compareButton. |
|
316 |
||
6772 | 317 |
" |
318 |
AcceptAndCancelBar new open |
|
319 |
" |
|
11816 | 320 |
|
17323 | 321 |
"Modified: / 03-02-2017 / 14:04:32 / cg" |
6772 | 322 |
! ! |
323 |
||
6775 | 324 |
!ViewWithAcceptAndCancelBar::AcceptAndCancelBar::ButtonWithHelpText methodsFor:'accessing'! |
325 |
||
17897 | 326 |
helpText |
6775 | 327 |
^ helpText |
328 |
! |
|
329 |
||
19437 | 330 |
helpText:aStringOrNil |
331 |
helpText := aStringOrNil. |
|
6775 | 332 |
! ! |
333 |
||
16305 | 334 |
!ViewWithAcceptAndCancelBar::AcceptAndCancelBar::ButtonWithHelpText methodsFor:'initialization'! |
335 |
||
336 |
reinitStyle |
|
337 |
"do nothing, especially keep the background color" |
|
338 |
! ! |
|
339 |
||
6772 | 340 |
!ViewWithAcceptAndCancelBar class methodsFor:'documentation'! |
341 |
||
342 |
version |
|
16305 | 343 |
^ '$Header$' |
8842 | 344 |
! |
345 |
||
346 |
version_CVS |
|
16305 | 347 |
^ '$Header$' |
6772 | 348 |
! ! |
13518
049393762925
class: ViewWithAcceptAndCancelBar
Claus Gittinger <cg@exept.de>
parents:
11816
diff
changeset
|
349 |