Search code examples
smalltalkdolphin-smalltalk

How to use a custom icon in a dolphin smalltalk treeview?


In a Dolphin smalltalk treeview I'd like to use a custom icon, depending on the state of the item displayed, (differente state, different icon) How can I do that ?

I cannot really understand how to use a "my" icon. I've create a class "connection", with an instance variable "connected" and two class methods "connectedIcon and unconnectedIcon that returns icon images. Then an instance function "icon" that returns one or the other image based on the connection state.

I can add instances of this class to a tree view and see the name of the connections. But how to show my Icons ?

I tried to sustitute the getImageBlock of my presenter view with the following expression [:obj | obj icon] but it doesn't work. (nothing seems to happen).

this is made in my presenter initialize :

initialize super initialize. treePresenter view getImageBlock: [:obj | obj icon]

what's wrong with it ? best regards Maurizio


Solution

  • When you are editing a TreeView, one of the properties is getImageBlock. By default it is not really a block but another object that understands the message #'value:' (the class IconicListAbstract). You can replace this property with a code block (or other object that understands #'value:') and answer the image you want displayed.