diff options
Diffstat (limited to 'render')
-rw-r--r-- | render/box.c | 69 | ||||
-rw-r--r-- | render/box.h | 15 | ||||
-rw-r--r-- | render/layout.c | 14 |
3 files changed, 91 insertions, 7 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) diff --git a/render/box.h b/render/box.h index a00daee48..002bb0601 100644 --- a/render/box.h +++ b/render/box.h @@ -40,7 +40,8 @@ struct formoption { struct gui_gadget { enum { GADGET_HIDDEN = 0, GADGET_TEXTBOX, GADGET_RADIO, GADGET_CHECKBOX, - GADGET_SELECT, GADGET_TEXTAREA, GADGET_ACTIONBUTTON } type; + GADGET_SELECT, GADGET_TEXTAREA, GADGET_ACTIONBUTTON, + GADGET_IMAGE, GADGET_PASSWORD } type; char* name; struct form* form; union { @@ -53,11 +54,23 @@ struct gui_gadget { int size; } textbox; struct { + unsigned int maxlength; + char* text; + int size; + } password; + struct { char* butttype; char* label; int pressed; } actionbutt; struct { + char* name; + char* value; + char* n; + int width, height; + int mx, my; + } image; + struct { int numitems; struct formoption* items; int size; diff --git a/render/layout.c b/render/layout.c index f428ae36d..9a6785025 100644 --- a/render/layout.c +++ b/render/layout.c @@ -101,7 +101,7 @@ int gadget_width(struct gui_gadget* gadget) struct formoption* current; int max; - /* should use wimp_textop via a gui wraper for these */ + /* should use wimp_textop via a gui wrapper for these */ switch (gadget->type) { case GADGET_CHECKBOX: @@ -109,8 +109,12 @@ int gadget_width(struct gui_gadget* gadget) return 22; case GADGET_TEXTBOX: return gadget->data.textbox.size * 8; + case GADGET_PASSWORD: + return gadget->data.password.size * 8; case GADGET_ACTIONBUTTON: return strlen(gadget->data.actionbutt.label) * 8 + 16; + case GADGET_IMAGE: + return gadget->data.image.width; case GADGET_SELECT: current = gadget->data.select.items; max = 32; @@ -138,10 +142,14 @@ int gadget_height(struct gui_gadget* gadget) return 22; case GADGET_TEXTBOX: return 28; + case GADGET_PASSWORD: + return 28; case GADGET_ACTIONBUTTON: return 28; + case GADGET_IMAGE: + return gadget->data.image.height; case GADGET_SELECT: - return 28; + return 28; // * gadget->data.select.size; case GADGET_TEXTAREA: return gadget->data.textarea.rows * 16 + 8; default: @@ -925,7 +933,7 @@ void calculate_table_widths(struct box *table) col = table->col; else col = xcalloc(table->columns, sizeof(*col)); - + assert(table->children != 0 && table->children->children != 0); for (pass = 0; pass != 2; pass++) { for (row_group = table->children; row_group != 0; row_group = row_group->next) { |