author | Claus Gittinger <cg@exept.de> |
Thu, 17 Feb 2000 16:01:27 +0100 | |
changeset 1361 | 9020214f03e6 |
parent 1358 | c0116e25a2ac |
child 1362 | b710bba663cb |
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. |
1030
0b9fbaecbe88
output a warning on the transcript, when an aspect method
Claus Gittinger <cg@exept.de>
parents:
1029
diff
changeset
|
811 |
] ifTrue:[ |
0b9fbaecbe88
output a warning on the transcript, when an aspect method
Claus Gittinger <cg@exept.de>
parents:
1029
diff
changeset
|
812 |
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
|
813 |
]. |
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
814 |
]. |
62 | 815 |
]. |
816 |
||
1361
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
817 |
"/ for each aspect, generate getter (if not yet implemented) |
698 | 818 |
self generateCodeFrom:(aProp spec aspectSelectors) in:cls |
819 |
do:[:aSel| |
|
858
6b2e9e31cf06
do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents:
796
diff
changeset
|
820 |
|sym| |
6b2e9e31cf06
do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents:
796
diff
changeset
|
821 |
|
6b2e9e31cf06
do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents:
796
diff
changeset
|
822 |
sym := aSel asSymbol. |
6b2e9e31cf06
do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents:
796
diff
changeset
|
823 |
(definedMethodSelectors includes:sym) ifFalse:[ |
6b2e9e31cf06
do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents:
796
diff
changeset
|
824 |
thisCode := (self generateAspectMethodFor:aSel spec:protoSpec inClass:cls). |
6b2e9e31cf06
do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents:
796
diff
changeset
|
825 |
code := code , thisCode. |
6b2e9e31cf06
do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents:
796
diff
changeset
|
826 |
definedMethodSelectors add:sym. |
6b2e9e31cf06
do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents:
796
diff
changeset
|
827 |
] |
698 | 828 |
]. |
829 |
||
1361
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
830 |
"/ exported aspects - need setter methods |
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
831 |
exportSels := (treeView exportedAspects ? #()) collect:[:entry | (entry subAspect , ':') asSymbol]. |
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
832 |
self generateCodeFrom:exportSels in:cls |
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
833 |
do:[:aSel| |
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
834 |
|sym aspect| |
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
835 |
|
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
836 |
sym := aSel asSymbol. |
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
837 |
(definedMethodSelectors includes:sym) ifFalse:[ |
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
838 |
aspect := (aSel copyWithoutLast:1) asSymbol. |
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
839 |
thisCode := (self generateAspectSetMethodFor:aspect spec:protoSpec inClass:cls). |
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
840 |
code := code , thisCode. |
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
841 |
definedMethodSelectors add:sym. |
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
842 |
] |
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
843 |
]. |
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
844 |
|
698 | 845 |
self generateCodeFrom:(aProp spec actionSelectors) in:cls |
846 |
do:[:aSel| |
|
858
6b2e9e31cf06
do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents:
796
diff
changeset
|
847 |
|sym| |
6b2e9e31cf06
do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents:
796
diff
changeset
|
848 |
|
6b2e9e31cf06
do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents:
796
diff
changeset
|
849 |
sym := aSel asSymbol. |
6b2e9e31cf06
do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents:
796
diff
changeset
|
850 |
(definedMethodSelectors includes:sym) ifFalse:[ |
6b2e9e31cf06
do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents:
796
diff
changeset
|
851 |
thisCode := (self generateActionMethodFor:aSel spec:protoSpec inClass:cls). |
6b2e9e31cf06
do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents:
796
diff
changeset
|
852 |
code := code , thisCode. |
6b2e9e31cf06
do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents:
796
diff
changeset
|
853 |
definedMethodSelectors add:sym. |
6b2e9e31cf06
do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents:
796
diff
changeset
|
854 |
] |
698 | 855 |
]. |
856 |
||
857 |
self generateCodeFrom:(aProp spec valueSelectors) in:cls |
|
858 |
do:[:aSel| |
|
858
6b2e9e31cf06
do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents:
796
diff
changeset
|
859 |
|sym| |
6b2e9e31cf06
do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents:
796
diff
changeset
|
860 |
|
6b2e9e31cf06
do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents:
796
diff
changeset
|
861 |
sym := aSel asSymbol. |
6b2e9e31cf06
do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents:
796
diff
changeset
|
862 |
(definedMethodSelectors includes:sym) ifFalse:[ |
6b2e9e31cf06
do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents:
796
diff
changeset
|
863 |
"/ uppercase: - assume its a globals name. |
6b2e9e31cf06
do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents:
796
diff
changeset
|
864 |
aSel first isUppercase ifFalse:[ |
6b2e9e31cf06
do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents:
796
diff
changeset
|
865 |
thisCode := (self generateValueMethodFor:aSel spec:protoSpec inClass:cls). |
6b2e9e31cf06
do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents:
796
diff
changeset
|
866 |
code := code , thisCode. |
6b2e9e31cf06
do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents:
796
diff
changeset
|
867 |
definedMethodSelectors add:sym. |
6b2e9e31cf06
do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents:
796
diff
changeset
|
868 |
] |
376 | 869 |
] |
698 | 870 |
]. |
316 | 871 |
]. |
872 |
||
925
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
873 |
AspectsAsInstances ifTrue:[ |
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
874 |
iVars := cls instVarNames asOrderedCollection. |
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
875 |
definedMethodSelectors do:[:ivar | |
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
876 |
(iVars includes:ivar) ifFalse:[ |
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
877 |
iVars add:ivar |
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
878 |
] |
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
879 |
]. |
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
880 |
iVars := iVars asArray. |
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
881 |
t := cls shallowCopy. |
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
882 |
t setInstanceVariableString:iVars asStringCollection asString. |
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
883 |
code := (t definition) , '!!\' withCRs , code. |
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
884 |
]. |
352 | 885 |
^ code |
698 | 886 |
|
925
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
887 |
"Modified: / 29.7.1998 / 12:21:19 / cg" |
698 | 888 |
! |
889 |
||
1358 | 890 |
generateAspectSelectorsMethod |
891 |
"generate aspectSelectors method. |
|
892 |
Return a string ready to compile into the application class." |
|
893 |
||
894 |
|cls code spec| |
|
895 |
||
896 |
className isNil ifTrue:[ |
|
897 |
self warn:'Set first the class!!'. |
|
898 |
^ nil |
|
899 |
]. |
|
900 |
||
901 |
(cls := self resolveName:className) isNil ifTrue:[ |
|
902 |
self warn:'Class ', className asString, ' does not exist!!'. |
|
903 |
^ nil |
|
904 |
]. |
|
905 |
spec := treeView exportedAspects. |
|
906 |
spec size == 0 ifTrue:[^ nil]. |
|
907 |
||
908 |
"/ make it an array ... |
|
909 |
spec := spec collect:[:entry | |
|
910 |
entry type isNil ifTrue:[ |
|
911 |
entry subAspect |
|
912 |
] ifFalse:[ |
|
913 |
Array with:entry subAspect with:entry type |
|
914 |
]. |
|
915 |
]. |
|
916 |
spec := spec asArray. |
|
917 |
||
918 |
code := '!!' , cls name , ' class methodsFor:''plugIn spec''!!\\' . |
|
919 |
||
920 |
code := code , 'aspectSelectors |
|
921 |
"This resource specification was automatically generated |
|
922 |
by the UIPainter of ST/X." |
|
923 |
||
924 |
"Do not manually edit this. If it is corrupted, |
|
925 |
the UIPainter may not be able to read the specification." |
|
926 |
||
927 |
"Return a description of exported aspects; |
|
928 |
these can be connected to aspects of an embedding application |
|
929 |
(if this app is embedded in a subCanvas)." |
|
930 |
||
931 |
^ ' , spec storeString , '\!!\'. |
|
932 |
code := code withCRs. |
|
933 |
^ code |
|
934 |
||
935 |
! |
|
936 |
||
1361
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
937 |
generateAspectSetMethodFor:aspect spec:protoSpec inClass:targetClass |
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
938 |
|code| |
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
939 |
|
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
940 |
code := '!!' , targetClass name , ' methodsFor:''aspects - exported''!!\\' , |
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
941 |
aspect , ':something\' , |
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
942 |
' "automatically generated by UIPainter ..."\\' , |
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
943 |
' "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
|
944 |
' "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
|
945 |
|
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
946 |
AspectsAsInstances ifTrue:[ |
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
947 |
code := (code , '\' , |
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
948 |
' "/ ' , aspect , ' notNil ifTrue:[\' , |
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
949 |
' "/ ' , aspect , ' removeDependent:self.\' , |
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
950 |
' "/ ].\' , |
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 |
' "/ ' , aspect ,' notNil ifTrue:[\' , |
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
953 |
' "/ ' , aspect , ' addDependent:self.\' , |
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
954 |
' "/ ].\' , |
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
955 |
' ^ self.\' , |
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
956 |
'!! !!\\') |
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
957 |
] ifFalse:[ |
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
958 |
code := (code , '\' , |
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
959 |
' "/ |holder|\' , |
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
960 |
'\' , |
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
961 |
' "/ (holder := builder bindingAt:#' , aspect , ') notNil ifTrue:[\' , |
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
962 |
' "/ holder removeDependent:self.\' , |
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
963 |
' "/ ].\' , |
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
964 |
' builder aspectAt:#' , aspect , ' put:something.\', |
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
965 |
' "/ something notNil ifTrue:[\' , |
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
966 |
' "/ something addDependent:self.\' , |
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
967 |
' "/ ].\' , |
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
968 |
' ^ self.\' , |
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
969 |
'!! !!\\') |
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
970 |
]. |
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
971 |
|
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
972 |
^ code withCRs |
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
973 |
|
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
974 |
"Modified: / 29.7.1998 / 11:29:16 / cg" |
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
975 |
"Modified: / 22.9.1999 / 12:33:47 / stefan" |
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
976 |
! |
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
977 |
|
698 | 978 |
generateCodeFrom:aListOfSelectors in:aClass do:aBlock |
979 |
||
744 | 980 |
self class redefineAspectMethods ifTrue:[ |
698 | 981 |
aListOfSelectors do:[:aSelector| |
982 |
(aSelector isArray or:[aClass implements:aSelector]) ifFalse:[ |
|
983 |
aBlock value:aSelector |
|
1030
0b9fbaecbe88
output a warning on the transcript, when an aspect method
Claus Gittinger <cg@exept.de>
parents:
1029
diff
changeset
|
984 |
] ifTrue:[ |
0b9fbaecbe88
output a warning on the transcript, when an aspect method
Claus Gittinger <cg@exept.de>
parents:
1029
diff
changeset
|
985 |
Transcript showCR:'#' , aSelector , ' skipped - already implemented in the class' |
698 | 986 |
] |
987 |
] |
|
988 |
] ifFalse:[ |
|
989 |
aListOfSelectors do:[:aSelector| |
|
1092
60e029255679
oops - failed to generate code for constant-list-holders.
Claus Gittinger <cg@exept.de>
parents:
1084
diff
changeset
|
990 |
aSelector isArray ifFalse:[ |
60e029255679
oops - failed to generate code for constant-list-holders.
Claus Gittinger <cg@exept.de>
parents:
1084
diff
changeset
|
991 |
(aClass canUnderstand:aSelector) ifFalse:[ |
60e029255679
oops - failed to generate code for constant-list-holders.
Claus Gittinger <cg@exept.de>
parents:
1084
diff
changeset
|
992 |
aBlock value:aSelector |
60e029255679
oops - failed to generate code for constant-list-holders.
Claus Gittinger <cg@exept.de>
parents:
1084
diff
changeset
|
993 |
] ifTrue:[ |
60e029255679
oops - failed to generate code for constant-list-holders.
Claus Gittinger <cg@exept.de>
parents:
1084
diff
changeset
|
994 |
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
|
995 |
] |
698 | 996 |
] |
997 |
] |
|
998 |
] |
|
999 |
||
1000 |
||
376 | 1001 |
! |
1002 |
||
1003 |
generateHookMethodFor:selectorSpec comment:commentWhen note:noteOrNil defaultCode:defaultCode inClass:targetClass |
|
1004 |
^ ('!!' , targetClass name , ' methodsFor:''hooks''!!\\' , |
|
1005 |
selectorSpec , '\' , |
|
1006 |
' "automatically generated by UIPainter ..."\\' , |
|
1007 |
' "*** the code here does nothing. It is invoked when"\' , |
|
1008 |
' "*** ' , commentWhen , '"\' , |
|
1009 |
' "*** Please change as required and accept in the browser."\' , |
|
1010 |
'\' , |
|
1011 |
' "specific code to be added below ..."\' , |
|
1012 |
' "' , (noteOrNil ? '') , '"\' , |
|
1013 |
'\' , |
|
1014 |
(defaultCode ? '^ self.') , |
|
1015 |
'!! !!\\') withCRs |
|
1016 |
||
1017 |
"Modified: / 25.10.1997 / 19:22:17 / cg" |
|
1018 |
"Created: / 31.10.1997 / 17:31:53 / cg" |
|
1019 |
! |
|
1020 |
||
1021 |
generateHookMethods |
|
1022 |
"generate hook methods |
|
1023 |
- but do not overwrite existing ones. |
|
1024 |
Return a string ready to compile into the application class." |
|
1025 |
||
1069 | 1026 |
|cls code| |
376 | 1027 |
|
1028 |
code := ''. |
|
1029 |
||
1030 |
className isNil ifTrue:[ |
|
1031 |
self warn:'set the class first'. |
|
1032 |
^ code |
|
1033 |
]. |
|
1034 |
cls := self resolveName:className. |
|
1035 |
||
1036 |
code := code , (self generateHookMethodsInClass:cls). |
|
1037 |
||
1038 |
^ code |
|
1039 |
||
1040 |
"Created: / 31.10.1997 / 17:21:29 / cg" |
|
1041 |
"Modified: / 31.10.1997 / 17:38:11 / cg" |
|
1042 |
! |
|
1043 |
||
1044 |
generateHookMethodsInClass:targetClass |
|
1045 |
|code| |
|
1046 |
||
1047 |
code := ''. |
|
1048 |
||
1049 |
(targetClass implements:#postBuildWith:) ifFalse:[ |
|
1050 |
code := code |
|
1051 |
, (self |
|
1052 |
generateHookMethodFor:'postBuildWith:aBuilder' |
|
1053 |
comment:'the widgets have been built, but before the view is opened' |
|
708 | 1054 |
note:'or after the super send' |
1055 |
defaultCode:' super postBuildWith:aBuilder' |
|
376 | 1056 |
inClass:targetClass) |
1057 |
]. |
|
1058 |
(targetClass implements:#postOpenWith:) ifFalse:[ |
|
1059 |
code := code |
|
1060 |
, (self |
|
1061 |
generateHookMethodFor:'postOpenWith:aBuilder' |
|
1062 |
comment:'the topView has been opened, but before events are dispatched for it' |
|
708 | 1063 |
note:'or after the super send' |
1064 |
defaultCode:' super postOpenWith:aBuilder' |
|
376 | 1065 |
inClass:targetClass) |
1066 |
]. |
|
1067 |
(targetClass implements:#closeRequest) ifFalse:[ |
|
1068 |
code := code |
|
1069 |
, (self |
|
1070 |
generateHookMethodFor:'closeRequest' |
|
1071 |
comment:'the topView has been asked to close' |
|
1072 |
note:'return without the ''super closeRequest'' to stay open' |
|
708 | 1073 |
defaultCode:' ^super closeRequest' |
376 | 1074 |
inClass:targetClass) |
1075 |
]. |
|
1076 |
^ code |
|
1077 |
||
1078 |
"Modified: / 31.10.1997 / 17:30:34 / cg" |
|
1079 |
"Created: / 31.10.1997 / 17:32:49 / cg" |
|
316 | 1080 |
! |
1081 |
||
965
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1082 |
generateMenuMethodFor:menuSel inClass:targetClass |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1083 |
|selector args showIt code alreadyInSuperclass numArgs method| |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1084 |
|
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1085 |
selector := menuSel asSymbol. |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1086 |
|
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1087 |
alreadyInSuperclass := targetClass superclass canUnderstand:selector. |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1088 |
|
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1089 |
code := '!!' , targetClass name , ' methodsFor:''menu actions''!!\\'. |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1090 |
|
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1091 |
selector = 'openAboutThisApplication' ifTrue:[ |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1092 |
code := code , |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1093 |
'openAboutThisApplication\' , |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1094 |
' "opens an about box for this application."\\' , |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1095 |
' "automatically generated by UIPainter ..."\\' , |
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 |
' |rev box myClass clsRev image msg|\\' , |
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 |
' rev := ''''.\' , |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1100 |
' myClass := self class.\' , |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1101 |
|
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1102 |
' (clsRev := myClass revision) notNil ifTrue:[\' , |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1103 |
' rev := '' (rev: '', clsRev printString, '')''].\\' , |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1104 |
|
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1105 |
' msg := Character cr asString , myClass name asBoldText, rev.\' , |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1106 |
' msg := (msg , ''\\*** add more info here ***\\'') withCRs.\\' , |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1107 |
' box := AboutBox title: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 |
' "/ *** add a #defaultIcon method in the class\' , |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1110 |
' "/ *** and uncomment the following line:\' , |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1111 |
' "/ image := self class defaultIcon.\\' , |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1112 |
' image notNil ifTrue:[\' , |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1113 |
' box image:image\' , |
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 |
' box label:(resources string:''About %1'' with:myClass name).\' , |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1116 |
' box autoHideAfter:10 with:[].\' , |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1117 |
' box showAtPointer.\' , |
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 |
^ code withCRs |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1120 |
]. |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1121 |
|
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1122 |
selector = 'menuOpen' ifTrue:[ |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1123 |
code := code , |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1124 |
'menuOpen\' , |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1125 |
' "automatically generated by UIPainter ..."\\' , |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1126 |
' "*** the code below opens a dialog for file selection"\' , |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1127 |
' "*** and invokes the #doOpen: method with the selected file."\' , |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1128 |
' "*** Please change as required and accept in the browser."\\' , |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1129 |
' |file|\\' , |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1130 |
' file :=\' , |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1131 |
' (FileSelectionBrowser\' , |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1132 |
' request: ''Open''\' , |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1133 |
' fileName: ''''\' , |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1134 |
' "/ inDirectory: lastOpenDirectory\' , |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1135 |
' withFileFilters: #(''*'')).\\' , |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1136 |
' file notNil ifTrue:[\' , |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1137 |
' "/ lastOpenDirectory := file asFilename directory.\' , |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1138 |
' self doOpen:file\' , |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1139 |
' ]\' , |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1140 |
'!! !!\'. |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1141 |
^ code withCRs |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1142 |
]. |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1143 |
|
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1144 |
numArgs := selector numArgs. |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1145 |
method := selector. |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1146 |
|
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1147 |
numArgs == 1 ifTrue:[ |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1148 |
args := 'anArgument'. |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1149 |
showIt := ''' , anArgument printString , '' ...''.\'. |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1150 |
] ifFalse:[ |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1151 |
args := ''. |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1152 |
showIt := ' ...''.\'. |
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 ~~ 0 ifTrue:[ |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1155 |
method := ''. |
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 |
selector keywords keysAndValuesDo:[:i :key| |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1158 |
method := method, key, 'arg', i printString, ' ' |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1159 |
] |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1160 |
] |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1161 |
]. |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1162 |
|
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1163 |
code := code , |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1164 |
method , args , '\' , |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1165 |
' "automatically generated by UIPainter ..."\\' , |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1166 |
' "*** the code below performs no action"\' , |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1167 |
' "*** (except for some feedback on the Transcript)"\' , |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1168 |
' "*** Please change as required and accept in the browser."\' , |
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 |
alreadyInSuperclass ifTrue:[ |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1172 |
code := code , |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1173 |
' "action for ' , selector , ' is already provided in a superclass."\' , |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1174 |
' "It may be redefined here ..."\\'. |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1175 |
] ifFalse:[ |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1176 |
code := code , |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1177 |
' "action to be added ..."\\'. |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1178 |
]. |
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 |
code := code , |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1181 |
' Transcript showCR:self class name, '': '. |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1182 |
alreadyInSuperclass ifTrue:[ |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1183 |
code := code , 'inherited '. |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1184 |
]. |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1185 |
code := code , 'menu action for ' , selector , showIt. |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1186 |
|
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1187 |
alreadyInSuperclass ifTrue:[ |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1188 |
code := code , |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1189 |
' super ' , selector , args , '.\'. |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1190 |
]. |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1191 |
|
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1192 |
code := code , |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1193 |
'!! !!\\'. |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1194 |
^ code withCRs |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1195 |
|
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1196 |
"Created: / 23.8.1998 / 16:46:51 / cg" |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1197 |
"Modified: / 23.8.1998 / 18:13:05 / cg" |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1198 |
! |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1199 |
|
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1200 |
generateMenuMethods |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1201 |
"generate menu methods |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1202 |
- but do not overwrite existing ones. |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1203 |
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
|
1204 |
|
1069 | 1205 |
|cls code menuSelector thisCode |
1206 |
definedMethodSelectors |
|
965
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1207 |
specArray fullSpec winSpec menuSpec |
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 |
className isNil ifTrue:[ |
1069 | 1211 |
self warn:'Define the class first !!'. |
1212 |
^ nil |
|
965
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1213 |
]. |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1214 |
|
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1215 |
(cls := self resolveName:className) isNil ifTrue:[ |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1216 |
self warn:'Class ', className asString, ' does not exist!!'. |
1069 | 1217 |
^ nil |
965
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1218 |
]. |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1219 |
|
1058 | 1220 |
specArray := treeView generateFullSpecForComponents:#() named:nil. |
965
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1221 |
fullSpec := specArray decodeAsLiteralArray. |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1222 |
winSpec := fullSpec window. |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1223 |
menuSelector := winSpec menu. |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1224 |
|
1069 | 1225 |
(menuSelector notNil |
1226 |
and:[ (cls respondsTo:menuSelector) ]) ifFalse:[ |
|
965
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1227 |
self warn:'No menu defined (yet)'. |
1069 | 1228 |
^ nil. |
965
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1229 |
]. |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1230 |
menuSpec := cls perform:menuSelector. |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1231 |
menuSpec := menuSpec decodeAsLiteralArray. |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1232 |
|
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1233 |
definedMethodSelectors := IdentitySet new. |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1234 |
code := ''. |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1235 |
|
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1236 |
menuSpec allItemsDo:[:item | |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1237 |
|sel| |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1238 |
|
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1239 |
(sel := item value) notNil ifTrue:[ |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1240 |
(definedMethodSelectors includes:sel) ifFalse:[ |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1241 |
self generateCodeFrom:(Array with:sel) in:cls do:[:aSel| |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1242 |
thisCode := (self generateMenuMethodFor:aSel inClass:cls). |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1243 |
code := code, thisCode. |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1244 |
]. |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1245 |
definedMethodSelectors add:sel. |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1246 |
]. |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1247 |
] |
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 |
|
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1250 |
(definedMethodSelectors includes:#menuOpen) ifTrue:[ |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1251 |
self generateCodeFrom:(Array with:#doOpen:) 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 |
]. |
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 |
^ code |
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 |
"Created: / 23.8.1998 / 16:12:09 / cg" |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1260 |
"Modified: / 23.8.1998 / 18:12:23 / cg" |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1261 |
! |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1262 |
|
188
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
1263 |
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
1264 |
^ ('!!' , targetClass name , ' methodsFor:''values''!!\\' , |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
1265 |
aspect , '\' , |
352 | 1266 |
' "automatically generated by UIPainter ..."\\' , |
1267 |
' "*** the code below returns a default value when invoked."\' , |
|
1268 |
' "*** (which may not be the one you wanted)"\' , |
|
1269 |
' "*** Please change as required and accept in the browser."\' , |
|
188
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
1270 |
'\' , |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
1271 |
' "value to be added below ..."\' , |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
1272 |
' Transcript showCR:self class name , '': no value yet for ' , aspect , ' ...''.\' , |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
1273 |
'\' , |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
1274 |
'^ nil.' , |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
1275 |
'!! !!\\') withCRs |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
1276 |
|
352 | 1277 |
"Modified: / 25.10.1997 / 19:22:17 / cg" |
188
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
1278 |
! |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
1279 |
|
78 | 1280 |
generateWindowSpecMethodSource |
457 | 1281 |
|spec str code category cls mthd specCode| |
60 | 1282 |
|
310 | 1283 |
spec := OrderedCollection new. |
60 | 1284 |
|
78 | 1285 |
self subViews do:[:aView| |
1191 | 1286 |
|vSpec| |
1287 |
||
78 | 1288 |
aView ~~ inputView ifTrue:[ |
1191 | 1289 |
"/ care for wrapped views ... |
1290 |
vSpec := self fullSpecFor:aView. |
|
1291 |
vSpec isNil ifTrue:[ |
|
1292 |
aView subViews size == 1 ifTrue:[ |
|
1293 |
vSpec := self fullSpecFor:(aView subViews first). |
|
1294 |
] |
|
1295 |
]. |
|
1296 |
vSpec isNil ifTrue:[ |
|
1297 |
self warn:'Oops - could not create spec for some view' |
|
1298 |
]. |
|
1299 |
spec add:vSpec |
|
60 | 1300 |
] |
1301 |
]. |
|
1058 | 1302 |
|
1303 |
spec := treeView generateFullSpecForComponents:spec named:methodName. |
|
310 | 1304 |
str := WriteStream on:String new. |
1305 |
UISpecification prettyPrintSpecArray:spec on:str indent:5. |
|
464 | 1306 |
specCode := str contents. |
457 | 1307 |
|
1308 |
(specCode includes:$!!) ifTrue:[ |
|
1309 |
"/ oops - must be chunk format ... |
|
1310 |
str := WriteStream on:String new. |
|
1311 |
str nextPutAllAsChunk:specCode. |
|
1312 |
specCode := str contents. |
|
1313 |
]. |
|
60 | 1314 |
|
178
fb8451053c96
keep windowSpec methods category if it already exists
Claus Gittinger <cg@exept.de>
parents:
175
diff
changeset
|
1315 |
"/ 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
|
1316 |
|
fb8451053c96
keep windowSpec methods category if it already exists
Claus Gittinger <cg@exept.de>
parents:
175
diff
changeset
|
1317 |
category := 'interface specs'. |
330 | 1318 |
cls := self resolveName:className. |
1319 |
||
1320 |
cls notNil ifTrue:[ |
|
178
fb8451053c96
keep windowSpec methods category if it already exists
Claus Gittinger <cg@exept.de>
parents:
175
diff
changeset
|
1321 |
(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
|
1322 |
category := mthd category. |
fb8451053c96
keep windowSpec methods category if it already exists
Claus Gittinger <cg@exept.de>
parents:
175
diff
changeset
|
1323 |
] |
fb8451053c96
keep windowSpec methods category if it already exists
Claus Gittinger <cg@exept.de>
parents:
175
diff
changeset
|
1324 |
]. |
fb8451053c96
keep windowSpec methods category if it already exists
Claus Gittinger <cg@exept.de>
parents:
175
diff
changeset
|
1325 |
|
238 | 1326 |
code := '!!' |
178
fb8451053c96
keep windowSpec methods category if it already exists
Claus Gittinger <cg@exept.de>
parents:
175
diff
changeset
|
1327 |
, className , ' class methodsFor:' , category storeString |
238 | 1328 |
, '!!' , '\\' |
60 | 1329 |
|
1330 |
, methodName , '\' |
|
742 | 1331 |
, ((ResourceSpecEditor codeGenerationCommentForClass: UIPainter) replChar:$!! withString:'!!!!') |
1332 |
, '\\ "\' |
|
1013 | 1333 |
, (' UIPainter new openOnClass:' , className , ' andSelector:#' , methodName , '\'). |
1334 |
||
1050
355a8ff451b6
care for as-yet-unspecified class in show-spec menu item.
Claus Gittinger <cg@exept.de>
parents:
1039
diff
changeset
|
1335 |
(cls notNil and:[cls isSubclassOf:ApplicationModel]) ifTrue:[ |
1013 | 1336 |
code := code |
1337 |
, (' ' , className , ' new openInterface:#' , methodName , '\'). |
|
1338 |
]. |
|
1339 |
||
1340 |
code := code |
|
742 | 1341 |
,(methodName = 'windowSpec' |
1342 |
ifTrue:[' ' , className , ' open\'] ifFalse: ['']) |
|
60 | 1343 |
, ' "\'. |
1344 |
||
1345 |
code := code |
|
1346 |
, '\' |
|
1347 |
, ' <resource: #canvas>\\' |
|
1084 | 1348 |
, ' ^ ' , specCode |
60 | 1349 |
, '\' |
238 | 1350 |
, '!! !!' |
60 | 1351 |
, '\\'. |
1352 |
||
1353 |
^ code withCRs |
|
1354 |
||
1013 | 1355 |
"Modified: / 5.9.1995 / 21:01:35 / claus" |
1356 |
"Modified: / 15.10.1998 / 11:29:53 / cg" |
|
60 | 1357 |
! ! |
1358 |
||
754 | 1359 |
!UIPainterView methodsFor:'grid manipulation'! |
1360 |
||
1361 |
newGrid |
|
1362 |
"define a new grid - this is a private helper which has to be |
|
1363 |
called after any change in the grid. It (re)creates the gridPixmap, |
|
1364 |
clears the view and redraws all visible objects." |
|
1365 |
||
1366 |
|defaultViewBackground| |
|
1367 |
||
1368 |
gridPixmap := nil. |
|
1369 |
defaultViewBackground := self class defaultViewBackgroundColor. |
|
1370 |
||
1371 |
shown ifTrue:[ |
|
1372 |
self viewBackground: (defaultViewBackground isColor |
|
1373 |
ifTrue: [defaultViewBackground] |
|
1374 |
ifFalse:[Black]). |
|
1375 |
self clear. |
|
1376 |
]. |
|
1377 |
||
1378 |
gridShown ifTrue:[ |
|
1379 |
self defineGrid. |
|
1380 |
gridPixmap colorMap: (defaultViewBackground isColor |
|
1381 |
ifTrue: [Array with:defaultViewBackground with:Color darkGray] |
|
1382 |
ifFalse:[Array with:White with:Black]). |
|
1383 |
self viewBackground:gridPixmap. |
|
1384 |
]. |
|
1385 |
||
1386 |
self invalidate |
|
1387 |
||
1388 |
! ! |
|
1389 |
||
60 | 1390 |
!UIPainterView methodsFor:'initialization'! |
1391 |
||
770 | 1392 |
create |
1393 |
"colors on device |
|
1394 |
" |
|
1395 |
super create. |
|
1396 |
||
1201 | 1397 |
handleColor := handleColor onDevice:device. |
1398 |
handleMasterColor := handleMasterColor onDevice:device. |
|
770 | 1399 |
! |
1400 |
||
60 | 1401 |
initialize |
62 | 1402 |
"setup attributes |
1403 |
" |
|
60 | 1404 |
super initialize. |
770 | 1405 |
superclassName := 'ApplicationModel'. |
1406 |
className := 'NewApplication'. |
|
1407 |
methodName := 'windowSpec'. |
|
1408 |
categoryName := 'Applications'. |
|
1409 |
HandCursor := Cursor leftHand. |
|
1410 |
handleColor := Color black. |
|
1411 |
handleMasterColor := Color red. |
|
60 | 1412 |
|
712 | 1413 |
self backgroundColor: self class defaultViewBackgroundColor. |
60 | 1414 |
! |
1415 |
||
1416 |
setupFromSpec:specOrSpecArray |
|
784 | 1417 |
|
78 | 1418 |
|spec builder| |
60 | 1419 |
|
784 | 1420 |
Cursor wait showWhile: [ |
1421 |
self removeAll. |
|
1029 | 1422 |
specOrSpecArray notNil ifTrue:[ |
1423 |
spec := UISpecification from:specOrSpecArray. |
|
1424 |
]. |
|
784 | 1425 |
builder := UIBuilder new isEditing:true. |
1426 |
"set applicationClass, in order that subspecifications may be resolved" |
|
1427 |
className notNil ifTrue:[ |
|
1428 |
builder applicationClass:(self resolveName:className). |
|
1429 |
]. |
|
1029 | 1430 |
spec notNil ifTrue:[ |
1431 |
spec window setupView:self topView for:builder. |
|
1432 |
self addSpec:(spec component) builder:builder in:self. |
|
1433 |
]. |
|
784 | 1434 |
self realizeAllSubViews. |
1435 |
inputView raise. |
|
1029 | 1436 |
spec notNil ifTrue:[ |
1437 |
treeView setAttributesFromWindowSpec:(spec window) |
|
1438 |
] |
|
784 | 1439 |
] |
1440 |
||
223 | 1441 |
! |
1442 |
||
1443 |
treeView:aTreeView |
|
361 | 1444 |
treeView := aTreeView. |
1445 |
||
1446 |
treeView delegate:( |
|
376 | 1447 |
"/ |
1448 |
"/ I want to handle everything typed |
|
1449 |
"/ in the treeView, except for Return and Cursor-keys |
|
1450 |
"/ |
|
1451 |
KeyboardForwarder |
|
1452 |
toView:self |
|
1453 |
condition:nil |
|
1454 |
filter:[:k | (k isSymbol |
|
1455 |
and:[k ~~ #Return |
|
1308 | 1456 |
and:[k ~~ #Tab |
1457 |
and:[(k startsWith:#Cursor) not]]]) |
|
376 | 1458 |
] |
361 | 1459 |
) |
1460 |
||
376 | 1461 |
"Modified: / 31.10.1997 / 20:22:09 / cg" |
60 | 1462 |
! ! |
1463 |
||
1464 |
!UIPainterView methodsFor:'menus'! |
|
1465 |
||
121 | 1466 |
showMiddleButtonMenu |
1467 |
"show the middle button menu; this returns nil |
|
62 | 1468 |
" |
223 | 1469 |
self enabled ifTrue:[ |
754 | 1470 |
(MenuPanel fromSpec:(UIPainter menuEdit) receiver:self superView application) startUp |
111 | 1471 |
]. |
121 | 1472 |
^ nil |
60 | 1473 |
|
62 | 1474 |
|
1475 |
||
60 | 1476 |
! ! |
1477 |
||
754 | 1478 |
!UIPainterView methodsFor:'private handles'! |
1479 |
||
1480 |
showSelected:aComponent |
|
1481 |
"show object selected |
|
1482 |
" |
|
1039 | 1483 |
|wasClipped sel hColor| |
754 | 1484 |
|
1485 |
selectionHiddenLevel == 0 ifTrue:[ |
|
995 | 1486 |
sel := treeView selection. |
1487 |
(sel size > 1 and: |
|
1488 |
[(treeView model list at: sel first) contents view == aComponent]) |
|
1039 | 1489 |
ifTrue: [hColor := handleMasterColor] |
1490 |
ifFalse:[hColor := handleColor]. |
|
1491 |
||
1492 |
self paint:hColor. |
|
754 | 1493 |
|
1494 |
(wasClipped := clipChildren) ifTrue:[ |
|
1495 |
self clippedByChildren:(clipChildren := false). |
|
1496 |
]. |
|
1497 |
||
1498 |
self handlesOf:aComponent do:[:rectangle :what| |
|
1499 |
what == #view ifTrue:[self displayRectangle:rectangle] |
|
1500 |
ifFalse:[self fillRectangle:rectangle] |
|
1501 |
]. |
|
1502 |
||
1503 |
wasClipped ifTrue:[ |
|
1504 |
self clippedByChildren:(clipChildren := true). |
|
1505 |
] |
|
1506 |
] |
|
1507 |
||
1508 |
||
1509 |
! ! |
|
1510 |
||
335 | 1511 |
!UIPainterView methodsFor:'queries'! |
1512 |
||
1513 |
resolveName:aName |
|
1514 |
|appl| |
|
1515 |
||
1516 |
appl := self application. |
|
1517 |
||
1518 |
appl notNil ifTrue:[ |
|
1519 |
^ appl resolveName:aName |
|
1520 |
]. |
|
1521 |
^ Smalltalk resolveName:aName inClass:self class |
|
1522 |
! ! |
|
1523 |
||
60 | 1524 |
!UIPainterView methodsFor:'removing components'! |
1525 |
||
78 | 1526 |
remove:anObject |
1527 |
"remove anObject from the contents do redraw |
|
60 | 1528 |
" |
134 | 1529 |
anObject notNil ifTrue:[ |
238 | 1530 |
treeView removeView:anObject. |
134 | 1531 |
] |
60 | 1532 |
! |
1533 |
||
1534 |
removeAll |
|
62 | 1535 |
"remove all objects and properties |
1536 |
" |
|
776 | 1537 |
self select:nil. |
1538 |
treeView removeAll. |
|
1539 |
self removeUndoHistory. |
|
60 | 1540 |
! ! |
1541 |
||
1542 |
!UIPainterView methodsFor:'searching'! |
|
1543 |
||
285 | 1544 |
findContainerOfView:aView |
1545 |
"returns the super view assigned to a view |
|
89 | 1546 |
" |
285 | 1547 |
|p| |
89 | 1548 |
|
285 | 1549 |
(p := self propertyOfParentForView:aView) isNil ifTrue:[ |
89 | 1550 |
^ self |
1551 |
]. |
|
285 | 1552 |
^ p view |
89 | 1553 |
! |
1554 |
||
60 | 1555 |
findObjectAt:aPoint |
1556 |
"find the origin/corner of the currentWidget |
|
1557 |
" |
|
285 | 1558 |
|view prop| |
60 | 1559 |
|
1560 |
view := super findObjectAt:aPoint. |
|
285 | 1561 |
prop := self propertyRespondsToView:view. |
60 | 1562 |
|
285 | 1563 |
prop notNil ifTrue:[^ prop view]. |
1564 |
^ nil |
|
60 | 1565 |
! |
1566 |
||
1567 |
findViewWithId:aViewId |
|
62 | 1568 |
"finds view assigned to identifier and returns the view or nil |
60 | 1569 |
" |
1570 |
|prop| |
|
1571 |
||
1572 |
prop := self propertyOfIdentifier:aViewId. |
|
1573 |
||
1574 |
prop notNil ifTrue:[^ prop view] |
|
1575 |
ifFalse:[^ nil] |
|
78 | 1576 |
! |
1577 |
||
1578 |
propertyOfIdentifier:anId |
|
1579 |
"returns property assigned to unique identifier |
|
1580 |
" |
|
1581 |
anId notNil ifTrue:[ |
|
238 | 1582 |
^ treeView propertyDetect:[:p| p identifier == anId ] |
78 | 1583 |
]. |
1584 |
^ nil |
|
1585 |
! |
|
1586 |
||
1587 |
propertyOfName:aString |
|
1588 |
"returns property assigned to name |
|
1589 |
" |
|
111 | 1590 |
|name| |
1591 |
||
1592 |
aString isNil ifFalse:[ |
|
1593 |
name := aString string withoutSeparators. |
|
238 | 1594 |
^ treeView propertyDetect:[:p| p name = name ]. |
78 | 1595 |
]. |
1596 |
^ nil |
|
1597 |
! |
|
1598 |
||
285 | 1599 |
propertyOfParentForView:aSubView |
1600 |
"returns the property of the parent or nil |
|
1601 |
" |
|
1602 |
|item| |
|
1603 |
||
1604 |
(item := treeView detectItemRespondsToView:aSubView) notNil ifTrue:[ |
|
1605 |
(item := item parent) notNil ifTrue:[^ item contents] |
|
1606 |
]. |
|
1607 |
^ nil |
|
1608 |
! |
|
1609 |
||
78 | 1610 |
propertyOfView:aView |
1611 |
"returns property assigned to view |
|
1612 |
" |
|
1613 |
(aView isNil or:[aView == self]) ifFalse:[ |
|
238 | 1614 |
^ treeView propertyDetect:[:p| p view == aView ] |
78 | 1615 |
]. |
1616 |
^ nil |
|
1617 |
! |
|
1618 |
||
285 | 1619 |
propertyRespondsToView:aView |
1620 |
"detect the property responding to the argument a view. The property of the view or |
|
1621 |
the first subview providing the properties is returned. If no property is detected |
|
1622 |
nil is returned. |
|
1623 |
" |
|
1624 |
|item| |
|
1625 |
||
1626 |
item := treeView detectItemRespondsToView:aView. |
|
1627 |
||
1628 |
(item notNil and:[item parent notNil]) ifTrue:[ |
|
1629 |
^ item contents |
|
1630 |
]. |
|
1631 |
^ nil |
|
1632 |
! |
|
1633 |
||
111 | 1634 |
uniqueNameFor:aSpecOrString |
78 | 1635 |
"generate and return an unique name for a class |
1636 |
" |
|
1637 |
|next name size| |
|
1638 |
||
712 | 1639 |
aSpecOrString isString ifFalse:[name := aSpecOrString userFriendlyName] |
111 | 1640 |
ifTrue:[name := aSpecOrString]. |
78 | 1641 |
|
111 | 1642 |
size := name size + 1. |
1643 |
next := 0. |
|
78 | 1644 |
|
238 | 1645 |
treeView propertiesDo:[:p| |
111 | 1646 |
|n| |
78 | 1647 |
n := p name. |
1648 |
||
1649 |
(n size >= size and:[n startsWith:name]) ifTrue:[ |
|
1650 |
next := next max:(p extractNumberStartingAt:size) |
|
1651 |
] |
|
1652 |
]. |
|
1653 |
next := next + 1. |
|
1654 |
name := name, next printString. |
|
1655 |
^ name |
|
1656 |
||
1657 |
||
1658 |
||
662 | 1659 |
|
78 | 1660 |
! |
1661 |
||
1662 |
uniqueNameOf:aView |
|
111 | 1663 |
|prop| |
78 | 1664 |
|
111 | 1665 |
(prop := self propertyOfView:aView) notNil ifTrue:[ |
1666 |
prop name isNil ifTrue:[ |
|
1667 |
prop name:(self uniqueNameFor:(prop spec)). |
|
1668 |
]. |
|
1669 |
^ prop name |
|
78 | 1670 |
]. |
111 | 1671 |
^ 'self' |
78 | 1672 |
|
60 | 1673 |
! ! |
1674 |
||
223 | 1675 |
!UIPainterView methodsFor:'selection basics'! |
1676 |
||
1677 |
addToSelection:anObject |
|
1678 |
"add an object to the selection |
|
1679 |
" |
|
1680 |
(self enabled and:[(self isSelected:anObject) not]) ifTrue:[ |
|
1681 |
selection isCollection ifFalse:[ |
|
1682 |
selection isNil ifTrue:[ |
|
1683 |
selection := anObject |
|
1684 |
] ifFalse:[ |
|
1685 |
selection := OrderedCollection with:selection with:anObject |
|
1686 |
] |
|
1687 |
] ifTrue:[ |
|
1347
c4046d0b638e
care for multiSelect into a non-list;
Claus Gittinger <cg@exept.de>
parents:
1338
diff
changeset
|
1688 |
"/ 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
|
1689 |
selection isList ifTrue:[ |
c4046d0b638e
care for multiSelect into a non-list;
Claus Gittinger <cg@exept.de>
parents:
1338
diff
changeset
|
1690 |
selection add:anObject |
c4046d0b638e
care for multiSelect into a non-list;
Claus Gittinger <cg@exept.de>
parents:
1338
diff
changeset
|
1691 |
] ifFalse:[ |
c4046d0b638e
care for multiSelect into a non-list;
Claus Gittinger <cg@exept.de>
parents:
1338
diff
changeset
|
1692 |
selection := selection asOrderedCollection. |
c4046d0b638e
care for multiSelect into a non-list;
Claus Gittinger <cg@exept.de>
parents:
1338
diff
changeset
|
1693 |
selection := selection copyWith:anObject |
c4046d0b638e
care for multiSelect into a non-list;
Claus Gittinger <cg@exept.de>
parents:
1338
diff
changeset
|
1694 |
] |
223 | 1695 |
]. |
1696 |
self showSelected:anObject. |
|
238 | 1697 |
treeView cvsSelectionAdd:anObject. |
223 | 1698 |
] |
1699 |
||
1347
c4046d0b638e
care for multiSelect into a non-list;
Claus Gittinger <cg@exept.de>
parents:
1338
diff
changeset
|
1700 |
"Modified: / 11.2.2000 / 01:39:05 / cg" |
223 | 1701 |
! |
1702 |
||
1703 |
removeFromSelection:anObject |
|
1704 |
"remove an object from the selection |
|
1705 |
" |
|
1706 |
(self isSelected:anObject) ifTrue:[ |
|
1707 |
self showUnselected:anObject. |
|
1708 |
||
1709 |
selection size > 1 ifTrue:[ |
|
1347
c4046d0b638e
care for multiSelect into a non-list;
Claus Gittinger <cg@exept.de>
parents:
1338
diff
changeset
|
1710 |
selection isList ifTrue:[ |
c4046d0b638e
care for multiSelect into a non-list;
Claus Gittinger <cg@exept.de>
parents:
1338
diff
changeset
|
1711 |
selection remove:anObject ifAbsent:nil |
c4046d0b638e
care for multiSelect into a non-list;
Claus Gittinger <cg@exept.de>
parents:
1338
diff
changeset
|
1712 |
] ifFalse:[ |
c4046d0b638e
care for multiSelect into a non-list;
Claus Gittinger <cg@exept.de>
parents:
1338
diff
changeset
|
1713 |
"/ 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
|
1714 |
selection := selection asOrderedCollection. |
c4046d0b638e
care for multiSelect into a non-list;
Claus Gittinger <cg@exept.de>
parents:
1338
diff
changeset
|
1715 |
selection := selection copyWithout:anObject |
c4046d0b638e
care for multiSelect into a non-list;
Claus Gittinger <cg@exept.de>
parents:
1338
diff
changeset
|
1716 |
]. |
223 | 1717 |
self showSelection. |
1718 |
] ifFalse:[ |
|
1719 |
selection := nil |
|
1720 |
]. |
|
238 | 1721 |
treeView cvsSelectionRemove:anObject. |
223 | 1722 |
] |
1723 |
||
1347
c4046d0b638e
care for multiSelect into a non-list;
Claus Gittinger <cg@exept.de>
parents:
1338
diff
changeset
|
1724 |
"Modified: / 11.2.2000 / 01:41:11 / cg" |
223 | 1725 |
! |
1726 |
||
1727 |
select:something |
|
1728 |
"change selection to something |
|
886
3c67610b9631
after deleting a widget do select the neighbour then the parent
tz
parents:
858
diff
changeset
|
1729 |
" |
760 | 1730 |
(self enabled and:[something ~= self selection]) ifTrue:[ |
1731 |
something isNil |
|
1732 |
ifTrue: [treeView selection: (Array with: 1)] |
|
1733 |
ifFalse:[treeView cvsSelection:something]. |
|
886
3c67610b9631
after deleting a widget do select the neighbour then the parent
tz
parents:
858
diff
changeset
|
1734 |
self setSelection:something withRedraw:true |
223 | 1735 |
] |
1736 |
||
1737 |
! |
|
1738 |
||
285 | 1739 |
updateSelectionFromModel:aSelOrNil |
223 | 1740 |
"update selection from a new selection |
1741 |
" |
|
768 | 1742 |
|aSet| |
1743 |
||
223 | 1744 |
selectionHiddenLevel == 0 ifTrue:[ |
285 | 1745 |
aSelOrNil size ~~ 0 ifTrue:[ |
768 | 1746 |
self selectionDo:[:el| |
1747 |
(aSelOrNil includes:el) ifFalse:[ |
|
1748 |
aSet isNil ifTrue:[ |
|
1749 |
aSet := IdentitySet new |
|
1750 |
]. |
|
1751 |
self showUnselected:el addAffectedViewsTo:aSet. |
|
1752 |
] |
|
1753 |
]. |
|
1754 |
self handleAffectedViews:aSet. |
|
285 | 1755 |
] ifFalse:[ |
768 | 1756 |
self hideSelection. |
285 | 1757 |
] |
223 | 1758 |
]. |
285 | 1759 |
self setSelection:aSelOrNil withRedraw:false. |
223 | 1760 |
self showSelection |
1761 |
||
1762 |
! ! |
|
1763 |
||
78 | 1764 |
!UIPainterView methodsFor:'specification'! |
1765 |
||
1766 |
addSpec:aSpecification builder:aBuilder in:aFrame |
|
1767 |
"build view and subviews from aSpecification into a frame. The top view |
|
1768 |
is returned. The contained components of a spec are set to nil |
|
1769 |
" |
|
330 | 1770 |
|cls| |
212 | 1771 |
|
330 | 1772 |
cls := self resolveName:className. |
1773 |
||
1774 |
cls notNil ifTrue:[ |
|
1775 |
aBuilder applicationClass:cls. |
|
212 | 1776 |
]. |
78 | 1777 |
|
111 | 1778 |
aBuilder componentCreationHook:[:aView :aSpec :aBdr||sv p s n| |
78 | 1779 |
p := ViewProperty new. |
1780 |
s := aSpec copy. |
|
1781 |
p spec:s. |
|
1782 |
p view:aView. |
|
1783 |
||
1784 |
s class supportsSubComponents ifTrue:[ |
|
1785 |
s component:nil |
|
1786 |
]. |
|
1787 |
||
111 | 1788 |
n := s name. |
1789 |
||
1790 |
(n isNil or:[(self propertyOfName:n) notNil]) ifTrue:[ |
|
1791 |
s name:(self uniqueNameFor:s) |
|
78 | 1792 |
]. |
238 | 1793 |
treeView addProperty:p. |
78 | 1794 |
]. |
1795 |
||
1796 |
^ aSpecification buildViewWithLayoutFor:aBuilder in:aFrame. |
|
60 | 1797 |
|
212 | 1798 |
"Modified: 4.7.1997 / 23:48:55 / cg" |
78 | 1799 |
! |
1800 |
||
1801 |
fullSpecFor:anObject |
|
1802 |
"generate a full spec for an object |
|
62 | 1803 |
" |
78 | 1804 |
|mySpec subSpecs| |
1805 |
||
1806 |
mySpec := self specFor:anObject. |
|
1807 |
||
1808 |
(mySpec notNil and:[mySpec class supportsSubComponents]) ifTrue:[ |
|
1809 |
(anObject subViews notNil) ifTrue:[ |
|
1810 |
anObject subViews do:[:aSubView||spec| |
|
1811 |
spec := self fullSpecFor:aSubView. |
|
1812 |
spec notNil ifTrue:[ |
|
1813 |
subSpecs isNil ifTrue:[ |
|
1814 |
subSpecs := OrderedCollection new |
|
1815 |
]. |
|
1816 |
subSpecs add:spec. |
|
1817 |
]. |
|
1818 |
]. |
|
1819 |
subSpecs notNil ifTrue:[ |
|
1820 |
mySpec component:(SpecCollection new collection:subSpecs) |
|
1821 |
] |
|
1822 |
] |
|
1823 |
]. |
|
1824 |
^ mySpec |
|
1825 |
||
60 | 1826 |
|
1827 |
||
1828 |
||
1829 |
||
1830 |
||
1831 |
! |
|
1832 |
||
1173 | 1833 |
rebuildView:aView fromSpec:aSpec withBuilder:aBuilderOrNil |
1834 |
|v builder| |
|
1835 |
||
1836 |
(builder := aBuilderOrNil) isNil ifTrue:[ |
|
1837 |
"/ create a dummy builder |
|
1838 |
builder := UIBuilder new isEditing:true. |
|
1839 |
className notNil ifTrue:[ |
|
1840 |
builder applicationClass:(self resolveName:className). |
|
1841 |
]. |
|
1842 |
]. |
|
285 | 1843 |
|
1252
f886528c2b35
when changing a layoutContainer
Claus Gittinger <cg@exept.de>
parents:
1230
diff
changeset
|
1844 |
aSpec class isLayoutContainer ifTrue:[ |
f886528c2b35
when changing a layoutContainer
Claus Gittinger <cg@exept.de>
parents:
1230
diff
changeset
|
1845 |
"/ TODO: |
f886528c2b35
when changing a layoutContainer
Claus Gittinger <cg@exept.de>
parents:
1230
diff
changeset
|
1846 |
"/ 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
|
1847 |
"/ 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
|
1848 |
|
1258 | 1849 |
(aView subViews ? #()) do:[:aSubView | |
1252
f886528c2b35
when changing a layoutContainer
Claus Gittinger <cg@exept.de>
parents:
1230
diff
changeset
|
1850 |
|fix spec prop| |
f886528c2b35
when changing a layoutContainer
Claus Gittinger <cg@exept.de>
parents:
1230
diff
changeset
|
1851 |
|
f886528c2b35
when changing a layoutContainer
Claus Gittinger <cg@exept.de>
parents:
1230
diff
changeset
|
1852 |
(prop := self propertyOfView:aSubView) notNil ifTrue:[ |
f886528c2b35
when changing a layoutContainer
Claus Gittinger <cg@exept.de>
parents:
1230
diff
changeset
|
1853 |
spec := prop spec. |
f886528c2b35
when changing a layoutContainer
Claus Gittinger <cg@exept.de>
parents:
1230
diff
changeset
|
1854 |
|
f886528c2b35
when changing a layoutContainer
Claus Gittinger <cg@exept.de>
parents:
1230
diff
changeset
|
1855 |
spec useDefaultExtent ifTrue:[ |
f886528c2b35
when changing a layoutContainer
Claus Gittinger <cg@exept.de>
parents:
1230
diff
changeset
|
1856 |
fix := aSubView sizeFixed:false. |
f886528c2b35
when changing a layoutContainer
Claus Gittinger <cg@exept.de>
parents:
1230
diff
changeset
|
1857 |
aSubView extent:aSubView preferredExtent. |
f886528c2b35
when changing a layoutContainer
Claus Gittinger <cg@exept.de>
parents:
1230
diff
changeset
|
1858 |
aSubView sizeFixed:fix |
f886528c2b35
when changing a layoutContainer
Claus Gittinger <cg@exept.de>
parents:
1230
diff
changeset
|
1859 |
] |
f886528c2b35
when changing a layoutContainer
Claus Gittinger <cg@exept.de>
parents:
1230
diff
changeset
|
1860 |
] |
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 |
]. |
f886528c2b35
when changing a layoutContainer
Claus Gittinger <cg@exept.de>
parents:
1230
diff
changeset
|
1863 |
|
285 | 1864 |
aSpec needsRebuildForAttributes ifTrue:[ |
1173 | 1865 |
"/ needs a full rebuild (in case view class depends upon spec-attribute) |
1866 |
v := aSpec buildViewWithLayoutFor:builder in:(self findContainerOfView:aView). |
|
285 | 1867 |
v realize. |
1868 |
aView destroy. |
|
1869 |
device sync. |
|
1870 |
device flush. |
|
1871 |
aView becomeSameAs:v. |
|
1872 |
inputView raise. |
|
1873 |
] ifFalse:[ |
|
1173 | 1874 |
aSpec setAttributesIn:aView with:builder. |
285 | 1875 |
self elementChangedSize:aView. |
1876 |
]. |
|
1877 |
||
1878 |
! |
|
1879 |
||
78 | 1880 |
specFor:anObject |
1881 |
"returns spec assigned to an object |
|
62 | 1882 |
" |
78 | 1883 |
|prop spec| |
60 | 1884 |
|
78 | 1885 |
(prop := self propertyOfView:anObject) notNil ifTrue:[ |
1886 |
spec := prop spec copy. |
|
1887 |
spec layoutFromView:anObject |
|
60 | 1888 |
]. |
78 | 1889 |
^ spec |
1890 |
||
1891 |
||
1892 |
||
60 | 1893 |
! |
1894 |
||
146 | 1895 |
specForSelection |
1896 |
"returns spec assigned to current single selection or nil |
|
1897 |
" |
|
1898 |
^ self specFor:(self singleSelection) |
|
1899 |
||
1900 |
||
1901 |
! |
|
1902 |
||
78 | 1903 |
updateFromSpec:aSpec |
1904 |
"update current selected view from specification |
|
62 | 1905 |
" |
1173 | 1906 |
|props name| |
78 | 1907 |
|
281 | 1908 |
aSpec class == WindowSpec ifTrue:[ |
698 | 1909 |
^ treeView canvasSpec:aSpec |
281 | 1910 |
]. |
1911 |
||
78 | 1912 |
self singleSelection notNil ifTrue:[ |
1913 |
self withSelectionHiddenDo:[ |
|
1914 |
self transaction:#specification selectionDo:[:aView| |
|
1915 |
props := self propertyOfView:aView. |
|
82 | 1916 |
name := (aSpec name) withoutSeparators. |
78 | 1917 |
|
82 | 1918 |
name = props name ifFalse:[ |
1919 |
(self propertyOfName:name) notNil ifTrue:[ |
|
1920 |
name := props name |
|
78 | 1921 |
] |
1922 |
]. |
|
82 | 1923 |
aSpec name:name. |
134 | 1924 |
self createUndoSpecModify:props. |
1173 | 1925 |
self rebuildView:aView fromSpec:aSpec withBuilder:nil. |
78 | 1926 |
props spec:(aSpec copy). |
238 | 1927 |
treeView propertyChanged:props. |
78 | 1928 |
] |
111 | 1929 |
] |
82 | 1930 |
] |
212 | 1931 |
|
1932 |
"Modified: 4.7.1997 / 23:49:44 / cg" |
|
60 | 1933 |
! ! |
1934 |
||
285 | 1935 |
!UIPainterView methodsFor:'testing'! |
1936 |
||
1937 |
canChangeLayoutOfView:aView |
|
1938 |
"returns true if the view can change its layout which is dependant on |
|
1939 |
its parent view. |
|
1940 |
" |
|
1941 |
|item prnt| |
|
1942 |
||
1943 |
( (item := treeView itemOfView:aView) isNil |
|
1944 |
or:[(prnt := item parent) isNil] |
|
1945 |
) ifTrue:[ |
|
1946 |
^ false |
|
1947 |
]. |
|
1948 |
^ (prnt parent isNil or:[prnt contents spec class isLayoutContainer not]) |
|
1949 |
! |
|
1950 |
||
1230
23e5d0c133e8
added exchangeLayouts function
Claus Gittinger <cg@exept.de>
parents:
1225
diff
changeset
|
1951 |
canExchangeSelectionLayouts |
23e5d0c133e8
added exchangeLayouts function
Claus Gittinger <cg@exept.de>
parents:
1225
diff
changeset
|
1952 |
"returns true if the selection size is exactly 2 |
23e5d0c133e8
added exchangeLayouts function
Claus Gittinger <cg@exept.de>
parents:
1225
diff
changeset
|
1953 |
and all elements in the selection can be moved or aligned |
23e5d0c133e8
added exchangeLayouts function
Claus Gittinger <cg@exept.de>
parents:
1225
diff
changeset
|
1954 |
" |
23e5d0c133e8
added exchangeLayouts function
Claus Gittinger <cg@exept.de>
parents:
1225
diff
changeset
|
1955 |
selection size == 2 ifFalse:[ |
23e5d0c133e8
added exchangeLayouts function
Claus Gittinger <cg@exept.de>
parents:
1225
diff
changeset
|
1956 |
^ false |
23e5d0c133e8
added exchangeLayouts function
Claus Gittinger <cg@exept.de>
parents:
1225
diff
changeset
|
1957 |
]. |
23e5d0c133e8
added exchangeLayouts function
Claus Gittinger <cg@exept.de>
parents:
1225
diff
changeset
|
1958 |
^ self canMoveOrAlignSelection |
23e5d0c133e8
added exchangeLayouts function
Claus Gittinger <cg@exept.de>
parents:
1225
diff
changeset
|
1959 |
|
23e5d0c133e8
added exchangeLayouts function
Claus Gittinger <cg@exept.de>
parents:
1225
diff
changeset
|
1960 |
! |
23e5d0c133e8
added exchangeLayouts function
Claus Gittinger <cg@exept.de>
parents:
1225
diff
changeset
|
1961 |
|
285 | 1962 |
canKeepLayoutInSelection |
1963 |
"returns true if layout can be kept during a paste operation |
|
1964 |
" |
|
1965 |
|prop| |
|
1966 |
||
1967 |
prop := self propertyOfView:(self singleSelection). |
|
1968 |
^ (prop isNil or:[prop spec class isLayoutContainer not]) |
|
1969 |
! |
|
1970 |
||
1971 |
canMove:something |
|
1972 |
"checks whether something is not nil and if all widgets derived from |
|
1973 |
something can change their layout ( move, align, ... operation ). |
|
1974 |
" |
|
1975 |
something notNil ifTrue:[ |
|
1976 |
self forEach:something do:[:aView| |
|
1977 |
(self canChangeLayoutOfView:aView) ifFalse:[^ false] |
|
1978 |
]. |
|
1979 |
^ true |
|
1980 |
]. |
|
1981 |
^ false |
|
1982 |
! |
|
1983 |
||
1984 |
canMoveOrAlignSelection |
|
1985 |
"returns true if a selection exists and all elements in the selection |
|
1986 |
can be moved or aligned |
|
1987 |
" |
|
1988 |
^ self canMove:(self selection) |
|
1989 |
||
1990 |
! ! |
|
1991 |
||
60 | 1992 |
!UIPainterView methodsFor:'transaction'! |
1993 |
||
1994 |
transaction:aType objects:something do:aOneArgBlock |
|
1995 |
"opens a transaction and evaluates a block within the transaction; the |
|
1996 |
argument to the block is a view from derived from something |
|
1997 |
" |
|
134 | 1998 |
self withinTransaction:aType objects:something do:[ |
1999 |
self forEach:something do:aOneArgBlock |
|
60 | 2000 |
] |
2001 |
! |
|
2002 |
||
134 | 2003 |
withinTransaction:aType objects:objects do:aNoneArgBlock |
2004 |
"evaluate a block with no arguments within a transaction |
|
60 | 2005 |
" |
134 | 2006 |
|text size prop| |
2007 |
||
2008 |
objects isNil ifTrue:[ ^ self ]. |
|
2009 |
||
2010 |
size := objects size. |
|
60 | 2011 |
|
134 | 2012 |
objects isCollection ifTrue:[ |
2013 |
size == 0 ifTrue:[ ^ self ]. |
|
2014 |
size == 1 ifTrue:[ prop := self propertyOfView:(objects first) ] |
|
2015 |
] ifFalse:[ |
|
2016 |
prop := self propertyOfView:objects |
|
2017 |
]. |
|
60 | 2018 |
|
134 | 2019 |
prop notNil ifTrue:[ |
2020 |
text := prop name |
|
2021 |
] ifFalse:[ |
|
2022 |
text := size printString, ' elements' |
|
60 | 2023 |
]. |
134 | 2024 |
|
2025 |
undoHistory withinTransaction:aType text:text do:[ |
|
2026 |
aNoneArgBlock value |
|
2027 |
] |
|
60 | 2028 |
! ! |
2029 |
||
2030 |
!UIPainterView methodsFor:'undo actions'! |
|
2031 |
||
134 | 2032 |
createUndoLayout:aView |
2033 |
"create undo action before changing a views layout |
|
60 | 2034 |
" |
134 | 2035 |
|lyt args prop| |
60 | 2036 |
|
2037 |
undoHistory isTransactionOpen ifTrue:[ |
|
2038 |
prop := self propertyOfView:aView. |
|
134 | 2039 |
|
60 | 2040 |
prop notNil ifTrue:[ |
134 | 2041 |
args := Array new:3. |
2042 |
args at:1 put:(prop identifier). |
|
2043 |
||
2044 |
(lyt := aView geometryLayout) notNil ifTrue:[ |
|
2045 |
args at:2 put:#geometryLayout: |
|
2046 |
] ifFalse:[ |
|
146 | 2047 |
lyt := aView extent. |
134 | 2048 |
args at:2 put:#extent: |
2049 |
]. |
|
2050 |
args at:3 put:(lyt copy). |
|
2051 |
undoHistory addUndoSelector:#undoLayout: withArgs:args. |
|
60 | 2052 |
] |
2053 |
] |
|
2054 |
! |
|
2055 |
||
134 | 2056 |
createUndoRemove:aView |
2057 |
"create undo method before deleting views |
|
60 | 2058 |
" |
285 | 2059 |
|prop pid| |
134 | 2060 |
|
2061 |
(prop := self propertyOfView:aView) notNil ifTrue:[ |
|
285 | 2062 |
(pid := self propertyOfParentForView:aView) notNil ifTrue:[ |
2063 |
pid := pid identifier |
|
2064 |
]. |
|
60 | 2065 |
|
134 | 2066 |
undoHistory addUndoSelector:#undoRemove: |
285 | 2067 |
withArgs:(Array with:(self fullSpecFor:aView) |
2068 |
with:(prop identifier) |
|
2069 |
with:pid) |
|
134 | 2070 |
] |
2071 |
! |
|
60 | 2072 |
|
134 | 2073 |
createUndoSpecModify:aProp |
2074 |
"undo method when changing the specification for an object |
|
2075 |
" |
|
2076 |
aProp notNil ifTrue:[ |
|
2077 |
undoHistory addUndoSelector:#undoSpecModify: |
|
2078 |
withArgs:(Array with:(aProp spec) with:(aProp identifier)) |
|
2079 |
] |
|
2080 |
! |
|
60 | 2081 |
|
134 | 2082 |
undoCreate:something |
2083 |
"undo method for creating or pasting an object |
|
2084 |
" |
|
2085 |
self forEach:something do:[:anId|self remove:(self findViewWithId:anId)]. |
|
2086 |
! |
|
60 | 2087 |
|
134 | 2088 |
undoLayout:args |
2089 |
"undo method to set the old layout; see 'createUndoLayout:' |
|
2090 |
" |
|
2091 |
|view| |
|
2092 |
||
2093 |
(view := self findViewWithId:(args at:1)) notNil ifTrue:[ |
|
146 | 2094 |
view perform:(args at:2) with:(args at:3). |
223 | 2095 |
self layoutChanged. |
60 | 2096 |
] |
2097 |
! |
|
2098 |
||
134 | 2099 |
undoRemove:args |
2100 |
"undo method when removing an object; see 'createUndoRemove:' |
|
2101 |
" |
|
2102 |
|frame prop view| |
|
2103 |
||
2104 |
(args at:3) notNil ifTrue:[ |
|
2105 |
frame := self findViewWithId:(args at:3). |
|
2106 |
]. |
|
2107 |
frame isNil ifTrue:[ |
|
2108 |
frame := self |
|
2109 |
]. |
|
395 | 2110 |
view := self addSpec:(args at:1) builder:(UIBuilder new isEditing:true) in:frame. |
134 | 2111 |
view realize. |
2112 |
inputView raise. |
|
2113 |
||
2114 |
prop := self propertyOfView:view. |
|
2115 |
prop identifier:(args at:2). |
|
2116 |
||
2117 |
! |
|
2118 |
||
2119 |
undoSpecModify:args |
|
2120 |
"undo method when changing a spec; see 'createUndoSpecModify:' |
|
60 | 2121 |
" |
1173 | 2122 |
|view spec props| |
60 | 2123 |
|
134 | 2124 |
props := self propertyOfIdentifier:(args at:2). |
60 | 2125 |
|
134 | 2126 |
props notNil ifTrue:[ |
2127 |
view := props view. |
|
2128 |
spec := args at:1. |
|
395 | 2129 |
|
134 | 2130 |
props spec:spec. |
1173 | 2131 |
self rebuildView:view fromSpec:spec withBuilder:nil. |
238 | 2132 |
treeView propertyChanged:props. |
211 | 2133 |
] |
2134 |
! ! |
|
2135 |
||
2136 |
!UIPainterView::ViewProperty class methodsFor:'instance creation'! |
|
2137 |
||
2138 |
new |
|
2139 |
Identifier notNil ifTrue:[Identifier := Identifier + 1] |
|
2140 |
ifFalse:[Identifier := 1]. |
|
2141 |
||
2142 |
^ self basicNew initialize |
|
2143 |
! ! |
|
2144 |
||
2145 |
!UIPainterView::ViewProperty methodsFor:'accessing'! |
|
2146 |
||
2147 |
identifier |
|
2148 |
"return the unique identifier assigned to property |
|
2149 |
" |
|
2150 |
^ identifier |
|
2151 |
! |
|
2152 |
||
2153 |
identifier:anIdentifier |
|
2154 |
"set the unique identifier assigned to property; called after an restore of |
|
2155 |
a deleted instance |
|
2156 |
" |
|
2157 |
identifier := anIdentifier |
|
2158 |
! |
|
2159 |
||
2160 |
spec |
|
2161 |
"return the value of the instance variable 'spec' (automatically generated)" |
|
2162 |
||
2163 |
^ spec! |
|
2164 |
||
2165 |
spec:something |
|
2166 |
"set the value of the instance variable 'spec' (automatically generated)" |
|
2167 |
||
2168 |
spec := something.! |
|
2169 |
||
2170 |
view |
|
2171 |
"return the value of the instance variable 'view' (automatically generated)" |
|
2172 |
||
2173 |
^ view! |
|
2174 |
||
2175 |
view:something |
|
2176 |
"set the value of the instance variable 'view' (automatically generated)" |
|
2177 |
||
2178 |
view := something.! ! |
|
2179 |
||
2180 |
!UIPainterView::ViewProperty methodsFor:'initialization'! |
|
2181 |
||
2182 |
initialize |
|
2183 |
super initialize. |
|
2184 |
identifier := Identifier |
|
2185 |
! ! |
|
2186 |
||
2187 |
!UIPainterView::ViewProperty methodsFor:'misc'! |
|
2188 |
||
2189 |
extractNumberStartingAt:anIndex |
|
2190 |
"return the number from the name starting at anIndex or 0. |
|
2191 |
" |
|
2192 |
|val| |
|
2193 |
||
2194 |
val := 0. |
|
2195 |
||
2196 |
self name from:anIndex do:[:c| |
|
2197 |
c isDigit ifTrue:[val := val * 10 + c digitValue] |
|
2198 |
ifFalse:[^ 0] |
|
2199 |
]. |
|
2200 |
^ val |
|
2201 |
||
2202 |
! ! |
|
2203 |
||
2204 |
!UIPainterView::ViewProperty methodsFor:'spec messages'! |
|
2205 |
||
2206 |
doesNotUnderstand:aMessage |
|
2207 |
spec notNil ifTrue:[ |
|
2208 |
(spec respondsTo:(aMessage selector)) ifTrue:[^ aMessage sendTo:spec] |
|
2209 |
]. |
|
2210 |
^ nil |
|
2211 |
! |
|
2212 |
||
2213 |
layout |
|
2214 |
spec layout |
|
2215 |
! |
|
2216 |
||
2217 |
layout:aLayout |
|
2218 |
spec layout:aLayout |
|
2219 |
! |
|
2220 |
||
2221 |
name |
|
2222 |
^ spec name |
|
2223 |
! |
|
2224 |
||
2225 |
name:aName |
|
2226 |
spec name:aName |
|
2227 |
! ! |
|
2228 |
||
60 | 2229 |
!UIPainterView class methodsFor:'documentation'! |
2230 |
||
2231 |
version |
|
2232 |
^ '$Header$' |
|
2233 |
! ! |
|
1225 | 2234 |
UIPainterView initialize! |