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