summaryrefslogtreecommitdiff
path: root/render/box.c
diff options
context:
space:
mode:
authorPhil Mellor <phil@monkeyson.info>2002-12-29 22:27:35 +0000
committerPhil Mellor <phil@monkeyson.info>2002-12-29 22:27:35 +0000
commit50fc20c2d4883b399fcee8c7a2905605304d9e40 (patch)
tree3f21c3c55f30504832a90da14785c42f8c0e4781 /render/box.c
parent0eec3d6d4ffbcfefd9593298530632c8ccf90760 (diff)
downloadnetsurf-50fc20c2d4883b399fcee8c7a2905605304d9e40.tar.gz
netsurf-50fc20c2d4883b399fcee8c7a2905605304d9e40.tar.bz2
[project @ 2002-12-29 22:27:35 by monkeyson]
Font anti-alias colours corrected. Begin displaying form elements - text, password, submit, reset svn path=/import/netsurf/; revision=71
Diffstat (limited to 'render/box.c')
-rw-r--r--render/box.c85
1 files changed, 84 insertions, 1 deletions
diff --git a/render/box.c b/render/box.c
index 59a32016f..5fc1aa355 100644
--- a/render/box.c
+++ b/render/box.c
@@ -1,5 +1,5 @@
/**
- * $Id: box.c,v 1.22 2002/12/27 20:35:32 bursa Exp $
+ * $Id: box.c,v 1.23 2002/12/29 22:27:35 monkeyson Exp $
*/
#include <assert.h>
@@ -19,6 +19,8 @@
* internal functions
*/
+struct box* box_gui_gadget(xmlNode * n, struct css_style* style);
+
void box_add_child(struct box * parent, struct box * child);
struct box * box_create(xmlNode * node, box_type type, struct css_style * style,
const char *href);
@@ -77,6 +79,7 @@ struct box * box_create(xmlNode * node, box_type type, struct css_style * style,
box->next_float = 0;
box->col = 0;
box->font = 0;
+ box->gadget = 0;
return box;
}
@@ -173,6 +176,7 @@ struct box * convert_xml_to_box(xmlNode * n, struct css_style * parent_style,
}
if (n->type == XML_TEXT_NODE ||
+ (n->type == XML_ELEMENT_NODE && (strcmp((const char *) n->name, "input") == 0)) ||
(n->type == XML_ELEMENT_NODE && (style->float_ == CSS_FLOAT_LEFT ||
style->float_ == CSS_FLOAT_RIGHT))) {
/* text nodes are converted to inline boxes, wrapped in an inline container block */
@@ -194,6 +198,11 @@ struct box * convert_xml_to_box(xmlNode * n, struct css_style * parent_style,
}
box->font = font_open(fonts, box->style);
box_add_child(inline_container, box);
+ } else if (strcmp((const char *) n->name, "input") == 0) {
+ LOG(("input"));
+ box = box_gui_gadget(n, parent_style);
+ if (box != NULL)
+ box_add_child(inline_container, box);
} else {
LOG(("float"));
box = box_create(0, BOX_FLOAT_LEFT, 0, href);
@@ -406,6 +415,7 @@ void box_normalise_block(struct box *block)
assert(block->type == BOX_BLOCK || block->type == BOX_TABLE_CELL);
for (child = block->children; child != 0; prev_child = child, child = child->next) {
+ fprintf(stderr, "child->type = %d\n", child->type);
switch (child->type) {
case BOX_BLOCK:
/* ok */
@@ -702,6 +712,12 @@ void box_free(struct box *box)
/* last this box */
// if (box->style != 0)
// free(box->style);
+ if (box->gadget != 0)
+ {
+ /* gadget_free(box->gadget); */
+ free((void*)box->gadget);
+ }
+
if (box->text != 0)
free((void*)box->text);
/* only free href if we're the top most user */
@@ -713,3 +729,70 @@ void box_free(struct box *box)
free((void*)box->href);
}
}
+
+struct box* box_gui_gadget(xmlNode * n, struct css_style* style)
+{
+ struct box* box = 0;
+ char* s;
+ char* type;
+
+ if ((type = (char *) xmlGetProp(n, (xmlChar *) "type")))
+ {
+ if (strcmp(type, "submit") == 0 || strcmp(type, "reset") == 0)
+ {
+ //style->display = CSS_DISPLAY_BLOCK;
+
+ box = box_create(n, BOX_INLINE, style, NULL);
+ box->gadget = xcalloc(1, sizeof(struct gui_gadget));
+ box->gadget->type = GADGET_ACTIONBUTTON;
+
+ box->text = 0;
+ box->length = 0;
+ box->font = 0;
+
+ if ((s = (char *) xmlGetProp(n, (xmlChar *) "value"))) {
+ box->gadget->data.actionbutt.label = s;
+ }
+ else
+ {
+ box->gadget->data.actionbutt.label = strdup(type);
+ box->gadget->data.actionbutt.label[0] = toupper(type[0]);
+ }
+ }
+ if (strcmp(type, "text") == 0 || strcmp(type, "password") == 0)
+ {
+ //style->display = CSS_DISPLAY_BLOCK;
+
+ box = box_create(n, BOX_INLINE, style, NULL);
+ box->gadget = xcalloc(1, sizeof(struct gui_gadget));
+ box->gadget->type = GADGET_TEXTBOX;
+
+ box->text = 0;
+ box->length = 0;
+ box->font = 0;
+
+ box->gadget->data.textbox.maxlength = 255;
+ if ((s = (char *) xmlGetProp(n, (xmlChar *) "maxlength"))) {
+ box->gadget->data.textbox.maxlength = atoi(s);
+ free(s);
+ }
+
+ box->gadget->data.textbox.size = box->gadget->data.textbox.maxlength;
+ if ((s = (char *) xmlGetProp(n, (xmlChar *) "size"))) {
+ box->gadget->data.textbox.size = atoi(s);
+ free(s);
+ }
+
+ box->gadget->data.textbox.text = xcalloc(box->gadget->data.textbox.maxlength + 1, sizeof(char));
+
+ if ((s = (char *) xmlGetProp(n, (xmlChar *) "value"))) {
+ strncpy(box->gadget->data.textbox.text, s,
+ box->gadget->data.textbox.maxlength);
+ free(s);
+ }
+
+ }
+ free(type);
+ }
+ return box;
+}