Leaked source code of windows server 2003
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.

278 lines
9.4 KiB

  1. /******************************************************************************
  2. Header File: Project Node.H
  3. This describes the Project Node. This keeps the Project Control Window code
  4. simple, by having a project node which can create new intances of itself,
  5. import itself from another source, edit itself, etc. Most Menu and tree view
  6. notification messages wind up being handled by being passed to the currently
  7. selected node on the tree, which will be an instance of a class derived from
  8. this one.
  9. Copyright (c) 1996 by Microsoft Corporation
  10. A Pretty Penny Enterprises Production
  11. Change History:
  12. 12-16-96 KjelgaardR@acm.org Created it
  13. ******************************************************************************/
  14. #if !defined(PROJECT_NODES)
  15. #define PROJECT_NODES
  16. #if defined(LONG_NAMES)
  17. #include "Utility Classes.H"
  18. #else
  19. #include "Utility.H"
  20. #endif
  21. // CBasicNode - base class for stuff we can manipulate
  22. class CBasicNode : public CObject {
  23. DECLARE_SERIAL(CBasicNode)
  24. CBasicNode* m_pcbnWorkspace;// Basic Node for the workspace
  25. protected:
  26. CString m_csName; // These should always have a name...
  27. HTREEITEM m_hti; // Handle in the owning tree view
  28. CTreeCtrl *m_pctcOwner; // The window that owns us
  29. CMDIChildWnd *m_pcmcwEdit; // The window we're being edited in.
  30. CDocument *m_pcdOwner; // Document we are part of
  31. CWordArray m_cwaMenuID; // Menu auto-fill
  32. bool m_bUniqueNameChange ; // True iff name change to make it
  33. // uniqe. (See UniqueName().)
  34. public:
  35. CBasicNode();
  36. ~CBasicNode();
  37. CString Name() const { return m_csName; }
  38. HTREEITEM Handle() const { return m_hti; }
  39. void NoteOwner(CDocument& cdOwner) { m_pcdOwner = &cdOwner; }
  40. CDocument* GetOwner() { return m_pcdOwner ; }
  41. void SetWorkspace(CBasicNode* pcbnWS) { m_pcbnWorkspace = pcbnWS; }
  42. CBasicNode* GetWorkspace() { return m_pcbnWorkspace ; }
  43. void Changed(BOOL bModified = TRUE, BOOL bWriteRC = FALSE) ;
  44. void UniqueName(bool bsizematters, bool bfile, LPCTSTR lpstrpath = _T("")) ;
  45. // Name ourselves and children- default to just our name, no children
  46. virtual void Fill(CTreeCtrl *pctcWhere,
  47. HTREEITEM htiParent = TVI_ROOT);
  48. // Overridable functions to allow polymorphic tree node handling
  49. virtual void ContextMenu(CWnd *pcw, CPoint cp);
  50. virtual CMDIChildWnd *CreateEditor() { return NULL; }
  51. virtual BOOL CanEdit() const { return TRUE; }
  52. virtual void Delete() { } // Default is don't honor it!
  53. virtual void Import() { } // Never at this level!
  54. // This override is called if our label is edited, or we are otherwise
  55. // renamed...
  56. virtual BOOL Rename(LPCTSTR lpstrNewName);
  57. void Edit() ;
  58. void OnEditorDestroyed() { m_pcmcwEdit = NULL ; }
  59. CMDIChildWnd* GetEditor() ;
  60. virtual void Serialize(CArchive& car);
  61. void WorkspaceChange(BOOL bModified = TRUE, BOOL bWriteRC = FALSE) {
  62. if (m_pcbnWorkspace)
  63. m_pcbnWorkspace -> Changed(bModified, bWriteRC);
  64. }
  65. };
  66. // Sometimes, it is useful to know something about the type of data managed by
  67. // a fixed node or a strings node. The following enumeration one way to do
  68. // this.
  69. typedef enum {
  70. FNT_RESOURCES = 0,
  71. FNT_UFMS,
  72. FNT_GTTS,
  73. FNT_GPDS,
  74. FNT_STRINGS,
  75. FNT_OTHER,
  76. FNT_UNKNOWN
  77. } FIXEDNODETYPE ;
  78. // CStringsNode is a hybrid between CFixedNode and CProjectNode. It is a fixed
  79. // node that can be opened and edited.
  80. class CStringsNode : public CBasicNode {
  81. unsigned m_uidName;
  82. CSafeObArray &m_csoaDescendants;
  83. CMultiDocTemplate* m_pcmdt; // Used for importing data
  84. CRuntimeClass* m_pcrc; // The second half of the import
  85. FIXEDNODETYPE m_fntType ; // Node type
  86. int m_nFirstSelRCID ; // RC ID of first entry to select in editor
  87. DECLARE_DYNAMIC(CStringsNode)
  88. public:
  89. CStringsNode(unsigned uidName, CSafeObArray& csoa,
  90. FIXEDNODETYPE fnt = FNT_OTHER, CMultiDocTemplate *pcmdt = NULL,
  91. CRuntimeClass *pcrc = NULL);
  92. void SetMenu(CWordArray& cwaSpec) { m_cwaMenuID.Copy(cwaSpec); }
  93. virtual BOOL CanEdit() const { return TRUE; }
  94. virtual void Fill(CTreeCtrl *pctc, HTREEITEM hti);
  95. virtual CMDIChildWnd* CreateEditor();
  96. int GetFirstSelRCID() { return m_nFirstSelRCID ; }
  97. void SetFirstSelRCID(int nrcid) { m_nFirstSelRCID = nrcid ; }
  98. };
  99. class CFileNode : public CBasicNode {
  100. BOOL m_bEditPath, m_bCheckForValidity;
  101. CString m_csExtension, m_csPath;
  102. DECLARE_SERIAL(CFileNode)
  103. const CString ViewName() {
  104. return m_bEditPath ? m_csPath + m_csName : m_csName;
  105. }
  106. public:
  107. CFileNode();
  108. // Attributes
  109. CString NameExt() const { return Name() + m_csExtension; }
  110. CString FullName() const { return m_csPath + Name() + m_csExtension; }
  111. const CString Path() const { return m_csPath; }
  112. const CString Extension() const { return m_csExtension; }
  113. virtual BOOL CanEdit() const;
  114. // Operations
  115. void SetExtension(LPCTSTR lpstrExt) { m_csExtension = lpstrExt; }
  116. void AllowPathEdit(BOOL bOK = TRUE) { m_bEditPath = bOK; }
  117. void EnableCreationCheck(BOOL bOn = TRUE) { m_bCheckForValidity = bOn; }
  118. void SetPath(LPCTSTR lpstrNew) { m_csPath = lpstrNew ; }
  119. void SetPathAndName(LPCTSTR lpstrpath, LPCTSTR lpstrname) ;
  120. // Overriden CBasicNode operations
  121. virtual BOOL Rename(LPCTSTR lpstrNewName);
  122. virtual void Fill(CTreeCtrl* pctc, HTREEITEM htiParent);
  123. virtual void Serialize(CArchive& car);
  124. };
  125. // This class is used to manage the RC ID nodes in the Workspace view.
  126. // Currently, there is one of these for each UFM and GTT node.
  127. //
  128. // Note: This class must be enhanced to support extra functionality.
  129. class CRCIDNode : public CBasicNode {
  130. int m_nRCID; // RC ID
  131. FIXEDNODETYPE m_fntType ; // Node type
  132. DECLARE_SERIAL(CRCIDNode)
  133. public:
  134. CRCIDNode() ;
  135. ~CRCIDNode() {} ;
  136. virtual void Fill(CTreeCtrl *pctc, HTREEITEM hti, int nid, FIXEDNODETYPE fnt) ;
  137. int nGetRCID() { return m_nRCID ; }
  138. void nSetRCID(int nrcid) { m_nRCID = nrcid ; }
  139. FIXEDNODETYPE fntGetType() { return m_fntType ; }
  140. void fntSetType(FIXEDNODETYPE fnt) { m_fntType = fnt ; }
  141. virtual void Serialize(CArchive& car);
  142. void BuildDisplayName() ;
  143. };
  144. // We bring it all together in a limited fashion at least, for the project
  145. // level node- it always contains a file name node.
  146. class CProjectNode : public CBasicNode {
  147. DECLARE_SERIAL(CProjectNode)
  148. bool m_bRefFlag ; // Referenced flag used in WS checking
  149. protected:
  150. CMultiDocTemplate* m_pcmdt;
  151. public:
  152. CProjectNode();
  153. CFileNode m_cfn;
  154. CRCIDNode m_crinRCID; // Workspace view, RC ID node
  155. const CString FileName() const { return m_cfn.FullName(); }
  156. const CString FilePath() const { return m_cfn.Path(); }
  157. const CString FileTitle() const { return m_cfn.Name(); }
  158. const CString FileExt() const { return m_cfn.Extension(); }
  159. const CString FileTitleExt() const { return m_cfn.NameExt(); }
  160. const CString GetPath() const { return m_cfn.Path() ; }
  161. void SetPath(LPCTSTR lpstrNew) { m_cfn.SetPath(lpstrNew) ; }
  162. BOOL SetFileName(LPCTSTR lpstrNew) { return m_cfn.Rename(lpstrNew); }
  163. void EditorInfo(CMultiDocTemplate* pcmdt) { m_pcmdt = pcmdt; }
  164. BOOL ReTitle(LPCTSTR lpstrNewName) {
  165. return m_cfn.CBasicNode::Rename(lpstrNewName);
  166. }
  167. virtual void Fill(CTreeCtrl *pctcWhere, HTREEITEM htiParent = TVI_ROOT,
  168. unsigned urcid = -1, FIXEDNODETYPE fnt = FNT_UNKNOWN);
  169. virtual void Serialize(CArchive& car);
  170. // RC ID management routines
  171. int nGetRCID() { return m_crinRCID.nGetRCID() ; }
  172. void nSetRCID(int nrcid) { m_crinRCID.nSetRCID(nrcid) ; }
  173. void ChangeID(CRCIDNode* prcidn, int nnewid, CString csrestype) ;
  174. // Reference flag management routines
  175. bool GetRefFlag() { return m_bRefFlag ; }
  176. void SetRefFlag() { m_bRefFlag = true ; }
  177. void ClearRefFlag() { m_bRefFlag = false ; }
  178. };
  179. // This is a special class for nodes with constant names. IE, labels for
  180. // groups of UFMs, GTTs, etc most of the time.
  181. class CFixedNode : public CBasicNode {
  182. unsigned m_uidName;
  183. CSafeObArray &m_csoaDescendants;
  184. CMultiDocTemplate* m_pcmdt; // Used for importing data
  185. CRuntimeClass* m_pcrc; // The second half of the import
  186. FIXEDNODETYPE m_fntType ; // Node type
  187. DECLARE_DYNAMIC(CFixedNode)
  188. public:
  189. CFixedNode(unsigned uidName, CSafeObArray& csoa, FIXEDNODETYPE fnt = FNT_OTHER,
  190. CMultiDocTemplate *pcmdt = NULL, CRuntimeClass *pcrc = NULL);
  191. void SetMenu(CWordArray& cwaSpec) { m_cwaMenuID.Copy(cwaSpec); }
  192. // GPD Deletion support
  193. void Zap(CProjectNode * pcpn, BOOL bdelfile) ;
  194. virtual BOOL CanEdit() const { return FALSE; }
  195. virtual void Import();
  196. void Copy(CProjectNode *pcpnsrc, CString csorgdest) ;
  197. int GetNextRCID() ;
  198. virtual void Fill(CTreeCtrl *pctc, HTREEITEM hti);
  199. bool IsFileInWorkspace(LPCTSTR strfspec) ;
  200. bool IsRCIDUnique(int nid) ;
  201. FIXEDNODETYPE GetType() { return m_fntType ; }
  202. };
  203. #endif