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