home *** CD-ROM | disk | FTP | other *** search
/ QBasic & Borland Pascal & C / Delphi5.iso / C / BC_502 / SCRIB7.PAK / SCRIBDOC.H < prev    next >
Encoding:
C/C++ Source or Header  |  1997-05-06  |  3.7 KB  |  128 lines

  1. // ScribDoc.h : interface of the CScribbleDoc 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 related
  9. // electronic documentation provided with the library.
  10. // See these sources for detailed information regarding the
  11. // Microsoft Foundation Classes product.
  12. /////////////////////////////////////////////////////////////////////////////
  13.  
  14. // Forward declaration of data structure class
  15. class CStroke;
  16. class CScribbleItem;
  17.  
  18. class CScribbleDoc : public COleServerDoc
  19. {
  20. protected: // create from serialization only
  21.     CScribbleDoc();
  22.     DECLARE_DYNCREATE(CScribbleDoc)
  23.  
  24. // Attributes
  25. protected:
  26.     // The document keeps track of the current pen width on
  27.     // behalf of all views. We'd like the user interface of
  28.     // Scribble to be such that if the user chooses the Draw
  29.     // Thick Line command, it will apply to all views, not just
  30.     // the view that currently has the focus.
  31.  
  32.     UINT            m_nPenWidth;        // current user-selected pen width
  33.     BOOL            m_bThickPen;        // TRUE if current pen is thick
  34.     UINT            m_nThinWidth;
  35.     UINT            m_nThickWidth;
  36.     CPen            m_penCur;           // pen created according to
  37.                                         // user-selected pen style (width)
  38. public:
  39.     CTypedPtrList<CObList,CStroke*>     m_strokeList;   
  40.     CPen*           GetCurrentPen() { return &m_penCur; }
  41.  
  42. protected:
  43.     CSize           m_sizeDoc;
  44. public:
  45.     CSize GetDocSize() { return m_sizeDoc; }
  46.     CScribbleItem* GetEmbeddedItem()
  47.         { return (CScribbleItem*)COleServerDoc::GetEmbeddedItem(); }
  48.  
  49. // Operations
  50. public:
  51.     CStroke* NewStroke();
  52.  
  53. // Overrides
  54.     // ClassWizard generated virtual function overrides
  55.     //{{AFX_VIRTUAL(CScribbleDoc)
  56.     protected:
  57.     virtual COleServerItem* OnGetEmbeddedItem();
  58.     public:
  59.     virtual BOOL OnNewDocument();
  60.     virtual void Serialize(CArchive& ar);
  61.     virtual BOOL OnOpenDocument(LPCTSTR lpszPathName);
  62.     virtual void DeleteContents();
  63.     //}}AFX_VIRTUAL
  64.  
  65. // Implementation
  66. protected:
  67.     void ReplacePen();
  68.     void OnSetItemRects(LPCRECT lpPosRect, LPCRECT lpClipRect);
  69.  
  70. public:
  71.     virtual ~CScribbleDoc();
  72. #ifdef _DEBUG
  73.     virtual void AssertValid() const;
  74.     virtual void Dump(CDumpContext& dc) const;
  75. #endif
  76.  
  77. protected:
  78.     void            InitDocument();
  79.  
  80. // Generated message map functions
  81. protected:
  82.     //{{AFX_MSG(CScribbleDoc)
  83.     afx_msg void OnEditClearAll();
  84.     afx_msg void OnPenThickOrThin();
  85.     afx_msg void OnUpdateEditClearAll(CCmdUI* pCmdUI);
  86.     afx_msg void OnUpdatePenThickOrThin(CCmdUI* pCmdUI);
  87.     afx_msg void OnPenWidths();
  88.     afx_msg void OnEditCopy();
  89.     //}}AFX_MSG
  90.     DECLARE_MESSAGE_MAP()
  91. };
  92.  
  93. /////////////////////////////////////////////////////////////////////////////
  94. // class CStroke
  95. //
  96. // A stroke is a series of connected points in the scribble drawing.
  97. // A scribble document may have multiple strokes.
  98.  
  99. class CStroke : public CObject
  100. {
  101. public:
  102.     CStroke(UINT nPenWidth);
  103.  
  104. protected:
  105.     CStroke();
  106.     DECLARE_SERIAL(CStroke)
  107.  
  108. // Attributes
  109. protected:
  110.     UINT                   m_nPenWidth;    // one pen width applies to entire stroke
  111. public:
  112.     CArray<CPoint,CPoint>  m_pointArray;   // series of connected points
  113.     CRect               m_rectBounding; // smallest rect that surrounds all
  114.                                         // of the points in the stroke
  115.                                         // measured in MM_LOENGLISH units
  116.                                         // (0.01 inches, with Y-axis inverted)
  117. public:
  118.     CRect& GetBoundingRect() { return m_rectBounding; }
  119.  
  120. // Operations
  121. public:
  122.     BOOL DrawStroke(CDC* pDC);
  123.     void FinishStroke();
  124.  
  125. public:
  126.     virtual void Serialize(CArchive& ar);
  127. };
  128.