diff -r 1cc365c34125 -r e82b01d17a78 ui/motif/text.c --- a/ui/motif/text.c Fri Jan 29 18:48:56 2016 +0100 +++ b/ui/motif/text.c Fri Jan 29 19:11:15 2016 +0100 @@ -336,12 +336,23 @@ /* ------------------------- textfield ------------------------- */ -UIWIDGET ui_textfield(UiObject *obj, UiString *value) { +static UIWIDGET create_textfield(UiObject *obj, int width, UiBool frameless, UiBool password, UiString *value) { UiContainer *ct = uic_get_current_container(obj); int n = 0; Arg args[16]; XtSetArg(args[n], XmNeditMode, XmSINGLE_LINE_EDIT); n++; + if(width > 0) { + XtSetArg(args[n], XmNcolumns, width / 2 + 1); + n++; + } + if(frameless) { + XtSetArg(args[n], XmNshadowThickness, 0); + n++; + } + if(password) { + // TODO + } Widget parent = ct->prepare(ct, args, &n, FALSE); Widget textfield = XmCreateText(parent, "text_field", args, n); @@ -364,7 +375,7 @@ return textfield; } -UIWIDGET ui_textfield_nv(UiObject *obj, char *varname) { +static UIWIDGET create_textfield_nv(UiObject *obj, int width, UiBool frameless, UiBool password, char *varname) { UiVar *var = uic_connect_var(obj->ctx, varname, UI_VAR_STRING); if(var) { UiString *value = var->value; @@ -375,6 +386,47 @@ return NULL; } +UIWIDGET ui_textfield(UiObject *obj, UiString *value) { + return create_textfield(obj, 0, FALSE, FALSE, value); +} + +UIWIDGET ui_textfield_nv(UiObject *obj, char *varname) { + return create_textfield_nv(obj, 0, FALSE, FALSE, varname); +} + +UIWIDGET ui_textfield_w(UiObject *obj, int width, UiString *value) { + return create_textfield(obj, width, FALSE, FALSE, value); +} + +UIWIDGET ui_textfield_wnv(UiObject *obj, int width, char *varname) { + return create_textfield_nv(obj, width, FALSE, FALSE, varname); +} + +UIWIDGET ui_frameless_textfield(UiObject *obj, UiString *value) { + return create_textfield(obj, 0, TRUE, FALSE, value); +} + +UIWIDGET ui_frameless_textfield_nv(UiObject *obj, char *varname) { + return create_textfield_nv(obj, 0, TRUE, FALSE, varname); +} + +UIWIDGET ui_passwordfield(UiObject *obj, UiString *value) { + return create_textfield(obj, 0, FALSE, TRUE, value); +} + +UIWIDGET ui_passwordfield_nv(UiObject *obj, char *varname) { + return create_textfield_nv(obj, 0, FALSE, TRUE, varname); +} + +UIWIDGET ui_passwordfield_w(UiObject *obj, int width, UiString *value) { + return create_textfield(obj, width, FALSE, TRUE, value); +} + +UIWIDGET ui_passwordfield_wnv(UiObject *obj, int width, char *varname) { + return create_textfield_nv(obj, width, FALSE, TRUE, varname); +} + + char* ui_textfield_get(UiString *str) { if(str->value) { XtFree(str->value);