-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathButton.cpp
More file actions
38 lines (36 loc) · 800 Bytes
/
Button.cpp
File metadata and controls
38 lines (36 loc) · 800 Bytes
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
#include "Button.h"
void Button::ProcessEvent(const ExMessage& msg)
{
switch (msg.message)
{
case WM_MOUSEMOVE:
if (status == Status::Idle && CheckCursorHit(msg.x, msg.y))
status = Status::Hovered;
else if (status == Status::Hovered && !CheckCursorHit(msg.x, msg.y))
status = Status::Idle;
break;
case WM_LBUTTONDOWN:
if (CheckCursorHit(msg.x, msg.y))
status = Status::Pushed;
break;
case WM_LBUTTONUP:
if (status == Status::Pushed)
OnClick();
break;
}
}
void Button::Draw()
{
switch (status)
{
case Button::Status::Idle:
putimage(region.left, region.top, &img_idle);
break;
case Button::Status::Hovered:
putimage(region.left, region.top, &img_hovered);
break;
case Button::Status::Pushed:
putimage(region.left, region.top, &img_pushed);
break;
}
}