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