-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCatMouse_Button.cpp
37 lines (29 loc) · 998 Bytes
/
CatMouse_Button.cpp
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
#include <stdio.h>
#include <graphics.h>
#include "CatMouse_Button.h"
Button::Button(int(*_p)(), LPCTSTR _pictureName, int _x_coordinate, int _y_coordinate,int* _judge, int _width, int _height) { //_pΪÿ¸öbuttonµÄspecial function
x_coordinate = _x_coordinate;
y_coordinate = _y_coordinate;
width = _width;
height = _height;
pictureName = _pictureName;
p = _p;
judge = _judge;
button = IMAGE(width, height);
loadimage(&button, pictureName, width, height);
}
void Button::outputButton() {
putimage(x_coordinate, y_coordinate, &button);
}
void Button::mouseTouch(MOUSEMSG myMouse) {
//struct MOUSEMSG myMouse;
//myMouse = GetMouseMsg();
if ( myMouse.x > x_coordinate && myMouse.x < (x_coordinate + width)
&& myMouse.y > y_coordinate && myMouse.y < (y_coordinate + height) ) { //ÏÞÖÆ·¶Î§
rectangle(x_coordinate, y_coordinate, (x_coordinate + width), (y_coordinate + height));
if (myMouse.mkLButton == true) {
if (judge == NULL) (*p)();
else *judge = (*p)();
}
}
}