home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c480 / 19.ddi / MFC / SAMPLES / SCRIBBLE / STEP1 / SCRIBDOC.H_ / SCRIBDOC.H
Encoding:
C/C++ Source or Header  |  1993-02-08  |  2.7 KB  |  99 lines

  1. // scribdoc.h : interface of the CScribDoc class
  2. //
  3. // This is a part of the Microsoft Foundation Classes C++ library.
  4. // Copyright (C) 1992 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 Microsoft
  9. // QuickHelp and/or WinHelp documentation provided with the library.
  10. // See these sources for detailed information regarding the
  11. // Microsoft Foundation Classes product.
  12.  
  13.  
  14. class CStroke;
  15.  
  16. class CScribDoc : public CDocument
  17. {
  18. protected: // create from serialization only
  19.     CScribDoc();
  20.     DECLARE_DYNCREATE(CScribDoc)
  21.  
  22. // Attributes
  23. protected:
  24.     CObList         m_strokeList;   // Each member of the list is a CStroke
  25.  
  26.     // The document keeps track of the current pen width on behalf of
  27.     // all views. We'd like the user interface of Scribble to be such
  28.     // that if the user chooses the Draw Thick Line command, it will apply
  29.     // to all views, not just the view that currently has the focus.
  30.  
  31.     UINT            m_nPenWidth;        // current user-selected pen width
  32.     CPen            m_penCur;           // pen created according to
  33.                                         // user-selected pen style (width)
  34. public:
  35.     CPen*           GetCurrentPen() { return &m_penCur; }
  36.  
  37.  
  38. // Operations
  39. public:
  40.     void DeleteContents();
  41.     CStroke* NewStroke();
  42.     POSITION GetFirstStrokePos();
  43.     CStroke* GetNextStroke(POSITION& pos);
  44.  
  45. // Implementation
  46.  
  47. public:
  48.     virtual ~CScribDoc();
  49.     virtual void Serialize(CArchive& ar);   // overridden for document i/o
  50. #ifdef _DEBUG
  51.     virtual void AssertValid() const;
  52.     virtual void Dump(CDumpContext& dc) const;
  53. #endif
  54. protected:
  55.     void            InitDocument();
  56.     virtual BOOL    OnNewDocument();
  57.     virtual BOOL    OnOpenDocument(const char* pszPathName);
  58.  
  59. // Generated message map functions
  60. protected:
  61.     //{{AFX_MSG(CScribDoc)
  62.         // NOTE - the ClassWizard will add and remove member functions here.
  63.         //    DO NOT EDIT what you see in these blocks of generated code !
  64.     //}}AFX_MSG
  65.     DECLARE_MESSAGE_MAP()
  66. };
  67.  
  68. /////////////////////////////////////////////////////////////////////////////
  69. // class CStroke
  70. //
  71. // A stroke is a series of connected points in the scribble drawing.
  72. // A scribble document may have multiple strokes.
  73.  
  74. class CStroke : public CObject
  75. {
  76. public:
  77.     CStroke(UINT nPenWidth);
  78.  
  79. protected:
  80.     CStroke();
  81.     DECLARE_SERIAL(CStroke)
  82.  
  83. // Attributes
  84.     UINT                m_nPenWidth;    // one pen width applies to entire stroke
  85.     CDWordArray         m_pointArray;   // series of connected points
  86.  
  87. // Operations
  88. public:
  89.     void AddPoint(CPoint pt);
  90.     BOOL DrawStroke(CDC* pDC);
  91.  
  92. // Helper functions
  93. protected:
  94.     CPoint GetPoint(int i) const { return CPoint(m_pointArray[i]); }
  95.  
  96. public:
  97.     virtual void Serialize(CArchive& ar);
  98. };
  99.