MaterialTreeView.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. /*
  2. ===========================================================================
  3. Doom 3 GPL Source Code
  4. Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
  5. This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
  6. Doom 3 Source Code is free software: you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation, either version 3 of the License, or
  9. (at your option) any later version.
  10. Doom 3 Source Code is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
  16. In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
  17. If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
  18. ===========================================================================
  19. */
  20. #pragma once
  21. #include <afxcview.h>
  22. #include "../common/PropTree/PropTreeView.h"
  23. #include "MaterialEditor.h"
  24. #include "MaterialView.h"
  25. /**
  26. * Structure used associate a material name with a tree item.
  27. */
  28. typedef struct {
  29. idStr materialName;
  30. HTREEITEM treeItem;
  31. } MaterialTreeItem_t;
  32. /**
  33. * A tree view of all the materials that have been defined.
  34. */
  35. class MaterialTreeView : public CTreeView, public MaterialView {
  36. public:
  37. virtual ~MaterialTreeView();
  38. void InitializeMaterialList(bool includeFile = true, const char* filename = NULL);
  39. void BuildMaterialList(bool includeFile = true, const char* filename = NULL);
  40. //Material Interface
  41. virtual void MV_OnMaterialChange(MaterialDoc* pMaterial);
  42. virtual void MV_OnMaterialApply(MaterialDoc* pMaterial);
  43. virtual void MV_OnMaterialSaved(MaterialDoc* pMaterial);
  44. virtual void MV_OnMaterialAdd(MaterialDoc* pMaterial);
  45. virtual void MV_OnMaterialDelete(MaterialDoc* pMaterial);
  46. virtual void MV_OnMaterialNameChanged(MaterialDoc* pMaterial, const char* oldName);
  47. virtual void MV_OnFileReload(const char* filename);
  48. bool CanCopy();
  49. bool CanPaste();
  50. bool CanCut();
  51. bool CanDelete();
  52. bool CanRename();
  53. bool CanSaveFile();
  54. idStr GetSaveFilename();
  55. bool FindNextMaterial(MaterialSearchData_t* searchData);
  56. HTREEITEM FindNextMaterial(HTREEITEM item, MaterialSearchData_t* searchData);
  57. HTREEITEM GetNextSeachItem(HTREEITEM item, bool stayInFile);
  58. void DeleteFolder(HTREEITEM item, bool addUndo = true);
  59. HTREEITEM AddFolder(const char* name, HTREEITEM parent);
  60. void RenameFolder(HTREEITEM item, const char* name);
  61. protected:
  62. MaterialTreeView();
  63. DECLARE_DYNCREATE(MaterialTreeView)
  64. /**
  65. * List of tree item types
  66. */
  67. enum {
  68. TYPE_ROOT = 0,
  69. TYPE_FOLDER,
  70. TYPE_FILE,
  71. TYPE_MATERIAL_FOLDER,
  72. TYPE_MATERIAL
  73. };
  74. //Overrides
  75. virtual BOOL PreTranslateMessage(MSG* pMsg);
  76. //Window Messages
  77. afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
  78. afx_msg void OnTvnSelchanged(NMHDR *pNMHDR, LRESULT *pResult);
  79. afx_msg void OnTvnBeginlabeledit(NMHDR *pNMHDR, LRESULT *pResult);
  80. afx_msg void OnTvnEndlabeledit(NMHDR *pNMHDR, LRESULT *pResult);
  81. afx_msg void OnContextMenu(CWnd* pWnd, CPoint point);
  82. afx_msg void OnNMRclick(NMHDR *pNMHDR, LRESULT *pResult);
  83. afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);
  84. afx_msg void OnTvnBegindrag(NMHDR *pNMHDR, LRESULT *pResult);
  85. afx_msg void OnMouseMove(UINT nFlags, CPoint point);
  86. afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
  87. //Menu Commands
  88. afx_msg void OnApplyMaterial();
  89. afx_msg void OnApplyFile();
  90. afx_msg void OnApplyAll();
  91. afx_msg void OnSaveMaterial();
  92. afx_msg void OnSaveFile();
  93. afx_msg void OnSaveAll();
  94. afx_msg void OnRenameMaterial();
  95. afx_msg void OnAddMaterial();
  96. afx_msg void OnAddFolder();
  97. afx_msg void OnDeleteMaterial();
  98. afx_msg void OnReloadFile();
  99. afx_msg void OnCut();
  100. afx_msg void OnCopy();
  101. afx_msg void OnPaste();
  102. //Internal Messages
  103. afx_msg LRESULT OnRenameFolderComplete(WPARAM wParam, LPARAM lParam);
  104. afx_msg LRESULT OnRenameMaterialComplete(WPARAM wParam, LPARAM lParam);
  105. DECLARE_MESSAGE_MAP()
  106. //Utility methods
  107. void RenameMaterial(HTREEITEM item, const char* originalName);
  108. bool GetFileName(HTREEITEM item, idStr& out);
  109. idStr GetMediaPath(HTREEITEM item, DWORD type);
  110. void GetMaterialPaths(HTREEITEM item, idList<MaterialTreeItem_t>* list);
  111. void AddStrList(const char *root, idStrList *list, bool includeFile);
  112. void PopupMenu(CPoint* pt);
  113. void SetItemImage(HTREEITEM item, bool mod, bool apply, bool children);
  114. //Methods for working with the quicktree
  115. void CleanLookupTrees(HTREEITEM item);
  116. void BuildLookupTrees(HTREEITEM item);
  117. idStr GetQuicktreePath(HTREEITEM item);
  118. protected:
  119. CImageList m_image;
  120. bool treeWithFile;
  121. //Hashtables for quick lookups
  122. idHashTable<HTREEITEM> quickTree;
  123. idHashTable<HTREEITEM> materialToTree;
  124. idHashTable<HTREEITEM> fileToTree;
  125. //Member variables for renaming folders
  126. HTREEITEM renamedFolder;
  127. idList<MaterialTreeItem_t> affectedMaterials;
  128. CImageList* dragImage;
  129. bool bDragging;
  130. CPoint dropPoint;
  131. HTREEITEM dragItem;
  132. //Hover Expand
  133. HTREEITEM hoverItem;
  134. DWORD hoverStartTime;
  135. bool internalChange;
  136. };