00001
00002
00003
00004
00005
00006
00007 #ifndef ZOOMVIEW_H
00008 #define ZOOMVIEW_H
00009
00010
00011
00012 class CZoomView : public CScrollView
00013 {
00014 DECLARE_DYNCREATE(CZoomView)
00015 protected:
00016 CZoomView();
00017
00018
00019 public:
00020
00021 void SetZoomSizes(SIZE sizeTotal,
00022 const SIZE& sizePage = sizeDefault,
00023 const SIZE& sizeLine = sizeDefault);
00024 void CenterOnLogicalPoint(CPoint ptCenter);
00025 CPoint GetLogicalCenterPoint(void);
00026
00027
00028 typedef enum {MODE_ZOOMOFF, MODE_ZOOMIN, MODE_ZOOMOUT} ZoomMode_;
00029 void SetZoomMode(ZoomMode_ zoomMode);
00030 ZoomMode_ GetZoomMode() {return m_zoomMode;};
00031 int DoZoomIn (CRect &rect);
00032 int DoZoomIn (CPoint *point = NULL, double delta = 1.25);
00033 int DoZoomOut (CPoint *point = NULL, double delta = 1.25);
00034 int DoZoomFull ();
00035
00036 double GetZoomRatio() const { return m_zoomScale; }
00037 void SetZoomRatio( double r ) { m_zoomScale = r; }
00038
00039
00040 virtual void NotifyZoom(void) {};
00041
00042
00043 void ViewDPtoLP (LPPOINT lpPoints, int nCount = 1);
00044 void ViewLPtoDP (LPPOINT lpPoints, int nCount = 1);
00045 void ClientToDevice(CPoint &point);
00046 void NormalizeRect(CRect &rect);
00047 void DrawBox(CDC &dc, CRect &rect, bool xor = true);
00048 void DrawLine(CDC &dc, const int &x1, const int &y1,
00049 const int &x2, const int &y2, bool xor = true);
00050
00051
00052 protected:
00053 virtual ~CZoomView();
00054 #ifdef _DEBUG
00055 virtual void AssertValid() const;
00056 #endif //_DEBUG
00057 virtual void OnPrepareDC(CDC* pDC, CPrintInfo* pInfo = NULL);
00058 virtual void OnDraw(CDC* pDC) { };
00059 private:
00060
00061 void PersistRatio(const CSize &orig, CSize &dest, CPoint &remainder);
00062 void CalcBars(void);
00063
00064
00065 ZoomMode_ m_zoomMode;
00066 bool m_bCaptured;
00067 CRect m_ptDragRect;
00068 CSize m_origTotalDev;
00069 CSize m_origPageDev;
00070 CSize m_origLineDev;
00071 double m_zoomScale;
00072 HCURSOR m_hZoomCursor;
00073
00074 public:
00075
00076
00077 afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
00078 afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
00079 afx_msg void OnMouseMove(UINT nFlags, CPoint point);
00080 afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
00081 afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
00082
00083
00084 DECLARE_MESSAGE_MAP()
00085 };
00086
00087
00088 #endif