-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathMyCheckbox.cpp
64 lines (54 loc) · 1 KB
/
MyCheckbox.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
#include "MyCheckbox.h"
#include <iostream>
/*
* Constructor
*/
MyCheckbox::MyCheckbox()
{
if (!texture.loadFromFile("images/settings/checkbox.png")) {};
if (!checkTexture.loadFromFile("images/settings/checkbox_s.png")) {};
sprite = sf::Sprite(texture);
}
/*
* Destructor
*/
MyCheckbox::~MyCheckbox()
{
}
//Setters and getters
void MyCheckbox::setPosition(int x, int y)
{
sprite.setPosition(x, y);
}
bool MyCheckbox::setChecked(int x, int y)
{
if (sprite.getGlobalBounds().contains(x, y)) {
return true;
}
return false;
}
void MyCheckbox::setChecked(bool checked) {
if (checked) {
sprite.setTexture(checkTexture);
}
else {
sprite.setTexture(texture);
}
_checked = checked;
}
sf::Sprite MyCheckbox::getSprite() const
{
return sf::Sprite(sprite);
}
bool MyCheckbox::isChecked() const
{
return _checked;
}
int MyCheckbox::getX() const
{
return sprite.getPosition().x;
}
int MyCheckbox::getY() const
{
return sprite.getPosition().y;
}