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
7.8 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1998 - 1998
  6. //
  7. // File: browser.h
  8. //
  9. //--------------------------------------------------------------------------
  10. #ifndef _BROWSER_H
  11. #define _BROWSER_H
  12. ///////////////////////////////////////////////////////////////////////////////
  13. // FORWARD DECLARATIONS
  14. class CTreeNode;
  15. class CDNSBrowseItem;
  16. class CDNSFilterCombo;
  17. class CDNSBrowserDlg;
  18. class CDNSCurrContainerCombo;
  19. class CDNSChildrenListView;
  20. class CPropertyPageHolderBase;
  21. ////////////////////////////////////////////////////////////////////////
  22. // CDNSComboBoxEx : simple C++/MFC wrapper for ComboBoxEx32 control
  23. class CDNSComboBoxEx : public CWnd
  24. {
  25. public:
  26. BOOL Create(DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID);
  27. // simple inlines
  28. HIMAGELIST SetImageList(HIMAGELIST himl);
  29. int GetCount() const;
  30. int GetCurSel() const;
  31. int SetCurSel(int nSelect);
  32. int InsertItem(const COMBOBOXEXITEM* pItem);
  33. LPARAM GetItemData(int nIndex) const;
  34. BOOL SetItemData(int nIndex, LPARAM lParam);
  35. void ResetContent();
  36. DWORD GetExtendedStyle() const;
  37. DWORD SetExtendedStyle(DWORD dwExMask, DWORD dwExStyle);
  38. };
  39. //////////////////////////////////////////////////////////////////////////
  40. // CDNSBrowseItem : proxy items for the nodes in the snapin
  41. typedef CList< CDNSBrowseItem*, CDNSBrowseItem* > CDNSBrowseItemList;
  42. class CDNSBrowseItem
  43. {
  44. public:
  45. CDNSBrowseItem()
  46. {
  47. m_nIndex = -1;
  48. m_pParent = NULL;
  49. m_pTreeNode = NULL;
  50. }
  51. ~CDNSBrowseItem()
  52. {
  53. RemoveChildren();
  54. if (m_pTreeNode != NULL)
  55. m_pTreeNode->DecrementSheetLockCount();
  56. }
  57. BOOL AddChild(CDNSBrowseItem* pChildBrowseItem);
  58. BOOL RemoveChildren(CDNSBrowseItem* pNotThisItem = NULL);
  59. // manipulation of CTreeNode pointer
  60. void SetTreeNode(CTreeNode* pTreeNode)
  61. {
  62. ASSERT(pTreeNode != NULL);
  63. pTreeNode->IncrementSheetLockCount();
  64. m_pTreeNode = pTreeNode;
  65. }
  66. CTreeNode* GetTreeNode() { return m_pTreeNode;}
  67. LPCTSTR GetSelectionString();
  68. // proxies for the CTreeNode functions
  69. int GetImageIndex(BOOL bOpenImage);
  70. LPCWSTR GetString(int nCol);
  71. BOOL IsContainer();
  72. // Master tree manipulation routines
  73. void AddTreeNodeChildren(CDNSFilterCombo* pFilter,
  74. CComponentDataObject* pComponentDataObject);
  75. private:
  76. void AddToContainerCombo(CDNSCurrContainerCombo* pCtrl,
  77. CDNSBrowseItem* pSelectedBrowseItem,
  78. int nIndent,int* pNCurrIndex);
  79. // DATA
  80. public:
  81. int m_nIndex; // index in the container combobox, for direct lookup
  82. CDNSBrowseItem* m_pParent; // parent in the browse tree
  83. private:
  84. CTreeNode* m_pTreeNode; // pointer to the node in the snapin master tree
  85. CDNSBrowseItemList m_childList; // list if children of the current node
  86. friend class CDNSChildrenListView;
  87. friend class CDNSCurrContainerCombo;
  88. };
  89. //////////////////////////////////////////////////////////////////////////
  90. // CDNSFilterCombo : dropdown list with filtering options and logic
  91. // NOTICE: the ordering will be the same as the strings in the filter combobox
  92. typedef enum
  93. {
  94. // these options are for containers
  95. SERVER = 0 ,
  96. ZONE_FWD,
  97. ZONE_REV,
  98. // these options are for records (leaves)
  99. RECORD_A,
  100. RECORD_CNAME,
  101. RECORD_A_AND_CNAME,
  102. RECORD_RP,
  103. RECORD_TEXT,
  104. RECORD_MB,
  105. RECORD_ALL,
  106. LAST // dummy item, just to know how many there are
  107. } DNSBrowseFilterOptionType;
  108. class CDNSFilterCombo : public CComboBox
  109. {
  110. public:
  111. CDNSFilterCombo() { m_option = LAST; }
  112. BOOL Initialize(UINT nCtrlID, UINT nIDFilterString, CDNSBrowserDlg* pDlg);
  113. void Set(DNSBrowseFilterOptionType option, LPCTSTR lpszExcludeServerName)
  114. {
  115. m_option = option;
  116. m_szExcludeServerName = lpszExcludeServerName;
  117. }
  118. DNSBrowseFilterOptionType Get() { return m_option;}
  119. void OnSelectionChange();
  120. BOOL CanAddToUIString(UINT n);
  121. BOOL IsValidTreeNode(CTreeNode* pTreeNode);
  122. BOOL IsValidResult(CDNSBrowseItem* pBrowseItem);
  123. void GetStringOf(CDNSBrowseItem* pBrowseItem, CString& szResult);
  124. private:
  125. DNSBrowseFilterOptionType m_option;
  126. CString m_szExcludeServerName;
  127. };
  128. //////////////////////////////////////////////////////////////////////////
  129. // CDNSCurrContainerCombo : deals with the selection of the current container
  130. class CDNSCurrContainerCombo : public CDNSComboBoxEx
  131. {
  132. public:
  133. BOOL Initialize(UINT nCtrlID, UINT nBitmapID, CDNSBrowserDlg* pDlg);
  134. CDNSBrowseItem* GetSelection();
  135. void InsertBrowseItem(CDNSBrowseItem* pBrowseItem, int nIndex, int nIndent);
  136. void SetTree(CDNSBrowseItem* pRootBrowseItem,
  137. CDNSBrowseItem* pSelectedBrowseItem);
  138. private:
  139. WTL::CImageList m_imageList;
  140. };
  141. //////////////////////////////////////////////////////////////////////////
  142. // CDNSChildrenListView : displays the list of childern for the current container
  143. class CDNSChildrenListView : public CListCtrl
  144. {
  145. public:
  146. CDNSChildrenListView() { m_pDlg = NULL;}
  147. BOOL Initialize(UINT nCtrlID, UINT nBitmapID, CDNSBrowserDlg* pDlg);
  148. void SetChildren(CDNSBrowseItem* pBrowseItem);
  149. CDNSBrowseItem* GetSelection();
  150. private:
  151. WTL::CImageList m_imageList;
  152. CDNSBrowserDlg* m_pDlg;
  153. };
  154. ///////////////////////////////////////////////////////////////////////////////
  155. // CDNSBrowserDlg : the browser itself
  156. class CBrowseExecContext; // fwd decl
  157. class CDNSBrowserDlg : public CHelpDialog
  158. {
  159. // Construction
  160. public:
  161. CDNSBrowserDlg(CComponentDataObject* pComponentDataObject, CPropertyPageHolderBase* pHolder,
  162. DNSBrowseFilterOptionType option, BOOL bEnableEdit = FALSE,
  163. LPCTSTR lpszExcludeServerName = NULL);
  164. ~CDNSBrowserDlg();
  165. virtual INT_PTR DoModal();
  166. // API's
  167. CTreeNode* GetSelection();
  168. LPCTSTR GetSelectionString();
  169. // Implementation
  170. protected:
  171. // message handlers and MFC overrides
  172. virtual BOOL OnInitDialog();
  173. afx_msg void OnButtonUp();
  174. afx_msg BOOL OnTooltip(UINT, NMHDR* pHdr, LRESULT* plRes);
  175. afx_msg void OnSelchangeComboSelNode();
  176. afx_msg void OnDblclkListNodeItems(NMHDR* pNMHDR, LRESULT* pResult);
  177. virtual void OnOK();
  178. virtual void OnCancel();
  179. afx_msg void OnItemchangedListNodeItems(NMHDR* pNMHDR, LRESULT* pResult);
  180. afx_msg void OnSelchangeComboFilter();
  181. afx_msg BOOL OnHelpInfo(HELPINFO* pHelpInfo);
  182. DECLARE_MESSAGE_MAP()
  183. private:
  184. // internal helper functions
  185. CEdit* GetSelectionEdit();
  186. void InitializeControls();
  187. void InitializeToolbar();
  188. void EnableOkButton(BOOL bEnable);
  189. void HandleOkOrDblClick(NMITEMACTIVATE* pItemActivate = NULL);
  190. void UpdateSelectionEdit(CDNSBrowseItem* pBrowseItem);
  191. // browse tree manipulation
  192. void InitBrowseTree();
  193. void ReEnumerateChildren();
  194. void ExpandBrowseTree(CDNSBrowseItem* pCurrBrowseItem,
  195. CDNSBrowseItem* pChildBrowseItem);
  196. void ContractBrowseTree(CDNSBrowseItem* pParentBrowseItem);
  197. void MoveUpHelper(CDNSBrowseItem* pNewBrowseItem);
  198. void MoveDownHelper();
  199. void AddTreeNodeChildrenHelper(CDNSBrowseItem* pBrowseItem,
  200. CDNSFilterCombo* pFilter, BOOL bExpand = TRUE);
  201. // dialog controls
  202. CDNSCurrContainerCombo m_currContainer;
  203. CToolBarCtrl m_toolbar;
  204. CDNSChildrenListView m_childrenList;
  205. CDNSFilterCombo m_filter;
  206. // dialog data
  207. BOOL m_bEnableEdit; // enable editbox
  208. CContainerNode* m_pMasterRootNode; // root of master browsable tree
  209. CDNSBrowseItem* m_pBrowseRootItem; // root of proxy tree
  210. CDNSBrowseItem* m_pCurrSelContainer; // current container selection
  211. // final item selection
  212. CDNSBrowseItem* m_pFinalSelection;
  213. CString m_szSelectionString;
  214. // component data object pointer
  215. CComponentDataObject* m_pComponentDataObject;
  216. // porperty page holder pointer, if needed
  217. CPropertyPageHolderBase* m_pHolder;
  218. friend class CDNSChildrenListView;
  219. friend class CBrowseExecContext;
  220. friend class CDNSFilterCombo;
  221. };
  222. #endif // _BROWSER_H