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