- wxTreeViewItem tvItem(item, TVIF_IMAGE | TVIF_SELECTEDIMAGE);
- tvItem.iSelectedImage = imageSel;
- tvItem.iImage = image;
- DoSetItem(&tvItem);
-}
-
-int wxTreeCtrl::GetItemImage(const wxTreeItemId& item,
- wxTreeItemIcon which) const
-{
- if ( HasIndirectData(item) )
- {
- return DoGetItemImageFromData(item, which);
- }
-
- UINT mask;
- switch ( which )
- {
- default:
- wxFAIL_MSG( wxT("unknown tree item image type") );
-
- case wxTreeItemIcon_Normal:
- mask = TVIF_IMAGE;
- break;
-
- case wxTreeItemIcon_Selected:
- mask = TVIF_SELECTEDIMAGE;
- break;
-
- case wxTreeItemIcon_Expanded:
- case wxTreeItemIcon_SelectedExpanded:
- return -1;
- }
-
- wxTreeViewItem tvItem(item, mask);
- DoGetItem(&tvItem);
-
- return mask == TVIF_IMAGE ? tvItem.iImage : tvItem.iSelectedImage;
-}
-
-void wxTreeCtrl::SetItemImage(const wxTreeItemId& item, int image,
- wxTreeItemIcon which)
-{
- int imageNormal, imageSel;
- switch ( which )
- {
- default:
- wxFAIL_MSG( wxT("unknown tree item image type") );
-
- case wxTreeItemIcon_Normal:
- imageNormal = image;
- imageSel = GetItemSelectedImage(item);
- break;
-
- case wxTreeItemIcon_Selected:
- imageNormal = GetItemImage(item);
- imageSel = image;
- break;
-
- case wxTreeItemIcon_Expanded:
- case wxTreeItemIcon_SelectedExpanded:
- if ( !HasIndirectData(item) )
- {
- // we need to get the old images first, because after we create
- // the wxTreeItemIndirectData GetItemXXXImage() will use it to
- // get the images
- imageNormal = GetItemImage(item);
- imageSel = GetItemSelectedImage(item);
-
- // if it doesn't have it yet, add it
- wxTreeItemIndirectData *data = new
- wxTreeItemIndirectData(this, item);
-
- // copy the data to the new location
- data->SetImage(imageNormal, wxTreeItemIcon_Normal);
- data->SetImage(imageSel, wxTreeItemIcon_Selected);
- }
-
- DoSetItemImageFromData(item, image, which);
-
- // reset the normal/selected images because we won't use them any
- // more - now they're stored inside the indirect data
- imageNormal =
- imageSel = I_IMAGECALLBACK;
- break;
- }
-
- // NB: at least in version 5.00.0518.9 of comctl32.dll we need to always
- // change both normal and selected image - otherwise the change simply
- // doesn't take place!
- DoSetItemImages(item, imageNormal, imageSel);
-}
-
-wxTreeItemData *wxTreeCtrl::GetItemData(const wxTreeItemId& item) const
-{
- wxTreeViewItem tvItem(item, TVIF_PARAM);
- if ( !DoGetItem(&tvItem) )
- {
- return NULL;
- }
-
- if ( HasIndirectData(item) )
- {
- return ((wxTreeItemIndirectData *)tvItem.lParam)->GetData();
- }
- else
- {
- return (wxTreeItemData *)tvItem.lParam;
- }