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