163 button->setChecked(true); |
163 button->setChecked(true); |
164 } |
164 } |
165 } |
165 } |
166 |
166 |
167 |
167 |
|
168 static void radiobutton_event(UiEvent *event, UiEventWrapper *wrapper) { |
|
169 if(wrapper->var) { |
|
170 UiInteger *value = wrapper->var->value; |
|
171 event->eventdata = value; |
|
172 event->intval = ui_get(value); |
|
173 } |
|
174 } |
|
175 |
168 UIWIDGET ui_radiobutton_create(UiObject *obj, UiToggleArgs args) { |
176 UIWIDGET ui_radiobutton_create(UiObject *obj, UiToggleArgs args) { |
169 UiContainerPrivate *ctn = ui_obj_container(obj); |
177 UiContainerPrivate *ctn = ui_obj_container(obj); |
170 UI_APPLY_LAYOUT(ctn->layout, args); |
178 UI_APPLY_LAYOUT(ctn->layout, args); |
171 |
179 |
172 QString str = QString::fromUtf8(args.label); |
180 QString str = QString::fromUtf8(args.label); |
188 } |
196 } |
189 value->get = ui_radiobutton_get; |
197 value->get = ui_radiobutton_get; |
190 value->set = ui_radiobutton_set; |
198 value->set = ui_radiobutton_set; |
191 } |
199 } |
192 |
200 |
193 // TODO: unbind var/remove button from buttongroup when the button is destroyed |
201 UiEventWrapper *event = new UiEventWrapper(obj, args.onchange, args.onchangedata); |
194 // TODO: implement callback |
202 event->var = var; |
195 // TODO: implement value observer |
203 event->customdata1 = button; |
|
204 event->prepare_event = togglebutton_event; |
|
205 button->connect(button, SIGNAL(clicked()), event, SLOT(slot())); |
|
206 button->connect(button, SIGNAL(destroyed()), event, SLOT(destroy())); |
196 |
207 |
197 ctn->add(button, false); |
208 ctn->add(button, false); |
198 |
209 |
199 return button; |
210 return button; |
200 } |
211 } |