TreePropertySheet.h
上传用户:qifu0001
上传日期:2007-01-02
资源大小:52k
文件大小:7k
源码类别:

TreeView控件

开发平台:

Visual C++

  1. #if !defined(AFX_TREEPROPERTYSHEET_H__B95F414E_0487_11D3_81D8_E47B2B99925E__INCLUDED_)
  2. #define AFX_TREEPROPERTYSHEET_H__B95F414E_0487_11D3_81D8_E47B2B99925E__INCLUDED_
  3. #if _MSC_VER > 1000
  4. #pragma once
  5. #endif // _MSC_VER > 1000
  6. // TreePropertySheet.h : Header-File
  7. //
  8. /////////////////////////////////////////////////////////////////////////////
  9. // CTreePropertySheet
  10. #include <afxtempl.h>
  11. enum {
  12. tps_above=0,
  13. tps_below=1,
  14. tps_horz_left=0,
  15. tps_horz_center=1,
  16. tps_horz_right=2,
  17. tps_vert_top=0,
  18. tps_vert_center=4,
  19. tps_vert_bottom=8,
  20. tps_horz_mask=3,
  21. tps_vert_mask=12,
  22. tps_item_branch=0,
  23. tps_item_node=1,
  24. tps_item_endbranch=2,
  25. tps_item_type_mask=3,
  26. tps_item_collapsed=0,
  27. tps_item_expanded=4,
  28. tps_capborder_none=0,
  29. tps_capborder_line=1,
  30. tps_capborder_flow=2
  31. };
  32. class CMemDC : public CDC {
  33. public:
  34. CBitmap m_MemBmp,*m_pOldBmp;
  35. int nWidth,nHeight;
  36. int nCurWidth, nCurHeight;
  37. public:
  38. CMemDC(int nWidth,int nHeight) : CDC()
  39. {
  40. CDC *tempDC=CWnd::GetDesktopWindow()->GetDC();
  41. CreateCompatibleDC(tempDC);
  42. m_MemBmp.CreateCompatibleBitmap(tempDC,nWidth,nHeight);
  43. m_pOldBmp=SelectObject(&m_MemBmp);
  44. this->nWidth =nWidth;
  45. this->nHeight =nHeight;
  46. nCurWidth =nWidth;
  47. nCurHeight =nHeight;
  48. CWnd::GetDesktopWindow()->ReleaseDC(tempDC);
  49.         FillSolidRect(CRect(0,0,nWidth,nHeight),RGB(192,192,192));
  50. }
  51. CMemDC(CBitmap *bmp) : CDC()
  52. {
  53. CDC *tempDC=CWnd::GetDesktopWindow()->GetDC();
  54. CreateCompatibleDC(tempDC);
  55. m_pOldBmp =SelectObject(bmp);
  56. CWnd::GetDesktopWindow()->ReleaseDC(tempDC);
  57. }
  58. ~CMemDC()
  59. {
  60. SelectObject(m_pOldBmp);
  61. }
  62.     static  CBitmap *CreateBitmap(int nWidth,int nHeight)
  63.     {
  64.         CBitmap *pBitmap;
  65. CDC *tempDC=CWnd::GetDesktopWindow()->GetDC();
  66.         pBitmap =new CBitmap();
  67.         pBitmap->CreateCompatibleBitmap(tempDC,nWidth,nHeight);
  68. CWnd::GetDesktopWindow()->ReleaseDC(tempDC);
  69.         return pBitmap;
  70.     }
  71.     void    FitInto(int nWidth,int nHeight)
  72.     {
  73.         if(this->nWidth<nWidth || this->nHeight<nHeight) {
  74.             SelectObject(m_pOldBmp);
  75.             m_MemBmp.DeleteObject();
  76.             CDC *tempDC=CWnd::GetDesktopWindow()->GetDC();
  77.             m_MemBmp.CreateCompatibleBitmap(tempDC,nWidth,nHeight);
  78.     CWnd::GetDesktopWindow()->ReleaseDC(tempDC);
  79.             SelectObject(&m_MemBmp);
  80.             this->nWidth    =nWidth;
  81.             this->nHeight   =nHeight;
  82. FillSolidRect(CRect(0,0,nWidth,nHeight),RGB(192,192,192));
  83.         }
  84. nCurWidth =nWidth;
  85. nCurHeight =nHeight;
  86.     }
  87. };
  88. class CTreePropertySheet : public CPropertySheet
  89. {
  90. DECLARE_DYNAMIC(CTreePropertySheet)
  91. // Subclasses
  92. protected:
  93. class cControlPos {
  94. public:
  95. int row,col;
  96. int nWidth,nHeight;
  97. int nZOrder;
  98. int nArrange;
  99. int nVertArrange;
  100. CWnd *pWnd;
  101. UINT nID;
  102. int nTWidth,nTHeight;
  103. CString sCaption;
  104. bool bAutoDelete;
  105. CRect rcFinalPos;
  106. cControlPos()
  107. {
  108. row=col=0;
  109. nWidth=nHeight=0;
  110. nZOrder=0;
  111. nArrange=nVertArrange=0;
  112. pWnd=NULL;
  113. nID=0;
  114. nTWidth=nTHeight=0;
  115. bAutoDelete=false;
  116. rcFinalPos=CRect(0,0,0,0);
  117. };
  118. };
  119. class cPropPage {
  120. public:
  121. int nType;
  122. CPropertyPage *pPage;
  123. CString sCaption;
  124. CString sCaptionDescr;
  125. };
  126. class cRowInfo {
  127. public:
  128. int nHeight;
  129. int nExtraTop;
  130. int nExtraBottom;
  131. };
  132. public:
  133. enum {
  134. ID_TREECTRL=0x1ffe
  135. };
  136. // Constructor/Destructor
  137. public:
  138. CTreePropertySheet(CWnd* pParentWnd, UINT iSelectPage=0);
  139. CTreePropertySheet(int nTreeWidth, UINT nIDCaption, CWnd* pParentWnd = NULL, UINT iSelectPage = 0);
  140. CTreePropertySheet(int nTreeWidth=100, LPCTSTR pszCaption="Tree property sheet", CWnd* pParentWnd = NULL, UINT iSelectPage = 0);
  141. // Attributes
  142. public:
  143. int m_nSpaceTop;
  144. int m_nSpaceBottom;
  145. int m_nSpaceLeft;
  146. int m_nSpaceRight;
  147. int m_nSpaceMid;
  148. int m_nCaptionHeight;
  149. int m_nCaptionBorder;
  150. bool m_bSpecialCaption;
  151. COLORREF m_clrCaptionLeft;
  152. COLORREF m_clrCaptionRight;
  153. COLORREF m_clrCaptionTextLeft;
  154. COLORREF m_clrCaptionTextRight;
  155. COLORREF m_clrCaptionBorderTopLeft;
  156. COLORREF m_clrCaptionBorderBottomRight;
  157. bool m_bDisableStandardButtons;
  158. CFont *m_pCaptionFont;
  159. bool m_bDeleteCaptionFont;
  160. CFont *m_pCaptionDescrFont;
  161. bool m_bDeleteCaptionDescrFont;
  162. bool m_bDragging;
  163. CPoint m_lButtonDownPoint;
  164. // Protected Attributes
  165. protected:
  166. int m_nTreeWidth;
  167. CArray<cRowInfo,cRowInfo&>
  168. m_anRowHeight_TopPane;
  169. CArray<cRowInfo,cRowInfo&>
  170. m_anRowHeight_BottomPane;
  171. CArray<cPropPage,cPropPage&>
  172. m_acPropPages;
  173. CArray<cControlPos,cControlPos&>
  174. m_acControlPos;
  175. CArray<CFont*,CFont*>
  176. m_apFonts;
  177. CTreeCtrl m_cTreeCtrl;
  178. CRect m_rcCaptionBar;
  179. CMemDC m_cCaptionBarDC;
  180. CMemDC m_cCaptionDC;
  181. bool m_bCaptionBarInvalidated;
  182. // Operations
  183. public:
  184. void InsertExtraControl(
  185. int nVertArrange,
  186. int zOrder,
  187. CWnd* pWnd,
  188. int row,int col,
  189. int nWidth,int nHeight,
  190. int nArrange,
  191. bool bAutoDelete);
  192. void InsertExtraSpace(
  193. int nVertArrange,
  194. int row,int col,
  195. int nWidth=-1,
  196. int nHeight=0);
  197. /* void AddPage(
  198. const CString& sCaption,
  199. int nType,
  200. UINT nIDTemplate,
  201. const CString& sCaptionDescr,
  202. CPropertyPage *pDlg=NULL);*/
  203. void AddPage(
  204. int nType,
  205. CPropertyPage* pPage,
  206. LPCTSTR lpszCaptionDescr=_T(""));
  207. void SetExtraRowSpace(int nVertArrange,int nRow,int nSpaceTop,int nSpaceBottom);
  208. void SetCaptionFont(LPCTSTR lpszFacename,int nHeight,bool bNoInvalidate=false);
  209. void SetCaptionDescrFont(LPCTSTR lpszFacename,int nHeight,bool bNoInvalidate=false);
  210. void SetLikeNetscape(bool bSpecialCaption);
  211. void SetSimple(bool bSpecialCaption);
  212. CFont *GetFont(const CString& sFacename,int nHeight);
  213. // Protected operations
  214. protected:
  215. COLORREF _interpolate(COLORREF clrLeft, COLORREF clrRight, int nStep, int nSteps);
  216. void RenderCaptionBar();
  217. void AlignControls();
  218. int GetHeight(CArray<cRowInfo,cRowInfo&>& pane);
  219. int GetWidth(int nVertArrange, int nRow);
  220. void AssignFillerSpace(int nVertArrange, int nRow, int nSpace);
  221. int CountFillers(int nVertArrange,int nRow);
  222. int CountColumns(int nVertArrange,int nRow);
  223. cControlPos* GetControl(int nVertArrange,int nRow,int nCol);
  224. bool HidePpgButtons();
  225. void HideTabControl();
  226. void AddTreeView();
  227. void AddPaneSpace(int nWidth, int nTopPane,int nBottomPane);
  228. void PlaceControl(cControlPos* pCtrl);
  229. // 躡erschreibungen
  230. // Vom Klassen-Assistenten generierte virtuelle Funktions黚erschreibungen
  231. //{{AFX_VIRTUAL(CTreePropertySheet)
  232. //}}AFX_VIRTUAL
  233. // Implementation
  234. public:
  235. virtual ~CTreePropertySheet();
  236. protected:
  237. //{{AFX_MSG(CTreePropertySheet)
  238. virtual BOOL OnInitDialog();
  239. afx_msg void OnPaint();
  240. afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
  241. afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
  242. afx_msg void OnMouseMove(UINT nFlags, CPoint point);
  243. //}}AFX_MSG
  244. afx_msg void OnSelChanged(NMHDR* pNotifyStruct, LRESULT* pResult);
  245. DECLARE_MESSAGE_MAP()
  246. };
  247. /////////////////////////////////////////////////////////////////////////////
  248. //{{AFX_INSERT_LOCATION}}
  249. #endif // AFX_TREEPROPERTYSHEET_H__B95F414E_0487_11D3_81D8_E47B2B99925E__INCLUDED_