home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c480 / 19.ddi / MFC / SAMPLES / SCRIBBLE / STEP5 / SCRIBDOC.H_ / SCRIBDOC.H
Encoding:
C/C++ Source or Header  |  1993-02-08  |  3.5 KB  |  120 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. protected:
  41.     CSize           m_sizeDoc;
  42. public:
  43.     CSize GetDocSize() { return m_sizeDoc; }
  44.  
  45. // Operations
  46. public:
  47.     void DeleteContents();
  48.     CStroke* NewStroke();
  49.     POSITION GetFirstStrokePos();
  50.     CStroke* GetNextStroke(POSITION& pos);
  51.  
  52. // Implementation
  53. protected:
  54.     void ReplacePen();
  55.  
  56. public:
  57.     virtual ~CScribDoc();
  58.     virtual void Serialize(CArchive& ar);   // overridden for document i/o
  59. #ifdef _DEBUG
  60.     virtual void AssertValid() const;
  61.     virtual void Dump(CDumpContext& dc) const;
  62. #endif
  63. protected:
  64.     void            InitDocument();
  65.     virtual BOOL    OnNewDocument();
  66.     virtual BOOL    OnOpenDocument(const char* pszPathName);
  67.  
  68. // Generated message map functions
  69. protected:
  70.     //{{AFX_MSG(CScribDoc)
  71.         // NOTE - the ClassWizard will add and remove member functions here.
  72.         //    DO NOT EDIT what you see in these blocks of generated code !
  73.     afx_msg void OnEditClearAll();
  74.     afx_msg void OnUpdateEditClearAll(CCmdUI* pCmdUI);
  75.     afx_msg void OnPenThickOrThin();
  76.     afx_msg void OnUpdatePenThickOrThin(CCmdUI* pCmdUI);
  77.     afx_msg void OnPenWidths();
  78.     //}}AFX_MSG
  79.     DECLARE_MESSAGE_MAP()
  80. };
  81.  
  82. /////////////////////////////////////////////////////////////////////////////
  83. // class CStroke
  84. //
  85. // A stroke is a series of connected points in the scribble drawing.
  86. // A scribble document may have multiple strokes.
  87.  
  88. class CStroke : public CObject
  89. {
  90. public:
  91.     CStroke(UINT nPenWidth);
  92.  
  93. protected:
  94.     CStroke();
  95.     DECLARE_SERIAL(CStroke)
  96.  
  97. // Attributes
  98.     UINT                m_nPenWidth;    // one pen width applies to entire stroke
  99.     CDWordArray         m_pointArray;   // series of connected points
  100.     CRect               m_rectBounding; // smallest rect that surrounds all
  101.                                         // of the points in the stroke
  102.                                         // measured in MM_LOENGLISH units
  103.                                         // (0.01 inches, with Y-axis inverted)
  104. public:
  105.     CRect& GetBoundingRect() { return m_rectBounding; }
  106.  
  107. // Operations
  108. public:
  109.     void AddPoint(CPoint pt);
  110.     BOOL DrawStroke(CDC* pDC);
  111.     void FinishStroke();
  112.  
  113. // Helper functions
  114. protected:
  115.     CPoint GetPoint(int i) const { return CPoint(m_pointArray[i]); }
  116.  
  117. public:
  118.     virtual void Serialize(CArchive& ar);
  119. };
  120.