]> icculus.org git repositories - divverent/nexuiz.git/blob - data/qcsrc/menu-div0test/item/radiobutton.c
added checkbox, radio button; removed unnecessary setFocus override in Nexposee and...
[divverent/nexuiz.git] / data / qcsrc / menu-div0test / item / radiobutton.c
1 #ifdef INTERFACE
2 void RadioButton_Click(entity me, entity other);
3 CLASS(RadioButton) EXTENDS(CheckBox)
4         METHOD(RadioButton, configureRadioButton, void(entity, string, float, string, float, float))
5         ATTRIB(RadioButton, checked, float, 0)
6         ATTRIB(RadioButton, group, float, 0)
7         ATTRIB(RadioButton, allowDeselect, float, 0)
8         ATTRIB(RadioButton, onClick, void(entity, entity), RadioButton_Click)
9 ENDCLASS(RadioButton)
10 #endif
11
12 #ifdef IMPLEMENTATION
13 void configureRadioButtonRadioButton(entity me, string txt, float sz, string gfx, float theGroup, float doAllowDeselect)
14 {
15         me.configureCheckBox(me, txt, sz, gfx);
16         me.align = 0;
17         me.group = theGroup;
18         me.allowDeselect = doAllowDeselect;
19 }
20 void RadioButton_Click(entity me, entity other)
21 {
22         if(me.checked)
23         {
24                 if(me.allowDeselect)
25                         me.checked = 0;
26         }
27         else
28         {
29                 entity e;
30                 for(e = me.parent.firstChild; e; e = e.Container_nextSibling)
31                         if(e != me)
32                                 if(e.group == me.group)
33                                         e.checked = 0;
34                 me.checked = 1;
35         }
36 }
37 #endif