SVRITEM.H
上传用户:bangxh
上传日期:2007-01-31
资源大小:42235k
文件大小:4k
源码类别:

Windows编程

开发平台:

Visual C++

  1. // svrdoc.h : interface of the CServerNode class
  2. //
  3. // This is a part of the Microsoft Foundation Classes C++ library.
  4. // Copyright (C) 1992-1995 Microsoft Corporation
  5. // All rights reserved.
  6. //
  7. // This source code is only intended as a supplement to the
  8. // Microsoft Foundation Classes Reference and Microsoft
  9. // QuickHelp and/or WinHelp documentation provided with the library.
  10. // See these sources for detailed information regarding the
  11. // Microsoft Foundation Classes product.
  12. #ifndef _SVRITEM_H
  13. #define _SVRITEM_H
  14. #define CX_MARGIN   8
  15. #define CY_MARGIN   4
  16. #define CX_INDENT   12
  17. #define CX_BACKDENT 5
  18. #define CY_SEPARATOR 4
  19. class CServerDoc;
  20. class CServerItem;
  21. // in this example a CServerNode represents a node in a graph
  22. class CServerNode : public CObject
  23. {
  24. DECLARE_SERIAL(CServerNode);
  25. // Constructors
  26. public:
  27. CServerNode(CServerDoc* pServerDoc = NULL);
  28. static CServerNode* CreateRootNode(CServerDoc* pDoc);
  29. void InitRootNode();
  30. // create from parent node
  31. CServerNode* CreateChildNode(LPCTSTR lpszDescription);
  32. CServerNode* PromptNewChildNode();  // create with user interface
  33. // Attributes
  34. CString     m_strDescription;       // node description/caption
  35. CString     m_strLinkKey;           // link node if different from caption
  36. CServerItem* m_pServerItem;         // pointer to active item (may be NULL)
  37. CObList     m_listChild;            // list of children
  38. BOOL        m_bHideChildren;
  39. CServerDoc* m_pDocument;            // back pointer to document
  40. enum EShape
  41. {
  42. shapeRect,
  43. shapeRound,
  44. shapeOval,
  45. shapeMax
  46. } m_shape;      // shape to draw
  47. CServerDoc* GetDocument() const // return type-safe container
  48. { return (CServerDoc*)m_pDocument; }
  49. BOOL HasChildren() const
  50. { return m_listChild.GetCount() != 0; }
  51. BOOL IsChild(const CServerNode* pPotentialChild) const;
  52. // for popup context sensitive menus (in IDR_POPUPS)
  53. int GetPopupMenuIndex()
  54. { return 0; }   // 0 for simple menu
  55. CServerNode* GetNext(CServerNode *pItem, BOOL bInit = TRUE);
  56. CServerNode* GetPrev(CServerNode *pItem, BOOL bInit = TRUE);
  57. const CString& GetItemName();
  58. void UpdateItemName();
  59. // Operations
  60. // bounding rect helpers
  61. void CalcNodeSize(CDC* pDC, CSize& sizeNode);
  62. $$IF(WANTS_TEXTVIEW)
  63. // Text view display helpers
  64. BOOL GetNodeText(CString *strBuf, int TAB) ;
  65. int GetTreeText(CString * strBuf, int TAB) ;
  66. $$ENDIF
  67. // drawing helpers
  68. BOOL Draw(CDC* pDC, CPoint pt, BOOL bSelected, CSize sizeNode);
  69. BOOL FindAndDelete(CServerNode *pItem);
  70. // find pItem, remove it and all of its children
  71. void DeleteChildNodes();    // remove all child nodes from a given node
  72. CServerNode* FindNode(LPCTSTR pszItemName);
  73. // recursive bounding rect and drawing helpers
  74. void CalcBounding(CDC* pDC, CPoint& ptStart, CSize& sizeMax);
  75. int DrawTree(CDC* pDC, CPoint ptStart, CServerNode* pItemSel);
  76. // simple UI helpers
  77. BOOL PromptChangeNode();
  78. virtual void Serialize(CArchive& ar);        // for native data
  79. // Implementation
  80. public:
  81. ~CServerNode();
  82. protected:
  83. void SaveAsText(CArchive& ar, int nLevel);
  84. friend class CServerItem;   // CServerItem is an extension of a CServerNode
  85. };
  86. // CServerItem represents the OLE glue to a CServerNode.  Such items
  87. //  are only allocated as necessary.
  88. class CServerItem : public COleServerItem
  89. {
  90. // Constructors
  91. public:
  92. CServerItem(CServerDoc* pDoc, CServerNode* pNode);
  93. // Attributes
  94. CServerNode* m_pServerNode;     // back pointer to node (may be NULL)
  95. CServerDoc* GetDocument() const // return type-safe container
  96. { return (CServerDoc*)COleServerItem::GetDocument(); }
  97. // Overridables
  98. protected:
  99. virtual void Serialize(CArchive& ar);   // called for clipboard save
  100. virtual BOOL OnDraw(CDC* pDC, CSize& rSize);
  101. virtual BOOL OnGetExtent(DVASPECT dwDrawAspect, CSize& rSize);
  102. virtual void OnOpen();      // select the node when a link is shown
  103. virtual BOOL OnRenderFileData(LPFORMATETC lpFormatEtc, CFile* pFile);
  104. virtual COleDataSource* OnGetClipboardData(BOOL bIncludeLink,
  105. LPPOINT pptOffset, LPSIZE pSize);
  106. // Implementation
  107. public:
  108. ~CServerItem();
  109. protected:
  110. // GetNativeClipboardData called by overrided OnGetClipboardData
  111. void GetNativeClipboardData(COleDataSource *pDataSource);
  112. friend class CServerNode;   // CServerNode is an extension of CServerItem
  113. };
  114. #endif
  115. /////////////////////////////////////////////////////////////////////////////