author | Claus Gittinger <cg@exept.de> |
Fri, 08 Aug 1997 17:50:25 +0200 | |
changeset 276 | c8b7fd1fcec5 |
parent 238 | 882be7e03af4 |
child 278 | 5b7dfe33b497 |
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 |
|
7 |
inclusion of the above copyright notice. This software may not |
|
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 |
|
238 | 14 |
instanceVariableNames:'treeView listHolder superclassName className methodName categoryName' |
60 | 15 |
classVariableNames:'HandCursor' |
16 |
poolDictionaries:'' |
|
17 |
category:'Interface-UIPainter' |
|
18 |
! |
|
19 |
||
211 | 20 |
Object subclass:#ViewProperty |
21 |
instanceVariableNames:'view spec identifier' |
|
22 |
classVariableNames:'Identifier' |
|
23 |
poolDictionaries:'' |
|
24 |
privateIn:UIPainterView |
|
25 |
! |
|
26 |
||
60 | 27 |
!UIPainterView class methodsFor:'documentation'! |
28 |
||
29 |
copyright |
|
30 |
" |
|
156 | 31 |
COPYRIGHT (c) 1995 by Claus Gittinger / eXept Software AG |
32 |
All Rights Reserved |
|
60 | 33 |
|
34 |
This software is furnished under a license and may be used |
|
35 |
only in accordance with the terms of that license and with the |
|
36 |
inclusion of the above copyright notice. This software may not |
|
37 |
be provided or otherwise made available to, or used by, any |
|
38 |
other person. No title to or ownership of the software is |
|
39 |
hereby transferred. |
|
40 |
" |
|
41 |
! |
|
42 |
||
43 |
documentation |
|
44 |
" |
|
128 | 45 |
buildIn view used by the UIPainter; from this view, the layout of the |
46 |
new application derives from. |
|
47 |
||
48 |
[see also:] |
|
49 |
UIBuilder |
|
50 |
UIObjectView |
|
156 | 51 |
|
52 |
[author:] |
|
53 |
Claus Gittinger |
|
54 |
Claus Atzkern |
|
60 | 55 |
" |
56 |
! ! |
|
57 |
||
58 |
!UIPainterView class methodsFor:'defaults'! |
|
59 |
||
60 |
defaultMenuMessage |
|
61 |
"This message is the default yo be sent to the menuHolder to get a menu |
|
62 |
" |
|
121 | 63 |
^ #showMiddleButtonMenu |
60 | 64 |
|
65 |
||
66 |
! ! |
|
67 |
||
68 |
!UIPainterView methodsFor:'accessing'! |
|
69 |
||
70 |
application |
|
71 |
^ nil |
|
72 |
||
73 |
"Modified: 6.9.1995 / 00:46:44 / claus" |
|
74 |
! |
|
75 |
||
78 | 76 |
applicationName |
77 |
^ self className |
|
78 |
! |
|
79 |
||
80 |
applicationName:aName |
|
81 |
self className:aName |
|
82 |
! |
|
83 |
||
60 | 84 |
className |
85 |
^ className |
|
86 |
! |
|
87 |
||
78 | 88 |
className:aName |
89 |
className := aName |
|
60 | 90 |
! |
91 |
||
92 |
className:aClassName superclassName:aSuperclassName selector:aSelector |
|
78 | 93 |
className := aClassName. |
60 | 94 |
superclassName := aSuperclassName. |
78 | 95 |
methodName := aSelector. |
60 | 96 |
|
97 |
! |
|
98 |
||
223 | 99 |
findInputViewIn:aSuperView |
100 |
"returns index of input view into superview or nil |
|
101 |
" |
|
102 |
aSuperView == self ifTrue:[ |
|
103 |
^ self subViews findFirst:[:v| v == inputView ] |
|
104 |
]. |
|
105 |
^ 0 |
|
106 |
! |
|
107 |
||
108 |
inputView |
|
109 |
^ inputView |
|
111 | 110 |
! |
111 |
||
60 | 112 |
methodName |
113 |
^ methodName |
|
114 |
! |
|
115 |
||
78 | 116 |
methodName:aName |
117 |
methodName := aName |
|
60 | 118 |
! |
119 |
||
120 |
selectNames:aStringOrCollection |
|
121 |
|prop coll s| |
|
122 |
||
123 |
(aStringOrCollection isNil or:[aStringOrCollection isEmpty]) ifTrue:[ |
|
131 | 124 |
^ self select:nil |
60 | 125 |
]. |
126 |
||
127 |
(s := aStringOrCollection) isString ifFalse:[ |
|
128 |
s size == 1 ifTrue:[ |
|
129 |
s := s first |
|
130 |
] ifFalse:[ |
|
131 |
coll := OrderedCollection new. |
|
132 |
||
133 |
s do:[:aName| |
|
134 |
(prop := self propertyOfName:aName) notNil ifTrue:[ |
|
135 |
coll add:(prop view) |
|
136 |
] |
|
137 |
]. |
|
138 |
coll size == 1 ifTrue:[ ^ self select:(coll at:1) ]. |
|
131 | 139 |
coll size == 0 ifTrue:[ ^ self select:nil ]. |
60 | 140 |
|
141 |
^ self select:coll. |
|
142 |
] |
|
143 |
]. |
|
144 |
||
145 |
prop := self propertyOfName:s. |
|
131 | 146 |
prop isNil ifTrue:[^ self select:nil] |
60 | 147 |
ifFalse:[^ self select:(prop view)] |
148 |
||
149 |
! ! |
|
150 |
||
111 | 151 |
!UIPainterView methodsFor:'change & update'! |
152 |
||
223 | 153 |
layoutChanged |
238 | 154 |
treeView layoutChanged |
111 | 155 |
! ! |
156 |
||
60 | 157 |
!UIPainterView methodsFor:'copy & cut & paste'! |
158 |
||
159 |
copySelection |
|
160 |
"copy the selection into the cut&paste-buffer |
|
161 |
" |
|
71 | 162 |
|specs coll| |
163 |
||
128 | 164 |
coll := self minSetOfSuperViews:(self selection). |
60 | 165 |
|
71 | 166 |
coll notNil ifTrue:[ |
131 | 167 |
self select:nil. |
78 | 168 |
specs := coll collect:[:aView| self fullSpecFor:aView ]. |
60 | 169 |
self setSelection:specs |
170 |
]. |
|
78 | 171 |
|
172 |
||
60 | 173 |
! |
174 |
||
175 |
deleteSelection |
|
62 | 176 |
"delete the selection; copy the selection into the cut&paste-buffer |
177 |
and open a transaction |
|
60 | 178 |
" |
134 | 179 |
|specs coll| |
71 | 180 |
|
128 | 181 |
coll := self minSetOfSuperViews:(self selection). |
60 | 182 |
|
78 | 183 |
coll notNil ifTrue:[ |
238 | 184 |
treeView cvsEventsDisabledDo:[ |
131 | 185 |
self select:nil. |
111 | 186 |
specs := coll collect:[:aView| self fullSpecFor:aView ]. |
60 | 187 |
|
134 | 188 |
self withinTransaction:#cut objects:coll do:[ |
189 |
coll reverseDo:[:aView| |
|
190 |
self createUndoRemove:aView. |
|
191 |
self remove:aView |
|
111 | 192 |
] |
193 |
]. |
|
194 |
self setSelection:specs. |
|
195 |
] |
|
60 | 196 |
] |
197 |
! |
|
198 |
||
199 |
pasteBuffer |
|
62 | 200 |
"add the objects in the paste-buffer to the object view |
60 | 201 |
" |
223 | 202 |
|sel| |
203 |
||
204 |
sel := self pasteSpecifications:(self getSelection) keepLayout:false. |
|
205 |
||
206 |
sel notNil ifTrue:[ |
|
207 |
self select:sel. |
|
208 |
]. |
|
89 | 209 |
|
210 |
! |
|
211 |
||
212 |
pasteSpecifications:aSpecificationOrList keepLayout:keepLayout |
|
223 | 213 |
"add the specs to the object view; returns list of pasted components |
89 | 214 |
" |
111 | 215 |
|paste frame pasteOrigin pasteOffset builder newSel| |
60 | 216 |
|
89 | 217 |
(self canPaste:aSpecificationOrList) ifFalse:[ |
223 | 218 |
^ nil |
89 | 219 |
]. |
223 | 220 |
|
238 | 221 |
treeView cvsSetupListDo:[ |
165 | 222 |
aSpecificationOrList isCollection ifTrue:[ |
223 |
paste := aSpecificationOrList |
|
224 |
] ifFalse:[ |
|
225 |
paste := Array with:aSpecificationOrList |
|
226 |
]. |
|
223 | 227 |
(frame := self singleSelection) isNil ifTrue:[ |
165 | 228 |
frame := self |
229 |
]. |
|
230 |
self setSelection:nil withRedraw:true. |
|
60 | 231 |
|
165 | 232 |
newSel := OrderedCollection new. |
233 |
builder := UIBuilder new. |
|
212 | 234 |
className notNil ifTrue:[ |
235 |
builder applicationClass:(Smalltalk classNamed:className). |
|
236 |
]. |
|
89 | 237 |
|
165 | 238 |
keepLayout ifFalse:[ |
239 |
pasteOffset := 0@0. |
|
240 |
pasteOrigin := self sensor mousePoint. |
|
241 |
pasteOrigin := device translatePoint:pasteOrigin from:device rootView id to:frame id. |
|
242 |
]. |
|
60 | 243 |
|
223 | 244 |
paste do:[:aSpec| |
245 |
|view| |
|
60 | 246 |
|
223 | 247 |
view := self addSpec:aSpec builder:builder in:frame. |
60 | 248 |
|
223 | 249 |
keepLayout ifFalse:[ |
250 |
(frame bounds containsPoint:pasteOrigin) ifFalse:[ |
|
251 |
self moveObject:view to:pasteOffset. |
|
252 |
] ifTrue:[ |
|
253 |
self moveObject:view to:pasteOrigin + pasteOffset. |
|
111 | 254 |
]. |
223 | 255 |
pasteOffset := pasteOffset + 4 |
89 | 256 |
]. |
223 | 257 |
view realize. |
258 |
newSel add:view. |
|
60 | 259 |
]. |
260 |
||
165 | 261 |
self withinTransaction:#paste objects:newSel do:[ |
262 |
undoHistory addUndoSelector:#undoCreate: |
|
263 |
withArgs:(newSel collect:[:v|(self propertyOfView:v) identifier]) |
|
264 |
]. |
|
134 | 265 |
|
165 | 266 |
newSel size == 1 ifTrue:[ |
267 |
newSel := newSel at:1 |
|
268 |
]. |
|
269 |
self realizeAllSubViews. |
|
270 |
inputView raise. |
|
271 |
self elementChangedSize:frame. |
|
223 | 272 |
]. |
273 |
^ newSel |
|
89 | 274 |
! |
275 |
||
276 |
pasteWithLayout |
|
277 |
"add the objects in the paste-buffer to the object view; don't change the |
|
278 |
layout |
|
279 |
" |
|
223 | 280 |
|sel| |
281 |
||
282 |
sel := self pasteSpecifications:(self getSelection) keepLayout:true. |
|
89 | 283 |
|
223 | 284 |
sel notNil ifTrue:[ |
285 |
self select:sel. |
|
286 |
]. |
|
60 | 287 |
! ! |
288 |
||
289 |
!UIPainterView methodsFor:'drag & drop'! |
|
290 |
||
291 |
canDrop:anObjectOrCollection |
|
223 | 292 |
anObjectOrCollection size == 1 ifTrue:[ |
293 |
^ self canPaste:(anObjectOrCollection first theObject) |
|
294 |
]. |
|
295 |
^ false |
|
296 |
! |
|
297 |
||
298 |
canPaste:something |
|
299 |
"returns true if something could be paste |
|
300 |
" |
|
301 |
|el size| |
|
302 |
||
303 |
((size := self numberOfSelections) <= 1 and:[self enabled]) ifFalse:[ |
|
304 |
^ false |
|
305 |
]. |
|
306 |
something isCollection ifTrue:[something notEmpty ifTrue:[el := something first]] |
|
307 |
ifFalse:[el := something]. |
|
308 |
||
309 |
(el isKindOf:UISpecification) ifFalse:[ |
|
310 |
^ false |
|
311 |
]. |
|
312 |
||
313 |
size == 1 ifTrue:[ |
|
314 |
^ self canPasteInto:(self singleSelection) |
|
315 |
]. |
|
316 |
^ true |
|
317 |
||
318 |
! |
|
319 |
||
320 |
canPasteInto:aView |
|
321 |
"can paste into a view |
|
322 |
" |
|
89 | 323 |
|spec| |
60 | 324 |
|
223 | 325 |
aView notNil ifTrue:[ |
326 |
spec := self specFor:aView. |
|
327 |
||
328 |
spec isNil ifTrue:[^ aView specClass supportsSubComponents] |
|
329 |
ifFalse:[^ spec class supportsSubComponents] |
|
89 | 330 |
]. |
331 |
^ false |
|
96
73725336b4fe
dont paste into scrollable selectionInListViews ...
Claus Gittinger <cg@exept.de>
parents:
89
diff
changeset
|
332 |
|
60 | 333 |
! |
334 |
||
335 |
drop:anObjectOrCollection at:aPoint |
|
223 | 336 |
|spec newSel oldSel| |
89 | 337 |
|
231 | 338 |
(oldSel := selection) isCollection ifTrue:[ |
339 |
oldSel := selection copy |
|
340 |
]. |
|
89 | 341 |
spec := (anObjectOrCollection at:1) theObject. |
223 | 342 |
newSel := self pasteSpecifications:spec keepLayout:false. |
60 | 343 |
|
223 | 344 |
oldSel isNil ifTrue:[self select:newSel] |
345 |
ifFalse:[self select:oldSel] |
|
60 | 346 |
! ! |
347 |
||
78 | 348 |
!UIPainterView methodsFor:'generating output'! |
349 |
||
60 | 350 |
generateActionMethodFor:aspect spec:protoSpec inClass:targetClass |
149 | 351 |
|args showIt| |
141 | 352 |
|
149 | 353 |
(aspect asSymbol numArgs) == 1 ifFalse:[ |
354 |
args := '\'. |
|
355 |
showIt := ' ...''.\'. |
|
356 |
] ifTrue:[ |
|
357 |
args := 'anArgument\'. |
|
358 |
showIt := ''' , anArgument printString , '' ...''.\'. |
|
359 |
]. |
|
141 | 360 |
|
60 | 361 |
^ ('!!' , targetClass name , ' methodsFor:''actions''!!\\' , |
141 | 362 |
aspect , args , |
60 | 363 |
' "automatically generated by UIPainter ..."\' , |
364 |
'\' , |
|
365 |
' "action to be added ..."\' , |
|
149 | 366 |
' Transcript showCR:self class name , '': action for ' , aspect , showIt , |
60 | 367 |
'!! !!\\') withCRs |
368 |
! |
|
369 |
||
370 |
generateAspectMethodFor:aspect spec:protoSpec inClass:targetClass |
|
134 | 371 |
|modelClass| |
372 |
||
149 | 373 |
modelClass := protoSpec defaultModelClassFor:aspect. |
134 | 374 |
|
60 | 375 |
^ ('!!' , targetClass name , ' methodsFor:''aspects''!!\\' , |
376 |
aspect , '\' , |
|
377 |
' "automatically generated by UIPainter ..."\' , |
|
378 |
'\' , |
|
379 |
' |holder|\' , |
|
380 |
'\' , |
|
381 |
' (holder := builder bindingAt:#' , aspect , ') isNil ifTrue:[\' , |
|
134 | 382 |
' builder aspectAt:#' , aspect , ' put:(holder := ' , ' ' , modelClass name , ' new' , ').\' , |
60 | 383 |
' ].\' , |
384 |
' ^ holder\' , |
|
385 |
'!! !!\\') withCRs |
|
386 |
! |
|
387 |
||
388 |
generateAspectMethods |
|
158
6e7f892308ae
do not generate accept/cancel and help action methods,
Claus Gittinger <cg@exept.de>
parents:
156
diff
changeset
|
389 |
|cls code skip| |
60 | 390 |
|
78 | 391 |
code := ''. |
392 |
||
60 | 393 |
className isNil ifTrue:[ |
69 | 394 |
self warn:'set the class first'. |
78 | 395 |
^ code |
60 | 396 |
]. |
89 | 397 |
cls := Smalltalk classNamed:className. |
60 | 398 |
|
238 | 399 |
treeView propertiesDo:[:aProp | |
62 | 400 |
|modelSelector menuSelector protoSpec thisCode| |
60 | 401 |
|
134 | 402 |
protoSpec := aProp spec. |
175 | 403 |
|
78 | 404 |
(modelSelector := aProp model) notNil ifTrue:[ |
60 | 405 |
(cls implements:modelSelector asSymbol) ifFalse:[ |
158
6e7f892308ae
do not generate accept/cancel and help action methods,
Claus Gittinger <cg@exept.de>
parents:
156
diff
changeset
|
406 |
skip := false. |
6e7f892308ae
do not generate accept/cancel and help action methods,
Claus Gittinger <cg@exept.de>
parents:
156
diff
changeset
|
407 |
(cls isSubclassOf:SimpleDialog) ifTrue:[ |
6e7f892308ae
do not generate accept/cancel and help action methods,
Claus Gittinger <cg@exept.de>
parents:
156
diff
changeset
|
408 |
skip := SimpleDialog implements:modelSelector asSymbol |
60 | 409 |
]. |
158
6e7f892308ae
do not generate accept/cancel and help action methods,
Claus Gittinger <cg@exept.de>
parents:
156
diff
changeset
|
410 |
skip ifFalse:[ |
6e7f892308ae
do not generate accept/cancel and help action methods,
Claus Gittinger <cg@exept.de>
parents:
156
diff
changeset
|
411 |
"/ kludge .. |
6e7f892308ae
do not generate accept/cancel and help action methods,
Claus Gittinger <cg@exept.de>
parents:
156
diff
changeset
|
412 |
(protoSpec isMemberOf:ActionButtonSpec) ifTrue:[ |
6e7f892308ae
do not generate accept/cancel and help action methods,
Claus Gittinger <cg@exept.de>
parents:
156
diff
changeset
|
413 |
thisCode := (self generateActionMethodFor:modelSelector spec:protoSpec inClass:cls). |
6e7f892308ae
do not generate accept/cancel and help action methods,
Claus Gittinger <cg@exept.de>
parents:
156
diff
changeset
|
414 |
] ifFalse:[ |
6e7f892308ae
do not generate accept/cancel and help action methods,
Claus Gittinger <cg@exept.de>
parents:
156
diff
changeset
|
415 |
thisCode := (self generateAspectMethodFor:modelSelector spec:protoSpec inClass:cls). |
6e7f892308ae
do not generate accept/cancel and help action methods,
Claus Gittinger <cg@exept.de>
parents:
156
diff
changeset
|
416 |
]. |
6e7f892308ae
do not generate accept/cancel and help action methods,
Claus Gittinger <cg@exept.de>
parents:
156
diff
changeset
|
417 |
code := code , thisCode |
6e7f892308ae
do not generate accept/cancel and help action methods,
Claus Gittinger <cg@exept.de>
parents:
156
diff
changeset
|
418 |
]. |
62 | 419 |
]. |
420 |
]. |
|
421 |
||
78 | 422 |
(menuSelector := aProp menu) notNil ifTrue:[ |
62 | 423 |
(cls implements:menuSelector asSymbol) ifFalse:[ |
424 |
thisCode := (self generateAspectMethodFor:menuSelector spec:protoSpec inClass:cls). |
|
425 |
code := code , thisCode |
|
60 | 426 |
] |
111 | 427 |
]. |
428 |
||
429 |
aProp spec aspectSelectors do:[:aSel| |
|
430 |
(cls implements:aSel asSymbol) ifFalse:[ |
|
431 |
thisCode := (self generateAspectMethodFor:aSel spec:protoSpec inClass:cls). |
|
432 |
code := code , thisCode |
|
433 |
] |
|
434 |
]. |
|
137 | 435 |
aProp spec actionSelectors do:[:aSel| |
436 |
(cls implements:aSel asSymbol) ifFalse:[ |
|
437 |
thisCode := (self generateActionMethodFor:aSel spec:protoSpec inClass:cls). |
|
438 |
code := code , thisCode |
|
439 |
] |
|
440 |
]. |
|
188
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
441 |
aProp spec valueSelectors do:[:aSel| |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
442 |
(cls implements:aSel asSymbol) ifFalse:[ |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
443 |
thisCode := (self generateValueMethodFor:aSel spec:protoSpec inClass:cls). |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
444 |
code := code , thisCode |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
445 |
] |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
446 |
]. |
111 | 447 |
|
60 | 448 |
]. |
449 |
^ code |
|
450 |
! |
|
451 |
||
188
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
452 |
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
453 |
^ ('!!' , targetClass name , ' methodsFor:''values''!!\\' , |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
454 |
aspect , '\' , |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
455 |
' "automatically generated by UIPainter ..."\' , |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
456 |
'\' , |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
457 |
' "value to be added below ..."\' , |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
458 |
' Transcript showCR:self class name , '': no value yet for ' , aspect , ' ...''.\' , |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
459 |
'\' , |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
460 |
'^ nil.' , |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
461 |
'!! !!\\') withCRs |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
462 |
|
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
463 |
|
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
464 |
|
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
465 |
|
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
466 |
! |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
467 |
|
78 | 468 |
generateWindowSpecMethodSource |
238 | 469 |
|spec specArray str code category cls mthd| |
60 | 470 |
|
78 | 471 |
specArray := OrderedCollection new. |
60 | 472 |
|
78 | 473 |
self subViews do:[:aView| |
474 |
aView ~~ inputView ifTrue:[ |
|
475 |
specArray add:(self fullSpecFor:aView) |
|
60 | 476 |
] |
477 |
]. |
|
78 | 478 |
spec := FullSpec new. |
479 |
spec fromBuilder:self components:(SpecCollection new collection:specArray). |
|
60 | 480 |
specArray := spec literalArrayEncoding. |
481 |
||
482 |
str := WriteStream on:String new. |
|
86 | 483 |
UISpecification prettyPrintSpecArray:specArray on:str indent:5. |
60 | 484 |
|
178
fb8451053c96
keep windowSpec methods category if it already exists
Claus Gittinger <cg@exept.de>
parents:
175
diff
changeset
|
485 |
"/ 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
|
486 |
|
fb8451053c96
keep windowSpec methods category if it already exists
Claus Gittinger <cg@exept.de>
parents:
175
diff
changeset
|
487 |
category := 'interface specs'. |
fb8451053c96
keep windowSpec methods category if it already exists
Claus Gittinger <cg@exept.de>
parents:
175
diff
changeset
|
488 |
(cls := Smalltalk classNamed:className) notNil ifTrue:[ |
fb8451053c96
keep windowSpec methods category if it already exists
Claus Gittinger <cg@exept.de>
parents:
175
diff
changeset
|
489 |
(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
|
490 |
category := mthd category. |
fb8451053c96
keep windowSpec methods category if it already exists
Claus Gittinger <cg@exept.de>
parents:
175
diff
changeset
|
491 |
] |
fb8451053c96
keep windowSpec methods category if it already exists
Claus Gittinger <cg@exept.de>
parents:
175
diff
changeset
|
492 |
]. |
fb8451053c96
keep windowSpec methods category if it already exists
Claus Gittinger <cg@exept.de>
parents:
175
diff
changeset
|
493 |
|
238 | 494 |
code := '!!' |
178
fb8451053c96
keep windowSpec methods category if it already exists
Claus Gittinger <cg@exept.de>
parents:
175
diff
changeset
|
495 |
, className , ' class methodsFor:' , category storeString |
238 | 496 |
, '!!' , '\\' |
60 | 497 |
|
498 |
, methodName , '\' |
|
499 |
, ' "this window spec was automatically generated by the ST/X UIPainter"\\' |
|
500 |
, ' "do not manually edit this - the painter/builder may not be able to\' |
|
501 |
, ' handle the specification if its corrupted."\\' |
|
502 |
, ' "\' |
|
503 |
, ' UIPainter new openOnClass:' , className , ' andSelector:#' , methodName , '\' |
|
504 |
, ' ' , className , ' new openInterface:#' , methodName , '\' |
|
505 |
, ' "\'. |
|
506 |
||
507 |
methodName = 'windowSpec' ifTrue:[ |
|
508 |
code := code , ' "' , className , ' open"\' |
|
509 |
]. |
|
510 |
code := code |
|
511 |
, '\' |
|
512 |
, ' <resource: #canvas>\\' |
|
513 |
, ' ^\' |
|
514 |
, ' ', str contents |
|
515 |
, '\' |
|
238 | 516 |
, '!! !!' |
60 | 517 |
, '\\'. |
518 |
||
519 |
^ code withCRs |
|
520 |
||
521 |
"Modified: 5.9.1995 / 21:01:35 / claus" |
|
178
fb8451053c96
keep windowSpec methods category if it already exists
Claus Gittinger <cg@exept.de>
parents:
175
diff
changeset
|
522 |
"Modified: 24.6.1997 / 19:12:44 / cg" |
60 | 523 |
! ! |
524 |
||
525 |
!UIPainterView methodsFor:'initialization'! |
|
526 |
||
527 |
initialize |
|
62 | 528 |
"setup attributes |
529 |
" |
|
60 | 530 |
super initialize. |
531 |
||
532 |
superclassName := 'ApplicationModel'. |
|
533 |
className := 'NewApplication'. |
|
534 |
methodName := 'windowSpec'. |
|
535 |
categoryName := 'Applications'. |
|
536 |
HandCursor := Cursor leftHand. |
|
537 |
||
538 |
! |
|
539 |
||
540 |
setupFromSpec:specOrSpecArray |
|
78 | 541 |
|spec builder| |
60 | 542 |
|
238 | 543 |
treeView cvsSetupListDo:[ |
111 | 544 |
self removeAll. |
545 |
spec := UISpecification from:specOrSpecArray. |
|
546 |
builder := UIBuilder new. |
|
547 |
spec window setupView:self topView for:builder. |
|
548 |
self addSpec:(spec component) builder:builder in:self. |
|
549 |
self realizeAllSubViews. |
|
550 |
inputView raise. |
|
551 |
] |
|
223 | 552 |
! |
553 |
||
554 |
treeView:aTreeView |
|
238 | 555 |
treeView := aTreeView |
60 | 556 |
! ! |
557 |
||
558 |
!UIPainterView methodsFor:'menus'! |
|
559 |
||
121 | 560 |
showMiddleButtonMenu |
561 |
"show the middle button menu; this returns nil |
|
62 | 562 |
" |
223 | 563 |
|menu| |
60 | 564 |
|
223 | 565 |
self enabled ifTrue:[ |
566 |
menu := MenuPanel fromSpec:(UIPainter menuCanvas) receiver:self. |
|
60 | 567 |
|
223 | 568 |
self hasSelection ifFalse:[ |
569 |
menu disableAll |
|
570 |
]. |
|
571 |
menu enabledAt:#paste put:(self canPaste:(self getSelection)). |
|
572 |
menu enabledAt:#undo put:(undoHistory isEmpty not). |
|
573 |
menu startUp. |
|
111 | 574 |
]. |
121 | 575 |
^ nil |
60 | 576 |
|
62 | 577 |
|
578 |
||
60 | 579 |
! ! |
580 |
||
581 |
!UIPainterView methodsFor:'removing components'! |
|
582 |
||
78 | 583 |
remove:anObject |
584 |
"remove anObject from the contents do redraw |
|
60 | 585 |
" |
134 | 586 |
anObject notNil ifTrue:[ |
238 | 587 |
treeView removeView:anObject. |
134 | 588 |
] |
60 | 589 |
! |
590 |
||
591 |
removeAll |
|
62 | 592 |
"remove all objects and properties |
593 |
" |
|
238 | 594 |
treeView cvsEventsDisabledDo:[ |
223 | 595 |
self select:nil. |
238 | 596 |
treeView removeAll. |
223 | 597 |
self removeUndoHistory. |
111 | 598 |
] |
60 | 599 |
! ! |
600 |
||
601 |
!UIPainterView methodsFor:'searching'! |
|
602 |
||
89 | 603 |
findContainerViewAt:aPoint |
604 |
"find container view responds to aPoint. |
|
605 |
" |
|
606 |
|view| |
|
607 |
||
608 |
(view := self findObjectAt:aPoint) isNil ifTrue:[ |
|
609 |
^ self |
|
610 |
]. |
|
611 |
||
612 |
[(view specClass supportsSubComponents or:[(view := view superView) == self]) |
|
613 |
] whileFalse:[ |
|
614 |
[(self propertyOfView:view) isNil] whileTrue:[ |
|
615 |
(view := view superView) == self ifTrue:[^ self] |
|
616 |
]. |
|
617 |
]. |
|
618 |
^ view |
|
619 |
! |
|
620 |
||
60 | 621 |
findObjectAt:aPoint |
622 |
"find the origin/corner of the currentWidget |
|
623 |
" |
|
624 |
|view| |
|
625 |
||
626 |
view := super findObjectAt:aPoint. |
|
627 |
||
628 |
view notNil ifTrue:[ |
|
629 |
"can be a view within a view not visible |
|
630 |
" |
|
631 |
[ (self propertyOfView:view) isNil ] whileTrue:[ |
|
632 |
(view := view superView) == self ifTrue:[^ nil] |
|
633 |
] |
|
634 |
]. |
|
635 |
^ view |
|
636 |
! |
|
637 |
||
638 |
findViewWithId:aViewId |
|
62 | 639 |
"finds view assigned to identifier and returns the view or nil |
60 | 640 |
" |
641 |
|prop| |
|
642 |
||
643 |
prop := self propertyOfIdentifier:aViewId. |
|
644 |
||
645 |
prop notNil ifTrue:[^ prop view] |
|
646 |
ifFalse:[^ nil] |
|
78 | 647 |
! |
648 |
||
649 |
propertyOfIdentifier:anId |
|
650 |
"returns property assigned to unique identifier |
|
651 |
" |
|
652 |
anId notNil ifTrue:[ |
|
238 | 653 |
^ treeView propertyDetect:[:p| p identifier == anId ] |
78 | 654 |
]. |
655 |
^ nil |
|
656 |
! |
|
657 |
||
658 |
propertyOfName:aString |
|
659 |
"returns property assigned to name |
|
660 |
" |
|
111 | 661 |
|name| |
662 |
||
663 |
aString isNil ifFalse:[ |
|
664 |
name := aString string withoutSeparators. |
|
238 | 665 |
^ treeView propertyDetect:[:p| p name = name ]. |
78 | 666 |
]. |
667 |
^ nil |
|
668 |
! |
|
669 |
||
670 |
propertyOfView:aView |
|
671 |
"returns property assigned to view |
|
672 |
" |
|
673 |
(aView isNil or:[aView == self]) ifFalse:[ |
|
238 | 674 |
^ treeView propertyDetect:[:p| p view == aView ] |
78 | 675 |
]. |
676 |
^ nil |
|
677 |
! |
|
678 |
||
111 | 679 |
uniqueNameFor:aSpecOrString |
78 | 680 |
"generate and return an unique name for a class |
681 |
" |
|
682 |
|next name size| |
|
683 |
||
111 | 684 |
aSpecOrString isString ifFalse:[name := aSpecOrString className asString] |
685 |
ifTrue:[name := aSpecOrString]. |
|
78 | 686 |
|
111 | 687 |
(name endsWith:'Spec') ifTrue:[ |
688 |
name := name copyFrom:1 to:(name size - 4). |
|
689 |
] ifFalse:[ |
|
690 |
name := name copy |
|
691 |
]. |
|
78 | 692 |
name at:1 put:(name at:1) asLowercase. |
111 | 693 |
size := name size + 1. |
694 |
next := 0. |
|
78 | 695 |
|
238 | 696 |
treeView propertiesDo:[:p| |
111 | 697 |
|n| |
78 | 698 |
n := p name. |
699 |
||
700 |
(n size >= size and:[n startsWith:name]) ifTrue:[ |
|
701 |
next := next max:(p extractNumberStartingAt:size) |
|
702 |
] |
|
703 |
]. |
|
704 |
next := next + 1. |
|
705 |
name := name, next printString. |
|
706 |
^ name |
|
707 |
||
708 |
||
709 |
||
710 |
! |
|
711 |
||
712 |
uniqueNameOf:aView |
|
111 | 713 |
|prop| |
78 | 714 |
|
111 | 715 |
(prop := self propertyOfView:aView) notNil ifTrue:[ |
716 |
prop name isNil ifTrue:[ |
|
717 |
prop name:(self uniqueNameFor:(prop spec)). |
|
718 |
]. |
|
719 |
^ prop name |
|
78 | 720 |
]. |
111 | 721 |
^ 'self' |
78 | 722 |
|
60 | 723 |
! ! |
724 |
||
223 | 725 |
!UIPainterView methodsFor:'selection basics'! |
726 |
||
727 |
addToSelection:anObject |
|
728 |
"add an object to the selection |
|
729 |
" |
|
730 |
(self enabled and:[(self isSelected:anObject) not]) ifTrue:[ |
|
731 |
selection isCollection ifFalse:[ |
|
732 |
selection isNil ifTrue:[ |
|
733 |
selection := anObject |
|
734 |
] ifFalse:[ |
|
735 |
selection := OrderedCollection with:selection with:anObject |
|
736 |
] |
|
737 |
] ifTrue:[ |
|
738 |
selection add:anObject |
|
739 |
]. |
|
740 |
self showSelected:anObject. |
|
238 | 741 |
treeView cvsSelectionAdd:anObject. |
223 | 742 |
] |
743 |
||
744 |
||
745 |
! |
|
746 |
||
747 |
removeFromSelection:anObject |
|
748 |
"remove an object from the selection |
|
749 |
" |
|
750 |
(self isSelected:anObject) ifTrue:[ |
|
751 |
self showUnselected:anObject. |
|
752 |
||
753 |
selection size > 1 ifTrue:[ |
|
754 |
selection remove:anObject ifAbsent:nil. |
|
755 |
self showSelection. |
|
756 |
] ifFalse:[ |
|
757 |
selection := nil |
|
758 |
]. |
|
238 | 759 |
treeView cvsSelectionRemove:anObject. |
223 | 760 |
] |
761 |
||
762 |
! |
|
763 |
||
764 |
select:something |
|
765 |
"change selection to something |
|
766 |
" |
|
767 |
(self enabled and:[something ~= self selection]) ifTrue:[ |
|
768 |
self setSelection:something withRedraw:true. |
|
238 | 769 |
treeView cvsSelection:something |
223 | 770 |
] |
771 |
||
772 |
! |
|
773 |
||
774 |
updateSelectionFromModel:aSel |
|
775 |
"update selection from a new selection |
|
776 |
" |
|
777 |
|sel| |
|
778 |
||
779 |
selectionHiddenLevel == 0 ifTrue:[ |
|
780 |
self selectionDo:[:el| (aSel includes:el) ifFalse:[self showUnselected:el] ] |
|
781 |
]. |
|
782 |
||
783 |
(aSel indexOf:self) ~~ 0 ifTrue:[ |
|
784 |
aSel size > 1 ifTrue:[sel := aSel copyWithout:self] |
|
785 |
] ifFalse:[ |
|
786 |
aSel size ~~ 0 ifTrue:[sel := aSel] |
|
787 |
]. |
|
788 |
||
789 |
self setSelection:sel withRedraw:false. |
|
790 |
self showSelection |
|
791 |
||
792 |
||
793 |
! ! |
|
794 |
||
78 | 795 |
!UIPainterView methodsFor:'specification'! |
796 |
||
797 |
addSpec:aSpecification builder:aBuilder in:aFrame |
|
798 |
"build view and subviews from aSpecification into a frame. The top view |
|
799 |
is returned. The contained components of a spec are set to nil |
|
800 |
" |
|
212 | 801 |
|
802 |
className notNil ifTrue:[ |
|
803 |
aBuilder applicationClass:(Smalltalk classNamed:className). |
|
804 |
]. |
|
78 | 805 |
|
111 | 806 |
aBuilder componentCreationHook:[:aView :aSpec :aBdr||sv p s n| |
78 | 807 |
p := ViewProperty new. |
808 |
s := aSpec copy. |
|
809 |
p spec:s. |
|
810 |
p view:aView. |
|
811 |
||
812 |
s class supportsSubComponents ifTrue:[ |
|
813 |
s component:nil |
|
814 |
]. |
|
815 |
||
111 | 816 |
n := s name. |
817 |
||
818 |
(n isNil or:[(self propertyOfName:n) notNil]) ifTrue:[ |
|
819 |
s name:(self uniqueNameFor:s) |
|
78 | 820 |
]. |
238 | 821 |
treeView addProperty:p. |
78 | 822 |
]. |
823 |
||
824 |
^ aSpecification buildViewWithLayoutFor:aBuilder in:aFrame. |
|
60 | 825 |
|
212 | 826 |
"Modified: 4.7.1997 / 23:48:55 / cg" |
78 | 827 |
! |
828 |
||
829 |
fullSpecFor:anObject |
|
830 |
"generate a full spec for an object |
|
62 | 831 |
" |
78 | 832 |
|mySpec subSpecs| |
833 |
||
834 |
mySpec := self specFor:anObject. |
|
835 |
||
836 |
(mySpec notNil and:[mySpec class supportsSubComponents]) ifTrue:[ |
|
837 |
(anObject subViews notNil) ifTrue:[ |
|
838 |
anObject subViews do:[:aSubView||spec| |
|
839 |
spec := self fullSpecFor:aSubView. |
|
840 |
spec notNil ifTrue:[ |
|
841 |
subSpecs isNil ifTrue:[ |
|
842 |
subSpecs := OrderedCollection new |
|
843 |
]. |
|
844 |
subSpecs add:spec. |
|
845 |
]. |
|
846 |
]. |
|
847 |
subSpecs notNil ifTrue:[ |
|
848 |
mySpec component:(SpecCollection new collection:subSpecs) |
|
849 |
] |
|
850 |
] |
|
851 |
]. |
|
852 |
^ mySpec |
|
853 |
||
60 | 854 |
|
855 |
||
856 |
||
857 |
||
858 |
||
859 |
! |
|
860 |
||
78 | 861 |
specFor:anObject |
862 |
"returns spec assigned to an object |
|
62 | 863 |
" |
78 | 864 |
|prop spec| |
60 | 865 |
|
78 | 866 |
(prop := self propertyOfView:anObject) notNil ifTrue:[ |
867 |
spec := prop spec copy. |
|
868 |
spec layoutFromView:anObject |
|
60 | 869 |
]. |
78 | 870 |
^ spec |
871 |
||
872 |
||
873 |
||
60 | 874 |
! |
875 |
||
146 | 876 |
specForSelection |
877 |
"returns spec assigned to current single selection or nil |
|
878 |
" |
|
879 |
^ self specFor:(self singleSelection) |
|
880 |
||
881 |
||
882 |
! |
|
883 |
||
78 | 884 |
updateFromSpec:aSpec |
885 |
"update current selected view from specification |
|
62 | 886 |
" |
78 | 887 |
|props name builder v| |
888 |
||
889 |
self singleSelection notNil ifTrue:[ |
|
890 |
self withSelectionHiddenDo:[ |
|
891 |
self transaction:#specification selectionDo:[:aView| |
|
892 |
builder := UIBuilder new. |
|
212 | 893 |
className notNil ifTrue:[ |
894 |
builder applicationClass:(Smalltalk classNamed:className). |
|
895 |
]. |
|
78 | 896 |
props := self propertyOfView:aView. |
82 | 897 |
name := (aSpec name) withoutSeparators. |
78 | 898 |
|
82 | 899 |
name = props name ifFalse:[ |
900 |
(self propertyOfName:name) notNil ifTrue:[ |
|
901 |
name := props name |
|
78 | 902 |
] |
903 |
]. |
|
82 | 904 |
aSpec name:name. |
134 | 905 |
self createUndoSpecModify:props. |
78 | 906 |
|
907 |
aSpec needsRebuildForAttributes ifTrue:[ |
|
908 |
v := aSpec buildViewWithLayoutFor:builder in:aView superView. |
|
909 |
v realize. |
|
910 |
aView destroy. |
|
911 |
device sync. device flush. |
|
912 |
aView becomeSameAs:v. |
|
913 |
inputView raise. |
|
914 |
] ifFalse:[ |
|
915 |
aSpec setAttributesIn:aView with:builder. |
|
916 |
self elementChangedSize:aView. |
|
917 |
]. |
|
918 |
props spec:(aSpec copy). |
|
238 | 919 |
treeView propertyChanged:props. |
78 | 920 |
] |
111 | 921 |
] |
82 | 922 |
] |
212 | 923 |
|
924 |
"Modified: 4.7.1997 / 23:49:44 / cg" |
|
60 | 925 |
! ! |
926 |
||
927 |
!UIPainterView methodsFor:'transaction'! |
|
928 |
||
929 |
transaction:aType objects:something do:aOneArgBlock |
|
930 |
"opens a transaction and evaluates a block within the transaction; the |
|
931 |
argument to the block is a view from derived from something |
|
932 |
" |
|
134 | 933 |
self withinTransaction:aType objects:something do:[ |
934 |
self forEach:something do:aOneArgBlock |
|
60 | 935 |
] |
936 |
! |
|
937 |
||
134 | 938 |
withinTransaction:aType objects:objects do:aNoneArgBlock |
939 |
"evaluate a block with no arguments within a transaction |
|
60 | 940 |
" |
134 | 941 |
|text size prop| |
942 |
||
943 |
objects isNil ifTrue:[ ^ self ]. |
|
944 |
||
945 |
size := objects size. |
|
60 | 946 |
|
134 | 947 |
objects isCollection ifTrue:[ |
948 |
size == 0 ifTrue:[ ^ self ]. |
|
949 |
size == 1 ifTrue:[ prop := self propertyOfView:(objects first) ] |
|
950 |
] ifFalse:[ |
|
951 |
prop := self propertyOfView:objects |
|
952 |
]. |
|
60 | 953 |
|
134 | 954 |
prop notNil ifTrue:[ |
955 |
text := prop name |
|
956 |
] ifFalse:[ |
|
957 |
text := size printString, ' elements' |
|
60 | 958 |
]. |
134 | 959 |
|
960 |
undoHistory withinTransaction:aType text:text do:[ |
|
961 |
aNoneArgBlock value |
|
962 |
] |
|
60 | 963 |
! ! |
964 |
||
965 |
!UIPainterView methodsFor:'undo actions'! |
|
966 |
||
134 | 967 |
createUndoLayout:aView |
968 |
"create undo action before changing a views layout |
|
60 | 969 |
" |
134 | 970 |
|lyt args prop| |
60 | 971 |
|
972 |
undoHistory isTransactionOpen ifTrue:[ |
|
973 |
prop := self propertyOfView:aView. |
|
134 | 974 |
|
60 | 975 |
prop notNil ifTrue:[ |
134 | 976 |
args := Array new:3. |
977 |
args at:1 put:(prop identifier). |
|
978 |
||
979 |
(lyt := aView geometryLayout) notNil ifTrue:[ |
|
980 |
args at:2 put:#geometryLayout: |
|
981 |
] ifFalse:[ |
|
146 | 982 |
lyt := aView extent. |
134 | 983 |
args at:2 put:#extent: |
984 |
]. |
|
985 |
args at:3 put:(lyt copy). |
|
986 |
undoHistory addUndoSelector:#undoLayout: withArgs:args. |
|
60 | 987 |
] |
988 |
] |
|
989 |
! |
|
990 |
||
134 | 991 |
createUndoRemove:aView |
992 |
"create undo method before deleting views |
|
60 | 993 |
" |
134 | 994 |
|frame prop pId spec| |
995 |
||
996 |
(prop := self propertyOfView:aView) notNil ifTrue:[ |
|
997 |
spec := self fullSpecFor:aView. |
|
998 |
frame := aView superView. |
|
60 | 999 |
|
134 | 1000 |
(self canPasteInto:frame) ifTrue:[ |
1001 |
(frame := self propertyOfView:frame) notNil ifTrue:[ |
|
1002 |
pId := frame identifier |
|
1003 |
] |
|
1004 |
]. |
|
1005 |
undoHistory addUndoSelector:#undoRemove: |
|
1006 |
withArgs:(Array with:spec with:(prop identifier) with:pId) |
|
1007 |
] |
|
1008 |
! |
|
60 | 1009 |
|
134 | 1010 |
createUndoSpecModify:aProp |
1011 |
"undo method when changing the specification for an object |
|
1012 |
" |
|
1013 |
aProp notNil ifTrue:[ |
|
1014 |
undoHistory addUndoSelector:#undoSpecModify: |
|
1015 |
withArgs:(Array with:(aProp spec) with:(aProp identifier)) |
|
1016 |
] |
|
1017 |
! |
|
60 | 1018 |
|
134 | 1019 |
undoCreate:something |
1020 |
"undo method for creating or pasting an object |
|
1021 |
" |
|
1022 |
self forEach:something do:[:anId|self remove:(self findViewWithId:anId)]. |
|
1023 |
! |
|
60 | 1024 |
|
134 | 1025 |
undoLayout:args |
1026 |
"undo method to set the old layout; see 'createUndoLayout:' |
|
1027 |
" |
|
1028 |
|view| |
|
1029 |
||
1030 |
(view := self findViewWithId:(args at:1)) notNil ifTrue:[ |
|
146 | 1031 |
view perform:(args at:2) with:(args at:3). |
223 | 1032 |
self layoutChanged. |
60 | 1033 |
] |
1034 |
! |
|
1035 |
||
134 | 1036 |
undoRemove:args |
1037 |
"undo method when removing an object; see 'createUndoRemove:' |
|
1038 |
" |
|
1039 |
|frame prop view| |
|
1040 |
||
1041 |
(args at:3) notNil ifTrue:[ |
|
1042 |
frame := self findViewWithId:(args at:3). |
|
1043 |
]. |
|
1044 |
frame isNil ifTrue:[ |
|
1045 |
frame := self |
|
1046 |
]. |
|
1047 |
view := self addSpec:(args at:1) builder:(UIBuilder new) in:frame. |
|
1048 |
view realize. |
|
1049 |
inputView raise. |
|
1050 |
||
1051 |
prop := self propertyOfView:view. |
|
1052 |
prop identifier:(args at:2). |
|
1053 |
||
1054 |
! |
|
1055 |
||
1056 |
undoSpecModify:args |
|
1057 |
"undo method when changing a spec; see 'createUndoSpecModify:' |
|
60 | 1058 |
" |
80
3316c52ef2b7
write back specification to properties after undo modification
ca
parents:
78
diff
changeset
|
1059 |
|builder view spec v props| |
60 | 1060 |
|
134 | 1061 |
props := self propertyOfIdentifier:(args at:2). |
60 | 1062 |
|
134 | 1063 |
props notNil ifTrue:[ |
1064 |
view := props view. |
|
1065 |
spec := args at:1. |
|
1066 |
builder := UIBuilder new. |
|
212 | 1067 |
className notNil ifTrue:[ |
1068 |
builder applicationClass:(Smalltalk classNamed:className). |
|
1069 |
]. |
|
134 | 1070 |
props spec:spec. |
80
3316c52ef2b7
write back specification to properties after undo modification
ca
parents:
78
diff
changeset
|
1071 |
|
134 | 1072 |
spec needsRebuildForAttributes ifTrue:[ |
1073 |
v := spec buildViewWithLayoutFor:builder in:view superView. |
|
1074 |
v realize. |
|
1075 |
view destroy. |
|
1076 |
view become:v |
|
1077 |
] ifFalse:[ |
|
1078 |
spec setAttributesIn:view with:builder. |
|
1079 |
self elementChangedSize:view. |
|
1080 |
]. |
|
238 | 1081 |
treeView propertyChanged:props. |
211 | 1082 |
] |
1083 |
! ! |
|
1084 |
||
1085 |
!UIPainterView::ViewProperty class methodsFor:'instance creation'! |
|
1086 |
||
1087 |
new |
|
1088 |
Identifier notNil ifTrue:[Identifier := Identifier + 1] |
|
1089 |
ifFalse:[Identifier := 1]. |
|
1090 |
||
1091 |
^ self basicNew initialize |
|
1092 |
! ! |
|
1093 |
||
1094 |
!UIPainterView::ViewProperty methodsFor:'accessing'! |
|
1095 |
||
1096 |
identifier |
|
1097 |
"return the unique identifier assigned to property |
|
1098 |
" |
|
1099 |
^ identifier |
|
1100 |
! |
|
1101 |
||
1102 |
identifier:anIdentifier |
|
1103 |
"set the unique identifier assigned to property; called after an restore of |
|
1104 |
a deleted instance |
|
1105 |
" |
|
1106 |
identifier := anIdentifier |
|
1107 |
! |
|
1108 |
||
1109 |
spec |
|
1110 |
"return the value of the instance variable 'spec' (automatically generated)" |
|
1111 |
||
1112 |
^ spec! |
|
1113 |
||
1114 |
spec:something |
|
1115 |
"set the value of the instance variable 'spec' (automatically generated)" |
|
1116 |
||
1117 |
spec := something.! |
|
1118 |
||
1119 |
view |
|
1120 |
"return the value of the instance variable 'view' (automatically generated)" |
|
1121 |
||
1122 |
^ view! |
|
1123 |
||
1124 |
view:something |
|
1125 |
"set the value of the instance variable 'view' (automatically generated)" |
|
1126 |
||
1127 |
view := something.! ! |
|
1128 |
||
1129 |
!UIPainterView::ViewProperty methodsFor:'initialization'! |
|
1130 |
||
1131 |
initialize |
|
1132 |
super initialize. |
|
1133 |
identifier := Identifier |
|
1134 |
! ! |
|
1135 |
||
1136 |
!UIPainterView::ViewProperty methodsFor:'misc'! |
|
1137 |
||
1138 |
extractNumberStartingAt:anIndex |
|
1139 |
"return the number from the name starting at anIndex or 0. |
|
1140 |
" |
|
1141 |
|val| |
|
1142 |
||
1143 |
val := 0. |
|
1144 |
||
1145 |
self name from:anIndex do:[:c| |
|
1146 |
c isDigit ifTrue:[val := val * 10 + c digitValue] |
|
1147 |
ifFalse:[^ 0] |
|
1148 |
]. |
|
1149 |
^ val |
|
1150 |
||
1151 |
! ! |
|
1152 |
||
1153 |
!UIPainterView::ViewProperty methodsFor:'spec messages'! |
|
1154 |
||
1155 |
doesNotUnderstand:aMessage |
|
1156 |
spec notNil ifTrue:[ |
|
1157 |
(spec respondsTo:(aMessage selector)) ifTrue:[^ aMessage sendTo:spec] |
|
1158 |
]. |
|
1159 |
^ nil |
|
1160 |
! |
|
1161 |
||
1162 |
layout |
|
1163 |
spec layout |
|
1164 |
! |
|
1165 |
||
1166 |
layout:aLayout |
|
1167 |
spec layout:aLayout |
|
1168 |
! |
|
1169 |
||
1170 |
name |
|
1171 |
^ spec name |
|
1172 |
! |
|
1173 |
||
1174 |
name:aName |
|
1175 |
spec name:aName |
|
1176 |
! ! |
|
1177 |
||
60 | 1178 |
!UIPainterView class methodsFor:'documentation'! |
1179 |
||
1180 |
version |
|
1181 |
^ '$Header$' |
|
1182 |
! ! |