annotate window/menuitem.cc @ 52:15a18fbe6f21

* Known bugs added to the README * Code cleaning (0 -> NULL when needed, indentation, spaces, ...)
author thib
date Sat, 18 Apr 2009 18:35:39 +0000
parents 223b71206888
children 4416cfac86ae
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
223b71206888 Initial import
thib
parents:
diff changeset
1 /*
223b71206888 Initial import
thib
parents:
diff changeset
2 * Copyright (c) 2004-2006 Kazunori "jagarl" Ueno
223b71206888 Initial import
thib
parents:
diff changeset
3 * All rights reserved.
223b71206888 Initial import
thib
parents:
diff changeset
4 *
223b71206888 Initial import
thib
parents:
diff changeset
5 * Redistribution and use in source and binary forms, with or without
223b71206888 Initial import
thib
parents:
diff changeset
6 * modification, are permitted provided that the following conditions
223b71206888 Initial import
thib
parents:
diff changeset
7 * are met:
223b71206888 Initial import
thib
parents:
diff changeset
8 * 1. Redistributions of source code must retain the above copyright
223b71206888 Initial import
thib
parents:
diff changeset
9 * notice, this list of conditions and the following disclaimer.
223b71206888 Initial import
thib
parents:
diff changeset
10 * 2. Redistributions in binary form must reproduce the above copyright
223b71206888 Initial import
thib
parents:
diff changeset
11 * notice, this list of conditions and the following disclaimer in the
223b71206888 Initial import
thib
parents:
diff changeset
12 * documentation and/or other materials provided with the distribution.
223b71206888 Initial import
thib
parents:
diff changeset
13 * 3. The name of the author may not be used to endorse or promote products
223b71206888 Initial import
thib
parents:
diff changeset
14 * derived from this software without specific prior written permission.
223b71206888 Initial import
thib
parents:
diff changeset
15 *
223b71206888 Initial import
thib
parents:
diff changeset
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
223b71206888 Initial import
thib
parents:
diff changeset
17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
223b71206888 Initial import
thib
parents:
diff changeset
18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
223b71206888 Initial import
thib
parents:
diff changeset
19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
223b71206888 Initial import
thib
parents:
diff changeset
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
223b71206888 Initial import
thib
parents:
diff changeset
21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
223b71206888 Initial import
thib
parents:
diff changeset
22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
223b71206888 Initial import
thib
parents:
diff changeset
23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
223b71206888 Initial import
thib
parents:
diff changeset
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
223b71206888 Initial import
thib
parents:
diff changeset
25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
223b71206888 Initial import
thib
parents:
diff changeset
26 */
223b71206888 Initial import
thib
parents:
diff changeset
27
223b71206888 Initial import
thib
parents:
diff changeset
28
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 0
diff changeset
29 #include "menuitem.h"
0
223b71206888 Initial import
thib
parents:
diff changeset
30
223b71206888 Initial import
thib
parents:
diff changeset
31 #define Button WidButton
223b71206888 Initial import
thib
parents:
diff changeset
32 #define Scale WidScale
223b71206888 Initial import
thib
parents:
diff changeset
33 #define Label WidLabel
223b71206888 Initial import
thib
parents:
diff changeset
34 #define TextButton WidTextButton
223b71206888 Initial import
thib
parents:
diff changeset
35 #define Text WidText
223b71206888 Initial import
thib
parents:
diff changeset
36
223b71206888 Initial import
thib
parents:
diff changeset
37 #define MenuItem WidMenuItem
223b71206888 Initial import
thib
parents:
diff changeset
38 #define RadioGroup WidRadioGroup
223b71206888 Initial import
thib
parents:
diff changeset
39 #define ScaleMenu WidScaleMenu
223b71206888 Initial import
thib
parents:
diff changeset
40 void fill(Surface* src, const Rect& rect, int r, int g, int b, int a = 0xff);
223b71206888 Initial import
thib
parents:
diff changeset
41
223b71206888 Initial import
thib
parents:
diff changeset
42 MenuItem::MenuItem(PicContainer* parent, const Rect& r_orig, int _x_size, int _y_size, int* _value_ptr) :
223b71206888 Initial import
thib
parents:
diff changeset
43 x_size(_x_size), y_size(_y_size), value_ptr(_value_ptr), set_func(0), set_pointer(0) {
223b71206888 Initial import
thib
parents:
diff changeset
44 SetPic(parent->create_node(r_orig, 0));
223b71206888 Initial import
thib
parents:
diff changeset
45 menu_width = r_orig.width();
223b71206888 Initial import
thib
parents:
diff changeset
46 menu_height = r_orig.height();
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 0
diff changeset
47 label = NULL;
0
223b71206888 Initial import
thib
parents:
diff changeset
48 lb_width = 0; lb_right = 0;
223b71206888 Initial import
thib
parents:
diff changeset
49 lb_left = -1; lb_bottom = -1;
223b71206888 Initial import
thib
parents:
diff changeset
50 int i;
223b71206888 Initial import
thib
parents:
diff changeset
51 for (i=0; i<x_size*y_size; i++) item.push_back(0);
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 0
diff changeset
52 }
15a18fbe6f21 * Known bugs added to the README
thib
parents: 0
diff changeset
53
0
223b71206888 Initial import
thib
parents:
diff changeset
54 void MenuItem::SetLabelLeft(PicWidget* lb, const Rect& min_rect, const Rect& min_margin) {
223b71206888 Initial import
thib
parents:
diff changeset
55 lb_width = min_rect.width();
223b71206888 Initial import
thib
parents:
diff changeset
56 lb_right = min_margin.width();
223b71206888 Initial import
thib
parents:
diff changeset
57 lb_left = -1;
223b71206888 Initial import
thib
parents:
diff changeset
58 lb_bottom = -1;
223b71206888 Initial import
thib
parents:
diff changeset
59 label = lb;
223b71206888 Initial import
thib
parents:
diff changeset
60 }
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 0
diff changeset
61
0
223b71206888 Initial import
thib
parents:
diff changeset
62 void MenuItem::SetLabelTop(PicWidget* lb, const Rect& left_margin, const Rect& bottom_margin) {
223b71206888 Initial import
thib
parents:
diff changeset
63 lb_left = left_margin.width();
223b71206888 Initial import
thib
parents:
diff changeset
64 lb_bottom = bottom_margin.height();
223b71206888 Initial import
thib
parents:
diff changeset
65 lb_width = -1;
223b71206888 Initial import
thib
parents:
diff changeset
66 lb_right = -1;
223b71206888 Initial import
thib
parents:
diff changeset
67 label = lb;
223b71206888 Initial import
thib
parents:
diff changeset
68 }
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 0
diff changeset
69
0
223b71206888 Initial import
thib
parents:
diff changeset
70 void MenuItem::SetValue(int new_value) {
223b71206888 Initial import
thib
parents:
diff changeset
71 SetValueImpl(new_value);
223b71206888 Initial import
thib
parents:
diff changeset
72 if (value_ptr) *value_ptr = new_value;
223b71206888 Initial import
thib
parents:
diff changeset
73 if (set_func) (*set_func)(set_pointer, this);
223b71206888 Initial import
thib
parents:
diff changeset
74 }
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 0
diff changeset
75
0
223b71206888 Initial import
thib
parents:
diff changeset
76 void MenuItem::activate(void) {
223b71206888 Initial import
thib
parents:
diff changeset
77 iterator it;
223b71206888 Initial import
thib
parents:
diff changeset
78 for (it=item.begin(); it!=item.end(); it++) {
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 0
diff changeset
79 if (*it == NULL) continue;
0
223b71206888 Initial import
thib
parents:
diff changeset
80 (*it)->activate();
223b71206888 Initial import
thib
parents:
diff changeset
81 }
223b71206888 Initial import
thib
parents:
diff changeset
82 }
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 0
diff changeset
83
0
223b71206888 Initial import
thib
parents:
diff changeset
84 void MenuItem::deactivate(void) {
223b71206888 Initial import
thib
parents:
diff changeset
85 iterator it;
223b71206888 Initial import
thib
parents:
diff changeset
86 for (it=item.begin(); it!=item.end(); it++) {
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 0
diff changeset
87 if (*it == NULL) continue;
0
223b71206888 Initial import
thib
parents:
diff changeset
88 (*it)->deactivate();
223b71206888 Initial import
thib
parents:
diff changeset
89 }
223b71206888 Initial import
thib
parents:
diff changeset
90 }
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 0
diff changeset
91
0
223b71206888 Initial import
thib
parents:
diff changeset
92 void MenuItem::pack(void) {
223b71206888 Initial import
thib
parents:
diff changeset
93 int x_min = 0, y_min = 0;
223b71206888 Initial import
thib
parents:
diff changeset
94 if (lb_width == -1) { // 上にラベルを貼る
223b71206888 Initial import
thib
parents:
diff changeset
95 if (lb_left < 0) lb_left = 0;
223b71206888 Initial import
thib
parents:
diff changeset
96 if (lb_bottom < 0) lb_bottom = 0;
223b71206888 Initial import
thib
parents:
diff changeset
97 if (label && label->Pic()) {
223b71206888 Initial import
thib
parents:
diff changeset
98 label->Pic()->Move(lb_left, 0);
223b71206888 Initial import
thib
parents:
diff changeset
99 y_min = lb_bottom + label->Pic()->Height();
223b71206888 Initial import
thib
parents:
diff changeset
100 } else {
223b71206888 Initial import
thib
parents:
diff changeset
101 y_min = lb_bottom;
223b71206888 Initial import
thib
parents:
diff changeset
102 }
223b71206888 Initial import
thib
parents:
diff changeset
103 } else { // 左にラベルを貼る
223b71206888 Initial import
thib
parents:
diff changeset
104 if (lb_right < 0) lb_right = 0;
223b71206888 Initial import
thib
parents:
diff changeset
105 if (label && label->Pic()) {
223b71206888 Initial import
thib
parents:
diff changeset
106 int label_width = label->Pic()->Width();
223b71206888 Initial import
thib
parents:
diff changeset
107 int label_height = label->Pic()->Height();
223b71206888 Initial import
thib
parents:
diff changeset
108 if (label_width > lb_width - lb_right) {
223b71206888 Initial import
thib
parents:
diff changeset
109 x_min = label_width + lb_right;
223b71206888 Initial import
thib
parents:
diff changeset
110 } else {
223b71206888 Initial import
thib
parents:
diff changeset
111 x_min = lb_width;
223b71206888 Initial import
thib
parents:
diff changeset
112 }
223b71206888 Initial import
thib
parents:
diff changeset
113 } else {
223b71206888 Initial import
thib
parents:
diff changeset
114 x_min = lb_width;
223b71206888 Initial import
thib
parents:
diff changeset
115 }
223b71206888 Initial import
thib
parents:
diff changeset
116 }
223b71206888 Initial import
thib
parents:
diff changeset
117 int* item_width = new int[x_size];
223b71206888 Initial import
thib
parents:
diff changeset
118 int* item_height = new int[y_size];
223b71206888 Initial import
thib
parents:
diff changeset
119 int* item_x = new int[x_size];
223b71206888 Initial import
thib
parents:
diff changeset
120 int* item_y = new int[y_size];
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 0
diff changeset
121 int i, j;
0
223b71206888 Initial import
thib
parents:
diff changeset
122 for (i=0; i<x_size; i++) item_width[i]=0;
223b71206888 Initial import
thib
parents:
diff changeset
123 for (i=0; i<y_size; i++) item_height[i]=0;
223b71206888 Initial import
thib
parents:
diff changeset
124
223b71206888 Initial import
thib
parents:
diff changeset
125 iterator it = item.begin();
223b71206888 Initial import
thib
parents:
diff changeset
126 for (i=0; i<y_size; i++) {
223b71206888 Initial import
thib
parents:
diff changeset
127 for (j=0; j<x_size; j++) {
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 0
diff changeset
128 if (*it != NULL && (*it)->Pic() != NULL) {
0
223b71206888 Initial import
thib
parents:
diff changeset
129 PicBase* pic = (*it)->Pic();
223b71206888 Initial import
thib
parents:
diff changeset
130 if (item_width[j] < pic->Width()) item_width[j] = pic->Width();
223b71206888 Initial import
thib
parents:
diff changeset
131 if (item_height[i] < pic->Height()) item_height[i] = pic->Height();
223b71206888 Initial import
thib
parents:
diff changeset
132 }
223b71206888 Initial import
thib
parents:
diff changeset
133 it++;
223b71206888 Initial import
thib
parents:
diff changeset
134 }
223b71206888 Initial import
thib
parents:
diff changeset
135 }
223b71206888 Initial import
thib
parents:
diff changeset
136 int width=0, height=0;
223b71206888 Initial import
thib
parents:
diff changeset
137 for (i=0; i<x_size; i++) {
223b71206888 Initial import
thib
parents:
diff changeset
138 width += item_width[i];
223b71206888 Initial import
thib
parents:
diff changeset
139 }
223b71206888 Initial import
thib
parents:
diff changeset
140 for (i=0; i<y_size; i++) {
223b71206888 Initial import
thib
parents:
diff changeset
141 height += item_height[i];
223b71206888 Initial import
thib
parents:
diff changeset
142 }
223b71206888 Initial import
thib
parents:
diff changeset
143
223b71206888 Initial import
thib
parents:
diff changeset
144 int x=x_min, y=y_min;
223b71206888 Initial import
thib
parents:
diff changeset
145 // width / height の再割り当て
223b71206888 Initial import
thib
parents:
diff changeset
146 if (menu_width > width + x_min) {
223b71206888 Initial import
thib
parents:
diff changeset
147 int dif = menu_width - width - x_min;
223b71206888 Initial import
thib
parents:
diff changeset
148 int n = x_size + 1;
223b71206888 Initial import
thib
parents:
diff changeset
149 x += dif/n;
223b71206888 Initial import
thib
parents:
diff changeset
150 for (i=0; i<x_size; i++) {
223b71206888 Initial import
thib
parents:
diff changeset
151 item_x[i] = x + item_width[i] / 2;
223b71206888 Initial import
thib
parents:
diff changeset
152 x += item_width[i] + dif*(i+2)/n - dif*(i+1)/n;
223b71206888 Initial import
thib
parents:
diff changeset
153 }
223b71206888 Initial import
thib
parents:
diff changeset
154 } else {
223b71206888 Initial import
thib
parents:
diff changeset
155 if (menu_width == 0) {
223b71206888 Initial import
thib
parents:
diff changeset
156 Pic()->SetSurfaceRect(Rect(0, 0, width+x_min, Pic()->Height()));
223b71206888 Initial import
thib
parents:
diff changeset
157 }
223b71206888 Initial import
thib
parents:
diff changeset
158 for (i=0; i<x_size; i++) {
223b71206888 Initial import
thib
parents:
diff changeset
159 item_x[i] = x + item_width[i] / 2;
223b71206888 Initial import
thib
parents:
diff changeset
160 x += item_width[i];
223b71206888 Initial import
thib
parents:
diff changeset
161 }
223b71206888 Initial import
thib
parents:
diff changeset
162 }
223b71206888 Initial import
thib
parents:
diff changeset
163 if (menu_height > height+y_min) {
223b71206888 Initial import
thib
parents:
diff changeset
164 int dif = menu_height - height - y_min;
223b71206888 Initial import
thib
parents:
diff changeset
165 int n = y_size + 1;
223b71206888 Initial import
thib
parents:
diff changeset
166 y += dif/n;
223b71206888 Initial import
thib
parents:
diff changeset
167 for (i=0; i<y_size; i++) {
223b71206888 Initial import
thib
parents:
diff changeset
168 item_y[i] = y + item_height[i] / 2;
223b71206888 Initial import
thib
parents:
diff changeset
169 y += item_height[i] + dif*(i+2)/n - dif*(i+1)/n;
223b71206888 Initial import
thib
parents:
diff changeset
170 }
223b71206888 Initial import
thib
parents:
diff changeset
171 } else {
223b71206888 Initial import
thib
parents:
diff changeset
172 if (menu_height == 0) {
223b71206888 Initial import
thib
parents:
diff changeset
173 Pic()->SetSurfaceRect(Rect(0, 0, Pic()->Width(), height+y_min));
223b71206888 Initial import
thib
parents:
diff changeset
174 }
223b71206888 Initial import
thib
parents:
diff changeset
175 for (i=0; i<y_size; i++) {
223b71206888 Initial import
thib
parents:
diff changeset
176 item_y[i] = y + item_height[i] / 2;
223b71206888 Initial import
thib
parents:
diff changeset
177 y += item_height[i];
223b71206888 Initial import
thib
parents:
diff changeset
178 }
223b71206888 Initial import
thib
parents:
diff changeset
179 }
223b71206888 Initial import
thib
parents:
diff changeset
180 // 位置の再割り当て
223b71206888 Initial import
thib
parents:
diff changeset
181 it = item.begin();
223b71206888 Initial import
thib
parents:
diff changeset
182 for (i=0; i<y_size; i++) {
223b71206888 Initial import
thib
parents:
diff changeset
183 for (j=0; j<x_size; j++) {
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 0
diff changeset
184 if (*it != NULL && (*it)->Pic() != NULL) {
0
223b71206888 Initial import
thib
parents:
diff changeset
185 PicBase* pic = (*it)->Pic();
223b71206888 Initial import
thib
parents:
diff changeset
186 int x0 = item_x[j]-pic->Width()/2;
223b71206888 Initial import
thib
parents:
diff changeset
187 int y0 = item_y[i]-pic->Height()/2;
223b71206888 Initial import
thib
parents:
diff changeset
188 pic->Move(x0, y0);
223b71206888 Initial import
thib
parents:
diff changeset
189 }
223b71206888 Initial import
thib
parents:
diff changeset
190 it++;
223b71206888 Initial import
thib
parents:
diff changeset
191 }
223b71206888 Initial import
thib
parents:
diff changeset
192 }
223b71206888 Initial import
thib
parents:
diff changeset
193 // 左にラベルがある場合、ラベルの高さ方向のセンタリング
223b71206888 Initial import
thib
parents:
diff changeset
194 if (label && label->Pic() && lb_width != -1) {
223b71206888 Initial import
thib
parents:
diff changeset
195 int label_width = label->Pic()->Width();
223b71206888 Initial import
thib
parents:
diff changeset
196 int label_height = label->Pic()->Height();
223b71206888 Initial import
thib
parents:
diff changeset
197 label->Pic()->Move(x_min-label_width-lb_right, (Pic()->Height() - label_height) / 2);
223b71206888 Initial import
thib
parents:
diff changeset
198 }
223b71206888 Initial import
thib
parents:
diff changeset
199
223b71206888 Initial import
thib
parents:
diff changeset
200 delete[] item_width;
223b71206888 Initial import
thib
parents:
diff changeset
201 delete[] item_height;
223b71206888 Initial import
thib
parents:
diff changeset
202 delete[] item_x;
223b71206888 Initial import
thib
parents:
diff changeset
203 delete[] item_y;
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 0
diff changeset
204 }
0
223b71206888 Initial import
thib
parents:
diff changeset
205
223b71206888 Initial import
thib
parents:
diff changeset
206 RadioButton::RadioButton(Event::Container& _container, PicContainer* _parent, const Rect& r_orig, int _x_size, int _y_size, int* _value_ptr, const Rect& _button_r, int _text_size, const Color& _fore, const Color& _pressed, const Color& _back) :
223b71206888 Initial import
thib
parents:
diff changeset
207 MenuItem(_parent, r_orig, _x_size, _y_size,_value_ptr),
223b71206888 Initial import
thib
parents:
diff changeset
208 container(_container), parent(_parent), text_size(_text_size), button_rect(_button_r), buttons(0),
223b71206888 Initial import
thib
parents:
diff changeset
209 fore_color(_fore), pressed_color(_pressed), back_color(_back) {
223b71206888 Initial import
thib
parents:
diff changeset
210 }
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 0
diff changeset
211
0
223b71206888 Initial import
thib
parents:
diff changeset
212 void RadioButton::Add(const char* s, bool is_center) {
223b71206888 Initial import
thib
parents:
diff changeset
213 Add(s, fore_color, pressed_color, back_color, is_center);
223b71206888 Initial import
thib
parents:
diff changeset
214 }
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 0
diff changeset
215
0
223b71206888 Initial import
thib
parents:
diff changeset
216 void RadioButton::Add(const char* s, const Color& fore, const Color& pressed, const Color& back, bool is_center) {
223b71206888 Initial import
thib
parents:
diff changeset
217 if (buttons >= x_size*y_size) {
223b71206888 Initial import
thib
parents:
diff changeset
218 fprintf(stderr,"too many buttons (%d/%d) in RadioButton::Add ; text = %s\n",x_size,y_size,s);
223b71206888 Initial import
thib
parents:
diff changeset
219 return;
223b71206888 Initial import
thib
parents:
diff changeset
220 }
223b71206888 Initial import
thib
parents:
diff changeset
221 TextButton* wid = new TextButton(container, PicNode(), s, text_size, TextButton::Attribute(is_center ? TextButton::CENTER : 0), button_rect, 1, fore, pressed, back);
223b71206888 Initial import
thib
parents:
diff changeset
222
223b71206888 Initial import
thib
parents:
diff changeset
223 wid->press_func = &PressCallback;
223b71206888 Initial import
thib
parents:
diff changeset
224 wid->press_pointer = (void*)this;
223b71206888 Initial import
thib
parents:
diff changeset
225
223b71206888 Initial import
thib
parents:
diff changeset
226 if (value_ptr && buttons == *value_ptr) wid->Toggle(true);
223b71206888 Initial import
thib
parents:
diff changeset
227 int x_pos, y_pos;
223b71206888 Initial import
thib
parents:
diff changeset
228 if (y_size == 0) x_pos=buttons;
223b71206888 Initial import
thib
parents:
diff changeset
229 else x_pos = buttons / y_size, y_pos = buttons % y_size;
223b71206888 Initial import
thib
parents:
diff changeset
230 item[x_pos + y_pos*x_size] = wid;
223b71206888 Initial import
thib
parents:
diff changeset
231 buttons++;
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 0
diff changeset
232 }
15a18fbe6f21 * Known bugs added to the README
thib
parents: 0
diff changeset
233
0
223b71206888 Initial import
thib
parents:
diff changeset
234 void RadioButton::PressCallback(void* pointer, Button* from) {
223b71206888 Initial import
thib
parents:
diff changeset
235 RadioButton* wid = (RadioButton*)pointer;
223b71206888 Initial import
thib
parents:
diff changeset
236 int i;
223b71206888 Initial import
thib
parents:
diff changeset
237 for (i=0; i<wid->x_size*wid->y_size; i++) {
223b71206888 Initial import
thib
parents:
diff changeset
238 if (from == wid->item[i]) {
223b71206888 Initial import
thib
parents:
diff changeset
239 wid->SetValue(i);
223b71206888 Initial import
thib
parents:
diff changeset
240 return;
223b71206888 Initial import
thib
parents:
diff changeset
241 }
223b71206888 Initial import
thib
parents:
diff changeset
242 }
223b71206888 Initial import
thib
parents:
diff changeset
243 }
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 0
diff changeset
244
0
223b71206888 Initial import
thib
parents:
diff changeset
245 void RadioButton::SetValueImpl(int new_value) {
223b71206888 Initial import
thib
parents:
diff changeset
246 int i;
223b71206888 Initial import
thib
parents:
diff changeset
247 for (i=0; i<x_size*y_size; i++) {
223b71206888 Initial import
thib
parents:
diff changeset
248 Button* wid = dynamic_cast<Button*>(item[i]);
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 0
diff changeset
249 if (wid != NULL) {
0
223b71206888 Initial import
thib
parents:
diff changeset
250 if (i == new_value) wid->Toggle(true);
223b71206888 Initial import
thib
parents:
diff changeset
251 else wid->Toggle(false);
223b71206888 Initial import
thib
parents:
diff changeset
252 }
223b71206888 Initial import
thib
parents:
diff changeset
253 }
223b71206888 Initial import
thib
parents:
diff changeset
254 }