-
Notifications
You must be signed in to change notification settings - Fork 1
/
GCP_CheckBox.cpp
53 lines (40 loc) · 1.28 KB
/
GCP_CheckBox.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
#include "GCP_FormComponent.h"
#include "GCP_CheckBox.h"
using namespace gcp;
GCP_CheckBox::GCP_CheckBox() {
_isChecked = false;
_isVisible = true;
setWidthHeight(15, 15);
}
void GCP_CheckBox::OnDraw(const GCP_Event &event)
{
if(!isVisible())
return;
GCP_Point<int> pointA,pointB;
GCP_Draw::Render()->Draw_Rect(_position.x() , _position.y() , 15,15,c_black);
if(isChecked())
GCP_Draw::Render()->Draw_FillEllipse(_position.x() + 7, _position.y() + 7, 4, 4, c_black);
//íàäïèñü ó ÷åêáîêñà
GCP_Draw::Render()->Draw_Text(_text, GCP_Rect<int>(_position.x() + 18, _position.y(), 100, 20), getStyle(), &drawdata);
basicOnDraw(event);
}
gcp_formEvent GCP_CheckBox::OnEvent(const GCP_Event &event)
{
//îáðàáîòêà ñîáûòèÿ
gcp_formEvent evt; //ïî óìîë÷àíèþ âñå ôëàãè îáíóëèì. îíè âñå ðàâíî íå íóæíû
evt.isEventInsideForm = false;
evt.isEventOnFormHead = false;
evt.isFormDragged = false;
if(!isVisible())
return evt;
if (event.eventType == GCP_ON_LEFT_CLICK) //÷åêáîêñ ñëó÷àåò òîëüêî ëåâóþ êíîïêó (ëîêàëüíî)
_isChecked = !isChecked();
basicOnEvent(event);
return evt;
}
/*bool GCP_CheckBox::OnMouseLeftClick(SDL_MouseButtonEvent mousebutton)
{
isChecked = !isChecked;
basicOnMouseLeftClick(mousebutton);
return true;
}*/