tags:

views:

324

answers:

1

I am working on a SWT Tree similar to the one here, however, I want to be able to show + signs in some cases instead of - for an expanded tree item. Is this possible ?

If not, is there Windows API to have custom icons for the expanded/collapsed state of a tree item ?

+1  A: 

The SWT Tree component makes use of native Tree widget if available, for example in case of Windows - it uses native widget while on Linux (depends on the UI engine being used), it may create custom tree on its own.

On the OS where it uses native Tree widget, it's not possible to customize the + and - icons.

As Ali suggested (see http://msdn.microsoft.com/en-us/library/bb773568%28VS.85%29.aspx), you may wish to use TVE_EXPANDPARTIAL, but keep in mind that the code will be OS dependent (even within versions of Windows).

You may, however, wish you use a custom image - using getImage() method in the TreeContentProvider to indicate the otherwise rather than relying on TVE_EXPANDPARTIAL. This will also ensure that your code is OS independent.

MasterGaurav
Thanks! TreeContentProvider is not part of SWT though ... Not sure how you you would do it but you bring up a good point about the code having to be OS dependent. I ended up implementing a 64 bit version and a 32 bit version of SWTTree subclass.
Ali
Ah! I forgot... it's part of JFace. Related class is TreeViewer.
MasterGaurav
setImage doesn't actually change the +/- icon. It adds an image to the right of +/- icon.
Ali
Agree. It does not change +/- icon but can be used to give the user an indication about what's happening / about-to-happen / can-happen
MasterGaurav