home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / mfc / ole / bindscrb / scribdoc.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-03-27  |  3.7 KB  |  132 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-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. // Forward declaration of data structure class
  15.  
  16. class CScribItem;
  17.  
  18.  
  19. /////////////////////////////////////////////////////////////////////////////
  20. // class CStroke
  21. //
  22. // A stroke is a series of connected points in the scribble drawing.
  23. // A scribble document may have multiple strokes.
  24.  
  25. class CStroke : public CObject
  26. {
  27. public:
  28.     CStroke(UINT nPenWidth);
  29.  
  30. protected:
  31.     CStroke();
  32.     DECLARE_SERIAL(CStroke)
  33.  
  34. // Attributes
  35.     UINT                   m_nPenWidth;    // one pen width applies to entire stroke
  36.     CArray<CPoint,CPoint>  m_pointArray;   // series of connected points
  37.     CRect               m_rectBounding; // smallest rect that surrounds all
  38.                                         // of the points in the stroke
  39.                                         // measured in MM_LOENGLISH units
  40.                                         // (0.01 inches, with Y-axis inverted)
  41. public:
  42.     CRect& GetBoundingRect() { return m_rectBounding; }
  43.  
  44. // Operations
  45. public:
  46.     BOOL DrawStroke(CDC* pDC);
  47.     void FinishStroke();
  48.  
  49. public:
  50.     virtual void Serialize(CArchive& ar);
  51. };
  52.  
  53.  
  54. /////////////////////////////////////////////////////////////////////////////
  55. // class CScribDoc
  56.  
  57. class CScribDoc : public COleServerDoc
  58. {
  59. protected: // create from serialization only
  60.     CScribDoc();
  61.     DECLARE_DYNCREATE(CScribDoc)
  62.  
  63. // Attributes
  64. protected:
  65.     // The document keeps track of the current pen width on
  66.     // behalf of all views. We'd like the user interface of
  67.     // Scribble to be such that if the user chooses the Draw
  68.     // Thick Line command, it will apply to all views, not just
  69.     // the view that currently has the focus.
  70.  
  71.     UINT            m_nPenWidth;        // current user-selected pen width
  72.     BOOL            m_bThickPen;        // TRUE if current pen is thick
  73.     UINT            m_nThinWidth;
  74.     UINT            m_nThickWidth;
  75.     CPen            m_penCur;           // pen created according to
  76.                                         // user-selected pen style (width)
  77. public:
  78.     CTypedPtrList<CObList,CStroke*>     m_strokeList;
  79.     CPen*           GetCurrentPen() { return &m_penCur; }
  80.  
  81. protected:
  82.     CSize           m_sizeDoc;
  83. public:
  84.     CSize GetDocSize() { return m_sizeDoc; }
  85.     COleServerItem* OnGetEmbeddedItem();
  86.     CScribItem* GetEmbeddedItem()
  87.         { return (CScribItem*)COleServerDoc::GetEmbeddedItem(); }
  88.  
  89.     CDocObjectServer* GetDocObjectServer(LPOLEDOCUMENTSITE pSite);
  90.  
  91. // Operations
  92. public:
  93.     CStroke* NewStroke();
  94.  
  95. // Overrides
  96.     // ClassWizard generated virtual function overrides
  97.     //{{AFX_VIRTUAL(CScribDoc)
  98.     public:
  99.     virtual BOOL OnNewDocument();
  100.     virtual BOOL OnOpenDocument(LPCTSTR lpszPathName);
  101.     virtual void DeleteContents();
  102.     //}}AFX_VIRTUAL
  103.  
  104. // Implementation
  105. protected:
  106.     void ReplacePen();
  107.     void OnSetItemRects(LPCRECT lpPosRect, LPCRECT lpClipRect);
  108.  
  109. public:
  110.     virtual ~CScribDoc();
  111.     virtual void Serialize(CArchive& ar);   // overridden for document i/o
  112. #ifdef _DEBUG
  113.     virtual void AssertValid() const;
  114.     virtual void Dump(CDumpContext& dc) const;
  115. #endif
  116. protected:
  117.     void            InitDocument();
  118.  
  119. // Generated message map functions
  120. protected:
  121.     //{{AFX_MSG(CScribDoc)
  122.     afx_msg void OnEditClearAll();
  123.     afx_msg void OnPenThickOrThin();
  124.     afx_msg void OnUpdateEditClearAll(CCmdUI* pCmdUI);
  125.     afx_msg void OnUpdatePenThickOrThin(CCmdUI* pCmdUI);
  126.     afx_msg void OnPenWidths();
  127.     afx_msg void OnEditCopy();
  128.     //}}AFX_MSG
  129.     DECLARE_MESSAGE_MAP()
  130.     DECLARE_OLECMD_MAP()
  131. };
  132.