LabelAndIcon is one of the more contrived objects in VisualWorks. At first it seems tame enough. Then we find there's this heirarchy of all these tweaked variants under it. But they all take just one graphic. And they all want the graphic to go on the left side. We ran into this as problem for the merge tool in VW 7.5. As a result, a simple little object was introduced called "VisualRow". It's just a collection of VisualComponents which are drawn horizontally. Using this, we could put N icons to the left of a label, with an expression something like:
(LabelAndIcon with: 'Hello World') icon: (VisualRow withAll: (#(#handWave #globe) collect: [:each | ListIconLibrary visualFor: each]))
It turned out pretty handy. But when I was working on the new browser tabs, I came upon a case, where I wanted one icon to the left of the text, and one to the right. I could have made another LabelAndIcon subclass. But by backing up for a minute, I realized that TabLabelAndIcon weren't doing anything more than what VisualRow already was. So I inverted the relationship and used it as the top level thing:
VisualRow withAll: (Array
with: anObject toolListIcon
with: (Label with: 'Comment')
with: ToolListIconLibrary warning)
Often we create these DSL's in Smalltalkm and we get so in the groove with them that we start hacking away at all kinds of stuff, when if we back up for a minute, often we'll find a simpler/more general solution just outside of our perhipheral view.