| sourceCodes method widgetClass sourceCode file start frame | sourceCodes := Dictionary new. (self class allMethodsInCategory: 'widget types') do: [:selector | method := self class compiledMethodAt: selector. widgetClass := method literals detect: [:lit | lit asString beginsWith: '#Pluggable']. sourceCode := method getSourceFromFile asString. start := sourceCode indexOf: $^. sourceCode := sourceCode allButFirst: start + 1. sourceCodes at: widgetClass value put: sourceCode]. file := FileStream newFileNamed: 'mywindow.st'. [ file nextPutAll: '| model window |'; cr. file nextPutAll: 'model := Model new.'; cr. file nextPutAll: 'window := '. file nextPutAll: '(SystemWindow labelled: ''My Window'') model: model.'; cr. window paneMorphs do: [:morph | file nextPutAll: 'window addMorph: ('. file nextPutAll: (sourceCodes at: morph class). file nextPutAll: ') frame: ('. frame := morph layoutFrame. file nextPutAll: ( frame leftFraction @ frame topFraction corner: frame rightFraction @ frame bottomFraction) printString. file nextPutAll: ').'; cr]. file nextPutAll: '^ window openInWorld'] ensure: [file ifNotNilDo: [:f | f edit]]
このページを編集 (1319 bytes)
このページは Swiki ブック内で孤立しています。 |
This page has been visited 417 times.