////////////////////////////////////////////////////////////////////////////// //文件: CItem类扩展 //主要功能: // 操作各类元素或完成一定的功能 // //程序编写: 2006-12-07 // // ///////////////////////////////////////////////////////////////////////////// #pragma once #include "itemBase.h" #include "cursor.h" #include "DrawOperator\memdc.h" namespace NDrawView { #define ITEM_VIEW_DEFAULT 0 #define ITEM_VIEW_PRINT 1 class CItemView : public CItemBase { public: CItemView(void); CItemView(CSigmaDoc * ppDoc); virtual ~CItemView(void); void OnLButtonDown(CDC *pDC, UINT nFlags, CPoint point, int vk) override; void OnLButtonUp(CDC *pDC, UINT nFlags, CPoint point, int vk) override; int OnMouseMove(CDC *pDC, UINT nFlags, CPoint point) override; void OnRButtonDblClk(UINT nFlags, CPoint point) override; void OnRButtonDown(UINT nFlags, CPoint point) override; BOOL OnRButtonUp(UINT nFlags, CPoint point) override; BOOL OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) override; BOOL OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags) override; BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message) override; //<打印及打印预览> void SetScreenRect(CRect rect); virtual void OnLButtonDownForPreviewPrint(UINT nFlags, CPoint point); virtual void OnLButtonUpForPreviewPrint(UINT nFlags, CPoint point); virtual void OnMouseMoveForPreviewPrint(UINT nFlags, CPoint point); void ScreenToPrint(CPoint & point); void GetViewFactors(double & offsetXOut, double & offsetYOut, double & zoomFactorOut); void SetViewFactors(double offsetX, double offsetY, double zoomFactor); void SetViewScreenFactors(double offsetX, double offsetY, double zoomFactor); // 变换到原始坐标 double TransfromX(double x); double TransfromY(double y); CRect TransfromRect(CRect rtSource); double DeTransfromX(double x); double DeTransfromY(double y); // 转换到变换坐标 CRect DeTransfromRect(CRect rtSource); // void SetMemDC(CMemoryDC* pMemViewDC) { m_pMemViewDC = pMemViewDC; } CDC * GetMemDC(void) { return m_pMemViewDC; } virtual CRect GetClientRect(void); virtual void setClientRect(CRect rect); virtual int GetPanMode(void); virtual BOOL GetViewRange(CRect8& rect); //获得要全图显示的范围 eCursorSelectStruct GetCursor(void); int IsViewState(void); void Extend(int mode); void Enlarge(void); void Reduce(void); void Reduce(double factor); /** * 放大画布 * * \param point 放大的中心点 * \param factor 放大倍数,事实上缩小也是它,小于 1 时为缩小 */ void Reduce(CPoint2D point, double factor); void ReduceForScreenPoint(); void PanTo(CPoint2D point); //移动到point,以point为中心 void EnableOldMode(BOOL bEnable); BOOL IsOldMode(void); public: CView* GetActiveView(void); BOOL IsCaptureCursor(void); void SetDisplayRange(void); int zoomMode; protected: CPoint m_ptLeft; CRect8 m_rect; CRect8 m_rectForPrint; CRect m_scressRect; CRect m_clientRect; BOOL bCaptureCursor; // CMemoryDC m_MemDC; BOOL m_bRButtonDown; BOOL m_bEnableCaptureCursor; BOOL m_bOldViewMode; //int m_type; CMemoryDC* m_pMemViewDC; double m_offsetX; double m_offsetY; double m_zoomFactor; double m_offsetScreenX; double m_offsetScreenY; double m_screenFactor; void LButtonDownPan(CPoint point); void MouseMovePan(CPoint point); void MouseMovePanForPreviewPrint(CPoint point); void LButtonUpPan(CPoint point); void RectangleSolid(CXyDC* pDC, CRect8* pRect); }; };