1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29 #include "widget.h"
30
31 #include "container.h"
32 #include "../common/context.h"
33
34 UIWIDGET ui_customwidget_create(UiObject *obj, ui_createwidget_func create_widget,
void *userdata, UiWidgetArgs *args) {
35 UIWIDGET widget = create_widget(obj, args, userdata);
36 UiContainerPrivate *ctn = ui_obj_container(obj);
37 UI_APPLY_LAYOUT(ctn->layout, args);
38 ctn->add(widget);
39 return widget;
40 }
41
42 UIWIDGET ui_separator_create(UiObject *obj, UiWidgetArgs *args) {
43 QFrame *separator = new QFrame();
44 separator->setFrameShape(QFrame::HLine);
45 separator->setFrameShadow(QFrame::Sunken);
46
47 UiContainerPrivate *ctn = ui_obj_container(obj);
48 UI_APPLY_LAYOUT(ctn->layout, args);
49
50 ctn->add(separator);
51
52 return separator;
53 }
54
55 void ui_set_enabled(
UIWIDGET widget,
int enabled) {
56 widget->setEnabled(enabled);
57 }
58
59 void ui_set_visible(
UIWIDGET widget,
int visible) {
60 widget->setVisible(visible);
61 }
62
63 void ui_widget_set_size(
UIWIDGET w,
int width,
int height) {
64 w->resize(width >=
0 ? width : w->width(), height >=
0 ? height : w->height());
65 }
66
67 void ui_widget_redraw(
UIWIDGET w) {
68 w->repaint();
69 }
70