DiagramEntity.h
Upload User: kairuinn
Upload Date: 2009-02-07
Package Size: 2922k
Code Size: 5k
Category:

Graph program

Development Platform:

Visual C++

  1. #ifndef _DIAGRAMENTITY_H_
  2. #define _DIAGRAMENTITY_H_
  3. #include "DiagramPropertyDlg.h"
  4. #define CMD_START 100
  5. #define CMD_CUT 100
  6. #define CMD_COPY 101
  7. #define CMD_DUPLICATE 102
  8. #define CMD_PROPERTIES 103
  9. #define CMD_UP 104
  10. #define CMD_DOWN 105
  11. #define CMD_FRONT 106
  12. #define CMD_BOTTOM 107
  13. #define CMD_SELECT_GROUP 108
  14. #define CMD_END 200
  15. #define DEHT_NONE 0
  16. #define DEHT_BODY 1
  17. #define DEHT_TOPLEFT 2
  18. #define DEHT_TOPMIDDLE 3
  19. #define DEHT_TOPRIGHT 4
  20. #define DEHT_BOTTOMLEFT 5
  21. #define DEHT_BOTTOMMIDDLE 6
  22. #define DEHT_BOTTOMRIGHT 7
  23. #define DEHT_LEFTMIDDLE 8
  24. #define DEHT_RIGHTMIDDLE 9
  25. #define round(a) ( int ) ( a + .5 )
  26. typedef enum
  27. {
  28. DIAGRAM_UNKNOWN = 0,
  29. DIAGRAM_LINE = 1,
  30. DIAGRAM_RECT = 2,
  31. DIAGRAM_LABEL = 3,
  32. DIAGRAM_PICTURE = 4
  33. } DIAGRAM_OBJECT_TYPE;
  34. #define  DIAGRAM_FRAME_STYLE_LEFT   1
  35. #define  DIAGRAM_FRAME_STYLE_RIGHT  2
  36. #define  DIAGRAM_FRAME_STYLE_TOP    4
  37. #define  DIAGRAM_FRAME_STYLE_BOTTOM 8
  38. class CDiagramEntityContainer;
  39. class CDiagramPropertyDlg;
  40. class IThumbnailerStorage;
  41. class CDiagramEntity : public CObject
  42. {
  43. friend class CDiagramEntityContainer;
  44. public:
  45. // Creation/initialization
  46. CDiagramEntity();
  47. virtual ~CDiagramEntity();
  48. protected:
  49. virtual void Clear();
  50. public:
  51. virtual DIAGRAM_OBJECT_TYPE  GetEntityType() {return DIAGRAM_UNKNOWN;};
  52. virtual CDiagramEntity* Clone();
  53. virtual void Copy( CDiagramEntity* obj );
  54. virtual BOOL FromString( const CString& str );
  55. virtual CString Export( UINT format = 0 ) const;
  56. virtual CString GetString() const;
  57. static CDiagramEntity* CreateFromString( const CString& str );
  58. virtual void    Serialize(CArchive& ar);
  59. // Object rectangle handling
  60. virtual CRect GetRect() const;
  61. virtual void SetRect( CRect rect );
  62. virtual void SetRect( double left, double top, double right, double bottom );
  63. virtual void MoveRect( double x, double y );
  64. double GetLeft() const;
  65. double GetRight() const;
  66. double GetTop() const;
  67. double GetBottom() const;
  68. virtual void SetLeft( double left );
  69. virtual void SetRight( double right );
  70. virtual void SetTop( double top );
  71. virtual void SetBottom( double bottom );
  72. virtual void SetMinimumSize( CSize minimumSize );
  73. virtual CSize GetMinimumSize() const;
  74. virtual void SetMaximumSize( CSize minimumSize );
  75. virtual CSize GetMaximumSize() const;
  76. virtual void SetConstraints( CSize min, CSize max );
  77. double GetZoom() const;
  78. // Selection handling
  79. virtual void Select( BOOL selected );
  80. virtual BOOL IsSelected() const;
  81. virtual BOOL BodyInRect( CRect rect ) const;
  82. // Interaction
  83. virtual int GetHitCode( CPoint point ) const;
  84. virtual int GetHitCode( const CPoint& point, const CRect& rect ) const;
  85. virtual BOOL DoMessage( UINT msg, CDiagramEntity* sender, IThumbnailerStorage* from = NULL );
  86. // Auxilliary
  87. virtual void ShowProperties( IThumbnailerStorage* parent, BOOL show = TRUE );
  88. virtual void ShowPopup( CPoint point, CWnd* parent );
  89. // Visuals
  90. virtual void Draw( CDC* dc, CRect rect );
  91. virtual HCURSOR GetCursor( int hit ) const;
  92. virtual void DrawObject( CDC* dc, double zoom , bool draw_markers = true);
  93. // Properties
  94. virtual CString GetTitle() const;
  95. virtual void SetTitle( CString title );
  96. virtual CString GetName() const;
  97. virtual void SetName( CString name );
  98. CString GetType() const;
  99. void SetType( CString type );
  100. int GetGroup() const;
  101. void SetGroup( int group );
  102. BOOL LoadFromString( CString& data );
  103. void SetParent( CDiagramEntityContainer* parent );
  104. CDiagramEntityContainer* GetParent() const;
  105. protected:
  106. // Selection
  107. virtual void DrawSelectionMarkers( CDC* dc, CRect rect ) const;
  108. virtual CRect GetSelectionMarkerRect( UINT marker, CRect rect ) const;
  109. // Visuals
  110. void GetFont( LOGFONT& lf ) const;
  111. // Properties
  112. void SetMarkerSize( CSize markerSize );
  113. CSize GetMarkerSize() const;
  114. void SetZoom( double zoom );
  115. void SetAttributeDialog( CDiagramPropertyDlg* dlg, UINT resid );
  116. CDiagramPropertyDlg* GetAttributeDialog() const;
  117. virtual CString GetDefaultGetString() const;
  118. virtual CString GetHeaderFromString( CString& str );
  119. virtual BOOL GetDefaultFromString( CString& str );
  120. void                        ReadStringFromArchive(CArchive& ar, CString& str);
  121. void                        WriteStringToArchive(CArchive& ar, CString& str);
  122. private:
  123. // Position
  124. double m_left;
  125. double m_right;
  126. double m_top;
  127. double m_bottom;
  128. // Sizes
  129. CSize m_markerSize;
  130. CSize m_minimumSize;
  131. CSize m_maximumSize;
  132. // States
  133. double m_zoom;
  134. BOOL m_selected;
  135. // Data
  136. CString m_type;
  137. CString m_title;
  138. CString m_name;
  139. int m_group;
  140. CDiagramPropertyDlg* m_propertydlg;
  141. UINT m_propertydlgresid;
  142. CDiagramEntityContainer* m_parent;
  143. };
  144. #endif // _DIAGRAMENTITY_H_