home *** CD-ROM | disk | FTP | other *** search
/ Mastering MFC Development / MMD.ISO / labs / c05 / lab02 / baseline / scribdoc.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-02-20  |  3.0 KB  |  101 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. /////////////////////////////////////////////////////////////////////////////
  15. // class CStroke
  16. //
  17. // A stroke is a series of connected points in the scribble drawing.
  18. // A scribble document may have multiple strokes.
  19. // Due to the way templates are expanded, this class must be placed
  20. // before CScribbleDoc.
  21.  
  22. class CStroke : public CObject
  23. {
  24. public:
  25.     CStroke(UINT nPenWidth);
  26.  
  27. protected:
  28.     CStroke();
  29.     DECLARE_SERIAL(CStroke)
  30.  
  31. // Attributes
  32. protected:
  33.     UINT                   m_nPenWidth;    // one pen width applies to entire stroke
  34. public:
  35.     CArray<CPoint,CPoint>  m_pointArray;   // series of connected points
  36.  
  37. // Operations
  38. public:
  39.     BOOL DrawStroke(CDC* pDC);
  40.  
  41. public:
  42.     virtual void Serialize(CArchive& ar);
  43. };
  44.  
  45. /////////////////////////////////////////////////////////////////////////////
  46. // class CSribbleDoc
  47.  
  48. class CScribbleDoc : public CDocument
  49. {
  50. protected: // create from serialization only
  51.     CScribbleDoc();
  52.     DECLARE_DYNCREATE(CScribbleDoc)
  53.  
  54. // Attributes
  55. protected:
  56.     // The document keeps track of the current pen width on
  57.     // behalf of all views. We'd like the user interface of
  58.     // Scribble to be such that if the user chooses the Draw
  59.     // Thick Line command, it will apply to all views, not just
  60.     // the view that currently has the focus.
  61.     enum PENWIDTH {THIN = 2, THICK = 5};
  62.     PENWIDTH            m_nPenWidth;        // current user-selected pen width
  63.     CPen                m_penCur;           // pen created according to
  64.                                             // user-selected pen style (width)
  65. public:
  66.     CTypedPtrList<CObList,CStroke*>     m_strokeList;   
  67.     CPen*           GetCurrentPen() { return &m_penCur; }
  68.     PENWIDTH        GetPenWidth() const { return m_nPenWidth; }
  69. // Operations
  70. public:
  71.     CStroke* NewStroke();
  72.  
  73. // Overrides
  74.     // ClassWizard generated virtual function overrides
  75.     //{{AFX_VIRTUAL(CScribbleDoc)
  76.     public:
  77.     virtual BOOL OnNewDocument();
  78.     virtual void Serialize(CArchive& ar);
  79.     virtual BOOL OnOpenDocument(LPCTSTR lpszPathName);
  80.     virtual void DeleteContents();
  81.     //}}AFX_VIRTUAL
  82.  
  83. // Implementation
  84. public:
  85.     virtual ~CScribbleDoc();
  86. #ifdef _DEBUG
  87.     virtual void AssertValid() const;
  88.     virtual void Dump(CDumpContext& dc) const;
  89. #endif
  90.  
  91. protected:
  92.     void            InitDocument();
  93.     void CScribbleDoc::ChangePen(PENWIDTH penWidth);
  94. // Generated message map functions
  95. protected:
  96.     //{{AFX_MSG(CScribbleDoc)
  97.     afx_msg void OnPenChangetothickorthin();
  98.     //}}AFX_MSG
  99.     DECLARE_MESSAGE_MAP()
  100. };
  101.