drawobj.h
上传用户:ywlong9188
上传日期:2022-05-31
资源大小:2656k
文件大小:15k
- #ifndef __DRAWOBJ_H__
- #define __DRAWOBJ_H__
- #define __UXL_GRAPH_CONFIG__
- //#include "insdtchk.h" // check the user's input
- class CProjView;
- class CProjDoc;
- class CDrawObj;
- typedef CTypedPtrList <CObList, CDrawObj*> CDrawObjList;
- /////////////////////////////////////////////////////////////////////////////
- // CDrawObj - base class for all 'drawable objects'
- class CDrawObj : public CObject
- {
- protected:
- DECLARE_SERIAL(CDrawObj);
- CDrawObj();
- // Attributes
- public:
- // for the object's name
- CString m_name;
- static int c_identify;
- // Constructors
- public:
- CDrawObj(const CRect& position);
- // Attributes
- CRect m_position;
- CProjDoc* m_pDocument;
- virtual int GetHandleCount();
- virtual CPoint GetHandle(int nHandle);
- CRect GetHandleRect(int nHandleID, CProjView* pView);
- virtual HCURSOR GetHandleCursor(int nHandle);
- virtual void SetLineColor(COLORREF color);
- virtual void SetFillColor(COLORREF color);
- virtual void ReConsist();
- virtual void SetActive(BOOL bActive);
- // Operations
- virtual void Draw(CDC* pDC);
- enum TrackerState { normal, selected, active };
- virtual void DrawTracker(CDC* pDC, TrackerState state);
- virtual void MoveTo(const CRect& positon, CProjView* pView = NULL);
- virtual int HitTest(CPoint point, CProjView* pView, BOOL bSelected);
- virtual BOOL Intersects(const CRect& rect);
- virtual void MoveHandleTo(int nHandle, CPoint point, CProjView* pView = NULL);
- virtual void OnOpen(CProjView* pView);
- virtual void OnEditProperties();
- virtual CDrawObj* Clone(CProjDoc* pDoc = NULL);
- virtual void Remove();
- void Invalidate();
- void CustomRect(CRect& rect);
- virtual void SendData( int nParam = 0);
- virtual void ResetData( int nParam = 0);
- virtual BOOL GetActiveObj(CDrawObjList& list);
- virtual void AlignToTop(const CRect& rect);
- virtual void AlignToLeft(const CRect& rect);
- virtual void AlignToRight(const CRect& rect);
- virtual void AlignToBottom(const CRect& rect);
- virtual void GetTypeInfo(CString& sParam,CString& sNumber,BOOL& bInt);
- virtual void Resize(const CRect& preRect,const CRect& nextRect,CProjView* pView);
- virtual void OriginalRect(CRect& rect1,CRect rect2);
- virtual void SetFlag(BOOL bFlag=TRUE);
- virtual void SetAlone(BOOL bAlone=TRUE);
- // Implementation
- public:
- virtual ~CDrawObj();
- virtual void Serialize(CArchive& ar);
- #ifdef _DEBUG
- void AssertValid();
- #endif
- // implementation data
- public:
-
- CString m_sParam;
- CString m_sNumber;
- BOOL m_bActive;
- BOOL m_bFlag;
- BOOL m_bIsAlone;
- // CString m_sTrick;
- //CDrawObjList m_activeObj;
- };
- // special 'list' class for this application (requires afxtempl.h)
- //typedef CTypedPtrList <CObList, CDrawObj*> CDrawObjList;
- ////////////////////////////////////////////////////////////////////////
- // draw rectangle
- class CDrawRect : public CDrawObj
- {
- protected:
- DECLARE_SERIAL(CDrawRect);
- CDrawRect();
- public:
- CDrawRect(const CRect& position);
- // Implementation
- public:
- virtual void Serialize(CArchive& ar);
- virtual void Draw(CDC* pDC);
- virtual int GetHandleCount();
- virtual CPoint GetHandle(int nHandle);
- virtual HCURSOR GetHandleCursor(int nHandle);
- virtual void MoveHandleTo(int nHandle, CPoint point, CProjView* pView = NULL);
- virtual BOOL Intersects(const CRect& rect);
- virtual void OnOpen(CProjView* pView);
- virtual void OnEditProperties();
- virtual CDrawObj* Clone(CProjDoc* pDoc);
- public:
- static int c_nStyle;
- static COLORREF c_cLine;
- static COLORREF c_cFace;
- static COLORREF c_cHighLight;
- static COLORREF c_cShadow;
- static BOOL c_bPen;
- static UINT c_nDeep;
-
- int m_nStyle;
- COLORREF m_cLine;
- COLORREF m_cFace;
- COLORREF m_cHighLight;
- COLORREF m_cShadow;
- BOOL m_bPen;
- UINT m_nDeep;
-
- friend class CRectTool;
- };
- /////////////////////////////////////////////////////////////////////////////
- class CDrawPoly;
- class CDrawPoly : public CDrawObj
- {
- protected:
- DECLARE_SERIAL(CDrawPoly);
- CDrawPoly();
- public:
- void HappyRect(CRect& rect,CRect position);
- void ReLayout(CPoint& point,CRect position,int i);
- CDrawPoly(const CRect& position);
- // Operations
- void AddPoint(const CPoint& point, CProjView* pView = NULL);
- BOOL RecalcBounds(CProjView* pView = NULL);
- // Implementation
- public:
- virtual ~CDrawPoly();
- virtual void Serialize(CArchive& ar);
- virtual void Draw(CDC* pDC);
- virtual void MoveTo(const CRect& position, CProjView* pView = NULL);
- virtual int GetHandleCount();
- virtual CPoint GetHandle(int nHandle);
- virtual HCURSOR GetHandleCursor(int nHandle);
- virtual void MoveHandleTo(int nHandle, CPoint point, CProjView* pView = NULL);
- virtual BOOL Intersects(const CRect& rect);
- virtual CDrawObj* Clone(CProjDoc* pDoc);
- virtual void OnEditProperties();
- virtual void AlignToTop(const CRect& rect);
- virtual void AlignToLeft(const CRect& rect);
- virtual void AlignToRight(const CRect& rect);
- virtual void AlignToBottom(const CRect& rect);
- protected:
- int m_nPoints;
- int m_nAllocPoints;
- CPoint* m_points;
- CDrawPoly* m_pDrawObj;
- double* m_pXRate;
- double* m_pYRate;
- int m_nAttr;
- int m_nStyle;
- int m_nWidth;
- COLORREF m_cLine;
- COLORREF m_cFill;
- BOOL m_bPen;
- BOOL m_bBrush;
- LOGPEN m_logpen;
- LOGBRUSH m_logbrush;
- friend class CPolyTool;
- };
- ////////////////////////////////////////////////////////
- class CDrawText : public CDrawObj
- {
- protected:
- DECLARE_SERIAL(CDrawText);
- CDrawText();
- ~CDrawText();
- public:
- CDrawText(const CRect& position);
- void RecalRect(CProjView* pView = NULL);
- // Implementation
- public:
- virtual void Serialize(CArchive& ar);
- virtual void Draw(CDC* pDC);
- virtual int GetHandleCount();
- //virtual CPoint GetHandle(int nHandle);
- //virtual HCURSOR GetHandleCursor(int nHandle);
- virtual void MoveTo(const CRect& positon, CProjView* pView = NULL);
- virtual void MoveHandleTo(int nHandle, CPoint point, CProjView* pView = NULL);
- virtual BOOL Intersects(const CRect& rect);
- virtual void OnOpen(CProjView* pView);
- virtual void OnEditProperties(CProjView* pView);
- virtual CDrawObj* Clone(CProjDoc* pDoc);
- protected:
- BOOL m_bRate;
- public:
- CString m_text;
- LOGFONT m_logFont;
- CFont m_font;
- CSize m_td;
- int m_nAttr;
- COLORREF m_cColor;
- CString m_sFaceName;
- int m_nSize;
- private:
-
- friend class CTextTool;
- };
- ////////////////////////////////////////////////////////////////////////
- // The Draw Bar Objects
- class CDrawBar : public CDrawObj
- {
- protected:
- DECLARE_SERIAL(CDrawBar);
- CDrawBar();
- public:
- CDrawBar(const CRect& position);
- // Implementation
- public:
- virtual void Serialize(CArchive& ar);
- virtual void Draw(CDC* pDC);
- virtual int GetHandleCount();
- virtual CPoint GetHandle(int nHandle);
- virtual HCURSOR GetHandleCursor(int nHandle);
- virtual void MoveHandleTo(int nHandle, CPoint point, CProjView* pView = NULL);
- virtual BOOL Intersects(const CRect& rect);
- virtual void OnOpen(CProjView* pView);
- virtual void OnEditProperties();
- virtual CDrawObj* Clone(CProjDoc* pDoc);
- virtual void SendData( int nParam = 0);
- virtual void ResetData( int nParam = 0);
- virtual BOOL GetActiveObj(CDrawObjList& list);
- public:
-
- static int c_nDirection;
- static int c_nOne;
- static int c_nTwo;
-
- static COLORREF c_cBar;
- static COLORREF c_cOne;
- static COLORREF c_cTwo;
- int m_nDirection;
- int m_nOne;
- int m_nTwo;
-
- // CString m_sNumber;
- // CString m_sParam;
- // CString m_sComment;
- COLORREF m_cBar;
- COLORREF m_cOne;
- COLORREF m_cTwo;
- BOOL m_bDesign;
- int m_nCurrent;
- friend class CBarTool;
- };
- ///////////////////////////////////////////////////////////
- // Draw Line Object
- class CDrawLine : public CDrawObj
- {
- protected:
- DECLARE_SERIAL(CDrawLine);
- CDrawLine();
- public:
- CDrawLine(const CRect& position);
- // Implementation
- public:
- virtual void Serialize(CArchive& ar);
- virtual void Draw(CDC* pDC);
- virtual int GetHandleCount();
- virtual CPoint GetHandle(int nHandle);
- virtual HCURSOR GetHandleCursor(int nHandle);
- virtual void MoveHandleTo(int nHandle, CPoint point, CProjView* pView = NULL);
- virtual BOOL Intersects(const CRect& rect);
- virtual void OnOpen(CProjView* pView);
- virtual void OnEditProperties();
- virtual CDrawObj* Clone(CProjDoc* pDoc);
- public:
- int m_nStyle;
- int m_nWidth;
- COLORREF m_cLine;
- // LOGPEN m_logpen;
- static int c_style;
- static int c_width;
- static COLORREF c_color;
- friend class CLineTool;
- };
- ////////////////////////////////////////////////////////////////////////
- // draw ellipse
- class CDrawEllipse : public CDrawObj
- {
- protected:
- DECLARE_SERIAL(CDrawEllipse);
- CDrawEllipse();
- public:
- CDrawEllipse(const CRect& position);
- // Implementation
- public:
- virtual void Serialize(CArchive& ar);
- virtual void Draw(CDC* pDC);
- virtual int GetHandleCount();
- virtual CPoint GetHandle(int nHandle);
- virtual HCURSOR GetHandleCursor(int nHandle);
- virtual void MoveHandleTo(int nHandle, CPoint point, CProjView* pView = NULL);
- virtual BOOL Intersects(const CRect& rect);
- virtual void OnOpen(CProjView* pView);
- virtual void OnEditProperties();
- virtual CDrawObj* Clone(CProjDoc* pDoc);
- virtual void SendData( int nParam = 0);
- public:
- static int c_nStyle;
- static int c_nAttr;
- static int c_nStartAngle;
- static int c_nEndAngle;
-
- static int c_nWidth;
- static COLORREF c_cLine;
- static COLORREF c_cFill;
-
- int m_nStyle;
- int m_nAttr;
- int m_nStartAngle;
- int m_nEndAngle;
-
- int m_nWidth;
- COLORREF m_cLine;
- COLORREF m_cFill;
- friend class CEllipseTool;
- };
- ////////////////////////////////////////////////////////
- class CDrawAnimateTag : public CDrawText
- {
- protected:
- DECLARE_SERIAL(CDrawAnimateTag);
- CDrawAnimateTag();
-
- public:
- CDrawAnimateTag(const CRect& position);
- // CString m_sParam;
- // CString m_sNumber;
- // Implementation
- public:
- virtual void Serialize(CArchive& ar);
- virtual CDrawObj* Clone(CProjDoc* pDoc);
- virtual void SendData( int nParam = 0 );
- virtual void ResetData( int nParam = 0 );
- virtual BOOL GetActiveObj(CDrawObjList& list);
- virtual void OnOpen(CProjView* pView);
- virtual void OnEditProperties(CProjView* pView);
- virtual void Draw( CDC* pDC );
- public:
-
- friend class CAnimateTagTool;
- };
- ////////////////////////////////////////////////////////////////////////
- // draw cursor
- class CDrawCursor : public CDrawObj
- {
- protected:
- DECLARE_SERIAL(CDrawCursor);
- CDrawCursor();
- public:
- CDrawCursor(const CRect& position);
- // Implementation
- public:
- virtual void Serialize(CArchive& ar);
- virtual void Draw(CDC* pDC);
- virtual int GetHandleCount();
- virtual CPoint GetHandle(int nHandle);
- virtual HCURSOR GetHandleCursor(int nHandle);
- virtual void MoveHandleTo(int nHandle, CPoint point, CProjView* pView = NULL);
- virtual BOOL Intersects(const CRect& rect);
- virtual void OnOpen(CProjView* pView);
- virtual void OnEditProperties();
- virtual CDrawObj* Clone(CProjDoc* pDoc);
- virtual void SendData( int nParam );
- virtual BOOL GetActiveObj(CDrawObjList& list);
- virtual void ResetData( int nParam );
- public:
- static int c_nStyle;
- static int c_nSegment;
-
- static BOOL c_bCursor;
- static BOOL c_bRuler;
- static BOOL c_bReverse;
- static COLORREF c_color;
- static COLORREF c_cruler;
- int m_nStyle;
- int m_nSegment;
- int m_nCurrent;
-
- BOOL m_bCursor;
- BOOL m_bRuler;
- BOOL m_bReverse;
- COLORREF m_color;
- COLORREF m_cruler;
- // CString m_sParam;
- // CString m_sNumber;
- friend class CCursorTool;
- };
- ////////////////////////////////////////////////////////////////////////
- // draw ISA symbols
- class CDrawISA : public CDrawAnimateTag
- {
- protected:
- DECLARE_SERIAL(CDrawISA);
- CDrawISA();
- public:
- CDrawISA(const CRect& position);
- // Implementation
- public:
- virtual void Serialize(CArchive& ar);
- virtual void Draw(CDC* pDC);
- virtual void OnOpen(CProjView* pView);
- virtual void OnEditProperties(CProjView* pView);
- virtual CDrawObj* Clone(CProjDoc* pDoc);
- //Member methods
- public:
-
- // Member properties
- public:
- static CString m_isa[53];
- int m_nIndex;
- int m_nRotate;
- int m_nWidth;
- COLORREF m_color;
- static int c_nIndex;
- friend class CISATool;
- };
- ////////////////////////////////////////////////////////////////////////
- // draw LOOP controls
- class CDrawLoop : public CDrawObj
- {
- protected:
- DECLARE_SERIAL(CDrawLoop);
- CDrawLoop();
- ~CDrawLoop();
- public:
- CDrawLoop(const CRect& position);
- // Implementation
- public:
- virtual void Serialize(CArchive& ar);
- virtual void Draw(CDC* pDC);
- virtual int GetHandleCount();
- virtual CPoint GetHandle(int nHandle);
- virtual HCURSOR GetHandleCursor(int nHandle);
- virtual void MoveHandleTo(int nHandle, CPoint point, CProjView* pView = NULL);
- virtual BOOL Intersects(const CRect& rect);
- virtual void OnOpen(CProjView* pView);
- virtual void OnEditProperties();
- virtual CDrawObj* Clone(CProjDoc* pDoc);
- virtual void MoveTo(const CRect& positon, CProjView* pView = NULL);
- virtual int HitTest(CPoint point, CProjView* pView, BOOL bSelected);
- virtual BOOL GetActiveObj(CDrawObjList& list);
- virtual void SendData( int nParam );
- virtual void AlignToTop(const CRect& rect);
- virtual void AlignToLeft(const CRect& rect);
- virtual void AlignToRight(const CRect& rect);
- virtual void AlignToBottom(const CRect& rect);
-
- // Member function
- public:
- // CString m_sNumber;
- BOOL m_bB1up;
- BOOL m_bB2up;
- BOOL m_bB3up;
- friend class CLoopTool;
- };
- ////////////////////////////////////////////////////////////////////////
- // draw Merge Object
- class CMergeObj : public CDrawObj
- {
- protected:
- DECLARE_SERIAL(CMergeObj);
- CMergeObj();
- ~CMergeObj();
- public:
- CMergeObj(const CRect& position);
- // Implementation
- public:
- virtual void Serialize(CArchive& ar);
- virtual void Draw(CDC* pDC);
- virtual int GetHandleCount();
- virtual CPoint GetHandle(int nHandle);
- virtual HCURSOR GetHandleCursor(int nHandle);
- virtual void MoveHandleTo(int nHandle, CPoint point, CProjView* pView = NULL);
- virtual BOOL Intersects(const CRect& rect);
- virtual void OnOpen(CProjView* pView);
- virtual void OnEditProperties();
- virtual CDrawObj* Clone(CProjDoc* pDoc);
- virtual void MoveTo(const CRect& positon, CProjView* pView = NULL);
- // virtual int HitTest(CPoint point, CProjView* pView, BOOL bSelected);
- virtual BOOL GetActiveObj(CDrawObjList& list);
- // virtual void SendData( int nParam );
- virtual void AlignToTop(const CRect& rect);
- virtual void AlignToLeft(const CRect& rect);
- virtual void AlignToRight(const CRect& rect);
- virtual void AlignToBottom(const CRect& rect);
- virtual void SetAlone(BOOL bAlone);
- // self-definition method
- public:
- void SetList(CDrawObjList& list);
- void ResetDoc();
- void ReRect();
- void RightRect(CRect& rect);
- public:
- CDrawObjList m_consist;
- CRect m_constRect;
- CObList m_rateList;
- private:
- void ZoomRect(CRect& rect,CRect postRect,double topRate,double bottomRate,double leftRate,double rightRate);
- };
- ////////////////////////////////////////////////////////////////////////
- // draw button object
- class CDrawButton : public CDrawRect
- {
- protected:
- DECLARE_SERIAL(CDrawButton)
- CDrawButton();
- public:
- CDrawButton(const CRect& position);
- public:
- virtual void OnOpen(CProjView* pView);
- virtual void OnEditProperties();
- virtual CDrawObj* Clone(CProjDoc* pDoc);
-
- public:
- virtual void Serialize(CArchive& ar);
- virtual void Draw(CDC* pDC);
- public:
- public:
- CString m_caption;
- LOGFONT m_logFont;
- COLORREF m_color;
- BOOL m_bType;
- int m_nState;
- friend class CButtonTool;
- };
- #endif // __DRAWOBJ_H__