-
Notifications
You must be signed in to change notification settings - Fork 2
/
BitmapView.h
72 lines (56 loc) · 2.03 KB
/
BitmapView.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
64
65
66
67
68
69
70
71
72
#ifndef __VIEW_H__
#define __VIEW_H__
#pragma once
#include <atlscrl.h>
#include <atlcrack.h>
#include <atltypes.h>
#include "Image.h"
class CBitmapView : public CZoomScrollWindowImpl<CBitmapView>
{
public:
friend CZoomScrollImpl<CBitmapView>;
friend CScrollImpl<CBitmapView>;
DECLARE_WND_CLASS_EX(NULL, CS_HREDRAW | CS_VREDRAW, -1)
CBitmapView();
BOOL PreTranslateMessage(MSG* pMsg);
void ClearBitmap();
void SetBitmap(Image image, bool bResetOffset = true);
const Image& GetImage() const { return m_image; }
void SetBackground(HBRUSH hBackground);
const CBrush& GetBackground() const { return m_hBackground; }
void SetFrame(UINT nFrame);
void SetFlipRotate(WICBitmapTransformOptions FlipRotate);
HBITMAP CreateBitmap(HDC hDC) const { return m_image.ConvertToBitmap(hDC, m_hBackground); }
void ZoomToFit();
void SaveImage(LPCTSTR lpFilename) const { m_image.Save(lpFilename); }
private:
void DoPaint(CDCHandle dc) const;
bool AdjustScrollOffset(int& x, int& y);
void InvalidateCursor();
void UpdateScrollSize(bool bResetOffset);
BEGIN_MSG_MAP(CBitmapView)
MSG_WM_ERASEBKGND(OnEraseBackground)
MSG_WM_KEYDOWN(OnKeyDown)
MSG_WM_KEYUP(OnKeyUp)
MSG_WM_LBUTTONDOWN(OnLButtonDown)
MSG_WM_LBUTTONUP(OnLButtonUp)
MSG_WM_MOUSEMOVE(OnMouseMove)
MSG_WM_CAPTURECHANGED(OnCaptureChanged)
MSG_WM_SETCURSOR(OnSetCursor)
CHAIN_MSG_MAP(CZoomScrollWindowImpl<CBitmapView>);
END_MSG_MAP()
private:
Image m_image;
CBrush m_hBackground;
CPoint m_pointDrag;
bool m_bPanning;
BOOL OnEraseBackground(CDCHandle dc);
void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
void OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags);
void OnLButtonDown(UINT nFlags, CPoint point);
void OnLButtonUp(UINT nFlags, CPoint point);
void OnMouseMove(UINT nFlags, CPoint point);
void OnCaptureChanged(CWindow wnd);
BOOL OnSetCursor(CWindow wnd, UINT nHitTest, UINT message);
};
#endif // __VIEW_H__