-
Notifications
You must be signed in to change notification settings - Fork 0
/
Button.cpp
106 lines (81 loc) · 1.69 KB
/
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
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
/*
* File: Button.cpp
* Author: scribble
*
* Created on November 29, 2012, 9:17 AM
*/
#include "Button.h"
Button::Button() {
}
Button::Button(int x_, int y_, int w_, int h_, int mode_, int action_, Color *fill_, Color *stroke_, Color *highlight_, Color *highlightStroke_){
x = x_;
y = y_;
width = w_;
height = h_;
mode = mode_;
action = action_;
selected = 0;
fillColor = fill_;
strokeColor = stroke_;
fill = fill_;
stroke = stroke_;
highlight = highlight_;
highlightStroke = highlightStroke_;
enabled = 1;
}
Button::Button(const Button& orig) {
}
Button::~Button() {
}
int Button::getX() {
return x;
}
int Button::getY() {
return y;
}
int Button::getWidth() {
return width;
}
int Button::getHeight() {
return height;
}
Color* Button::getFillColor(){
return fillColor;
}
Color* Button::getStrokeColor(){
return strokeColor;
}
void Button::setSelected(){
if (selected == 1){
selected = 0;
fillColor = fill;
strokeColor = stroke;
}
else {
selected = 1;
fillColor = highlight;
strokeColor = highlightStroke;
}
}
bool Button::getSelected(){
return selected;
}
bool Button::pointInsideArea(Point *point){
//point has to be inside frame. could be changed but overlaps may occur
if((point->getX() > x) && (point->getX() < width+x) && (point->getY() > y) && (point->getY() < height+y)){
return true;
}
return false;
}
int Button::getMode(){
return mode;
}
int Button::getAction(){
return action;
}
void Button::setEnabled(bool en){
enabled = en;
}
bool Button::getEnabled(){
return enabled;
}