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