QotD    "To be or not to be" – Shakespeare
View this PageEdit this PageUploads to this PageHistory of this PageTop of the SwikiRecent ChangesSearch the SwikiHelp Guide
UserInterfaceTheme design note
Last updated at 6:14 pm UTC on 25 September 2017
Chris Muller
Mon, Sep 18, 2017 at 2:09 AM

To: The general-purpose Squeak developers list

One goal of the design was to provide access to a
first-class Theme object, without needing to either write, nor see,
that extra level of indirection in the code.

   myMorph userInterfaceTheme color


   (myMorph userInterfaceTheme propertyNamed: #color)

The lookup of #color for the example above is then implemented as
Original version ->
doesNotUnderstand: aMessage 
	"Answer whether I have, or inherit, a value for the visual-attribute specified by aMessage's #selector."

	aMessage numArgs > 0 ifTrue: [^ super doesNotUnderstand: aMessage].
	scope isEmpty ifTrue: [^ super doesNotUnderstand: aMessage].
	^ [self get: scope top class -> aMessage selector]
		ensure: [scope pop]

This was changed in update System-mt.963 as a result of some concerns about the details of how the scope variable list might get damaged. When an object requests the applicable them a new UserInterfaceThemeRequest instance is created that knows the actual theme instance and the requesting object. This simplifies the code a little
doesNotUnderstand: aMessage 
	"Look up the visual-attribute specified by aMessage's #selector in the current theme for the current target object."

	^ aMessage numArgs = 0
		ifTrue: [self theme get: self target class -> aMessage selector]
		ifFalse: [super doesNotUnderstand: aMessage]

and makes it much more understandable