Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

84 lines
1.6 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //
  7. //=============================================================================//
  8. #include "cbase.h"
  9. #include "itreeitem.h"
  10. #include "mxtk/mxTreeView.h"
  11. #include "project.h"
  12. #include "scene.h"
  13. #include "soundentry.h"
  14. #include "vcdfile.h"
  15. #include "wavefile.h"
  16. #include "workspace.h"
  17. //-----------------------------------------------------------------------------
  18. // Purpose:
  19. // Input : *tree -
  20. // *parent -
  21. // Output : mxTreeViewItem
  22. //-----------------------------------------------------------------------------
  23. mxTreeViewItem *ITreeItem::FindItem( mxTreeView *tree, mxTreeViewItem *parent, bool recurse )
  24. {
  25. if ( !tree )
  26. return NULL;
  27. mxTreeViewItem *child = tree->getFirstChild( parent );
  28. while ( child )
  29. {
  30. ITreeItem *treeItem = (ITreeItem *)tree->getUserData( child );
  31. if ( treeItem )
  32. {
  33. if ( treeItem == this )
  34. {
  35. return child;
  36. }
  37. if ( recurse )
  38. {
  39. mxTreeViewItem *found = FindItem( tree, child, recurse );
  40. if ( found )
  41. {
  42. return found;
  43. }
  44. }
  45. }
  46. child = tree->getNextChild( child );
  47. }
  48. return NULL;
  49. }
  50. ITreeItem *ITreeItem::GetParentItem()
  51. {
  52. if ( GetSoundEntry() )
  53. {
  54. return GetSoundEntry()->GetOwnerVCDFile();
  55. }
  56. if ( GetVCDFile() )
  57. {
  58. return GetVCDFile()->GetOwnerScene();
  59. }
  60. if ( GetScene() )
  61. {
  62. return GetScene()->GetOwnerProject();
  63. }
  64. if ( GetProject() )
  65. {
  66. return GetProject()->GetOwnerWorkspace();
  67. }
  68. if ( GetWaveFile() )
  69. {
  70. return GetWaveFile()->GetOwnerSoundEntry();
  71. }
  72. return NULL;
  73. }