UIPainterView.st
changeset 149 e652608690b1
parent 146 ae84facd80be
child 154 34d5602e13d7
equal deleted inserted replaced
148:785417b6955d 149:e652608690b1
    18 !
    18 !
    19 
    19 
    20 Object subclass:#ViewProperty
    20 Object subclass:#ViewProperty
    21 	instanceVariableNames:'view spec identifier'
    21 	instanceVariableNames:'view spec identifier'
    22 	classVariableNames:'Identifier'
    22 	classVariableNames:'Identifier'
    23 	poolDictionaries:''
       
    24 	privateIn:UIPainterView
       
    25 !
       
    26 
       
    27 UIPainterView::ViewProperty subclass:#GroupProperties
       
    28 	instanceVariableNames:'controlledObjects group name'
       
    29 	classVariableNames:''
       
    30 	poolDictionaries:''
    23 	poolDictionaries:''
    31 	privateIn:UIPainterView
    24 	privateIn:UIPainterView
    32 !
    25 !
    33 
    26 
    34 MultiSelectionInList subclass:#ListHolder
    27 MultiSelectionInList subclass:#ListHolder
   526 ! !
   519 ! !
   527 
   520 
   528 !UIPainterView methodsFor:'generating output'!
   521 !UIPainterView methodsFor:'generating output'!
   529 
   522 
   530 generateActionMethodFor:aspect spec:protoSpec inClass:targetClass
   523 generateActionMethodFor:aspect spec:protoSpec inClass:targetClass
   531     |args|
   524     |args showIt|
   532 
   525 
   533 
   526     (aspect asSymbol numArgs) == 1 ifFalse:[
   534     (aspect last) == $: ifFalse:[args := '\']
   527         args := '\'.
   535                          ifTrue:[args := 'anArgument\'].
   528         showIt := ' ...''.\'.
       
   529     ] ifTrue:[
       
   530         args := 'anArgument\'.
       
   531         showIt := ''' , anArgument printString , '' ...''.\'.
       
   532     ].
   536 
   533 
   537     ^ ('!!' , targetClass name , ' methodsFor:''actions''!!\\' ,
   534     ^ ('!!' , targetClass name , ' methodsFor:''actions''!!\\' ,
   538       aspect , args ,
   535       aspect , args ,
   539       '    "automatically generated by UIPainter ..."\' ,
   536       '    "automatically generated by UIPainter ..."\' ,
   540       '\' ,
   537       '\' ,
   541       '    "action to be added ..."\' ,
   538       '    "action to be added ..."\' ,
   542       '    Transcript showCR:''action for ' , aspect , ' ...''.\' ,
   539       '    Transcript showCR:self class name , '': action for ' , aspect , showIt ,
   543       '!! !!\\') withCRs
   540       '!! !!\\') withCRs
   544 !
   541 !
   545 
   542 
   546 generateAspectMethodFor:aspect spec:protoSpec inClass:targetClass
   543 generateAspectMethodFor:aspect spec:protoSpec inClass:targetClass
   547     |modelClass|
   544     |modelClass|
   548 
   545 
   549     modelClass := protoSpec defaultModelClass.
   546     modelClass := protoSpec defaultModelClassFor:aspect.
   550 
   547 
   551     ^ ('!!' , targetClass name , ' methodsFor:''aspects''!!\\' ,
   548     ^ ('!!' , targetClass name , ' methodsFor:''aspects''!!\\' ,
   552       aspect , '\' ,
   549       aspect , '\' ,
   553       '    "automatically generated by UIPainter ..."\' ,
   550       '    "automatically generated by UIPainter ..."\' ,
   554       '\' ,
   551       '\' ,
   656 "/    code := code , self generateAspectMethods.
   653 "/    code := code , self generateAspectMethods.
   657 
   654 
   658     ^ code withCRs
   655     ^ code withCRs
   659 
   656 
   660     "Modified: 5.9.1995 / 20:57:53 / claus"
   657     "Modified: 5.9.1995 / 20:57:53 / claus"
   661 !
       
   662 
       
   663 generateInitCodeForGroup:aGroup
       
   664     |code c name p objects outlets moreCode sym typ val|
       
   665 
       
   666     " <name> := <GroupClass> in:<name-of-superview>"
       
   667 
       
   668     code := ''.
       
   669 
       
   670     p := self propertyOfGroup:aGroup.
       
   671     name := p at:#variableName.
       
   672     c := '  ' , name , ' := ' , (aGroup class name) , ' new.\'.
       
   673 
       
   674     code := code , c withCRs.
       
   675 
       
   676     " <name> <symbol>:<value>"
       
   677 
       
   678     objects := p at:#controlledObjects ifAbsent:[nil].
       
   679     objects notNil ifTrue:[
       
   680         objects do:[:controlledObject |
       
   681             c := c , name , ' add:' , (self uniqueNameOf:controlledObject) , '.\'
       
   682         ]
       
   683     ].
       
   684 
       
   685     code := code , c withCRs
       
   686 
       
   687 
       
   688 
       
   689 
       
   690 
       
   691 !
       
   692 
       
   693 generateInitCodeForOtherStuff
       
   694     |code g c name p outlets moreCode sym typ val|
       
   695 
       
   696     code := ''.
       
   697 
       
   698     "generate code for groups"
       
   699 
       
   700     listHolder propertiesDo:[:props|
       
   701         g := props at:#group ifAbsent:[nil].
       
   702         g notNil ifTrue:[
       
   703             code := code , (self generateInitCodeForGroup:g)
       
   704         ]
       
   705     ].
       
   706     ^ code
       
   707 
       
   708 
       
   709 !
   658 !
   710 
   659 
   711 generateInitCodeForView:aView
   660 generateInitCodeForView:aView
   712     |code c name p outlets moreCode sym typ val|
   661     |code c name p outlets moreCode sym typ val|
   713 
   662 
   793     code := defCode withCRs.
   742     code := defCode withCRs.
   794 
   743 
   795     self subviewsOf:self do:[:v |
   744     self subviewsOf:self do:[:v |
   796         code := code , (self generateInitCodeForView:v)
   745         code := code , (self generateInitCodeForView:v)
   797     ].
   746     ].
   798 
       
   799     code := code , (self generateInitCodeForOtherStuff).
       
   800 
       
   801     code := code , '    ^ self\' withCRs.
   747     code := code , '    ^ self\' withCRs.
   802 
   748 
   803     defCode := Character excla asString , '\\'.
   749     defCode := Character excla asString , '\\'.
   804     defCode := defCode , 'setupLocalStuff\'.
   750     defCode := defCode , 'setupLocalStuff\'.
   805     defCode := defCode , '    ^ self\'.
   751     defCode := defCode , '    ^ self\'.
   810     ^ code.
   756     ^ code.
   811 
   757 
   812 
   758 
   813 
   759 
   814 
   760 
   815 !
       
   816 
       
   817 generateOutlets
       
   818     ^ self
       
   819 !
   761 !
   820 
   762 
   821 generateWindowSpecMethodSource
   763 generateWindowSpecMethodSource
   822     |t s spec specArray str code|
   764     |t s spec specArray str code|
   823 
   765 
   865     ^ code withCRs
   807     ^ code withCRs
   866 
   808 
   867     "Modified: 5.9.1995 / 21:01:35 / claus"
   809     "Modified: 5.9.1995 / 21:01:35 / claus"
   868 !
   810 !
   869 
   811 
   870 nameOfClass
       
   871     ^ 'NewView'
       
   872 !
       
   873 
       
   874 outletValueOf:aSymbol for:aView
       
   875 "/    |c name p outlets moreCode sym typ val|
       
   876 "/
       
   877 "/    p := self propertyOfView:aView.
       
   878 "/    outlets := p at:#outlets ifAbsent:[^ nil].
       
   879 "/    outlets notNil ifTrue:[
       
   880 "/        outlets do:[:selectorOutlet |
       
   881 "/            sym := selectorOutlet at:#selector.
       
   882 "/            (sym == aSymbol) ifTrue:[
       
   883 "/                typ := selectorOutlet at:#type.
       
   884 "/                val := selectorOutlet at:#value.
       
   885 "/                ^ val
       
   886 "/            ]
       
   887 "/        ]
       
   888 "/    ].
       
   889     ^ nil
       
   890 
       
   891 
       
   892 
       
   893 
       
   894 !
       
   895 
       
   896 storeContentsOn:aStream
   812 storeContentsOn:aStream
   897     listHolder propertiesDo:[:p| p storeOn:aStream]
   813     listHolder propertiesDo:[:p| p storeOn:aStream]
   898 !
   814 !
   899 
   815 
   900 subviewsOf:aView do:aBlock
   816 subviewsOf:aView do:aBlock
   912         ]
   828         ]
   913     ]
   829     ]
   914 
   830 
   915 ! !
   831 ! !
   916 
   832 
   917 !UIPainterView methodsFor:'group manipulations'!
       
   918 
       
   919 groupEnterFields
       
   920     |props group objects|
       
   921 
       
   922     self hasSelection ifFalse:[
       
   923         ^ self
       
   924     ].
       
   925     self selectionDo:[:aView |
       
   926         (aView isKindOf:EditField) ifFalse:[
       
   927             self warn:'select EditFields only !!'.
       
   928             ^ self
       
   929         ]
       
   930     ].
       
   931     self withSelectionHiddenDo:[
       
   932         group := EnterFieldGroup new.
       
   933         props := GroupProperties new.
       
   934         name  := self uniqueNameFor:(EnterFieldGroup className).
       
   935         props group:group.
       
   936         props name:name.
       
   937         group groupID:name asSymbol.
       
   938         objects := OrderedCollection new.
       
   939         props controlledObjects:objects.
       
   940         listHolder add:props.
       
   941 
       
   942         self selectionDo:[:aView |
       
   943             objects add:aView.
       
   944             group add:aView
       
   945         ].
       
   946     ]
       
   947 
       
   948 
       
   949 !
       
   950 
       
   951 groupRadioButtons
       
   952     |props name group objects|
       
   953 
       
   954     self hasSelection ifFalse:[
       
   955         ^ self
       
   956     ].
       
   957     self selectionDo:[:aView |
       
   958         (aView isKindOf:RadioButton) ifFalse:[
       
   959             self warn:'select RadioButtons only !!'.
       
   960             ^ self
       
   961         ]
       
   962     ].
       
   963     self withSelectionHiddenDo:[
       
   964         group := RadioButtonGroup new.
       
   965         props := GroupProperties new.
       
   966         name  := self uniqueNameFor:(RadioButtonGroup className).
       
   967         props group:group.
       
   968         props name:name.
       
   969         group groupID:name asSymbol.
       
   970         objects := OrderedCollection new.
       
   971         props controlledObjects:objects.
       
   972         listHolder add:props.
       
   973 
       
   974         self selectionDo:[:aView |
       
   975             aView turnOff.
       
   976             objects add:aView.
       
   977             group add:aView
       
   978         ].
       
   979     ]
       
   980 
       
   981     "Modified: 5.9.1995 / 16:06:15 / claus"
       
   982 ! !
       
   983 
       
   984 !UIPainterView methodsFor:'initialization'!
   833 !UIPainterView methodsFor:'initialization'!
   985 
   834 
   986 destroy
   835 destroy
   987     "remove dependencies
   836     "remove dependencies
   988     "
   837     "
  1069 
   918 
  1070 
   919 
  1071 
   920 
  1072 ! !
   921 ! !
  1073 
   922 
  1074 !UIPainterView methodsFor:'misc'!
       
  1075 
       
  1076 changeFont:aFontDescription
       
  1077     |f|
       
  1078 
       
  1079     f := aFontDescription onDevice:device.
       
  1080 "/    f := Font family:family
       
  1081 "/                face:face
       
  1082 "/               style:style
       
  1083 "/                size:size.
       
  1084 
       
  1085     f notNil ifTrue:[
       
  1086         self withSelectionHiddenDo:[
       
  1087             self selectionDo:[:aView |
       
  1088                 aView font:f.
       
  1089                 self elementChangedSize:aView.
       
  1090             ]
       
  1091         ].
       
  1092     ]
       
  1093 
       
  1094     "Modified: 5.9.1995 / 12:13:27 / claus"
       
  1095     "Created: 10.4.1997 / 09:56:16 / cg"
       
  1096 !
       
  1097 
       
  1098 changeFontFamily:family face:face style:style size:size
       
  1099     |f|
       
  1100 
       
  1101     f := Font family:family
       
  1102                 face:face
       
  1103                style:style
       
  1104                 size:size.
       
  1105 
       
  1106     f notNil ifTrue:[
       
  1107         self withSelectionHiddenDo:[
       
  1108             self selectionDo:[:aView |
       
  1109                 aView font:f.
       
  1110                 self elementChangedSize:aView.
       
  1111             ]
       
  1112         ]
       
  1113     ]
       
  1114 
       
  1115     "Modified: 5.9.1995 / 12:13:27 / claus"
       
  1116 ! !
       
  1117 
       
  1118 !UIPainterView methodsFor:'removing components'!
   923 !UIPainterView methodsFor:'removing components'!
  1119 
   924 
  1120 remove:anObject
   925 remove:anObject
  1121     "remove anObject from the contents do redraw
   926     "remove anObject from the contents do redraw
  1122     "
   927     "
  1179 
   984 
  1180     prop := self propertyOfIdentifier:aViewId.
   985     prop := self propertyOfIdentifier:aViewId.
  1181 
   986 
  1182     prop notNil ifTrue:[^ prop view]
   987     prop notNil ifTrue:[^ prop view]
  1183                ifFalse:[^ nil]
   988                ifFalse:[^ nil]
  1184 !
       
  1185 
       
  1186 propertyOfGroup:aGroup
       
  1187     "returns property assigned to group
       
  1188     "
       
  1189     ^ listHolder detectProperty:[:p| p group == aGroup ]
       
  1190 !
   989 !
  1191 
   990 
  1192 propertyOfIdentifier:anId
   991 propertyOfIdentifier:anId
  1193     "returns property assigned to unique identifier
   992     "returns property assigned to unique identifier
  1194     "
   993     "
  1663   ^ self basicNew initialize
  1462   ^ self basicNew initialize
  1664 ! !
  1463 ! !
  1665 
  1464 
  1666 !UIPainterView::ViewProperty methodsFor:'accessing'!
  1465 !UIPainterView::ViewProperty methodsFor:'accessing'!
  1667 
  1466 
  1668 group
       
  1669     ^ nil
       
  1670 !
       
  1671 
       
  1672 identifier
  1467 identifier
  1673     "return the unique identifier assigned to property
  1468     "return the unique identifier assigned to property
  1674     "
  1469     "
  1675     ^ identifier
  1470     ^ identifier
  1676 !
  1471 !
  1747     ^ spec name
  1542     ^ spec name
  1748 !
  1543 !
  1749 
  1544 
  1750 name:aName
  1545 name:aName
  1751     spec name:aName
  1546     spec name:aName
  1752 ! !
       
  1753 
       
  1754 !UIPainterView::GroupProperties methodsFor:'accessing'!
       
  1755 
       
  1756 controlledObjects
       
  1757     "return the value of the instance variable 'controlledObjects' (automatically generated)"
       
  1758 
       
  1759     ^ controlledObjects!
       
  1760 
       
  1761 controlledObjects:something
       
  1762     "set the value of the instance variable 'controlledObjects' (automatically generated)"
       
  1763 
       
  1764     controlledObjects := something.!
       
  1765 
       
  1766 group
       
  1767     "return the value of the instance variable 'group'
       
  1768     "
       
  1769     ^ group
       
  1770 !
       
  1771 
       
  1772 group:something
       
  1773     "set the value of the instance variable 'group'
       
  1774     "
       
  1775     group := something.
       
  1776 !
       
  1777 
       
  1778 name
       
  1779     "return the value of the group name
       
  1780     "
       
  1781     ^ name
       
  1782 !
       
  1783 
       
  1784 name:aName
       
  1785     "set the value of the group name
       
  1786     "
       
  1787     name := aName
       
  1788 ! !
  1547 ! !
  1789 
  1548 
  1790 !UIPainterView::ListHolder class methodsFor:'instance creation'!
  1549 !UIPainterView::ListHolder class methodsFor:'instance creation'!
  1791 
  1550 
  1792 for:aPainter
  1551 for:aPainter