68 |
68 |
69 // listener for notifying observers |
69 // listener for notifying observers |
70 // TODO: |
70 // TODO: |
71 } |
71 } |
72 |
72 |
73 // add button to current container |
73 // add label to current container |
74 UI_APPLY_LAYOUT1(current, args); |
74 UI_APPLY_LAYOUT1(current, args); |
75 |
75 |
76 current->container->Add(label, false); |
76 current->container->Add(label, false); |
77 |
77 |
78 return widget; |
78 return widget; |
100 void ui_label_set(UiString* str, const char* newvalue) { |
100 void ui_label_set(UiString* str, const char* newvalue) { |
101 UiWidget* widget = (UiWidget*)str->obj; |
101 UiWidget* widget = (UiWidget*)str->obj; |
102 TextBox box = widget->uielement.as<TextBox>(); |
102 TextBox box = widget->uielement.as<TextBox>(); |
103 box.Text(ui_string_set(str, newvalue)); |
103 box.Text(ui_string_set(str, newvalue)); |
104 } |
104 } |
|
105 |
|
106 |
|
107 // -------------------- progressbar ------------------------- |
|
108 |
|
109 UIWIDGET ui_progressbar_create(UiObject* obj, UiProgressbarArgs args) { |
|
110 UiObject* current = uic_current_obj(obj); |
|
111 |
|
112 // create textbox and toolkit wrapper |
|
113 ProgressBar progressbar = ProgressBar(); |
|
114 progressbar.Minimum(args.min); |
|
115 progressbar.Maximum(args.max == 0 ? 100 : args.max); |
|
116 if (args.width > 0) { |
|
117 progressbar.Width(args.width); |
|
118 } |
|
119 |
|
120 UIElement elm = progressbar; |
|
121 UiWidget* widget = new UiWidget(elm); |
|
122 ui_context_add_widget_destructor(current->ctx, widget); |
|
123 |
|
124 UiVar* var = uic_widget_var(obj->ctx, current->ctx, args.value, args.varname, UI_VAR_DOUBLE); |
|
125 if (var) { |
|
126 UiDouble* value = (UiDouble*)var->value; |
|
127 value->obj = widget; |
|
128 value->get = ui_progressbar_get; |
|
129 value->set = ui_progressbar_set; |
|
130 |
|
131 // listener for notifying observers |
|
132 // TODO: |
|
133 } |
|
134 |
|
135 // add button to current container |
|
136 UI_APPLY_LAYOUT1(current, args); |
|
137 |
|
138 current->container->Add(progressbar, false); |
|
139 |
|
140 return widget; |
|
141 } |
|
142 |
|
143 double ui_progressbar_get(UiDouble * d) { |
|
144 UiWidget* widget = (UiWidget*)d->obj; |
|
145 ProgressBar progressbar = widget->uielement.as<ProgressBar>(); |
|
146 d->value = progressbar.Value(); |
|
147 return d->value; |
|
148 } |
|
149 |
|
150 void ui_progressbar_set(UiDouble * d, double newvalue) { |
|
151 UiWidget* widget = (UiWidget*)d->obj; |
|
152 ProgressBar progressbar = widget->uielement.as<ProgressBar>(); |
|
153 d->value = newvalue; |
|
154 progressbar.Value(newvalue); |
|
155 } |