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.

291 lines
8.6 KiB

  1. // rootprop.h - Root node property pages header file
  2. #ifndef _ROOTPROP_H_
  3. #define _ROOTPROP_H_
  4. #include "scopenode.h"
  5. #include "atlwin.h"
  6. #include "atldlgs.h"
  7. #include "atlctrls.h"
  8. #include <list>
  9. class CRootNode;
  10. ////////////////////////////////////////////////////////////////////////////////////////
  11. // CEditObject adn CEditList
  12. class CEditObject
  13. {
  14. friend class CEditObjList;
  15. public:
  16. CEditObject(std::vector<CClassInfo>::iterator itObject = NULL)
  17. {
  18. m_itObjOriginal = itObject;
  19. m_pObjModified = NULL;
  20. m_bDeleted = FALSE;
  21. if (itObject)
  22. m_strName = itObject->Name();
  23. }
  24. virtual ~CEditObject() { SAFE_DELETE(m_pObjModified); }
  25. LPCWSTR Name() { return m_strName.c_str(); }
  26. BOOL IsDeleted() { return m_bDeleted; }
  27. CClassInfo& GetObject()
  28. {
  29. ASSERT(!m_bDeleted);
  30. return m_pObjModified ? *m_pObjModified : *m_itObjOriginal;
  31. }
  32. CClassInfo* GetModifiedObject()
  33. {
  34. ASSERT(!m_bDeleted);
  35. if (m_pObjModified == NULL)
  36. {
  37. ASSERT(m_itObjOriginal != NULL);
  38. m_pObjModified = new CClassInfo(*m_itObjOriginal);
  39. }
  40. ASSERT(m_pObjModified != NULL);
  41. return m_pObjModified;
  42. }
  43. private:
  44. std::vector<CClassInfo>::iterator m_itObjOriginal;
  45. CClassInfo* m_pObjModified;
  46. tstring m_strName;
  47. BOOL m_bDeleted;
  48. };
  49. typedef std::list<CEditObject>::iterator EditObjIter;
  50. class CEditObjList
  51. {
  52. public:
  53. CEditObjList() : m_lNotifyHandle(NULL), m_cRef(0), m_pvClasses(NULL) {}
  54. virtual ~CEditObjList()
  55. {
  56. if (m_lNotifyHandle != NULL)
  57. {
  58. MMCFreeNotifyHandle(m_lNotifyHandle);
  59. }
  60. }
  61. HRESULT Initialize(CRootNode* pRootNode, classInfo_vector& vClasses, LONG_PTR lNotifyHandle);
  62. void PageActive(HWND hwndPage);
  63. BOOL ApplyChanges(HWND hwndPage);
  64. EditObjIter FindObject(LPCWSTR pszName);
  65. EditObjIter AddObject(CClassInfo* pClassInfo);
  66. void DeleteObject(EditObjIter itObj);
  67. EditObjIter begin() { return m_ObjectList.begin(); }
  68. EditObjIter end() { return m_ObjectList.end(); }
  69. long size() { return m_ObjectList.size(); }
  70. CRootNode* RootNode() { return m_spRootNode; }
  71. ULONG AddRef() { return ++m_cRef; }
  72. ULONG Release()
  73. {
  74. ASSERT(m_cRef > 0);
  75. if (--m_cRef != 0)
  76. return m_cRef;
  77. delete this;
  78. return 0;
  79. }
  80. private:
  81. int m_iPageMax;
  82. CComPtr<CRootNode> m_spRootNode;
  83. classInfo_vector* m_pvClasses;
  84. std::list<CEditObject> m_ObjectList;
  85. LONG_PTR m_lNotifyHandle;
  86. ULONG m_cRef;
  87. };
  88. class CRootGeneralPage : public CPropertyPageImpl<CRootGeneralPage>
  89. {
  90. public:
  91. typedef CPropertyPageImpl<CRootGeneralPage> BC;
  92. // Constructor/destructor
  93. CRootGeneralPage(CEditObjList& ObjList): m_ObjList(ObjList) { m_ObjList.AddRef(); }
  94. virtual ~CRootGeneralPage() { m_ObjList.Release(); }
  95. enum { IDD = IDD_ROOT_GENERAL_PAGE };
  96. protected:
  97. BEGIN_MSG_MAP( CRootGeneralPage )
  98. COMMAND_HANDLER(IDC_COMMENTS, EN_CHANGE, OnChange)
  99. MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
  100. MESSAGE_HANDLER(WM_CLOSE, OnClose)
  101. CHAIN_MSG_MAP(BC)
  102. END_MSG_MAP()
  103. // message handlers
  104. LRESULT OnInitDialog( UINT mMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled );
  105. LRESULT OnClose( UINT mMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled );
  106. LRESULT OnChange( WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled );
  107. // overrrides
  108. BOOL OnSetActive();
  109. BOOL OnApply();
  110. void OnFinalMessage(HWND) { delete this; }
  111. private:
  112. CEditObjList& m_ObjList;
  113. BOOL m_bChgComment;
  114. };
  115. class CRootObjectPage : public CPropertyPageImpl<CRootObjectPage>
  116. {
  117. public:
  118. typedef CPropertyPageImpl<CRootObjectPage> BC;
  119. CRootObjectPage(CEditObjList& ObjList): m_ObjList(ObjList) { m_ObjList.AddRef(); }
  120. virtual ~CRootObjectPage() { m_ObjList.Release(); }
  121. enum { IDD = IDD_ROOT_OBJECT_PAGE };
  122. protected:
  123. BEGIN_MSG_MAP( CRootObjectPage )
  124. NOTIFY_HANDLER(IDC_OBJECTLIST, LVN_ITEMCHANGED, OnObjListChanged)
  125. COMMAND_HANDLER(IDC_ADDOBJECT, BN_CLICKED, OnAddObject)
  126. COMMAND_HANDLER(IDC_REMOVEOBJECT, BN_CLICKED, OnRemoveObject)
  127. MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
  128. CHAIN_MSG_MAP(BC)
  129. END_MSG_MAP()
  130. // handlers
  131. LRESULT OnInitDialog( UINT mMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled );
  132. LRESULT OnAddObject( WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled );
  133. LRESULT OnRemoveObject( WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled );
  134. LRESULT OnObjListChanged(int idCtrl, LPNMHDR pNMHDR, BOOL& bHandled);
  135. // overrrides
  136. BOOL OnSetActive();
  137. BOOL OnApply();
  138. void OnFinalMessage(HWND) { delete this; }
  139. private:
  140. CEditObjList& m_ObjList;
  141. EditObjIter m_itObjSelect;
  142. };
  143. class CRootMenuPage : public CPropertyPageImpl<CRootMenuPage>
  144. {
  145. public:
  146. typedef CPropertyPageImpl<CRootMenuPage> BC;
  147. CRootMenuPage(CEditObjList& ObjList): m_ObjList(ObjList) { m_ObjList.AddRef(); }
  148. virtual ~CRootMenuPage();
  149. enum { IDD = IDD_ROOT_MENU_PAGE };
  150. protected:
  151. BEGIN_MSG_MAP( CRootMenuPage )
  152. MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
  153. NOTIFY_HANDLER(IDC_MENULIST, LVN_ITEMCHANGED, OnMenuListChanged)
  154. NOTIFY_HANDLER(IDC_MENULIST, NM_DBLCLK, OnMenuListDblClk)
  155. COMMAND_HANDLER(IDC_OBJECTLIST, CBN_SELENDOK, OnObjectSelect )
  156. COMMAND_HANDLER(IDC_ADDMENU, BN_CLICKED, OnAddMenu)
  157. COMMAND_HANDLER(IDC_REMOVEMENU, BN_CLICKED, OnRemoveMenu)
  158. COMMAND_HANDLER(IDC_EDITMENU, BN_CLICKED, OnEditMenu)
  159. COMMAND_HANDLER(IDC_MOVEUP, BN_CLICKED, OnMoveUpDown)
  160. COMMAND_HANDLER(IDC_MOVEDOWN, BN_CLICKED, OnMoveUpDown);
  161. CHAIN_MSG_MAP(BC)
  162. END_MSG_MAP()
  163. // handlers
  164. LRESULT OnInitDialog( UINT mMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled );
  165. LRESULT OnObjectSelect( WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled );
  166. LRESULT OnAddMenu( WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled );
  167. LRESULT OnRemoveMenu( WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled );
  168. LRESULT OnEditMenu( WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled );
  169. LRESULT OnMenuListChanged(int idCtrl, LPNMHDR pNMHDR, BOOL& bHandled);
  170. LRESULT OnMenuListDblClk(int idCtrl, LPNMHDR pNMHDR, BOOL& bHandled);
  171. LRESULT OnMoveUpDown( WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled );
  172. // overrrides
  173. BOOL OnSetActive();
  174. BOOL OnApply();
  175. void OnFinalMessage(HWND) { delete this; }
  176. // implementation
  177. void DisplayMenus();
  178. private:
  179. CListViewCtrl m_MenuLV;
  180. CComboBox m_ObjectCB;
  181. CEditObjList& m_ObjList;
  182. EditObjIter m_itObjSelect;
  183. tstring m_strObjSelect;
  184. };
  185. class CRootViewPage : public CPropertyPageImpl<CRootViewPage>
  186. {
  187. public:
  188. typedef CPropertyPageImpl<CRootViewPage> BC;
  189. CRootViewPage(CEditObjList& ObjList): m_ObjList(ObjList) { m_ObjList.AddRef(); }
  190. virtual ~CRootViewPage();
  191. enum { IDD = IDD_ROOT_VIEW_PAGE };
  192. protected:
  193. BEGIN_MSG_MAP( CRootViewPage )
  194. MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
  195. NOTIFY_HANDLER(IDC_COLUMNLIST, LVN_ITEMCHANGED, OnColumnListChanged)
  196. COMMAND_HANDLER( IDC_OBJECTLIST, CBN_SELENDOK, OnObjectSelect )
  197. COMMAND_HANDLER(IDC_ADDCOLUMN, BN_CLICKED, OnAddColumn)
  198. COMMAND_HANDLER(IDC_REMOVECOLUMN, BN_CLICKED, OnRemoveColumn)
  199. CHAIN_MSG_MAP(BC)
  200. END_MSG_MAP()
  201. // handlers
  202. LRESULT OnInitDialog( UINT mMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled );
  203. LRESULT OnObjectSelect( WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled );
  204. LRESULT OnAddColumn( WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled );
  205. LRESULT OnRemoveColumn( WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled );
  206. LRESULT OnColumnListChanged(int idCtrl, LPNMHDR pNMHDR, BOOL& bHandled);
  207. // overrrides
  208. BOOL OnSetActive();
  209. BOOL OnApply();
  210. void OnFinalMessage(HWND) { delete this; }
  211. // implementation
  212. void DisplayColumns();
  213. private:
  214. CListViewCtrl m_ColumnLV;
  215. CComboBox m_ObjectCB;
  216. CEditObjList& m_ObjList;
  217. EditObjIter m_itObjSelect;
  218. tstring m_strObjSelect;
  219. };
  220. #endif // _ROOTPROP_H_