ui/motif/label.c

changeset 433
605bb5dc34f1
parent 430
ea949c0109d8
equal deleted inserted replaced
431:bb7da585debc 433:605bb5dc34f1
54 54
55 char *name = args.name ? (char*)args.name : "label"; 55 char *name = args.name ? (char*)args.name : "label";
56 Widget w = XmCreateLabel(parent, name, xargs, n); 56 Widget w = XmCreateLabel(parent, name, xargs, n);
57 XtManageChild(w); 57 XtManageChild(w);
58 ctn->add(ctn, w); 58 ctn->add(ctn, w);
59 59
60 XmStringFree(label); 60 XmStringFree(label);
61 return w; 61 return w;
62 } 62 }
63 63
64 UIWIDGET ui_label_create(UiObject* obj, UiLabelArgs args) { 64 UIWIDGET ui_label_create(UiObject* obj, UiLabelArgs args) {
72 UIWIDGET ui_rlabel_create(UiObject* obj, UiLabelArgs args) { 72 UIWIDGET ui_rlabel_create(UiObject* obj, UiLabelArgs args) {
73 return label_create(obj, args, XmALIGNMENT_END); 73 return label_create(obj, args, XmALIGNMENT_END);
74 } 74 }
75 75
76 76
77 /* ------------------------------ progressbar ------------------------------ */ 77 /* -------------------------- progressbar/spiner -------------------------- */
78 78
79 static void ui_destroy_progressbar(Widget w, UiProgressBar *pb, XtPointer d) { 79 static void ui_destroy_progressbar(Widget w, UiProgressBar *pb, XtPointer d) {
80 // TODO: free other stuff 80 // TODO: free other stuff
81 free(pb); 81 free(pb);
82 } 82 }
182 UiProgressBar *pb = d->obj; 182 UiProgressBar *pb = d->obj;
183 d->value = value; 183 d->value = value;
184 pb->value = value; 184 pb->value = value;
185 ui_progressbar_expose(pb->widget, pb, NULL); 185 ui_progressbar_expose(pb->widget, pb, NULL);
186 } 186 }
187
188
189 UIWIDGET ui_progressspinner_create(UiObject* obj, UiProgressbarSpinnerArgs args) {
190 Arg xargs[16];
191 int n = 0;
192
193 UiContainerPrivate *ctn = ui_obj_container(obj);
194 UI_APPLY_LAYOUT(ctn->layout, args);
195
196 Widget parent = ctn->prepare(ctn, xargs, &n);
197
198 XmString label = XmStringCreateSimple("");
199 XtSetArg(xargs[n], XmNlabelString, label); n++;
200 XtSetArg(xargs[n], XmNalignment, XmALIGNMENT_END); n++;
201 XtSetArg(xargs[n], gridMinWidth, 40); n++;
202
203 char *name = args.name ? (char*)args.name : "progresss_spinner";
204 Widget w = XmCreateLabel(parent, name, xargs, n);
205 XtManageChild(w);
206 ctn->add(ctn, w);
207
208 UiVar* var = uic_widget_var(obj->ctx, obj->ctx, args.value, args.varname, UI_VAR_INTEGER);
209 if(var) {
210 UiInteger *value = var->value;
211 value->obj = w;
212 value->get = ui_progressspinner_get;
213 value->set = ui_progressspinner_set;
214
215 if(value->value) {
216 ui_progressspinner_set(value, 1);
217 }
218 }
219
220
221 XmStringFree(label);
222 return w;
223 }
224
225 int64_t ui_progressspinner_get(UiInteger *i) {
226 return i->value;
227 }
228
229 void ui_progressspinner_set(UiInteger *i, int64_t value) {
230 Widget w = i->obj;
231 XmString label;
232 if(value) {
233 char str[4];
234 snprintf(str, 4, "%c", 150);
235 label = XmStringCreateSimple(str);
236 } else {
237 label = XmStringCreateSimple("");
238 }
239 XtVaSetValues(w, XmNlabelString, label, NULL);
240 XmStringFree(label);
241 i->value = value;
242 }

mercurial