]> de.git.xonotic.org Git - voretournament/voretournament.git/blob - data/qcsrc/menu/item/checkbox.c
Initial checkout of Vore Tournament 0.1.alpha.
[voretournament/voretournament.git] / data / qcsrc / menu / item / checkbox.c
1 #ifdef INTERFACE\r
2 void CheckBox_Click(entity me, entity other);\r
3 CLASS(CheckBox) EXTENDS(Button)\r
4         METHOD(CheckBox, configureCheckBox, void(entity, string, float, string))\r
5         METHOD(CheckBox, draw, void(entity))\r
6         METHOD(CheckBox, toString, string(entity))\r
7         METHOD(CheckBox, setChecked, void(entity, float))\r
8         ATTRIB(CheckBox, useDownAsChecked, float, 0)\r
9         ATTRIB(CheckBox, checked, float, 0)\r
10         ATTRIB(CheckBox, onClick, void(entity, entity), CheckBox_Click)\r
11         ATTRIB(CheckBox, srcMulti, float, 0)\r
12         ATTRIB(CheckBox, disabled, float, 0)\r
13 ENDCLASS(CheckBox)\r
14 #endif\r
15 \r
16 #ifdef IMPLEMENTATION\r
17 void setCheckedCheckBox(entity me, float val)\r
18 {\r
19         me.checked = val;\r
20 }\r
21 void CheckBox_Click(entity me, entity other)\r
22 {\r
23         me.setChecked(me, !me.checked);\r
24 }\r
25 string toStringCheckBox(entity me)\r
26 {\r
27         return strcat(toStringLabel(me), ", ", me.checked ? "checked" : "unchecked");\r
28 }\r
29 void configureCheckBoxCheckBox(entity me, string txt, float sz, string gfx)\r
30 {\r
31         me.configureButton(me, txt, sz, gfx);\r
32         me.align = 0;\r
33 }\r
34 void drawCheckBox(entity me)\r
35 {\r
36         float s;\r
37         s = me.pressed;\r
38         if(me.useDownAsChecked)\r
39         {\r
40                 me.srcSuffix = string_null;\r
41                 me.forcePressed = me.checked;\r
42         }\r
43         else\r
44                 me.srcSuffix = (me.checked ? "1" : "0");\r
45         drawButton(me);\r
46         me.pressed = s;\r
47 }\r
48 #endif\r