home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c480 / 19.ddi / MFC / SAMPLES / SCRIBBLE / STEP2 / SCRIBDOC.H_ / SCRIBDOC.H
Encoding:
C/C++ Source or Header  |  1993-02-08  |  3.1 KB  |  108 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.     BOOL            m_bThickPen;        // TRUE if current pen is thick
  33.     UINT            m_nThinWidth;
  34.     UINT            m_nThickWidth;
  35.     CPen            m_penCur;           // pen created according to
  36.                                         // user-selected pen style (width)
  37. public:
  38.     CPen*           GetCurrentPen() { return &m_penCur; }
  39.  
  40.  
  41. // Operations
  42. public:
  43.     void DeleteContents();
  44.     CStroke* NewStroke();
  45.     POSITION GetFirstStrokePos();
  46.     CStroke* GetNextStroke(POSITION& pos);
  47.  
  48. // Implementation
  49. protected:
  50.     void ReplacePen();
  51.  
  52. public:
  53.     virtual ~CScribDoc();
  54.     virtual void Serialize(CArchive& ar);   // overridden for document i/o
  55. #ifdef _DEBUG
  56.     virtual void AssertValid() const;
  57.     virtual void Dump(CDumpContext& dc) const;
  58. #endif
  59. protected:
  60.     void            InitDocument();
  61.     virtual BOOL    OnNewDocument();
  62.     virtual BOOL    OnOpenDocument(const char* pszPathName);
  63.  
  64. // Generated message map functions
  65. protected:
  66.     //{{AFX_MSG(CScribDoc)
  67.         // NOTE - the ClassWizard will add and remove member functions here.
  68.         //    DO NOT EDIT what you see in these blocks of generated code !
  69.     afx_msg void OnEditClearAll();
  70.     afx_msg void OnUpdateEditClearAll(CCmdUI* pCmdUI);
  71.     afx_msg void OnPenThickOrThin();
  72.     afx_msg void OnUpdatePenThickOrThin(CCmdUI* pCmdUI);
  73.     //}}AFX_MSG
  74.     DECLARE_MESSAGE_MAP()
  75. };
  76.  
  77. /////////////////////////////////////////////////////////////////////////////
  78. // class CStroke
  79. //
  80. // A stroke is a series of connected points in the scribble drawing.
  81. // A scribble document may have multiple strokes.
  82.  
  83. class CStroke : public CObject
  84. {
  85. public:
  86.     CStroke(UINT nPenWidth);
  87.  
  88. protected:
  89.     CStroke();
  90.     DECLARE_SERIAL(CStroke)
  91.  
  92. // Attributes
  93.     UINT                m_nPenWidth;    // one pen width applies to entire stroke
  94.     CDWordArray         m_pointArray;   // series of connected points
  95.  
  96. // Operations
  97. public:
  98.     void AddPoint(CPoint pt);
  99.     BOOL DrawStroke(CDC* pDC);
  100.  
  101. // Helper functions
  102. protected:
  103.     CPoint GetPoint(int i) const { return CPoint(m_pointArray[i]); }
  104.  
  105. public:
  106.     virtual void Serialize(CArchive& ar);
  107. };
  108.