UIPainterView.st
changeset 2197 873c7b960233
parent 2195 bb6de5f8fd03
child 2212 7224d23c4a37
equal deleted inserted replaced
2196:7e4e066ca7f5 2197:873c7b960233
  1346       '!! !!\\') withCRs
  1346       '!! !!\\') withCRs
  1347 
  1347 
  1348     "Modified: / 25.10.1997 / 19:22:17 / cg"
  1348     "Modified: / 25.10.1997 / 19:22:17 / cg"
  1349 !
  1349 !
  1350 
  1350 
       
  1351 generateWindowSpec
       
  1352     |spec|
       
  1353 
       
  1354     spec := OrderedCollection new.
       
  1355 
       
  1356     self subViews do:[:aView|
       
  1357         |vSpec|
       
  1358 
       
  1359         "/ care for wrapped views ...
       
  1360         vSpec := self fullSpecFor:aView.
       
  1361         vSpec isNil ifTrue:[
       
  1362             aView subViews size == 1 ifTrue:[
       
  1363                 vSpec := self fullSpecFor:(aView subViews first).
       
  1364             ]
       
  1365         ].
       
  1366         vSpec isNil ifTrue:[
       
  1367             self warn:'Oops - could not create spec for some view'
       
  1368         ].
       
  1369         spec add:vSpec
       
  1370     ].
       
  1371 
       
  1372     spec := treeView generateFullSpecForComponents:spec named:methodName.
       
  1373     ^ spec
       
  1374 !
       
  1375 
  1351 generateWindowSpecMethodSource
  1376 generateWindowSpecMethodSource
  1352     |spec str code category cls mthd specCode|
  1377     |spec str code category cls mthd specCode|
  1353 
  1378 
  1354     spec := OrderedCollection new.
  1379     spec := self generateWindowSpec.
  1355 
  1380 
  1356     self subViews do:[:aView|
       
  1357 	|vSpec|
       
  1358 
       
  1359 	"/ care for wrapped views ...
       
  1360 	vSpec := self fullSpecFor:aView.
       
  1361 	vSpec isNil ifTrue:[
       
  1362 	    aView subViews size == 1 ifTrue:[
       
  1363 		vSpec := self fullSpecFor:(aView subViews first).
       
  1364 	    ]
       
  1365 	].
       
  1366 	vSpec isNil ifTrue:[
       
  1367 	    self warn:'Oops - could not create spec for some view'
       
  1368 	].
       
  1369 	spec add:vSpec
       
  1370     ].
       
  1371 
       
  1372     spec := treeView generateFullSpecForComponents:spec named:methodName.
       
  1373     str  := WriteStream on:String new.
  1381     str  := WriteStream on:String new.
  1374     UISpecification prettyPrintSpecArray:spec on:str indent:5.
  1382     UISpecification prettyPrintSpecArray:spec on:str indent:5.
  1375     specCode := str contents.
  1383     specCode := str contents.
  1376 
  1384 
  1377     (specCode includes:$!!) ifTrue:[
  1385     (specCode includes:$!!) ifTrue:[
  1378 	"/ oops - must be chunk format ...
  1386         "/ oops - must be chunk format ...
  1379 	str  := WriteStream on:String new.
  1387         str  := WriteStream on:String new.
  1380 	str nextPutAllAsChunk:specCode.
  1388         str nextPutAllAsChunk:specCode.
  1381 	specCode := str contents.
  1389         specCode := str contents.
  1382     ].
  1390     ].
  1383 
  1391 
  1384     "/ if that method already exists, do not overwrite the category
  1392     "/ if that method already exists, do not overwrite the category
  1385 
  1393 
  1386     category := 'interface specs'.
  1394     category := 'interface specs'.
  1387     cls := self resolveName:className.
  1395     cls := self resolveName:className.
  1388 
  1396 
  1389     cls notNil ifTrue:[
  1397     cls notNil ifTrue:[
  1390 	(mthd := cls class compiledMethodAt:methodName asSymbol) notNil ifTrue:[
  1398         (mthd := cls class compiledMethodAt:methodName asSymbol) notNil ifTrue:[
  1391 	    category := mthd category.
  1399             category := mthd category.
  1392 	]
  1400         ]
  1393     ].
  1401     ].
  1394 
  1402 
  1395     code := '!!'
  1403     code := '!!'
  1396 	    , className , ' class methodsFor:' , category storeString
  1404             , className , ' class methodsFor:' , category storeString
  1397 	    , '!!' , '\\'
  1405             , '!!' , '\\'
  1398 
  1406 
  1399 	    , methodName , '\'
  1407             , methodName , '\'
  1400 	    , ((ResourceSpecEditor codeGenerationCommentForClass: UIPainter) replChar:$!! withString:'!!!!')
  1408             , ((ResourceSpecEditor codeGenerationCommentForClass: UIPainter) replChar:$!! withString:'!!!!')
  1401 	    , '\\    "\'
  1409             , '\\    "\'
  1402 	    , ('     UIPainter new openOnClass:' , className , ' andSelector:#' , methodName , '\').
  1410             , ('     UIPainter new openOnClass:' , className , ' andSelector:#' , methodName , '\').
  1403 
  1411 
  1404     (cls notNil and:[cls isSubclassOf:ApplicationModel]) ifTrue:[
  1412     (cls notNil and:[cls isSubclassOf:ApplicationModel]) ifTrue:[
  1405 	code := code
  1413         code := code
  1406 	    , ('     ' , className , ' new openInterface:#' , methodName , '\').
  1414             , ('     ' , className , ' new openInterface:#' , methodName , '\').
  1407     ].
  1415     ].
  1408 
  1416 
  1409     code := code
  1417     code := code
  1410 	    ,(methodName = 'windowSpec'
  1418             ,(methodName = 'windowSpec'
  1411 		ifTrue:['     ' , className , ' open\'] ifFalse: [''])
  1419                 ifTrue:['     ' , className , ' open\'] ifFalse: [''])
  1412 	    , '    "\'.
  1420             , '    "\'.
  1413 
  1421 
  1414     code := code
  1422     code := code
  1415 	    , '\'
  1423             , '\'
  1416 	    , '    <resource: #canvas>\\'
  1424             , '    <resource: #canvas>\\'
  1417 	    , '    ^ ' , specCode
  1425             , '    ^ ' , specCode
  1418 	    , '\'
  1426             , '\'
  1419 	    , '!! !!'
  1427             , '!! !!'
  1420 	    , '\\'.
  1428             , '\\'.
  1421 
  1429 
  1422     ^ code withCRs
  1430     ^ code withCRs
  1423 
  1431 
  1424     "Modified: / 5.9.1995 / 21:01:35 / claus"
  1432     "Modified: / 5.9.1995 / 21:01:35 / claus"
  1425     "Modified: / 15.10.1998 / 11:29:53 / cg"
  1433     "Modified: / 15.10.1998 / 11:29:53 / cg"
  1607 
  1615 
  1608     self backgroundColor: self class defaultViewBackgroundColor.
  1616     self backgroundColor: self class defaultViewBackgroundColor.
  1609 !
  1617 !
  1610 
  1618 
  1611 setupFromSpec:specOrSpecArray
  1619 setupFromSpec:specOrSpecArray
  1612 
  1620     |spec builder specWindow|
  1613     |spec builder|
       
  1614 
  1621 
  1615     Cursor wait showWhile: [
  1622     Cursor wait showWhile: [
  1616 	self removeAll.
  1623         self removeAll.
  1617 	specOrSpecArray notNil ifTrue:[
  1624         specOrSpecArray notNil ifTrue:[
  1618 	    spec    := UISpecification from:specOrSpecArray.
  1625             spec    := UISpecification from:specOrSpecArray.
  1619 	].
  1626         ].
  1620 	builder := UIBuilder new isEditing:true.
  1627         builder := UIBuilder new isEditing:true.
  1621 	"set applicationClass, in order that subspecifications may be resolved"
  1628         "set applicationClass, in order that subspecifications may be resolved"
  1622 	className notNil ifTrue:[
  1629         className notNil ifTrue:[
  1623 	    builder applicationClass:(self resolveName:className).
  1630             builder applicationClass:(self resolveName:className).
  1624 	].
  1631         ].
  1625 	spec notNil ifTrue:[
  1632         spec notNil ifTrue:[
  1626 	    spec window setupView:self topView for:builder.
  1633             specWindow := spec window.
  1627 	    self addSpec:(spec component) builder:builder in:self.
  1634         ].
  1628 	].
  1635         specWindow notNil ifTrue:[
  1629 	self realizeAllSubViews.
  1636             specWindow setupView:self topView for:builder.
  1630 	spec notNil ifTrue:[
  1637             self addSpec:(spec component) builder:builder in:self.
  1631 	    treeView setAttributesFromWindowSpec:(spec window)
  1638         ].
  1632 	].
  1639         self realizeAllSubViews.
       
  1640         specWindow notNil ifTrue:[
       
  1641             treeView setAttributesFromWindowSpec:specWindow
       
  1642         ].
  1633     ].
  1643     ].
  1634 !
  1644 !
  1635 
  1645 
  1636 treeView:aTreeView
  1646 treeView:aTreeView
  1637     treeView := aTreeView.
  1647     treeView := aTreeView.