home *** CD-ROM | disk | FTP | other *** search
/ QBasic & Borland Pascal & C / Delphi5.iso / C / BC_502 / SCRIB2.PAK / SCRIBDOC.H < prev    next >
Encoding:
C/C++ Source or Header  |  1997-05-06  |  3.0 KB  |  108 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. // Forward declaration of data structure class
  15. class CStroke;
  16.  
  17. class CScribbleDoc : public CDocument
  18. {
  19. protected: // create from serialization only
  20.     CScribbleDoc();
  21.     DECLARE_DYNCREATE(CScribbleDoc)
  22.  
  23. // Attributes
  24. protected:
  25.     // The document keeps track of the current pen width on
  26.     // behalf of all views. We'd like the user interface of
  27.     // Scribble to be such that if the user chooses the Draw
  28.     // Thick Line command, it will apply to all views, not just
  29.     // 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.     CTypedPtrList<CObList,CStroke*>     m_strokeList;   
  39.     CPen*           GetCurrentPen() { return &m_penCur; }
  40.  
  41. // Operations
  42. public:
  43.     CStroke* NewStroke();
  44.  
  45. // Overrides
  46.     // ClassWizard generated virtual function overrides
  47.     //{{AFX_VIRTUAL(CScribbleDoc)
  48.     public:
  49.     virtual BOOL OnNewDocument();
  50.     virtual void Serialize(CArchive& ar);
  51.     virtual BOOL OnOpenDocument(LPCTSTR lpszPathName);
  52.     virtual void DeleteContents();
  53.     //}}AFX_VIRTUAL
  54.  
  55. // Implementation
  56. protected:
  57.     void ReplacePen();
  58.  
  59. public:
  60.     virtual ~CScribbleDoc();
  61. #ifdef _DEBUG
  62.     virtual void AssertValid() const;
  63.     virtual void Dump(CDumpContext& dc) const;
  64. #endif
  65.  
  66. protected:
  67.     void            InitDocument();
  68.  
  69. // Generated message map functions
  70. protected:
  71.     //{{AFX_MSG(CScribbleDoc)
  72.     afx_msg void OnEditClearAll();
  73.     afx_msg void OnPenThickOrThin();
  74.     afx_msg void OnUpdateEditClearAll(CCmdUI* pCmdUI);
  75.     afx_msg void OnUpdatePenThickOrThin(CCmdUI* pCmdUI);
  76.     //}}AFX_MSG
  77.     DECLARE_MESSAGE_MAP()
  78. };
  79.  
  80. /////////////////////////////////////////////////////////////////////////////
  81. // class CStroke
  82. //
  83. // A stroke is a series of connected points in the scribble drawing.
  84. // A scribble document may have multiple strokes.
  85.  
  86. class CStroke : public CObject
  87. {
  88. public:
  89.     CStroke(UINT nPenWidth);
  90.  
  91. protected:
  92.     CStroke();
  93.     DECLARE_SERIAL(CStroke)
  94.  
  95. // Attributes
  96. protected:
  97.     UINT                   m_nPenWidth;    // one pen width applies to entire stroke
  98. public:
  99.     CArray<CPoint,CPoint>  m_pointArray;   // series of connected points
  100.  
  101. // Operations
  102. public:
  103.     BOOL DrawStroke(CDC* pDC);
  104.  
  105. public:
  106.     virtual void Serialize(CArchive& ar);
  107. };
  108.