home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / mfc / ole / drawcli / drawvw.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-03-27  |  5.8 KB  |  168 lines

  1. // drawvw.h : interface of the CDrawView 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. // Hints for UpdateAllViews/OnUpdate
  15. #define HINT_UPDATE_WINDOW      0
  16. #define HINT_UPDATE_DRAWOBJ     1
  17. #define HINT_UPDATE_SELECTION   2
  18. #define HINT_DELETE_SELECTION   3
  19. #define HINT_UPDATE_OLE_ITEMS   4
  20.  
  21. class CDrawObj;
  22.  
  23. class CDrawView : public CScrollView
  24. {
  25. protected: // create from serialization only
  26.     CDrawView();
  27.     DECLARE_DYNCREATE(CDrawView)
  28.  
  29. // Attributes
  30. public:
  31.     CDrawDoc* GetDocument()
  32.         { return (CDrawDoc*)m_pDocument; }
  33.     void SetPageSize(CSize size);
  34.     CRect GetInitialPosition();
  35.  
  36. // Operations
  37. public:
  38.     void DocToClient(CRect& rect);
  39.     void DocToClient(CPoint& point);
  40.     void ClientToDoc(CPoint& point);
  41.     void ClientToDoc(CRect& rect);
  42.     void Select(CDrawObj* pObj, BOOL bAdd = FALSE);
  43.     void SelectWithinRect(CRect rect, BOOL bAdd = FALSE);
  44.     void Deselect(CDrawObj* pObj);
  45.     void CloneSelection();
  46.     void UpdateActiveItem();
  47.     void InvalObj(CDrawObj* pObj);
  48.     void Remove(CDrawObj* pObj);
  49.     void PasteNative(COleDataObject& dataObject);
  50.     void PasteEmbedded(COleDataObject& dataObject, CPoint point );
  51.  
  52. // Implementation
  53. protected:
  54.     // added for drop-target functionality
  55.     COleDropTarget m_dropTarget;        // for drop target functionality
  56.     CPoint m_dragPoint;                 // current position
  57.     CSize m_dragSize;                   // size of dragged object
  58.     CSize m_dragOffset;                 // offset between pt and drag object corner
  59.     DROPEFFECT m_prevDropEffect;
  60.     BOOL m_bDragDataAcceptable;
  61.  
  62.     BOOL GetObjectInfo(COleDataObject* pDataObject,
  63.         CSize* pSize, CSize* pOffset);
  64.     // end of drop-target additions
  65.  
  66. public:
  67.     virtual ~CDrawView();
  68. #ifdef _DEBUG
  69.     virtual void AssertValid() const;
  70.     virtual void Dump(CDumpContext& dc) const;
  71. #endif
  72.  
  73.     virtual void OnPrint(CDC* pDC, CPrintInfo* pInfo);  // overriden to record time/date
  74.     virtual void OnDraw(CDC* pDC);  // overridden to draw this view
  75.     virtual void OnActivateView(BOOL bActivate, CView* pActiveView, CView* pDeactiveView);
  76.     virtual void OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint);
  77.     virtual void OnPrepareDC(CDC* pDC, CPrintInfo* pInfo);
  78.     virtual BOOL OnScrollBy(CSize sizeScroll, BOOL bDoScroll);
  79.     virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
  80.     void DrawGrid(CDC* pDC);
  81.  
  82.     // added for drop-target functionality
  83.     virtual BOOL OnDrop(COleDataObject* pDataObject,
  84.         DROPEFFECT dropEffect, CPoint point);
  85.     virtual DROPEFFECT OnDragEnter(COleDataObject* pDataObject,
  86.         DWORD grfKeyState, CPoint point);
  87.     virtual DROPEFFECT OnDragOver(COleDataObject* pDataObject,
  88.         DWORD grfKeyState, CPoint point);
  89.     virtual void OnDragLeave();
  90.     static CLIPFORMAT m_cfObjectDescriptor;
  91.     // end of drop-target additions
  92.  
  93.     static CLIPFORMAT m_cfDraw; // custom clipboard format
  94.  
  95.     CDrawObjList m_selection;
  96.     BOOL m_bGrid;
  97.     COLORREF m_gridColor;
  98.     BOOL m_bActive; // is the view active?
  99.  
  100. protected:
  101.     virtual void OnInitialUpdate(); // called first time after construct
  102.  
  103.     // Printing support
  104.     virtual BOOL OnPreparePrinting(CPrintInfo* pInfo);
  105.     virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo);
  106.     virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo);
  107.  
  108.     // OLE Container support
  109. public:
  110.     virtual BOOL IsSelected(const CObject* pDocItem) const;
  111.  
  112. // Generated message map functions
  113. protected:
  114.     //{{AFX_MSG(CDrawView)
  115.     afx_msg void OnInsertObject();
  116.     afx_msg void OnCancelEdit();
  117.     afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
  118.     afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
  119.     afx_msg void OnMouseMove(UINT nFlags, CPoint point);
  120.     afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
  121.     afx_msg void OnDrawSelect();
  122.     afx_msg void OnDrawRoundRect();
  123.     afx_msg void OnDrawRect();
  124.     afx_msg void OnDrawLine();
  125.     afx_msg void OnDrawEllipse();
  126.     afx_msg void OnUpdateDrawEllipse(CCmdUI* pCmdUI);
  127.     afx_msg void OnUpdateDrawLine(CCmdUI* pCmdUI);
  128.     afx_msg void OnUpdateDrawRect(CCmdUI* pCmdUI);
  129.     afx_msg void OnUpdateDrawRoundRect(CCmdUI* pCmdUI);
  130.     afx_msg void OnUpdateDrawSelect(CCmdUI* pCmdUI);
  131.     afx_msg void OnUpdateSingleSelect(CCmdUI* pCmdUI);
  132.     afx_msg void OnEditSelectAll();
  133.     afx_msg void OnEditClear();
  134.     afx_msg void OnUpdateAnySelect(CCmdUI* pCmdUI);
  135.     afx_msg void OnDrawPolygon();
  136.     afx_msg void OnUpdateDrawPolygon(CCmdUI* pCmdUI);
  137.     afx_msg void OnSize(UINT nType, int cx, int cy);
  138.     afx_msg void OnViewGrid();
  139.     afx_msg void OnUpdateViewGrid(CCmdUI* pCmdUI);
  140.     afx_msg BOOL OnEraseBkgnd(CDC* pDC);
  141.     afx_msg void OnObjectFillColor();
  142.     afx_msg void OnObjectLineColor();
  143.     afx_msg void OnObjectMoveBack();
  144.     afx_msg void OnObjectMoveForward();
  145.     afx_msg void OnObjectMoveToBack();
  146.     afx_msg void OnObjectMoveToFront();
  147.     afx_msg void OnEditCopy();
  148.     afx_msg void OnUpdateEditCopy(CCmdUI* pCmdUI);
  149.     afx_msg void OnEditCut();
  150.     afx_msg void OnUpdateEditCut(CCmdUI* pCmdUI);
  151.     afx_msg void OnEditPaste();
  152.     afx_msg void OnUpdateEditPaste(CCmdUI* pCmdUI);
  153.     afx_msg void OnFilePrint();
  154.     afx_msg void OnSetFocus(CWnd* pOldWnd);
  155.     afx_msg void OnViewShowObjects();
  156.     afx_msg void OnUpdateViewShowObjects(CCmdUI* pCmdUI);
  157.     afx_msg void OnEditProperties();
  158.     afx_msg void OnUpdateEditProperties(CCmdUI* pCmdUI);
  159.     afx_msg void OnDestroy();
  160.     afx_msg void OnUpdateEditSelectAll(CCmdUI* pCmdUI);
  161.     afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
  162.     afx_msg void OnContextMenu(CWnd* pWnd, CPoint point);
  163.     //}}AFX_MSG
  164.     DECLARE_MESSAGE_MAP()
  165. };
  166.  
  167. /////////////////////////////////////////////////////////////////////////////
  168.