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