added some special textfields (Motif)

Fri, 29 Jan 2016 19:11:15 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Fri, 29 Jan 2016 19:11:15 +0100
changeset 122
e82b01d17a78
parent 121
1cc365c34125
child 123
55adc92e7c09

added some special textfields (Motif)

application/main.c file | annotate | diff | comparison | revisions
ui/gtk/text.c file | annotate | diff | comparison | revisions
ui/motif/label.c file | annotate | diff | comparison | revisions
ui/motif/list.c file | annotate | diff | comparison | revisions
ui/motif/text.c file | annotate | diff | comparison | revisions
ui/motif/toolkit.c file | annotate | diff | comparison | revisions
--- a/application/main.c	Fri Jan 29 18:48:56 2016 +0100
+++ b/application/main.c	Fri Jan 29 19:11:15 2016 +0100
@@ -149,8 +149,8 @@
     
     ui_layout_fill(obj, FALSE);
     ui_hbox_sp(obj, 0, 10);
+    ui_textfield_w(obj, 5, NULL);
     ui_textfield_w(obj, 10, NULL);
-    ui_textfield_w(obj, 40, NULL);
     ui_textfield(obj, NULL);
     ui_end(obj);
     
--- a/ui/gtk/text.c	Fri Jan 29 18:48:56 2016 +0100
+++ b/ui/gtk/text.c	Fri Jan 29 19:11:15 2016 +0100
@@ -502,36 +502,36 @@
     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_w(UiObject *obj, int width, UiString *value) {
-    return create_textfield(obj, width, FALSE, TRUE, value);
-}
-
-UIWIDGET ui_textfield_nv(UiObject *obj, char *varname) {
-    return create_textfield_nv(obj, 0, FALSE, FALSE, varname);
+UIWIDGET ui_passwordfield_nv(UiObject *obj, char *varname) {
+    return create_textfield_nv(obj, 0, FALSE, TRUE, varname);
 }
 
-UIWIDGET ui_textfield_wnv(UiObject *obj, int width, char *varname) {
-    return create_textfield_nv(obj, width, FALSE, FALSE, varname);
-}
-
-UIWIDGET ui_frameless_textfield_nv(UiObject *obj, char *varname) {
-    return create_textfield_nv(obj, 0, TRUE, FALSE, varname);
-}
-
-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) {
--- a/ui/motif/label.c	Fri Jan 29 18:48:56 2016 +0100
+++ b/ui/motif/label.c	Fri Jan 29 19:11:15 2016 +0100
@@ -67,4 +67,4 @@
     XtManageChild(widget);
     
     return widget;
-}
\ No newline at end of file
+}
--- a/ui/motif/list.c	Fri Jan 29 18:48:56 2016 +0100
+++ b/ui/motif/list.c	Fri Jan 29 19:11:15 2016 +0100
@@ -213,4 +213,4 @@
             (ui_callback)ui_listview_update,
             listview);
     
-}
\ No newline at end of file
+}
--- 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);
--- a/ui/motif/toolkit.c	Fri Jan 29 18:48:56 2016 +0100
+++ b/ui/motif/toolkit.c	Fri Jan 29 19:11:15 2016 +0100
@@ -305,6 +305,6 @@
             type,
             8,
             PropModeReplace,
-            "dark",
+            (const unsigned char*)"dark",
             4);
 }

mercurial