forked from sabrogden/Ditto
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathScrollHelper.h
63 lines (49 loc) · 1.92 KB
/
ScrollHelper.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// Filename: ScrollHelper.h
// S.Chan, 01 Jul 2005
#ifndef SCROLL_HELPER_INCLUDED
#define SCROLL_HELPER_INCLUDED
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
class CScrollHelper
{
public:
CScrollHelper();
~CScrollHelper();
// Attach/detach a CWnd or CDialog.
void AttachWnd(CWnd* pWnd);
void DetachWnd();
// Set/get the virtual display size. When the dialog or window
// size is smaller than the display size, then that is when
// scrollbars will appear. Set either the display width or display
// height to zero if you don't want to enable the scrollbar in the
// corresponding direction.
void SetDisplaySize(int displayWidth, int displayHeight, double zoomScale);
const CSize& GetDisplaySize() const;
// Get current scroll position. This is needed if you are scrolling
// a custom CWnd which implements its own drawing in OnPaint().
const CSize& GetScrollPos() const;
// Get current page size. Useful for debugging purposes.
const CSize& GetPageSize() const;
// Scroll back to top, left, or top-left corner of the window.
void ScrollToOrigin(bool scrollLeft, bool scrollTop);
// Message handling.
void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
BOOL OnMouseWheel(UINT nFlags, short zDelta, CPoint pt);
BOOL OnMouseHWheel(UINT nFlags, short zDelta, CPoint pt);
void OnSize(UINT nType, int cx, int cy);
BOOL Update(CPoint changes);
private:
int Get32BitScrollPos(int bar, CScrollBar* pScrollBar);
void UpdateScrollInfo();
void UpdateScrollBar(int bar, int windowSize, int displaySize,
LONG& pageSize, LONG& scrollPos, LONG& deltaPos);
CWnd* m_attachWnd;
CSize m_pageSize;
CSize m_displaySize;
CSize m_scrollPos;
double m_zoomScale;
};
#endif // SCROLL_HELPER_INCLUDED
// END