author | ca |
Wed, 29 Oct 1997 17:43:19 +0100 | |
changeset 360 | 1a4ec4aa2c67 |
parent 352 | 088174fc1e71 |
child 361 | 6624bb5d9a1a |
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 |
" |
|
312 | 228 |
|paste frame pasteOrigin pasteOffset builder newSel bounds| |
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:[ |
330 | 248 |
builder applicationClass:(self resolveName:className) |
212 | 249 |
]. |
89 | 250 |
|
165 | 251 |
keepLayout ifFalse:[ |
252 |
pasteOffset := 0@0. |
|
312 | 253 |
|
278 | 254 |
aPointOrNil isNil ifTrue:[ |
255 |
pasteOrigin := self sensor mousePoint. |
|
312 | 256 |
pasteOrigin := device translatePoint:pasteOrigin |
257 |
from:device rootView id |
|
258 |
to:frame id. |
|
278 | 259 |
] ifFalse:[ |
312 | 260 |
pasteOrigin := device translatePoint:aPointOrNil |
261 |
from:self id |
|
262 |
to:frame id. |
|
263 |
] |
|
264 |
]. |
|
265 |
keepLayout ifFalse:[ |
|
266 |
bounds := Rectangle origin:0@0 extent:(frame bounds extent) |
|
165 | 267 |
]. |
60 | 268 |
|
223 | 269 |
paste do:[:aSpec| |
270 |
|view| |
|
60 | 271 |
|
223 | 272 |
view := self addSpec:aSpec builder:builder in:frame. |
60 | 273 |
|
223 | 274 |
keepLayout ifFalse:[ |
312 | 275 |
(bounds containsPoint:pasteOrigin) ifFalse:[ |
315 | 276 |
self moveObject:view to:pasteOffset. |
223 | 277 |
] ifTrue:[ |
278 |
self moveObject:view to:pasteOrigin + pasteOffset. |
|
111 | 279 |
]. |
223 | 280 |
pasteOffset := pasteOffset + 4 |
89 | 281 |
]. |
223 | 282 |
view realize. |
283 |
newSel add:view. |
|
60 | 284 |
]. |
285 |
||
165 | 286 |
self withinTransaction:#paste objects:newSel do:[ |
287 |
undoHistory addUndoSelector:#undoCreate: |
|
288 |
withArgs:(newSel collect:[:v|(self propertyOfView:v) identifier]) |
|
289 |
]. |
|
134 | 290 |
|
165 | 291 |
self realizeAllSubViews. |
285 | 292 |
newSel do:[:v| v raise]. |
165 | 293 |
inputView raise. |
294 |
self elementChangedSize:frame. |
|
285 | 295 |
|
296 |
newSel size == 1 ifTrue:[newSel := newSel at:1]. |
|
223 | 297 |
]. |
298 |
^ newSel |
|
89 | 299 |
! |
300 |
||
301 |
pasteWithLayout |
|
302 |
"add the objects in the paste-buffer to the object view; don't change the |
|
303 |
layout |
|
304 |
" |
|
223 | 305 |
|sel| |
306 |
||
307 |
sel := self pasteSpecifications:(self getSelection) keepLayout:true. |
|
89 | 308 |
|
223 | 309 |
sel notNil ifTrue:[ |
310 |
self select:sel. |
|
311 |
]. |
|
60 | 312 |
! ! |
313 |
||
314 |
!UIPainterView methodsFor:'drag & drop'! |
|
315 |
||
288 | 316 |
canDrop:something |
317 |
"returns true if something can be droped |
|
318 |
" |
|
319 |
(something size == 1 and:[self enabled and:[self numberOfSelections <= 1]]) ifTrue:[ |
|
320 |
^ something first theObject isKindOf:UISpecification |
|
223 | 321 |
]. |
322 |
^ false |
|
323 |
! |
|
324 |
||
285 | 325 |
canPaste |
326 |
"returns true if something to be past exists and can be paste into |
|
327 |
the selection if exists |
|
328 |
" |
|
329 |
^ self canPaste:(self getSelection) |
|
330 |
! |
|
331 |
||
223 | 332 |
canPaste:something |
333 |
"returns true if something could be paste |
|
334 |
" |
|
335 |
|el size| |
|
336 |
||
337 |
((size := self numberOfSelections) <= 1 and:[self enabled]) ifFalse:[ |
|
338 |
^ false |
|
339 |
]. |
|
340 |
something isCollection ifTrue:[something notEmpty ifTrue:[el := something first]] |
|
341 |
ifFalse:[el := something]. |
|
342 |
||
343 |
(el isKindOf:UISpecification) ifFalse:[ |
|
344 |
^ false |
|
345 |
]. |
|
346 |
||
347 |
size == 1 ifTrue:[ |
|
348 |
^ self canPasteInto:(self singleSelection) |
|
349 |
]. |
|
350 |
^ true |
|
351 |
||
352 |
! |
|
353 |
||
354 |
canPasteInto:aView |
|
355 |
"can paste into a view |
|
356 |
" |
|
285 | 357 |
|prop| |
60 | 358 |
|
223 | 359 |
aView notNil ifTrue:[ |
285 | 360 |
(prop := self propertyRespondsToView:aView) notNil ifTrue:[ |
361 |
^ prop spec class supportsSubComponents |
|
362 |
]. |
|
363 |
^ aView specClass supportsSubComponents. |
|
89 | 364 |
]. |
365 |
^ false |
|
96
73725336b4fe
dont paste into scrollable selectionInListViews ...
Claus Gittinger <cg@exept.de>
parents:
89
diff
changeset
|
366 |
|
60 | 367 |
! |
368 |
||
369 |
drop:anObjectOrCollection at:aPoint |
|
278 | 370 |
|spec newSel oldSel dragOffset| |
371 |
||
288 | 372 |
self selection notNil ifTrue:[ |
373 |
oldSel := self singleSelection. |
|
374 |
||
375 |
(self canPasteInto:oldSel) ifFalse:[ |
|
376 |
oldSel := nil. |
|
377 |
self setSelection:nil withRedraw:true |
|
378 |
] |
|
231 | 379 |
]. |
89 | 380 |
spec := (anObjectOrCollection at:1) theObject. |
278 | 381 |
dragOffset := DragAndDropManager dragOffsetQuerySignal raise. |
382 |
newSel := self pasteSpecifications:spec keepLayout:false at:aPoint - dragOffset. |
|
60 | 383 |
|
223 | 384 |
oldSel isNil ifTrue:[self select:newSel] |
385 |
ifFalse:[self select:oldSel] |
|
60 | 386 |
! ! |
387 |
||
78 | 388 |
!UIPainterView methodsFor:'generating output'! |
389 |
||
352 | 390 |
aspectMethods |
391 |
"extract a list of aspect methods - for browsing" |
|
392 |
||
393 |
|cls methods skip selector protoSpec| |
|
394 |
||
395 |
className isNil ifTrue:[ |
|
396 |
self warn:'set the class first'. |
|
397 |
^ #() |
|
398 |
]. |
|
399 |
||
400 |
cls := self resolveName:className. |
|
401 |
methods := IdentitySet new. |
|
402 |
||
403 |
treeView propertiesDo:[:aProp| |
|
404 |
|selector| |
|
405 |
||
406 |
(selector := aProp model) notNil ifTrue:[ |
|
407 |
selector isArray ifFalse:[ |
|
408 |
selector := selector asSymbol. |
|
409 |
(cls implements:selector) ifTrue:[ |
|
410 |
skip := false. |
|
411 |
(cls isSubclassOf:SimpleDialog) ifTrue:[ |
|
412 |
skip := SimpleDialog implements:selector asSymbol |
|
413 |
]. |
|
414 |
skip ifFalse:[ |
|
415 |
methods add:(cls compiledMethodAt:selector) |
|
416 |
]. |
|
417 |
]. |
|
418 |
]. |
|
419 |
]. |
|
420 |
||
421 |
(selector := aProp menu) notNil ifTrue:[ |
|
422 |
selector isArray ifFalse:[ |
|
423 |
selector := selector asSymbol. |
|
424 |
(cls implements:selector) ifTrue:[ |
|
425 |
methods add:(cls compiledMethodAt:selector) |
|
426 |
] |
|
427 |
]. |
|
428 |
]. |
|
429 |
||
430 |
(aProp spec aspectSelectors) do:[:aSel | |
|
431 |
|selector| |
|
432 |
||
433 |
aSel isArray ifFalse:[ |
|
434 |
selector := aSel asSymbol. |
|
435 |
(cls implements:selector) ifTrue:[ |
|
436 |
methods add:(cls compiledMethodAt:selector) |
|
437 |
] |
|
438 |
]. |
|
439 |
]. |
|
440 |
aProp spec actionSelectors do:[:aSel| |
|
441 |
|selector| |
|
442 |
||
443 |
aSel isArray ifFalse:[ |
|
444 |
selector := aSel asSymbol. |
|
445 |
(cls implements:selector) ifTrue:[ |
|
446 |
methods add:(cls compiledMethodAt:selector) |
|
447 |
] |
|
448 |
]. |
|
449 |
]. |
|
450 |
aProp spec valueSelectors do:[:aSel| |
|
451 |
|selector| |
|
452 |
||
453 |
aSel isArray ifFalse:[ |
|
454 |
selector := aSel asSymbol. |
|
455 |
(cls implements:selector) ifTrue:[ |
|
456 |
methods add:(cls compiledMethodAt:selector) |
|
457 |
] |
|
458 |
]. |
|
459 |
] |
|
460 |
]. |
|
461 |
||
462 |
protoSpec := treeView canvasSpec. |
|
463 |
||
464 |
(selector := protoSpec menu) notNil ifTrue:[ |
|
465 |
selector isArray ifFalse:[ |
|
466 |
selector := selector asSymbol. |
|
467 |
(cls implements:selector) ifTrue:[ |
|
468 |
methods add:(cls compiledMethodAt:selector) |
|
469 |
] |
|
470 |
]. |
|
471 |
]. |
|
472 |
||
473 |
^ methods |
|
474 |
||
475 |
"Created: / 25.10.1997 / 18:58:25 / cg" |
|
476 |
"Modified: / 26.10.1997 / 15:06:18 / cg" |
|
477 |
! |
|
478 |
||
60 | 479 |
generateActionMethodFor:aspect spec:protoSpec inClass:targetClass |
288 | 480 |
|selector args showIt code alreadyInSuperclass| |
481 |
||
482 |
selector := aspect asSymbol. |
|
141 | 483 |
|
288 | 484 |
alreadyInSuperclass := targetClass superclass canUnderstand:selector. |
485 |
||
486 |
(selector numArgs) == 1 ifFalse:[ |
|
487 |
args := ''. |
|
149 | 488 |
showIt := ' ...''.\'. |
489 |
] ifTrue:[ |
|
288 | 490 |
args := 'anArgument'. |
149 | 491 |
showIt := ''' , anArgument printString , '' ...''.\'. |
492 |
]. |
|
141 | 493 |
|
288 | 494 |
code := '!!' , targetClass name , ' methodsFor:''actions''!!\\' , |
495 |
aspect , args , '\' , |
|
352 | 496 |
' "automatically generated by UIPainter ..."\\' , |
497 |
' "*** the code below performs no action"\' , |
|
498 |
' "*** (except for some feedback on the Transcript)"\' , |
|
499 |
' "*** Please change as required and accept in the browser."\' , |
|
288 | 500 |
'\' . |
501 |
||
502 |
alreadyInSuperclass ifTrue:[ |
|
503 |
code := code , |
|
504 |
' "action for ' , aspect , ' is already provided in a superclass."\' , |
|
505 |
' "It may be redefined here ..."\\'. |
|
506 |
] ifFalse:[ |
|
507 |
code := code , |
|
508 |
' "action to be added ..."\\'. |
|
509 |
]. |
|
510 |
||
511 |
code := code , |
|
512 |
' Transcript showCR:self class name, '': '. |
|
513 |
alreadyInSuperclass ifTrue:[ |
|
514 |
code := code , 'inherited '. |
|
515 |
]. |
|
516 |
code := code , 'action for ' , aspect , showIt. |
|
517 |
||
518 |
alreadyInSuperclass ifTrue:[ |
|
519 |
code := code , |
|
520 |
' super ' , aspect , args , '.\'. |
|
521 |
]. |
|
522 |
||
523 |
code := code , |
|
524 |
'!! !!\\'. |
|
525 |
^ code withCRs |
|
526 |
||
352 | 527 |
"Modified: / 25.10.1997 / 19:18:50 / cg" |
60 | 528 |
! |
529 |
||
530 |
generateAspectMethodFor:aspect spec:protoSpec inClass:targetClass |
|
352 | 531 |
|modelClass modelValue modelGen| |
134 | 532 |
|
149 | 533 |
modelClass := protoSpec defaultModelClassFor:aspect. |
352 | 534 |
modelValue := protoSpec defaultModelValueFor:aspect. |
535 |
||
536 |
modelValue isNil ifTrue:[ |
|
537 |
modelGen := modelClass name , ' new' |
|
538 |
] ifFalse:[ |
|
539 |
modelGen := modelValue storeString , ' asValue' |
|
540 |
]. |
|
134 | 541 |
|
60 | 542 |
^ ('!!' , targetClass name , ' methodsFor:''aspects''!!\\' , |
543 |
aspect , '\' , |
|
352 | 544 |
' "automatically generated by UIPainter ..."\\' , |
545 |
' "*** the code below creates a default model when invoked."\' , |
|
546 |
' "*** (which may not be the one you wanted)"\' , |
|
547 |
' "*** Please change as required and accept in the browser."\' , |
|
60 | 548 |
'\' , |
549 |
' |holder|\' , |
|
550 |
'\' , |
|
551 |
' (holder := builder bindingAt:#' , aspect , ') isNil ifTrue:[\' , |
|
352 | 552 |
' builder aspectAt:#' , aspect , ' put:(holder := ' , ' ' , modelGen , ').\' , |
60 | 553 |
' ].\' , |
554 |
' ^ holder\' , |
|
555 |
'!! !!\\') withCRs |
|
352 | 556 |
|
557 |
"Modified: / 26.10.1997 / 19:01:15 / cg" |
|
60 | 558 |
! |
559 |
||
560 |
generateAspectMethods |
|
352 | 561 |
"generate aspect, action & menu methods |
562 |
- but do not overwrite existing ones. |
|
563 |
Return a string ready to compile into the application class." |
|
564 |
||
565 |
|cls code skip menuSelector protoSpec thisCode| |
|
60 | 566 |
|
78 | 567 |
code := ''. |
568 |
||
60 | 569 |
className isNil ifTrue:[ |
69 | 570 |
self warn:'set the class first'. |
78 | 571 |
^ code |
60 | 572 |
]. |
330 | 573 |
cls := self resolveName:className. |
60 | 574 |
|
316 | 575 |
treeView propertiesDo:[:aProp| |
352 | 576 |
|modelSelector menuSelector| |
577 |
||
134 | 578 |
protoSpec := aProp spec. |
175 | 579 |
|
78 | 580 |
(modelSelector := aProp model) notNil ifTrue:[ |
352 | 581 |
(modelSelector isArray not) ifTrue:[ |
582 |
(cls implements:modelSelector asSymbol) ifFalse:[ |
|
583 |
skip := false. |
|
584 |
(cls isSubclassOf:SimpleDialog) ifTrue:[ |
|
585 |
skip := SimpleDialog implements:modelSelector asSymbol |
|
158
6e7f892308ae
do not generate accept/cancel and help action methods,
Claus Gittinger <cg@exept.de>
parents:
156
diff
changeset
|
586 |
]. |
352 | 587 |
skip ifFalse:[ |
588 |
"/ kludge .. |
|
589 |
(protoSpec isMemberOf:ActionButtonSpec) ifTrue:[ |
|
590 |
thisCode := (self generateActionMethodFor:modelSelector spec:protoSpec inClass:cls). |
|
591 |
] ifFalse:[ |
|
592 |
thisCode := (self generateAspectMethodFor:modelSelector spec:protoSpec inClass:cls). |
|
593 |
]. |
|
594 |
code := code , thisCode |
|
595 |
]. |
|
158
6e7f892308ae
do not generate accept/cancel and help action methods,
Claus Gittinger <cg@exept.de>
parents:
156
diff
changeset
|
596 |
]. |
62 | 597 |
]. |
598 |
]. |
|
599 |
||
78 | 600 |
(menuSelector := aProp menu) notNil ifTrue:[ |
352 | 601 |
(menuSelector isArray not) ifTrue:[ |
602 |
thisCode := self generateMenuMethodFor:menuSelector spec:protoSpec inClass:cls. |
|
603 |
thisCode size ~~ 0 ifTrue:[ |
|
604 |
code := code , thisCode |
|
605 |
] |
|
60 | 606 |
] |
111 | 607 |
]. |
608 |
||
609 |
aProp spec aspectSelectors do:[:aSel| |
|
352 | 610 |
(aSel isArray not) ifTrue:[ |
611 |
(cls implements:aSel asSymbol) ifFalse:[ |
|
612 |
thisCode := (self generateAspectMethodFor:aSel spec:protoSpec inClass:cls). |
|
613 |
code := code , thisCode |
|
614 |
] |
|
111 | 615 |
] |
616 |
]. |
|
137 | 617 |
aProp spec actionSelectors do:[:aSel| |
352 | 618 |
(aSel isArray not) ifTrue:[ |
619 |
(cls implements:aSel asSymbol) ifFalse:[ |
|
620 |
thisCode := (self generateActionMethodFor:aSel spec:protoSpec inClass:cls). |
|
621 |
code := code , thisCode |
|
622 |
] |
|
137 | 623 |
] |
624 |
]. |
|
188
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
625 |
aProp spec valueSelectors do:[:aSel| |
352 | 626 |
(aSel isArray not) ifTrue:[ |
627 |
(cls implements:aSel asSymbol) ifFalse:[ |
|
628 |
thisCode := (self generateValueMethodFor:aSel spec:protoSpec inClass:cls). |
|
629 |
code := code , thisCode |
|
630 |
] |
|
188
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
631 |
] |
316 | 632 |
] |
633 |
]. |
|
634 |
||
635 |
protoSpec := treeView canvasSpec. |
|
636 |
||
637 |
(menuSelector := protoSpec menu) notNil ifTrue:[ |
|
352 | 638 |
(menuSelector isArray not) ifTrue:[ |
639 |
thisCode := self generateMenuMethodFor:menuSelector spec:protoSpec inClass:cls. |
|
640 |
thisCode size ~~ 0 ifTrue:[ |
|
641 |
code := code , thisCode |
|
642 |
] |
|
316 | 643 |
] |
644 |
]. |
|
645 |
||
352 | 646 |
^ code |
316 | 647 |
|
352 | 648 |
"Modified: / 26.10.1997 / 14:43:55 / cg" |
316 | 649 |
! |
650 |
||
651 |
generateMenuMethodFor:aspect spec:protoSpec inClass:aClass |
|
652 |
|code cperf performer category| |
|
653 |
||
654 |
(aClass implements:aspect asSymbol) ifFalse:[ |
|
655 |
code := MenuEditor generateCodeFor:aClass menuSelector:(aspect asSymbol). |
|
656 |
] ifTrue:[ |
|
657 |
code := '' |
|
658 |
]. |
|
111 | 659 |
|
316 | 660 |
(protoSpec respondsTo:#menuPerformer) ifTrue:[ |
661 |
performer := protoSpec menuPerformer. |
|
60 | 662 |
]. |
316 | 663 |
performer notNil ifTrue:[ |
664 |
performer := performer asSymbol. |
|
665 |
||
666 |
(aClass implements:performer) ifFalse:[ |
|
667 |
category := MenuEditor sourceCategory. |
|
668 |
||
669 |
cperf := Character excla asString |
|
670 |
, aClass name , ' methodsFor:' , category storeString |
|
671 |
, Character excla asString , '\\' |
|
672 |
, performer , '\' |
|
352 | 673 |
, ' "this menu spec was automatically generated by the UI MenuBuilder"\\' |
316 | 674 |
, ' ^ self\\' |
675 |
, '\' |
|
676 |
, Character excla asString |
|
677 |
, ' ' |
|
678 |
, Character excla asString |
|
679 |
, '\\'. |
|
680 |
||
681 |
code := code, cperf. |
|
682 |
] |
|
683 |
]. |
|
684 |
||
685 |
code size == 0 ifTrue:[ |
|
686 |
^ nil |
|
687 |
]. |
|
688 |
^ code withCRs |
|
352 | 689 |
|
690 |
"Modified: / 26.10.1997 / 14:44:20 / cg" |
|
60 | 691 |
! |
692 |
||
188
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
693 |
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
694 |
^ ('!!' , targetClass name , ' methodsFor:''values''!!\\' , |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
695 |
aspect , '\' , |
352 | 696 |
' "automatically generated by UIPainter ..."\\' , |
697 |
' "*** the code below returns a default value when invoked."\' , |
|
698 |
' "*** (which may not be the one you wanted)"\' , |
|
699 |
' "*** Please change as required and accept in the browser."\' , |
|
188
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
700 |
'\' , |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
701 |
' "value to be added below ..."\' , |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
702 |
' Transcript showCR:self class name , '': no value yet for ' , aspect , ' ...''.\' , |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
703 |
'\' , |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
704 |
'^ nil.' , |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
705 |
'!! !!\\') withCRs |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
706 |
|
352 | 707 |
"Modified: / 25.10.1997 / 19:22:17 / cg" |
188
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
708 |
! |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
709 |
|
78 | 710 |
generateWindowSpecMethodSource |
310 | 711 |
|spec str code category cls mthd| |
60 | 712 |
|
310 | 713 |
spec := OrderedCollection new. |
60 | 714 |
|
78 | 715 |
self subViews do:[:aView| |
716 |
aView ~~ inputView ifTrue:[ |
|
310 | 717 |
spec add:(self fullSpecFor:aView) |
60 | 718 |
] |
719 |
]. |
|
310 | 720 |
spec := treeView generateFullSpecForComponents:spec. |
721 |
str := WriteStream on:String new. |
|
722 |
UISpecification prettyPrintSpecArray:spec on:str indent:5. |
|
60 | 723 |
|
178
fb8451053c96
keep windowSpec methods category if it already exists
Claus Gittinger <cg@exept.de>
parents:
175
diff
changeset
|
724 |
"/ 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
|
725 |
|
fb8451053c96
keep windowSpec methods category if it already exists
Claus Gittinger <cg@exept.de>
parents:
175
diff
changeset
|
726 |
category := 'interface specs'. |
330 | 727 |
cls := self resolveName:className. |
728 |
||
729 |
cls notNil ifTrue:[ |
|
178
fb8451053c96
keep windowSpec methods category if it already exists
Claus Gittinger <cg@exept.de>
parents:
175
diff
changeset
|
730 |
(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
|
731 |
category := mthd category. |
fb8451053c96
keep windowSpec methods category if it already exists
Claus Gittinger <cg@exept.de>
parents:
175
diff
changeset
|
732 |
] |
fb8451053c96
keep windowSpec methods category if it already exists
Claus Gittinger <cg@exept.de>
parents:
175
diff
changeset
|
733 |
]. |
fb8451053c96
keep windowSpec methods category if it already exists
Claus Gittinger <cg@exept.de>
parents:
175
diff
changeset
|
734 |
|
238 | 735 |
code := '!!' |
178
fb8451053c96
keep windowSpec methods category if it already exists
Claus Gittinger <cg@exept.de>
parents:
175
diff
changeset
|
736 |
, className , ' class methodsFor:' , category storeString |
238 | 737 |
, '!!' , '\\' |
60 | 738 |
|
739 |
, methodName , '\' |
|
740 |
, ' "this window spec was automatically generated by the ST/X UIPainter"\\' |
|
741 |
, ' "do not manually edit this - the painter/builder may not be able to\' |
|
742 |
, ' handle the specification if its corrupted."\\' |
|
743 |
, ' "\' |
|
744 |
, ' UIPainter new openOnClass:' , className , ' andSelector:#' , methodName , '\' |
|
745 |
, ' ' , className , ' new openInterface:#' , methodName , '\' |
|
746 |
, ' "\'. |
|
747 |
||
748 |
methodName = 'windowSpec' ifTrue:[ |
|
749 |
code := code , ' "' , className , ' open"\' |
|
750 |
]. |
|
751 |
code := code |
|
752 |
, '\' |
|
753 |
, ' <resource: #canvas>\\' |
|
754 |
, ' ^\' |
|
755 |
, ' ', str contents |
|
756 |
, '\' |
|
238 | 757 |
, '!! !!' |
60 | 758 |
, '\\'. |
759 |
||
760 |
^ code withCRs |
|
761 |
||
762 |
"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
|
763 |
"Modified: 24.6.1997 / 19:12:44 / cg" |
60 | 764 |
! ! |
765 |
||
766 |
!UIPainterView methodsFor:'initialization'! |
|
767 |
||
768 |
initialize |
|
62 | 769 |
"setup attributes |
770 |
" |
|
60 | 771 |
super initialize. |
772 |
||
773 |
superclassName := 'ApplicationModel'. |
|
774 |
className := 'NewApplication'. |
|
775 |
methodName := 'windowSpec'. |
|
776 |
categoryName := 'Applications'. |
|
777 |
HandCursor := Cursor leftHand. |
|
778 |
||
779 |
! |
|
780 |
||
781 |
setupFromSpec:specOrSpecArray |
|
78 | 782 |
|spec builder| |
60 | 783 |
|
238 | 784 |
treeView cvsSetupListDo:[ |
111 | 785 |
self removeAll. |
786 |
spec := UISpecification from:specOrSpecArray. |
|
787 |
builder := UIBuilder new. |
|
788 |
spec window setupView:self topView for:builder. |
|
789 |
self addSpec:(spec component) builder:builder in:self. |
|
790 |
self realizeAllSubViews. |
|
791 |
inputView raise. |
|
310 | 792 |
treeView setAttributesFromWindowSpec:(spec window). |
111 | 793 |
] |
223 | 794 |
! |
795 |
||
796 |
treeView:aTreeView |
|
238 | 797 |
treeView := aTreeView |
60 | 798 |
! ! |
799 |
||
800 |
!UIPainterView methodsFor:'menus'! |
|
801 |
||
121 | 802 |
showMiddleButtonMenu |
803 |
"show the middle button menu; this returns nil |
|
62 | 804 |
" |
223 | 805 |
self enabled ifTrue:[ |
285 | 806 |
(MenuPanel fromSpec:(UIPainter menuCanvas) receiver:self) startUp |
111 | 807 |
]. |
121 | 808 |
^ nil |
60 | 809 |
|
62 | 810 |
|
811 |
||
60 | 812 |
! ! |
813 |
||
335 | 814 |
!UIPainterView methodsFor:'queries'! |
815 |
||
816 |
resolveName:aName |
|
817 |
|appl| |
|
818 |
||
819 |
appl := self application. |
|
820 |
||
821 |
appl notNil ifTrue:[ |
|
822 |
^ appl resolveName:aName |
|
823 |
]. |
|
824 |
^ Smalltalk resolveName:aName inClass:self class |
|
825 |
! ! |
|
826 |
||
60 | 827 |
!UIPainterView methodsFor:'removing components'! |
828 |
||
78 | 829 |
remove:anObject |
830 |
"remove anObject from the contents do redraw |
|
60 | 831 |
" |
134 | 832 |
anObject notNil ifTrue:[ |
238 | 833 |
treeView removeView:anObject. |
134 | 834 |
] |
60 | 835 |
! |
836 |
||
837 |
removeAll |
|
62 | 838 |
"remove all objects and properties |
839 |
" |
|
238 | 840 |
treeView cvsEventsDisabledDo:[ |
223 | 841 |
self select:nil. |
238 | 842 |
treeView removeAll. |
223 | 843 |
self removeUndoHistory. |
111 | 844 |
] |
60 | 845 |
! ! |
846 |
||
847 |
!UIPainterView methodsFor:'searching'! |
|
848 |
||
285 | 849 |
findContainerOfView:aView |
850 |
"returns the super view assigned to a view |
|
89 | 851 |
" |
285 | 852 |
|p| |
89 | 853 |
|
285 | 854 |
(p := self propertyOfParentForView:aView) isNil ifTrue:[ |
89 | 855 |
^ self |
856 |
]. |
|
285 | 857 |
^ p view |
89 | 858 |
! |
859 |
||
60 | 860 |
findObjectAt:aPoint |
861 |
"find the origin/corner of the currentWidget |
|
862 |
" |
|
285 | 863 |
|view prop| |
60 | 864 |
|
865 |
view := super findObjectAt:aPoint. |
|
285 | 866 |
prop := self propertyRespondsToView:view. |
60 | 867 |
|
285 | 868 |
prop notNil ifTrue:[^ prop view]. |
869 |
^ nil |
|
60 | 870 |
! |
871 |
||
872 |
findViewWithId:aViewId |
|
62 | 873 |
"finds view assigned to identifier and returns the view or nil |
60 | 874 |
" |
875 |
|prop| |
|
876 |
||
877 |
prop := self propertyOfIdentifier:aViewId. |
|
878 |
||
879 |
prop notNil ifTrue:[^ prop view] |
|
880 |
ifFalse:[^ nil] |
|
78 | 881 |
! |
882 |
||
883 |
propertyOfIdentifier:anId |
|
884 |
"returns property assigned to unique identifier |
|
885 |
" |
|
886 |
anId notNil ifTrue:[ |
|
238 | 887 |
^ treeView propertyDetect:[:p| p identifier == anId ] |
78 | 888 |
]. |
889 |
^ nil |
|
890 |
! |
|
891 |
||
892 |
propertyOfName:aString |
|
893 |
"returns property assigned to name |
|
894 |
" |
|
111 | 895 |
|name| |
896 |
||
897 |
aString isNil ifFalse:[ |
|
898 |
name := aString string withoutSeparators. |
|
238 | 899 |
^ treeView propertyDetect:[:p| p name = name ]. |
78 | 900 |
]. |
901 |
^ nil |
|
902 |
! |
|
903 |
||
285 | 904 |
propertyOfParentForView:aSubView |
905 |
"returns the property of the parent or nil |
|
906 |
" |
|
907 |
|item| |
|
908 |
||
909 |
(item := treeView detectItemRespondsToView:aSubView) notNil ifTrue:[ |
|
910 |
(item := item parent) notNil ifTrue:[^ item contents] |
|
911 |
]. |
|
912 |
^ nil |
|
913 |
! |
|
914 |
||
78 | 915 |
propertyOfView:aView |
916 |
"returns property assigned to view |
|
917 |
" |
|
918 |
(aView isNil or:[aView == self]) ifFalse:[ |
|
238 | 919 |
^ treeView propertyDetect:[:p| p view == aView ] |
78 | 920 |
]. |
921 |
^ nil |
|
922 |
! |
|
923 |
||
285 | 924 |
propertyRespondsToView:aView |
925 |
"detect the property responding to the argument a view. The property of the view or |
|
926 |
the first subview providing the properties is returned. If no property is detected |
|
927 |
nil is returned. |
|
928 |
" |
|
929 |
|item| |
|
930 |
||
931 |
item := treeView detectItemRespondsToView:aView. |
|
932 |
||
933 |
(item notNil and:[item parent notNil]) ifTrue:[ |
|
934 |
^ item contents |
|
935 |
]. |
|
936 |
^ nil |
|
937 |
! |
|
938 |
||
111 | 939 |
uniqueNameFor:aSpecOrString |
78 | 940 |
"generate and return an unique name for a class |
941 |
" |
|
942 |
|next name size| |
|
943 |
||
111 | 944 |
aSpecOrString isString ifFalse:[name := aSpecOrString className asString] |
945 |
ifTrue:[name := aSpecOrString]. |
|
78 | 946 |
|
111 | 947 |
(name endsWith:'Spec') ifTrue:[ |
948 |
name := name copyFrom:1 to:(name size - 4). |
|
949 |
] ifFalse:[ |
|
950 |
name := name copy |
|
951 |
]. |
|
78 | 952 |
name at:1 put:(name at:1) asLowercase. |
111 | 953 |
size := name size + 1. |
954 |
next := 0. |
|
78 | 955 |
|
238 | 956 |
treeView propertiesDo:[:p| |
111 | 957 |
|n| |
78 | 958 |
n := p name. |
959 |
||
960 |
(n size >= size and:[n startsWith:name]) ifTrue:[ |
|
961 |
next := next max:(p extractNumberStartingAt:size) |
|
962 |
] |
|
963 |
]. |
|
964 |
next := next + 1. |
|
965 |
name := name, next printString. |
|
966 |
^ name |
|
967 |
||
968 |
||
969 |
||
970 |
! |
|
971 |
||
972 |
uniqueNameOf:aView |
|
111 | 973 |
|prop| |
78 | 974 |
|
111 | 975 |
(prop := self propertyOfView:aView) notNil ifTrue:[ |
976 |
prop name isNil ifTrue:[ |
|
977 |
prop name:(self uniqueNameFor:(prop spec)). |
|
978 |
]. |
|
979 |
^ prop name |
|
78 | 980 |
]. |
111 | 981 |
^ 'self' |
78 | 982 |
|
60 | 983 |
! ! |
984 |
||
223 | 985 |
!UIPainterView methodsFor:'selection basics'! |
986 |
||
987 |
addToSelection:anObject |
|
988 |
"add an object to the selection |
|
989 |
" |
|
990 |
(self enabled and:[(self isSelected:anObject) not]) ifTrue:[ |
|
991 |
selection isCollection ifFalse:[ |
|
992 |
selection isNil ifTrue:[ |
|
993 |
selection := anObject |
|
994 |
] ifFalse:[ |
|
995 |
selection := OrderedCollection with:selection with:anObject |
|
996 |
] |
|
997 |
] ifTrue:[ |
|
998 |
selection add:anObject |
|
999 |
]. |
|
1000 |
self showSelected:anObject. |
|
238 | 1001 |
treeView cvsSelectionAdd:anObject. |
223 | 1002 |
] |
1003 |
||
1004 |
||
1005 |
! |
|
1006 |
||
1007 |
removeFromSelection:anObject |
|
1008 |
"remove an object from the selection |
|
1009 |
" |
|
1010 |
(self isSelected:anObject) ifTrue:[ |
|
1011 |
self showUnselected:anObject. |
|
1012 |
||
1013 |
selection size > 1 ifTrue:[ |
|
1014 |
selection remove:anObject ifAbsent:nil. |
|
1015 |
self showSelection. |
|
1016 |
] ifFalse:[ |
|
1017 |
selection := nil |
|
1018 |
]. |
|
238 | 1019 |
treeView cvsSelectionRemove:anObject. |
223 | 1020 |
] |
1021 |
||
1022 |
! |
|
1023 |
||
1024 |
select:something |
|
1025 |
"change selection to something |
|
1026 |
" |
|
1027 |
(self enabled and:[something ~= self selection]) ifTrue:[ |
|
1028 |
self setSelection:something withRedraw:true. |
|
238 | 1029 |
treeView cvsSelection:something |
223 | 1030 |
] |
1031 |
||
1032 |
! |
|
1033 |
||
285 | 1034 |
updateSelectionFromModel:aSelOrNil |
223 | 1035 |
"update selection from a new selection |
1036 |
" |
|
1037 |
selectionHiddenLevel == 0 ifTrue:[ |
|
285 | 1038 |
aSelOrNil size ~~ 0 ifTrue:[ |
1039 |
self selectionDo:[:el| (aSelOrNil includes:el) ifFalse:[self showUnselected:el] ] |
|
1040 |
] ifFalse:[ |
|
1041 |
self selectionDo:[:el| self showUnselected:el ] |
|
1042 |
] |
|
223 | 1043 |
]. |
285 | 1044 |
self setSelection:aSelOrNil withRedraw:false. |
223 | 1045 |
self showSelection |
1046 |
||
1047 |
! ! |
|
1048 |
||
78 | 1049 |
!UIPainterView methodsFor:'specification'! |
1050 |
||
1051 |
addSpec:aSpecification builder:aBuilder in:aFrame |
|
1052 |
"build view and subviews from aSpecification into a frame. The top view |
|
1053 |
is returned. The contained components of a spec are set to nil |
|
1054 |
" |
|
330 | 1055 |
|cls| |
212 | 1056 |
|
330 | 1057 |
cls := self resolveName:className. |
1058 |
||
1059 |
cls notNil ifTrue:[ |
|
1060 |
aBuilder applicationClass:cls. |
|
212 | 1061 |
]. |
78 | 1062 |
|
111 | 1063 |
aBuilder componentCreationHook:[:aView :aSpec :aBdr||sv p s n| |
78 | 1064 |
p := ViewProperty new. |
1065 |
s := aSpec copy. |
|
1066 |
p spec:s. |
|
1067 |
p view:aView. |
|
1068 |
||
1069 |
s class supportsSubComponents ifTrue:[ |
|
1070 |
s component:nil |
|
1071 |
]. |
|
1072 |
||
111 | 1073 |
n := s name. |
1074 |
||
1075 |
(n isNil or:[(self propertyOfName:n) notNil]) ifTrue:[ |
|
1076 |
s name:(self uniqueNameFor:s) |
|
78 | 1077 |
]. |
238 | 1078 |
treeView addProperty:p. |
78 | 1079 |
]. |
1080 |
||
1081 |
^ aSpecification buildViewWithLayoutFor:aBuilder in:aFrame. |
|
60 | 1082 |
|
212 | 1083 |
"Modified: 4.7.1997 / 23:48:55 / cg" |
78 | 1084 |
! |
1085 |
||
1086 |
fullSpecFor:anObject |
|
1087 |
"generate a full spec for an object |
|
62 | 1088 |
" |
78 | 1089 |
|mySpec subSpecs| |
1090 |
||
1091 |
mySpec := self specFor:anObject. |
|
1092 |
||
1093 |
(mySpec notNil and:[mySpec class supportsSubComponents]) ifTrue:[ |
|
1094 |
(anObject subViews notNil) ifTrue:[ |
|
1095 |
anObject subViews do:[:aSubView||spec| |
|
1096 |
spec := self fullSpecFor:aSubView. |
|
1097 |
spec notNil ifTrue:[ |
|
1098 |
subSpecs isNil ifTrue:[ |
|
1099 |
subSpecs := OrderedCollection new |
|
1100 |
]. |
|
1101 |
subSpecs add:spec. |
|
1102 |
]. |
|
1103 |
]. |
|
1104 |
subSpecs notNil ifTrue:[ |
|
1105 |
mySpec component:(SpecCollection new collection:subSpecs) |
|
1106 |
] |
|
1107 |
] |
|
1108 |
]. |
|
1109 |
^ mySpec |
|
1110 |
||
60 | 1111 |
|
1112 |
||
1113 |
||
1114 |
||
1115 |
||
1116 |
! |
|
1117 |
||
285 | 1118 |
rebuildView:aView fromSpec:aSpec withBuilder:aBuilder |
1119 |
|v| |
|
1120 |
||
1121 |
aSpec needsRebuildForAttributes ifTrue:[ |
|
1122 |
v := aSpec buildViewWithLayoutFor:aBuilder in:(self findContainerOfView:aView). |
|
1123 |
v realize. |
|
1124 |
aView destroy. |
|
1125 |
device sync. |
|
1126 |
device flush. |
|
1127 |
aView becomeSameAs:v. |
|
1128 |
inputView raise. |
|
1129 |
] ifFalse:[ |
|
1130 |
aSpec setAttributesIn:aView with:aBuilder. |
|
1131 |
self elementChangedSize:aView. |
|
1132 |
]. |
|
1133 |
||
1134 |
! |
|
1135 |
||
78 | 1136 |
specFor:anObject |
1137 |
"returns spec assigned to an object |
|
62 | 1138 |
" |
78 | 1139 |
|prop spec| |
60 | 1140 |
|
78 | 1141 |
(prop := self propertyOfView:anObject) notNil ifTrue:[ |
1142 |
spec := prop spec copy. |
|
1143 |
spec layoutFromView:anObject |
|
60 | 1144 |
]. |
78 | 1145 |
^ spec |
1146 |
||
1147 |
||
1148 |
||
60 | 1149 |
! |
1150 |
||
146 | 1151 |
specForSelection |
1152 |
"returns spec assigned to current single selection or nil |
|
1153 |
" |
|
1154 |
^ self specFor:(self singleSelection) |
|
1155 |
||
1156 |
||
1157 |
! |
|
1158 |
||
78 | 1159 |
updateFromSpec:aSpec |
1160 |
"update current selected view from specification |
|
62 | 1161 |
" |
327
0040d47658c6
check - warnings eliminated. Fix in InspectorList.st
Claus Gittinger <cg@exept.de>
parents:
316
diff
changeset
|
1162 |
|props name builder| |
78 | 1163 |
|
281 | 1164 |
aSpec class == WindowSpec ifTrue:[ |
310 | 1165 |
^ treeView canvasSpec:aSpec |
281 | 1166 |
]. |
1167 |
||
78 | 1168 |
self singleSelection notNil ifTrue:[ |
1169 |
self withSelectionHiddenDo:[ |
|
1170 |
self transaction:#specification selectionDo:[:aView| |
|
1171 |
builder := UIBuilder new. |
|
212 | 1172 |
className notNil ifTrue:[ |
330 | 1173 |
builder applicationClass:(self resolveName:className). |
212 | 1174 |
]. |
78 | 1175 |
props := self propertyOfView:aView. |
82 | 1176 |
name := (aSpec name) withoutSeparators. |
78 | 1177 |
|
82 | 1178 |
name = props name ifFalse:[ |
1179 |
(self propertyOfName:name) notNil ifTrue:[ |
|
1180 |
name := props name |
|
78 | 1181 |
] |
1182 |
]. |
|
82 | 1183 |
aSpec name:name. |
134 | 1184 |
self createUndoSpecModify:props. |
285 | 1185 |
self rebuildView:aView fromSpec:aSpec withBuilder:builder. |
78 | 1186 |
props spec:(aSpec copy). |
238 | 1187 |
treeView propertyChanged:props. |
78 | 1188 |
] |
111 | 1189 |
] |
82 | 1190 |
] |
212 | 1191 |
|
1192 |
"Modified: 4.7.1997 / 23:49:44 / cg" |
|
60 | 1193 |
! ! |
1194 |
||
285 | 1195 |
!UIPainterView methodsFor:'testing'! |
1196 |
||
1197 |
canChangeLayoutOfView:aView |
|
1198 |
"returns true if the view can change its layout which is dependant on |
|
1199 |
its parent view. |
|
1200 |
" |
|
1201 |
|item prnt| |
|
1202 |
||
1203 |
( (item := treeView itemOfView:aView) isNil |
|
1204 |
or:[(prnt := item parent) isNil] |
|
1205 |
) ifTrue:[ |
|
1206 |
^ false |
|
1207 |
]. |
|
1208 |
^ (prnt parent isNil or:[prnt contents spec class isLayoutContainer not]) |
|
1209 |
! |
|
1210 |
||
1211 |
canKeepLayoutInSelection |
|
1212 |
"returns true if layout can be kept during a paste operation |
|
1213 |
" |
|
1214 |
|prop| |
|
1215 |
||
1216 |
prop := self propertyOfView:(self singleSelection). |
|
1217 |
^ (prop isNil or:[prop spec class isLayoutContainer not]) |
|
1218 |
! |
|
1219 |
||
1220 |
canMove:something |
|
1221 |
"checks whether something is not nil and if all widgets derived from |
|
1222 |
something can change their layout ( move, align, ... operation ). |
|
1223 |
" |
|
1224 |
something notNil ifTrue:[ |
|
1225 |
self forEach:something do:[:aView| |
|
1226 |
(self canChangeLayoutOfView:aView) ifFalse:[^ false] |
|
1227 |
]. |
|
1228 |
^ true |
|
1229 |
]. |
|
1230 |
^ false |
|
1231 |
! |
|
1232 |
||
1233 |
canMoveOrAlignSelection |
|
1234 |
"returns true if a selection exists and all elements in the selection |
|
1235 |
can be moved or aligned |
|
1236 |
" |
|
1237 |
^ self canMove:(self selection) |
|
1238 |
||
1239 |
! ! |
|
1240 |
||
60 | 1241 |
!UIPainterView methodsFor:'transaction'! |
1242 |
||
1243 |
transaction:aType objects:something do:aOneArgBlock |
|
1244 |
"opens a transaction and evaluates a block within the transaction; the |
|
1245 |
argument to the block is a view from derived from something |
|
1246 |
" |
|
134 | 1247 |
self withinTransaction:aType objects:something do:[ |
1248 |
self forEach:something do:aOneArgBlock |
|
60 | 1249 |
] |
1250 |
! |
|
1251 |
||
134 | 1252 |
withinTransaction:aType objects:objects do:aNoneArgBlock |
1253 |
"evaluate a block with no arguments within a transaction |
|
60 | 1254 |
" |
134 | 1255 |
|text size prop| |
1256 |
||
1257 |
objects isNil ifTrue:[ ^ self ]. |
|
1258 |
||
1259 |
size := objects size. |
|
60 | 1260 |
|
134 | 1261 |
objects isCollection ifTrue:[ |
1262 |
size == 0 ifTrue:[ ^ self ]. |
|
1263 |
size == 1 ifTrue:[ prop := self propertyOfView:(objects first) ] |
|
1264 |
] ifFalse:[ |
|
1265 |
prop := self propertyOfView:objects |
|
1266 |
]. |
|
60 | 1267 |
|
134 | 1268 |
prop notNil ifTrue:[ |
1269 |
text := prop name |
|
1270 |
] ifFalse:[ |
|
1271 |
text := size printString, ' elements' |
|
60 | 1272 |
]. |
134 | 1273 |
|
1274 |
undoHistory withinTransaction:aType text:text do:[ |
|
1275 |
aNoneArgBlock value |
|
1276 |
] |
|
60 | 1277 |
! ! |
1278 |
||
1279 |
!UIPainterView methodsFor:'undo actions'! |
|
1280 |
||
134 | 1281 |
createUndoLayout:aView |
1282 |
"create undo action before changing a views layout |
|
60 | 1283 |
" |
134 | 1284 |
|lyt args prop| |
60 | 1285 |
|
1286 |
undoHistory isTransactionOpen ifTrue:[ |
|
1287 |
prop := self propertyOfView:aView. |
|
134 | 1288 |
|
60 | 1289 |
prop notNil ifTrue:[ |
134 | 1290 |
args := Array new:3. |
1291 |
args at:1 put:(prop identifier). |
|
1292 |
||
1293 |
(lyt := aView geometryLayout) notNil ifTrue:[ |
|
1294 |
args at:2 put:#geometryLayout: |
|
1295 |
] ifFalse:[ |
|
146 | 1296 |
lyt := aView extent. |
134 | 1297 |
args at:2 put:#extent: |
1298 |
]. |
|
1299 |
args at:3 put:(lyt copy). |
|
1300 |
undoHistory addUndoSelector:#undoLayout: withArgs:args. |
|
60 | 1301 |
] |
1302 |
] |
|
1303 |
! |
|
1304 |
||
134 | 1305 |
createUndoRemove:aView |
1306 |
"create undo method before deleting views |
|
60 | 1307 |
" |
285 | 1308 |
|prop pid| |
134 | 1309 |
|
1310 |
(prop := self propertyOfView:aView) notNil ifTrue:[ |
|
285 | 1311 |
(pid := self propertyOfParentForView:aView) notNil ifTrue:[ |
1312 |
pid := pid identifier |
|
1313 |
]. |
|
60 | 1314 |
|
134 | 1315 |
undoHistory addUndoSelector:#undoRemove: |
285 | 1316 |
withArgs:(Array with:(self fullSpecFor:aView) |
1317 |
with:(prop identifier) |
|
1318 |
with:pid) |
|
134 | 1319 |
] |
1320 |
! |
|
60 | 1321 |
|
134 | 1322 |
createUndoSpecModify:aProp |
1323 |
"undo method when changing the specification for an object |
|
1324 |
" |
|
1325 |
aProp notNil ifTrue:[ |
|
1326 |
undoHistory addUndoSelector:#undoSpecModify: |
|
1327 |
withArgs:(Array with:(aProp spec) with:(aProp identifier)) |
|
1328 |
] |
|
1329 |
! |
|
60 | 1330 |
|
134 | 1331 |
undoCreate:something |
1332 |
"undo method for creating or pasting an object |
|
1333 |
" |
|
1334 |
self forEach:something do:[:anId|self remove:(self findViewWithId:anId)]. |
|
1335 |
! |
|
60 | 1336 |
|
134 | 1337 |
undoLayout:args |
1338 |
"undo method to set the old layout; see 'createUndoLayout:' |
|
1339 |
" |
|
1340 |
|view| |
|
1341 |
||
1342 |
(view := self findViewWithId:(args at:1)) notNil ifTrue:[ |
|
146 | 1343 |
view perform:(args at:2) with:(args at:3). |
223 | 1344 |
self layoutChanged. |
60 | 1345 |
] |
1346 |
! |
|
1347 |
||
134 | 1348 |
undoRemove:args |
1349 |
"undo method when removing an object; see 'createUndoRemove:' |
|
1350 |
" |
|
1351 |
|frame prop view| |
|
1352 |
||
1353 |
(args at:3) notNil ifTrue:[ |
|
1354 |
frame := self findViewWithId:(args at:3). |
|
1355 |
]. |
|
1356 |
frame isNil ifTrue:[ |
|
1357 |
frame := self |
|
1358 |
]. |
|
1359 |
view := self addSpec:(args at:1) builder:(UIBuilder new) in:frame. |
|
1360 |
view realize. |
|
1361 |
inputView raise. |
|
1362 |
||
1363 |
prop := self propertyOfView:view. |
|
1364 |
prop identifier:(args at:2). |
|
1365 |
||
1366 |
! |
|
1367 |
||
1368 |
undoSpecModify:args |
|
1369 |
"undo method when changing a spec; see 'createUndoSpecModify:' |
|
60 | 1370 |
" |
327
0040d47658c6
check - warnings eliminated. Fix in InspectorList.st
Claus Gittinger <cg@exept.de>
parents:
316
diff
changeset
|
1371 |
|builder view spec props| |
60 | 1372 |
|
134 | 1373 |
props := self propertyOfIdentifier:(args at:2). |
60 | 1374 |
|
134 | 1375 |
props notNil ifTrue:[ |
1376 |
view := props view. |
|
1377 |
spec := args at:1. |
|
1378 |
builder := UIBuilder new. |
|
212 | 1379 |
className notNil ifTrue:[ |
330 | 1380 |
builder applicationClass:(self resolveName:className). |
212 | 1381 |
]. |
134 | 1382 |
props spec:spec. |
285 | 1383 |
self rebuildView:view fromSpec:spec withBuilder:builder. |
238 | 1384 |
treeView propertyChanged:props. |
211 | 1385 |
] |
1386 |
! ! |
|
1387 |
||
1388 |
!UIPainterView::ViewProperty class methodsFor:'instance creation'! |
|
1389 |
||
1390 |
new |
|
1391 |
Identifier notNil ifTrue:[Identifier := Identifier + 1] |
|
1392 |
ifFalse:[Identifier := 1]. |
|
1393 |
||
1394 |
^ self basicNew initialize |
|
1395 |
! ! |
|
1396 |
||
1397 |
!UIPainterView::ViewProperty methodsFor:'accessing'! |
|
1398 |
||
1399 |
identifier |
|
1400 |
"return the unique identifier assigned to property |
|
1401 |
" |
|
1402 |
^ identifier |
|
1403 |
! |
|
1404 |
||
1405 |
identifier:anIdentifier |
|
1406 |
"set the unique identifier assigned to property; called after an restore of |
|
1407 |
a deleted instance |
|
1408 |
" |
|
1409 |
identifier := anIdentifier |
|
1410 |
! |
|
1411 |
||
1412 |
spec |
|
1413 |
"return the value of the instance variable 'spec' (automatically generated)" |
|
1414 |
||
1415 |
^ spec! |
|
1416 |
||
1417 |
spec:something |
|
1418 |
"set the value of the instance variable 'spec' (automatically generated)" |
|
1419 |
||
1420 |
spec := something.! |
|
1421 |
||
1422 |
view |
|
1423 |
"return the value of the instance variable 'view' (automatically generated)" |
|
1424 |
||
1425 |
^ view! |
|
1426 |
||
1427 |
view:something |
|
1428 |
"set the value of the instance variable 'view' (automatically generated)" |
|
1429 |
||
1430 |
view := something.! ! |
|
1431 |
||
1432 |
!UIPainterView::ViewProperty methodsFor:'initialization'! |
|
1433 |
||
1434 |
initialize |
|
1435 |
super initialize. |
|
1436 |
identifier := Identifier |
|
1437 |
! ! |
|
1438 |
||
1439 |
!UIPainterView::ViewProperty methodsFor:'misc'! |
|
1440 |
||
1441 |
extractNumberStartingAt:anIndex |
|
1442 |
"return the number from the name starting at anIndex or 0. |
|
1443 |
" |
|
1444 |
|val| |
|
1445 |
||
1446 |
val := 0. |
|
1447 |
||
1448 |
self name from:anIndex do:[:c| |
|
1449 |
c isDigit ifTrue:[val := val * 10 + c digitValue] |
|
1450 |
ifFalse:[^ 0] |
|
1451 |
]. |
|
1452 |
^ val |
|
1453 |
||
1454 |
! ! |
|
1455 |
||
1456 |
!UIPainterView::ViewProperty methodsFor:'spec messages'! |
|
1457 |
||
1458 |
doesNotUnderstand:aMessage |
|
1459 |
spec notNil ifTrue:[ |
|
1460 |
(spec respondsTo:(aMessage selector)) ifTrue:[^ aMessage sendTo:spec] |
|
1461 |
]. |
|
1462 |
^ nil |
|
1463 |
! |
|
1464 |
||
1465 |
layout |
|
1466 |
spec layout |
|
1467 |
! |
|
1468 |
||
1469 |
layout:aLayout |
|
1470 |
spec layout:aLayout |
|
1471 |
! |
|
1472 |
||
1473 |
name |
|
1474 |
^ spec name |
|
1475 |
! |
|
1476 |
||
1477 |
name:aName |
|
1478 |
spec name:aName |
|
1479 |
! ! |
|
1480 |
||
60 | 1481 |
!UIPainterView class methodsFor:'documentation'! |
1482 |
||
1483 |
version |
|
1484 |
^ '$Header$' |
|
1485 |
! ! |