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