StaticTreeCtrl.h
上传用户:dengkfang
上传日期:2008-12-30
资源大小:5233k
文件大小:5k
源码类别:

CA认证

开发平台:

Visual C++

  1. #if !defined(AFX_STATICTREECTRL_H__A9777424_A55F_4A55_BE9D_5308028DB601__INCLUDED_)
  2. #define AFX_STATICTREECTRL_H__A9777424_A55F_4A55_BE9D_5308028DB601__INCLUDED_
  3. #if _MSC_VER > 1000
  4. #pragma once
  5. #endif // _MSC_VER > 1000
  6. // StaticTreeCtrl.h : header file
  7. //
  8. /////////////////////////////////////////////////////////////////////////////
  9. #define CM_INSERTCHILD WM_APP + 10000
  10. #define CM_INSERTSIBLING WM_APP + 10001
  11. #define CM_DELETENODE WM_APP + 10002
  12. #define CM_MODIFYNODETEXT WM_APP + 10003
  13. #define CM_CHANGENODECOLOR WM_APP + 10004
  14. #define CM_TOGGLECONNECTINGLINES WM_APP + 10010
  15. #define CM_SETCONNECTINGLINESCOLOR WM_APP + 10011
  16. #define CM_SETFONT WM_APP + 10020
  17. #define CM_SETDEFAULTCOLOR WM_APP + 10021
  18. #define CM_SETBACKGROUNDBITMAP WM_APP + 10022
  19. #define CM_TOGGLEMENUSOUND WM_APP + 10030
  20. #if defined( _UNICODE )
  21. #define STRCPY(x,y) wcscpy(x,y)
  22. #else
  23. #define STRCPY(x,y) strcpy(x,y)
  24. #endif
  25. /////////////////////////////////////////////////////////////////////////////
  26. // CTreeNode class
  27. class CTreeNode
  28. {
  29. public:
  30. CTreeNode()
  31. {
  32. csLabel.Empty();
  33. rNode.SetRectEmpty();
  34. bUseDefaultTextColor = TRUE;
  35. bOpen = TRUE;
  36. pParent = NULL;
  37. pSibling = NULL;
  38. pChild = NULL;
  39. }
  40. virtual ~CTreeNode()
  41. {
  42. csLabel.Empty();
  43. }
  44. CString csLabel;
  45. CRect rNode;
  46. COLORREF crText;
  47. BOOL bUseDefaultTextColor;
  48. BOOL bOpen;
  49. CTreeNode* pParent;
  50. CTreeNode* pSibling;
  51. CTreeNode* pChild;
  52. };
  53. #define    HTREENODE   CTreeNode*
  54. #define    HTOPNODE    ( (HTREENODE) -0x10000 )
  55. /////////////////////////////////////////////////////////////////////////////
  56. // CStaticTreeCtrl window
  57. class CStaticTreeCtrl : public CStatic
  58. {
  59. // Construction
  60. public:
  61. CStaticTreeCtrl();
  62. // Attributes
  63. protected:
  64. LOGFONT m_lgFont;
  65. CFont m_Font;
  66. COLORREF m_crDefaultTextColor;
  67. COLORREF m_crConnectingLines;
  68. BOOL m_bShowLines;
  69. CBitmap m_bmpBackground;
  70. int m_iDocHeight;
  71. BOOL m_bScrollBarMessage;
  72. int m_iLineHeight;
  73. int m_iIndent;
  74. int m_iPadding;
  75. HTREENODE m_pTopNode;
  76. HTREENODE m_pSelected;
  77. BOOL m_bAudioOn;
  78. // Operations
  79. public:
  80. virtual CStaticTreeCtrl& SetTextFont ( LONG nHeight, BOOL bBold, BOOL bItalic, const CString& csFaceName );
  81. virtual CStaticTreeCtrl& SetDefaultTextColor ( COLORREF crText );
  82. HTREENODE InsertSibling ( HTREENODE pInsertAfter, const CString& csLabel,
  83. COLORREF crText = 0, BOOL bUseDefaultTextColor = TRUE,
  84. BOOL bInvalidate = FALSE );
  85. HTREENODE InsertChild ( HTREENODE pParent, const CString& csLabel,
  86. COLORREF crText = 0, BOOL bUseDefaultTextColor = TRUE,
  87. BOOL bInvalidate = FALSE );
  88. void DeleteNode ( HTREENODE pNode, BOOL bInvalidate = FALSE );
  89. void ToggleNode ( HTREENODE pNode, BOOL bInvalidate = FALSE );
  90. void SetNodeColor ( HTREENODE pNode, COLORREF crText, BOOL bInvalidate = FALSE );
  91. void SetBackgroundBitmap ( BOOL bInvalidate = FALSE );
  92. void SetNodeText(HTREENODE pNode, CString strText);
  93. protected:
  94. void DeleteNodeRecursive ( HTREENODE pNode ); // Recursive delete
  95. int DrawNodesRecursive ( CDC* pDC, HTREENODE pNode, int x, int y, CRect rFrame );
  96. int HowMuchTextFits ( CDC* pDC, int iAvailableWidth, CString csText );
  97. void DrawLinesRecursive ( CDC* pDC, HTREENODE pNode );
  98. void ResetScrollBar ();
  99. HTREENODE FindNodeByPoint ( const CPoint& point, HTREENODE pNode );
  100. BOOL NodeTextDlg ( CString& csText );
  101. // Message handlers
  102. /* void OnCM_InsertChild();
  103. void OnCM_InsertSibling();
  104. void OnCM_DeleteNode();
  105. void OnCM_ModifyNodeText();
  106. void OnCM_ChangeNodeColor();
  107. void OnCM_ToggleConnectingLines();
  108. void OnCM_SetConnectingLinesColor();
  109. void OnCM_SetFont();
  110. void OnCM_SetDefaultColor();
  111. void OnCM_SetBackgroundBitmap();
  112. void OnCM_ToggleMenuSound();*/
  113. // Overrides
  114. // ClassWizard generated virtual function overrides
  115. //{{AFX_VIRTUAL(CStaticTreeCtrl)
  116. protected:
  117. virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam);
  118. //}}AFX_VIRTUAL
  119. // Implementation
  120. public:
  121. virtual ~CStaticTreeCtrl();
  122. // Generated message map functions
  123. protected:
  124. //{{AFX_MSG(CStaticTreeCtrl)
  125. afx_msg void OnPaint();
  126. afx_msg void OnSize(UINT nType, int cx, int cy);
  127. afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
  128. afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
  129. // afx_msg BOOL OnMouseWheel(UINT nFlags, short zDelta, CPoint pt);
  130. // afx_msg void OnContextMenu(CWnd* pWnd, CPoint point);
  131. //}}AFX_MSG
  132. DECLARE_MESSAGE_MAP()
  133. };
  134. /////////////////////////////////////////////////////////////////////////////
  135. //{{AFX_INSERT_LOCATION}}
  136. // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
  137. #endif // !defined(AFX_STATICTREECTRL_H__A9777424_A55F_4A55_BE9D_5308028DB601__INCLUDED_)