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