author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Mon, 30 Jan 2012 17:49:41 +0000 | |
branch | jv |
changeset 12128 | a7ff7d66ee85 |
parent 12125 | 0c49a3b13e43 |
child 12296 | 6921627a8c27 |
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 |
|
12125 | 64 |
"define the action to be performed when the green accept button is pressed" |
65 |
||
6772 | 66 |
acceptAction := something. |
12125 | 67 |
|
68 |
"Modified (comment): / 29-11-2011 / 12:59:18 / cg" |
|
6772 | 69 |
! |
70 |
||
71 |
cancelAction:something |
|
12125 | 72 |
"define the action to be performed when the red cancel button is pressed" |
73 |
||
6772 | 74 |
cancelAction := something. |
12125 | 75 |
|
76 |
"Modified (comment): / 29-11-2011 / 12:59:24 / cg" |
|
6772 | 77 |
! |
78 |
||
12125 | 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 |
12125 | 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. |
12125 | 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:[ |
12125 | 146 |
(app := self application) notNil ifTrue:[ |
147 |
(changedObject == reallyModifiedHolder |
|
148 |
or:[ changedObject == slaveView modifiedChannel ]) ifTrue:[ |
|
7309 | 149 |
app |
150 |
enqueueMessage:#updateBarVisibility |
|
8240 | 151 |
for:self |
152 |
arguments:#(). |
|
7309 | 153 |
]. |
6772 | 154 |
]. |
155 |
]. |
|
156 |
super update:something with:aParameter from:changedObject |
|
7309 | 157 |
|
12125 | 158 |
"Modified: / 29-11-2011 / 12:57:55 / cg" |
6772 | 159 |
! |
160 |
||
161 |
updateBarVisibility |
|
162 |
|modified| |
|
163 |
||
12125 | 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 |
]. |
|
12125 | 173 |
|
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 |
||
198 |
slaveView:aView |
|
199 |
self add:aView. |
|
200 |
slaveView := aView. |
|
201 |
aView origin:(0.0@0.0) corner:(1.0@1.0). |
|
202 |
aView modifiedChannel addDependent:self. |
|
203 |
||
204 |
" |
|
205 |
|v| |
|
206 |
||
207 |
v := self new. |
|
208 |
v slaveView:CodeView new. |
|
209 |
v open |
|
210 |
" |
|
211 |
! ! |
|
212 |
||
213 |
!ViewWithAcceptAndCancelBar::AcceptAndCancelBar methodsFor:'accessing'! |
|
214 |
||
215 |
acceptButton |
|
216 |
^ acceptButton |
|
217 |
! |
|
218 |
||
219 |
cancelButton |
|
220 |
^ cancelButton |
|
8332 | 221 |
! |
222 |
||
223 |
compareButton |
|
224 |
^ compareButton |
|
7761 | 225 |
! ! |
226 |
||
227 |
!ViewWithAcceptAndCancelBar::AcceptAndCancelBar methodsFor:'help'! |
|
6775 | 228 |
|
229 |
flyByHelpTextAt:srcPoint |
|
230 |
"return the helpText for aPoint (i.e. when mouse-pointer is moved over an item)." |
|
231 |
||
232 |
(acceptButton bounds containsPoint:srcPoint) ifTrue:[ |
|
233 |
^ 'Accept' |
|
234 |
]. |
|
8332 | 235 |
(cancelButton bounds containsPoint:srcPoint) ifTrue:[ |
6775 | 236 |
^ 'Cancel' |
237 |
]. |
|
8332 | 238 |
(compareButton bounds containsPoint:srcPoint) ifTrue:[ |
239 |
^ 'Compare against Original' |
|
240 |
]. |
|
6775 | 241 |
^ nil |
6772 | 242 |
! ! |
243 |
||
244 |
!ViewWithAcceptAndCancelBar::AcceptAndCancelBar methodsFor:'initialization'! |
|
245 |
||
246 |
initialize |
|
247 |
super initialize. |
|
248 |
||
6775 | 249 |
acceptButton := ButtonWithHelpText new. |
8336 | 250 |
acceptButton origin:0.0 @ 0.0 corner:1.0@0.7. |
6772 | 251 |
acceptButton backgroundColor:Color green. |
6775 | 252 |
acceptButton flyByHelpText:'Accept'. |
6772 | 253 |
self add:acceptButton. |
254 |
||
6775 | 255 |
cancelButton := ButtonWithHelpText new. |
8336 | 256 |
cancelButton origin:0.0 @ 0.7 corner:1.0@0.9. |
6772 | 257 |
cancelButton backgroundColor:Color red. |
6775 | 258 |
cancelButton flyByHelpText:'Cancel'. |
6772 | 259 |
self add:cancelButton. |
260 |
||
8332 | 261 |
compareButton := ButtonWithHelpText new. |
8336 | 262 |
compareButton origin:0.0 @ 0.9 corner:1.0@1.0. |
8332 | 263 |
compareButton backgroundColor:Color yellow. |
264 |
compareButton flyByHelpText:'Compare against Original'. |
|
265 |
compareButton label:'?'. |
|
266 |
self add:compareButton. |
|
267 |
||
6772 | 268 |
" |
269 |
AcceptAndCancelBar new open |
|
270 |
" |
|
271 |
! ! |
|
272 |
||
6775 | 273 |
!ViewWithAcceptAndCancelBar::AcceptAndCancelBar::ButtonWithHelpText methodsFor:'accessing'! |
274 |
||
275 |
flyByHelpText |
|
276 |
^ helpText |
|
277 |
! |
|
278 |
||
279 |
flyByHelpText:something |
|
280 |
helpText := something. |
|
281 |
! ! |
|
282 |
||
6772 | 283 |
!ViewWithAcceptAndCancelBar class methodsFor:'documentation'! |
284 |
||
285 |
version |
|
12128
a7ff7d66ee85
Improvements in LintHighlighter, few fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12125
diff
changeset
|
286 |
^ '$Id: ViewWithAcceptAndCancelBar.st 7854 2012-01-30 17:49:41Z vranyj1 $' |
8842 | 287 |
! |
288 |
||
289 |
version_CVS |
|
12125 | 290 |
^ '§Header: /cvs/stx/stx/libtool/ViewWithAcceptAndCancelBar.st,v 1.10 2011/11/29 13:05:12 cg Exp §' |
12128
a7ff7d66ee85
Improvements in LintHighlighter, few fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12125
diff
changeset
|
291 |
! |
a7ff7d66ee85
Improvements in LintHighlighter, few fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12125
diff
changeset
|
292 |
|
a7ff7d66ee85
Improvements in LintHighlighter, few fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12125
diff
changeset
|
293 |
version_SVN |
a7ff7d66ee85
Improvements in LintHighlighter, few fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12125
diff
changeset
|
294 |
^ '$Id: ViewWithAcceptAndCancelBar.st 7854 2012-01-30 17:49:41Z vranyj1 $' |
12125 | 295 |
! ! |