Hi...
currentl yI am stuck teaching my tree view to use a different icon when selected. I already managed to use my own icon for display, but it still does not change. here is what I did: First, I have overridden onViewAvailable in MyShell presenter to set the appropriate ImageManagers: MyShell>>onViewAvailable super onViewAvailable. ((self presenterNamed: 'projectTree') view) imageManager: self imageManager; stateImageManager: self stateImageManager. ((self presenterNamed: 'fileList') view) imageManager: self imageManager; stateImageManager: self stateImageManager The imageManager and stateImageManager objects I have checked with an inspect on imageManager imageAt: 1 and stateImageManager imageAt: 1 They return different images. The getImageBlock: property of the 'projectTree' view is [ : item | 1]. Now, the 1st icon of imageManager is always shown, regardless whether a tree item is seleced or not. Unfortunately I found no docu on stateImageManager, but I thought its purpose is probably to show different icons when items get selected?! Thanks for any help! Ciao ...Jochen |
fixed the problem with an getImageBlock that compares the node against the
current selection. Still, I wonder what the stateImageManager is good for?! Any idea? Ciao ...Jochen |
Jochen,
> Still, I wonder what the stateImageManager is good for?! Any idea? I had a mooch around MSDN and found the following which _sort_ of explains it. Can't say I've ever used them though. Regards Ian Tree-View Image Lists Each item in a tree-view control can have four bitmapped images associated with it. a.. An image, such as an open folder, displayed when the item is selected. b.. An image, such as a closed folder, displayed when the item is not selected. c.. An overlay image that is drawn transparently over the selected or nonselected image. d.. A state image, which is an additional image displayed to the left of the selected or nonselected image. You can use state images, such as checked and cleared check boxes, to indicate application-defined item states. By default, a tree-view control does not display item images. To display item images, you must create image lists and associate them with the control. For more information about image lists, see Image Lists. A tree-view control can have two image lists: a normal image list and a state image list. A normal image list stores the selected, nonselected, and overlay images. A state image list stores state images. Use the ImageList_Create function to create an image list, and use other image list functions to add bitmaps to the image list. Then, to associate the image list with the tree-view control, use the TVM_SETIMAGELIST message. The TVM_GETIMAGELIST message retrieves a handle to one of a tree-view control's image lists. This message is useful if you need to add more images to the list. In addition to the selected and nonselected images, a tree-view control's normal image list can contain up to four overlay images. Overlay images are identified by a one-based index and are designed to be drawn transparently over the selected and nonselected images. To assign an overlay mask index to an image in the normal image list, call the ImageList_SetOverlayImage function. By default, all items display the first image in the normal image list for both the selected and nonselected states. Also, by default, items do not display overlay images or state images. You can change these default behaviors for an item by sending the TVM_INSERTITEM or TVM_SETITEM message. These messages use the TVITEM structure to specify image list indexes for an item. To specify an item's selected and nonselected images, set the TVIF_SELECTEDIMAGE and TVIF_IMAGE bits in the mask member of the TVITEM structure and specify indexes from the control's normal image list in the iSelectImage and iImage members. Alternatively, you can specify the I_IMAGECALLBACK value in iSelectImage and iImage instead of specifying indexes. This causes the control to query its parent window for an image list index each time the item is about to be redrawn. The control sends the TVN_GETDISPINFO notification message to retrieve the index. To associate an overlay image with an item, use the INDEXTOOVERLAYMASK macro to specify an overlay mask index in the state member of the item's TVITEM structure. You must also set the TVIS_OVERLAYMASK bits in the stateMask member. Overlay mask indexes are one-based; an index of zero indicates that no overlay image was specified. State images are stored in a separate state image list and identified by their index. To specify the state image list, send a TVM_SETIMAGELIST message. Unlike the list-view control, which uses a one-based index to identify state images, tree-view control state images are identified by a zero-based index. However, an index of zero indicates that the item does not have a state image. Consequently, image zero cannot be used as a state image. For further discussion of item states and state images, see Tree-View Item States Overview |
Free forum by Nabble | Edit this page |