GME  13
ScrollZoomView.h
Go to the documentation of this file.
00001 /*
00002 
00003   Custom ScrollView class by Peter
00004 
00005 */
00006 
00007 #if !defined(AFX_SROLLZOOMVIEW_H__4110C3CC_05C2_4E15_A035_0A8F39EF36A1__INCLUDED_)
00008 #define AFX_SROLLZOOMVIEW_H__4110C3CC_05C2_4E15_A035_0A8F39EF36A1__INCLUDED_
00009 
00010 #if _MSC_VER > 1000
00011 #pragma once
00012 #endif // _MSC_VER > 1000
00013 // SrollZoomView.h : header file
00014 //
00015 
00017 // class CScrollZoomView supports simple scrolling and scaling
00018 
00019 class CScrollZoomView : public CView
00020 {
00021         DECLARE_DYNAMIC(CScrollZoomView)
00022 
00023 // Constructors
00024 protected:
00025         CScrollZoomView();
00026 
00027         static UINT uCachedScrollLines;
00028         static bool bScrollLinesRequested;
00029 
00030 public:
00031         // used to specify default calculated page and line sizes
00032         static AFX_DATA const SIZE sizeDefault;
00033 
00034         static UINT GetMouseScrollLines(void);
00035 
00036         // in logical units - call one of the following Set routines
00037         void SetScaleToFitSize(SIZE sizeTotal);
00038         void SetScrollSizes(int nMapMode, SIZE sizeTotal, int scalePercent,
00039                                 const SIZE& sizePage = sizeDefault,
00040                                 const SIZE& sizeLine = sizeDefault);
00041 
00042 // Attributes
00043 public:
00044         CPoint GetScrollPosition() const;       // upper corner of scrolling
00045         CSize GetTotalSize() const                              { return m_totalLog; }             // logical size
00046 
00047         // for device units
00048         CPoint GetDeviceScrollPosition() const;
00049         void GetDeviceScrollSizes(int& nMapMode, SIZE& sizeTotal, SIZE& sizePage, SIZE& sizeLine) const;
00050 
00051 // Operations
00052 public:
00053         void ScrollToPosition(POINT pt);    // set upper left position
00054         void FillOutsideRect(CDC* pDC, CBrush* pBrush);
00055         void ResizeParentToFit(BOOL bShrinkOnly = TRUE);
00056         BOOL DoMouseWheel(UINT fFlags, short zDelta, CPoint point);
00057 
00058         void notifyPanning(CPoint pt);
00059 
00060 // Implementation
00061 protected:
00062         bool m_zoomScroll;
00063         CPoint m_zoomP;
00064         bool m_noHscroll; // hack terge
00065         bool m_noVscroll; // hack terge
00066 
00067         int m_nMapMode;
00068         CSize m_totalLog;           // total size in logical units (no rounding)
00069         CSize m_totalDev;           // total size in device units
00070         CSize m_pageDev;            // per page scroll size in device units
00071         CSize m_lineDev;            // per line scroll size in device units
00072         int       m_scalePercent;               // Modified by Peter
00073 
00074         BOOL m_bCenter;             // Center output if larger than total size
00075         BOOL m_bInsideUpdate;       // internal state for OnSize callback
00076         void CenterOnPoint(CPoint ptCenter);
00077         void ScrollToDevicePosition(POINT ptDev); // explicit scrolling no checking
00078 
00079 protected:
00080         virtual void OnDraw(CDC* pDC) = 0;      // pass on pure virtual
00081 
00082         void UpdateBars();          // adjust scrollbars etc
00083         BOOL GetTrueClientSize(CSize& size, CSize& sizeSb);
00084                 // size with no bars
00085         void GetScrollBarSizes(CSize& sizeSb);
00086         void GetScrollBarState(CSize sizeClient, CSize& needSb,
00087                 CSize& sizeRange, CPoint& ptMove, BOOL bInsideClient);
00088 
00089 public:
00090         virtual ~CScrollZoomView();
00091 #ifdef _DEBUG
00092         virtual void Dump(CDumpContext&) const;
00093         virtual void AssertValid() const;
00094 #endif //_DEBUG
00095         virtual void CalcWindowRect(LPRECT lpClientRect,
00096                 UINT nAdjustType = adjustBorder);
00097         virtual void OnPrepareDC(CDC* pDC, CPrintInfo* pInfo = NULL);
00098 
00099         // scrolling implementation support for OLE
00100         virtual BOOL OnScroll(UINT nScrollCode, UINT nPos, BOOL bDoScroll = TRUE);
00101         virtual BOOL OnScrollBy(CSize sizeScroll, BOOL bDoScroll = TRUE);
00102 
00103         //{{AFX_MSG(CScrollZoomView)
00104         afx_msg void OnSize(UINT nType, int cx, int cy);
00105         afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
00106         afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
00107         afx_msg BOOL OnMouseWheel(UINT fFlags, short zDelta, CPoint point);
00108         //}}AFX_MSG
00109         DECLARE_MESSAGE_MAP()
00110 };
00112 
00113 //{{AFX_INSERT_LOCATION}}
00114 // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
00115 
00116 #endif // !defined(AFX_SROLLZOOMVIEW_H__4110C3CC_05C2_4E15_A035_0A8F39EF36A1__INCLUDED_)