author | ca |
Fri, 15 Aug 1997 17:36:02 +0200 | |
changeset 281 | aabb4037f6a3 |
parent 279 | ef937b65a7f6 |
child 285 | d80b3c6a4373 |
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 |
||
231 | 358 |
(oldSel := selection) isCollection ifTrue:[ |
359 |
oldSel := selection copy |
|
360 |
]. |
|
89 | 361 |
spec := (anObjectOrCollection at:1) theObject. |
278 | 362 |
dragOffset := DragAndDropManager dragOffsetQuerySignal raise. |
363 |
newSel := self pasteSpecifications:spec keepLayout:false at:aPoint - dragOffset. |
|
60 | 364 |
|
223 | 365 |
oldSel isNil ifTrue:[self select:newSel] |
366 |
ifFalse:[self select:oldSel] |
|
278 | 367 |
|
279 | 368 |
"Modified: 11.8.1997 / 16:41:52 / cg" |
60 | 369 |
! ! |
370 |
||
78 | 371 |
!UIPainterView methodsFor:'generating output'! |
372 |
||
60 | 373 |
generateActionMethodFor:aspect spec:protoSpec inClass:targetClass |
149 | 374 |
|args showIt| |
141 | 375 |
|
149 | 376 |
(aspect asSymbol numArgs) == 1 ifFalse:[ |
377 |
args := '\'. |
|
378 |
showIt := ' ...''.\'. |
|
379 |
] ifTrue:[ |
|
380 |
args := 'anArgument\'. |
|
381 |
showIt := ''' , anArgument printString , '' ...''.\'. |
|
382 |
]. |
|
141 | 383 |
|
60 | 384 |
^ ('!!' , targetClass name , ' methodsFor:''actions''!!\\' , |
141 | 385 |
aspect , args , |
60 | 386 |
' "automatically generated by UIPainter ..."\' , |
387 |
'\' , |
|
388 |
' "action to be added ..."\' , |
|
149 | 389 |
' Transcript showCR:self class name , '': action for ' , aspect , showIt , |
60 | 390 |
'!! !!\\') withCRs |
391 |
! |
|
392 |
||
393 |
generateAspectMethodFor:aspect spec:protoSpec inClass:targetClass |
|
134 | 394 |
|modelClass| |
395 |
||
149 | 396 |
modelClass := protoSpec defaultModelClassFor:aspect. |
134 | 397 |
|
60 | 398 |
^ ('!!' , targetClass name , ' methodsFor:''aspects''!!\\' , |
399 |
aspect , '\' , |
|
400 |
' "automatically generated by UIPainter ..."\' , |
|
401 |
'\' , |
|
402 |
' |holder|\' , |
|
403 |
'\' , |
|
404 |
' (holder := builder bindingAt:#' , aspect , ') isNil ifTrue:[\' , |
|
134 | 405 |
' builder aspectAt:#' , aspect , ' put:(holder := ' , ' ' , modelClass name , ' new' , ').\' , |
60 | 406 |
' ].\' , |
407 |
' ^ holder\' , |
|
408 |
'!! !!\\') withCRs |
|
409 |
! |
|
410 |
||
411 |
generateAspectMethods |
|
158
6e7f892308ae
do not generate accept/cancel and help action methods,
Claus Gittinger <cg@exept.de>
parents:
156
diff
changeset
|
412 |
|cls code skip| |
60 | 413 |
|
78 | 414 |
code := ''. |
415 |
||
60 | 416 |
className isNil ifTrue:[ |
69 | 417 |
self warn:'set the class first'. |
78 | 418 |
^ code |
60 | 419 |
]. |
89 | 420 |
cls := Smalltalk classNamed:className. |
60 | 421 |
|
238 | 422 |
treeView propertiesDo:[:aProp | |
62 | 423 |
|modelSelector menuSelector protoSpec thisCode| |
60 | 424 |
|
134 | 425 |
protoSpec := aProp spec. |
175 | 426 |
|
78 | 427 |
(modelSelector := aProp model) notNil ifTrue:[ |
60 | 428 |
(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
|
429 |
skip := false. |
6e7f892308ae
do not generate accept/cancel and help action methods,
Claus Gittinger <cg@exept.de>
parents:
156
diff
changeset
|
430 |
(cls isSubclassOf:SimpleDialog) ifTrue:[ |
6e7f892308ae
do not generate accept/cancel and help action methods,
Claus Gittinger <cg@exept.de>
parents:
156
diff
changeset
|
431 |
skip := SimpleDialog implements:modelSelector asSymbol |
60 | 432 |
]. |
158
6e7f892308ae
do not generate accept/cancel and help action methods,
Claus Gittinger <cg@exept.de>
parents:
156
diff
changeset
|
433 |
skip ifFalse:[ |
6e7f892308ae
do not generate accept/cancel and help action methods,
Claus Gittinger <cg@exept.de>
parents:
156
diff
changeset
|
434 |
"/ kludge .. |
6e7f892308ae
do not generate accept/cancel and help action methods,
Claus Gittinger <cg@exept.de>
parents:
156
diff
changeset
|
435 |
(protoSpec isMemberOf:ActionButtonSpec) ifTrue:[ |
6e7f892308ae
do not generate accept/cancel and help action methods,
Claus Gittinger <cg@exept.de>
parents:
156
diff
changeset
|
436 |
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
|
437 |
] ifFalse:[ |
6e7f892308ae
do not generate accept/cancel and help action methods,
Claus Gittinger <cg@exept.de>
parents:
156
diff
changeset
|
438 |
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
|
439 |
]. |
6e7f892308ae
do not generate accept/cancel and help action methods,
Claus Gittinger <cg@exept.de>
parents:
156
diff
changeset
|
440 |
code := code , thisCode |
6e7f892308ae
do not generate accept/cancel and help action methods,
Claus Gittinger <cg@exept.de>
parents:
156
diff
changeset
|
441 |
]. |
62 | 442 |
]. |
443 |
]. |
|
444 |
||
78 | 445 |
(menuSelector := aProp menu) notNil ifTrue:[ |
62 | 446 |
(cls implements:menuSelector asSymbol) ifFalse:[ |
447 |
thisCode := (self generateAspectMethodFor:menuSelector spec:protoSpec inClass:cls). |
|
448 |
code := code , thisCode |
|
60 | 449 |
] |
111 | 450 |
]. |
451 |
||
452 |
aProp spec aspectSelectors do:[:aSel| |
|
453 |
(cls implements:aSel asSymbol) ifFalse:[ |
|
454 |
thisCode := (self generateAspectMethodFor:aSel spec:protoSpec inClass:cls). |
|
455 |
code := code , thisCode |
|
456 |
] |
|
457 |
]. |
|
137 | 458 |
aProp spec actionSelectors do:[:aSel| |
459 |
(cls implements:aSel asSymbol) ifFalse:[ |
|
460 |
thisCode := (self generateActionMethodFor:aSel spec:protoSpec inClass:cls). |
|
461 |
code := code , thisCode |
|
462 |
] |
|
463 |
]. |
|
188
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
464 |
aProp spec valueSelectors do:[:aSel| |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
465 |
(cls implements:aSel asSymbol) ifFalse:[ |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
466 |
thisCode := (self generateValueMethodFor:aSel spec:protoSpec inClass:cls). |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
467 |
code := code , thisCode |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
468 |
] |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
469 |
]. |
111 | 470 |
|
60 | 471 |
]. |
472 |
^ code |
|
473 |
! |
|
474 |
||
188
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
475 |
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
476 |
^ ('!!' , targetClass name , ' methodsFor:''values''!!\\' , |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
477 |
aspect , '\' , |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
478 |
' "automatically generated by UIPainter ..."\' , |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
479 |
'\' , |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
480 |
' "value to be added below ..."\' , |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
481 |
' Transcript showCR:self class name , '': no value yet for ' , aspect , ' ...''.\' , |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
482 |
'\' , |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
483 |
'^ nil.' , |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
484 |
'!! !!\\') withCRs |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
485 |
|
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
486 |
|
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 |
|
78 | 491 |
generateWindowSpecMethodSource |
238 | 492 |
|spec specArray str code category cls mthd| |
60 | 493 |
|
78 | 494 |
specArray := OrderedCollection new. |
60 | 495 |
|
78 | 496 |
self subViews do:[:aView| |
497 |
aView ~~ inputView ifTrue:[ |
|
498 |
specArray add:(self fullSpecFor:aView) |
|
60 | 499 |
] |
500 |
]. |
|
78 | 501 |
spec := FullSpec new. |
281 | 502 |
spec fromBuilder:self topView components:(SpecCollection new collection:specArray). |
60 | 503 |
specArray := spec literalArrayEncoding. |
504 |
||
505 |
str := WriteStream on:String new. |
|
86 | 506 |
UISpecification prettyPrintSpecArray:specArray on:str indent:5. |
60 | 507 |
|
178
fb8451053c96
keep windowSpec methods category if it already exists
Claus Gittinger <cg@exept.de>
parents:
175
diff
changeset
|
508 |
"/ 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
|
509 |
|
fb8451053c96
keep windowSpec methods category if it already exists
Claus Gittinger <cg@exept.de>
parents:
175
diff
changeset
|
510 |
category := 'interface specs'. |
fb8451053c96
keep windowSpec methods category if it already exists
Claus Gittinger <cg@exept.de>
parents:
175
diff
changeset
|
511 |
(cls := Smalltalk classNamed:className) notNil ifTrue:[ |
fb8451053c96
keep windowSpec methods category if it already exists
Claus Gittinger <cg@exept.de>
parents:
175
diff
changeset
|
512 |
(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
|
513 |
category := mthd category. |
fb8451053c96
keep windowSpec methods category if it already exists
Claus Gittinger <cg@exept.de>
parents:
175
diff
changeset
|
514 |
] |
fb8451053c96
keep windowSpec methods category if it already exists
Claus Gittinger <cg@exept.de>
parents:
175
diff
changeset
|
515 |
]. |
fb8451053c96
keep windowSpec methods category if it already exists
Claus Gittinger <cg@exept.de>
parents:
175
diff
changeset
|
516 |
|
238 | 517 |
code := '!!' |
178
fb8451053c96
keep windowSpec methods category if it already exists
Claus Gittinger <cg@exept.de>
parents:
175
diff
changeset
|
518 |
, className , ' class methodsFor:' , category storeString |
238 | 519 |
, '!!' , '\\' |
60 | 520 |
|
521 |
, methodName , '\' |
|
522 |
, ' "this window spec was automatically generated by the ST/X UIPainter"\\' |
|
523 |
, ' "do not manually edit this - the painter/builder may not be able to\' |
|
524 |
, ' handle the specification if its corrupted."\\' |
|
525 |
, ' "\' |
|
526 |
, ' UIPainter new openOnClass:' , className , ' andSelector:#' , methodName , '\' |
|
527 |
, ' ' , className , ' new openInterface:#' , methodName , '\' |
|
528 |
, ' "\'. |
|
529 |
||
530 |
methodName = 'windowSpec' ifTrue:[ |
|
531 |
code := code , ' "' , className , ' open"\' |
|
532 |
]. |
|
533 |
code := code |
|
534 |
, '\' |
|
535 |
, ' <resource: #canvas>\\' |
|
536 |
, ' ^\' |
|
537 |
, ' ', str contents |
|
538 |
, '\' |
|
238 | 539 |
, '!! !!' |
60 | 540 |
, '\\'. |
541 |
||
542 |
^ code withCRs |
|
543 |
||
544 |
"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
|
545 |
"Modified: 24.6.1997 / 19:12:44 / cg" |
60 | 546 |
! ! |
547 |
||
548 |
!UIPainterView methodsFor:'initialization'! |
|
549 |
||
550 |
initialize |
|
62 | 551 |
"setup attributes |
552 |
" |
|
60 | 553 |
super initialize. |
554 |
||
555 |
superclassName := 'ApplicationModel'. |
|
556 |
className := 'NewApplication'. |
|
557 |
methodName := 'windowSpec'. |
|
558 |
categoryName := 'Applications'. |
|
559 |
HandCursor := Cursor leftHand. |
|
560 |
||
561 |
! |
|
562 |
||
563 |
setupFromSpec:specOrSpecArray |
|
78 | 564 |
|spec builder| |
60 | 565 |
|
238 | 566 |
treeView cvsSetupListDo:[ |
111 | 567 |
self removeAll. |
568 |
spec := UISpecification from:specOrSpecArray. |
|
569 |
builder := UIBuilder new. |
|
570 |
spec window setupView:self topView for:builder. |
|
571 |
self addSpec:(spec component) builder:builder in:self. |
|
572 |
self realizeAllSubViews. |
|
573 |
inputView raise. |
|
574 |
] |
|
223 | 575 |
! |
576 |
||
577 |
treeView:aTreeView |
|
238 | 578 |
treeView := aTreeView |
60 | 579 |
! ! |
580 |
||
581 |
!UIPainterView methodsFor:'menus'! |
|
582 |
||
121 | 583 |
showMiddleButtonMenu |
584 |
"show the middle button menu; this returns nil |
|
62 | 585 |
" |
223 | 586 |
|menu| |
60 | 587 |
|
223 | 588 |
self enabled ifTrue:[ |
589 |
menu := MenuPanel fromSpec:(UIPainter menuCanvas) receiver:self. |
|
60 | 590 |
|
223 | 591 |
self hasSelection ifFalse:[ |
592 |
menu disableAll |
|
593 |
]. |
|
594 |
menu enabledAt:#paste put:(self canPaste:(self getSelection)). |
|
595 |
menu enabledAt:#undo put:(undoHistory isEmpty not). |
|
596 |
menu startUp. |
|
111 | 597 |
]. |
121 | 598 |
^ nil |
60 | 599 |
|
62 | 600 |
|
601 |
||
60 | 602 |
! ! |
603 |
||
604 |
!UIPainterView methodsFor:'removing components'! |
|
605 |
||
78 | 606 |
remove:anObject |
607 |
"remove anObject from the contents do redraw |
|
60 | 608 |
" |
134 | 609 |
anObject notNil ifTrue:[ |
238 | 610 |
treeView removeView:anObject. |
134 | 611 |
] |
60 | 612 |
! |
613 |
||
614 |
removeAll |
|
62 | 615 |
"remove all objects and properties |
616 |
" |
|
238 | 617 |
treeView cvsEventsDisabledDo:[ |
223 | 618 |
self select:nil. |
238 | 619 |
treeView removeAll. |
223 | 620 |
self removeUndoHistory. |
111 | 621 |
] |
60 | 622 |
! ! |
623 |
||
624 |
!UIPainterView methodsFor:'searching'! |
|
625 |
||
89 | 626 |
findContainerViewAt:aPoint |
627 |
"find container view responds to aPoint. |
|
628 |
" |
|
629 |
|view| |
|
630 |
||
631 |
(view := self findObjectAt:aPoint) isNil ifTrue:[ |
|
632 |
^ self |
|
633 |
]. |
|
634 |
||
635 |
[(view specClass supportsSubComponents or:[(view := view superView) == self]) |
|
636 |
] whileFalse:[ |
|
637 |
[(self propertyOfView:view) isNil] whileTrue:[ |
|
638 |
(view := view superView) == self ifTrue:[^ self] |
|
639 |
]. |
|
640 |
]. |
|
641 |
^ view |
|
642 |
! |
|
643 |
||
60 | 644 |
findObjectAt:aPoint |
645 |
"find the origin/corner of the currentWidget |
|
646 |
" |
|
647 |
|view| |
|
648 |
||
649 |
view := super findObjectAt:aPoint. |
|
650 |
||
651 |
view notNil ifTrue:[ |
|
652 |
"can be a view within a view not visible |
|
653 |
" |
|
654 |
[ (self propertyOfView:view) isNil ] whileTrue:[ |
|
655 |
(view := view superView) == self ifTrue:[^ nil] |
|
656 |
] |
|
657 |
]. |
|
658 |
^ view |
|
659 |
! |
|
660 |
||
661 |
findViewWithId:aViewId |
|
62 | 662 |
"finds view assigned to identifier and returns the view or nil |
60 | 663 |
" |
664 |
|prop| |
|
665 |
||
666 |
prop := self propertyOfIdentifier:aViewId. |
|
667 |
||
668 |
prop notNil ifTrue:[^ prop view] |
|
669 |
ifFalse:[^ nil] |
|
78 | 670 |
! |
671 |
||
672 |
propertyOfIdentifier:anId |
|
673 |
"returns property assigned to unique identifier |
|
674 |
" |
|
675 |
anId notNil ifTrue:[ |
|
238 | 676 |
^ treeView propertyDetect:[:p| p identifier == anId ] |
78 | 677 |
]. |
678 |
^ nil |
|
679 |
! |
|
680 |
||
681 |
propertyOfName:aString |
|
682 |
"returns property assigned to name |
|
683 |
" |
|
111 | 684 |
|name| |
685 |
||
686 |
aString isNil ifFalse:[ |
|
687 |
name := aString string withoutSeparators. |
|
238 | 688 |
^ treeView propertyDetect:[:p| p name = name ]. |
78 | 689 |
]. |
690 |
^ nil |
|
691 |
! |
|
692 |
||
693 |
propertyOfView:aView |
|
694 |
"returns property assigned to view |
|
695 |
" |
|
696 |
(aView isNil or:[aView == self]) ifFalse:[ |
|
238 | 697 |
^ treeView propertyDetect:[:p| p view == aView ] |
78 | 698 |
]. |
699 |
^ nil |
|
700 |
! |
|
701 |
||
111 | 702 |
uniqueNameFor:aSpecOrString |
78 | 703 |
"generate and return an unique name for a class |
704 |
" |
|
705 |
|next name size| |
|
706 |
||
111 | 707 |
aSpecOrString isString ifFalse:[name := aSpecOrString className asString] |
708 |
ifTrue:[name := aSpecOrString]. |
|
78 | 709 |
|
111 | 710 |
(name endsWith:'Spec') ifTrue:[ |
711 |
name := name copyFrom:1 to:(name size - 4). |
|
712 |
] ifFalse:[ |
|
713 |
name := name copy |
|
714 |
]. |
|
78 | 715 |
name at:1 put:(name at:1) asLowercase. |
111 | 716 |
size := name size + 1. |
717 |
next := 0. |
|
78 | 718 |
|
238 | 719 |
treeView propertiesDo:[:p| |
111 | 720 |
|n| |
78 | 721 |
n := p name. |
722 |
||
723 |
(n size >= size and:[n startsWith:name]) ifTrue:[ |
|
724 |
next := next max:(p extractNumberStartingAt:size) |
|
725 |
] |
|
726 |
]. |
|
727 |
next := next + 1. |
|
728 |
name := name, next printString. |
|
729 |
^ name |
|
730 |
||
731 |
||
732 |
||
733 |
! |
|
734 |
||
735 |
uniqueNameOf:aView |
|
111 | 736 |
|prop| |
78 | 737 |
|
111 | 738 |
(prop := self propertyOfView:aView) notNil ifTrue:[ |
739 |
prop name isNil ifTrue:[ |
|
740 |
prop name:(self uniqueNameFor:(prop spec)). |
|
741 |
]. |
|
742 |
^ prop name |
|
78 | 743 |
]. |
111 | 744 |
^ 'self' |
78 | 745 |
|
60 | 746 |
! ! |
747 |
||
223 | 748 |
!UIPainterView methodsFor:'selection basics'! |
749 |
||
750 |
addToSelection:anObject |
|
751 |
"add an object to the selection |
|
752 |
" |
|
753 |
(self enabled and:[(self isSelected:anObject) not]) ifTrue:[ |
|
754 |
selection isCollection ifFalse:[ |
|
755 |
selection isNil ifTrue:[ |
|
756 |
selection := anObject |
|
757 |
] ifFalse:[ |
|
758 |
selection := OrderedCollection with:selection with:anObject |
|
759 |
] |
|
760 |
] ifTrue:[ |
|
761 |
selection add:anObject |
|
762 |
]. |
|
763 |
self showSelected:anObject. |
|
238 | 764 |
treeView cvsSelectionAdd:anObject. |
223 | 765 |
] |
766 |
||
767 |
||
768 |
! |
|
769 |
||
770 |
removeFromSelection:anObject |
|
771 |
"remove an object from the selection |
|
772 |
" |
|
773 |
(self isSelected:anObject) ifTrue:[ |
|
774 |
self showUnselected:anObject. |
|
775 |
||
776 |
selection size > 1 ifTrue:[ |
|
777 |
selection remove:anObject ifAbsent:nil. |
|
778 |
self showSelection. |
|
779 |
] ifFalse:[ |
|
780 |
selection := nil |
|
781 |
]. |
|
238 | 782 |
treeView cvsSelectionRemove:anObject. |
223 | 783 |
] |
784 |
||
785 |
! |
|
786 |
||
787 |
select:something |
|
788 |
"change selection to something |
|
789 |
" |
|
790 |
(self enabled and:[something ~= self selection]) ifTrue:[ |
|
791 |
self setSelection:something withRedraw:true. |
|
238 | 792 |
treeView cvsSelection:something |
223 | 793 |
] |
794 |
||
795 |
! |
|
796 |
||
797 |
updateSelectionFromModel:aSel |
|
798 |
"update selection from a new selection |
|
799 |
" |
|
800 |
|sel| |
|
801 |
||
802 |
selectionHiddenLevel == 0 ifTrue:[ |
|
803 |
self selectionDo:[:el| (aSel includes:el) ifFalse:[self showUnselected:el] ] |
|
804 |
]. |
|
805 |
||
806 |
(aSel indexOf:self) ~~ 0 ifTrue:[ |
|
807 |
aSel size > 1 ifTrue:[sel := aSel copyWithout:self] |
|
808 |
] ifFalse:[ |
|
809 |
aSel size ~~ 0 ifTrue:[sel := aSel] |
|
810 |
]. |
|
811 |
||
812 |
self setSelection:sel withRedraw:false. |
|
813 |
self showSelection |
|
814 |
||
815 |
||
816 |
! ! |
|
817 |
||
78 | 818 |
!UIPainterView methodsFor:'specification'! |
819 |
||
820 |
addSpec:aSpecification builder:aBuilder in:aFrame |
|
821 |
"build view and subviews from aSpecification into a frame. The top view |
|
822 |
is returned. The contained components of a spec are set to nil |
|
823 |
" |
|
212 | 824 |
|
825 |
className notNil ifTrue:[ |
|
826 |
aBuilder applicationClass:(Smalltalk classNamed:className). |
|
827 |
]. |
|
78 | 828 |
|
111 | 829 |
aBuilder componentCreationHook:[:aView :aSpec :aBdr||sv p s n| |
78 | 830 |
p := ViewProperty new. |
831 |
s := aSpec copy. |
|
832 |
p spec:s. |
|
833 |
p view:aView. |
|
834 |
||
835 |
s class supportsSubComponents ifTrue:[ |
|
836 |
s component:nil |
|
837 |
]. |
|
838 |
||
111 | 839 |
n := s name. |
840 |
||
841 |
(n isNil or:[(self propertyOfName:n) notNil]) ifTrue:[ |
|
842 |
s name:(self uniqueNameFor:s) |
|
78 | 843 |
]. |
238 | 844 |
treeView addProperty:p. |
78 | 845 |
]. |
846 |
||
847 |
^ aSpecification buildViewWithLayoutFor:aBuilder in:aFrame. |
|
60 | 848 |
|
212 | 849 |
"Modified: 4.7.1997 / 23:48:55 / cg" |
78 | 850 |
! |
851 |
||
852 |
fullSpecFor:anObject |
|
853 |
"generate a full spec for an object |
|
62 | 854 |
" |
78 | 855 |
|mySpec subSpecs| |
856 |
||
857 |
mySpec := self specFor:anObject. |
|
858 |
||
859 |
(mySpec notNil and:[mySpec class supportsSubComponents]) ifTrue:[ |
|
860 |
(anObject subViews notNil) ifTrue:[ |
|
861 |
anObject subViews do:[:aSubView||spec| |
|
862 |
spec := self fullSpecFor:aSubView. |
|
863 |
spec notNil ifTrue:[ |
|
864 |
subSpecs isNil ifTrue:[ |
|
865 |
subSpecs := OrderedCollection new |
|
866 |
]. |
|
867 |
subSpecs add:spec. |
|
868 |
]. |
|
869 |
]. |
|
870 |
subSpecs notNil ifTrue:[ |
|
871 |
mySpec component:(SpecCollection new collection:subSpecs) |
|
872 |
] |
|
873 |
] |
|
874 |
]. |
|
875 |
^ mySpec |
|
876 |
||
60 | 877 |
|
878 |
||
879 |
||
880 |
||
881 |
||
882 |
! |
|
883 |
||
78 | 884 |
specFor:anObject |
885 |
"returns spec assigned to an object |
|
62 | 886 |
" |
78 | 887 |
|prop spec| |
60 | 888 |
|
78 | 889 |
(prop := self propertyOfView:anObject) notNil ifTrue:[ |
890 |
spec := prop spec copy. |
|
891 |
spec layoutFromView:anObject |
|
60 | 892 |
]. |
78 | 893 |
^ spec |
894 |
||
895 |
||
896 |
||
60 | 897 |
! |
898 |
||
146 | 899 |
specForSelection |
900 |
"returns spec assigned to current single selection or nil |
|
901 |
" |
|
902 |
^ self specFor:(self singleSelection) |
|
903 |
||
904 |
||
905 |
! |
|
906 |
||
78 | 907 |
updateFromSpec:aSpec |
908 |
"update current selected view from specification |
|
62 | 909 |
" |
78 | 910 |
|props name builder v| |
911 |
||
281 | 912 |
aSpec class == WindowSpec ifTrue:[ |
913 |
aSpec setAttributesIn:self topView with:(UIBuilder new). |
|
914 |
^ treeView canvasNameChanged:aSpec name. |
|
915 |
]. |
|
916 |
||
78 | 917 |
self singleSelection notNil ifTrue:[ |
918 |
self withSelectionHiddenDo:[ |
|
919 |
self transaction:#specification selectionDo:[:aView| |
|
920 |
builder := UIBuilder new. |
|
212 | 921 |
className notNil ifTrue:[ |
922 |
builder applicationClass:(Smalltalk classNamed:className). |
|
923 |
]. |
|
78 | 924 |
props := self propertyOfView:aView. |
82 | 925 |
name := (aSpec name) withoutSeparators. |
78 | 926 |
|
82 | 927 |
name = props name ifFalse:[ |
928 |
(self propertyOfName:name) notNil ifTrue:[ |
|
929 |
name := props name |
|
78 | 930 |
] |
931 |
]. |
|
82 | 932 |
aSpec name:name. |
134 | 933 |
self createUndoSpecModify:props. |
78 | 934 |
|
935 |
aSpec needsRebuildForAttributes ifTrue:[ |
|
936 |
v := aSpec buildViewWithLayoutFor:builder in:aView superView. |
|
937 |
v realize. |
|
938 |
aView destroy. |
|
939 |
device sync. device flush. |
|
940 |
aView becomeSameAs:v. |
|
941 |
inputView raise. |
|
942 |
] ifFalse:[ |
|
943 |
aSpec setAttributesIn:aView with:builder. |
|
944 |
self elementChangedSize:aView. |
|
945 |
]. |
|
946 |
props spec:(aSpec copy). |
|
238 | 947 |
treeView propertyChanged:props. |
78 | 948 |
] |
111 | 949 |
] |
82 | 950 |
] |
212 | 951 |
|
952 |
"Modified: 4.7.1997 / 23:49:44 / cg" |
|
60 | 953 |
! ! |
954 |
||
955 |
!UIPainterView methodsFor:'transaction'! |
|
956 |
||
957 |
transaction:aType objects:something do:aOneArgBlock |
|
958 |
"opens a transaction and evaluates a block within the transaction; the |
|
959 |
argument to the block is a view from derived from something |
|
960 |
" |
|
134 | 961 |
self withinTransaction:aType objects:something do:[ |
962 |
self forEach:something do:aOneArgBlock |
|
60 | 963 |
] |
964 |
! |
|
965 |
||
134 | 966 |
withinTransaction:aType objects:objects do:aNoneArgBlock |
967 |
"evaluate a block with no arguments within a transaction |
|
60 | 968 |
" |
134 | 969 |
|text size prop| |
970 |
||
971 |
objects isNil ifTrue:[ ^ self ]. |
|
972 |
||
973 |
size := objects size. |
|
60 | 974 |
|
134 | 975 |
objects isCollection ifTrue:[ |
976 |
size == 0 ifTrue:[ ^ self ]. |
|
977 |
size == 1 ifTrue:[ prop := self propertyOfView:(objects first) ] |
|
978 |
] ifFalse:[ |
|
979 |
prop := self propertyOfView:objects |
|
980 |
]. |
|
60 | 981 |
|
134 | 982 |
prop notNil ifTrue:[ |
983 |
text := prop name |
|
984 |
] ifFalse:[ |
|
985 |
text := size printString, ' elements' |
|
60 | 986 |
]. |
134 | 987 |
|
988 |
undoHistory withinTransaction:aType text:text do:[ |
|
989 |
aNoneArgBlock value |
|
990 |
] |
|
60 | 991 |
! ! |
992 |
||
993 |
!UIPainterView methodsFor:'undo actions'! |
|
994 |
||
134 | 995 |
createUndoLayout:aView |
996 |
"create undo action before changing a views layout |
|
60 | 997 |
" |
134 | 998 |
|lyt args prop| |
60 | 999 |
|
1000 |
undoHistory isTransactionOpen ifTrue:[ |
|
1001 |
prop := self propertyOfView:aView. |
|
134 | 1002 |
|
60 | 1003 |
prop notNil ifTrue:[ |
134 | 1004 |
args := Array new:3. |
1005 |
args at:1 put:(prop identifier). |
|
1006 |
||
1007 |
(lyt := aView geometryLayout) notNil ifTrue:[ |
|
1008 |
args at:2 put:#geometryLayout: |
|
1009 |
] ifFalse:[ |
|
146 | 1010 |
lyt := aView extent. |
134 | 1011 |
args at:2 put:#extent: |
1012 |
]. |
|
1013 |
args at:3 put:(lyt copy). |
|
1014 |
undoHistory addUndoSelector:#undoLayout: withArgs:args. |
|
60 | 1015 |
] |
1016 |
] |
|
1017 |
! |
|
1018 |
||
134 | 1019 |
createUndoRemove:aView |
1020 |
"create undo method before deleting views |
|
60 | 1021 |
" |
134 | 1022 |
|frame prop pId spec| |
1023 |
||
1024 |
(prop := self propertyOfView:aView) notNil ifTrue:[ |
|
1025 |
spec := self fullSpecFor:aView. |
|
1026 |
frame := aView superView. |
|
60 | 1027 |
|
134 | 1028 |
(self canPasteInto:frame) ifTrue:[ |
1029 |
(frame := self propertyOfView:frame) notNil ifTrue:[ |
|
1030 |
pId := frame identifier |
|
1031 |
] |
|
1032 |
]. |
|
1033 |
undoHistory addUndoSelector:#undoRemove: |
|
1034 |
withArgs:(Array with:spec with:(prop identifier) with:pId) |
|
1035 |
] |
|
1036 |
! |
|
60 | 1037 |
|
134 | 1038 |
createUndoSpecModify:aProp |
1039 |
"undo method when changing the specification for an object |
|
1040 |
" |
|
1041 |
aProp notNil ifTrue:[ |
|
1042 |
undoHistory addUndoSelector:#undoSpecModify: |
|
1043 |
withArgs:(Array with:(aProp spec) with:(aProp identifier)) |
|
1044 |
] |
|
1045 |
! |
|
60 | 1046 |
|
134 | 1047 |
undoCreate:something |
1048 |
"undo method for creating or pasting an object |
|
1049 |
" |
|
1050 |
self forEach:something do:[:anId|self remove:(self findViewWithId:anId)]. |
|
1051 |
! |
|
60 | 1052 |
|
134 | 1053 |
undoLayout:args |
1054 |
"undo method to set the old layout; see 'createUndoLayout:' |
|
1055 |
" |
|
1056 |
|view| |
|
1057 |
||
1058 |
(view := self findViewWithId:(args at:1)) notNil ifTrue:[ |
|
146 | 1059 |
view perform:(args at:2) with:(args at:3). |
223 | 1060 |
self layoutChanged. |
60 | 1061 |
] |
1062 |
! |
|
1063 |
||
134 | 1064 |
undoRemove:args |
1065 |
"undo method when removing an object; see 'createUndoRemove:' |
|
1066 |
" |
|
1067 |
|frame prop view| |
|
1068 |
||
1069 |
(args at:3) notNil ifTrue:[ |
|
1070 |
frame := self findViewWithId:(args at:3). |
|
1071 |
]. |
|
1072 |
frame isNil ifTrue:[ |
|
1073 |
frame := self |
|
1074 |
]. |
|
1075 |
view := self addSpec:(args at:1) builder:(UIBuilder new) in:frame. |
|
1076 |
view realize. |
|
1077 |
inputView raise. |
|
1078 |
||
1079 |
prop := self propertyOfView:view. |
|
1080 |
prop identifier:(args at:2). |
|
1081 |
||
1082 |
! |
|
1083 |
||
1084 |
undoSpecModify:args |
|
1085 |
"undo method when changing a spec; see 'createUndoSpecModify:' |
|
60 | 1086 |
" |
80
3316c52ef2b7
write back specification to properties after undo modification
ca
parents:
78
diff
changeset
|
1087 |
|builder view spec v props| |
60 | 1088 |
|
134 | 1089 |
props := self propertyOfIdentifier:(args at:2). |
60 | 1090 |
|
134 | 1091 |
props notNil ifTrue:[ |
1092 |
view := props view. |
|
1093 |
spec := args at:1. |
|
1094 |
builder := UIBuilder new. |
|
212 | 1095 |
className notNil ifTrue:[ |
1096 |
builder applicationClass:(Smalltalk classNamed:className). |
|
1097 |
]. |
|
134 | 1098 |
props spec:spec. |
80
3316c52ef2b7
write back specification to properties after undo modification
ca
parents:
78
diff
changeset
|
1099 |
|
134 | 1100 |
spec needsRebuildForAttributes ifTrue:[ |
1101 |
v := spec buildViewWithLayoutFor:builder in:view superView. |
|
1102 |
v realize. |
|
1103 |
view destroy. |
|
1104 |
view become:v |
|
1105 |
] ifFalse:[ |
|
1106 |
spec setAttributesIn:view with:builder. |
|
1107 |
self elementChangedSize:view. |
|
1108 |
]. |
|
238 | 1109 |
treeView propertyChanged:props. |
211 | 1110 |
] |
1111 |
! ! |
|
1112 |
||
1113 |
!UIPainterView::ViewProperty class methodsFor:'instance creation'! |
|
1114 |
||
1115 |
new |
|
1116 |
Identifier notNil ifTrue:[Identifier := Identifier + 1] |
|
1117 |
ifFalse:[Identifier := 1]. |
|
1118 |
||
1119 |
^ self basicNew initialize |
|
1120 |
! ! |
|
1121 |
||
1122 |
!UIPainterView::ViewProperty methodsFor:'accessing'! |
|
1123 |
||
1124 |
identifier |
|
1125 |
"return the unique identifier assigned to property |
|
1126 |
" |
|
1127 |
^ identifier |
|
1128 |
! |
|
1129 |
||
1130 |
identifier:anIdentifier |
|
1131 |
"set the unique identifier assigned to property; called after an restore of |
|
1132 |
a deleted instance |
|
1133 |
" |
|
1134 |
identifier := anIdentifier |
|
1135 |
! |
|
1136 |
||
1137 |
spec |
|
1138 |
"return the value of the instance variable 'spec' (automatically generated)" |
|
1139 |
||
1140 |
^ spec! |
|
1141 |
||
1142 |
spec:something |
|
1143 |
"set the value of the instance variable 'spec' (automatically generated)" |
|
1144 |
||
1145 |
spec := something.! |
|
1146 |
||
1147 |
view |
|
1148 |
"return the value of the instance variable 'view' (automatically generated)" |
|
1149 |
||
1150 |
^ view! |
|
1151 |
||
1152 |
view:something |
|
1153 |
"set the value of the instance variable 'view' (automatically generated)" |
|
1154 |
||
1155 |
view := something.! ! |
|
1156 |
||
1157 |
!UIPainterView::ViewProperty methodsFor:'initialization'! |
|
1158 |
||
1159 |
initialize |
|
1160 |
super initialize. |
|
1161 |
identifier := Identifier |
|
1162 |
! ! |
|
1163 |
||
1164 |
!UIPainterView::ViewProperty methodsFor:'misc'! |
|
1165 |
||
1166 |
extractNumberStartingAt:anIndex |
|
1167 |
"return the number from the name starting at anIndex or 0. |
|
1168 |
" |
|
1169 |
|val| |
|
1170 |
||
1171 |
val := 0. |
|
1172 |
||
1173 |
self name from:anIndex do:[:c| |
|
1174 |
c isDigit ifTrue:[val := val * 10 + c digitValue] |
|
1175 |
ifFalse:[^ 0] |
|
1176 |
]. |
|
1177 |
^ val |
|
1178 |
||
1179 |
! ! |
|
1180 |
||
1181 |
!UIPainterView::ViewProperty methodsFor:'spec messages'! |
|
1182 |
||
1183 |
doesNotUnderstand:aMessage |
|
1184 |
spec notNil ifTrue:[ |
|
1185 |
(spec respondsTo:(aMessage selector)) ifTrue:[^ aMessage sendTo:spec] |
|
1186 |
]. |
|
1187 |
^ nil |
|
1188 |
! |
|
1189 |
||
1190 |
layout |
|
1191 |
spec layout |
|
1192 |
! |
|
1193 |
||
1194 |
layout:aLayout |
|
1195 |
spec layout:aLayout |
|
1196 |
! |
|
1197 |
||
1198 |
name |
|
1199 |
^ spec name |
|
1200 |
! |
|
1201 |
||
1202 |
name:aName |
|
1203 |
spec name:aName |
|
1204 |
! ! |
|
1205 |
||
60 | 1206 |
!UIPainterView class methodsFor:'documentation'! |
1207 |
||
1208 |
version |
|
1209 |
^ '$Header$' |
|
1210 |
! ! |