ui/qt/text.cpp

changeset 597
fc85ca42a7ce
parent 572
e655587695c0
child 672
1b08ba076b65
equal deleted inserted replaced
596:34866811080d 597:fc85ca42a7ce
55 value->value.free = NULL; 55 value->value.free = NULL;
56 56
57 return document; 57 return document;
58 } 58 }
59 59
60 UIWIDGET ui_textarea_create(UiObject *obj, UiTextAreaArgs args) { 60 UIWIDGET ui_textarea_create(UiObject *obj, UiTextAreaArgs *args) {
61 UiContainerPrivate *ctn = ui_obj_container(obj); 61 UiContainerPrivate *ctn = ui_obj_container(obj);
62 UI_APPLY_LAYOUT(ctn->layout, args); 62 UI_APPLY_LAYOUT(ctn->layout, args);
63 63
64 QTextEdit *textarea = new QTextEdit(); 64 QTextEdit *textarea = new QTextEdit();
65 ctn->add(textarea, true); 65 ctn->add(textarea, true);
66 66
67 QTextDocument *document = nullptr; 67 QTextDocument *document = nullptr;
68 68
69 UiVar* var = uic_widget_var(obj->ctx, obj->ctx, args.value, args.varname, UI_VAR_STRING); 69 UiVar* var = uic_widget_var(obj->ctx, obj->ctx, args->value, args->varname, UI_VAR_STRING);
70 if(var) { 70 if(var) {
71 UiText *value = (UiText*)var->value; 71 UiText *value = (UiText*)var->value;
72 72
73 document = get_or_create_doc(value); 73 document = get_or_create_doc(value);
74 74
208 cursor.removeSelectedText(); 208 cursor.removeSelectedText();
209 } 209 }
210 210
211 /* ------------------------------ TextField ------------------------------ */ 211 /* ------------------------------ TextField ------------------------------ */
212 212
213 static UIWIDGET create_textfield(UiObject *obj, UiTextFieldArgs args, bool password, bool frameless) { 213 static UIWIDGET create_textfield(UiObject *obj, UiTextFieldArgs *args, bool password, bool frameless) {
214 UiContainerPrivate *ctn = ui_obj_container(obj); 214 UiContainerPrivate *ctn = ui_obj_container(obj);
215 UI_APPLY_LAYOUT(ctn->layout, args); 215 UI_APPLY_LAYOUT(ctn->layout, args);
216 216
217 QLineEdit *textfield = new QLineEdit(); 217 QLineEdit *textfield = new QLineEdit();
218 ctn->add(textfield, false); 218 ctn->add(textfield, false);
219 219
220 if(password) { 220 if(password) {
221 textfield->setEchoMode(QLineEdit::Password); 221 textfield->setEchoMode(QLineEdit::Password);
222 } 222 }
223 223
224 UiVar* var = uic_widget_var(obj->ctx, obj->ctx, args.value, args.varname, UI_VAR_STRING); 224 UiVar* var = uic_widget_var(obj->ctx, obj->ctx, args->value, args->varname, UI_VAR_STRING);
225 if(var) { 225 if(var) {
226 UiString *value = (UiString*)var->value; 226 UiString *value = (UiString*)var->value;
227 if(value->value.ptr) { 227 if(value->value.ptr) {
228 QString str = QString::fromUtf8(value->value.ptr); 228 QString str = QString::fromUtf8(value->value.ptr);
229 textfield->setText(str); 229 textfield->setText(str);
239 } 239 }
240 240
241 return textfield; 241 return textfield;
242 } 242 }
243 243
244 UIWIDGET ui_textfield_create(UiObject *obj, UiTextFieldArgs args) { 244 UIWIDGET ui_textfield_create(UiObject *obj, UiTextFieldArgs *args) {
245 return create_textfield(obj, args, false, false); 245 return create_textfield(obj, args, false, false);
246 } 246 }
247 247
248 UIWIDGET ui_frameless_textfield_create(UiObject* obj, UiTextFieldArgs args) { 248 UIWIDGET ui_frameless_textfield_create(UiObject* obj, UiTextFieldArgs *args) {
249 return create_textfield(obj, args, false, true); 249 return create_textfield(obj, args, false, true);
250 } 250 }
251 251
252 UIWIDGET ui_passwordfield_create(UiObject* obj, UiTextFieldArgs args) { 252 UIWIDGET ui_passwordfield_create(UiObject* obj, UiTextFieldArgs *args) {
253 return create_textfield(obj, args, true, false); 253 return create_textfield(obj, args, true, false);
254 } 254 }
255 255
256 char* ui_textfield_get(UiString *str) { 256 char* ui_textfield_get(UiString *str) {
257 QLineEdit *textfield = (QLineEdit*)str->obj; 257 QLineEdit *textfield = (QLineEdit*)str->obj;

mercurial