ui/qt/entry.cpp

changeset 597
fc85ca42a7ce
parent 561
5798e3a28c59
child 672
1b08ba076b65
equal deleted inserted replaced
596:34866811080d 597:fc85ca42a7ce
34 #include <QDoubleSpinBox> 34 #include <QDoubleSpinBox>
35 #include <QSpinBox> 35 #include <QSpinBox>
36 36
37 37
38 38
39 UIWIDGET ui_spinner_create(UiObject *obj, UiSpinnerArgs args) { 39 UIWIDGET ui_spinner_create(UiObject *obj, UiSpinnerArgs *args) {
40 UiContainerPrivate *ctn = ui_obj_container(obj); 40 UiContainerPrivate *ctn = ui_obj_container(obj);
41 UI_APPLY_LAYOUT(ctn->layout, args); 41 UI_APPLY_LAYOUT(ctn->layout, args);
42 42
43 bool use_double = false; 43 bool use_double = false;
44 UiVar *var = NULL; 44 UiVar *var = NULL;
45 if(args.varname) { 45 if(args->varname) {
46 var = uic_get_var(obj->ctx, args.varname); 46 var = uic_get_var(obj->ctx, args->varname);
47 if(var->type == UI_VAR_DOUBLE) { 47 if(var->type == UI_VAR_DOUBLE) {
48 use_double = true; 48 use_double = true;
49 } else if(var->type == UI_VAR_RANGE) { 49 } else if(var->type == UI_VAR_RANGE) {
50 use_double = true; 50 use_double = true;
51 } else if(var->type != UI_VAR_INTEGER) { 51 } else if(var->type != UI_VAR_INTEGER) {
52 var = NULL; 52 var = NULL;
53 fprintf(stderr, "UI Error: var '%s' has wrong type (must be int/double/range)\n", args.varname); 53 fprintf(stderr, "UI Error: var '%s' has wrong type (must be int/double/range)\n", args->varname);
54 } 54 }
55 } 55 }
56 56
57 if(!var) { 57 if(!var) {
58 if(args.intvalue) { 58 if(args->intvalue) {
59 var = uic_widget_var(obj->ctx, obj->ctx, args.intvalue, NULL, UI_VAR_INTEGER); 59 var = uic_widget_var(obj->ctx, obj->ctx, args->intvalue, NULL, UI_VAR_INTEGER);
60 } else if(args.doublevalue) { 60 } else if(args->doublevalue) {
61 var = uic_widget_var(obj->ctx, obj->ctx, args.doublevalue, NULL, UI_VAR_DOUBLE); 61 var = uic_widget_var(obj->ctx, obj->ctx, args->doublevalue, NULL, UI_VAR_DOUBLE);
62 use_double = true; 62 use_double = true;
63 } else if(args.rangevalue) { 63 } else if(args->rangevalue) {
64 var = uic_widget_var(obj->ctx, obj->ctx, args.rangevalue, NULL, UI_VAR_RANGE); 64 var = uic_widget_var(obj->ctx, obj->ctx, args->rangevalue, NULL, UI_VAR_RANGE);
65 use_double = true; 65 use_double = true;
66 } else { 66 } else {
67 if(args.digits > 0) { 67 if(args->digits > 0) {
68 use_double = true; 68 use_double = true;
69 } 69 }
70 } 70 }
71 } 71 }
72 72
73 QAbstractSpinBox *widget = nullptr; 73 QAbstractSpinBox *widget = nullptr;
74 if(use_double) { 74 if(use_double) {
75 QDoubleSpinBox *spinbox = new QDoubleSpinBox(); 75 QDoubleSpinBox *spinbox = new QDoubleSpinBox();
76 spinbox->setDecimals(args.digits); 76 spinbox->setDecimals(args->digits);
77 if(args.step != 0) { 77 if(args->step != 0) {
78 spinbox->setSingleStep(args.step); 78 spinbox->setSingleStep(args->step);
79 } 79 }
80 widget = spinbox; 80 widget = spinbox;
81 } else { 81 } else {
82 QSpinBox *spinbox = new QSpinBox(); 82 QSpinBox *spinbox = new QSpinBox();
83 if(args.step != 0) { 83 if(args->step != 0) {
84 spinbox->setSingleStep(args.step); 84 spinbox->setSingleStep(args->step);
85 } 85 }
86 widget = spinbox; 86 widget = spinbox;
87 } 87 }
88 88
89 if(var) { 89 if(var) {

mercurial