doom3-gpl
Doom 3 GPL source release
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
MaterialTreeView.h
Go to the documentation of this file.
1 /*
2 ===========================================================================
3 
4 Doom 3 GPL Source Code
5 Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
6 
7 This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
8 
9 Doom 3 Source Code is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
13 
14 Doom 3 Source Code is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18 
19 You should have received a copy of the GNU General Public License
20 along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
21 
22 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.
23 
24 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.
25 
26 ===========================================================================
27 */
28 #pragma once
29 
30 #include <afxcview.h>
31 #include "../common/PropTree/PropTreeView.h"
32 #include "MaterialEditor.h"
33 #include "MaterialView.h"
34 
38 typedef struct {
40  HTREEITEM treeItem;
42 
46 class MaterialTreeView : public CTreeView, public MaterialView {
47 
48 public:
49  virtual ~MaterialTreeView();
50 
51  void InitializeMaterialList(bool includeFile = true, const char* filename = NULL);
52  void BuildMaterialList(bool includeFile = true, const char* filename = NULL);
53 
54  //Material Interface
55  virtual void MV_OnMaterialChange(MaterialDoc* pMaterial);
56  virtual void MV_OnMaterialApply(MaterialDoc* pMaterial);
57  virtual void MV_OnMaterialSaved(MaterialDoc* pMaterial);
58  virtual void MV_OnMaterialAdd(MaterialDoc* pMaterial);
59  virtual void MV_OnMaterialDelete(MaterialDoc* pMaterial);
60  virtual void MV_OnMaterialNameChanged(MaterialDoc* pMaterial, const char* oldName);
61  virtual void MV_OnFileReload(const char* filename);
62 
63  bool CanCopy();
64  bool CanPaste();
65  bool CanCut();
66  bool CanDelete();
67  bool CanRename();
68  bool CanSaveFile();
70 
71  bool FindNextMaterial(MaterialSearchData_t* searchData);
72  HTREEITEM FindNextMaterial(HTREEITEM item, MaterialSearchData_t* searchData);
73  HTREEITEM GetNextSeachItem(HTREEITEM item, bool stayInFile);
74 
75  void DeleteFolder(HTREEITEM item, bool addUndo = true);
76  HTREEITEM AddFolder(const char* name, HTREEITEM parent);
77  void RenameFolder(HTREEITEM item, const char* name);
78 
79 
80 protected:
82  DECLARE_DYNCREATE(MaterialTreeView)
83 
84 
87  enum {
88  TYPE_ROOT = 0,
93  };
94 
95  //Overrides
96  virtual BOOL PreTranslateMessage(MSG* pMsg);
97 
98  //Window Messages
99  afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
100  afx_msg void OnTvnSelchanged(NMHDR *pNMHDR, LRESULT *pResult);
101  afx_msg void OnTvnBeginlabeledit(NMHDR *pNMHDR, LRESULT *pResult);
102  afx_msg void OnTvnEndlabeledit(NMHDR *pNMHDR, LRESULT *pResult);
103  afx_msg void OnContextMenu(CWnd* pWnd, CPoint point);
104  afx_msg void OnNMRclick(NMHDR *pNMHDR, LRESULT *pResult);
105  afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);
106  afx_msg void OnTvnBegindrag(NMHDR *pNMHDR, LRESULT *pResult);
107  afx_msg void OnMouseMove(UINT nFlags, CPoint point);
108  afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
109 
110  //Menu Commands
111  afx_msg void OnApplyMaterial();
112  afx_msg void OnApplyFile();
113  afx_msg void OnApplyAll();
114  afx_msg void OnSaveMaterial();
115  afx_msg void OnSaveFile();
116  afx_msg void OnSaveAll();
117  afx_msg void OnRenameMaterial();
118  afx_msg void OnAddMaterial();
119  afx_msg void OnAddFolder();
120  afx_msg void OnDeleteMaterial();
121  afx_msg void OnReloadFile();
122  afx_msg void OnCut();
123  afx_msg void OnCopy();
124  afx_msg void OnPaste();
125 
126  //Internal Messages
127  afx_msg LRESULT OnRenameFolderComplete(WPARAM wParam, LPARAM lParam);
128  afx_msg LRESULT OnRenameMaterialComplete(WPARAM wParam, LPARAM lParam);
129 
130  DECLARE_MESSAGE_MAP()
131 
132 
133  //Utility methods
134  void RenameMaterial(HTREEITEM item, const char* originalName);
135  bool GetFileName(HTREEITEM item, idStr& out);
136  idStr GetMediaPath(HTREEITEM item, DWORD type);
137  void GetMaterialPaths(HTREEITEM item, idList<MaterialTreeItem_t>* list);
138  void AddStrList(const char *root, idStrList *list, bool includeFile);
139  void PopupMenu(CPoint* pt);
140  void SetItemImage(HTREEITEM item, bool mod, bool apply, bool children);
141 
142 
143  //Methods for working with the quicktree
144  void CleanLookupTrees(HTREEITEM item);
145  void BuildLookupTrees(HTREEITEM item);
146  idStr GetQuicktreePath(HTREEITEM item);
147 
148 
149 protected:
150  CImageList m_image;
152 
153  //Hashtables for quick lookups
154  idHashTable<HTREEITEM> quickTree;
157 
158 
159  //Member variables for renaming folders
160  HTREEITEM renamedFolder;
162 
163  CImageList* dragImage;
164  bool bDragging;
165  CPoint dropPoint;
166  HTREEITEM dragItem;
167 
168  //Hover Expand
169  HTREEITEM hoverItem;
171 
173 };
174 
175 
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct)
Called by the MFC framework as the view is being created.
virtual BOOL PreTranslateMessage(MSG *pMsg)
Handles the keyboard shortcut for delete.
afx_msg LRESULT OnRenameMaterialComplete(WPARAM wParam, LPARAM lParam)
This message is sent after the label edit is complete to ensure that the sorting stays consistent...
MaterialTreeView()
Constructor for MaterialTreeView.
virtual void MV_OnFileReload(const char *filename)
Called when a file has been reloaded.
CONST PIXELFORMATDESCRIPTOR UINT
Definition: win_qgl.cpp:47
virtual void MV_OnMaterialDelete(MaterialDoc *pMaterial)
Called when a material is deleted.
afx_msg void OnAddMaterial()
Adds a new material.
virtual void MV_OnMaterialSaved(MaterialDoc *pMaterial)
Called when the material changes have been saved.
#define const
Definition: getdate.c:251
afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
Handles keyboard shortcut for cut, copy and paste.
void AddStrList(const char *root, idStrList *list, bool includeFile)
Adds a string list of materials to the tree creating the proper hierarchy.
DWORD
Definition: win_qgl.cpp:61
idHashTable< HTREEITEM > quickTree
afx_msg void OnNMRclick(NMHDR *pNMHDR, LRESULT *pResult)
Displays the popup menu.
idHashTable< HTREEITEM > fileToTree
void InitializeMaterialList(bool includeFile=true, const char *filename=NULL)
Clears the tree and rebuilds it.
afx_msg void OnLButtonUp(UINT nFlags, CPoint point)
Handles the end of a drag copy/move when the user releases the left mouse button. ...
virtual ~MaterialTreeView()
Destructor for MaterialTreeView.
afx_msg void OnSaveAll()
Save all materials that have been changed.
virtual void MV_OnMaterialChange(MaterialDoc *pMaterial)
Called when the material has changed but not applied.
void GetMaterialPaths(HTREEITEM item, idList< MaterialTreeItem_t > *list)
Creates a list of material paths for all materials under the provided item.
GLuint GLuint GLsizei GLenum type
Definition: glext.h:2845
void BuildLookupTrees(HTREEITEM item)
Build the lookup tree for a given item and all of its children.
HTREEITEM AddFolder(const char *name, HTREEITEM parent)
Adds a new material folder.
#define BOOL
Definition: mprintf.c:71
afx_msg void OnSaveFile()
Saves all materials in the selected file.
void BuildMaterialList(bool includeFile=true, const char *filename=NULL)
Builds the tree of materials.
afx_msg void OnTvnBeginlabeledit(NMHDR *pNMHDR, LRESULT *pResult)
Determines if a tree item's label can be edited.
void SetItemImage(HTREEITEM item, bool mod, bool apply, bool children)
Sets the appropriate item image based on the state of the item.
afx_msg LRESULT OnRenameFolderComplete(WPARAM wParam, LPARAM lParam)
This message is sent after the label edit is complete to actually perform the rename operation...
Responsible for managing a single material that is being viewed and/or edited.
Definition: MaterialDoc.h:67
void DeleteFolder(HTREEITEM item, bool addUndo=true)
Deletes a given folder.
bool FindNextMaterial(MaterialSearchData_t *searchData)
Searches for a material given the supplied search parameters.
afx_msg void OnPaste()
Performs a paste operation.
virtual void MV_OnMaterialNameChanged(MaterialDoc *pMaterial, const char *oldName)
Called when the material name has changed.
bool CanPaste()
Returns true if the user can paste an item in the copy buffer.
afx_msg void OnCut()
Performs a cut operation.
MaterialView Interface.
Definition: MaterialView.h:38
void PopupMenu(CPoint *pt)
Displays the popup menu with all of the appropriate menu items enabled.
#define NULL
Definition: Lib.h:88
afx_msg void OnTvnBegindrag(NMHDR *pNMHDR, LRESULT *pResult)
Begins the process of a drag cut/copy.
bool CanSaveFile()
Returns true if the currently selected file needs to be saved.
afx_msg void OnAddFolder()
Adds a new folder.
bool CanCut()
Returns true if the user can cut the selected item.
HTREEITEM GetNextSeachItem(HTREEITEM item, bool stayInFile)
Returns the next item to search or NULL if there is nothing else to search.
virtual void MV_OnMaterialApply(MaterialDoc *pMaterial)
Called when the material changes have been applied.
idList< MaterialTreeItem_t > affectedMaterials
void RenameMaterial(HTREEITEM item, const char *originalName)
Handles all of the little problems associated with renaming a folder.
afx_msg void OnApplyAll()
Applies all materials that need to be applied.
idStr GetSaveFilename()
Returns the filename of currently selected file.
bool CanCopy()
Returns true if the user can copy the selected item.
Structure used to store the user defined search parameters.
afx_msg void OnMouseMove(UINT nFlags, CPoint point)
Handles mouse movement as an item is being dragged.
afx_msg void OnDeleteMaterial()
Deletes a material or material folder.
A tree view of all the materials that have been defined.
bool GetFileName(HTREEITEM item, idStr &out)
Returns the filename of the provided item.
Structure used associate a material name with a tree item.
idHashTable< HTREEITEM > materialToTree
const GLcharARB * name
Definition: glext.h:3629
afx_msg void OnCopy()
Performs a copy operation.
Definition: Str.h:116
afx_msg void OnTvnSelchanged(NMHDR *pNMHDR, LRESULT *pResult)
Changes the selected material when the select tree item changes.
typedef void(APIENTRYP PFNGLBLENDCOLORPROC)(GLclampf red
bool CanDelete()
Returns true if the user can delete the selected item.
#define protected
Definition: TypeInfo.cpp:31
void CleanLookupTrees(HTREEITEM item)
Cleans the lookup tables for the provided item and all children.
afx_msg void OnTvnEndlabeledit(NMHDR *pNMHDR, LRESULT *pResult)
Makes sure that a rename operation can be performed after a label edit is complete and performs the f...
idStr GetQuicktreePath(HTREEITEM item)
Returns the quicktree path for a given item.
afx_msg void OnContextMenu(CWnd *pWnd, CPoint point)
Displays the popup menu.
CImageList * dragImage
afx_msg void OnReloadFile()
Reloads the selected file.
void RenameFolder(HTREEITEM item, const char *name)
Renames a material folder.
Definition: List.h:84
afx_msg void OnApplyFile()
Applies all materials in the currently selected file.
afx_msg void OnSaveMaterial()
Saves the selected material.
virtual void MV_OnMaterialAdd(MaterialDoc *pMaterial)
Called when a material is added.
afx_msg void OnRenameMaterial()
Begins a label edit to rename a material or material folder.
afx_msg void OnApplyMaterial()
Applies the current material.
bool CanRename()
Returns true if the user can rename the selected item.
idStr GetMediaPath(HTREEITEM item, DWORD type)
Returns the Doom III name for the provided item.