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 / step5 / scribdoc.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-03-27  |  3.3 KB  |  122 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.     CRect               m_rectBounding; // smallest rect that surrounds all
  37.                                         // of the points in the stroke
  38.                                         // measured in MM_LOENGLISH units
  39.                                         // (0.01 inches, with Y-axis inverted)
  40. public:
  41.     CRect& GetBoundingRect() { return m_rectBounding; }
  42.  
  43. // Operations
  44. public:
  45.     BOOL DrawStroke(CDC* pDC);
  46.     void FinishStroke();
  47.  
  48. public:
  49.     virtual void Serialize(CArchive& ar);
  50. };
  51.  
  52.  
  53.  
  54. class CScribbleDoc : public CDocument
  55. {
  56. protected: // create from serialization only
  57.     CScribbleDoc();
  58.     DECLARE_DYNCREATE(CScribbleDoc)
  59.  
  60. // Attributes
  61. protected:
  62.     // The document keeps track of the current pen width on
  63.     // behalf of all views. We'd like the user interface of
  64.     // Scribble to be such that if the user chooses the Draw
  65.     // Thick Line command, it will apply to all views, not just
  66.     // the view that currently has the focus.
  67.  
  68.     UINT            m_nPenWidth;        // current user-selected pen width
  69.     BOOL            m_bThickPen;        // TRUE if current pen is thick
  70.     UINT            m_nThinWidth;
  71.     UINT            m_nThickWidth;
  72.     CPen            m_penCur;           // pen created according to
  73.                                         // user-selected pen style (width)
  74. public:
  75.     CTypedPtrList<CObList,CStroke*>     m_strokeList;
  76.     CPen*           GetCurrentPen() { return &m_penCur; }
  77.  
  78. protected:
  79.     CSize           m_sizeDoc;
  80. public:
  81.     CSize GetDocSize() { return m_sizeDoc; }
  82.  
  83. // Operations
  84. public:
  85.     CStroke* NewStroke();
  86.  
  87. // Overrides
  88.     // ClassWizard generated virtual function overrides
  89.     //{{AFX_VIRTUAL(CScribbleDoc)
  90.     public:
  91.     virtual BOOL OnNewDocument();
  92.     virtual void Serialize(CArchive& ar);
  93.     virtual BOOL OnOpenDocument(LPCTSTR lpszPathName);
  94.     virtual void DeleteContents();
  95.     //}}AFX_VIRTUAL
  96.  
  97. // Implementation
  98. protected:
  99.     void ReplacePen();
  100.  
  101. public:
  102.     virtual ~CScribbleDoc();
  103. #ifdef _DEBUG
  104.     virtual void AssertValid() const;
  105.     virtual void Dump(CDumpContext& dc) const;
  106. #endif
  107.  
  108. protected:
  109.     void            InitDocument();
  110.  
  111. // Generated message map functions
  112. protected:
  113.     //{{AFX_MSG(CScribbleDoc)
  114.     afx_msg void OnEditClearAll();
  115.     afx_msg void OnPenThickOrThin();
  116.     afx_msg void OnUpdateEditClearAll(CCmdUI* pCmdUI);
  117.     afx_msg void OnUpdatePenThickOrThin(CCmdUI* pCmdUI);
  118.     afx_msg void OnPenWidths();
  119.     //}}AFX_MSG
  120.     DECLARE_MESSAGE_MAP()
  121. };
  122.