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