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