-
Notifications
You must be signed in to change notification settings - Fork 0
/
canvas.cc
59 lines (55 loc) · 1.29 KB
/
canvas.cc
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
#include "mgui.h"
#include "canvas.h"
void CCanvas::create(int x, int y, int width, int height, CWindow *parent) {
DWORD style = WS_VISIBLE | WS_CHILD;
CWindow::create(0, "MGUIWindow", "",
style,
x, y, width, height, parent->m_wnd, NULL);
}
bool CCanvas::handleEvent(UINT message, WPARAM wParam, LPARAM lParam) {
bool processed;
int x, y;
switch (message) {
//Frequent messages on top.
case WM_MOUSEMOVE:
x = GET_X_LPARAM(lParam);
y = GET_Y_LPARAM(lParam);
onMouseMove(x, y);
processed = true;
break;
case WM_PAINT:
::BeginPaint(m_wnd, &ps);
onPaint(ps);
::EndPaint(m_wnd, &ps);
processed = true;
break;
case WM_RBUTTONDOWN:
x = GET_X_LPARAM(lParam);
y = GET_Y_LPARAM(lParam);
onRightMouseDown(x, y);
processed = true;
break;
case WM_RBUTTONUP:
x = GET_X_LPARAM(lParam);
y = GET_Y_LPARAM(lParam);
onRightMouseUp(x, y);
processed = true;
break;
case WM_LBUTTONDOWN:
x = GET_X_LPARAM(lParam);
y = GET_Y_LPARAM(lParam);
onLeftMouseDown(x, y);
processed = true;
break;
case WM_LBUTTONUP:
x = GET_X_LPARAM(lParam);
y = GET_Y_LPARAM(lParam);
onLeftMouseUp(x, y);
processed = true;
break;
}
if (processed == false) {
processed = CWindow::handleEvent(message, wParam, lParam);
}
return processed;
}