Silk.st 881 B

12345678910111213141516171819202122232425262728293031323334
  1. Smalltalk createPackage: 'Silk'!
  2. Domite subclass: #Silk
  3. instanceVariableNames: ''
  4. package: 'Silk'!
  5. !Silk commentStamp!
  6. I am adding convenience APIs to my subclass, `Domite`.
  7. ##Rendering
  8. - `aSilk << anObject` uses double-dispatch via `renderOnSilk:`. This allows creating widgets (no formal superclass, anything with `renderOnSilk:` is a widget), as well as incorporating blocks: `aSilk << aBlock` runs the block, passing aSilk as a parameter.!
  9. !Silk methodsFor: 'writing'!
  10. nextPut: anObject
  11. "Double-dispatches anObject via renderOnSilk: message.
  12. If a message returns nil, this fallbacks to superclass.
  13. Otherwise, it is assumed renderOnSilk: did its job."
  14. (anObject renderOnSilk: self)
  15. ifNil: [ super nextPut: anObject ]
  16. ! !
  17. !BlockClosure methodsFor: '*Silk'!
  18. renderOnSilk: aSilk
  19. self value: aSilk
  20. ! !
  21. !Object methodsFor: '*Silk'!
  22. renderOnSilk: aSilk
  23. ^ nil
  24. ! !