diff options
author | John Mark Bell <jmb@netsurf-browser.org> | 2003-09-09 19:25:28 +0000 |
---|---|---|
committer | John Mark Bell <jmb@netsurf-browser.org> | 2003-09-09 19:25:28 +0000 |
commit | ddb2b9871649a38eec0a3e2465fe433fc82186e4 (patch) | |
tree | 10d221c53bf740d06a4e924e2bdb06e640b04001 /render/box.c | |
parent | 47dcb4f127a96305a80ddbb725d94bf176878d16 (diff) | |
download | netsurf-ddb2b9871649a38eec0a3e2465fe433fc82186e4.tar.gz netsurf-ddb2b9871649a38eec0a3e2465fe433fc82186e4.tar.bz2 |
[project @ 2003-09-09 19:25:28 by jmb]
Forms: [input type=image] support, passwords are now displayed as asterisks
svn path=/import/netsurf/; revision=275
Diffstat (limited to 'render/box.c')
-rw-r--r-- | render/box.c | 69 |
1 files changed, 66 insertions, 3 deletions
diff --git a/render/box.c b/render/box.c index 307df5848..382429bb1 100644 --- a/render/box.c +++ b/render/box.c @@ -751,13 +751,12 @@ struct result box_input(xmlNode *n, struct status *status, { struct box* box = 0; struct gui_gadget *gadget = 0; - char *s, *type; + char *s, *type, *url; type = (char *) xmlGetProp(n, (const xmlChar *) "type"); /* the default type is "text" */ - if (type == 0 || stricmp(type, "text") == 0 || - stricmp(type, "password") == 0) + if (type == 0 || stricmp(type, "text") == 0) { box = box_create(style, NULL, 0); box->gadget = gadget = xcalloc(1, sizeof(struct gui_gadget)); @@ -785,6 +784,34 @@ struct result box_input(xmlNode *n, struct status *status, } } + if (stricmp(type, "password") == 0) + { + box = box_create(style, NULL, 0); + box->gadget = gadget = xcalloc(1, sizeof(struct gui_gadget)); + gadget->type = GADGET_PASSWORD; + + gadget->data.password.maxlength = 32; + if ((s = (char *) xmlGetProp(n, (const xmlChar *) "maxlength"))) { + gadget->data.password.maxlength = atoi(s); + xmlFree(s); + } + + gadget->data.password.size = box->gadget->data.password.maxlength; + if ((s = (char *) xmlGetProp(n, (const xmlChar *) "size"))) { + gadget->data.password.size = atoi(s); + xmlFree(s); + } + + gadget->data.password.text = xcalloc( + gadget->data.password.maxlength + 2, sizeof(char)); + + if ((s = (char *) xmlGetProp(n, (const xmlChar *) "value"))) { + strncpy(gadget->data.password.text, s, + gadget->data.password.maxlength); + xmlFree(s); + } + + } else if (stricmp(type, "hidden") == 0) { /* no box for hidden inputs */ @@ -835,6 +862,29 @@ struct result box_input(xmlNode *n, struct status *status, box->gadget->data.actionbutt.butttype = strdup(type); } + else if (stricmp(type, "image") == 0) + { + box = box_create(style, NULL, 0); + box->gadget = gadget = xcalloc(1, sizeof(struct gui_gadget)); + gadget->type = GADGET_IMAGE; + if ((s = (char *) xmlGetProp(n, (const xmlChar*) "name"))) { + gadget->data.image.n = s; + } + if ((s = (char *) xmlGetProp(n, (const xmlChar*) "width"))) { + gadget->data.image.width = (atoi(s)); + } + if ((s = (char *) xmlGetProp(n, (const xmlChar*) "height"))) { + gadget->data.image.height = (atoi(s)); + } + if ((s = (char *) xmlGetProp(n, (const xmlChar*) "src"))) { + url = url_join(strdup(s), status->content->url); + html_fetch_object(status->content, url, box); + } + gadget->data.image.name = + xcalloc(strlen(gadget->data.image.n) + 5, sizeof(char)); + gadget->data.image.value = + xcalloc(strlen(gadget->data.image.n) + 20, sizeof(char)); + } if (type != 0) xmlFree(type); @@ -1319,10 +1369,23 @@ void gadget_free(struct gui_gadget* g) if (g->data.textbox.text != 0) xmlFree(g->data.textbox.text); break; + case GADGET_PASSWORD: + gui_remove_gadget(g); + if (g->data.password.text != 0) + xmlFree(g->data.password.text); + break; case GADGET_ACTIONBUTTON: if (g->data.actionbutt.label != 0) xmlFree(g->data.actionbutt.label); break; + case GADGET_IMAGE: + if (g->data.image.n != 0) + xmlFree(g->data.image.n); + if (g->data.image.name != 0) + xfree(g->data.image.name); + if (g->data.image.value != 0) + xfree(g->data.image.value); + break; case GADGET_SELECT: o = g->data.select.items; while (o != NULL) |