Source code of Windows XP (NT5)
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.

162 lines
4.8 KiB

  1. /////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 1996-1997 Microsoft Corporation
  4. //
  5. // Module Name:
  6. // TreeView.h
  7. //
  8. // Abstract:
  9. // Definition of the CClusterTreeView class.
  10. //
  11. // Implementation File:
  12. // TreeView.cpp
  13. //
  14. // Author:
  15. // David Potter (davidp) May 1, 1996
  16. //
  17. // Revision History:
  18. //
  19. // Notes:
  20. //
  21. /////////////////////////////////////////////////////////////////////////////
  22. #ifndef _TREEVIEW_H_
  23. #define _TREEVIEW_H_
  24. /////////////////////////////////////////////////////////////////////////////
  25. // Forward Class Declarations
  26. /////////////////////////////////////////////////////////////////////////////
  27. class CClusterTreeView;
  28. /////////////////////////////////////////////////////////////////////////////
  29. // External Class Declarations
  30. /////////////////////////////////////////////////////////////////////////////
  31. class CClusterDoc;
  32. class CSplitterFrame;
  33. /////////////////////////////////////////////////////////////////////////////
  34. // Type Definitions
  35. /////////////////////////////////////////////////////////////////////////////
  36. typedef CList<CClusterTreeView *, CClusterTreeView *> CClusterTreeViewList;
  37. /////////////////////////////////////////////////////////////////////////////
  38. // Include Files
  39. /////////////////////////////////////////////////////////////////////////////
  40. #ifndef _TREEITEM_H_
  41. #include "TreeItem.h" // for CTreeItem
  42. #endif
  43. #ifndef _SPLITFRM_H
  44. #include "SplitFrm.h" // for CSplitterFrame
  45. #endif
  46. /////////////////////////////////////////////////////////////////////////////
  47. // CClusterTreeView view
  48. /////////////////////////////////////////////////////////////////////////////
  49. class CClusterTreeView : public CTreeView
  50. {
  51. friend class CTreeItem;
  52. friend class CClusterDoc;
  53. friend class CSplitterFrame;
  54. protected: // create from serialization only
  55. CClusterTreeView(void);
  56. DECLARE_DYNCREATE(CClusterTreeView)
  57. // Attributes
  58. protected:
  59. CSplitterFrame * m_pframe;
  60. BOOL BDragging(void) const { ASSERT_VALID(Pframe()); return Pframe()->BDragging(); }
  61. CImageList * Pimagelist(void) const { ASSERT_VALID(Pframe()); return Pframe()->Pimagelist(); }
  62. public:
  63. CClusterDoc * GetDocument(void);
  64. CSplitterFrame * Pframe(void) const { return m_pframe; }
  65. CTreeItem * PtiSelected(void) const;
  66. HTREEITEM HtiSelected(void) const { return GetTreeCtrl().GetSelectedItem(); }
  67. // Operations
  68. public:
  69. CMenu * PmenuPopup(
  70. IN CPoint & rpointScreen,
  71. OUT CClusterItem *& rpci
  72. );
  73. void SaveCurrentSelection(void);
  74. void ReadPreviousSelection(OUT CString & rstrSelection);
  75. protected:
  76. // Overrides
  77. // ClassWizard generated virtual function overrides
  78. //{{AFX_VIRTUAL(CClusterTreeView)
  79. public:
  80. virtual void OnDraw(CDC* pDC); // overridden to draw this view
  81. virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
  82. virtual BOOL Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext = NULL);
  83. virtual BOOL OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo);
  84. virtual BOOL PreTranslateMessage(MSG* pMsg);
  85. protected:
  86. virtual void OnInitialUpdate(); // called first time after construct
  87. virtual void OnActivateView(BOOL bActivate, CView* pActivateView, CView* pDeactiveView);
  88. //}}AFX_VIRTUAL
  89. // Implementation
  90. public:
  91. virtual ~CClusterTreeView(void);
  92. #ifdef _DEBUG
  93. virtual void AssertValid(void) const;
  94. virtual void Dump(CDumpContext& dc) const;
  95. #endif
  96. protected:
  97. // Label editing.
  98. CTreeItem * m_ptiBeingEdited;
  99. BOOL m_bShiftPressed;
  100. BOOL m_bControlPressed;
  101. BOOL m_bAltPressed;
  102. MSG m_msgControl;
  103. // Drag & drop.
  104. HTREEITEM m_htiDrag;
  105. CTreeItem * m_ptiDrag;
  106. HTREEITEM m_htiDrop;
  107. void OnMouseMoveForDrag(IN UINT nFlags, IN CPoint point, IN const CWnd * pwndDrop);
  108. void OnButtonUpForDrag(IN UINT nFlags, IN CPoint point);
  109. void BeginDrag(void);
  110. void EndDrag(void);
  111. BOOL BAddItems(
  112. IN OUT CTreeItem * pti,
  113. IN const CString & rstrSelection,
  114. IN BOOL bExpanded = FALSE
  115. );
  116. // Generated message map functions
  117. protected:
  118. //{{AFX_MSG(CClusterTreeView)
  119. afx_msg void OnDestroy();
  120. afx_msg void OnCmdRename();
  121. afx_msg void OnSelChanged(NMHDR* pNMHDR, LRESULT* pResult);
  122. afx_msg void OnBeginLabelEdit(NMHDR* pNMHDR, LRESULT* pResult);
  123. afx_msg void OnEndLabelEdit(NMHDR* pNMHDR, LRESULT* pResult);
  124. afx_msg void OnItemExpanded(NMHDR* pNMHDR, LRESULT* pResult);
  125. afx_msg void OnBeginDrag(NMHDR* pNMHDR, LRESULT* pResult);
  126. afx_msg void OnKeyDown(NMHDR* pNMHDR, LRESULT* pResult);
  127. //}}AFX_MSG
  128. DECLARE_MESSAGE_MAP()
  129. };
  130. #ifndef _DEBUG // debug version in TreeView.cpp
  131. inline CClusterDoc * CClusterTreeView::GetDocument(void)
  132. { return (CClusterDoc *) m_pDocument; }
  133. #endif
  134. /////////////////////////////////////////////////////////////////////////////
  135. #endif // _TREEVIEW_H_