247 |
247 |
248 |
248 |
249 ! ! |
249 ! ! |
250 |
250 |
251 !UIPainterView methodsFor:'generating output'! |
251 !UIPainterView methodsFor:'generating output'! |
252 |
|
253 XXgenerateWindowSpecMethodSource |
|
254 |spec specArray str code| |
|
255 |
|
256 subViews remove:inputView. |
|
257 [ |
|
258 spec := FullSpec fromView:self |
|
259 ] valueNowOrOnUnwindDo:[ |
|
260 subViews addFirst:inputView. |
|
261 ]. |
|
262 specArray := spec literalArrayEncoding. |
|
263 |
|
264 str := WriteStream on:String new. |
|
265 self prettyPrintSpecArray:specArray on:str indent:5. |
|
266 |
|
267 code := Character excla asString |
|
268 , className , ' class methodsFor:''interface specs''' |
|
269 , Character excla asString , '\\' |
|
270 |
|
271 , methodName , '\' |
|
272 , ' "this window spec was automatically generated by the ST/X UIPainter"\\' |
|
273 , ' "do not manually edit this - the painter/builder may not be able to\' |
|
274 , ' handle the specification if its corrupted."\\' |
|
275 , ' "\' |
|
276 , ' UIPainter new openOnClass:' , className , ' andSelector:#' , methodName , '\' |
|
277 , ' ' , className , ' new openInterface:#' , methodName , '\' |
|
278 , ' "\'. |
|
279 |
|
280 methodName = 'windowSpec' ifTrue:[ |
|
281 code := code , ' "' , className , ' open"\' |
|
282 ]. |
|
283 code := code |
|
284 , '\' |
|
285 , ' <resource: #canvas>\\' |
|
286 , ' ^\' |
|
287 , ' ', str contents |
|
288 , '\' |
|
289 , Character excla asString |
|
290 , ' ' |
|
291 , Character excla asString |
|
292 , '\\'. |
|
293 |
|
294 ^ code withCRs |
|
295 |
|
296 "Modified: 5.9.1995 / 21:01:35 / claus" |
|
297 ! |
|
298 |
252 |
299 generateActionMethodFor:aspect spec:protoSpec inClass:targetClass |
253 generateActionMethodFor:aspect spec:protoSpec inClass:targetClass |
300 ^ ('!!' , targetClass name , ' methodsFor:''actions''!!\\' , |
254 ^ ('!!' , targetClass name , ' methodsFor:''actions''!!\\' , |
301 aspect , '\' , |
255 aspect , '\' , |
302 ' "automatically generated by UIPainter ..."\' , |
256 ' "automatically generated by UIPainter ..."\' , |
576 spec := FullSpec new. |
530 spec := FullSpec new. |
577 spec fromBuilder:self components:(SpecCollection new collection:specArray). |
531 spec fromBuilder:self components:(SpecCollection new collection:specArray). |
578 specArray := spec literalArrayEncoding. |
532 specArray := spec literalArrayEncoding. |
579 |
533 |
580 str := WriteStream on:String new. |
534 str := WriteStream on:String new. |
581 self prettyPrintSpecArray:specArray on:str indent:5. |
535 UISpecification prettyPrintSpecArray:specArray on:str indent:5. |
582 |
536 |
583 code := Character excla asString |
537 code := Character excla asString |
584 , className , ' class methodsFor:''interface specs''' |
538 , className , ' class methodsFor:''interface specs''' |
585 , Character excla asString , '\\' |
539 , Character excla asString , '\\' |
586 |
540 |
638 ^ nil |
592 ^ nil |
639 |
593 |
640 |
594 |
641 |
595 |
642 |
596 |
643 ! |
|
644 |
|
645 prettyPrintSpecArray:spec on:aStream indent:i |
|
646 "just for your convenience: prettyPrint a specArray to aStream - it looks better that way" |
|
647 |
|
648 |what oneLine| |
|
649 |
|
650 spec isArray ifFalse:[ |
|
651 spec isLiteral ifTrue:[ |
|
652 aStream nextPutAll:spec storeString |
|
653 ] ifFalse:[ |
|
654 self halt. |
|
655 ]. |
|
656 ^ self |
|
657 ]. |
|
658 |
|
659 spec isEmpty ifTrue:[ |
|
660 aStream nextPutAll:'#()'. |
|
661 ^ self |
|
662 ]. |
|
663 |
|
664 what := spec at:1. |
|
665 what isArray ifTrue:[ |
|
666 aStream cr; spaces:i+2. |
|
667 aStream nextPutAll:'#('. |
|
668 "/ a spec-collection |
|
669 spec do:[:element | |
|
670 self prettyPrintSpecArray:element on:aStream indent:i+2. |
|
671 ]. |
|
672 aStream cr. |
|
673 aStream spaces:i+1. |
|
674 aStream nextPutAll:')'. |
|
675 ^ self. |
|
676 ]. |
|
677 |
|
678 oneLine := false. |
|
679 (#(#LayoutFrame #LayoutOrigin #AlignmentOrigin |
|
680 #Rectangle #Point |
|
681 #Color #ColorValue |
|
682 ) |
|
683 includesIdentical:what) ifTrue:[ |
|
684 oneLine := true |
|
685 ]. |
|
686 |
|
687 oneLine ifFalse:[ |
|
688 aStream cr. |
|
689 aStream spaces:i+2. |
|
690 ]. |
|
691 aStream nextPutAll:'#('. |
|
692 |
|
693 |
|
694 aStream nextPutAll:what storeString. |
|
695 |
|
696 oneLine ifFalse:[ |
|
697 aStream cr. |
|
698 aStream spaces:i+4. |
|
699 ]. |
|
700 |
|
701 2 to:spec size do:[:index | |
|
702 aStream space. |
|
703 self prettyPrintSpecArray:(spec at:index) on:aStream indent:i+4. |
|
704 oneLine ifFalse:[ |
|
705 (index odd and:[index ~~ (spec size)]) ifTrue:[ |
|
706 aStream cr; spaces:i+4. |
|
707 ] |
|
708 ] |
|
709 ]. |
|
710 oneLine ifFalse:[ |
|
711 aStream cr. |
|
712 aStream spaces:i+1. |
|
713 ]. |
|
714 aStream nextPutAll:')'. |
|
715 |
|
716 "Modified: 5.9.1995 / 17:44:20 / claus" |
|
717 ! |
597 ! |
718 |
598 |
719 storeContentsOn:aStream |
599 storeContentsOn:aStream |
720 viewProperties do:[:p| p storeOn:aStream] |
600 viewProperties do:[:p| p storeOn:aStream] |
721 ! |
601 ! |
1221 |
1101 |
1222 |
1102 |
1223 ! |
1103 ! |
1224 |
1104 |
1225 uniqueNameOf:aView |
1105 uniqueNameOf:aView |
1226 |prop| |
1106 |name prop| |
1227 |
1107 |
1228 aView notNil ifTrue:[ |
1108 aView notNil ifTrue:[ |
1229 prop := self propertyOfView:aView |
1109 prop := self propertyOfView:aView |
1230 ]. |
1110 ]. |
1231 |
1111 prop isNil ifTrue:[ |
1232 prop notNil ifTrue:[^ prop name] |
1112 ^ 'self' |
1233 ifFalse:[^ 'self'] |
1113 ]. |
|
1114 (name := prop name) isNil ifTrue:[ |
|
1115 name := self uniqueNameFor:(aView class). |
|
1116 prop name:name. |
|
1117 ]. |
|
1118 ^ name |
|
1119 |
1234 ! ! |
1120 ! ! |
1235 |
1121 |
1236 !UIPainterView methodsFor:'selection'! |
1122 !UIPainterView methodsFor:'selection'! |
1237 |
1123 |
1238 addTreeFrom:aView to:aCollection |
1124 addTreeFrom:aView to:aCollection |