| 30 #include "container.h" |
30 #include "container.h" |
| 31 #include "toolkit.h" |
31 #include "toolkit.h" |
| 32 |
32 |
| 33 UIWIDGET ui_button_create(UiObject* obj, UiButtonArgs *args) { |
33 UIWIDGET ui_button_create(UiObject* obj, UiButtonArgs *args) { |
| 34 UiContainerPrivate *ctn = ui_obj_container(obj); |
34 UiContainerPrivate *ctn = ui_obj_container(obj); |
| 35 UI_APPLY_LAYOUT(ctn->layout, args); |
|
| 36 |
35 |
| 37 QString str = QString::fromUtf8(args->label); |
36 QString str = QString::fromUtf8(args->label); |
| 38 QPushButton *button = new QPushButton(str); |
37 QPushButton *button = new QPushButton(str); |
| 39 |
38 |
| 40 if(args->onclick) { |
39 if(args->onclick) { |
| 41 UiEventWrapper *event = new UiEventWrapper(obj, args->onclick, args->onclickdata); |
40 UiEventWrapper *event = new UiEventWrapper(obj, args->onclick, args->onclickdata); |
| 42 button->connect(button, SIGNAL(clicked()), event, SLOT(slot())); |
41 button->connect(button, SIGNAL(clicked()), event, SLOT(slot())); |
| 43 button->connect(button, SIGNAL(destroyed()), event, SLOT(destroy())); |
42 button->connect(button, SIGNAL(destroyed()), event, SLOT(destroy())); |
| 44 } |
43 } |
| 45 |
44 |
| 46 ctn->add(button); |
45 UiLayout layout = UI_ARGS2LAYOUT(args); |
| |
46 ctn->add(button, layout); |
| 47 |
47 |
| 48 return button; |
48 return button; |
| 49 } |
49 } |
| 50 |
50 |
| 51 void ui_button_set_label(UIWIDGET button, const char *label) { |
51 void ui_button_set_label(UIWIDGET button, const char *label) { |
| 67 } |
67 } |
| 68 } |
68 } |
| 69 |
69 |
| 70 UIWIDGET ui_togglebutton_create(UiObject* obj, UiToggleArgs *args) { |
70 UIWIDGET ui_togglebutton_create(UiObject* obj, UiToggleArgs *args) { |
| 71 UiContainerPrivate *ctn = ui_obj_container(obj); |
71 UiContainerPrivate *ctn = ui_obj_container(obj); |
| 72 UI_APPLY_LAYOUT(ctn->layout, args); |
|
| 73 |
72 |
| 74 QString str = QString::fromUtf8(args->label); |
73 QString str = QString::fromUtf8(args->label); |
| 75 QPushButton *button = new QPushButton(str); |
74 QPushButton *button = new QPushButton(str); |
| 76 button->setCheckable(true); |
75 button->setCheckable(true); |
| 77 |
76 |
| 127 } |
127 } |
| 128 |
128 |
| 129 |
129 |
| 130 UIWIDGET ui_checkbox_create(UiObject* obj, UiToggleArgs *args) { |
130 UIWIDGET ui_checkbox_create(UiObject* obj, UiToggleArgs *args) { |
| 131 UiContainerPrivate *ctn = ui_obj_container(obj); |
131 UiContainerPrivate *ctn = ui_obj_container(obj); |
| 132 UI_APPLY_LAYOUT(ctn->layout, args); |
|
| 133 |
132 |
| 134 QString str = QString::fromUtf8(args->label); |
133 QString str = QString::fromUtf8(args->label); |
| 135 QCheckBox *checkbox = new QCheckBox(str); |
134 QCheckBox *checkbox = new QCheckBox(str); |
| 136 |
135 |
| 137 UiVar* var = uic_widget_var(obj->ctx, obj->ctx, args->value, args->varname, UI_VAR_INTEGER); |
136 UiVar* var = uic_widget_var(obj->ctx, obj->ctx, args->value, args->varname, UI_VAR_INTEGER); |
| 186 } |
186 } |
| 187 } |
187 } |
| 188 |
188 |
| 189 UIWIDGET ui_radiobutton_create(UiObject *obj, UiToggleArgs *args) { |
189 UIWIDGET ui_radiobutton_create(UiObject *obj, UiToggleArgs *args) { |
| 190 UiContainerPrivate *ctn = ui_obj_container(obj); |
190 UiContainerPrivate *ctn = ui_obj_container(obj); |
| 191 UI_APPLY_LAYOUT(ctn->layout, args); |
|
| 192 |
191 |
| 193 QString str = QString::fromUtf8(args->label); |
192 QString str = QString::fromUtf8(args->label); |
| 194 QRadioButton *button = new QRadioButton(str); |
193 QRadioButton *button = new QRadioButton(str); |
| 195 button->setAutoExclusive(false); |
194 button->setAutoExclusive(false); |
| 196 |
195 |
| 216 event->customdata1 = button; |
215 event->customdata1 = button; |
| 217 event->prepare_event = togglebutton_event; |
216 event->prepare_event = togglebutton_event; |
| 218 button->connect(button, SIGNAL(clicked()), event, SLOT(slot())); |
217 button->connect(button, SIGNAL(clicked()), event, SLOT(slot())); |
| 219 button->connect(button, SIGNAL(destroyed()), event, SLOT(destroy())); |
218 button->connect(button, SIGNAL(destroyed()), event, SLOT(destroy())); |
| 220 |
219 |
| 221 ctn->add(button); |
220 UiLayout layout = UI_ARGS2LAYOUT(args); |
| |
221 ctn->add(button, layout); |
| 222 |
222 |
| 223 return button; |
223 return button; |
| 224 } |
224 } |
| 225 |
225 |
| 226 int64_t ui_radiobutton_get(UiInteger *value) { |
226 int64_t ui_radiobutton_get(UiInteger *value) { |