-
Notifications
You must be signed in to change notification settings - Fork 1
/
checkbox.c
51 lines (42 loc) · 840 Bytes
/
checkbox.c
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
#include "checkbox.h"
void checkbox_draw(
checkbox_t* checkbox
)
{
if (checkbox->selected)
ansi_setcolor(checkbox->color_selected);
else
ansi_setcolor(checkbox->color);
ansi_gotoxy(checkbox->x, checkbox->y);
printc('[');
if (checkbox->checked)
printc('X');
else
printc(' ');
printc(']');
}
inline void checkbox_check(checkbox_t* c)
{
c->checked = true;
checkbox_draw(c);
}
inline void checkbox_uncheck(checkbox_t* c)
{
c->checked = false;
checkbox_draw(c);
}
inline void checkbox_toggle(checkbox_t* c)
{
c->checked = !c->checked;
checkbox_draw(c);
}
inline void checkbox_select(checkbox_t* c)
{
c->selected = true;
checkbox_draw(c);
}
inline void checkbox_deselect(checkbox_t* c)
{
c->selected = false;
checkbox_draw(c);
}