removeWidgetFrom: window
| clickPoint selected |
clickPoint := Point fromUser.
selected := window paneMorphs
detect: [:morph | morph bounds containsPoint: clickPoint]
ifNone: [].
selected
ifNotNil: [selected delete]removeWidgetFrom: window
| clickPoint selected |
clickPoint := Point fromUser.
selected := window
paneMorphSatisfying: [:morph | morph bounds containsPoint: clickPoint].
selected ifNotNil: [
selected delete.
window updatePanesFromSubmorphs]addModelItemsToWindowMenu: aMenu
window := aMenu defaultTarget.
aMenu addLine.
(self class allMethodsInCategory: 'widget types') do: [:widgetSym |
aMenu
add: 'add ', widgetSym
target: self
selector: #add:to:
argumentList: {widgetSym. window}].
aMenu addLine.
aMenu add: 'delete' target: self selector: #removeWidgetFrom: argument: window.
aMenu addLine.
aMenu add: 'show script' target: self selector: #generateScriptOf: argument: windowgenerateScriptOf: window
| 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]]このページを編集 (4429 bytes)
| 以下の 1 ページから参照されています。 |
This page has been visited 289 times.