author | Claus Gittinger <cg@exept.de> |
Tue, 26 Feb 2008 11:20:50 +0100 | |
changeset 2297 | ee43ce83094d |
parent 2295 | 79edbe5882c6 |
child 2311 | 67811bdeb0f5 |
permissions | -rw-r--r-- |
60 | 1 |
" |
156 | 2 |
COPYRIGHT (c) 1995 by Claus Gittinger / eXept Software AG |
1834 | 3 |
All Rights Reserved |
60 | 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 |
|
742 | 7 |
inclusion of the above copyright notice. This software may not |
60 | 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 |
" |
|
1387 | 12 |
"{ Package: 'stx:libtool2' }" |
13 |
||
60 | 14 |
UIObjectView subclass:#UIPainterView |
278 | 15 |
instanceVariableNames:'treeView listHolder superclassName className methodName |
2244 | 16 |
categoryName handleColorBlack handleColorWhite handleMasterColor |
2276
485bda17023f
more changes to allow for non-class/selector (i.e. spec-only) use
Claus Gittinger <cg@exept.de>
parents:
2265
diff
changeset
|
17 |
sketchPainter listOfAspectsHolder' |
2244 | 18 |
classVariableNames:'HandCursor RedefineAspectMethods AspectsAsInstances |
19 |
GenerateCommentedCode' |
|
60 | 20 |
poolDictionaries:'' |
21 |
category:'Interface-UIPainter' |
|
22 |
! |
|
23 |
||
211 | 24 |
Object subclass:#ViewProperty |
25 |
instanceVariableNames:'view spec identifier' |
|
26 |
classVariableNames:'Identifier' |
|
27 |
poolDictionaries:'' |
|
28 |
privateIn:UIPainterView |
|
29 |
! |
|
30 |
||
60 | 31 |
!UIPainterView class methodsFor:'documentation'! |
32 |
||
33 |
copyright |
|
34 |
" |
|
156 | 35 |
COPYRIGHT (c) 1995 by Claus Gittinger / eXept Software AG |
1834 | 36 |
All Rights Reserved |
60 | 37 |
|
38 |
This software is furnished under a license and may be used |
|
39 |
only in accordance with the terms of that license and with the |
|
742 | 40 |
inclusion of the above copyright notice. This software may not |
60 | 41 |
be provided or otherwise made available to, or used by, any |
42 |
other person. No title to or ownership of the software is |
|
43 |
hereby transferred. |
|
44 |
" |
|
45 |
! |
|
46 |
||
47 |
documentation |
|
48 |
" |
|
128 | 49 |
buildIn view used by the UIPainter; from this view, the layout of the |
50 |
new application derives from. |
|
51 |
||
52 |
[see also:] |
|
1834 | 53 |
UIBuilder |
54 |
UIObjectView |
|
156 | 55 |
|
56 |
[author:] |
|
1834 | 57 |
Claus Gittinger |
58 |
Claus Atzkern |
|
60 | 59 |
" |
60 |
! ! |
|
61 |
||
1225 | 62 |
!UIPainterView class methodsFor:'initialization'! |
63 |
||
64 |
initialize |
|
65 |
||
1494 | 66 |
AspectsAsInstances := true. "/ false. |
1225 | 67 |
RedefineAspectMethods := false. |
68 |
||
69 |
"Created: / 22.9.1999 / 12:32:31 / stefan" |
|
70 |
! ! |
|
71 |
||
698 | 72 |
!UIPainterView class methodsFor:'code generation mode'! |
73 |
||
925
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
74 |
generateAspectsAsInstanceVariables |
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
75 |
"if on, aspects are held as instance variables; |
2244 | 76 |
if off (the default), they are kept in the bindings dictionary." |
77 |
||
925
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
78 |
^ AspectsAsInstances |
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
79 |
|
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
80 |
"Created: / 29.7.1998 / 11:21:38 / cg" |
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
81 |
"Modified: / 29.7.1998 / 11:22:01 / cg" |
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
82 |
! |
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
83 |
|
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
84 |
generateAspectsAsInstanceVariables:aBoolean |
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
85 |
"if on, aspects are held as instance variables; |
2244 | 86 |
if off (the default), they are kept in the bindings dictionary." |
87 |
||
925
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
88 |
AspectsAsInstances := aBoolean |
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
89 |
|
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
90 |
"Created: / 29.7.1998 / 11:21:26 / cg" |
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
91 |
"Modified: / 29.7.1998 / 11:22:11 / cg" |
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
92 |
! |
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
93 |
|
2244 | 94 |
generateCommentedCode |
95 |
"comments in generated aspect methods; yes or no." |
|
96 |
||
97 |
^ GenerateCommentedCode ? true |
|
98 |
||
99 |
"Modified: / 12-01-2008 / 10:21:06 / cg" |
|
100 |
! |
|
101 |
||
102 |
generateCommentedCode:aBoolean |
|
103 |
"comments in generated aspect methods; yes or no." |
|
104 |
||
105 |
GenerateCommentedCode := aBoolean |
|
106 |
! |
|
107 |
||
742 | 108 |
redefineAspectMethods |
2244 | 109 |
"redefine methods yes or no. |
110 |
If a method is defined in super class should the message be reinstalled ?" |
|
111 |
||
1225 | 112 |
^ RedefineAspectMethods |
698 | 113 |
|
1225 | 114 |
"Modified: / 22.9.1999 / 12:33:03 / stefan" |
698 | 115 |
! |
116 |
||
742 | 117 |
redefineAspectMethods:aBoolean |
2244 | 118 |
"redefine methods yes or no. |
119 |
If a method is defined in super class should the message be reinstalled ?" |
|
120 |
||
742 | 121 |
RedefineAspectMethods := aBoolean |
698 | 122 |
! ! |
123 |
||
60 | 124 |
!UIPainterView class methodsFor:'defaults'! |
125 |
||
1834 | 126 |
defaultMenuMessage |
60 | 127 |
"This message is the default yo be sent to the menuHolder to get a menu |
128 |
" |
|
121 | 129 |
^ #showMiddleButtonMenu |
60 | 130 |
|
131 |
||
132 |
! ! |
|
133 |
||
134 |
!UIPainterView methodsFor:'accessing'! |
|
135 |
||
136 |
application |
|
137 |
^ nil |
|
138 |
||
139 |
"Modified: 6.9.1995 / 00:46:44 / claus" |
|
140 |
! |
|
141 |
||
78 | 142 |
applicationName |
143 |
^ self className |
|
144 |
! |
|
145 |
||
146 |
applicationName:aName |
|
147 |
self className:aName |
|
148 |
! |
|
149 |
||
1977 | 150 |
class:aClass superclassName:aSuperclassName selector:aSelector |
151 |
self assert:(aClass isBehavior). |
|
152 |
className := aClass name. |
|
153 |
superclassName := aSuperclassName. |
|
154 |
methodName := aSelector. |
|
155 |
! |
|
156 |
||
60 | 157 |
className |
158 |
^ className |
|
159 |
! |
|
160 |
||
78 | 161 |
className:aName |
1977 | 162 |
self assert:(aName isString). |
78 | 163 |
className := aName |
60 | 164 |
! |
165 |
||
166 |
className:aClassName superclassName:aSuperclassName selector:aSelector |
|
1977 | 167 |
self assert:(aClassName isString). |
78 | 168 |
className := aClassName. |
60 | 169 |
superclassName := aSuperclassName. |
78 | 170 |
methodName := aSelector. |
60 | 171 |
! |
172 |
||
2276
485bda17023f
more changes to allow for non-class/selector (i.e. spec-only) use
Claus Gittinger <cg@exept.de>
parents:
2265
diff
changeset
|
173 |
listOfAspectsHolder:something |
485bda17023f
more changes to allow for non-class/selector (i.e. spec-only) use
Claus Gittinger <cg@exept.de>
parents:
2265
diff
changeset
|
174 |
listOfAspectsHolder := something. |
485bda17023f
more changes to allow for non-class/selector (i.e. spec-only) use
Claus Gittinger <cg@exept.de>
parents:
2265
diff
changeset
|
175 |
! |
485bda17023f
more changes to allow for non-class/selector (i.e. spec-only) use
Claus Gittinger <cg@exept.de>
parents:
2265
diff
changeset
|
176 |
|
60 | 177 |
methodName |
178 |
^ methodName |
|
179 |
! |
|
180 |
||
78 | 181 |
methodName:aName |
182 |
methodName := aName |
|
60 | 183 |
! |
184 |
||
185 |
selectNames:aStringOrCollection |
|
1031 | 186 |
|prop coll s n newSel| |
187 |
||
188 |
(aStringOrCollection size == 0) ifTrue:[ |
|
1834 | 189 |
newSel := nil. |
1031 | 190 |
] ifFalse:[ |
1834 | 191 |
(s := aStringOrCollection) isString ifFalse:[ |
192 |
s size == 1 ifTrue:[ |
|
193 |
s := s first |
|
194 |
] ifFalse:[ |
|
195 |
coll := OrderedCollection new. |
|
196 |
||
197 |
s do:[:aName| |
|
198 |
(prop := self propertyOfName:aName) notNil ifTrue:[ |
|
199 |
coll add:(prop view) |
|
200 |
] |
|
201 |
]. |
|
202 |
(n := coll size) == 1 ifTrue:[ |
|
203 |
newSel := coll at:1 |
|
204 |
] ifFalse:[ |
|
205 |
n == 0 ifTrue:[ |
|
206 |
newSel := nil |
|
207 |
] ifFalse:[ |
|
208 |
newSel := coll |
|
209 |
] |
|
210 |
]. |
|
211 |
^ self select:newSel. |
|
212 |
] |
|
213 |
]. |
|
214 |
||
215 |
prop := self propertyOfName:s. |
|
216 |
prop isNil ifTrue:[ |
|
217 |
newSel := nil |
|
218 |
] ifFalse:[ |
|
219 |
newSel := prop view |
|
220 |
]. |
|
60 | 221 |
]. |
222 |
||
1031 | 223 |
^ self select:newSel |
60 | 224 |
! ! |
225 |
||
111 | 226 |
!UIPainterView methodsFor:'change & update'! |
227 |
||
223 | 228 |
layoutChanged |
1445 | 229 |
treeView notNil ifTrue:[ |
1834 | 230 |
treeView layoutChanged |
1445 | 231 |
] |
111 | 232 |
! ! |
233 |
||
60 | 234 |
!UIPainterView methodsFor:'copy & cut & paste'! |
235 |
||
2221 | 236 |
changeSelectionAfterPasteOf:sel |
237 |
sel notNil ifTrue:[ |
|
238 |
self select:sel. |
|
239 |
]. |
|
240 |
! |
|
241 |
||
1744
c59a91953b64
paste with no container selected: search for a good one
Claus Gittinger <cg@exept.de>
parents:
1733
diff
changeset
|
242 |
commonContainerOf:someComponents |
c59a91953b64
paste with no container selected: search for a good one
Claus Gittinger <cg@exept.de>
parents:
1733
diff
changeset
|
243 |
|container| |
c59a91953b64
paste with no container selected: search for a good one
Claus Gittinger <cg@exept.de>
parents:
1733
diff
changeset
|
244 |
|
c59a91953b64
paste with no container selected: search for a good one
Claus Gittinger <cg@exept.de>
parents:
1733
diff
changeset
|
245 |
container := someComponents first container. |
c59a91953b64
paste with no container selected: search for a good one
Claus Gittinger <cg@exept.de>
parents:
1733
diff
changeset
|
246 |
[container notNil |
c59a91953b64
paste with no container selected: search for a good one
Claus Gittinger <cg@exept.de>
parents:
1733
diff
changeset
|
247 |
and:[ (someComponents conform:[:eachComponent | eachComponent isComponentOf:container]) not]] |
1834 | 248 |
whileTrue:[ |
249 |
container := container container. |
|
1744
c59a91953b64
paste with no container selected: search for a good one
Claus Gittinger <cg@exept.de>
parents:
1733
diff
changeset
|
250 |
]. |
c59a91953b64
paste with no container selected: search for a good one
Claus Gittinger <cg@exept.de>
parents:
1733
diff
changeset
|
251 |
^ container |
c59a91953b64
paste with no container selected: search for a good one
Claus Gittinger <cg@exept.de>
parents:
1733
diff
changeset
|
252 |
! |
c59a91953b64
paste with no container selected: search for a good one
Claus Gittinger <cg@exept.de>
parents:
1733
diff
changeset
|
253 |
|
60 | 254 |
copySelection |
1959 | 255 |
"copy the selection into the cut & paste-buffer" |
256 |
||
698 | 257 |
|specs coll sel| |
258 |
||
259 |
sel := treeView selection. |
|
71 | 260 |
|
2257
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
261 |
coll := self minClosedViewSetFor:(self selection). |
60 | 262 |
|
71 | 263 |
coll notNil ifTrue:[ |
776 | 264 |
"/ self select:nil. |
1870 | 265 |
specs := coll collect:[:aView| self fullSpecFor:aView ]. |
266 |
self setClipboardObject:specs. |
|
776 | 267 |
"/ treeView selection: sel |
60 | 268 |
]. |
269 |
! |
|
270 |
||
723 | 271 |
deleteSelection |
1959 | 272 |
"delete the selection buffered" |
273 |
||
887
79a6e12e1d0f
after deleting a widget do select the neighbour then the parent (step 2)
tz
parents:
886
diff
changeset
|
274 |
self deleteSelectionBuffered: true |
79a6e12e1d0f
after deleting a widget do select the neighbour then the parent (step 2)
tz
parents:
886
diff
changeset
|
275 |
! |
79a6e12e1d0f
after deleting a widget do select the neighbour then the parent (step 2)
tz
parents:
886
diff
changeset
|
276 |
|
79a6e12e1d0f
after deleting a widget do select the neighbour then the parent (step 2)
tz
parents:
886
diff
changeset
|
277 |
deleteSelectionBuffered: buffered |
2257
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
278 |
"cut the selection. If buffered is true, place it into the cut&paste-buffer" |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
279 |
|
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
280 |
|specs specsToRemove index oldSelection newSelection treeModel children size node| |
71 | 281 |
|
1621
112670159075
cg: check if selection change is allowed BEFORE changing the
tm
parents:
1574
diff
changeset
|
282 |
treeView askForSelectionChangeAllowed ifFalse:[^ self]. |
112670159075
cg: check if selection change is allowed BEFORE changing the
tm
parents:
1574
diff
changeset
|
283 |
|
2257
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
284 |
specsToRemove := self minClosedViewSetFor:(self selection). |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
285 |
specsToRemove notEmptyOrNil ifTrue:[ |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
286 |
treeView canvasEventsDisabledDo:[ |
1870 | 287 |
treeModel := treeView model. |
288 |
oldSelection := treeModel selectedNodes at:1 ifAbsent: nil. |
|
289 |
||
290 |
oldSelection notNil ifTrue:[ |
|
291 |
children := oldSelection parent children. |
|
292 |
(size := children size) > 1 ifTrue:[ |
|
293 |
index := children identityIndexOf:oldSelection. |
|
294 |
size == index ifTrue:[ |
|
295 |
index := index - 1 |
|
296 |
]. |
|
297 |
newSelection := children at:index ifAbsent:1. |
|
298 |
] ifFalse:[ |
|
299 |
newSelection := oldSelection parent |
|
300 |
]. |
|
301 |
newSelection := treeModel indexOf:newSelection. |
|
302 |
] ifFalse:[ |
|
303 |
newSelection := 1 |
|
304 |
]. |
|
305 |
||
306 |
self hideSelection. |
|
307 |
selection := nil. |
|
2257
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
308 |
specs := specsToRemove collect:[:aView| self fullSpecFor:aView ]. |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
309 |
|
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
310 |
self withinTransaction:#cut objects:specsToRemove do:[ |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
311 |
specsToRemove reverseDo:[:aView| |
1870 | 312 |
self createUndoRemove:aView. |
313 |
self remove:aView. |
|
314 |
] |
|
315 |
]. |
|
316 |
buffered ifTrue: [self setClipboardObject:specs]. |
|
317 |
treeView selection:nil. |
|
318 |
treeView selection:(Array with: newSelection). |
|
2257
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
319 |
(node := treeView selectedNode) notNil ifTrue:[ |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
320 |
self setSelection:node contents view withRedraw:true. |
1870 | 321 |
] |
322 |
] |
|
698 | 323 |
] |
324 |
! |
|
325 |
||
723 | 326 |
deleteTotalSelection |
1959 | 327 |
"delete the selection" |
328 |
||
887
79a6e12e1d0f
after deleting a widget do select the neighbour then the parent (step 2)
tz
parents:
886
diff
changeset
|
329 |
self deleteSelectionBuffered: false |
60 | 330 |
! |
331 |
||
1832 | 332 |
getSelectedViewsAndSpecs |
333 |
"return an array filed with selected views and corresponding specs. |
|
1959 | 334 |
Nil if there is none." |
335 |
||
1832 | 336 |
|specs coll sel| |
337 |
||
338 |
sel := treeView selection. |
|
339 |
||
2257
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
340 |
coll := self minClosedViewSetFor:(self selection). |
1832 | 341 |
|
342 |
coll isNil ifTrue:[^ nil]. |
|
343 |
||
344 |
specs := coll collect:[:aView| self fullSpecFor:aView ]. |
|
345 |
^ Array with: coll with: specs |
|
346 |
! |
|
347 |
||
60 | 348 |
pasteBuffer |
1959 | 349 |
"add the objects in the paste-buffer to the object view" |
350 |
||
223 | 351 |
|sel| |
352 |
||
1872 | 353 |
sel := self pasteSpecifications:(self getClipboardObject) keepLayout:false. |
2221 | 354 |
self changeSelectionAfterPasteOf:sel. |
89 | 355 |
! |
356 |
||
1338
3c1a528c50db
added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
357 |
pasteKeepingPosition |
1834 | 358 |
"add the objects in the paste-buffer to the object view; |
1338
3c1a528c50db
added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
359 |
translate the layout as appropriate, to position the component |
1959 | 360 |
at the same absolute position (relative to topView) as before" |
361 |
||
1338
3c1a528c50db
added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
362 |
|sel| |
3c1a528c50db
added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
363 |
|
3c1a528c50db
added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
364 |
sel := self |
1872 | 365 |
pasteSpecifications:(self getClipboardObject) |
366 |
keepLayout:true |
|
367 |
keepPosition:true |
|
368 |
at:nil. |
|
1338
3c1a528c50db
added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
369 |
|
2221 | 370 |
self changeSelectionAfterPasteOf:sel. |
1338
3c1a528c50db
added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
371 |
! |
3c1a528c50db
added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
372 |
|
89 | 373 |
pasteSpecifications:aSpecificationOrList keepLayout:keepLayout |
2257
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
374 |
"add the specs to the object view; returns list of pasted widgets" |
278 | 375 |
|
376 |
^ self |
|
1959 | 377 |
pasteSpecifications:aSpecificationOrList |
378 |
keepLayout:keepLayout |
|
379 |
at:nil |
|
278 | 380 |
|
381 |
"Modified: 11.8.1997 / 01:00:35 / cg" |
|
382 |
! |
|
383 |
||
384 |
pasteSpecifications:aSpecificationOrList keepLayout:keepLayout at:aPointOrNil |
|
2257
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
385 |
"add the specs to the object view; returns list of pasted widgets" |
1959 | 386 |
|
1834 | 387 |
^ self |
1959 | 388 |
pasteSpecifications:aSpecificationOrList |
389 |
keepLayout:keepLayout |
|
390 |
keepPosition:false |
|
391 |
at:aPointOrNil |
|
1338
3c1a528c50db
added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
392 |
! |
3c1a528c50db
added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
393 |
|
3c1a528c50db
added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
394 |
pasteSpecifications:aSpecificationOrList keepLayout:keepLayout keepPosition:keepPosition at:aPointOrNil |
2257
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
395 |
"add the specs to the object view; returns list of pasted widgets" |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
396 |
|
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
397 |
|specsToPaste pasteOrigin pasteOffset builder newSel bounds containerToPasteInto| |
1621
112670159075
cg: check if selection change is allowed BEFORE changing the
tm
parents:
1574
diff
changeset
|
398 |
|
112670159075
cg: check if selection change is allowed BEFORE changing the
tm
parents:
1574
diff
changeset
|
399 |
treeView askForSelectionChangeAllowed ifFalse:[^ nil]. |
112670159075
cg: check if selection change is allowed BEFORE changing the
tm
parents:
1574
diff
changeset
|
400 |
|
1744
c59a91953b64
paste with no container selected: search for a good one
Claus Gittinger <cg@exept.de>
parents:
1733
diff
changeset
|
401 |
containerToPasteInto := self singleSelection. |
c59a91953b64
paste with no container selected: search for a good one
Claus Gittinger <cg@exept.de>
parents:
1733
diff
changeset
|
402 |
containerToPasteInto isNil ifTrue:[ |
1878
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
403 |
self selection size > 0 ifTrue:[ |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
404 |
containerToPasteInto := self commonContainerOf:self selection |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
405 |
] ifFalse:[ |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
406 |
containerToPasteInto := self |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
407 |
]. |
2221 | 408 |
"/ self selection:containerToPasteInto. |
1744
c59a91953b64
paste with no container selected: search for a good one
Claus Gittinger <cg@exept.de>
parents:
1733
diff
changeset
|
409 |
]. |
c59a91953b64
paste with no container selected: search for a good one
Claus Gittinger <cg@exept.de>
parents:
1733
diff
changeset
|
410 |
|
c59a91953b64
paste with no container selected: search for a good one
Claus Gittinger <cg@exept.de>
parents:
1733
diff
changeset
|
411 |
(self canPasteInto:containerToPasteInto) ifFalse:[ |
1878
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
412 |
containerToPasteInto notNil ifTrue:[ |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
413 |
"/ search up parent list for something we can paste into |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
414 |
[containerToPasteInto notNil and:[(self canPasteInto:containerToPasteInto) not]] whileTrue:[ |
2212 | 415 |
containerToPasteInto == self ifTrue:[ |
416 |
containerToPasteInto := nil |
|
417 |
] ifFalse:[ |
|
418 |
containerToPasteInto := containerToPasteInto container. |
|
419 |
]. |
|
1878
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
420 |
]. |
2221 | 421 |
"/ self selection:containerToPasteInto. |
1878
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
422 |
]. |
1621
112670159075
cg: check if selection change is allowed BEFORE changing the
tm
parents:
1574
diff
changeset
|
423 |
]. |
1752 | 424 |
containerToPasteInto isNil ifTrue:[ |
1878
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
425 |
containerToPasteInto := self |
1752 | 426 |
]. |
60 | 427 |
|
2221 | 428 |
(self canPaste:aSpecificationOrList into:containerToPasteInto) |
429 |
"(self canPaste:aSpecificationOrList)" |
|
430 |
ifFalse:[ |
|
2276
485bda17023f
more changes to allow for non-class/selector (i.e. spec-only) use
Claus Gittinger <cg@exept.de>
parents:
2265
diff
changeset
|
431 |
self halt. |
485bda17023f
more changes to allow for non-class/selector (i.e. spec-only) use
Claus Gittinger <cg@exept.de>
parents:
2265
diff
changeset
|
432 |
(self canPaste:aSpecificationOrList into:containerToPasteInto). |
1878
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
433 |
Dialog warn:'Cannot paste into selected component (not a container ?)'. |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
434 |
^ nil |
89 | 435 |
]. |
223 | 436 |
|
776 | 437 |
aSpecificationOrList isCollection ifTrue:[ |
2257
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
438 |
specsToPaste := aSpecificationOrList |
776 | 439 |
] ifFalse:[ |
2257
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
440 |
specsToPaste := Array with:aSpecificationOrList |
776 | 441 |
]. |
2221 | 442 |
"/ self setClipboardObject:nil. |
776 | 443 |
|
444 |
newSel := OrderedCollection new. |
|
445 |
builder := UIBuilder new isEditing:true. |
|
446 |
||
447 |
className notNil ifTrue:[ |
|
1878
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
448 |
builder applicationClass:(self resolveName:className) |
776 | 449 |
]. |
450 |
||
1338
3c1a528c50db
added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
451 |
(keepLayout not or:[keepPosition]) ifTrue:[ |
1878
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
452 |
pasteOffset := 0@0. |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
453 |
|
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
454 |
keepPosition ifTrue:[ |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
455 |
pasteOrigin := device translatePoint:0@0 |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
456 |
fromView:self |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
457 |
toView:containerToPasteInto. |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
458 |
] ifFalse:[ |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
459 |
aPointOrNil isNil ifTrue:[ |
2257
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
460 |
pasteOrigin := device translatePoint:(self sensor mousePoint) |
1878
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
461 |
fromView:nil |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
462 |
toView:containerToPasteInto. |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
463 |
] ifFalse:[ |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
464 |
pasteOrigin := device translatePoint:aPointOrNil |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
465 |
fromView:self |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
466 |
toView:containerToPasteInto. |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
467 |
] |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
468 |
]. |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
469 |
|
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
470 |
bounds := Rectangle origin:0@0 extent:(containerToPasteInto bounds extent) |
776 | 471 |
]. |
60 | 472 |
|
2257
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
473 |
specsToPaste do:[:eachSpec| |
1878
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
474 |
|view newOrigin| |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
475 |
|
2257
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
476 |
view := self addSpec:eachSpec builder:builder in:containerToPasteInto. |
1878
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
477 |
|
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
478 |
keepPosition ifTrue:[ |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
479 |
self moveObject:view to:(view origin + pasteOrigin). |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
480 |
] ifFalse:[ |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
481 |
keepLayout ifFalse:[ |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
482 |
(bounds containsPoint:pasteOrigin) ifFalse:[ |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
483 |
newOrigin := pasteOffset. |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
484 |
] ifTrue:[ |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
485 |
newOrigin := pasteOrigin + pasteOffset. |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
486 |
]. |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
487 |
self moveObject:view to:newOrigin. |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
488 |
pasteOffset := pasteOffset + 4 |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
489 |
]. |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
490 |
]. |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
491 |
view realize. |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
492 |
newSel add:view. |
776 | 493 |
]. |
60 | 494 |
|
776 | 495 |
self withinTransaction:#paste objects:newSel do:[ |
1878
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
496 |
undoHistory addUndoSelector:#undoCreate: |
1954 | 497 |
withArgs:(newSel collect:[:v|(self propertyOfView:v) identifier]). |
498 |
self undoHistoryChanged. |
|
776 | 499 |
]. |
60 | 500 |
|
776 | 501 |
self realizeAllSubViews. |
502 |
newSel do:[:v| v raise]. |
|
1744
c59a91953b64
paste with no container selected: search for a good one
Claus Gittinger <cg@exept.de>
parents:
1733
diff
changeset
|
503 |
self elementChangedSize:containerToPasteInto. |
134 | 504 |
|
776 | 505 |
newSel size == 1 ifTrue:[newSel := newSel at:1]. |
223 | 506 |
^ newSel |
1500
36c0b4b268b8
use new translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1494
diff
changeset
|
507 |
|
36c0b4b268b8
use new translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1494
diff
changeset
|
508 |
"Modified: / 10.10.2001 / 14:15:12 / cg" |
89 | 509 |
! |
510 |
||
511 |
pasteWithLayout |
|
1959 | 512 |
"add the objects in the paste-buffer to the object view; |
513 |
don't change the layout" |
|
514 |
||
223 | 515 |
|sel| |
516 |
||
1872 | 517 |
sel := self pasteSpecifications:(self getClipboardObject) keepLayout:true. |
2221 | 518 |
self changeSelectionAfterPasteOf:sel. |
2257
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
519 |
! |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
520 |
|
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
521 |
replaceSelectionBy:aNewSpec |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
522 |
"replace the selected widget by another one." |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
523 |
|
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
524 |
|specs coll index oldSelection newSelection treeModel children size node |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
525 |
container widgets builder newView property| |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
526 |
|
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
527 |
treeView askForSelectionChangeAllowed ifFalse:[^ self]. |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
528 |
self assert:(self selection size == 1). |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
529 |
|
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
530 |
treeModel := treeView model. |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
531 |
oldSelection := treeModel selectedNodes at:1 ifAbsent: nil. |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
532 |
property := oldSelection contents. |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
533 |
property spec:aNewSpec. |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
534 |
self halt. |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
535 |
self rebuildView:(property view) fromSpec:aNewSpec withBuilder:nil forceNewView:true. |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
536 |
|
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
537 |
"/ p := self propertyOfView:aView) |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
538 |
"/ |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
539 |
"/ builder := UIBuilder new isEditing:true. |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
540 |
"/ newView := aNewSpec buildViewWithLayoutFor:builder in:(container contents view). |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
541 |
self halt. |
2265 | 542 |
"/ ^self. |
2257
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
543 |
self deleteSelectionBuffered:false. |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
544 |
widgets := self pasteSpecifications:(Array with:aNewSpec) keepLayout:false. |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
545 |
self select:widgets. |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
546 |
^ widgets. |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
547 |
|
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
548 |
treeView canvasEventsDisabledDo:[ |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
549 |
treeModel := treeView model. |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
550 |
oldSelection := treeModel selectedNodes at:1 ifAbsent: nil. |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
551 |
|
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
552 |
oldSelection notNil ifTrue:[ |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
553 |
children := oldSelection parent children. |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
554 |
(size := children size) > 1 ifTrue:[ |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
555 |
index := children identityIndexOf:oldSelection. |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
556 |
size == index ifTrue:[ |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
557 |
index := index - 1 |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
558 |
]. |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
559 |
newSelection := children at:index ifAbsent:1. |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
560 |
] ifFalse:[ |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
561 |
newSelection := oldSelection parent |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
562 |
]. |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
563 |
newSelection := treeModel indexOf:newSelection. |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
564 |
] ifFalse:[ |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
565 |
newSelection := 1 |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
566 |
]. |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
567 |
|
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
568 |
self hideSelection. |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
569 |
selection := nil. |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
570 |
specs := coll collect:[:aView| self fullSpecFor:aView ]. |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
571 |
|
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
572 |
self withinTransaction:#cut objects:coll do:[ |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
573 |
coll reverseDo:[:aView| |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
574 |
self createUndoRemove:aView. |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
575 |
self remove:aView. |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
576 |
] |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
577 |
]. |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
578 |
treeView selection:nil. |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
579 |
treeView selection:(Array with: newSelection). |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
580 |
(node := treeView selectedNode) notNil ifTrue:[ |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
581 |
self setSelection:node contents view withRedraw:true. |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
582 |
] |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
583 |
] |
60 | 584 |
! ! |
585 |
||
586 |
!UIPainterView methodsFor:'drag & drop'! |
|
587 |
||
2116 | 588 |
canDrop:aDropContext |
589 |
^ self canDropObjects:aDropContext dropObjects |
|
590 |
||
591 |
"Created: / 13-10-2006 / 17:46:11 / cg" |
|
592 |
! |
|
593 |
||
594 |
canDropObjects:aCollectionOfDropObjects |
|
1914 | 595 |
"returns true if something can be dropped" |
596 |
||
2112 | 597 |
^ (aCollectionOfDropObjects size == 1 |
598 |
and:[ self enabled |
|
599 |
and:[ self numberOfSelections <= 1 |
|
600 |
and:[ aCollectionOfDropObjects first theObject isKindOf:UISpecification ]]]) |
|
601 |
||
2116 | 602 |
"Created: / 13-10-2006 / 16:09:24 / cg" |
223 | 603 |
! |
604 |
||
285 | 605 |
canPaste |
1914 | 606 |
"returns true if there is something which can be pasted in the clipboard" |
607 |
||
1872 | 608 |
^ self canPaste:(self getClipboardObject) |
285 | 609 |
! |
610 |
||
223 | 611 |
canPaste:something |
1914 | 612 |
"returns true if something could be pasted" |
613 |
||
2221 | 614 |
^ self canPaste:something into:(self singleSelection) |
615 |
! |
|
616 |
||
617 |
canPaste:something into:containerToPasteInto |
|
618 |
"returns true if something could be pasted" |
|
619 |
||
2276
485bda17023f
more changes to allow for non-class/selector (i.e. spec-only) use
Claus Gittinger <cg@exept.de>
parents:
2265
diff
changeset
|
620 |
(self enabled) ifFalse:[ |
1914 | 621 |
^ false |
223 | 622 |
]. |
2276
485bda17023f
more changes to allow for non-class/selector (i.e. spec-only) use
Claus Gittinger <cg@exept.de>
parents:
2265
diff
changeset
|
623 |
something isCollection ifTrue:[ |
485bda17023f
more changes to allow for non-class/selector (i.e. spec-only) use
Claus Gittinger <cg@exept.de>
parents:
2265
diff
changeset
|
624 |
something isEmpty ifTrue:[ ^ false]. |
485bda17023f
more changes to allow for non-class/selector (i.e. spec-only) use
Claus Gittinger <cg@exept.de>
parents:
2265
diff
changeset
|
625 |
^ something conform:[:el | (self canPaste:el into:containerToPasteInto)] |
485bda17023f
more changes to allow for non-class/selector (i.e. spec-only) use
Claus Gittinger <cg@exept.de>
parents:
2265
diff
changeset
|
626 |
]. |
485bda17023f
more changes to allow for non-class/selector (i.e. spec-only) use
Claus Gittinger <cg@exept.de>
parents:
2265
diff
changeset
|
627 |
|
485bda17023f
more changes to allow for non-class/selector (i.e. spec-only) use
Claus Gittinger <cg@exept.de>
parents:
2265
diff
changeset
|
628 |
(something isKindOf:UISpecification) ifFalse:[ |
1914 | 629 |
^ false |
223 | 630 |
]. |
631 |
||
2276
485bda17023f
more changes to allow for non-class/selector (i.e. spec-only) use
Claus Gittinger <cg@exept.de>
parents:
2265
diff
changeset
|
632 |
^ self canPasteInto:containerToPasteInto |
223 | 633 |
! |
634 |
||
635 |
canPasteInto:aView |
|
1914 | 636 |
"return true, if I can paste into a view" |
637 |
||
285 | 638 |
|prop| |
60 | 639 |
|
1870 | 640 |
aView isNil ifTrue:[ ^ false ]. |
2265 | 641 |
aView == self ifTrue:[ ^ true ]. |
1870 | 642 |
|
643 |
(prop := self propertyOfView:aView) notNil ifTrue:[ |
|
644 |
^ prop spec class supportsSubComponents |
|
89 | 645 |
]. |
1870 | 646 |
^ aView specClass supportsSubComponents. |
60 | 647 |
! |
648 |
||
2116 | 649 |
dropObjects:aCollectionOfDropObjects at:aPoint |
1833 | 650 |
|spec newSel oldSel dragOffset widg doit| |
651 |
||
652 |
doit := true. |
|
288 | 653 |
self selection notNil ifTrue:[ |
1953 | 654 |
oldSel := self singleSelection. |
655 |
||
656 |
"/ search selections hierarchy for a widget into which we can paste |
|
657 |
widg := oldSel. |
|
658 |
[widg isNil or:[self canPasteInto:widg]] whileFalse:[ |
|
659 |
widg notNil ifTrue:[ |
|
660 |
widg := widg container |
|
661 |
]. |
|
662 |
]. |
|
663 |
||
664 |
oldSel := nil. |
|
665 |
self setSelection:widg withRedraw:true. |
|
231 | 666 |
]. |
1953 | 667 |
spec := (aCollectionOfDropObjects at:1) theObject. |
1833 | 668 |
doit ifTrue:[ |
1953 | 669 |
dragOffset := DragAndDropManager dragOffsetQuerySignal query. |
670 |
newSel := self pasteSpecifications:spec keepLayout:false at:aPoint - dragOffset. |
|
671 |
||
672 |
self select:(oldSel ? newSel) |
|
1833 | 673 |
]. |
1060
0332a41de5c5
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
1058
diff
changeset
|
674 |
|
2116 | 675 |
"Modified: / 18-03-1999 / 18:29:43 / stefan" |
676 |
"Created: / 13-10-2006 / 16:09:27 / cg" |
|
60 | 677 |
! ! |
678 |
||
2244 | 679 |
!UIPainterView methodsFor:'drawing'! |
680 |
||
681 |
clearRectangle:visRect |
|
682 |
super clearRectangle:visRect. |
|
683 |
sketchPainter notNil ifTrue:[ |
|
684 |
sketchPainter redrawInTargetView |
|
685 |
]. |
|
686 |
||
687 |
"Created: / 16-01-2008 / 17:52:27 / cg" |
|
688 |
! |
|
689 |
||
690 |
clearView |
|
691 |
super clearView. |
|
692 |
sketchPainter notNil ifTrue:[ |
|
693 |
sketchPainter redrawInTargetView |
|
694 |
]. |
|
695 |
||
696 |
"Created: / 16-01-2008 / 17:46:08 / cg" |
|
697 |
! |
|
698 |
||
2248 | 699 |
useSketchFile:aFilename |
700 |
|mime sketchPainterClass| |
|
701 |
||
702 |
mime := aFilename asFilename mimeTypeFromName. |
|
703 |
mime isNil ifTrue:[ |
|
704 |
mime := aFilename asFilename mimeTypeOfContents. |
|
705 |
]. |
|
706 |
||
707 |
mime notNil ifTrue:[ |
|
708 |
mime = 'application/x-waltop-digital-notepad' ifTrue:[ |
|
709 |
sketchPainterClass := TOPFileDrawer. |
|
710 |
]. |
|
2278
8ff3bd6f0820
Allow to load background from image file #useSketchFile:
Stefan Vogel <sv@exept.de>
parents:
2276
diff
changeset
|
711 |
(mime startsWith:'image') ifTrue:[ |
8ff3bd6f0820
Allow to load background from image file #useSketchFile:
Stefan Vogel <sv@exept.de>
parents:
2276
diff
changeset
|
712 |
self viewBackground:(ImageReader fromFile:aFilename). |
8ff3bd6f0820
Allow to load background from image file #useSketchFile:
Stefan Vogel <sv@exept.de>
parents:
2276
diff
changeset
|
713 |
^ self. |
8ff3bd6f0820
Allow to load background from image file #useSketchFile:
Stefan Vogel <sv@exept.de>
parents:
2276
diff
changeset
|
714 |
]. |
2248 | 715 |
]. |
716 |
sketchPainterClass isNil ifTrue:[ |
|
717 |
self error:'unsupported sketch file format' |
|
718 |
]. |
|
719 |
||
720 |
sketchPainter := sketchPainterClass new. |
|
2244 | 721 |
sketchPainter targetView:self. |
722 |
sketchPainter readFile:aFilename. |
|
723 |
sketchPainter ajustSketch. |
|
724 |
self invalidate. |
|
725 |
||
726 |
"Created: / 16-01-2008 / 17:46:26 / cg" |
|
727 |
! ! |
|
728 |
||
361 | 729 |
!UIPainterView methodsFor:'event handling'! |
730 |
||
731 |
keyPress:key x:x y:y view:aView |
|
376 | 732 |
"a delegated keyEvent from aView" |
733 |
||
361 | 734 |
self keyPress:key x:x y:y |
735 |
||
376 | 736 |
"Modified: / 31.10.1997 / 20:27:22 / cg" |
361 | 737 |
! |
738 |
||
739 |
keyRelease:key x:x y:y view:aView |
|
376 | 740 |
"a delegated keyEvent from aView" |
741 |
||
361 | 742 |
self keyRelease:key x:x y:y |
743 |
||
376 | 744 |
"Modified: / 31.10.1997 / 20:27:32 / cg" |
754 | 745 |
! |
746 |
||
747 |
sizeChanged:how |
|
748 |
||
1834 | 749 |
super sizeChanged:how. |
754 | 750 |
|
751 |
self layoutChanged |
|
361 | 752 |
! ! |
753 |
||
78 | 754 |
!UIPainterView methodsFor:'generating output'! |
755 |
||
352 | 756 |
aspectMethods |
757 |
"extract a list of aspect methods - for browsing" |
|
758 |
||
1683
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
759 |
|cls methods| |
352 | 760 |
|
761 |
className isNil ifTrue:[ |
|
1834 | 762 |
self warn:'No class defined !!'. |
763 |
^ #() |
|
352 | 764 |
]. |
765 |
||
766 |
cls := self resolveName:className. |
|
767 |
methods := IdentitySet new. |
|
768 |
||
1683
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
769 |
self aspectSelectorsAndTypesDo: |
1834 | 770 |
[:selector :typeSymbol | |
771 |
|skip| |
|
772 |
||
773 |
(cls includesSelector:selector) ifTrue:[ |
|
774 |
||
775 |
skip := false. |
|
776 |
(typeSymbol == #modelAspect) ifTrue:[ |
|
777 |
(cls isSubclassOf:SimpleDialog) ifTrue:[ |
|
778 |
skip := SimpleDialog includesSelector:(selector asSymbol) |
|
779 |
]. |
|
780 |
]. |
|
781 |
skip ifFalse:[ |
|
782 |
methods add:(cls compiledMethodAt:selector) |
|
783 |
]. |
|
784 |
] |
|
785 |
]. |
|
1683
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
786 |
|
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
787 |
^ methods |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
788 |
|
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
789 |
"Created: / 25.10.1997 / 18:58:25 / cg" |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
790 |
"Modified: / 26.10.1997 / 15:06:18 / cg" |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
791 |
! |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
792 |
|
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
793 |
aspectSelectorsAndTypesDo:aTwoArgBlock |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
794 |
"evaluate aBlock for every aspect methods selector; 2nd arg describes the aspects type" |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
795 |
|
1726 | 796 |
|cls selector protoSpec| |
1683
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
797 |
|
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
798 |
className isNil ifTrue:[ |
2195
bb6de5f8fd03
Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents:
2191
diff
changeset
|
799 |
self warn:'No class defined !!'. |
bb6de5f8fd03
Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents:
2191
diff
changeset
|
800 |
^ self |
1683
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
801 |
]. |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
802 |
|
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
803 |
cls := self resolveName:className. |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
804 |
|
352 | 805 |
treeView propertiesDo:[:aProp| |
2195
bb6de5f8fd03
Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents:
2191
diff
changeset
|
806 |
|selector| |
bb6de5f8fd03
Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents:
2191
diff
changeset
|
807 |
|
bb6de5f8fd03
Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents:
2191
diff
changeset
|
808 |
(selector := aProp model) notNil ifTrue:[ |
bb6de5f8fd03
Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents:
2191
diff
changeset
|
809 |
selector isArray ifFalse:[ |
bb6de5f8fd03
Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents:
2191
diff
changeset
|
810 |
aTwoArgBlock value:(selector asSymbol) value:#modelAspect |
bb6de5f8fd03
Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents:
2191
diff
changeset
|
811 |
]. |
bb6de5f8fd03
Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents:
2191
diff
changeset
|
812 |
]. |
bb6de5f8fd03
Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents:
2191
diff
changeset
|
813 |
|
bb6de5f8fd03
Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents:
2191
diff
changeset
|
814 |
(selector := aProp menu) notNil ifTrue:[ |
bb6de5f8fd03
Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents:
2191
diff
changeset
|
815 |
selector isArray ifFalse:[ |
bb6de5f8fd03
Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents:
2191
diff
changeset
|
816 |
aTwoArgBlock value:(selector asSymbol) value:#menu |
bb6de5f8fd03
Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents:
2191
diff
changeset
|
817 |
]. |
bb6de5f8fd03
Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents:
2191
diff
changeset
|
818 |
]. |
bb6de5f8fd03
Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents:
2191
diff
changeset
|
819 |
|
bb6de5f8fd03
Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents:
2191
diff
changeset
|
820 |
(aProp spec aspectSelectors) do:[:aSel | |
2250
e65b8bf6224b
care for non-symbolic aspects (false)
Claus Gittinger <cg@exept.de>
parents:
2248
diff
changeset
|
821 |
(aSel isString or:[aSel isSymbol]) ifTrue:[ |
2195
bb6de5f8fd03
Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents:
2191
diff
changeset
|
822 |
aTwoArgBlock value:(aSel asSymbol) value:#channelAspect |
bb6de5f8fd03
Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents:
2191
diff
changeset
|
823 |
]. |
bb6de5f8fd03
Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents:
2191
diff
changeset
|
824 |
]. |
bb6de5f8fd03
Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents:
2191
diff
changeset
|
825 |
aProp spec actionSelectors do:[:aSel| |
2250
e65b8bf6224b
care for non-symbolic aspects (false)
Claus Gittinger <cg@exept.de>
parents:
2248
diff
changeset
|
826 |
(aSel isString or:[aSel isSymbol]) ifTrue:[ |
2195
bb6de5f8fd03
Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents:
2191
diff
changeset
|
827 |
aTwoArgBlock value:(aSel asSymbol) value:#actionSelector |
bb6de5f8fd03
Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents:
2191
diff
changeset
|
828 |
]. |
bb6de5f8fd03
Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents:
2191
diff
changeset
|
829 |
]. |
bb6de5f8fd03
Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents:
2191
diff
changeset
|
830 |
aProp spec valueSelectors do:[:aSel| |
2250
e65b8bf6224b
care for non-symbolic aspects (false)
Claus Gittinger <cg@exept.de>
parents:
2248
diff
changeset
|
831 |
(aSel isString or:[aSel isSymbol]) ifTrue:[ |
2195
bb6de5f8fd03
Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents:
2191
diff
changeset
|
832 |
aTwoArgBlock value:(aSel asSymbol) value:#valueSelector |
bb6de5f8fd03
Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents:
2191
diff
changeset
|
833 |
]. |
bb6de5f8fd03
Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents:
2191
diff
changeset
|
834 |
] |
352 | 835 |
]. |
836 |
||
837 |
protoSpec := treeView canvasSpec. |
|
838 |
||
839 |
(selector := protoSpec menu) notNil ifTrue:[ |
|
2195
bb6de5f8fd03
Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents:
2191
diff
changeset
|
840 |
selector isArray ifFalse:[ |
bb6de5f8fd03
Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents:
2191
diff
changeset
|
841 |
aTwoArgBlock value:(selector asSymbol) value:#menu |
bb6de5f8fd03
Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents:
2191
diff
changeset
|
842 |
]. |
352 | 843 |
]. |
844 |
! |
|
845 |
||
60 | 846 |
generateActionMethodFor:aspect spec:protoSpec inClass:targetClass |
2244 | 847 |
|selector args showIt codeStream alreadyInSuperclass numArgs method| |
288 | 848 |
|
849 |
selector := aspect asSymbol. |
|
141 | 850 |
|
288 | 851 |
alreadyInSuperclass := targetClass superclass canUnderstand:selector. |
852 |
||
568 | 853 |
numArgs := selector numArgs. |
854 |
method := aspect. |
|
855 |
||
856 |
numArgs == 1 ifTrue:[ |
|
2244 | 857 |
args := 'anArgument'. |
2295 | 858 |
showIt := ''' , anArgument printString , ''...''.'. |
1834 | 859 |
] ifFalse:[ |
2244 | 860 |
args := ''. |
861 |
showIt := ' ...''.'. |
|
862 |
||
863 |
numArgs ~~ 0 ifTrue:[ |
|
864 |
method := ''. |
|
865 |
||
866 |
selector keywords keysAndValuesDo:[:i :key| |
|
867 |
method := method, key, 'arg', i printString, ' ' |
|
868 |
] |
|
869 |
] |
|
149 | 870 |
]. |
2244 | 871 |
codeStream := WriteStream on:(String new:100). |
872 |
codeStream |
|
873 |
nextPutLine:('!!',targetClass name,' methodsFor:''actions''!!'); |
|
874 |
nextPutLine:(method,args); |
|
875 |
nextPutLine:' <resource: #uiCallback>'; |
|
876 |
cr. |
|
877 |
||
878 |
self class generateCommentedCode ifTrue:[ |
|
879 |
codeStream |
|
2295 | 880 |
nextPutAll:' "automatically generated by UIPainter..." |
2244 | 881 |
|
882 |
"*** the code below performs no action" |
|
883 |
"*** (except for some feedback on the Transcript)" |
|
884 |
"*** Please change as required and accept in the browser." |
|
885 |
"*** (and replace this comment by something more useful ;-)" |
|
886 |
||
887 |
'. |
|
888 |
||
889 |
alreadyInSuperclass ifTrue:[ |
|
890 |
codeStream |
|
891 |
nextPutLine:' "action for ' , aspect , ' is already provided in a superclass."'; |
|
892 |
nextPutLine:' "It may be redefined here..."'; |
|
893 |
cr. |
|
894 |
] ifFalse:[ |
|
895 |
codeStream |
|
896 |
nextPutLine:' "action to be defined here..."'; |
|
897 |
cr. |
|
898 |
]. |
|
899 |
]. |
|
900 |
||
901 |
codeStream |
|
902 |
nextPutAll:' Transcript showCR:self class name, '': '. |
|
288 | 903 |
|
904 |
alreadyInSuperclass ifTrue:[ |
|
2244 | 905 |
codeStream |
906 |
nextPutAll:'inherited '. |
|
288 | 907 |
]. |
2244 | 908 |
codeStream |
909 |
nextPutAll:'action for '; |
|
910 |
nextPutAll:aspect; |
|
911 |
nextPutLine:showIt. |
|
288 | 912 |
|
913 |
alreadyInSuperclass ifTrue:[ |
|
2244 | 914 |
codeStream |
915 |
nextPutAll:' super '; |
|
916 |
nextPutAll:aspect; |
|
917 |
nextPutAll:args; |
|
918 |
nextPutLine:'.'. |
|
288 | 919 |
]. |
920 |
||
2244 | 921 |
codeStream |
922 |
nextPutLine:'!! !!'; cr. |
|
923 |
||
924 |
^ codeStream contents. |
|
925 |
||
926 |
"Modified: / 12-01-2008 / 10:21:52 / cg" |
|
60 | 927 |
! |
928 |
||
1683
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
929 |
generateAspectMethodCode |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
930 |
"generate aspect, action & menu methods |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
931 |
- but do not overwrite existing ones. |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
932 |
Return a string ready to compile into the application class." |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
933 |
|
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
934 |
^ self generateAspectMethodCodeFiltering:nil |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
935 |
! |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
936 |
|
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
937 |
generateAspectMethodCodeFiltering:aFilterOrEmpty |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
938 |
"generate aspect, action & menu methods |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
939 |
- but do not overwrite existing ones. |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
940 |
Return a string ready to compile into the application class." |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
941 |
|
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
942 |
|cls codePieces skip protoSpec thisCode |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
943 |
definedMethodSelectors iVars t exportSels| |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
944 |
|
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
945 |
cls := self targetClass. |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
946 |
cls isNil ifTrue:[ |
2024 | 947 |
^ nil |
1683
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
948 |
]. |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
949 |
|
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
950 |
codePieces := OrderedCollection new. |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
951 |
definedMethodSelectors := IdentitySet new. |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
952 |
|
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
953 |
treeView propertiesDo:[:aProp| |
2024 | 954 |
|modelSelector| |
955 |
||
956 |
protoSpec := aProp spec. |
|
957 |
||
958 |
(modelSelector := aProp model) notNil ifTrue:[ |
|
959 |
self generateCodeFrom:(Array with:modelSelector) in:cls |
|
960 |
do:[:aSel| |
|
961 |
(aFilterOrEmpty isNil or:[aFilterOrEmpty includes:aSel]) ifTrue:[ |
|
962 |
skip := false. |
|
963 |
||
964 |
(cls isSubclassOf:SimpleDialog) ifTrue:[ |
|
965 |
skip := SimpleDialog includesSelector:aSel |
|
966 |
]. |
|
967 |
(definedMethodSelectors includes:aSel) ifTrue:[ |
|
968 |
skip := true. |
|
969 |
]. |
|
970 |
||
971 |
skip ifFalse:[ |
|
972 |
"/ kludge .. |
|
973 |
"/ (protoSpec isKindOf:ActionButtonSpec) |
|
974 |
(protoSpec defaultModelIsCallBackMethodSelector:aSel) |
|
975 |
ifTrue:[ |
|
976 |
thisCode := (self generateActionMethodFor:aSel spec:protoSpec inClass:cls). |
|
977 |
] ifFalse:[ |
|
978 |
thisCode := (self generateAspectMethodFor:aSel spec:protoSpec inClass:cls). |
|
979 |
]. |
|
980 |
codePieces add:thisCode. |
|
981 |
definedMethodSelectors add:aSel. |
|
982 |
Transcript showCR:'code generated for aspect: ' , aSel |
|
983 |
] ifTrue:[ |
|
984 |
Transcript showCR:'*** no code generated for aspect: ' , aSel , ' (method already exists)' |
|
985 |
]. |
|
986 |
]. |
|
987 |
]. |
|
988 |
]. |
|
989 |
||
990 |
"/ for each aspect, generate getter (if not yet implemented) |
|
991 |
self generateCodeFrom:(aProp spec aspectSelectors) in:cls |
|
992 |
do:[:aSel| |
|
993 |
(aFilterOrEmpty isNil or:[aFilterOrEmpty includes:aSel]) ifTrue:[ |
|
994 |
(definedMethodSelectors includes:aSel) ifFalse:[ |
|
995 |
thisCode := (self generateAspectMethodFor:aSel spec:protoSpec inClass:cls). |
|
996 |
codePieces add:thisCode. |
|
997 |
definedMethodSelectors add:aSel. |
|
998 |
Transcript showCR:'code generated for aspect: ' , aSel |
|
999 |
] |
|
1000 |
] |
|
1001 |
]. |
|
1002 |
||
1003 |
"/ exported aspects - need setter methods |
|
1004 |
exportSels := (treeView exportedAspects ? #()) collect:[:entry | (entry subAspect , ':') asSymbol]. |
|
1005 |
self generateCodeFrom:exportSels in:cls |
|
1006 |
do:[:aSel| |
|
1007 |
|aspect| |
|
1008 |
||
1009 |
(aFilterOrEmpty isNil or:[aFilterOrEmpty includes:aSel]) ifTrue:[ |
|
1010 |
(definedMethodSelectors includes:aSel) ifFalse:[ |
|
1011 |
aspect := (aSel copyWithoutLast:1) asSymbol. |
|
1012 |
thisCode := (self generateAspectSetMethodFor:aspect spec:protoSpec inClass:cls). |
|
1013 |
codePieces add:thisCode. |
|
1014 |
definedMethodSelectors add:aSel. |
|
1015 |
Transcript showCR:'export code generated for aspect: ' , aSel |
|
1016 |
] |
|
1017 |
] |
|
1018 |
]. |
|
1019 |
||
1020 |
self generateCodeFrom:(aProp spec actionSelectors) in:cls |
|
1021 |
do:[:aSel| |
|
1022 |
(aFilterOrEmpty isNil or:[aFilterOrEmpty includes:aSel]) ifTrue:[ |
|
1023 |
(definedMethodSelectors includes:aSel) ifFalse:[ |
|
1024 |
thisCode := (self generateActionMethodFor:aSel spec:protoSpec inClass:cls). |
|
1025 |
codePieces add:thisCode. |
|
1026 |
definedMethodSelectors add:aSel. |
|
1027 |
Transcript showCR:'action generated for aspect: ' , aSel |
|
1028 |
] |
|
1029 |
] |
|
1030 |
]. |
|
1031 |
||
1032 |
self generateCodeFrom:(aProp spec valueSelectors) in:cls |
|
1033 |
do:[:aSel| |
|
1034 |
(aFilterOrEmpty isNil or:[aFilterOrEmpty includes:aSel]) ifTrue:[ |
|
1035 |
(definedMethodSelectors includes:aSel) ifFalse:[ |
|
1036 |
"/ uppercase: - assume its a globals name. |
|
1037 |
aSel isUppercaseFirst ifFalse:[ |
|
1038 |
thisCode := (self generateValueMethodFor:aSel spec:protoSpec inClass:cls). |
|
1039 |
codePieces add:thisCode. |
|
1040 |
definedMethodSelectors add:aSel. |
|
1041 |
Transcript showCR:'code generated for aspect: ' , aSel |
|
1042 |
] |
|
1043 |
] |
|
1044 |
] |
|
1045 |
]. |
|
1683
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1046 |
]. |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1047 |
|
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1048 |
AspectsAsInstances ifTrue:[ |
2024 | 1049 |
iVars := cls instVarNames asOrderedCollection. |
1050 |
definedMethodSelectors do:[:ivar | |
|
1051 |
(iVars includes:ivar) ifFalse:[ |
|
1052 |
iVars add:ivar |
|
1053 |
] |
|
1054 |
]. |
|
1055 |
iVars := iVars asArray. |
|
1056 |
t := cls shallowCopy. |
|
1057 |
t setInstanceVariableString:iVars asStringCollection asString. |
|
1058 |
codePieces addFirst:(t definition , '!!\' withCRs). |
|
1683
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1059 |
]. |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1060 |
|
1834 | 1061 |
^ String |
2024 | 1062 |
streamContents: |
1063 |
[:codeStream | |
|
1064 |
codePieces do:[:eachPiece | codeStream nextPutAll:eachPiece]. |
|
1065 |
]. |
|
1683
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1066 |
|
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1067 |
"Modified: / 29.7.1998 / 12:21:19 / cg" |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1068 |
! |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1069 |
|
60 | 1070 |
generateAspectMethodFor:aspect spec:protoSpec inClass:targetClass |
2244 | 1071 |
|modelClass modelValueString modelValue modelGen codeStream| |
134 | 1072 |
|
149 | 1073 |
modelClass := protoSpec defaultModelClassFor:aspect. |
1257
acb8c0a58ef3
dataSPec defaultValue when generating aspects
Claus Gittinger <cg@exept.de>
parents:
1252
diff
changeset
|
1074 |
modelValueString := protoSpec defaultModelValueStringFor:aspect. |
acb8c0a58ef3
dataSPec defaultValue when generating aspects
Claus Gittinger <cg@exept.de>
parents:
1252
diff
changeset
|
1075 |
modelValueString notNil ifTrue:[ |
2244 | 1076 |
modelGen := modelValueString |
1257
acb8c0a58ef3
dataSPec defaultValue when generating aspects
Claus Gittinger <cg@exept.de>
parents:
1252
diff
changeset
|
1077 |
] ifFalse:[ |
2244 | 1078 |
modelValue := protoSpec defaultModelValueFor:aspect. |
1079 |
modelValue isNil ifTrue:[ |
|
1080 |
modelGen := modelClass name , ' new' |
|
1081 |
] ifFalse:[ |
|
1082 |
modelGen := modelValue storeString , ' asValue' |
|
1083 |
]. |
|
352 | 1084 |
|
1085 |
]. |
|
134 | 1086 |
|
2244 | 1087 |
codeStream := WriteStream on:(String new:100). |
1088 |
codeStream |
|
1089 |
nextPutLine:('!!' , targetClass name , ' methodsFor:''aspects''!!'); |
|
1090 |
nextPutLine:aspect; |
|
1091 |
nextPutLine:' <resource: #uiAspect>'; |
|
1092 |
cr. |
|
1093 |
||
1094 |
self class generateCommentedCode ifTrue:[ |
|
1095 |
codeStream |
|
1096 |
nextPutAll:' "automatically generated by UIPainter ..." |
|
1097 |
||
1098 |
"*** the code below creates a default model when invoked." |
|
1099 |
"*** (which may not be the one you wanted)" |
|
1100 |
"*** Please change as required and accept it in the browser." |
|
1101 |
"*** (and replace this comment by something more useful ;-)" |
|
1102 |
||
1103 |
'. |
|
1104 |
]. |
|
1474 | 1105 |
|
925
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
1106 |
AspectsAsInstances ifTrue:[ |
2244 | 1107 |
codeStream |
1108 |
nextPutLine:(' ',aspect,' isNil ifTrue:['); |
|
1109 |
nextPutLine:(' ',aspect,' := ',modelGen,'.'). |
|
1110 |
||
1111 |
modelClass ~~ TriggerValue ifTrue:[ |
|
1112 |
self class generateCommentedCode ifTrue:[ |
|
1113 |
codeStream |
|
1114 |
nextPutLine:'"/ if your app needs to be notified of changes, uncomment one of the lines below:'. |
|
1115 |
]. |
|
1116 |
codeStream |
|
1117 |
nextPutLine:'"/ ',aspect,' addDependent:self.'; |
|
1118 |
nextPutLine:'"/ ',aspect,' onChangeSend:#',aspect,'Changed to:self.'. |
|
1119 |
]. |
|
1120 |
codeStream |
|
1121 |
nextPutLine:' ].'; |
|
1122 |
nextPutLine:' ^ ',aspect,'.'. |
|
925
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
1123 |
] ifFalse:[ |
2244 | 1124 |
codeStream |
1125 |
nextPutLine:(' |holder|'); |
|
1126 |
cr; |
|
1127 |
nextPutLine:(' (holder := builder bindingAt:#',aspect,') isNil ifTrue:['); |
|
1128 |
nextPutLine:(' holder := ',modelGen,'.'); |
|
1129 |
nextPutLine:(' builder aspectAt:#',aspect,' put:holder.'). |
|
1130 |
||
1131 |
modelClass ~~ TriggerValue ifTrue:[ |
|
1132 |
self class generateCommentedCode ifTrue:[ |
|
1133 |
codeStream |
|
1134 |
nextPutLine:'"/ if your app needs to be notified of changes, uncomment one of the lines below:'. |
|
1135 |
]. |
|
1136 |
codeStream |
|
1137 |
nextPutLine:'"/ holder addDependent:self.'; |
|
1138 |
nextPutLine:'"/ holder onChangeSend:#',aspect,'Changed to:self.'. |
|
1139 |
]. |
|
1140 |
codeStream |
|
1141 |
nextPutLine:' ].'; |
|
1142 |
nextPutLine:' ^ holder.'. |
|
925
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
1143 |
]. |
1361
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
1144 |
|
2244 | 1145 |
codeStream |
1146 |
nextPutLine:'!! !!'; cr. |
|
1147 |
"/ self halt. |
|
1148 |
^ codeStream contents. |
|
1149 |
||
1150 |
"Modified: / 22-09-1999 / 12:33:47 / stefan" |
|
1151 |
"Modified: / 12-01-2008 / 10:21:43 / cg" |
|
60 | 1152 |
! |
1153 |
||
1358 | 1154 |
generateAspectSelectorsMethod |
1155 |
"generate aspectSelectors method. |
|
1156 |
Return a string ready to compile into the application class." |
|
1157 |
||
1158 |
|cls code spec| |
|
1159 |
||
1683
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1160 |
cls := self targetClass. |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1161 |
cls isNil ifTrue:[ |
1834 | 1162 |
^ nil |
1358 | 1163 |
]. |
1164 |
||
1165 |
spec := treeView exportedAspects. |
|
1166 |
spec size == 0 ifTrue:[^ nil]. |
|
1167 |
||
1168 |
"/ make it an array ... |
|
1362
b710bba663cb
fixed generateAspectSelectors code generator
Claus Gittinger <cg@exept.de>
parents:
1361
diff
changeset
|
1169 |
spec := spec collect:[:entry | |subAspect type| |
1834 | 1170 |
subAspect := entry subAspect asSymbol. |
1171 |
(type := entry type) isNil ifTrue:[ |
|
1172 |
subAspect |
|
1173 |
] ifFalse:[ |
|
1174 |
Array with:subAspect with:type asSymbol |
|
1175 |
]. |
|
1176 |
]. |
|
1358 | 1177 |
spec := spec asArray. |
1178 |
||
1179 |
code := '!!' , cls name , ' class methodsFor:''plugIn spec''!!\\' . |
|
1180 |
||
1181 |
code := code , 'aspectSelectors |
|
1182 |
"This resource specification was automatically generated |
|
1183 |
by the UIPainter of ST/X." |
|
1184 |
||
1185 |
"Do not manually edit this. If it is corrupted, |
|
1186 |
the UIPainter may not be able to read the specification." |
|
1187 |
||
1188 |
"Return a description of exported aspects; |
|
1189 |
these can be connected to aspects of an embedding application |
|
1190 |
(if this app is embedded in a subCanvas)." |
|
1191 |
||
1362
b710bba663cb
fixed generateAspectSelectors code generator
Claus Gittinger <cg@exept.de>
parents:
1361
diff
changeset
|
1192 |
^ #(\'. |
b710bba663cb
fixed generateAspectSelectors code generator
Claus Gittinger <cg@exept.de>
parents:
1361
diff
changeset
|
1193 |
spec do:[:el | code := code , (' ' , el storeString , '\') ]. |
b710bba663cb
fixed generateAspectSelectors code generator
Claus Gittinger <cg@exept.de>
parents:
1361
diff
changeset
|
1194 |
code := code , ' ).\'. |
b710bba663cb
fixed generateAspectSelectors code generator
Claus Gittinger <cg@exept.de>
parents:
1361
diff
changeset
|
1195 |
code := code , '\!!\'. |
1358 | 1196 |
code := code withCRs. |
1197 |
^ code |
|
1198 |
||
1362
b710bba663cb
fixed generateAspectSelectors code generator
Claus Gittinger <cg@exept.de>
parents:
1361
diff
changeset
|
1199 |
"Modified: / 18.2.2000 / 02:08:34 / cg" |
1358 | 1200 |
! |
1201 |
||
1361
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
1202 |
generateAspectSetMethodFor:aspect spec:protoSpec inClass:targetClass |
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
1203 |
|code| |
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
1204 |
|
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
1205 |
code := '!!' , targetClass name , ' methodsFor:''aspects - exported''!!\\' , |
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
1206 |
aspect , ':something\' , |
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
1207 |
' "automatically generated by UIPainter ..."\\' , |
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
1208 |
' "This method is used when I am embedded as subApplication,"\' , |
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
1209 |
' "and the mainApp wants to connect its aspects to mine."\'. |
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
1210 |
|
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
1211 |
AspectsAsInstances ifTrue:[ |
1834 | 1212 |
code := (code , '\' , |
1213 |
'"/ ' , aspect , ' notNil ifTrue:[\' , |
|
1214 |
'"/ ' , aspect , ' removeDependent:self.\' , |
|
1215 |
'"/ ].\' , |
|
1216 |
' ' , aspect ,' := something.\' , |
|
1217 |
'"/ ' , aspect ,' notNil ifTrue:[\' , |
|
1218 |
'"/ ' , aspect , ' addDependent:self.\' , |
|
1219 |
'"/ ].\' , |
|
1220 |
' ^ self.\' , |
|
1221 |
'!! !!\\') |
|
1361
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
1222 |
] ifFalse:[ |
1834 | 1223 |
code := (code , '\' , |
1224 |
'"/ |holder|\' , |
|
1225 |
'\' , |
|
1226 |
'"/ (holder := builder bindingAt:#' , aspect , ') notNil ifTrue:[\' , |
|
1227 |
'"/ holder removeDependent:self.\' , |
|
1228 |
'"/ ].\' , |
|
1229 |
' builder aspectAt:#' , aspect , ' put:something.\', |
|
1230 |
'"/ something notNil ifTrue:[\' , |
|
1231 |
'"/ something addDependent:self.\' , |
|
1232 |
'"/ ].\' , |
|
1233 |
' ^ self.\' , |
|
1234 |
'!! !!\\') |
|
1361
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
1235 |
]. |
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
1236 |
|
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
1237 |
^ code withCRs |
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
1238 |
|
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
1239 |
"Modified: / 29.7.1998 / 11:29:16 / cg" |
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
1240 |
"Modified: / 22.9.1999 / 12:33:47 / stefan" |
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
1241 |
! |
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
1242 |
|
698 | 1243 |
generateCodeFrom:aListOfSelectors in:aClass do:aBlock |
1696 | 1244 |
|realSelectors redefCondition redefMessage| |
1245 |
||
2250
e65b8bf6224b
care for non-symbolic aspects (false)
Claus Gittinger <cg@exept.de>
parents:
2248
diff
changeset
|
1246 |
realSelectors := aListOfSelectors select:[:sel | sel isString or:[sel isSymbol]]. |
698 | 1247 |
|
744 | 1248 |
self class redefineAspectMethods ifTrue:[ |
2195
bb6de5f8fd03
Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents:
2191
diff
changeset
|
1249 |
redefCondition := [:cls :sel | (cls includesSelector:sel) not]. |
bb6de5f8fd03
Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents:
2191
diff
changeset
|
1250 |
redefMessage := ' skipped - already implemented in the class'. |
698 | 1251 |
] ifFalse:[ |
2195
bb6de5f8fd03
Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents:
2191
diff
changeset
|
1252 |
redefCondition := [:cls :sel | (cls canUnderstand:sel) not]. |
bb6de5f8fd03
Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents:
2191
diff
changeset
|
1253 |
redefMessage := ' skipped - already implemented in the class (or superclass)'. |
1696 | 1254 |
]. |
1255 |
||
1256 |
realSelectors do:[:aSelector| |
|
2195
bb6de5f8fd03
Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents:
2191
diff
changeset
|
1257 |
(redefCondition value:aClass value:aSelector) ifTrue:[ |
bb6de5f8fd03
Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents:
2191
diff
changeset
|
1258 |
aBlock value:aSelector asSymbol |
bb6de5f8fd03
Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents:
2191
diff
changeset
|
1259 |
] ifFalse:[ |
bb6de5f8fd03
Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents:
2191
diff
changeset
|
1260 |
Transcript showCR:('#' , aSelector , redefMessage) |
bb6de5f8fd03
Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents:
2191
diff
changeset
|
1261 |
] |
698 | 1262 |
] |
376 | 1263 |
! |
1264 |
||
1265 |
generateHookMethodFor:selectorSpec comment:commentWhen note:noteOrNil defaultCode:defaultCode inClass:targetClass |
|
1266 |
^ ('!!' , targetClass name , ' methodsFor:''hooks''!!\\' , |
|
1267 |
selectorSpec , '\' , |
|
1268 |
' "automatically generated by UIPainter ..."\\' , |
|
1269 |
' "*** the code here does nothing. It is invoked when"\' , |
|
1270 |
' "*** ' , commentWhen , '"\' , |
|
1271 |
' "*** Please change as required and accept in the browser."\' , |
|
1272 |
'\' , |
|
1273 |
' "specific code to be added below ..."\' , |
|
1274 |
' "' , (noteOrNil ? '') , '"\' , |
|
1275 |
'\' , |
|
1276 |
(defaultCode ? '^ self.') , |
|
1277 |
'!! !!\\') withCRs |
|
1278 |
||
1279 |
"Modified: / 25.10.1997 / 19:22:17 / cg" |
|
1280 |
"Created: / 31.10.1997 / 17:31:53 / cg" |
|
1281 |
! |
|
1282 |
||
1283 |
generateHookMethods |
|
1284 |
"generate hook methods |
|
1285 |
- but do not overwrite existing ones. |
|
1286 |
Return a string ready to compile into the application class." |
|
1287 |
||
1683
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1288 |
|cls| |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1289 |
|
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1290 |
cls := self targetClass. |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1291 |
cls isNil ifTrue:[ |
1834 | 1292 |
^ nil |
376 | 1293 |
]. |
1683
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1294 |
|
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1295 |
^ self generateHookMethodsInClass:cls. |
376 | 1296 |
! |
1297 |
||
1298 |
generateHookMethodsInClass:targetClass |
|
1299 |
|code| |
|
1300 |
||
1301 |
code := ''. |
|
1302 |
||
1554
d5e4612bf7cf
implements -> includesSelector
Claus Gittinger <cg@exept.de>
parents:
1543
diff
changeset
|
1303 |
(targetClass includesSelector:#postBuildWith:) ifFalse:[ |
1834 | 1304 |
code := code |
1305 |
, (self |
|
1306 |
generateHookMethodFor:'postBuildWith:aBuilder' |
|
1307 |
comment:'the widgets have been built, but before the view is opened' |
|
1308 |
note:'or after the super send' |
|
1309 |
defaultCode:' super postBuildWith:aBuilder' |
|
1310 |
inClass:targetClass) |
|
376 | 1311 |
]. |
1554
d5e4612bf7cf
implements -> includesSelector
Claus Gittinger <cg@exept.de>
parents:
1543
diff
changeset
|
1312 |
(targetClass includesSelector:#postOpenWith:) ifFalse:[ |
1834 | 1313 |
code := code |
1314 |
, (self |
|
1315 |
generateHookMethodFor:'postOpenWith:aBuilder' |
|
1316 |
comment:'the topView has been opened, but before events are dispatched for it' |
|
1317 |
note:'or after the super send' |
|
1318 |
defaultCode:' super postOpenWith:aBuilder' |
|
1319 |
inClass:targetClass) |
|
376 | 1320 |
]. |
1554
d5e4612bf7cf
implements -> includesSelector
Claus Gittinger <cg@exept.de>
parents:
1543
diff
changeset
|
1321 |
(targetClass includesSelector:#closeRequest) ifFalse:[ |
1834 | 1322 |
code := code |
1323 |
, (self |
|
1324 |
generateHookMethodFor:'closeRequest' |
|
1325 |
comment:'the topView has been asked to close' |
|
1326 |
note:'return without the ''super closeRequest'' to stay open' |
|
1327 |
defaultCode:' ^super closeRequest' |
|
1328 |
inClass:targetClass) |
|
376 | 1329 |
]. |
1330 |
^ code |
|
1331 |
||
1332 |
"Modified: / 31.10.1997 / 17:30:34 / cg" |
|
1333 |
"Created: / 31.10.1997 / 17:32:49 / cg" |
|
316 | 1334 |
! |
1335 |
||
965
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1336 |
generateMenuMethodFor:menuSel inClass:targetClass |
1805
cf1a9d636bf7
category and comment flags now in Userprefs
Claus Gittinger <cg@exept.de>
parents:
1785
diff
changeset
|
1337 |
|selector args showIt code alreadyInSuperclass numArgs method category| |
965
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1338 |
|
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1339 |
selector := menuSel asSymbol. |
1805
cf1a9d636bf7
category and comment flags now in Userprefs
Claus Gittinger <cg@exept.de>
parents:
1785
diff
changeset
|
1340 |
category := UserPreferences current categoryForMenuActionsMethods. |
965
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1341 |
|
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1342 |
alreadyInSuperclass := targetClass superclass canUnderstand:selector. |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1343 |
|
1805
cf1a9d636bf7
category and comment flags now in Userprefs
Claus Gittinger <cg@exept.de>
parents:
1785
diff
changeset
|
1344 |
code := '!!' , targetClass name , ' methodsFor:''' , category , '''!!\\'. |
965
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1345 |
|
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1346 |
selector = 'openAboutThisApplication' ifTrue:[ |
1834 | 1347 |
code := code , |
1348 |
'openAboutThisApplication\' , |
|
1349 |
' "opens an about box for this application."\\' , |
|
1350 |
' "automatically generated by UIPainter ..."\\' , |
|
1351 |
||
1352 |
' |rev box myClass clsRev image msg|\\' , |
|
1353 |
||
1354 |
' rev := ''''.\' , |
|
1355 |
' myClass := self class.\' , |
|
1356 |
||
1357 |
' (clsRev := myClass revision) notNil ifTrue:[\' , |
|
1358 |
' rev := '' (rev: '', clsRev printString, '')''].\\' , |
|
1359 |
||
1360 |
' msg := Character cr asString , myClass name asBoldText, rev.\' , |
|
1361 |
' msg := (msg , ''\\*** add more info here ***\\'') withCRs.\\' , |
|
1362 |
' box := AboutBox title:msg.\' , |
|
1363 |
||
1364 |
' "/ *** add a #defaultIcon method in the class\' , |
|
1365 |
' "/ *** and uncomment the following line:\' , |
|
1366 |
' "/ image := self class defaultIcon.\\' , |
|
1367 |
' image notNil ifTrue:[\' , |
|
1368 |
' box image:image\' , |
|
1369 |
' ].\' , |
|
1370 |
' box label:(resources string:''About %1'' with:myClass name).\' , |
|
1371 |
' box autoHideAfter:10 with:[].\' , |
|
1372 |
' box showAtPointer.\' , |
|
1373 |
'!! !!\\'. |
|
1374 |
^ code withCRs |
|
965
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1375 |
]. |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1376 |
|
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1377 |
selector = 'menuOpen' ifTrue:[ |
1834 | 1378 |
code := code , |
1379 |
'menuOpen\' , |
|
1380 |
' "automatically generated by UIPainter ..."\\' , |
|
1381 |
' "*** the code below opens a dialog for file selection"\' , |
|
1382 |
' "*** and invokes the #doOpen: method with the selected file."\' , |
|
1383 |
' "*** Please change as required and accept in the browser."\\' , |
|
1384 |
' |file|\\' , |
|
1385 |
' file :=\' , |
|
1386 |
' (FileSelectionBrowser\' , |
|
1387 |
' request: ''Open''\' , |
|
1388 |
' fileName: ''''\' , |
|
1389 |
' "/ inDirectory: lastOpenDirectory\' , |
|
1390 |
' withFileFilters: #(''*'')).\\' , |
|
1391 |
' file notNil ifTrue:[\' , |
|
1392 |
' "/ lastOpenDirectory := file asFilename directory.\' , |
|
1393 |
' self doOpen:file\' , |
|
1394 |
' ]\' , |
|
1395 |
'!! !!\'. |
|
1396 |
^ code withCRs |
|
965
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1397 |
]. |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1398 |
|
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1399 |
numArgs := selector numArgs. |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1400 |
method := selector. |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1401 |
|
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1402 |
numArgs == 1 ifTrue:[ |
1834 | 1403 |
args := 'anArgument'. |
1404 |
showIt := ''' , anArgument printString , '' ...''.\'. |
|
1405 |
] ifFalse:[ |
|
1406 |
args := ''. |
|
1407 |
showIt := ' ...''.\'. |
|
1408 |
||
1409 |
numArgs ~~ 0 ifTrue:[ |
|
1410 |
method := ''. |
|
1411 |
||
1412 |
selector keywords keysAndValuesDo:[:i :key| |
|
1413 |
method := method, key, 'arg', i printString, ' ' |
|
1414 |
] |
|
1415 |
] |
|
965
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1416 |
]. |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1417 |
|
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1418 |
code := code , |
1834 | 1419 |
method , args , '\' , |
1420 |
' "automatically generated by UIPainter ..."\\' , |
|
1421 |
' "*** the code below performs no action"\' , |
|
1422 |
' "*** (except for some feedback on the Transcript)"\' , |
|
1423 |
' "*** Please change as required and accept in the browser."\' , |
|
1424 |
'\' . |
|
965
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1425 |
|
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1426 |
alreadyInSuperclass ifTrue:[ |
1834 | 1427 |
code := code , |
1428 |
' "action for ' , selector , ' is already provided in a superclass."\' , |
|
1429 |
' "It may be redefined here ..."\\'. |
|
965
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1430 |
] ifFalse:[ |
1834 | 1431 |
code := code , |
1432 |
' "action to be added ..."\\'. |
|
965
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1433 |
]. |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1434 |
|
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1435 |
code := code , |
1834 | 1436 |
' Transcript showCR:self class name, '': '. |
965
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1437 |
alreadyInSuperclass ifTrue:[ |
1834 | 1438 |
code := code , 'inherited '. |
965
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1439 |
]. |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1440 |
code := code , 'menu action for ' , selector , showIt. |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1441 |
|
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1442 |
alreadyInSuperclass ifTrue:[ |
1834 | 1443 |
code := code , |
1444 |
' super ' , selector , args , '.\'. |
|
965
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1445 |
]. |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1446 |
|
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1447 |
code := code , |
1834 | 1448 |
'!! !!\\'. |
965
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1449 |
^ code withCRs |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1450 |
|
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1451 |
"Created: / 23.8.1998 / 16:46:51 / cg" |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1452 |
"Modified: / 23.8.1998 / 18:13:05 / cg" |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1453 |
! |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1454 |
|
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1455 |
generateMenuMethods |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1456 |
"generate menu methods |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1457 |
- but do not overwrite existing ones. |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1458 |
Return a string ready to compile into the application class." |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1459 |
|
1069 | 1460 |
|cls code menuSelector thisCode |
1461 |
definedMethodSelectors |
|
2276
485bda17023f
more changes to allow for non-class/selector (i.e. spec-only) use
Claus Gittinger <cg@exept.de>
parents:
2265
diff
changeset
|
1462 |
spec specArray fullSpec winSpec menuSpec| |
965
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1463 |
|
1683
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1464 |
cls := self targetClass. |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1465 |
cls isNil ifTrue:[ |
2276
485bda17023f
more changes to allow for non-class/selector (i.e. spec-only) use
Claus Gittinger <cg@exept.de>
parents:
2265
diff
changeset
|
1466 |
^ nil |
965
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1467 |
]. |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1468 |
|
2276
485bda17023f
more changes to allow for non-class/selector (i.e. spec-only) use
Claus Gittinger <cg@exept.de>
parents:
2265
diff
changeset
|
1469 |
spec := treeView generateFullSpecForComponents:#() named:nil. |
485bda17023f
more changes to allow for non-class/selector (i.e. spec-only) use
Claus Gittinger <cg@exept.de>
parents:
2265
diff
changeset
|
1470 |
specArray := spec literalArrayEncoding. |
965
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1471 |
fullSpec := specArray decodeAsLiteralArray. |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1472 |
winSpec := fullSpec window. |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1473 |
menuSelector := winSpec menu. |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1474 |
|
1834 | 1475 |
(menuSelector notNil |
1069 | 1476 |
and:[ (cls respondsTo:menuSelector) ]) ifFalse:[ |
2276
485bda17023f
more changes to allow for non-class/selector (i.e. spec-only) use
Claus Gittinger <cg@exept.de>
parents:
2265
diff
changeset
|
1477 |
self warn:'No menu defined (yet)'. |
485bda17023f
more changes to allow for non-class/selector (i.e. spec-only) use
Claus Gittinger <cg@exept.de>
parents:
2265
diff
changeset
|
1478 |
^ nil. |
965
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1479 |
]. |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1480 |
menuSpec := cls perform:menuSelector. |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1481 |
menuSpec := menuSpec decodeAsLiteralArray. |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1482 |
|
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1483 |
definedMethodSelectors := IdentitySet new. |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1484 |
code := ''. |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1485 |
|
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1486 |
menuSpec allItemsDo:[:item | |
2276
485bda17023f
more changes to allow for non-class/selector (i.e. spec-only) use
Claus Gittinger <cg@exept.de>
parents:
2265
diff
changeset
|
1487 |
|sel| |
485bda17023f
more changes to allow for non-class/selector (i.e. spec-only) use
Claus Gittinger <cg@exept.de>
parents:
2265
diff
changeset
|
1488 |
|
485bda17023f
more changes to allow for non-class/selector (i.e. spec-only) use
Claus Gittinger <cg@exept.de>
parents:
2265
diff
changeset
|
1489 |
(sel := item value) notNil ifTrue:[ |
485bda17023f
more changes to allow for non-class/selector (i.e. spec-only) use
Claus Gittinger <cg@exept.de>
parents:
2265
diff
changeset
|
1490 |
(definedMethodSelectors includes:sel) ifFalse:[ |
485bda17023f
more changes to allow for non-class/selector (i.e. spec-only) use
Claus Gittinger <cg@exept.de>
parents:
2265
diff
changeset
|
1491 |
self generateCodeFrom:(Array with:sel) in:cls do:[:aSel| |
485bda17023f
more changes to allow for non-class/selector (i.e. spec-only) use
Claus Gittinger <cg@exept.de>
parents:
2265
diff
changeset
|
1492 |
thisCode := (self generateMenuMethodFor:aSel inClass:cls). |
485bda17023f
more changes to allow for non-class/selector (i.e. spec-only) use
Claus Gittinger <cg@exept.de>
parents:
2265
diff
changeset
|
1493 |
code := code, thisCode. |
485bda17023f
more changes to allow for non-class/selector (i.e. spec-only) use
Claus Gittinger <cg@exept.de>
parents:
2265
diff
changeset
|
1494 |
]. |
485bda17023f
more changes to allow for non-class/selector (i.e. spec-only) use
Claus Gittinger <cg@exept.de>
parents:
2265
diff
changeset
|
1495 |
definedMethodSelectors add:sel. |
485bda17023f
more changes to allow for non-class/selector (i.e. spec-only) use
Claus Gittinger <cg@exept.de>
parents:
2265
diff
changeset
|
1496 |
]. |
485bda17023f
more changes to allow for non-class/selector (i.e. spec-only) use
Claus Gittinger <cg@exept.de>
parents:
2265
diff
changeset
|
1497 |
] |
965
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1498 |
]. |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1499 |
|
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1500 |
(definedMethodSelectors includes:#menuOpen) ifTrue:[ |
2276
485bda17023f
more changes to allow for non-class/selector (i.e. spec-only) use
Claus Gittinger <cg@exept.de>
parents:
2265
diff
changeset
|
1501 |
self generateCodeFrom:(Array with:#doOpen:) in:cls do:[:aSel| |
485bda17023f
more changes to allow for non-class/selector (i.e. spec-only) use
Claus Gittinger <cg@exept.de>
parents:
2265
diff
changeset
|
1502 |
thisCode := (self generateMenuMethodFor:aSel inClass:cls). |
485bda17023f
more changes to allow for non-class/selector (i.e. spec-only) use
Claus Gittinger <cg@exept.de>
parents:
2265
diff
changeset
|
1503 |
code := code, thisCode. |
485bda17023f
more changes to allow for non-class/selector (i.e. spec-only) use
Claus Gittinger <cg@exept.de>
parents:
2265
diff
changeset
|
1504 |
]. |
965
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1505 |
]. |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1506 |
|
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1507 |
^ code |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1508 |
|
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1509 |
"Created: / 23.8.1998 / 16:12:09 / cg" |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1510 |
"Modified: / 23.8.1998 / 18:12:23 / cg" |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1511 |
! |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1512 |
|
188
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
1513 |
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
1514 |
^ ('!!' , targetClass name , ' methodsFor:''values''!!\\' , |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
1515 |
aspect , '\' , |
352 | 1516 |
' "automatically generated by UIPainter ..."\\' , |
1517 |
' "*** the code below returns a default value when invoked."\' , |
|
1518 |
' "*** (which may not be the one you wanted)"\' , |
|
1519 |
' "*** Please change as required and accept in the browser."\' , |
|
188
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
1520 |
'\' , |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
1521 |
' "value to be added below ..."\' , |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
1522 |
' Transcript showCR:self class name , '': no value yet for ' , aspect , ' ...''.\' , |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
1523 |
'\' , |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
1524 |
'^ nil.' , |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
1525 |
'!! !!\\') withCRs |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
1526 |
|
352 | 1527 |
"Modified: / 25.10.1997 / 19:22:17 / cg" |
188
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
1528 |
! |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
1529 |
|
2197
873c7b960233
slightly refactored to allow for more redefinition in a subclass
Claus Gittinger <cg@exept.de>
parents:
2195
diff
changeset
|
1530 |
generateWindowSpec |
873c7b960233
slightly refactored to allow for more redefinition in a subclass
Claus Gittinger <cg@exept.de>
parents:
2195
diff
changeset
|
1531 |
|spec| |
60 | 1532 |
|
310 | 1533 |
spec := OrderedCollection new. |
60 | 1534 |
|
78 | 1535 |
self subViews do:[:aView| |
2197
873c7b960233
slightly refactored to allow for more redefinition in a subclass
Claus Gittinger <cg@exept.de>
parents:
2195
diff
changeset
|
1536 |
|vSpec| |
873c7b960233
slightly refactored to allow for more redefinition in a subclass
Claus Gittinger <cg@exept.de>
parents:
2195
diff
changeset
|
1537 |
|
873c7b960233
slightly refactored to allow for more redefinition in a subclass
Claus Gittinger <cg@exept.de>
parents:
2195
diff
changeset
|
1538 |
"/ care for wrapped views ... |
873c7b960233
slightly refactored to allow for more redefinition in a subclass
Claus Gittinger <cg@exept.de>
parents:
2195
diff
changeset
|
1539 |
vSpec := self fullSpecFor:aView. |
873c7b960233
slightly refactored to allow for more redefinition in a subclass
Claus Gittinger <cg@exept.de>
parents:
2195
diff
changeset
|
1540 |
vSpec isNil ifTrue:[ |
873c7b960233
slightly refactored to allow for more redefinition in a subclass
Claus Gittinger <cg@exept.de>
parents:
2195
diff
changeset
|
1541 |
aView subViews size == 1 ifTrue:[ |
873c7b960233
slightly refactored to allow for more redefinition in a subclass
Claus Gittinger <cg@exept.de>
parents:
2195
diff
changeset
|
1542 |
vSpec := self fullSpecFor:(aView subViews first). |
873c7b960233
slightly refactored to allow for more redefinition in a subclass
Claus Gittinger <cg@exept.de>
parents:
2195
diff
changeset
|
1543 |
] |
873c7b960233
slightly refactored to allow for more redefinition in a subclass
Claus Gittinger <cg@exept.de>
parents:
2195
diff
changeset
|
1544 |
]. |
873c7b960233
slightly refactored to allow for more redefinition in a subclass
Claus Gittinger <cg@exept.de>
parents:
2195
diff
changeset
|
1545 |
vSpec isNil ifTrue:[ |
873c7b960233
slightly refactored to allow for more redefinition in a subclass
Claus Gittinger <cg@exept.de>
parents:
2195
diff
changeset
|
1546 |
self warn:'Oops - could not create spec for some view' |
873c7b960233
slightly refactored to allow for more redefinition in a subclass
Claus Gittinger <cg@exept.de>
parents:
2195
diff
changeset
|
1547 |
]. |
873c7b960233
slightly refactored to allow for more redefinition in a subclass
Claus Gittinger <cg@exept.de>
parents:
2195
diff
changeset
|
1548 |
spec add:vSpec |
60 | 1549 |
]. |
1058 | 1550 |
|
1551 |
spec := treeView generateFullSpecForComponents:spec named:methodName. |
|
2197
873c7b960233
slightly refactored to allow for more redefinition in a subclass
Claus Gittinger <cg@exept.de>
parents:
2195
diff
changeset
|
1552 |
^ spec |
873c7b960233
slightly refactored to allow for more redefinition in a subclass
Claus Gittinger <cg@exept.de>
parents:
2195
diff
changeset
|
1553 |
! |
873c7b960233
slightly refactored to allow for more redefinition in a subclass
Claus Gittinger <cg@exept.de>
parents:
2195
diff
changeset
|
1554 |
|
873c7b960233
slightly refactored to allow for more redefinition in a subclass
Claus Gittinger <cg@exept.de>
parents:
2195
diff
changeset
|
1555 |
generateWindowSpecMethodSource |
2276
485bda17023f
more changes to allow for non-class/selector (i.e. spec-only) use
Claus Gittinger <cg@exept.de>
parents:
2265
diff
changeset
|
1556 |
|spec specArray str code category cls mthd specCode| |
2197
873c7b960233
slightly refactored to allow for more redefinition in a subclass
Claus Gittinger <cg@exept.de>
parents:
2195
diff
changeset
|
1557 |
|
873c7b960233
slightly refactored to allow for more redefinition in a subclass
Claus Gittinger <cg@exept.de>
parents:
2195
diff
changeset
|
1558 |
spec := self generateWindowSpec. |
2276
485bda17023f
more changes to allow for non-class/selector (i.e. spec-only) use
Claus Gittinger <cg@exept.de>
parents:
2265
diff
changeset
|
1559 |
specArray := spec literalArrayEncoding. |
2197
873c7b960233
slightly refactored to allow for more redefinition in a subclass
Claus Gittinger <cg@exept.de>
parents:
2195
diff
changeset
|
1560 |
|
310 | 1561 |
str := WriteStream on:String new. |
2276
485bda17023f
more changes to allow for non-class/selector (i.e. spec-only) use
Claus Gittinger <cg@exept.de>
parents:
2265
diff
changeset
|
1562 |
UISpecification prettyPrintSpecArray:specArray on:str indent:5. |
464 | 1563 |
specCode := str contents. |
457 | 1564 |
|
1565 |
(specCode includes:$!!) ifTrue:[ |
|
2197
873c7b960233
slightly refactored to allow for more redefinition in a subclass
Claus Gittinger <cg@exept.de>
parents:
2195
diff
changeset
|
1566 |
"/ oops - must be chunk format ... |
873c7b960233
slightly refactored to allow for more redefinition in a subclass
Claus Gittinger <cg@exept.de>
parents:
2195
diff
changeset
|
1567 |
str := WriteStream on:String new. |
873c7b960233
slightly refactored to allow for more redefinition in a subclass
Claus Gittinger <cg@exept.de>
parents:
2195
diff
changeset
|
1568 |
str nextPutAllAsChunk:specCode. |
873c7b960233
slightly refactored to allow for more redefinition in a subclass
Claus Gittinger <cg@exept.de>
parents:
2195
diff
changeset
|
1569 |
specCode := str contents. |
457 | 1570 |
]. |
60 | 1571 |
|
178
fb8451053c96
keep windowSpec methods category if it already exists
Claus Gittinger <cg@exept.de>
parents:
175
diff
changeset
|
1572 |
"/ if that method already exists, do not overwrite the category |
fb8451053c96
keep windowSpec methods category if it already exists
Claus Gittinger <cg@exept.de>
parents:
175
diff
changeset
|
1573 |
|
fb8451053c96
keep windowSpec methods category if it already exists
Claus Gittinger <cg@exept.de>
parents:
175
diff
changeset
|
1574 |
category := 'interface specs'. |
330 | 1575 |
cls := self resolveName:className. |
1576 |
||
1577 |
cls notNil ifTrue:[ |
|
2197
873c7b960233
slightly refactored to allow for more redefinition in a subclass
Claus Gittinger <cg@exept.de>
parents:
2195
diff
changeset
|
1578 |
(mthd := cls class compiledMethodAt:methodName asSymbol) notNil ifTrue:[ |
873c7b960233
slightly refactored to allow for more redefinition in a subclass
Claus Gittinger <cg@exept.de>
parents:
2195
diff
changeset
|
1579 |
category := mthd category. |
873c7b960233
slightly refactored to allow for more redefinition in a subclass
Claus Gittinger <cg@exept.de>
parents:
2195
diff
changeset
|
1580 |
] |
178
fb8451053c96
keep windowSpec methods category if it already exists
Claus Gittinger <cg@exept.de>
parents:
175
diff
changeset
|
1581 |
]. |
fb8451053c96
keep windowSpec methods category if it already exists
Claus Gittinger <cg@exept.de>
parents:
175
diff
changeset
|
1582 |
|
238 | 1583 |
code := '!!' |
2197
873c7b960233
slightly refactored to allow for more redefinition in a subclass
Claus Gittinger <cg@exept.de>
parents:
2195
diff
changeset
|
1584 |
, className , ' class methodsFor:' , category storeString |
873c7b960233
slightly refactored to allow for more redefinition in a subclass
Claus Gittinger <cg@exept.de>
parents:
2195
diff
changeset
|
1585 |
, '!!' , '\\' |
873c7b960233
slightly refactored to allow for more redefinition in a subclass
Claus Gittinger <cg@exept.de>
parents:
2195
diff
changeset
|
1586 |
|
873c7b960233
slightly refactored to allow for more redefinition in a subclass
Claus Gittinger <cg@exept.de>
parents:
2195
diff
changeset
|
1587 |
, methodName , '\' |
873c7b960233
slightly refactored to allow for more redefinition in a subclass
Claus Gittinger <cg@exept.de>
parents:
2195
diff
changeset
|
1588 |
, ((ResourceSpecEditor codeGenerationCommentForClass: UIPainter) replChar:$!! withString:'!!!!') |
873c7b960233
slightly refactored to allow for more redefinition in a subclass
Claus Gittinger <cg@exept.de>
parents:
2195
diff
changeset
|
1589 |
, '\\ "\' |
873c7b960233
slightly refactored to allow for more redefinition in a subclass
Claus Gittinger <cg@exept.de>
parents:
2195
diff
changeset
|
1590 |
, (' UIPainter new openOnClass:' , className , ' andSelector:#' , methodName , '\'). |
1013 | 1591 |
|
1050
355a8ff451b6
care for as-yet-unspecified class in show-spec menu item.
Claus Gittinger <cg@exept.de>
parents:
1039
diff
changeset
|
1592 |
(cls notNil and:[cls isSubclassOf:ApplicationModel]) ifTrue:[ |
2197
873c7b960233
slightly refactored to allow for more redefinition in a subclass
Claus Gittinger <cg@exept.de>
parents:
2195
diff
changeset
|
1593 |
code := code |
873c7b960233
slightly refactored to allow for more redefinition in a subclass
Claus Gittinger <cg@exept.de>
parents:
2195
diff
changeset
|
1594 |
, (' ' , className , ' new openInterface:#' , methodName , '\'). |
1013 | 1595 |
]. |
1596 |
||
1597 |
code := code |
|
2197
873c7b960233
slightly refactored to allow for more redefinition in a subclass
Claus Gittinger <cg@exept.de>
parents:
2195
diff
changeset
|
1598 |
,(methodName = 'windowSpec' |
873c7b960233
slightly refactored to allow for more redefinition in a subclass
Claus Gittinger <cg@exept.de>
parents:
2195
diff
changeset
|
1599 |
ifTrue:[' ' , className , ' open\'] ifFalse: ['']) |
873c7b960233
slightly refactored to allow for more redefinition in a subclass
Claus Gittinger <cg@exept.de>
parents:
2195
diff
changeset
|
1600 |
, ' "\'. |
1834 | 1601 |
|
1602 |
code := code |
|
2197
873c7b960233
slightly refactored to allow for more redefinition in a subclass
Claus Gittinger <cg@exept.de>
parents:
2195
diff
changeset
|
1603 |
, '\' |
873c7b960233
slightly refactored to allow for more redefinition in a subclass
Claus Gittinger <cg@exept.de>
parents:
2195
diff
changeset
|
1604 |
, ' <resource: #canvas>\\' |
873c7b960233
slightly refactored to allow for more redefinition in a subclass
Claus Gittinger <cg@exept.de>
parents:
2195
diff
changeset
|
1605 |
, ' ^ ' , specCode |
873c7b960233
slightly refactored to allow for more redefinition in a subclass
Claus Gittinger <cg@exept.de>
parents:
2195
diff
changeset
|
1606 |
, '\' |
873c7b960233
slightly refactored to allow for more redefinition in a subclass
Claus Gittinger <cg@exept.de>
parents:
2195
diff
changeset
|
1607 |
, '!! !!' |
873c7b960233
slightly refactored to allow for more redefinition in a subclass
Claus Gittinger <cg@exept.de>
parents:
2195
diff
changeset
|
1608 |
, '\\'. |
60 | 1609 |
|
1610 |
^ code withCRs |
|
1611 |
||
1013 | 1612 |
"Modified: / 5.9.1995 / 21:01:35 / claus" |
1613 |
"Modified: / 15.10.1998 / 11:29:53 / cg" |
|
1683
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1614 |
! |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1615 |
|
2244 | 1616 |
listOfAspects |
1617 |
|cls aspects| |
|
1618 |
||
2276
485bda17023f
more changes to allow for non-class/selector (i.e. spec-only) use
Claus Gittinger <cg@exept.de>
parents:
2265
diff
changeset
|
1619 |
listOfAspectsHolder notNil ifTrue:[ |
485bda17023f
more changes to allow for non-class/selector (i.e. spec-only) use
Claus Gittinger <cg@exept.de>
parents:
2265
diff
changeset
|
1620 |
^ listOfAspectsHolder value |
485bda17023f
more changes to allow for non-class/selector (i.e. spec-only) use
Claus Gittinger <cg@exept.de>
parents:
2265
diff
changeset
|
1621 |
]. |
485bda17023f
more changes to allow for non-class/selector (i.e. spec-only) use
Claus Gittinger <cg@exept.de>
parents:
2265
diff
changeset
|
1622 |
|
2244 | 1623 |
aspects := IdentitySet new. |
1624 |
||
1625 |
cls := self targetClass. |
|
1626 |
cls notNil ifTrue:[ |
|
2265 | 1627 |
cls withAllSuperclassesDo:[:cls | |
1628 |
cls methodsDo:[:m | |
|
1629 |
((m resources ? #()) includesAny:#(uiAspect)) ifTrue:[ |
|
1630 |
aspects add:m selector |
|
1631 |
]. |
|
1632 |
] |
|
2244 | 1633 |
] |
1634 |
]. |
|
1635 |
||
1636 |
treeView propertiesDo:[:aProp| |
|
1637 |
|modelSelector| |
|
1638 |
||
1639 |
(modelSelector := aProp model) notNil ifTrue:[ |
|
1640 |
aspects add:modelSelector asSymbol |
|
1641 |
]. |
|
1642 |
||
1643 |
"/ aspects addAll:aProp spec actionSelectors. |
|
2250
e65b8bf6224b
care for non-symbolic aspects (false)
Claus Gittinger <cg@exept.de>
parents:
2248
diff
changeset
|
1644 |
|
e65b8bf6224b
care for non-symbolic aspects (false)
Claus Gittinger <cg@exept.de>
parents:
2248
diff
changeset
|
1645 |
aspects addAll:(aProp spec valueSelectors select:[:a | a isString or:[a isSymbol]]). |
e65b8bf6224b
care for non-symbolic aspects (false)
Claus Gittinger <cg@exept.de>
parents:
2248
diff
changeset
|
1646 |
aspects addAll:(aProp spec aspectSelectors select:[:a | a isString or:[a isSymbol]]). |
2244 | 1647 |
]. |
1648 |
||
1649 |
^ aspects asOrderedCollection sort. |
|
1650 |
||
1651 |
"Created: / 12-01-2008 / 19:24:45 / cg" |
|
1652 |
! |
|
1653 |
||
1654 |
listOfCallbacks |
|
1655 |
|cls aspects| |
|
1656 |
||
1657 |
aspects := IdentitySet new. |
|
1658 |
||
1659 |
cls := self targetClass. |
|
1660 |
cls notNil ifTrue:[ |
|
1661 |
cls methodsDo:[:m | |
|
1662 |
((m resources ? #()) includesAny:#(uiCallback)) ifTrue:[ |
|
1663 |
aspects add:m selector |
|
1664 |
]. |
|
1665 |
] |
|
1666 |
]. |
|
1667 |
||
1668 |
treeView propertiesDo:[:aProp| |
|
1669 |
|modelSelector| |
|
1670 |
||
1671 |
aspects addAll:aProp spec actionSelectors. |
|
1672 |
"/ aspects addAll:aProp spec valueSelectors. |
|
1673 |
"/ aspects addAll:aProp spec aspectSelectors. |
|
1674 |
]. |
|
1675 |
||
1676 |
^ aspects asOrderedCollection sort. |
|
1677 |
||
1678 |
"Created: / 12-01-2008 / 19:25:19 / cg" |
|
1679 |
! |
|
1680 |
||
1683
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1681 |
targetClass |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1682 |
|cls| |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1683 |
|
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1684 |
className isNil ifTrue:[ |
2248 | 1685 |
self warn:'No TargetClass defined !!'. |
1686 |
^ nil |
|
1683
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1687 |
]. |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1688 |
(cls := self resolveName:className) isNil ifTrue:[ |
2248 | 1689 |
"/ self warn:('Class ', className asString, ' does not exist !!'). |
1690 |
^ nil |
|
1683
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1691 |
]. |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1692 |
^ cls. |
60 | 1693 |
! ! |
1694 |
||
754 | 1695 |
!UIPainterView methodsFor:'grid manipulation'! |
1696 |
||
1697 |
newGrid |
|
1698 |
"define a new grid - this is a private helper which has to be |
|
1699 |
called after any change in the grid. It (re)creates the gridPixmap, |
|
1700 |
clears the view and redraws all visible objects." |
|
1701 |
||
1702 |
|defaultViewBackground| |
|
1703 |
||
1704 |
gridPixmap := nil. |
|
1705 |
defaultViewBackground := self class defaultViewBackgroundColor. |
|
1706 |
||
1707 |
shown ifTrue:[ |
|
1834 | 1708 |
self viewBackground: (defaultViewBackground isColor |
1709 |
ifTrue: [defaultViewBackground] |
|
1710 |
ifFalse:[Black]). |
|
1711 |
self clear. |
|
754 | 1712 |
]. |
1713 |
||
1714 |
gridShown ifTrue:[ |
|
1834 | 1715 |
self defineGrid. |
1716 |
gridPixmap colorMap: (defaultViewBackground isColor |
|
1717 |
ifTrue: [Array with:defaultViewBackground with:Color darkGray] |
|
1718 |
ifFalse:[Array with:White with:Black]). |
|
1719 |
self viewBackground:gridPixmap. |
|
754 | 1720 |
]. |
1721 |
||
1722 |
self invalidate |
|
1723 |
||
1724 |
! ! |
|
1725 |
||
1832 | 1726 |
!UIPainterView methodsFor:'group & ungroup'! |
1727 |
||
1728 |
group |
|
1729 |
||
1730 |
self groupSelectionWithLayout: false |
|
1731 |
! |
|
1732 |
||
1733 |
groupSelectionWithLayout: withLayout |
|
1734 |
| spec rect views box layout specs canvas view oldSelection cS nViews menu item xOffset yOffset | |
|
1735 |
||
1736 |
menu := Menu new. |
|
1737 |
menu receiver: self. |
|
1738 |
item := MenuItem label:'Box' value:[spec := ViewSpec new]. |
|
1739 |
menu addItem: item. |
|
1740 |
item := MenuItem label:'TBox' value:[spec := TBoxSpec new]. |
|
1741 |
menu addItem: item. |
|
1742 |
item := MenuItem label:'FramedBox' value:[spec := FramedBoxSpec new]. |
|
1743 |
menu addItem: item. |
|
1744 |
item := MenuItem label:'HorizontalPanel' value:[spec := HorizontalPanelViewSpec new]. |
|
1745 |
menu addItem: item. |
|
1746 |
item := MenuItem label:'VerticalPanel' value:[spec := VerticalPanelViewSpec new]. |
|
1747 |
menu addItem: item. |
|
1748 |
(MenuPanel menu: menu) startUp. |
|
1749 |
canvas := self painter. |
|
1750 |
cS := canvas getSelectedViewsAndSpecs. |
|
1751 |
cS isNil ifTrue:[^self]. |
|
1752 |
views := cS first. |
|
1834 | 1753 |
specs := cS last. |
1832 | 1754 |
rect := views first frame. |
1755 |
2 to: views size do:[:i| rect := rect merge: (views at: i) frame]. |
|
1834 | 1756 |
layout := LayoutFrame leftFraction:0.0 offset: rect origin x |
1757 |
rightFraction:0.0 offset: rect corner x + 1 |
|
1758 |
topFraction:0.0 offset: rect origin y |
|
1759 |
bottomFraction:0.0 offset:rect corner y + 1. |
|
1832 | 1760 |
oldSelection := canvas selection. |
1761 |
canvas select: views first superView. |
|
1762 |
spec layout: layout. |
|
1763 |
spec class == VerticalPanelViewSpec ifTrue:[ |
|
1834 | 1764 |
spec verticalLayout: #topSpace. |
1765 |
spec horizontalLayout: #fit. |
|
1832 | 1766 |
]. |
1767 |
spec class == HorizontalPanelViewSpec ifTrue:[ |
|
1834 | 1768 |
spec verticalLayout: #fit. |
1769 |
spec horizontalLayout: #leftSpace. |
|
1832 | 1770 |
]. |
1771 |
||
1772 |
box := self pasteSpecifications:spec keepLayout:true at:nil. |
|
1773 |
||
1774 |
xOffset := box origin x. |
|
1775 |
yOffset := box origin y. |
|
1776 |
withLayout ifFalse:[ |
|
1834 | 1777 |
1 to: specs size do:[:i| |
1778 |
view := views at: i. |
|
1779 |
layout := LayoutFrame leftFraction:0.0 offset: (view origin x - xOffset) |
|
1780 |
rightFraction:0.0 offset: (view corner x - xOffset + 1) |
|
1781 |
topFraction:0.0 offset: (view origin y - yOffset ) |
|
1782 |
bottomFraction:0.0 offset: (view corner y - yOffset + 1). |
|
1783 |
(specs at: i) layout: layout. |
|
1784 |
]. |
|
1785 |
]. |
|
1832 | 1786 |
canvas selection: oldSelection. |
1787 |
canvas deleteSelection. |
|
1788 |
canvas selection:box. |
|
1789 |
nViews := canvas pasteSpecifications:specs keepLayout:true. |
|
1790 |
canvas selection: box. |
|
1791 |
! |
|
1792 |
||
1793 |
groupWithLayout |
|
1794 |
||
1795 |
self groupSelectionWithLayout: true |
|
1796 |
! |
|
1797 |
||
1798 |
ungroup |
|
1799 |
||
1800 |
self ungroupSelectionWithLayout: false |
|
1801 |
! |
|
1802 |
||
1803 |
ungroupSelectionWithLayout: withLayout |
|
1804 |
||
1805 |
| canvas cS views specs frame view layout superView| |
|
1806 |
||
1807 |
canvas := self painter. |
|
1808 |
cS := canvas getSelectedViewsAndSpecs. |
|
1809 |
cS isNil ifTrue:[^self]. |
|
1810 |
views := cS first first subViews copy. |
|
1811 |
superView := cS first first superView. |
|
1812 |
cS last first component isNil ifTrue:[^self]. |
|
1813 |
cS last first component collection isEmpty ifTrue:[^self]. |
|
1834 | 1814 |
specs := cS last first component collection copy. |
1832 | 1815 |
frame := cS first first frame. |
1816 |
canvas deleteSelection. |
|
1817 |
withLayout ifFalse:[ |
|
1834 | 1818 |
1 to: specs size do:[:i| |
1819 |
view := views at: i. |
|
1820 |
layout := LayoutFrame leftFraction:0.0 offset: (view origin x + frame origin x) |
|
1821 |
rightFraction:0.0 offset: (view corner x + frame origin x + 1) |
|
1822 |
topFraction:0.0 offset: (view origin y + frame origin y ) |
|
1823 |
bottomFraction:0.0 offset: (view corner y + frame origin y + 1). |
|
1824 |
(specs at: i) layout: layout. |
|
1825 |
]. |
|
1826 |
]. |
|
1832 | 1827 |
canvas selection: superView. |
1828 |
canvas pasteSpecifications:specs keepLayout:true. |
|
1829 |
canvas selection: superView. |
|
1830 |
! |
|
1831 |
||
1832 |
ungroupWithLayout |
|
1833 |
||
1834 |
self ungroupSelectionWithLayout: true |
|
1835 |
! ! |
|
1836 |
||
60 | 1837 |
!UIPainterView methodsFor:'initialization'! |
1838 |
||
770 | 1839 |
create |
1959 | 1840 |
"colors on device" |
1841 |
||
770 | 1842 |
super create. |
1959 | 1843 |
handleColorBlack := handleColorBlack onDevice:device. |
1844 |
handleColorWhite := handleColorWhite onDevice:device. |
|
1201 | 1845 |
handleMasterColor := handleMasterColor onDevice:device. |
770 | 1846 |
! |
1847 |
||
60 | 1848 |
initialize |
62 | 1849 |
"setup attributes |
1850 |
" |
|
60 | 1851 |
super initialize. |
770 | 1852 |
superclassName := 'ApplicationModel'. |
1853 |
className := 'NewApplication'. |
|
1854 |
methodName := 'windowSpec'. |
|
1855 |
categoryName := 'Applications'. |
|
1856 |
HandCursor := Cursor leftHand. |
|
1467
b46624bb6994
use white handles, if the views background color is dark.
Claus Gittinger <cg@exept.de>
parents:
1450
diff
changeset
|
1857 |
handleColorBlack := Color black. |
b46624bb6994
use white handles, if the views background color is dark.
Claus Gittinger <cg@exept.de>
parents:
1450
diff
changeset
|
1858 |
handleColorWhite := Color white. |
770 | 1859 |
handleMasterColor := Color red. |
60 | 1860 |
|
712 | 1861 |
self backgroundColor: self class defaultViewBackgroundColor. |
60 | 1862 |
! |
1863 |
||
1864 |
setupFromSpec:specOrSpecArray |
|
2197
873c7b960233
slightly refactored to allow for more redefinition in a subclass
Claus Gittinger <cg@exept.de>
parents:
2195
diff
changeset
|
1865 |
|spec builder specWindow| |
60 | 1866 |
|
784 | 1867 |
Cursor wait showWhile: [ |
2197
873c7b960233
slightly refactored to allow for more redefinition in a subclass
Claus Gittinger <cg@exept.de>
parents:
2195
diff
changeset
|
1868 |
self removeAll. |
873c7b960233
slightly refactored to allow for more redefinition in a subclass
Claus Gittinger <cg@exept.de>
parents:
2195
diff
changeset
|
1869 |
specOrSpecArray notNil ifTrue:[ |
873c7b960233
slightly refactored to allow for more redefinition in a subclass
Claus Gittinger <cg@exept.de>
parents:
2195
diff
changeset
|
1870 |
spec := UISpecification from:specOrSpecArray. |
873c7b960233
slightly refactored to allow for more redefinition in a subclass
Claus Gittinger <cg@exept.de>
parents:
2195
diff
changeset
|
1871 |
]. |
873c7b960233
slightly refactored to allow for more redefinition in a subclass
Claus Gittinger <cg@exept.de>
parents:
2195
diff
changeset
|
1872 |
builder := UIBuilder new isEditing:true. |
873c7b960233
slightly refactored to allow for more redefinition in a subclass
Claus Gittinger <cg@exept.de>
parents:
2195
diff
changeset
|
1873 |
"set applicationClass, in order that subspecifications may be resolved" |
873c7b960233
slightly refactored to allow for more redefinition in a subclass
Claus Gittinger <cg@exept.de>
parents:
2195
diff
changeset
|
1874 |
className notNil ifTrue:[ |
873c7b960233
slightly refactored to allow for more redefinition in a subclass
Claus Gittinger <cg@exept.de>
parents:
2195
diff
changeset
|
1875 |
builder applicationClass:(self resolveName:className). |
873c7b960233
slightly refactored to allow for more redefinition in a subclass
Claus Gittinger <cg@exept.de>
parents:
2195
diff
changeset
|
1876 |
]. |
873c7b960233
slightly refactored to allow for more redefinition in a subclass
Claus Gittinger <cg@exept.de>
parents:
2195
diff
changeset
|
1877 |
spec notNil ifTrue:[ |
873c7b960233
slightly refactored to allow for more redefinition in a subclass
Claus Gittinger <cg@exept.de>
parents:
2195
diff
changeset
|
1878 |
specWindow := spec window. |
873c7b960233
slightly refactored to allow for more redefinition in a subclass
Claus Gittinger <cg@exept.de>
parents:
2195
diff
changeset
|
1879 |
]. |
873c7b960233
slightly refactored to allow for more redefinition in a subclass
Claus Gittinger <cg@exept.de>
parents:
2195
diff
changeset
|
1880 |
specWindow notNil ifTrue:[ |
873c7b960233
slightly refactored to allow for more redefinition in a subclass
Claus Gittinger <cg@exept.de>
parents:
2195
diff
changeset
|
1881 |
specWindow setupView:self topView for:builder. |
873c7b960233
slightly refactored to allow for more redefinition in a subclass
Claus Gittinger <cg@exept.de>
parents:
2195
diff
changeset
|
1882 |
self addSpec:(spec component) builder:builder in:self. |
873c7b960233
slightly refactored to allow for more redefinition in a subclass
Claus Gittinger <cg@exept.de>
parents:
2195
diff
changeset
|
1883 |
]. |
873c7b960233
slightly refactored to allow for more redefinition in a subclass
Claus Gittinger <cg@exept.de>
parents:
2195
diff
changeset
|
1884 |
self realizeAllSubViews. |
873c7b960233
slightly refactored to allow for more redefinition in a subclass
Claus Gittinger <cg@exept.de>
parents:
2195
diff
changeset
|
1885 |
specWindow notNil ifTrue:[ |
873c7b960233
slightly refactored to allow for more redefinition in a subclass
Claus Gittinger <cg@exept.de>
parents:
2195
diff
changeset
|
1886 |
treeView setAttributesFromWindowSpec:specWindow |
873c7b960233
slightly refactored to allow for more redefinition in a subclass
Claus Gittinger <cg@exept.de>
parents:
2195
diff
changeset
|
1887 |
]. |
1671 | 1888 |
]. |
223 | 1889 |
! |
1890 |
||
1891 |
treeView:aTreeView |
|
361 | 1892 |
treeView := aTreeView. |
1893 |
||
1894 |
treeView delegate:( |
|
1834 | 1895 |
"/ |
1896 |
"/ I want to handle everything typed |
|
1897 |
"/ in the treeView, except for Return and Cursor-keys |
|
1898 |
"/ |
|
1899 |
KeyboardForwarder |
|
1900 |
toView:self |
|
1901 |
condition:nil |
|
1902 |
filter:[:k | (k isSymbol |
|
1903 |
and:[k ~~ #Return |
|
1904 |
and:[k ~~ #Tab |
|
1905 |
and:[(k startsWith:#Cursor) not]]]) |
|
1906 |
] |
|
361 | 1907 |
) |
1908 |
||
376 | 1909 |
"Modified: / 31.10.1997 / 20:22:09 / cg" |
60 | 1910 |
! ! |
1911 |
||
1912 |
!UIPainterView methodsFor:'menus'! |
|
1913 |
||
121 | 1914 |
showMiddleButtonMenu |
2191 | 1915 |
"show the middle button menu; this returns nil" |
1635 | 1916 |
|
1917 |
|m| |
|
1918 |
||
223 | 1919 |
self enabled ifTrue:[ |
2191 | 1920 |
m := MenuPanel fromSpec:(UIPainter menuEdit) receiver:self superView application. |
1921 |
self startUpMenu:m |
|
111 | 1922 |
]. |
2191 | 1923 |
^ nil |
1924 |
||
1925 |
"Modified: / 31-10-2007 / 11:10:10 / cg" |
|
60 | 1926 |
! ! |
1927 |
||
1714 | 1928 |
!UIPainterView methodsFor:'private-handles'! |
754 | 1929 |
|
1832 | 1930 |
painter |
1931 |
^ treeView canvas |
|
1932 |
! |
|
1933 |
||
754 | 1934 |
showSelected:aComponent |
1935 |
"show object selected |
|
1936 |
" |
|
1543 | 1937 |
|wasClipped sel hColor bg| |
754 | 1938 |
|
1939 |
selectionHiddenLevel == 0 ifTrue:[ |
|
1834 | 1940 |
sel := treeView selection. |
1941 |
(sel size > 1 and: |
|
1942 |
[(treeView model list at: sel first) contents view == aComponent]) |
|
1943 |
ifTrue: [ |
|
1944 |
hColor := handleMasterColor |
|
1945 |
] ifFalse:[ |
|
1946 |
bg := aComponent viewBackground. |
|
1947 |
bg isColor ifTrue:[ |
|
1948 |
bg brightness < 0.5 ifTrue:[ |
|
1949 |
hColor := handleColorWhite |
|
1950 |
] ifFalse:[ |
|
1951 |
hColor := handleColorBlack |
|
1952 |
] |
|
1953 |
] ifFalse:[ |
|
1954 |
hColor := handleColorBlack |
|
1955 |
] |
|
1956 |
]. |
|
1957 |
||
1958 |
self paint:hColor. |
|
1959 |
||
1960 |
(wasClipped := clipChildren) ifTrue:[ |
|
1961 |
self clippedByChildren:(clipChildren := false). |
|
1962 |
]. |
|
1963 |
||
1964 |
self handlesOf:aComponent do:[:aRectangle :what| |l t w h| |
|
1965 |
l := aRectangle left + 1. |
|
1966 |
t := aRectangle top + 1. |
|
1967 |
w := aRectangle width - 2. |
|
1968 |
h := aRectangle height - 2. |
|
1969 |
||
1970 |
what == #view ifTrue:[self displayRectangleX:l y:t width:w height:h] |
|
1971 |
ifFalse:[self fillRectangleX:l y:t width:w height:h] |
|
1972 |
]. |
|
1973 |
||
1974 |
wasClipped ifTrue:[ |
|
1975 |
self clippedByChildren:(clipChildren := true). |
|
1976 |
] |
|
754 | 1977 |
] |
1543 | 1978 |
|
1979 |
"Modified: / 6.12.2001 / 00:00:16 / cg" |
|
754 | 1980 |
! ! |
1981 |
||
335 | 1982 |
!UIPainterView methodsFor:'queries'! |
1983 |
||
2276
485bda17023f
more changes to allow for non-class/selector (i.e. spec-only) use
Claus Gittinger <cg@exept.de>
parents:
2265
diff
changeset
|
1984 |
isEditingSpecOnly |
485bda17023f
more changes to allow for non-class/selector (i.e. spec-only) use
Claus Gittinger <cg@exept.de>
parents:
2265
diff
changeset
|
1985 |
self halt. |
485bda17023f
more changes to allow for non-class/selector (i.e. spec-only) use
Claus Gittinger <cg@exept.de>
parents:
2265
diff
changeset
|
1986 |
! |
485bda17023f
more changes to allow for non-class/selector (i.e. spec-only) use
Claus Gittinger <cg@exept.de>
parents:
2265
diff
changeset
|
1987 |
|
485bda17023f
more changes to allow for non-class/selector (i.e. spec-only) use
Claus Gittinger <cg@exept.de>
parents:
2265
diff
changeset
|
1988 |
isNotEditingSpecOnly |
485bda17023f
more changes to allow for non-class/selector (i.e. spec-only) use
Claus Gittinger <cg@exept.de>
parents:
2265
diff
changeset
|
1989 |
self halt. |
485bda17023f
more changes to allow for non-class/selector (i.e. spec-only) use
Claus Gittinger <cg@exept.de>
parents:
2265
diff
changeset
|
1990 |
! |
485bda17023f
more changes to allow for non-class/selector (i.e. spec-only) use
Claus Gittinger <cg@exept.de>
parents:
2265
diff
changeset
|
1991 |
|
335 | 1992 |
resolveName:aName |
1993 |
|appl| |
|
1994 |
||
1995 |
appl := self application. |
|
1996 |
||
1997 |
appl notNil ifTrue:[ |
|
1834 | 1998 |
^ appl resolveName:aName |
335 | 1999 |
]. |
2000 |
^ Smalltalk resolveName:aName inClass:self class |
|
2001 |
! ! |
|
2002 |
||
60 | 2003 |
!UIPainterView methodsFor:'removing components'! |
2004 |
||
78 | 2005 |
remove:anObject |
2006 |
"remove anObject from the contents do redraw |
|
60 | 2007 |
" |
134 | 2008 |
anObject notNil ifTrue:[ |
1834 | 2009 |
treeView removeView:anObject. |
134 | 2010 |
] |
60 | 2011 |
! |
2012 |
||
2013 |
removeAll |
|
62 | 2014 |
"remove all objects and properties |
2015 |
" |
|
776 | 2016 |
self select:nil. |
2017 |
treeView removeAll. |
|
2018 |
self removeUndoHistory. |
|
60 | 2019 |
! ! |
2020 |
||
2021 |
!UIPainterView methodsFor:'searching'! |
|
2022 |
||
285 | 2023 |
findContainerOfView:aView |
2024 |
"returns the super view assigned to a view |
|
89 | 2025 |
" |
285 | 2026 |
|p| |
89 | 2027 |
|
285 | 2028 |
(p := self propertyOfParentForView:aView) isNil ifTrue:[ |
1834 | 2029 |
^ self |
89 | 2030 |
]. |
285 | 2031 |
^ p view |
89 | 2032 |
! |
2033 |
||
60 | 2034 |
findObjectAt:aPoint |
2035 |
"find the origin/corner of the currentWidget |
|
2036 |
" |
|
285 | 2037 |
|view prop| |
60 | 2038 |
|
2039 |
view := super findObjectAt:aPoint. |
|
1870 | 2040 |
prop := self propertyOfView:view. |
60 | 2041 |
|
285 | 2042 |
prop notNil ifTrue:[^ prop view]. |
1870 | 2043 |
^ nil |
60 | 2044 |
! |
2045 |
||
2046 |
findViewWithId:aViewId |
|
62 | 2047 |
"finds view assigned to identifier and returns the view or nil |
60 | 2048 |
" |
2049 |
|prop| |
|
2050 |
||
2051 |
prop := self propertyOfIdentifier:aViewId. |
|
2052 |
||
2053 |
prop notNil ifTrue:[^ prop view] |
|
1834 | 2054 |
ifFalse:[^ nil] |
78 | 2055 |
! |
2056 |
||
2057 |
propertyOfIdentifier:anId |
|
2058 |
"returns property assigned to unique identifier |
|
2059 |
" |
|
2060 |
anId notNil ifTrue:[ |
|
1834 | 2061 |
^ treeView propertyDetect:[:p| p identifier == anId ] |
78 | 2062 |
]. |
2063 |
^ nil |
|
2064 |
! |
|
2065 |
||
2066 |
propertyOfName:aString |
|
2231 | 2067 |
"returns the property for a given widgets name (name in tree)" |
2068 |
||
111 | 2069 |
|name| |
2070 |
||
2071 |
aString isNil ifFalse:[ |
|
2231 | 2072 |
name := aString string withoutSeparators. |
2073 |
^ treeView propertyDetect:[:p| p name = name ]. |
|
78 | 2074 |
]. |
2075 |
^ nil |
|
2076 |
! |
|
2077 |
||
285 | 2078 |
propertyOfParentForView:aSubView |
2079 |
"returns the property of the parent or nil |
|
2080 |
" |
|
2081 |
|item| |
|
2082 |
||
1870 | 2083 |
(item := treeView detectItemCorespondingToView:aSubView) notNil ifTrue:[ |
2084 |
(item := item parent) notNil ifTrue:[^ item contents] |
|
285 | 2085 |
]. |
2086 |
^ nil |
|
2087 |
! |
|
2088 |
||
78 | 2089 |
propertyOfView:aView |
1870 | 2090 |
"detect the property for the argument, a view. The property of the view or |
285 | 2091 |
the first subview providing the properties is returned. If no property is detected |
2092 |
nil is returned. |
|
2093 |
" |
|
2094 |
|item| |
|
2095 |
||
1870 | 2096 |
item := treeView detectItemCorespondingToView:aView. |
285 | 2097 |
|
2098 |
(item notNil and:[item parent notNil]) ifTrue:[ |
|
1870 | 2099 |
^ item contents |
285 | 2100 |
]. |
2101 |
^ nil |
|
2102 |
! |
|
2103 |
||
111 | 2104 |
uniqueNameFor:aSpecOrString |
2231 | 2105 |
"generate and return a unique name for a specClass or an items name. |
2106 |
(unique name in the tree)" |
|
2107 |
||
2108 |
|maxUsedIndex name nameLen| |
|
2109 |
||
2110 |
name := aSpecOrString isString |
|
2111 |
ifFalse:[aSpecOrString userFriendlyName] |
|
2112 |
ifTrue:[aSpecOrString]. |
|
2113 |
||
2114 |
nameLen := name size. |
|
2115 |
maxUsedIndex := 0. |
|
78 | 2116 |
|
238 | 2117 |
treeView propertiesDo:[:p| |
2231 | 2118 |
|thisName| |
2119 |
||
2120 |
thisName := p name. |
|
2121 |
||
2122 |
(thisName size > nameLen and:[thisName startsWith:name]) ifTrue:[ |
|
2123 |
maxUsedIndex := maxUsedIndex max:(p extractNumberStartingAt:nameLen+1) |
|
2124 |
] |
|
78 | 2125 |
]. |
2231 | 2126 |
^ name, (maxUsedIndex+1) printString. |
78 | 2127 |
! |
2128 |
||
2129 |
uniqueNameOf:aView |
|
111 | 2130 |
|prop| |
78 | 2131 |
|
111 | 2132 |
(prop := self propertyOfView:aView) notNil ifTrue:[ |
1834 | 2133 |
prop name isNil ifTrue:[ |
2134 |
prop name:(self uniqueNameFor:(prop spec)). |
|
2135 |
]. |
|
2136 |
^ prop name |
|
78 | 2137 |
]. |
111 | 2138 |
^ 'self' |
78 | 2139 |
|
60 | 2140 |
! ! |
2141 |
||
223 | 2142 |
!UIPainterView methodsFor:'selection basics'! |
2143 |
||
2144 |
addToSelection:anObject |
|
2145 |
"add an object to the selection |
|
2146 |
" |
|
2147 |
(self enabled and:[(self isSelected:anObject) not]) ifTrue:[ |
|
2257
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
2148 |
selection isCollection ifFalse:[ |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
2149 |
selection isNil ifTrue:[ |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
2150 |
selection := anObject |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
2151 |
] ifFalse:[ |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
2152 |
selection := OrderedCollection with:selection with:anObject |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
2153 |
] |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
2154 |
] ifTrue:[ |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
2155 |
"/ to enforce the change-message (value is identical to oldValue) |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
2156 |
selection isList ifTrue:[ |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
2157 |
selection add:anObject |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
2158 |
] ifFalse:[ |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
2159 |
selection := selection asOrderedCollection. |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
2160 |
selection := selection copyWith:anObject |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
2161 |
] |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
2162 |
]. |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
2163 |
self showSelected:anObject. |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
2164 |
treeView canvasSelectionAdd:anObject. |
223 | 2165 |
] |
2166 |
||
1347
c4046d0b638e
care for multiSelect into a non-list;
Claus Gittinger <cg@exept.de>
parents:
1338
diff
changeset
|
2167 |
"Modified: / 11.2.2000 / 01:39:05 / cg" |
223 | 2168 |
! |
2169 |
||
2170 |
removeFromSelection:anObject |
|
2171 |
"remove an object from the selection |
|
2172 |
" |
|
2173 |
(self isSelected:anObject) ifTrue:[ |
|
2257
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
2174 |
self showUnselected:anObject. |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
2175 |
|
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
2176 |
selection size > 1 ifTrue:[ |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
2177 |
selection isList ifTrue:[ |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
2178 |
selection remove:anObject ifAbsent:nil |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
2179 |
] ifFalse:[ |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
2180 |
"/ to enforce the change-message (value is identical to oldValue) |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
2181 |
selection := selection asOrderedCollection. |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
2182 |
selection := selection copyWithout:anObject |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
2183 |
]. |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
2184 |
self showSelection. |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
2185 |
] ifFalse:[ |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
2186 |
selection := nil |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
2187 |
]. |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
2188 |
treeView canvasSelectionRemove:anObject. |
223 | 2189 |
] |
2190 |
||
1347
c4046d0b638e
care for multiSelect into a non-list;
Claus Gittinger <cg@exept.de>
parents:
1338
diff
changeset
|
2191 |
"Modified: / 11.2.2000 / 01:41:11 / cg" |
223 | 2192 |
! |
2193 |
||
2194 |
select:something |
|
2195 |
"change selection to something |
|
1834 | 2196 |
" |
2197 |
(self enabled and:[something ~= self selection]) ifTrue:[ |
|
2257
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
2198 |
something isNil |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
2199 |
ifTrue: [treeView selection: (Array with: 1)] |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
2200 |
ifFalse:[treeView canvasSelection:something]. |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
2201 |
self setSelection:something withRedraw:true |
223 | 2202 |
] |
2203 |
! |
|
2204 |
||
1830 | 2205 |
selectNextUpInHierarchy |
2206 |
| sel | |
|
2207 |
||
2208 |
(sel := self selection) isNil ifTrue:[^self]. |
|
2209 |
sel isCollection ifTrue:[ |
|
2257
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
2210 |
sel := self selection first. |
1830 | 2211 |
]. |
2212 |
sel := sel superView. |
|
2213 |
sel isNil ifTrue:[^self]. |
|
2257
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
2214 |
treeView canvasSelection: sel. |
1830 | 2215 |
self selection: sel. |
2216 |
! |
|
2217 |
||
285 | 2218 |
updateSelectionFromModel:aSelOrNil |
223 | 2219 |
"update selection from a new selection |
2220 |
" |
|
1427 | 2221 |
|list| |
768 | 2222 |
|
2180 | 2223 |
"/ do not return here if not shown - we NEED the correct selection |
223 | 2224 |
selectionHiddenLevel == 0 ifTrue:[ |
2039 | 2225 |
aSelOrNil size ~~ 0 ifTrue:[ |
2226 |
list := OrderedCollection new. |
|
2227 |
||
2228 |
self selectionDo:[:el| |
|
2229 |
(aSelOrNil includes:el) ifFalse:[list add:el] |
|
2230 |
]. |
|
2180 | 2231 |
self shown ifTrue:[self showUnselected:list]. |
2039 | 2232 |
] ifFalse:[ |
2180 | 2233 |
self shown ifTrue:[self hideSelection]. |
2039 | 2234 |
] |
223 | 2235 |
]. |
285 | 2236 |
self setSelection:aSelOrNil withRedraw:false. |
2180 | 2237 |
self shown ifTrue:[ self showSelection ]. |
223 | 2238 |
! ! |
2239 |
||
78 | 2240 |
!UIPainterView methodsFor:'specification'! |
2241 |
||
2242 |
addSpec:aSpecification builder:aBuilder in:aFrame |
|
2243 |
"build view and subviews from aSpecification into a frame. The top view |
|
2244 |
is returned. The contained components of a spec are set to nil |
|
2245 |
" |
|
330 | 2246 |
|cls| |
212 | 2247 |
|
330 | 2248 |
cls := self resolveName:className. |
2249 |
||
2250 |
cls notNil ifTrue:[ |
|
2226 | 2251 |
aBuilder applicationClass:cls. |
212 | 2252 |
]. |
78 | 2253 |
|
2229 | 2254 |
"/ remember view<->spec associations to tree |
2255 |
aBuilder componentCreationHook:[:aView :aSpec :builder| |
|
2231 | 2256 |
|newProperty copyOfSpec nameOfSpec| |
2257 |
||
2258 |
newProperty := ViewProperty new. |
|
2259 |
copyOfSpec := aSpec copy. |
|
2260 |
newProperty spec:copyOfSpec. |
|
2261 |
newProperty view:aView. |
|
2226 | 2262 |
|
2229 | 2263 |
"/ break refs to child-specs |
2264 |
"/ (not needed, as we keep the child info in the view hierarchy) |
|
2231 | 2265 |
copyOfSpec class supportsSubComponents ifTrue:[ |
2266 |
copyOfSpec component:nil |
|
2226 | 2267 |
]. |
2268 |
||
2231 | 2269 |
nameOfSpec := copyOfSpec name. |
2270 |
||
2271 |
(nameOfSpec isNil or:[(self propertyOfName:nameOfSpec) notNil]) ifTrue:[ |
|
2272 |
copyOfSpec name:(self uniqueNameFor:copyOfSpec) |
|
2226 | 2273 |
]. |
2231 | 2274 |
treeView addProperty:newProperty. |
78 | 2275 |
]. |
2276 |
^ aSpecification buildViewWithLayoutFor:aBuilder in:aFrame. |
|
60 | 2277 |
|
212 | 2278 |
"Modified: 4.7.1997 / 23:48:55 / cg" |
78 | 2279 |
! |
2280 |
||
2281 |
fullSpecFor:anObject |
|
2282 |
"generate a full spec for an object |
|
62 | 2283 |
" |
78 | 2284 |
|mySpec subSpecs| |
2285 |
||
2286 |
mySpec := self specFor:anObject. |
|
2287 |
||
2288 |
(mySpec notNil and:[mySpec class supportsSubComponents]) ifTrue:[ |
|
1834 | 2289 |
(anObject subViews notNil) ifTrue:[ |
2290 |
anObject subViews do:[:aSubView||spec| |
|
2291 |
spec := self fullSpecFor:aSubView. |
|
2292 |
spec notNil ifTrue:[ |
|
2293 |
subSpecs isNil ifTrue:[ |
|
2294 |
subSpecs := OrderedCollection new |
|
2295 |
]. |
|
2296 |
subSpecs add:spec. |
|
2297 |
]. |
|
2298 |
]. |
|
2299 |
subSpecs notNil ifTrue:[ |
|
2300 |
mySpec component:(SpecCollection new collection:subSpecs) |
|
2301 |
] |
|
2302 |
] |
|
78 | 2303 |
]. |
2304 |
^ mySpec |
|
2305 |
||
60 | 2306 |
|
2307 |
||
2308 |
||
2309 |
||
2310 |
||
2311 |
! |
|
2312 |
||
1173 | 2313 |
rebuildView:aView fromSpec:aSpec withBuilder:aBuilderOrNil |
2257
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
2314 |
self |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
2315 |
rebuildView:aView fromSpec:aSpec withBuilder:aBuilderOrNil forceNewView:false |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
2316 |
! |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
2317 |
|
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
2318 |
rebuildView:aView fromSpec:aSpec withBuilder:aBuilderOrNil forceNewView:forceNewView |
1173 | 2319 |
|v builder| |
2320 |
||
2321 |
(builder := aBuilderOrNil) isNil ifTrue:[ |
|
2257
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
2322 |
"/ create a dummy builder |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
2323 |
builder := UIBuilder new isEditing:true. |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
2324 |
className notNil ifTrue:[ |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
2325 |
builder applicationClass:(self resolveName:className). |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
2326 |
]. |
1173 | 2327 |
]. |
285 | 2328 |
|
1252
f886528c2b35
when changing a layoutContainer
Claus Gittinger <cg@exept.de>
parents:
1230
diff
changeset
|
2329 |
aSpec class isLayoutContainer ifTrue:[ |
2257
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
2330 |
"/ TODO: |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
2331 |
"/ go through subviews and let them resize to their default/preferred |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
2332 |
"/ needed if we change a containers layout from fit to non-fit. |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
2333 |
|
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
2334 |
(aView subViews ? #()) do:[:aSubView | |
2265 | 2335 |
|fix spec prop container| |
2257
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
2336 |
|
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
2337 |
(prop := self propertyOfView:aSubView) notNil ifTrue:[ |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
2338 |
spec := prop spec. |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
2339 |
|
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
2340 |
spec useDefaultExtent ifTrue:[ |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
2341 |
fix := aSubView sizeFixed:false. |
2265 | 2342 |
aView class == VerticalPanelView ifTrue:[ |
2343 |
aSubView height:aSubView preferredExtent y. |
|
2344 |
] ifFalse:[ |
|
2345 |
aView class == HorizontalPanelView ifTrue:[ |
|
2346 |
aSubView width:aSubView preferredExtent x. |
|
2347 |
] ifFalse:[ |
|
2348 |
aSubView extent:aSubView preferredExtent. |
|
2349 |
]. |
|
2350 |
]. |
|
2257
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
2351 |
aSubView sizeFixed:fix |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
2352 |
] |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
2353 |
] |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
2354 |
]. |
1252
f886528c2b35
when changing a layoutContainer
Claus Gittinger <cg@exept.de>
parents:
1230
diff
changeset
|
2355 |
]. |
f886528c2b35
when changing a layoutContainer
Claus Gittinger <cg@exept.de>
parents:
1230
diff
changeset
|
2356 |
|
2257
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
2357 |
(forceNewView or:[aSpec needsRebuildForAttributes]) ifTrue:[ |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
2358 |
"/ needs a full rebuild (in case view class depends upon spec-attribute) |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
2359 |
v := aSpec buildViewWithLayoutFor:builder in:(self findContainerOfView:aView). |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
2360 |
v realize. |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
2361 |
aView destroy. |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
2362 |
device sync. |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
2363 |
device flush. |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
2364 |
aView becomeSameAs:v. |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
2365 |
"/ inputView raise. |
285 | 2366 |
] ifFalse:[ |
2257
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
2367 |
aSpec setAttributesIn:aView with:builder. |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
2368 |
self elementChangedSize:aView. |
285 | 2369 |
]. |
2370 |
! |
|
2371 |
||
78 | 2372 |
specFor:anObject |
2373 |
"returns spec assigned to an object |
|
62 | 2374 |
" |
78 | 2375 |
|prop spec| |
60 | 2376 |
|
1744
c59a91953b64
paste with no container selected: search for a good one
Claus Gittinger <cg@exept.de>
parents:
1733
diff
changeset
|
2377 |
(prop := self propertyOfView:anObject) isNil ifTrue:[^ nil]. |
c59a91953b64
paste with no container selected: search for a good one
Claus Gittinger <cg@exept.de>
parents:
1733
diff
changeset
|
2378 |
spec := prop spec copy. |
c59a91953b64
paste with no container selected: search for a good one
Claus Gittinger <cg@exept.de>
parents:
1733
diff
changeset
|
2379 |
spec layoutFromView:anObject. |
78 | 2380 |
^ spec |
60 | 2381 |
! |
2382 |
||
146 | 2383 |
specForSelection |
2384 |
"returns spec assigned to current single selection or nil |
|
2385 |
" |
|
2386 |
^ self specFor:(self singleSelection) |
|
2387 |
||
2388 |
||
2389 |
! |
|
2390 |
||
78 | 2391 |
updateFromSpec:aSpec |
2392 |
"update current selected view from specification |
|
62 | 2393 |
" |
1173 | 2394 |
|props name| |
78 | 2395 |
|
281 | 2396 |
aSpec class == WindowSpec ifTrue:[ |
1834 | 2397 |
^ treeView canvasSpec:aSpec |
281 | 2398 |
]. |
2399 |
||
78 | 2400 |
self singleSelection notNil ifTrue:[ |
1834 | 2401 |
self withSelectionHiddenDo:[ |
2402 |
self transaction:#specification selectionDo:[:aView| |
|
2403 |
props := self propertyOfView:aView. |
|
2404 |
name := (aSpec name) withoutSeparators. |
|
2405 |
||
2406 |
name = props name ifFalse:[ |
|
2407 |
(self propertyOfName:name) notNil ifTrue:[ |
|
2408 |
name := props name |
|
2409 |
] |
|
2410 |
]. |
|
2411 |
||
2412 |
aSpec name:name. |
|
2413 |
self createUndoSpecModify:props. |
|
2414 |
self rebuildView:aView fromSpec:aSpec withBuilder:nil. |
|
2415 |
props spec:(aSpec copy). |
|
2416 |
treeView propertyChanged:props. |
|
2417 |
] |
|
2418 |
] |
|
82 | 2419 |
] |
212 | 2420 |
|
1520
eb77c52704c7
drop: paste in surrounding view if not possible to drop in selected.
Claus Gittinger <cg@exept.de>
parents:
1500
diff
changeset
|
2421 |
"Modified: / 30.10.2001 / 13:59:45 / cg" |
60 | 2422 |
! ! |
2423 |
||
285 | 2424 |
!UIPainterView methodsFor:'testing'! |
2425 |
||
2426 |
canChangeLayoutOfView:aView |
|
2427 |
"returns true if the view can change its layout which is dependant on |
|
2428 |
its parent view. |
|
2429 |
" |
|
2430 |
|item prnt| |
|
2431 |
||
2432 |
( (item := treeView itemOfView:aView) isNil |
|
2433 |
or:[(prnt := item parent) isNil] |
|
2434 |
) ifTrue:[ |
|
1834 | 2435 |
^ false |
285 | 2436 |
]. |
2437 |
^ (prnt parent isNil or:[prnt contents spec class isLayoutContainer not]) |
|
2438 |
! |
|
2439 |
||
1230
23e5d0c133e8
added exchangeLayouts function
Claus Gittinger <cg@exept.de>
parents:
1225
diff
changeset
|
2440 |
canExchangeSelectionLayouts |
23e5d0c133e8
added exchangeLayouts function
Claus Gittinger <cg@exept.de>
parents:
1225
diff
changeset
|
2441 |
"returns true if the selection size is exactly 2 |
23e5d0c133e8
added exchangeLayouts function
Claus Gittinger <cg@exept.de>
parents:
1225
diff
changeset
|
2442 |
and all elements in the selection can be moved or aligned |
23e5d0c133e8
added exchangeLayouts function
Claus Gittinger <cg@exept.de>
parents:
1225
diff
changeset
|
2443 |
" |
23e5d0c133e8
added exchangeLayouts function
Claus Gittinger <cg@exept.de>
parents:
1225
diff
changeset
|
2444 |
selection size == 2 ifFalse:[ |
1834 | 2445 |
^ false |
1230
23e5d0c133e8
added exchangeLayouts function
Claus Gittinger <cg@exept.de>
parents:
1225
diff
changeset
|
2446 |
]. |
23e5d0c133e8
added exchangeLayouts function
Claus Gittinger <cg@exept.de>
parents:
1225
diff
changeset
|
2447 |
^ self canMoveOrAlignSelection |
23e5d0c133e8
added exchangeLayouts function
Claus Gittinger <cg@exept.de>
parents:
1225
diff
changeset
|
2448 |
|
23e5d0c133e8
added exchangeLayouts function
Claus Gittinger <cg@exept.de>
parents:
1225
diff
changeset
|
2449 |
! |
23e5d0c133e8
added exchangeLayouts function
Claus Gittinger <cg@exept.de>
parents:
1225
diff
changeset
|
2450 |
|
285 | 2451 |
canKeepLayoutInSelection |
2452 |
"returns true if layout can be kept during a paste operation |
|
2453 |
" |
|
2454 |
|prop| |
|
2455 |
||
2456 |
prop := self propertyOfView:(self singleSelection). |
|
2457 |
^ (prop isNil or:[prop spec class isLayoutContainer not]) |
|
2458 |
! |
|
2459 |
||
2460 |
canMove:something |
|
2461 |
"checks whether something is not nil and if all widgets derived from |
|
2462 |
something can change their layout ( move, align, ... operation ). |
|
2463 |
" |
|
2464 |
something notNil ifTrue:[ |
|
1834 | 2465 |
self forEach:something do:[:aView| |
2466 |
(self canChangeLayoutOfView:aView) ifFalse:[^ false] |
|
2467 |
]. |
|
2468 |
^ true |
|
285 | 2469 |
]. |
2470 |
^ false |
|
2471 |
! |
|
2472 |
||
2473 |
canMoveOrAlignSelection |
|
2474 |
"returns true if a selection exists and all elements in the selection |
|
2475 |
can be moved or aligned |
|
2476 |
" |
|
2477 |
^ self canMove:(self selection) |
|
2478 |
||
2479 |
! ! |
|
2480 |
||
60 | 2481 |
!UIPainterView methodsFor:'transaction'! |
2482 |
||
2483 |
transaction:aType objects:something do:aOneArgBlock |
|
2484 |
"opens a transaction and evaluates a block within the transaction; the |
|
2485 |
argument to the block is a view from derived from something |
|
2486 |
" |
|
134 | 2487 |
self withinTransaction:aType objects:something do:[ |
1834 | 2488 |
self forEach:something do:aOneArgBlock |
60 | 2489 |
] |
2490 |
! |
|
2491 |
||
1954 | 2492 |
withinTransaction:aType objects:objects do:aNoArgBlock |
134 | 2493 |
"evaluate a block with no arguments within a transaction |
60 | 2494 |
" |
134 | 2495 |
|text size prop| |
2496 |
||
2497 |
objects isNil ifTrue:[ ^ self ]. |
|
2498 |
||
2499 |
size := objects size. |
|
60 | 2500 |
|
134 | 2501 |
objects isCollection ifTrue:[ |
1954 | 2502 |
size == 0 ifTrue:[ ^ self ]. |
2503 |
size == 1 ifTrue:[ prop := self propertyOfView:(objects first) ] |
|
134 | 2504 |
] ifFalse:[ |
1954 | 2505 |
prop := self propertyOfView:objects |
134 | 2506 |
]. |
60 | 2507 |
|
134 | 2508 |
prop notNil ifTrue:[ |
1954 | 2509 |
text := prop name |
134 | 2510 |
] ifFalse:[ |
1954 | 2511 |
text := size printString, ' elements' |
60 | 2512 |
]. |
134 | 2513 |
|
1954 | 2514 |
undoHistory withinTransaction:aType text:text do:aNoArgBlock. |
2515 |
self undoHistoryChanged. |
|
60 | 2516 |
! ! |
2517 |
||
2518 |
!UIPainterView methodsFor:'undo actions'! |
|
2519 |
||
134 | 2520 |
createUndoLayout:aView |
2521 |
"create undo action before changing a views layout |
|
60 | 2522 |
" |
134 | 2523 |
|lyt args prop| |
60 | 2524 |
|
2525 |
undoHistory isTransactionOpen ifTrue:[ |
|
1954 | 2526 |
prop := self propertyOfView:aView. |
2527 |
||
2528 |
prop notNil ifTrue:[ |
|
2529 |
args := Array new:3. |
|
2530 |
args at:1 put:(prop identifier). |
|
2531 |
||
2532 |
(lyt := aView geometryLayout) notNil ifTrue:[ |
|
2533 |
args at:2 put:#geometryLayout: |
|
2534 |
] ifFalse:[ |
|
2535 |
lyt := aView extent. |
|
2536 |
args at:2 put:#extent: |
|
2537 |
]. |
|
2538 |
args at:3 put:(lyt copy). |
|
2539 |
undoHistory addUndoSelector:#undoLayout: withArgs:args. |
|
2540 |
self undoHistoryChanged. |
|
2541 |
] |
|
60 | 2542 |
] |
2543 |
! |
|
2544 |
||
134 | 2545 |
createUndoRemove:aView |
2546 |
"create undo method before deleting views |
|
60 | 2547 |
" |
285 | 2548 |
|prop pid| |
134 | 2549 |
|
2550 |
(prop := self propertyOfView:aView) notNil ifTrue:[ |
|
1954 | 2551 |
(pid := self propertyOfParentForView:aView) notNil ifTrue:[ |
2552 |
pid := pid identifier |
|
2553 |
]. |
|
2554 |
||
2555 |
undoHistory addUndoSelector:#undoRemove: |
|
2556 |
withArgs:(Array with:(self fullSpecFor:aView) |
|
2557 |
with:(prop identifier) |
|
2558 |
with:pid). |
|
2559 |
self undoHistoryChanged. |
|
134 | 2560 |
] |
2561 |
! |
|
60 | 2562 |
|
134 | 2563 |
createUndoSpecModify:aProp |
2564 |
"undo method when changing the specification for an object |
|
2565 |
" |
|
2566 |
aProp notNil ifTrue:[ |
|
1954 | 2567 |
undoHistory addUndoSelector:#undoSpecModify: |
2568 |
withArgs:(Array with:(aProp spec) with:(aProp identifier)). |
|
2569 |
self undoHistoryChanged. |
|
134 | 2570 |
] |
2571 |
! |
|
60 | 2572 |
|
134 | 2573 |
undoCreate:something |
2574 |
"undo method for creating or pasting an object |
|
2575 |
" |
|
2576 |
self forEach:something do:[:anId|self remove:(self findViewWithId:anId)]. |
|
2577 |
! |
|
60 | 2578 |
|
1520
eb77c52704c7
drop: paste in surrounding view if not possible to drop in selected.
Claus Gittinger <cg@exept.de>
parents:
1500
diff
changeset
|
2579 |
undoHistory |
eb77c52704c7
drop: paste in surrounding view if not possible to drop in selected.
Claus Gittinger <cg@exept.de>
parents:
1500
diff
changeset
|
2580 |
^ undoHistory |
eb77c52704c7
drop: paste in surrounding view if not possible to drop in selected.
Claus Gittinger <cg@exept.de>
parents:
1500
diff
changeset
|
2581 |
|
eb77c52704c7
drop: paste in surrounding view if not possible to drop in selected.
Claus Gittinger <cg@exept.de>
parents:
1500
diff
changeset
|
2582 |
"Created: / 30.10.2001 / 13:42:45 / cg" |
eb77c52704c7
drop: paste in surrounding view if not possible to drop in selected.
Claus Gittinger <cg@exept.de>
parents:
1500
diff
changeset
|
2583 |
! |
eb77c52704c7
drop: paste in surrounding view if not possible to drop in selected.
Claus Gittinger <cg@exept.de>
parents:
1500
diff
changeset
|
2584 |
|
134 | 2585 |
undoLayout:args |
2586 |
"undo method to set the old layout; see 'createUndoLayout:' |
|
2587 |
" |
|
2588 |
|view| |
|
2589 |
||
2590 |
(view := self findViewWithId:(args at:1)) notNil ifTrue:[ |
|
1834 | 2591 |
view perform:(args at:2) with:(args at:3). |
2592 |
self layoutChanged. |
|
60 | 2593 |
] |
2594 |
! |
|
2595 |
||
134 | 2596 |
undoRemove:args |
2597 |
"undo method when removing an object; see 'createUndoRemove:' |
|
2598 |
" |
|
2599 |
|frame prop view| |
|
2600 |
||
2601 |
(args at:3) notNil ifTrue:[ |
|
1834 | 2602 |
frame := self findViewWithId:(args at:3). |
134 | 2603 |
]. |
2604 |
frame isNil ifTrue:[ |
|
1834 | 2605 |
frame := self |
134 | 2606 |
]. |
395 | 2607 |
view := self addSpec:(args at:1) builder:(UIBuilder new isEditing:true) in:frame. |
134 | 2608 |
view realize. |
2609 |
||
2610 |
prop := self propertyOfView:view. |
|
2611 |
prop identifier:(args at:2). |
|
2612 |
! |
|
2613 |
||
2614 |
undoSpecModify:args |
|
2615 |
"undo method when changing a spec; see 'createUndoSpecModify:' |
|
60 | 2616 |
" |
1173 | 2617 |
|view spec props| |
60 | 2618 |
|
134 | 2619 |
props := self propertyOfIdentifier:(args at:2). |
60 | 2620 |
|
134 | 2621 |
props notNil ifTrue:[ |
1834 | 2622 |
view := props view. |
2623 |
spec := args at:1. |
|
2624 |
||
2625 |
props spec:spec. |
|
2626 |
self rebuildView:view fromSpec:spec withBuilder:nil. |
|
2627 |
treeView propertyChanged:props. |
|
211 | 2628 |
] |
2629 |
! ! |
|
2630 |
||
2631 |
!UIPainterView::ViewProperty class methodsFor:'instance creation'! |
|
2632 |
||
2633 |
new |
|
2634 |
Identifier notNil ifTrue:[Identifier := Identifier + 1] |
|
1834 | 2635 |
ifFalse:[Identifier := 1]. |
211 | 2636 |
|
2637 |
^ self basicNew initialize |
|
2638 |
! ! |
|
2639 |
||
2640 |
!UIPainterView::ViewProperty methodsFor:'accessing'! |
|
2641 |
||
2642 |
identifier |
|
2643 |
"return the unique identifier assigned to property |
|
2644 |
" |
|
2645 |
^ identifier |
|
2646 |
! |
|
2647 |
||
2648 |
identifier:anIdentifier |
|
2649 |
"set the unique identifier assigned to property; called after an restore of |
|
2650 |
a deleted instance |
|
2651 |
" |
|
2652 |
identifier := anIdentifier |
|
2653 |
! |
|
2654 |
||
2655 |
spec |
|
2656 |
"return the value of the instance variable 'spec' (automatically generated)" |
|
2657 |
||
1427 | 2658 |
^ spec |
2659 |
! |
|
211 | 2660 |
|
2661 |
spec:something |
|
2662 |
"set the value of the instance variable 'spec' (automatically generated)" |
|
2663 |
||
1427 | 2664 |
spec := something. |
2665 |
! |
|
211 | 2666 |
|
2667 |
view |
|
2668 |
"return the value of the instance variable 'view' (automatically generated)" |
|
2669 |
||
1427 | 2670 |
^ view |
2671 |
! |
|
211 | 2672 |
|
2673 |
view:something |
|
2674 |
"set the value of the instance variable 'view' (automatically generated)" |
|
2675 |
||
1427 | 2676 |
view := something. |
2677 |
! ! |
|
211 | 2678 |
|
2679 |
!UIPainterView::ViewProperty methodsFor:'initialization'! |
|
2680 |
||
2681 |
initialize |
|
2682 |
super initialize. |
|
2683 |
identifier := Identifier |
|
2684 |
! ! |
|
2685 |
||
2686 |
!UIPainterView::ViewProperty methodsFor:'misc'! |
|
2687 |
||
2688 |
extractNumberStartingAt:anIndex |
|
2231 | 2689 |
"return the number from the name starting at anIndex (or 0 if there is no number)." |
2690 |
||
2691 |
"/ cg: code cleanup. |
|
2692 |
^ Integer |
|
2693 |
readFrom:(self name readStream skip:(anIndex-1)) |
|
2694 |
onError:0 |
|
2695 |
||
2696 |
"/ |val| |
|
2697 |
"/ |
|
2698 |
"/ val := 0. |
|
2699 |
"/ |
|
2700 |
"/ self name from:anIndex do:[:c| |
|
2701 |
"/ c isDigit ifTrue:[val := val * 10 + c digitValue] |
|
2702 |
"/ ifFalse:[^ 0] |
|
2703 |
"/ ]. |
|
2704 |
"/ ^ val |
|
2705 |
||
211 | 2706 |
" |
2231 | 2707 |
(self basicNew spec:(ButtonSpec new name:'button12')) extractNumberStartingAt:7 |
2708 |
" |
|
211 | 2709 |
! ! |
2710 |
||
2711 |
!UIPainterView::ViewProperty methodsFor:'spec messages'! |
|
2712 |
||
2713 |
doesNotUnderstand:aMessage |
|
2714 |
spec notNil ifTrue:[ |
|
1834 | 2715 |
(spec respondsTo:(aMessage selector)) ifTrue:[^ aMessage sendTo:spec] |
211 | 2716 |
]. |
2717 |
^ nil |
|
2718 |
! |
|
2719 |
||
2720 |
layout |
|
1664 | 2721 |
^ spec layout |
211 | 2722 |
! |
2723 |
||
2724 |
layout:aLayout |
|
2725 |
spec layout:aLayout |
|
2726 |
! |
|
2727 |
||
2728 |
name |
|
2729 |
^ spec name |
|
2730 |
! |
|
2731 |
||
2732 |
name:aName |
|
2733 |
spec name:aName |
|
2734 |
! ! |
|
2735 |
||
60 | 2736 |
!UIPainterView class methodsFor:'documentation'! |
2737 |
||
2738 |
version |
|
2739 |
^ '$Header$' |
|
2740 |
! ! |
|
1621
112670159075
cg: check if selection change is allowed BEFORE changing the
tm
parents:
1574
diff
changeset
|
2741 |
|
1225 | 2742 |
UIPainterView initialize! |