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