1

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

3 Answers3

3

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.

James Foster
  • 136
  • 1
  • 1
  • Thanks, I found also useful the dolphin blog tutorials "using icons" and "Beauty with less Beast". I'm going to experiment ... – Maurizio Ferreira Jul 26 '16 at 20:10
  • I cannot really understand how to use a "my" icon. I've create a class "connection", with an instance variable "connected" – Maurizio Ferreira Aug 02 '16 at 19:42
  • Seems that the block defined in getImageBlock should return a numeric index: (that I suppose must be the index of my image) if, for example, I set the block to [:obj | 1] all the elements of the list display an internal icon if I set the block to [:obj | 2] all the elements of the list display another icon, and so on. The question is : where should I put my icons, and how to get the associated index ? Btw, I set the block in the createSchematicWiring method of my presenter. Is this the right place ? Maurizio – Maurizio Ferreira Aug 03 '16 at 21:08
1

In Microsoft Windows, icons are typically stored in a DLL. You should be able to use an icon explorer or editing tool to see the icons in a dll. For example, get IconExplorer from http://www.mitec.cz/iconex.html and try opening DolphinDR7.dll. Do the icons and numbers match what you see when you return a number in your application?

To determine (or override) the resource library used, see SessionManager>>#'defaultResLibPath'.

Typically, the getImageBlock is set using the property editor in the GUI editor, but setting it through code can work as well.

James Foster
  • 2,070
  • 10
  • 15
0

Wonderful Dolphin Smalltalk!

I had two problems

1) how and where to modify the getImageBlock method of my Treepresenter. 2) where to put the icons ad how to get the imageindex of each icon.

This is the solution :

1) it's not needed. The treeview sends an #iconImageIndex" message to my model this is handled by the default method (in the Object class) that send to my object the message #icon and to the result of this message (an icon) the message #iconIndex. This message is understood from the icon that answers with its own iconIndex.

So the only method I need to impement is #icon in my class Connection that I implemented as follows:

icon opened ifTrue: [^Connection connectedIcon] ifFalse: [^Connection unconnectedIcon]

In the class itself the two icons are imported in the image by evaluating the createIconMethod, as explained in the blog article 'Beauty with less Beast'.

So my problems are solved.

Thanks to all. Maurizio.