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