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