UIPainter.st
changeset 155 575239b7ad0b
parent 152 2261aa2fa21d
child 156 b332d7117c40
equal deleted inserted replaced
154:34d5602e13d7 155:575239b7ad0b
   155                 #'value:' #file
   155                 #'value:' #file
   156                 #'submenu:'
   156                 #'submenu:'
   157                         #(#Menu #(
   157                         #(#Menu #(
   158                                  #(#MenuItem
   158                                  #(#MenuItem
   159                                         #'label:' 'new'
   159                                         #'label:' 'new'
   160                                         #'value:' #removeAll
   160                                         #'value:' #doNew
   161                                   )
   161                                   )
   162                                  #(#MenuItem
   162                                  #(#MenuItem
   163                                         #'label:' 'from class ...'
   163                                         #'label:' 'from class ...'
   164                                         #'value:' #doFromClass
   164                                         #'value:' #doFromClass
   165                                   )
   165                                   )
   234                 #'label:' 'code'
   234                 #'label:' 'code'
   235                 #'value:' #code
   235                 #'value:' #code
   236                 #'submenu:'
   236                 #'submenu:'
   237                         #(#Menu #(
   237                         #(#Menu #(
   238                                 #(#MenuItem
   238                                 #(#MenuItem
   239                                         #'label:' 'class && method'
   239                                         #'label:' 'class && method ...'
   240                                         #'value:' #defineClassAndSelector
   240                                         #'value:' #defineClassAndSelector
   241                                  )
   241                                  )
   242                                  #(#MenuItem
   242                                  #(#MenuItem
   243                                         #'label:' 'install spec'
   243                                         #'label:' 'install spec'
   244                                         #'value:' #doInstallSpec
   244                                         #'value:' #doInstallSpec
   250                                  #(#MenuItem
   250                                  #(#MenuItem
   251                                         #'label:' 'install aspects'
   251                                         #'label:' 'install aspects'
   252                                         #'value:' #doInstallAspects
   252                                         #'value:' #doInstallAspects
   253                                   )
   253                                   )
   254                                  #(#MenuItem
   254                                  #(#MenuItem
   255                                         #'label:' 'windowSpec'
   255                                         #'label:' 'show windowSpec'
   256                                         #'value:' #doWindowSpec
   256                                         #'value:' #doWindowSpec
   257                                    )
   257                                    )
   258                                 #(#MenuItem
   258                                 #(#MenuItem
   259                                         #'label:' 'browse application'
   259                                         #'label:' 'browse application'
   260                                         #'value:' #doBrowseAppClass
   260                                         #'value:' #doBrowseAppClass
   286         )
   286         )
   287         nil
   287         nil
   288         nil
   288         nil
   289       )
   289       )
   290 
   290 
       
   291     "Modified: 17.6.1997 / 12:30:17 / cg"
   291 !
   292 !
   292 
   293 
   293 nameAndSelectorSpec
   294 nameAndSelectorSpec
   294     "this window spec was automatically generated by the ST/X UIPainter"
   295     "this window spec was automatically generated by the ST/X UIPainter"
   295 
   296 
  1123 
  1124 
  1124 
  1125 
  1125 !
  1126 !
  1126 
  1127 
  1127 doFromClass
  1128 doFromClass
  1128         |className methodName cls sel accepted failed spec s painter|
  1129     |className methodName cls sel accepted failed spec s painter|
  1129 
  1130 
  1130         className  := '' asValue.
  1131     objectList painter isModified ifTrue:[
  1131         methodName := '' asValue.
  1132         (self confirm:'edit another interface without saving your modifications ?') ifFalse:[
  1132         painter    := self painter.
  1133             ^ self
  1133 
  1134         ]
  1134         (s := painter className) notNil ifTrue:[
  1135     ].
  1135             className value:s
  1136 
  1136         ].
  1137     className  := '' asValue.
  1137         (s := painter methodName) notNil ifTrue:[
  1138     methodName := '' asValue.
  1138             methodName value:s
  1139     painter    := self painter.
  1139         ].
  1140 
  1140 
  1141     (s := painter className) notNil ifTrue:[
  1141         failed := false.
  1142         className value:s
  1142         [
  1143     ].
  1143             accepted :=
  1144     (s := painter methodName) notNil ifTrue:[
  1144                 (DialogBox new
  1145         methodName value:s
  1145                     addTextLabel:'Classes name:';
  1146     ].
  1146                     addInputFieldOn:className; 
  1147 
  1147                     addVerticalSpace;
  1148     failed := false.
  1148                     addTextLabel:'methods name:';
  1149     [
  1149                     addInputFieldOn:methodName; 
  1150         accepted :=
  1150                     addAbortButton; 
  1151             (DialogBox new
  1151                     addOkButton; 
  1152                 addTextLabel:'Classes name:';
  1152                     open
  1153                 addInputFieldOn:className; 
  1153                 ) accepted.
  1154                 addVerticalSpace;
  1154 
  1155                 addTextLabel:'methods name:';
  1155              accepted ifTrue:[
  1156                 addInputFieldOn:methodName; 
  1156                 cls := Smalltalk classNamed:className value.
  1157                 addAbortButton; 
  1157                 cls isNil ifTrue:[
  1158                 addOkButton; 
       
  1159                 open
       
  1160             ) accepted.
       
  1161 
       
  1162          accepted ifTrue:[
       
  1163             cls := Smalltalk classNamed:className value.
       
  1164             cls isNil ifTrue:[
       
  1165                 failed := true.
       
  1166                 self warn:'no such class'.
       
  1167             ] ifFalse:[
       
  1168                 sel := methodName value asSymbol.
       
  1169                 (cls respondsTo:sel ) ifFalse:[
  1158                     failed := true.
  1170                     failed := true.
  1159                     self warn:'no such class'.
  1171                     self warn:'no such method'
  1160                 ] ifFalse:[
  1172                 ] ifTrue:[
  1161                     sel := methodName value asSymbol.
  1173                     spec := cls perform:sel.
  1162                     (cls respondsTo:sel ) ifFalse:[
  1174                     spec isArray ifFalse:[
  1163                         failed := true.
  1175                         failed := true.
  1164                         self warn:'no such method'
  1176                         self warn:'not a windowSpec method'    
  1165                     ] ifTrue:[
  1177                     ].
  1166                         spec := cls perform:sel.
  1178                     "/ ok, got it
  1167                         spec isArray ifFalse:[
  1179                     painter className:className value.
  1168                             failed := true.
  1180                     painter methodName:methodName value.
  1169                             self warn:'not a windowSpec method'    
  1181                     painter setupFromSpec:spec.
  1170                         ].
  1182                   ^ self
  1171                         "/ ok, got it
  1183                  ]
  1172                         painter className:className value.
  1184             ]
  1173                         painter methodName:methodName value.
  1185          ]
  1174                         painter setupFromSpec:spec.
  1186     ] doWhile:[accepted and:[failed]].
  1175                       ^ self
  1187 
  1176                      ]
  1188     "Modified: 17.6.1997 / 12:33:36 / cg"
  1177                 ]
       
  1178              ]
       
  1179         ] doWhile:[accepted and:[failed]].
       
  1180 
       
  1181 !
  1189 !
  1182 
  1190 
  1183 doInstallAspects
  1191 doInstallAspects
  1184     |code|
  1192     |code|
  1185 
  1193 
  1259                   selector:specSelector.
  1267                   selector:specSelector.
  1260 
  1268 
  1261     code := self painter generateCode.
  1269     code := self painter generateCode.
  1262     (ReadStream on:code) fileIn.
  1270     (ReadStream on:code) fileIn.
  1263 
  1271 
       
  1272 !
       
  1273 
       
  1274 doNew
       
  1275     objectList painter isModified ifTrue:[
       
  1276         (self confirm:'new interface without saving your modifications ?') ifFalse:[
       
  1277             ^ self
       
  1278         ]
       
  1279     ].
       
  1280 
       
  1281     self removeAll
       
  1282 
       
  1283     "Modified: 17.6.1997 / 12:33:31 / cg"
  1264 !
  1284 !
  1265 
  1285 
  1266 doOpen
  1286 doOpen
  1267     |box|
  1287     |box|
  1268 
  1288 
  1276 !
  1296 !
  1277 
  1297 
  1278 doPickAView
  1298 doPickAView
  1279     |painter view className methodName cls sel accepted spec s|
  1299     |painter view className methodName cls sel accepted spec s|
  1280 
  1300 
       
  1301     objectList painter isModified ifTrue:[
       
  1302         (self confirm:'pick another interface without saving your modifications ?') ifFalse:[
       
  1303             ^ self
       
  1304         ]
       
  1305     ].
       
  1306 
  1281     (view := Display viewFromUser) notNil ifTrue:[
  1307     (view := Display viewFromUser) notNil ifTrue:[
  1282         painter := self painter.
  1308         painter := self painter.
  1283 
  1309 
  1284         spec := UISpecification fromView:view topView.
  1310         spec := UISpecification fromView:view topView.
  1285 
  1311 
  1286      "/ ok, got it
  1312      "/ ok, got it
  1287         painter setupFromSpec:spec.
  1313         painter setupFromSpec:spec.
  1288         painter className:view class name.
  1314         painter className:view class name.
  1289         painter methodName:#newSpec.
  1315         painter methodName:#newSpec.
  1290     ]
  1316     ]
       
  1317 
       
  1318     "Modified: 17.6.1997 / 12:33:23 / cg"
  1291 !
  1319 !
  1292 
  1320 
  1293 doRaise
  1321 doRaise
  1294     self painter topView raise.
  1322     self painter topView raise.
  1295 
  1323