UIPainter.st
changeset 55 19e021c8f1ef
parent 54 d0b5a33e6df0
child 58 668eb9eae2ac
equal deleted inserted replaced
54:d0b5a33e6df0 55:19e021c8f1ef
    12 
    12 
    13 ApplicationModel subclass:#UIPainter
    13 ApplicationModel subclass:#UIPainter
    14 	instanceVariableNames:'menu nameField elementMenu workView treeView outletView stringBox
    14 	instanceVariableNames:'menu nameField elementMenu workView treeView outletView stringBox
    15 		actionBox listBox fileBox currentFileName topView propertyFrame
    15 		actionBox listBox fileBox currentFileName topView propertyFrame
    16 		whichProperty changeSelectorHolder changeChannel
    16 		whichProperty changeSelectorHolder changeChannel
    17 		aspectSelectorHolder aspectChannel nameChannel fgChannel
    17 		aspectSelectorHolder aspectChannel nameChannel applyAction
    18 		bgChannel applyAction leftFractionHolder leftOffsetHolder
    18 		leftFractionHolder leftOffsetHolder rightFractionHolder
    19 		rightFractionHolder rightOffsetHolder topFractionHolder
    19 		rightOffsetHolder topFractionHolder topOffsetHolder
    20 		topOffsetHolder bottomFractionHolder bottomOffsetHolder specClass
    20 		bottomFractionHolder bottomOffsetHolder specClass specSelector
    21 		specSelector leftAlignmentFractionHolder
    21 		specSuperclass leftAlignmentFractionHolder
    22 		topAlignmentFractionHolder classNameHolder methodNameHolder
    22 		topAlignmentFractionHolder classNameHolder methodNameHolder
    23 		aspectHolders propertyShown specShown'
    23 		aspectHolders propertyShown specShown'
    24 	classVariableNames:''
    24 	classVariableNames:''
    25 	poolDictionaries:''
    25 	poolDictionaries:''
    26 	category:'Interface-UIPainter'
    26 	category:'Interface-UIPainter'
   185                                   #'collection:' 
   185                                   #'collection:' 
   186                                    #(
   186                                    #(
   187                                      #(#InputFieldSpec
   187                                      #(#InputFieldSpec
   188                                         #'layout:' #(#LayoutFrame 0 0 49 0 163 0 69 0)
   188                                         #'layout:' #(#LayoutFrame 0 0 49 0 163 0 69 0)
   189                                         #model: #foregroundChannel
   189                                         #model: #foregroundChannel
       
   190                                         #acceptOnLostFocus: true
       
   191                                         #tabable: true
       
   192 
   190                                     )
   193                                     )
   191                                      #(#InputFieldSpec
   194                                      #(#InputFieldSpec
   192                                         #'layout:' #(#LayoutFrame 0 0 119 0 163 0 142 0)
   195                                         #'layout:' #(#LayoutFrame 0 0 119 0 163 0 142 0)
   193                                         #model: #backgroundChannel
   196                                         #model: #backgroundChannel
       
   197                                         #acceptOnLostFocus: true
       
   198                                         #tabable: true
       
   199 
   194                                     )
   200                                     )
   195                                   )
   201                                   )
   196                               )
   202                               )
   197                               #'horizontalLayout:' #fit
   203                               #'horizontalLayout:' #fit
   198                               #'verticalLayout:' #spreadSpace
   204                               #'verticalLayout:' #spreadSpace
   200                            #(#ActionButtonSpec
   206                            #(#ActionButtonSpec
   201                               #'name:' 'button'
   207                               #'name:' 'button'
   202                               #'layout:' #(#LayoutFrame 102 0 246 0 153 0 272 0)
   208                               #'layout:' #(#LayoutFrame 102 0 246 0 153 0 272 0)
   203                               #'label:' 'apply'
   209                               #'label:' 'apply'
   204                               #'model:' #setColors
   210                               #'model:' #setColors
       
   211                               #tabable: true
       
   212 
   205                           )
   213                           )
   206                         )
   214                         )
   207                     )
   215                     )
   208                     #'labelPosition:' #topLeft
   216                     #'labelPosition:' #topLeft
   209                     #'showFrame:' false
   217                     #'showFrame:' false
   936                 )
   944                 )
   937                  #(#ActionButtonSpec
   945                  #(#ActionButtonSpec
   938                     #'name:' 'button1'
   946                     #'name:' 'button1'
   939                     #'layout:' #(#LayoutFrame 30 0 250 0 129 0 279 0)
   947                     #'layout:' #(#LayoutFrame 30 0 250 0 129 0 279 0)
   940                     #'label:' 'cancel'
   948                     #'label:' 'cancel'
   941                     #'model:' #cancelClicked
   949                     #'model:' #cancel
   942                 )
   950                 )
   943                  #(#ActionButtonSpec
   951                  #(#ActionButtonSpec
   944                     #'name:' 'button2'
   952                     #'name:' 'button2'
   945                     #'layout:' #(#LayoutFrame 160 0 250 0 259 0 279 0)
   953                     #'layout:' #(#LayoutFrame 160 0 250 0 259 0 279 0)
   946                     #'label:' 'ok'
   954                     #'label:' 'ok'
   947                     #'model:' #okClicked
   955                     #'model:' #accept
   948                 )
   956                 )
   949               )
   957               )
   950           )
   958           )
   951       )
   959       )
   952 
   960 
  1022         singleSelection isNil ifFalse:[
  1030         singleSelection isNil ifFalse:[
  1023             nameChannel isNil ifTrue:[self nameChannel].
  1031             nameChannel isNil ifTrue:[self nameChannel].
  1024             nameChannel value:singleSelection name.
  1032             nameChannel value:singleSelection name.
  1025 
  1033 
  1026             self fetchLayoutFrom:singleSelection.
  1034             self fetchLayoutFrom:singleSelection.
       
  1035             self fetchColorsFrom:singleSelection.
  1027             self fetchModelAspectsFrom:singleSelection.
  1036             self fetchModelAspectsFrom:singleSelection.
  1028         ].
  1037         ].
  1029         ^ self
  1038         ^ self
  1030     ].
  1039     ].
  1031 ! !
  1040 ! !
  1035 aspectFor:aKey
  1044 aspectFor:aKey
  1036     ^ aspectHolders at:aKey ifAbsent:[super aspectFor:aKey]
  1045     ^ aspectHolders at:aKey ifAbsent:[super aspectFor:aKey]
  1037 !
  1046 !
  1038 
  1047 
  1039 backgroundChannel
  1048 backgroundChannel
  1040     ^ bgChannel
  1049     ^ self aspectFor:#backgroundChannel
  1041 !
  1050 !
  1042 
  1051 
  1043 bottomFractionChannel
  1052 bottomFractionChannel
  1044     ^ bottomFractionHolder
  1053     ^ bottomFractionHolder
  1045 !
  1054 !
  1048     ^ bottomOffsetHolder
  1057     ^ bottomOffsetHolder
  1049 
  1058 
  1050 !
  1059 !
  1051 
  1060 
  1052 foregroundChannel
  1061 foregroundChannel
  1053     ^ fgChannel
  1062     ^ self aspectFor:#foregroundChannel
       
  1063 
  1054 !
  1064 !
  1055 
  1065 
  1056 leftAlignmentFractionChannel
  1066 leftAlignmentFractionChannel
  1057     ^ leftAlignmentFractionHolder
  1067     ^ leftAlignmentFractionHolder
  1058 
  1068 
  1150     "return a spec for the buttons in the panel;
  1160     "return a spec for the buttons in the panel;
  1151      entries consists of selector and bitmap-filename.
  1161      entries consists of selector and bitmap-filename.
  1152      nil selectors are taken as separators (see setupButtonPanel)"
  1162      nil selectors are taken as separators (see setupButtonPanel)"
  1153 
  1163 
  1154     ^ #(
  1164     ^ #(
  1155         #(alignSelectionLeft         true 'b_alignL.xbm'  nil false)
  1165         #( alignSelectionLeft         'b_alignL.xbm'    )
  1156         #(alignSelectionRight        true 'b_alignR.xbm'  nil false)
  1166         #( alignSelectionRight        'b_alignR.xbm'    )
  1157         #(alignSelectionLeftAndRight true 'b_alignLR.xbm' nil false)
  1167         #( alignSelectionLeftAndRight 'b_alignLR.xbm'   )
  1158         #(nil                        nil  nil nil)
  1168         #( nil )
  1159         #(alignSelectionTop          true 'b_alignT.xbm'  nil false)
  1169         #( alignSelectionTop          'b_alignT.xbm'    )
  1160         #(alignSelectionBottom       true 'b_alignB.xbm'  nil false)
  1170         #( alignSelectionBottom       'b_alignB.xbm'    )
  1161         #(alignSelectionTopAndBottom true 'b_alignTB.xbm' nil false)
  1171         #( alignSelectionTopAndBottom 'b_alignTB.xbm'   )
  1162         #(nil                        nil  nil nil)
  1172         #( nil )
  1163         #(alignSelectionCenterHor    true 'b_alignCH.xbm' nil false)
  1173         #( alignSelectionCenterHor    'b_alignCH.xbm'   )
  1164         #(alignSelectionCenterVer    true 'b_alignCV.xbm' nil false)
  1174         #( alignSelectionCenterVer    'b_alignCV.xbm'   )
  1165         #(nil                        nil  nil nil)
  1175         #( nil )
  1166         #(moveSelectionLeft          true 'b_moveLeft.xbm'  nil true)
  1176         #( moveSelectionLeft:         'b_moveLeft.xbm'  )
  1167         #(moveSelectionRight         true 'b_moveRight.xbm' nil true)
  1177         #( moveSelectionRight:        'b_moveRight.xbm' )
  1168         #(moveSelectionUp            true 'b_moveUp.xbm'    nil true)
  1178         #( moveSelectionUp:           'b_moveUp.xbm'    )
  1169         #(moveSelectionDown          true 'b_moveDown.xbm'  nil true)
  1179         #( moveSelectionDown:         'b_moveDown.xbm'  )
  1170         #(moveSelectionLeft10        true 'b_moveLeft2.xbm'  nil true)
  1180        )
  1171         #(moveSelectionRight10       true 'b_moveRight2.xbm' nil true)
       
  1172         #(moveSelectionUp10          true 'b_moveUp2.xbm'    nil true)
       
  1173         #(moveSelectionDown10        true 'b_moveDown2.xbm'  nil true)
       
  1174      )
       
  1175 
       
  1176     "Modified: 5.9.1995 / 22:20:36 / claus"
       
  1177 !
  1181 !
  1178 
  1182 
  1179 createCanvas 
  1183 createCanvas 
  1180     |topView|
  1184     |topView|
  1181 
  1185 
  1182     super initialize.
  1186     super initialize.
  1183 
  1187 
  1184     topView := StandardSystemView new.
  1188     topView := StandardSystemView new.
  1185     topView label:'unnamed'.
  1189     topView label:'unnamed'.
  1186     topView extent:300@300.
  1190     topView extent:300@300.
       
  1191     topView application:self.
  1187 
  1192 
  1188     workView := UIPainterView in:topView.
  1193     workView := UIPainterView in:topView.
  1189     workView layout:(0.0 @ 0.0 corner:1.0 @ 1.0) asLayout.
  1194     workView layout:(0.0 @ 0.0 corner:1.0 @ 1.0) asLayout.
  1190 
  1195 
  1191     ^ workView.
  1196     ^ workView.
  1217 initChannels
  1222 initChannels
  1218     aspectHolders := IdentityDictionary new.
  1223     aspectHolders := IdentityDictionary new.
  1219 
  1224 
  1220     aspectHolders at:#classNameChannel put:((specClass notNil ifTrue:[specClass name] ifFalse:['NewApplication']) asValue).
  1225     aspectHolders at:#classNameChannel put:((specClass notNil ifTrue:[specClass name] ifFalse:['NewApplication']) asValue).
  1221     aspectHolders at:#superclassNameChannel put:((specClass notNil ifTrue:[specClass superclass] ifFalse:[ApplicationModel]) name asValue).
  1226     aspectHolders at:#superclassNameChannel put:((specClass notNil ifTrue:[specClass superclass] ifFalse:[ApplicationModel]) name asValue).
  1222     aspectHolders at:#methodNameChannel put:(specSelector asValue).
  1227     aspectHolders at:#methodNameChannel put:((specSelector notNil ifTrue:[specSelector] ifFalse:[#windowSpec]) asValue).
  1223 
  1228 
  1224     aspectHolders at:#aspectChannel put:(ValueHolder new).
  1229     aspectHolders at:#aspectChannel put:(ValueHolder new).
  1225     aspectHolders at:#changeChannel put:(ValueHolder new).
  1230     aspectHolders at:#changeChannel put:(ValueHolder new).
  1226 
  1231 
  1227     aspectHolders at:#foregroundChannel put:(ValueHolder new).
  1232     aspectHolders at:#foregroundChannel put:(ValueHolder new).
  1248                                     'type'
  1253                                     'type'
  1249                                     'align'
  1254                                     'align'
  1250                                     'dimension'
  1255                                     'dimension'
  1251                                     'special'
  1256                                     'special'
  1252                                     'code'
  1257                                     'code'
  1253                                     'debug'
       
  1254                                     'test'
  1258                                     'test'
  1255                                  )).
  1259                                  )).
  1256 
  1260 
  1257     menu selectors:#(#file
  1261     menu selectors:#(#file
  1258                      #font
  1262                      #font
  1265                     ).
  1269                     ).
  1266 
  1270 
  1267     menu at:#file 
  1271     menu at:#file 
  1268             putLabels:(resources  array:
  1272             putLabels:(resources  array:
  1269                       #('new'
  1273                       #('new'
  1270                         'from class' 
  1274                         'from class ...' 
  1271                         'pick a view ' 
  1275                         'pick a view ' 
  1272                         '-'
  1276                         '-'
  1273                         'save' 
  1277                         'save' 
  1274                         'save as ...' 
  1278                         'save as ...' 
  1275                         '-'
  1279                         '-'
  1276                         'compile' 
  1280                         'install' 
  1277                         '-'
  1281                         '-'
  1278                         'source' 
  1282 "/                        'source' 
  1279                         'windowSpec' 
  1283                         'windowSpec' 
  1280                         'inspect me' 
  1284                         'inspect me' 
  1281                         '-'
  1285                         '-'
  1282                         'print'
  1286                         'print'
  1283                         '-'
  1287                         '-'
  1288                         doPickAView
  1292                         doPickAView
  1289                         nil
  1293                         nil
  1290                         doSave 
  1294                         doSave 
  1291                         doSaveAs 
  1295                         doSaveAs 
  1292                         nil 
  1296                         nil 
  1293                         doCompile 
  1297                         doInstall 
  1294                         nil 
  1298                         nil 
  1295                         doSource 
  1299 "/                        doSource 
  1296                         doWindowSpec 
  1300                         doWindowSpec 
  1297                         inspect
  1301                         inspect
  1298                         nil 
  1302                         nil 
  1299                         doPrint
  1303                         doPrint
  1300                         nil 
  1304                         nil 
  1507      via some selector"
  1511      via some selector"
  1508 
  1512 
  1509     |specArray|
  1513     |specArray|
  1510 
  1514 
  1511     specClass := aClass.
  1515     specClass := aClass.
       
  1516     specSuperclass := aClass superclass.
  1512     specSelector :=  aSelector.
  1517     specSelector :=  aSelector.
  1513 
  1518 
  1514     self openInterface.
  1519     self openInterface.
  1515     workView className:aClass name.
  1520     workView className:aClass name.
  1516     workView methodName:aSelector.
  1521     workView methodName:aSelector.
  1524 
  1529 
  1525     newBuilder := self new.
  1530     newBuilder := self new.
  1526 !
  1531 !
  1527 
  1532 
  1528 setupButtonPanelIn:aTopView below:aMenu
  1533 setupButtonPanelIn:aTopView below:aMenu
  1529     "create the buttonPanel"
  1534     "create the buttonPanel
  1530 
  1535     "
  1531     |spc mh buttonPanel|
  1536     |spc mh buttonPanel pressAction|
  1532 
  1537 
  1533     spc := View viewSpacing // 2.
  1538     spc := View viewSpacing // 2.
  1534     buttonPanel := HorizontalPanelView in:aTopView.
  1539     buttonPanel := HorizontalPanelView in:aTopView.
  1535     buttonPanel level:-1; borderWidth:0.
  1540     buttonPanel level:-1; borderWidth:0.
  1536     buttonPanel horizontalLayout:#leftSpace.
  1541     buttonPanel horizontalLayout:#leftSpace.
  1537 
  1542 
  1538     self buttonPanelSpec do:[:entry |
  1543     pressAction := [:aButton :aSelector|
  1539 	|sel toCanvas imgFile label b sep autoRepeat|
  1544         |menu org top|
  1540 
  1545 
  1541 	sel := entry at:1.
  1546         workView selection notNil ifTrue:[
  1542 	sel isNil ifTrue:[
  1547             top := aButton topView.
  1543 	    sep := View in:buttonPanel.
  1548 
  1544 	    sep extent:20@1; borderWidth:0.
  1549             org := top origin + (aButton originRelativeTo:top) 
  1545 	] ifFalse:[
  1550                               + (0@((spc + aButton extent y))).
  1546 	    toCanvas := entry at:2.
  1551 
  1547 	    imgFile := entry at:3.
  1552             menu := PopUpMenu labels:#( '1' '2' '4' '10' '..' )
  1548 	    label := entry at:4.
  1553                                 args:#(  1   2   4   10   nil ).
  1549 	    autoRepeat := entry at:5.
  1554 
  1550 	    b := Button in:buttonPanel.
  1555             menu action:[:anArg||no|
  1551 	    autoRepeat ifTrue:[
  1556                 (no := anArg) isNil ifTrue:[
  1552 		b autoRepeat:autoRepeat.
  1557                     no := EnterBox request:'number'.
  1553 		b controller beTriggerOnDown.
  1558                     no := SmallInteger readFrom:no onError:0.
  1554 	    ].
  1559                 ].
  1555 	    imgFile notNil ifTrue:[
  1560                 no ~~ 0 ifTrue:[
  1556 		b logo:(Image fromFile:imgFile).
  1561                     workView perform:aSelector with:no
  1557 	    ] ifFalse:[
  1562                 ]
  1558 		b logo:label
  1563             ].
  1559 	    ].
  1564             menu showAt:org.
  1560 	    toCanvas ifTrue:[
  1565         ].
  1561 		b model:workView 
  1566         aButton turnOff
  1562 	    ] ifFalse:[
  1567     ].
  1563 		b model:self
  1568 
  1564 	    ].
  1569     self buttonPanelSpec do:[:anArray| |selector image button|
  1565 	    b changeMessage:sel
  1570         selector := anArray at:1.
  1566 	]
  1571 
       
  1572         selector notNil ifTrue:[
       
  1573             image  := Image fromFile:( anArray at:2 ).
       
  1574             button := Button label:image in:buttonPanel.
       
  1575 
       
  1576             selector last == $: ifFalse:[
       
  1577                 button action:[ workView perform:selector ]
       
  1578             ] ifTrue:[
       
  1579                 button pressAction:[ pressAction value:button value:selector ] 
       
  1580             ]
       
  1581         ] ifFalse:[|sep|
       
  1582             sep := View in:buttonPanel.
       
  1583             sep extent:20@1; borderWidth:0.
       
  1584         ]
  1567     ].
  1585     ].
  1568 
  1586 
  1569     mh := aMenu height.
  1587     mh := aMenu height.
  1570     buttonPanel origin:0.0 @ (mh + spc)
  1588     buttonPanel origin:0.0 @ (mh + spc)
  1571 		corner:(1.0 @ (mh + spc + buttonPanel preferredExtent y)).
  1589                 corner:(1.0 @ (mh + spc + buttonPanel preferredExtent y)).
  1572 
  1590 
  1573     buttonPanel leftInset:spc; rightInset:spc.
  1591     buttonPanel leftInset:spc; rightInset:spc.
  1574     ^ buttonPanel
  1592   ^ buttonPanel
  1575 
       
  1576     "Modified: 5.9.1995 / 22:23:13 / claus"
       
  1577 ! !
  1593 ! !
  1578 
  1594 
  1579 !UIPainter methodsFor:'misc'!
  1595 !UIPainter methodsFor:'misc'!
  1580 
  1596 
  1581 listOfOutletsFor:aViewClass
  1597 listOfOutletsFor:aViewClass
  1781 
  1797 
  1782     "Modified: 5.9.1995 / 21:51:57 / claus"
  1798     "Modified: 5.9.1995 / 21:51:57 / claus"
  1783 ! !
  1799 ! !
  1784 
  1800 
  1785 !UIPainter methodsFor:'private - fetch'!
  1801 !UIPainter methodsFor:'private - fetch'!
       
  1802 
       
  1803 fetchColorsFrom:aView
       
  1804     |holder|
       
  1805 
       
  1806     holder := self aspectFor:#foregroundChannel.
       
  1807     (aView respondsTo:#foregroundColor) ifTrue:[
       
  1808         holder value:(aView foregroundColor storeString).
       
  1809     ] ifFalse:[
       
  1810         holder value:nil
       
  1811     ].
       
  1812     holder := self aspectFor:#backgroundChannel.
       
  1813     (aView respondsTo:#backgroundColor) ifTrue:[
       
  1814         holder value:(aView backgroundColor storeString).
       
  1815     ] ifFalse:[
       
  1816         holder value:nil
       
  1817     ].
       
  1818 
       
  1819 !
  1786 
  1820 
  1787 fetchLayoutFrom:aView
  1821 fetchLayoutFrom:aView
  1788     |layout extent|
  1822     |layout extent|
  1789 
  1823 
  1790     layout := aView geometryLayout.
  1824     layout := aView geometryLayout.
  2030 closeRequest
  2064 closeRequest
  2031     workView  notNil ifTrue:[workView  release. workView := nil].
  2065     workView  notNil ifTrue:[workView  release. workView := nil].
  2032     super closeRequest
  2066     super closeRequest
  2033 !
  2067 !
  2034 
  2068 
  2035 doCompile
  2069 closeRequestFor:aTopView
  2036    |code|
  2070     aTopView ~~ topView ifTrue:[
  2037 
  2071         topView device beep.
  2038    code := workView generateCode.
  2072         ^ self
  2039    (ReadStream on:code) fileIn.
  2073     ].
  2040 
  2074     super closeRequestFor:aTopView
  2041     "Modified: 4.9.1995 / 17:06:10 / claus"
  2075 !
  2042 !
  2076 
       
  2077 propertySelectionChanged
       
  2078     workView singleSelectionDo:[:selectedView |
       
  2079         propertyShown   := whichProperty selection.
       
  2080         self showPropertyView
       
  2081     ]
       
  2082 !
       
  2083 
       
  2084 selectOutlet:nr
       
  2085     |outlet type sel text box action initialText initialList
       
  2086      view prop t val|
       
  2087 
       
  2088     outlet := outletView selectionValue.
       
  2089     outletView deselect.
       
  2090     view := workView selection.
       
  2091     view isNil ifTrue:[
       
  2092         self notify:'select something first'.
       
  2093         ^ self
       
  2094     ].
       
  2095     action := [:s | self setOutlet:sel type:type to:s in:view].
       
  2096     (outlet = 'label') ifTrue:[
       
  2097         type := #string.
       
  2098         sel := #label:.
       
  2099         text := 'label-text:'.
       
  2100         initialText := view label
       
  2101     ].
       
  2102     (outlet = 'fixed size') ifTrue:[
       
  2103         type := #boolean.
       
  2104         sel := #sizeFixed:.
       
  2105         text := 'size is fix:'.
       
  2106     ].
       
  2107     (outlet = 'frame shown') ifTrue:[
       
  2108         type := #boolean.
       
  2109         sel := #showFrame:.
       
  2110         text := 'frame is to be drawn:'.
       
  2111     ].
       
  2112     (outlet = 'labels') ifTrue:[
       
  2113         type := #strings.
       
  2114         sel := #labels:.
       
  2115         initialText := view labels
       
  2116     ].
       
  2117     (outlet = 'contents') ifTrue:[
       
  2118         type := #text.
       
  2119         sel := #contents:.
       
  2120         initialText := view contents
       
  2121     ].
       
  2122     (outlet = 'initialText') ifTrue:[
       
  2123         type := #string.
       
  2124         sel := #initialText:.
       
  2125         initialText := view contents
       
  2126     ].
       
  2127     (outlet = 'field type') ifTrue:[
       
  2128         type := #fieldTypeSymbol.
       
  2129         sel := #type:.
       
  2130         initialList := #(number    
       
  2131                          string
       
  2132                          password
       
  2133                         ).
       
  2134         initialText := view converter isNil ifTrue:[#string] ifFalse:[view converter type].
       
  2135     ].
       
  2136     (outlet = 'field length') ifTrue:[
       
  2137         type := #numberOrNil.
       
  2138         sel := #maxChars:.
       
  2139         text := 'field length (empty -> unlimited)'.
       
  2140         initialText := view maxChars isNil ifTrue:[''] ifFalse:[view maxChars printString].
       
  2141     ].
       
  2142     (outlet = 'level') ifTrue:[
       
  2143         type := #number.
       
  2144         sel := #level:.
       
  2145         initialText := view level printString
       
  2146     ].
       
  2147     (outlet = 'active level') ifTrue:[
       
  2148         type := #number.
       
  2149         sel := #onLevel:.
       
  2150         initialText := view onLevel printString
       
  2151     ].
       
  2152     (outlet = 'passive level') ifTrue:[
       
  2153         type := #number.
       
  2154         sel := #offLevel:.
       
  2155         initialText := view offLevel printString
       
  2156     ].
       
  2157     (outlet = 'iconic-label') ifTrue:[
       
  2158         type := #form.
       
  2159         sel := #label:.
       
  2160         text := 'label-icon:'
       
  2161     ].
       
  2162     (outlet = 'view background-color') ifTrue:[
       
  2163         type := #color.
       
  2164         sel := #viewBackground:.
       
  2165         text := 'view background color'.
       
  2166         initialText := 'Black'
       
  2167     ].
       
  2168     (outlet = 'foreground-color') ifTrue:[
       
  2169         type := #color.
       
  2170         sel := #foregroundColor:.
       
  2171         text := 'foreground color'.
       
  2172         initialText := 'Black'
       
  2173     ].
       
  2174     (outlet = 'background-color') ifTrue:[
       
  2175         type := #color.
       
  2176         sel := #backgroundColor:.
       
  2177         text := 'background color'.
       
  2178         initialText := 'Grey'
       
  2179     ].
       
  2180     (outlet = 'active foreground-color') ifTrue:[
       
  2181         type := #color.
       
  2182         sel := #activeForegroundColor:.
       
  2183         text := 'active foreground color'.
       
  2184         initialText := 'Yellow'
       
  2185     ].
       
  2186     (outlet = 'active background-color') ifTrue:[
       
  2187         type := #color.
       
  2188         sel := #activeBackgroundColor:.
       
  2189         text := 'active background color'.
       
  2190         initialText := 'Grey'
       
  2191     ].
       
  2192     (outlet = 'scroll action') ifTrue:[
       
  2193         type := #block.
       
  2194         sel := #scrollAction:.
       
  2195         text := 'action block when scrolled'
       
  2196     ].
       
  2197     (outlet = 'scrollUp action') ifTrue:[
       
  2198         type := #block.
       
  2199         sel := #scrollUpAction:.
       
  2200         text := 'action block when scrolled up'
       
  2201     ].
       
  2202     (outlet = 'scrollDown action') ifTrue:[
       
  2203         type := #block.
       
  2204         sel := #scrollDownAction:.
       
  2205         text := 'action block when scrolled down'
       
  2206     ].
       
  2207     (outlet = 'scrollLeft action') ifTrue:[
       
  2208         type := #block.
       
  2209         sel := #scrollLeftAction:.
       
  2210         text := 'action block when scrolled left'
       
  2211     ].
       
  2212     (outlet = 'scrollRight action') ifTrue:[
       
  2213         type := #block.
       
  2214         sel := #scrollRightAction:.
       
  2215         text := 'action block when scrolled right'
       
  2216     ].
       
  2217     (outlet = 'press action') ifTrue:[
       
  2218         type := #block.
       
  2219         sel := #pressAction:.
       
  2220         text := 'action block when pressed'
       
  2221     ].
       
  2222     (outlet = 'release action') ifTrue:[
       
  2223         type := #block.
       
  2224         sel := #releaseAction:.
       
  2225         text := 'action block when released'
       
  2226     ].
       
  2227     (outlet = 'style') ifTrue:[
       
  2228         type := #symbol.
       
  2229         sel := #style:.
       
  2230         initialList := #(motif next)
       
  2231     ].
       
  2232     (outlet = 'handle position') ifTrue:[
       
  2233         type := #symbol.
       
  2234         sel := #handlePosition:.
       
  2235         initialList := #(left center right)
       
  2236     ].
       
  2237     (outlet = 'horizontal layout') ifTrue:[
       
  2238         type := #symbol.
       
  2239         sel := #horizontalLayout:.
       
  2240         text := 'horizontal components layout'.
       
  2241         initialList := #(left
       
  2242                          leftSpace
       
  2243                          leftMax
       
  2244                          leftSpaceMax
       
  2245                          center 
       
  2246                          centerMax 
       
  2247                          right 
       
  2248                          rightSpace 
       
  2249                          rightMax 
       
  2250                          rightSpaceMax 
       
  2251                          spread 
       
  2252                          spreadSpace 
       
  2253                          spreadMax 
       
  2254                          spreadSpaceMax 
       
  2255                          fit
       
  2256                          fitSpace).
       
  2257         initialText := view horizontalLayout printString
       
  2258     ].
       
  2259     (outlet = 'vertical layout') ifTrue:[
       
  2260         type := #symbol.
       
  2261         sel := #verticalLayout:.
       
  2262         text := 'vertical components layout'.
       
  2263         initialList := #(top    
       
  2264                          topSpace
       
  2265                          center 
       
  2266                          bottom 
       
  2267                          bottomSpace 
       
  2268                          spread 
       
  2269                          spreadSpace 
       
  2270                          fit
       
  2271                          fitSpace).
       
  2272         initialText := view verticalLayout printString
       
  2273     ].
       
  2274     (outlet = 'label position') ifTrue:[
       
  2275         type := #symbol.
       
  2276         sel := #labelPosition:.
       
  2277         initialList := #(topLeft topCenter topRight bottomLeft bottomCenter bottomRight).
       
  2278         initialText := view labelPosition printString
       
  2279     ].
       
  2280     (outlet = 'label layout') ifTrue:[
       
  2281         type := #symbol.
       
  2282         sel := #adjust:.
       
  2283         initialList := #( left right center centerLeft centerRight fit ).
       
  2284         initialText := view adjust printString
       
  2285     ].
       
  2286     (outlet = 'orientation') ifTrue:[
       
  2287         type := #symbol.
       
  2288         sel := #orientation:.
       
  2289         initialList := #( horizontal vertical ).
       
  2290         initialText := view orientation printString
       
  2291     ].
       
  2292 
       
  2293     (type == #color) ifTrue:[
       
  2294         initialList := #('Black'
       
  2295                          'White'
       
  2296                          'LightGrey'
       
  2297                          'Grey'
       
  2298                          'DarkGrey'
       
  2299                          'Yellow'
       
  2300                          'Red'
       
  2301                          'Green'
       
  2302                          'Blue'
       
  2303                         )
       
  2304     ].
       
  2305 
       
  2306     text isNil ifTrue:[
       
  2307         text := outlet
       
  2308     ].
       
  2309 
       
  2310     "what type of box do we need"
       
  2311 
       
  2312     t := type.
       
  2313     ((type == #color) or:[type == #symbol or:[type == #fieldTypeSymbol]]) ifTrue:[
       
  2314         t := #list
       
  2315     ].
       
  2316     ((type == #number) or:[type == #numberOrNil]) ifTrue:[
       
  2317         t := #string
       
  2318     ].
       
  2319     (type == #strings) ifTrue:[
       
  2320         t := #text
       
  2321     ].
       
  2322     (type == #block) ifTrue:[
       
  2323         t := #text.
       
  2324         initialText := workView outletValueOf:sel for:view.
       
  2325         initialText isNil ifTrue:[initialText := '[statements]']
       
  2326     ].
       
  2327     (type == #block1) ifTrue:[
       
  2328         t := #text.
       
  2329         type := #block.
       
  2330         initialText := workView outletValueOf:sel for:view.
       
  2331         initialText isNil ifTrue:[initialText := '[:argument | statements ]']
       
  2332     ].
       
  2333     (type == #block2) ifTrue:[
       
  2334         t := #text.
       
  2335         type := #block.
       
  2336         initialText := workView outletValueOf:sel for:view.
       
  2337         initialText isNil ifTrue:[initialText := '[:arg1 :arg2 | statements ]']
       
  2338     ].
       
  2339 
       
  2340     "show a box to enter thing"
       
  2341 
       
  2342     (t == #boolean) ifTrue:[
       
  2343         val := Dialog confirmWithCancel:text.
       
  2344         (val == true or:[val == false]) ifTrue:[
       
  2345             action value:val
       
  2346         ].
       
  2347         ^ self
       
  2348     ].
       
  2349     (t == #string) ifTrue:[
       
  2350 "/        stringBox isNil ifTrue:[
       
  2351             stringBox := EnterBox new.
       
  2352 "/        ].
       
  2353         box := stringBox
       
  2354     ].
       
  2355     (t == #list) ifTrue:[
       
  2356 "/        listBox isNil ifTrue:[
       
  2357             listBox := ListSelectionBox new.
       
  2358 "/        ].
       
  2359         listBox list:initialList.
       
  2360         box := listBox
       
  2361     ].
       
  2362     (t == #text) ifTrue:[
       
  2363 "/        actionBox isNil ifTrue:[
       
  2364             actionBox := TextBox new.
       
  2365 "/        ].
       
  2366         actionBox initialText:initialText.
       
  2367         box := actionBox
       
  2368     ].
       
  2369 "
       
  2370 Transcript show:'outlet: '. Transcript showCR:outlet.
       
  2371 Transcript show:'type:   '. Transcript showCR:type.
       
  2372 Transcript show:'sel:    '. Transcript showCR:sel.
       
  2373 Transcript show:'text:   '. Transcript showCR:text.
       
  2374 "
       
  2375 
       
  2376     box isNil ifTrue:[
       
  2377         self notify:'not yet implemented'
       
  2378     ] ifFalse:[
       
  2379         box initialText:initialText.
       
  2380         box title:text.
       
  2381         box action:action.
       
  2382         box showAtPointer
       
  2383     ]
       
  2384 
       
  2385     "Modified: 6.9.1995 / 13:46:29 / claus"
       
  2386 !
       
  2387 
       
  2388 setColors
       
  2389     |fg bg|
       
  2390 
       
  2391     fg := self foregroundChannel value.
       
  2392     (fg notNil and:[fg notEmpty]) ifTrue:[
       
  2393         fg := Color readFrom:fg.
       
  2394         workView singleSelectionDo:[:selectedView |
       
  2395             selectedView foregroundColor:fg
       
  2396         ].
       
  2397     ].
       
  2398     bg := self backgroundChannel value.
       
  2399     (bg notNil and:[bg notEmpty]) ifTrue:[
       
  2400         bg := Color readFrom:bg.
       
  2401         workView singleSelectionDo:[:selectedView |
       
  2402             selectedView backgroundColor:bg
       
  2403         ].
       
  2404     ].
       
  2405 !
       
  2406 
       
  2407 setMiscAspects
       
  2408     "sent when apply is pressen in the misc-sub view"
       
  2409 
       
  2410     workView singleSelectionDo:[:selectedView |
       
  2411         selectedView ~~ workView ifTrue:[
       
  2412             workView changeVariableNameOf:selectedView to:nameChannel value
       
  2413         ]
       
  2414     ].
       
  2415 !
       
  2416 
       
  2417 setModelAspects
       
  2418     "sent when apply is pressen in the model-sub view"
       
  2419 
       
  2420     |aspectSymbol|
       
  2421 
       
  2422     aspectSymbol := (self aspectFor:#aspectChannel) value.
       
  2423     (aspectSymbol notNil and:[aspectSymbol notEmpty]) ifTrue:[
       
  2424         aspectSymbol := aspectSymbol asSymbol.
       
  2425         workView singleSelectionDo:[:selectedView |
       
  2426             selectedView ~~ workView ifTrue:[
       
  2427                 workView setAspectSelector:aspectSymbol forView:selectedView
       
  2428             ].
       
  2429         ].
       
  2430     ].
       
  2431 !
       
  2432 
       
  2433 setOutlet:outletSymbol type:type to:outletValue in:aView
       
  2434     |block val messageSymbol|
       
  2435 
       
  2436     messageSymbol := outletSymbol.
       
  2437     val := outletValue.
       
  2438     (type == #block) ifTrue:[
       
  2439 	block := Compiler evaluate:val.
       
  2440 	(block == #Error) ifTrue:[
       
  2441 	    self warn:'action will not work in test-mode'.
       
  2442 	    workView addOutletDefinitionFor:outletSymbol
       
  2443 				       type:type
       
  2444 				      value:outletValue
       
  2445 					for:aView.
       
  2446 	    ^ self
       
  2447 	].
       
  2448 	val := block
       
  2449     ].
       
  2450     (type == #number) ifTrue:[
       
  2451 	val := Number readFromString:outletValue onError:0 
       
  2452     ].
       
  2453     (type == #numberOrNil) ifTrue:[
       
  2454 	val := Number readFromString:outletValue onError:nil
       
  2455     ].
       
  2456     (type == #text) ifTrue:[
       
  2457 	val := outletValue asString
       
  2458     ].
       
  2459     (type == #strings) ifTrue:[
       
  2460 	val := outletValue asText
       
  2461     ].
       
  2462     (type == #symbol) ifTrue:[
       
  2463 	val := outletValue asSymbol.
       
  2464     ].
       
  2465     (type == #fieldTypeSymbol) ifTrue:[
       
  2466 	val := outletValue asSymbol.
       
  2467 	val == #password ifTrue:[
       
  2468 	    aView passwordCharacter:$*
       
  2469 	] ifFalse:[
       
  2470 	    aView passwordCharacter:nil
       
  2471 	].
       
  2472 	val := (PrintConverter new initFor:val).
       
  2473 	messageSymbol := #converter:
       
  2474     ].
       
  2475     (type == #color) ifTrue:[
       
  2476 	val := Color name:outletValue.
       
  2477 	val isNil ifTrue:[
       
  2478 	    self warn:('no such color:' , outletValue).
       
  2479 	    ^ self
       
  2480 	]
       
  2481     ].
       
  2482 Transcript show:(val printString).
       
  2483 Transcript showCR:('(' , val class printString , ')').
       
  2484 
       
  2485     workView selectionHiddenDo:[
       
  2486 	aView perform:messageSymbol with:val.
       
  2487 	workView elementChanged:aView.
       
  2488 	aView redraw.
       
  2489     ].
       
  2490     workView addOutletDefinitionFor:outletSymbol
       
  2491 			       type:type
       
  2492 			      value:outletValue
       
  2493 				for:aView
       
  2494 
       
  2495     "Modified: 6.9.1995 / 13:44:46 / claus"
       
  2496 !
       
  2497 
       
  2498 showPropertyView
       
  2499     |v l spec|
       
  2500 
       
  2501     workView singleSelectionDo:[:selectedView |
       
  2502         propertyShown = 'dimension' ifTrue:[
       
  2503             (l := selectedView geometryLayout) notNil ifTrue:[
       
  2504                 l isLayout ifTrue:[
       
  2505                     l isAlignmentOrigin ifTrue:[
       
  2506                         spec := self class geometrySpecForAlignmentOrigin
       
  2507                     ] ifFalse:[
       
  2508                         l isLayoutFrame ifFalse:[
       
  2509                             spec := self class geometrySpecForLayoutOrigin
       
  2510                         ]
       
  2511                     ]
       
  2512                 ]
       
  2513             ].
       
  2514             spec isNil ifTrue:[
       
  2515                 spec := self class geometrySpecForLayoutFrame
       
  2516             ].
       
  2517             ^ self setupPropertyFromSpec:spec
       
  2518         ].
       
  2519 
       
  2520         propertyShown = 'colors' ifTrue:[
       
  2521             ^ self setupPropertyFromSpec:(self class colorSpec)
       
  2522         ].
       
  2523 
       
  2524         propertyShown = 'model' ifTrue:[
       
  2525             ^ self setupPropertyFromSpec:(self class modelSpec)
       
  2526         ].
       
  2527 
       
  2528         propertyShown = 'misc' ifTrue:[
       
  2529             ^ self setupPropertyFromSpec:(self class miscSpec)
       
  2530         ].
       
  2531 
       
  2532         propertyShown = 'attribute list' ifTrue:[
       
  2533             specShown ~~ #attributeList ifTrue:[
       
  2534                 propertyFrame destroySubViews.
       
  2535                 v := ScrollableView for:SelectionInListView in:propertyFrame.
       
  2536                 v origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
       
  2537                 outletView := v scrolledView.
       
  2538                 outletView action:[:lineNr | lineNr notNil ifTrue:[self selectOutlet:lineNr]].
       
  2539                 propertyFrame realizeAllSubViews.
       
  2540                 specShown := #attributeList.
       
  2541             ].
       
  2542             self showOutletsFor:(workView selection).
       
  2543             ^ self
       
  2544         ].
       
  2545     ].
       
  2546 
       
  2547     propertyFrame destroySubViews.
       
  2548     outletView := nil.
       
  2549     specShown := nil.
       
  2550 
       
  2551 ! !
       
  2552 
       
  2553 !UIPainter methodsFor:'user interaction - dialogs'!
       
  2554 
       
  2555 checkClassAndSelector
       
  2556     "check for class & superclass"
       
  2557 
       
  2558     |superclass cls|
       
  2559 
       
  2560     (cls := Smalltalk at:specClass asSymbol) isNil ifTrue:[
       
  2561         (superclass := Smalltalk at:specSuperclass asSymbol) isNil ifTrue:[
       
  2562             self warn:'no class named ' , specSuperclass , ' exists.'.
       
  2563             ^ false.
       
  2564         ].
       
  2565         (self confirm:'create ' , specClass , ' ?') ifTrue:[
       
  2566             superclass subclass:(specClass asSymbol)
       
  2567                        instanceVariableNames:''
       
  2568                        classVariableNames:''
       
  2569                        poolDictionaries:''
       
  2570                        category:'New-Applications'.
       
  2571             ^ true.
       
  2572         ].
       
  2573         ^ false.
       
  2574     ].
       
  2575     cls isBehavior ifFalse:[
       
  2576         self warn:'a global named ' , specClass , ' exists, but is no class.'.
       
  2577         ^ false.
       
  2578     ].
       
  2579 
       
  2580     specSuperclass notNil ifTrue:[
       
  2581         (superclass := Smalltalk at:specSuperclass asSymbol) isNil ifTrue:[
       
  2582             self warn:'no class named ' , specSuperclass , ' exists.'.
       
  2583             ^ false.
       
  2584         ].
       
  2585 
       
  2586         (cls isSubclassOf:superclass) ifFalse:[
       
  2587             self warn:'a global named ' , specClass , ' exists, but is not a subclass of ' , superclass name , '.'.
       
  2588             ^ false.
       
  2589         ]
       
  2590     ].
       
  2591     ^ true
       
  2592 !
       
  2593 
       
  2594 defineClassAndSelector
       
  2595     "launch a dialog to define class, superclass and method"
       
  2596 
       
  2597     |again|
       
  2598 
       
  2599     [
       
  2600         again := false.
       
  2601         (self openDialogInterface:#nameAndSelectorSpec) ifTrue:[
       
  2602 
       
  2603             specClass := (self aspectFor:#classNameChannel) value.
       
  2604             specSelector := (self aspectFor:#methodNameChannel) value.
       
  2605             specSuperclass := (self aspectFor:#superclassNameChannel) value.
       
  2606 
       
  2607             again := self checkClassAndSelector not.
       
  2608             again ifFalse:[
       
  2609                 workView className:specClass superclassName:specSuperclass selector:specSelector.
       
  2610             ].
       
  2611         ]
       
  2612     ] doWhile:[again]
       
  2613 
       
  2614 ! !
       
  2615 
       
  2616 !UIPainter methodsFor:'user interaction - menu'!
  2043 
  2617 
  2044 doFinish
  2618 doFinish
  2045     self closeRequest
  2619     self closeRequest
  2046 !
  2620 !
  2047 
  2621 
  2098         ] doWhile:[accepted and:[failed]].
  2672         ] doWhile:[accepted and:[failed]].
  2099 
  2673 
  2100     "Modified: 5.9.1995 / 18:47:57 / claus"
  2674     "Modified: 5.9.1995 / 18:47:57 / claus"
  2101 !
  2675 !
  2102 
  2676 
       
  2677 doInstall
       
  2678     |code|
       
  2679 
       
  2680     (specClass isNil or:[specSelector isNil]) ifTrue:[
       
  2681         self defineClassAndSelector
       
  2682     ].
       
  2683 
       
  2684     self checkClassAndSelector ifFalse:[
       
  2685         ^ self
       
  2686     ].
       
  2687 
       
  2688     workView className:specClass superclassName:specSuperclass selector:specSelector.
       
  2689 
       
  2690     code := workView generateCode.
       
  2691     (ReadStream on:code) fileIn.
       
  2692 
       
  2693     "Modified: 4.9.1995 / 17:06:10 / claus"
       
  2694 !
       
  2695 
  2103 doNew
  2696 doNew
  2104     workView removeAll.
  2697     workView removeAll.
  2105     ^ self
  2698     ^ self
  2106 
  2699 
  2107     "Modified: 5.9.1995 / 20:52:21 / claus"
  2700     "Modified: 5.9.1995 / 20:52:21 / claus"
  2164     ].
  2757     ].
  2165     fileBox title:(Resource name:'BUILDER_SAVE_TITLE' fromFile:'Builder.rs').
  2758     fileBox title:(Resource name:'BUILDER_SAVE_TITLE' fromFile:'Builder.rs').
  2166     fileBox action:[:fileName | self saveAs:fileName].
  2759     fileBox action:[:fileName | self saveAs:fileName].
  2167     fileBox okText:(Resource name:'BUILDER_SAVE_OK_LABEL' fromFile:'Builder.rs').
  2760     fileBox okText:(Resource name:'BUILDER_SAVE_OK_LABEL' fromFile:'Builder.rs').
  2168     fileBox showAtPointer
  2761     fileBox showAtPointer
  2169 !
  2762 ! !
       
  2763 
       
  2764 !UIPainter ignoredMethodsFor:'user interaction - menu'!
  2170 
  2765 
  2171 doSource
  2766 doSource
  2172    |code v|
  2767    |code v|
  2173 
  2768 
  2174    code := workView generateCode.
  2769    code := workView generateCode.
  2176    v contents:code.
  2771    v contents:code.
  2177    v label:(workView applicationName).
  2772    v label:(workView applicationName).
  2178     ^ self
  2773     ^ self
  2179 
  2774 
  2180     "Modified: 5.9.1995 / 21:02:05 / claus"
  2775     "Modified: 5.9.1995 / 21:02:05 / claus"
  2181 !
  2776 ! !
       
  2777 
       
  2778 !UIPainter methodsFor:'user interaction - menu'!
  2182 
  2779 
  2183 doWindowSpec
  2780 doWindowSpec
  2184    |code v|
  2781    |code v|
  2185 
  2782 
  2186    code := workView generateWindowSpec.
  2783    code := workView generateWindowSpecMethodSource.
  2187    v := CodeView open.
  2784    v := CodeView open.
  2188    v contents:code.
  2785    v contents:code.
  2189    v label:'windowSpec'.
  2786    v label:'windowSpec'.
  2190     ^ self
  2787     ^ self
  2191 
  2788 
  2192     "Modified: 5.9.1995 / 21:04:14 / claus"
  2789     "Modified: 5.9.1995 / 21:04:14 / claus"
  2193 !
  2790 !
  2194 
  2791 
  2195 propertySelectionChanged
       
  2196     workView singleSelectionDo:[:selectedView |
       
  2197         propertyShown   := whichProperty selection.
       
  2198         self showPropertyView
       
  2199     ]
       
  2200 !
       
  2201 
       
  2202 selectOutlet:nr
       
  2203     |outlet type sel text box action initialText initialList
       
  2204      view prop t val|
       
  2205 
       
  2206     outlet := outletView selectionValue.
       
  2207     outletView deselect.
       
  2208     view := workView selection.
       
  2209     view isNil ifTrue:[
       
  2210         self notify:'select something first'.
       
  2211         ^ self
       
  2212     ].
       
  2213     action := [:s | self setOutlet:sel type:type to:s in:view].
       
  2214     (outlet = 'label') ifTrue:[
       
  2215         type := #string.
       
  2216         sel := #label:.
       
  2217         text := 'label-text:'.
       
  2218         initialText := view label
       
  2219     ].
       
  2220     (outlet = 'fixed size') ifTrue:[
       
  2221         type := #boolean.
       
  2222         sel := #sizeFixed:.
       
  2223         text := 'size is fix:'.
       
  2224     ].
       
  2225     (outlet = 'frame shown') ifTrue:[
       
  2226         type := #boolean.
       
  2227         sel := #showFrame:.
       
  2228         text := 'frame is to be drawn:'.
       
  2229     ].
       
  2230     (outlet = 'labels') ifTrue:[
       
  2231         type := #strings.
       
  2232         sel := #labels:.
       
  2233         initialText := view labels
       
  2234     ].
       
  2235     (outlet = 'contents') ifTrue:[
       
  2236         type := #text.
       
  2237         sel := #contents:.
       
  2238         initialText := view contents
       
  2239     ].
       
  2240     (outlet = 'initialText') ifTrue:[
       
  2241         type := #string.
       
  2242         sel := #initialText:.
       
  2243         initialText := view contents
       
  2244     ].
       
  2245     (outlet = 'field type') ifTrue:[
       
  2246         type := #fieldTypeSymbol.
       
  2247         sel := #type:.
       
  2248         initialList := #(number    
       
  2249                          string
       
  2250                          password
       
  2251                         ).
       
  2252         initialText := view converter isNil ifTrue:[#string] ifFalse:[view converter type].
       
  2253     ].
       
  2254     (outlet = 'field length') ifTrue:[
       
  2255         type := #numberOrNil.
       
  2256         sel := #maxChars:.
       
  2257         text := 'field length (empty -> unlimited)'.
       
  2258         initialText := view maxChars isNil ifTrue:[''] ifFalse:[view maxChars printString].
       
  2259     ].
       
  2260     (outlet = 'level') ifTrue:[
       
  2261         type := #number.
       
  2262         sel := #level:.
       
  2263         initialText := view level printString
       
  2264     ].
       
  2265     (outlet = 'active level') ifTrue:[
       
  2266         type := #number.
       
  2267         sel := #onLevel:.
       
  2268         initialText := view onLevel printString
       
  2269     ].
       
  2270     (outlet = 'passive level') ifTrue:[
       
  2271         type := #number.
       
  2272         sel := #offLevel:.
       
  2273         initialText := view offLevel printString
       
  2274     ].
       
  2275     (outlet = 'iconic-label') ifTrue:[
       
  2276         type := #form.
       
  2277         sel := #label:.
       
  2278         text := 'label-icon:'
       
  2279     ].
       
  2280     (outlet = 'view background-color') ifTrue:[
       
  2281         type := #color.
       
  2282         sel := #viewBackground:.
       
  2283         text := 'view background color'.
       
  2284         initialText := 'Black'
       
  2285     ].
       
  2286     (outlet = 'foreground-color') ifTrue:[
       
  2287         type := #color.
       
  2288         sel := #foregroundColor:.
       
  2289         text := 'foreground color'.
       
  2290         initialText := 'Black'
       
  2291     ].
       
  2292     (outlet = 'background-color') ifTrue:[
       
  2293         type := #color.
       
  2294         sel := #backgroundColor:.
       
  2295         text := 'background color'.
       
  2296         initialText := 'Grey'
       
  2297     ].
       
  2298     (outlet = 'active foreground-color') ifTrue:[
       
  2299         type := #color.
       
  2300         sel := #activeForegroundColor:.
       
  2301         text := 'active foreground color'.
       
  2302         initialText := 'Yellow'
       
  2303     ].
       
  2304     (outlet = 'active background-color') ifTrue:[
       
  2305         type := #color.
       
  2306         sel := #activeBackgroundColor:.
       
  2307         text := 'active background color'.
       
  2308         initialText := 'Grey'
       
  2309     ].
       
  2310     (outlet = 'scroll action') ifTrue:[
       
  2311         type := #block.
       
  2312         sel := #scrollAction:.
       
  2313         text := 'action block when scrolled'
       
  2314     ].
       
  2315     (outlet = 'scrollUp action') ifTrue:[
       
  2316         type := #block.
       
  2317         sel := #scrollUpAction:.
       
  2318         text := 'action block when scrolled up'
       
  2319     ].
       
  2320     (outlet = 'scrollDown action') ifTrue:[
       
  2321         type := #block.
       
  2322         sel := #scrollDownAction:.
       
  2323         text := 'action block when scrolled down'
       
  2324     ].
       
  2325     (outlet = 'scrollLeft action') ifTrue:[
       
  2326         type := #block.
       
  2327         sel := #scrollLeftAction:.
       
  2328         text := 'action block when scrolled left'
       
  2329     ].
       
  2330     (outlet = 'scrollRight action') ifTrue:[
       
  2331         type := #block.
       
  2332         sel := #scrollRightAction:.
       
  2333         text := 'action block when scrolled right'
       
  2334     ].
       
  2335     (outlet = 'press action') ifTrue:[
       
  2336         type := #block.
       
  2337         sel := #pressAction:.
       
  2338         text := 'action block when pressed'
       
  2339     ].
       
  2340     (outlet = 'release action') ifTrue:[
       
  2341         type := #block.
       
  2342         sel := #releaseAction:.
       
  2343         text := 'action block when released'
       
  2344     ].
       
  2345     (outlet = 'style') ifTrue:[
       
  2346         type := #symbol.
       
  2347         sel := #style:.
       
  2348         initialList := #(motif next)
       
  2349     ].
       
  2350     (outlet = 'handle position') ifTrue:[
       
  2351         type := #symbol.
       
  2352         sel := #handlePosition:.
       
  2353         initialList := #(left center right)
       
  2354     ].
       
  2355     (outlet = 'horizontal layout') ifTrue:[
       
  2356         type := #symbol.
       
  2357         sel := #horizontalLayout:.
       
  2358         text := 'horizontal components layout'.
       
  2359         initialList := #(left
       
  2360                          leftSpace
       
  2361                          leftMax
       
  2362                          leftSpaceMax
       
  2363                          center 
       
  2364                          centerMax 
       
  2365                          right 
       
  2366                          rightSpace 
       
  2367                          rightMax 
       
  2368                          rightSpaceMax 
       
  2369                          spread 
       
  2370                          spreadSpace 
       
  2371                          spreadMax 
       
  2372                          spreadSpaceMax 
       
  2373                          fit
       
  2374                          fitSpace).
       
  2375         initialText := view horizontalLayout printString
       
  2376     ].
       
  2377     (outlet = 'vertical layout') ifTrue:[
       
  2378         type := #symbol.
       
  2379         sel := #verticalLayout:.
       
  2380         text := 'vertical components layout'.
       
  2381         initialList := #(top    
       
  2382                          topSpace
       
  2383                          center 
       
  2384                          bottom 
       
  2385                          bottomSpace 
       
  2386                          spread 
       
  2387                          spreadSpace 
       
  2388                          fit
       
  2389                          fitSpace).
       
  2390         initialText := view verticalLayout printString
       
  2391     ].
       
  2392     (outlet = 'label position') ifTrue:[
       
  2393         type := #symbol.
       
  2394         sel := #labelPosition:.
       
  2395         initialList := #(topLeft topCenter topRight bottomLeft bottomCenter bottomRight).
       
  2396         initialText := view labelPosition printString
       
  2397     ].
       
  2398     (outlet = 'label layout') ifTrue:[
       
  2399         type := #symbol.
       
  2400         sel := #adjust:.
       
  2401         initialList := #( left right center centerLeft centerRight fit ).
       
  2402         initialText := view adjust printString
       
  2403     ].
       
  2404     (outlet = 'orientation') ifTrue:[
       
  2405         type := #symbol.
       
  2406         sel := #orientation:.
       
  2407         initialList := #( horizontal vertical ).
       
  2408         initialText := view orientation printString
       
  2409     ].
       
  2410 
       
  2411     (type == #color) ifTrue:[
       
  2412         initialList := #('Black'
       
  2413                          'White'
       
  2414                          'LightGrey'
       
  2415                          'Grey'
       
  2416                          'DarkGrey'
       
  2417                          'Yellow'
       
  2418                          'Red'
       
  2419                          'Green'
       
  2420                          'Blue'
       
  2421                         )
       
  2422     ].
       
  2423 
       
  2424     text isNil ifTrue:[
       
  2425         text := outlet
       
  2426     ].
       
  2427 
       
  2428     "what type of box do we need"
       
  2429 
       
  2430     t := type.
       
  2431     ((type == #color) or:[type == #symbol or:[type == #fieldTypeSymbol]]) ifTrue:[
       
  2432         t := #list
       
  2433     ].
       
  2434     ((type == #number) or:[type == #numberOrNil]) ifTrue:[
       
  2435         t := #string
       
  2436     ].
       
  2437     (type == #strings) ifTrue:[
       
  2438         t := #text
       
  2439     ].
       
  2440     (type == #block) ifTrue:[
       
  2441         t := #text.
       
  2442         initialText := workView outletValueOf:sel for:view.
       
  2443         initialText isNil ifTrue:[initialText := '[statements]']
       
  2444     ].
       
  2445     (type == #block1) ifTrue:[
       
  2446         t := #text.
       
  2447         type := #block.
       
  2448         initialText := workView outletValueOf:sel for:view.
       
  2449         initialText isNil ifTrue:[initialText := '[:argument | statements ]']
       
  2450     ].
       
  2451     (type == #block2) ifTrue:[
       
  2452         t := #text.
       
  2453         type := #block.
       
  2454         initialText := workView outletValueOf:sel for:view.
       
  2455         initialText isNil ifTrue:[initialText := '[:arg1 :arg2 | statements ]']
       
  2456     ].
       
  2457 
       
  2458     "show a box to enter thing"
       
  2459 
       
  2460     (t == #boolean) ifTrue:[
       
  2461         val := Dialog confirmWithCancel:text.
       
  2462         (val == true or:[val == false]) ifTrue:[
       
  2463             action value:val
       
  2464         ].
       
  2465         ^ self
       
  2466     ].
       
  2467     (t == #string) ifTrue:[
       
  2468 "/        stringBox isNil ifTrue:[
       
  2469             stringBox := EnterBox new.
       
  2470 "/        ].
       
  2471         box := stringBox
       
  2472     ].
       
  2473     (t == #list) ifTrue:[
       
  2474 "/        listBox isNil ifTrue:[
       
  2475             listBox := ListSelectionBox new.
       
  2476 "/        ].
       
  2477         listBox list:initialList.
       
  2478         box := listBox
       
  2479     ].
       
  2480     (t == #text) ifTrue:[
       
  2481 "/        actionBox isNil ifTrue:[
       
  2482             actionBox := TextBox new.
       
  2483 "/        ].
       
  2484         actionBox initialText:initialText.
       
  2485         box := actionBox
       
  2486     ].
       
  2487 "
       
  2488 Transcript show:'outlet: '. Transcript showCR:outlet.
       
  2489 Transcript show:'type:   '. Transcript showCR:type.
       
  2490 Transcript show:'sel:    '. Transcript showCR:sel.
       
  2491 Transcript show:'text:   '. Transcript showCR:text.
       
  2492 "
       
  2493 
       
  2494     box isNil ifTrue:[
       
  2495         self notify:'not yet implemented'
       
  2496     ] ifFalse:[
       
  2497         box initialText:initialText.
       
  2498         box title:text.
       
  2499         box action:action.
       
  2500         box showAtPointer
       
  2501     ]
       
  2502 
       
  2503     "Modified: 6.9.1995 / 13:46:29 / claus"
       
  2504 !
       
  2505 
       
  2506 setColors
       
  2507     |fg bg|
       
  2508 
       
  2509     fg := fgChannel value.
       
  2510     (fg notNil and:[fg notEmpty]) ifTrue:[
       
  2511         fg := Color readFrom:fg.
       
  2512         workView singleSelectionDo:[:selectedView |
       
  2513             selectedView ~~ workView ifTrue:[
       
  2514                 selectedView foregroundColor:fg
       
  2515             ].
       
  2516         ].
       
  2517     ].
       
  2518     bg := bgChannel value.
       
  2519     (bg notNil and:[bg notEmpty]) ifTrue:[
       
  2520         bg := Color readFrom:bg.
       
  2521         workView singleSelectionDo:[:selectedView |
       
  2522             selectedView ~~ workView ifTrue:[
       
  2523                 selectedView backgroundColor:bg
       
  2524             ].
       
  2525         ].
       
  2526     ].
       
  2527 !
       
  2528 
       
  2529 setMiscAspects
       
  2530     "sent when apply is pressen in the misc-sub view"
       
  2531 
       
  2532     workView singleSelectionDo:[:selectedView |
       
  2533         selectedView ~~ workView ifTrue:[
       
  2534             workView changeVariableNameOf:selectedView to:nameChannel value
       
  2535         ]
       
  2536     ].
       
  2537 !
       
  2538 
       
  2539 setModelAspects
       
  2540     "sent when apply is pressen in the model-sub view"
       
  2541 
       
  2542     |aspectSymbol|
       
  2543 
       
  2544     aspectSymbol := (self aspectFor:#aspectChannel) value.
       
  2545     (aspectSymbol notNil and:[aspectSymbol notEmpty]) ifTrue:[
       
  2546         aspectSymbol := aspectSymbol asSymbol.
       
  2547         workView singleSelectionDo:[:selectedView |
       
  2548             selectedView ~~ workView ifTrue:[
       
  2549                 workView setAspectSelector:aspectSymbol forView:selectedView
       
  2550             ].
       
  2551         ].
       
  2552     ].
       
  2553 !
       
  2554 
       
  2555 setOutlet:outletSymbol type:type to:outletValue in:aView
       
  2556     |block val messageSymbol|
       
  2557 
       
  2558     messageSymbol := outletSymbol.
       
  2559     val := outletValue.
       
  2560     (type == #block) ifTrue:[
       
  2561 	block := Compiler evaluate:val.
       
  2562 	(block == #Error) ifTrue:[
       
  2563 	    self warn:'action will not work in test-mode'.
       
  2564 	    workView addOutletDefinitionFor:outletSymbol
       
  2565 				       type:type
       
  2566 				      value:outletValue
       
  2567 					for:aView.
       
  2568 	    ^ self
       
  2569 	].
       
  2570 	val := block
       
  2571     ].
       
  2572     (type == #number) ifTrue:[
       
  2573 	val := Number readFromString:outletValue onError:0 
       
  2574     ].
       
  2575     (type == #numberOrNil) ifTrue:[
       
  2576 	val := Number readFromString:outletValue onError:nil
       
  2577     ].
       
  2578     (type == #text) ifTrue:[
       
  2579 	val := outletValue asString
       
  2580     ].
       
  2581     (type == #strings) ifTrue:[
       
  2582 	val := outletValue asText
       
  2583     ].
       
  2584     (type == #symbol) ifTrue:[
       
  2585 	val := outletValue asSymbol.
       
  2586     ].
       
  2587     (type == #fieldTypeSymbol) ifTrue:[
       
  2588 	val := outletValue asSymbol.
       
  2589 	val == #password ifTrue:[
       
  2590 	    aView passwordCharacter:$*
       
  2591 	] ifFalse:[
       
  2592 	    aView passwordCharacter:nil
       
  2593 	].
       
  2594 	val := (PrintConverter new initFor:val).
       
  2595 	messageSymbol := #converter:
       
  2596     ].
       
  2597     (type == #color) ifTrue:[
       
  2598 	val := Color name:outletValue.
       
  2599 	val isNil ifTrue:[
       
  2600 	    self warn:('no such color:' , outletValue).
       
  2601 	    ^ self
       
  2602 	]
       
  2603     ].
       
  2604 Transcript show:(val printString).
       
  2605 Transcript showCR:('(' , val class printString , ')').
       
  2606 
       
  2607     workView selectionHiddenDo:[
       
  2608 	aView perform:messageSymbol with:val.
       
  2609 	workView elementChanged:aView.
       
  2610 	aView redraw.
       
  2611     ].
       
  2612     workView addOutletDefinitionFor:outletSymbol
       
  2613 			       type:type
       
  2614 			      value:outletValue
       
  2615 				for:aView
       
  2616 
       
  2617     "Modified: 6.9.1995 / 13:44:46 / claus"
       
  2618 !
       
  2619 
       
  2620 showPropertyView
       
  2621     |v l spec|
       
  2622 
       
  2623     workView singleSelectionDo:[:selectedView |
       
  2624         propertyShown = 'dimension' ifTrue:[
       
  2625             (l := selectedView geometryLayout) notNil ifTrue:[
       
  2626                 l isLayout ifTrue:[
       
  2627                     l isAlignmentOrigin ifTrue:[
       
  2628                         spec := self class geometrySpecForAlignmentOrigin
       
  2629                     ] ifFalse:[
       
  2630                         l isLayoutFrame ifFalse:[
       
  2631                             spec := self class geometrySpecForLayoutOrigin
       
  2632                         ]
       
  2633                     ]
       
  2634                 ]
       
  2635             ].
       
  2636             spec isNil ifTrue:[
       
  2637                 spec := self class geometrySpecForLayoutFrame
       
  2638             ].
       
  2639             ^ self setupPropertyFromSpec:spec
       
  2640         ].
       
  2641 
       
  2642         propertyShown = 'colors' ifTrue:[
       
  2643             ^ self setupPropertyFromSpec:(self class colorSpec)
       
  2644         ].
       
  2645 
       
  2646         propertyShown = 'model' ifTrue:[
       
  2647             ^ self setupPropertyFromSpec:(self class modelSpec)
       
  2648         ].
       
  2649 
       
  2650         propertyShown = 'misc' ifTrue:[
       
  2651             ^ self setupPropertyFromSpec:(self class miscSpec)
       
  2652         ].
       
  2653 
       
  2654         propertyShown = 'attribute list' ifTrue:[
       
  2655             specShown ~~ #attributeList ifTrue:[
       
  2656                 propertyFrame destroySubViews.
       
  2657                 v := ScrollableView for:SelectionInListView in:propertyFrame.
       
  2658                 v origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
       
  2659                 outletView := v scrolledView.
       
  2660                 outletView action:[:lineNr | lineNr notNil ifTrue:[self selectOutlet:lineNr]].
       
  2661                 propertyFrame realizeAllSubViews.
       
  2662                 specShown := #attributeList.
       
  2663             ].
       
  2664             self showOutletsFor:(workView selection).
       
  2665             ^ self
       
  2666         ].
       
  2667     ].
       
  2668 
       
  2669     propertyFrame destroySubViews.
       
  2670     outletView := nil.
       
  2671     specShown := nil.
       
  2672 
       
  2673 !
       
  2674 
       
  2675 toggleTest
  2792 toggleTest
  2676     |m t|
  2793     |m t|
  2677 
  2794 
  2678     m := menu menuAt:#test.
  2795     m := menu menuAt:#test.
  2679     t := workView testMode not.
  2796     t := workView testMode not.
  2684         m labelAt:#toggleTest put:(resources string:'test on')
  2801         m labelAt:#toggleTest put:(resources string:'test on')
  2685     ].
  2802     ].
  2686     workView testMode:t
  2803     workView testMode:t
  2687 ! !
  2804 ! !
  2688 
  2805 
  2689 !UIPainter methodsFor:'user interaction - dialogs'!
       
  2690 
       
  2691 defineClassAndSelector
       
  2692     "launch a dialog to define class, superclass and method"
       
  2693 
       
  2694     |dialog|
       
  2695 
       
  2696     self openDialogInterface:#nameAndSelectorSpec.
       
  2697 ! !
       
  2698 
       
  2699 !UIPainter class methodsFor:'documentation'!
  2806 !UIPainter class methodsFor:'documentation'!
  2700 
  2807 
  2701 version
  2808 version
  2702     ^ '$Header$'
  2809     ^ '$Header$'
  2703 ! !
  2810 ! !