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