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 / step1 / scribdoc.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-03-27  |  2.7 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-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.     CPen            m_penCur;           // pen created according to
  63.                                         // user-selected pen style (width)
  64. public:
  65.     CTypedPtrList<CObList,CStroke*>     m_strokeList;
  66.     CPen*           GetCurrentPen() { return &m_penCur; }
  67.  
  68. // Operations
  69. public:
  70.     CStroke* NewStroke();
  71.  
  72. // Overrides
  73.     // ClassWizard generated virtual function overrides
  74.     //{{AFX_VIRTUAL(CScribbleDoc)
  75.     public:
  76.     virtual BOOL OnNewDocument();
  77.     virtual void Serialize(CArchive& ar);
  78.     virtual BOOL OnOpenDocument(LPCTSTR lpszPathName);
  79.     virtual void DeleteContents();
  80.     //}}AFX_VIRTUAL
  81.  
  82. // Implementation
  83. public:
  84.     virtual ~CScribbleDoc();
  85. #ifdef _DEBUG
  86.     virtual void AssertValid() const;
  87.     virtual void Dump(CDumpContext& dc) const;
  88. #endif
  89.  
  90. protected:
  91.     void            InitDocument();
  92.  
  93. // Generated message map functions
  94. protected:
  95.     //{{AFX_MSG(CScribbleDoc)
  96.         // NOTE - the ClassWizard will add and remove member functions here.
  97.         //    DO NOT EDIT what you see in these blocks of generated code !
  98.     //}}AFX_MSG
  99.     DECLARE_MESSAGE_MAP()
  100. };
  101.