home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / mfc / tutorial / scribble / step3 / scribdoc.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-03-27  |  2.9 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-1998 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.  
  16. /////////////////////////////////////////////////////////////////////////////
  17. // class CStroke
  18. //
  19. // A stroke is a series of connected points in the scribble drawing.
  20. // A scribble document may have multiple strokes.
  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.  
  47. class CScribbleDoc : public CDocument
  48. {
  49. protected: // create from serialization only
  50.     CScribbleDoc();
  51.     DECLARE_DYNCREATE(CScribbleDoc)
  52.  
  53. // Attributes
  54. protected:
  55.     // The document keeps track of the current pen width on
  56.     // behalf of all views. We'd like the user interface of
  57.     // Scribble to be such that if the user chooses the Draw
  58.     // Thick Line command, it will apply to all views, not just
  59.     // the view that currently has the focus.
  60.  
  61.     UINT            m_nPenWidth;        // current user-selected pen width
  62.     BOOL            m_bThickPen;        // TRUE if current pen is thick
  63.     UINT            m_nThinWidth;
  64.     UINT            m_nThickWidth;
  65.     CPen            m_penCur;           // pen created according to
  66.                                         // user-selected pen style (width)
  67. public:
  68.     CTypedPtrList<CObList,CStroke*>     m_strokeList;
  69.     CPen*           GetCurrentPen() { return &m_penCur; }
  70.  
  71. // Operations
  72. public:
  73.     CStroke* NewStroke();
  74.  
  75. // Overrides
  76.     // ClassWizard generated virtual function overrides
  77.     //{{AFX_VIRTUAL(CScribbleDoc)
  78.     public:
  79.     virtual BOOL OnNewDocument();
  80.     virtual void Serialize(CArchive& ar);
  81.     virtual BOOL OnOpenDocument(LPCTSTR lpszPathName);
  82.     virtual void DeleteContents();
  83.     //}}AFX_VIRTUAL
  84.  
  85. // Implementation
  86. protected:
  87.     void ReplacePen();
  88.  
  89. public:
  90.     virtual ~CScribbleDoc();
  91. #ifdef _DEBUG
  92.     virtual void AssertValid() const;
  93.     virtual void Dump(CDumpContext& dc) const;
  94. #endif
  95.  
  96. protected:
  97.     void            InitDocument();
  98.  
  99. // Generated message map functions
  100. protected:
  101.     //{{AFX_MSG(CScribbleDoc)
  102.     afx_msg void OnEditClearAll();
  103.     afx_msg void OnPenThickOrThin();
  104.     afx_msg void OnUpdateEditClearAll(CCmdUI* pCmdUI);
  105.     afx_msg void OnUpdatePenThickOrThin(CCmdUI* pCmdUI);
  106.     afx_msg void OnPenWidths();
  107.     //}}AFX_MSG
  108.     DECLARE_MESSAGE_MAP()
  109. };
  110.