home *** CD-ROM | disk | FTP | other *** search
/ Mastering MFC Development / MMD.ISO / labs / c05 / lab03 / ex01 / scribdoc.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-02-20  |  3.1 KB  |  110 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.     void OnUpdatePenPixel(CCmdUI * pCmdUI);
  52.     CScribbleDoc();
  53.     DECLARE_DYNCREATE(CScribbleDoc)
  54.  
  55.  
  56. // Attributes
  57. protected:
  58.     // The document keeps track of the current pen width on
  59.     // behalf of all views. We'd like the user interface of
  60.     // Scribble to be such that if the user chooses the Draw
  61.     // Thick Line command, it will apply to all views, not just
  62.     // the view that currently has the focus.
  63.     enum PENWIDTH { VERY_THIN    = 1,
  64.                     THIN        = 2,
  65.                     MEDIUM        = 3,
  66.                     HEAVY        = 4,
  67.                     THICK        = 5,
  68.                     VERY_THICK    = 6 };
  69.     PENWIDTH        m_nPenWidth;        // current user-selected pen width
  70.     CPen            m_penCur;           // pen created according to
  71.                                         // user-selected pen style (width)
  72. public:
  73.     CTypedPtrList<CObList,CStroke*>     m_strokeList;   
  74.     CPen*           GetCurrentPen() { return &m_penCur; }
  75.     PENWIDTH        GetPenWidth() const    { return m_nPenWidth; }
  76.  
  77. // Operations
  78. public:
  79.     CStroke* NewStroke();
  80.  
  81. // Overrides
  82.     // ClassWizard generated virtual function overrides
  83.     //{{AFX_VIRTUAL(CScribbleDoc)
  84.     public:
  85.     virtual BOOL OnNewDocument();
  86.     virtual void Serialize(CArchive& ar);
  87.     virtual BOOL OnOpenDocument(LPCTSTR lpszPathName);
  88.     virtual void DeleteContents();
  89.     //}}AFX_VIRTUAL
  90.  
  91. // Implementation
  92. public:
  93.     virtual ~CScribbleDoc();
  94. #ifdef _DEBUG
  95.     virtual void AssertValid() const;
  96.     virtual void Dump(CDumpContext& dc) const;
  97. #endif
  98.  
  99. protected:
  100.     void            InitDocument();
  101.     void ChangePen (PENWIDTH penWidth);
  102.  
  103. // Generated message map functions
  104. protected:
  105.     //{{AFX_MSG(CScribbleDoc)
  106.     afx_msg void OnPenPixel(UINT nID);
  107.     //}}AFX_MSG
  108.     DECLARE_MESSAGE_MAP()
  109. };
  110.