12 "{ Package: 'stx:libtool2' }" |
12 "{ Package: 'stx:libtool2' }" |
13 |
13 |
14 UIObjectView subclass:#UIPainterView |
14 UIObjectView subclass:#UIPainterView |
15 instanceVariableNames:'treeView listHolder superclassName className methodName |
15 instanceVariableNames:'treeView listHolder superclassName className methodName |
16 categoryName handleColorBlack handleColorWhite handleMasterColor |
16 categoryName handleColorBlack handleColorWhite handleMasterColor |
17 sketchPainter' |
17 sketchPainter listOfAspectsHolder' |
18 classVariableNames:'HandCursor RedefineAspectMethods AspectsAsInstances |
18 classVariableNames:'HandCursor RedefineAspectMethods AspectsAsInstances |
19 GenerateCommentedCode' |
19 GenerateCommentedCode' |
20 poolDictionaries:'' |
20 poolDictionaries:'' |
21 category:'Interface-UIPainter' |
21 category:'Interface-UIPainter' |
22 ! |
22 ! |
166 className:aClassName superclassName:aSuperclassName selector:aSelector |
166 className:aClassName superclassName:aSuperclassName selector:aSelector |
167 self assert:(aClassName isString). |
167 self assert:(aClassName isString). |
168 className := aClassName. |
168 className := aClassName. |
169 superclassName := aSuperclassName. |
169 superclassName := aSuperclassName. |
170 methodName := aSelector. |
170 methodName := aSelector. |
|
171 ! |
|
172 |
|
173 listOfAspectsHolder:something |
|
174 listOfAspectsHolder := something. |
171 ! |
175 ! |
172 |
176 |
173 methodName |
177 methodName |
174 ^ methodName |
178 ^ methodName |
175 ! |
179 ! |
609 ! |
615 ! |
610 |
616 |
611 canPaste:something into:containerToPasteInto |
617 canPaste:something into:containerToPasteInto |
612 "returns true if something could be pasted" |
618 "returns true if something could be pasted" |
613 |
619 |
614 |el size| |
620 (self enabled) ifFalse:[ |
615 |
|
616 ((size := self numberOfSelections) <= 1 and:[self enabled]) ifFalse:[ |
|
617 ^ false |
621 ^ false |
618 ]. |
622 ]. |
619 something isCollection |
623 something isCollection ifTrue:[ |
620 ifTrue:[something notEmpty ifTrue:[el := something first]] |
624 something isEmpty ifTrue:[ ^ false]. |
621 ifFalse:[el := something]. |
625 ^ something conform:[:el | (self canPaste:el into:containerToPasteInto)] |
622 |
626 ]. |
623 (el isKindOf:UISpecification) ifFalse:[ |
627 |
|
628 (something isKindOf:UISpecification) ifFalse:[ |
624 ^ false |
629 ^ false |
625 ]. |
630 ]. |
626 |
631 |
627 size == 1 ifTrue:[ |
632 ^ self canPasteInto:containerToPasteInto |
628 ^ self canPasteInto:containerToPasteInto |
|
629 ]. |
|
630 ^ true |
|
631 ! |
633 ! |
632 |
634 |
633 canPasteInto:aView |
635 canPasteInto:aView |
634 "return true, if I can paste into a view" |
636 "return true, if I can paste into a view" |
635 |
637 |
1452 - but do not overwrite existing ones. |
1454 - but do not overwrite existing ones. |
1453 Return a string ready to compile into the application class." |
1455 Return a string ready to compile into the application class." |
1454 |
1456 |
1455 |cls code menuSelector thisCode |
1457 |cls code menuSelector thisCode |
1456 definedMethodSelectors |
1458 definedMethodSelectors |
1457 specArray fullSpec winSpec menuSpec |
1459 spec specArray fullSpec winSpec menuSpec| |
1458 | |
|
1459 |
1460 |
1460 cls := self targetClass. |
1461 cls := self targetClass. |
1461 cls isNil ifTrue:[ |
1462 cls isNil ifTrue:[ |
1462 ^ nil |
1463 ^ nil |
1463 ]. |
1464 ]. |
1464 |
1465 |
1465 specArray := treeView generateFullSpecForComponents:#() named:nil. |
1466 spec := treeView generateFullSpecForComponents:#() named:nil. |
|
1467 specArray := spec literalArrayEncoding. |
1466 fullSpec := specArray decodeAsLiteralArray. |
1468 fullSpec := specArray decodeAsLiteralArray. |
1467 winSpec := fullSpec window. |
1469 winSpec := fullSpec window. |
1468 menuSelector := winSpec menu. |
1470 menuSelector := winSpec menu. |
1469 |
1471 |
1470 (menuSelector notNil |
1472 (menuSelector notNil |
1471 and:[ (cls respondsTo:menuSelector) ]) ifFalse:[ |
1473 and:[ (cls respondsTo:menuSelector) ]) ifFalse:[ |
1472 self warn:'No menu defined (yet)'. |
1474 self warn:'No menu defined (yet)'. |
1473 ^ nil. |
1475 ^ nil. |
1474 ]. |
1476 ]. |
1475 menuSpec := cls perform:menuSelector. |
1477 menuSpec := cls perform:menuSelector. |
1476 menuSpec := menuSpec decodeAsLiteralArray. |
1478 menuSpec := menuSpec decodeAsLiteralArray. |
1477 |
1479 |
1478 definedMethodSelectors := IdentitySet new. |
1480 definedMethodSelectors := IdentitySet new. |
1479 code := ''. |
1481 code := ''. |
1480 |
1482 |
1481 menuSpec allItemsDo:[:item | |
1483 menuSpec allItemsDo:[:item | |
1482 |sel| |
1484 |sel| |
1483 |
1485 |
1484 (sel := item value) notNil ifTrue:[ |
1486 (sel := item value) notNil ifTrue:[ |
1485 (definedMethodSelectors includes:sel) ifFalse:[ |
1487 (definedMethodSelectors includes:sel) ifFalse:[ |
1486 self generateCodeFrom:(Array with:sel) in:cls do:[:aSel| |
1488 self generateCodeFrom:(Array with:sel) in:cls do:[:aSel| |
1487 thisCode := (self generateMenuMethodFor:aSel inClass:cls). |
1489 thisCode := (self generateMenuMethodFor:aSel inClass:cls). |
1488 code := code, thisCode. |
1490 code := code, thisCode. |
1489 ]. |
1491 ]. |
1490 definedMethodSelectors add:sel. |
1492 definedMethodSelectors add:sel. |
1491 ]. |
1493 ]. |
1492 ] |
1494 ] |
1493 ]. |
1495 ]. |
1494 |
1496 |
1495 (definedMethodSelectors includes:#menuOpen) ifTrue:[ |
1497 (definedMethodSelectors includes:#menuOpen) ifTrue:[ |
1496 self generateCodeFrom:(Array with:#doOpen:) in:cls do:[:aSel| |
1498 self generateCodeFrom:(Array with:#doOpen:) in:cls do:[:aSel| |
1497 thisCode := (self generateMenuMethodFor:aSel inClass:cls). |
1499 thisCode := (self generateMenuMethodFor:aSel inClass:cls). |
1498 code := code, thisCode. |
1500 code := code, thisCode. |
1499 ]. |
1501 ]. |
1500 ]. |
1502 ]. |
1501 |
1503 |
1502 ^ code |
1504 ^ code |
1503 |
1505 |
1504 "Created: / 23.8.1998 / 16:12:09 / cg" |
1506 "Created: / 23.8.1998 / 16:12:09 / cg" |
1546 spec := treeView generateFullSpecForComponents:spec named:methodName. |
1548 spec := treeView generateFullSpecForComponents:spec named:methodName. |
1547 ^ spec |
1549 ^ spec |
1548 ! |
1550 ! |
1549 |
1551 |
1550 generateWindowSpecMethodSource |
1552 generateWindowSpecMethodSource |
1551 |spec str code category cls mthd specCode| |
1553 |spec specArray str code category cls mthd specCode| |
1552 |
1554 |
1553 spec := self generateWindowSpec. |
1555 spec := self generateWindowSpec. |
|
1556 specArray := spec literalArrayEncoding. |
1554 |
1557 |
1555 str := WriteStream on:String new. |
1558 str := WriteStream on:String new. |
1556 UISpecification prettyPrintSpecArray:spec on:str indent:5. |
1559 UISpecification prettyPrintSpecArray:specArray on:str indent:5. |
1557 specCode := str contents. |
1560 specCode := str contents. |
1558 |
1561 |
1559 (specCode includes:$!!) ifTrue:[ |
1562 (specCode includes:$!!) ifTrue:[ |
1560 "/ oops - must be chunk format ... |
1563 "/ oops - must be chunk format ... |
1561 str := WriteStream on:String new. |
1564 str := WriteStream on:String new. |