[project @ 2004-05-21 23:42:26 by bursa]

Fix and clean code for radio and checkbox inputs.

svn path=/import/netsurf/; revision=884
This commit is contained in:
James Bursa 2004-05-21 23:42:26 +00:00
parent bb9149e93b
commit 4a500f5614
5 changed files with 11 additions and 19 deletions

View File

@ -516,9 +516,8 @@ void clear_radio_gadgets(struct browser_window *bw, struct box *box,
if (box->gadget->type == GADGET_RADIO
&& box->gadget->name != 0 && box->gadget != group) {
if (strcmp(box->gadget->name, group->name) == 0) {
if (box->gadget->data.radio.selected) {
box->gadget->data.radio.selected =
0;
if (box->gadget->selected) {
box->gadget->selected = false;
gui_redraw_gadget(bw, box->gadget);
}
}
@ -641,12 +640,12 @@ int browser_window_gadget_click(struct browser_window* bw, unsigned long click_x
gui_gadget_combo(bw, g, click_x, click_y);
break;
case GADGET_CHECKBOX:
g->data.checkbox.selected = !g->data.checkbox.selected;
g->selected = !g->selected;
gui_redraw_gadget(bw, g);
break;
case GADGET_RADIO:
clear_radio_gadgets(bw, click_boxes[i].content->data.html.layout->children, g);
g->data.radio.selected = -1;
g->selected = true;
gui_redraw_gadget(bw, g);
break;
case GADGET_SUBMIT:

View File

@ -1134,10 +1134,7 @@ struct box_result box_input(xmlNode *n, struct box_status *status,
gadget->type = GADGET_CHECKBOX;
if ((s = (char *) xmlGetProp(n, (const xmlChar *) "checked"))) {
if (gadget->type == GADGET_CHECKBOX)
gadget->data.checkbox.selected = -1;
else
gadget->data.radio.selected = -1;
gadget->selected = true;
xmlFree(s);
}

View File

@ -43,6 +43,7 @@ struct form_control *form_new_control(form_control_type type)
control->disabled = false;
control->form = 0;
control->box = 0;
control->selected = false;
control->prev = 0;
control->next = 0;
return control;
@ -124,9 +125,9 @@ struct form_successful_control *form_successful_controls(struct form *form,
continue;
/* ignore checkboxes and radio buttons which aren't selected */
if (control->type == GADGET_CHECKBOX && !control->data.checkbox.selected)
if (control->type == GADGET_CHECKBOX && !control->selected)
continue;
if (control->type == GADGET_RADIO && !control->data.radio.selected)
if (control->type == GADGET_RADIO && !control->selected)
continue;
/* select */

View File

@ -60,6 +60,7 @@ struct form_control {
struct box *caret_text_box;
int caret_char_offset;
unsigned int maxlength;
bool selected;
union {
struct {
int mx, my;
@ -72,12 +73,6 @@ struct form_control {
/** Currently selected item, if num_selected == 1. */
struct form_option *current;
} select;
struct {
int selected;
} checkbox;
struct {
int selected;
} radio;
} data;
struct form_control *prev; /**< Previous control in this form */
struct form_control *next; /**< Next control in this form. */

View File

@ -227,12 +227,12 @@ void html_redraw_box(struct content *content, struct box * box,
} else if (box->gadget && box->gadget->type == GADGET_CHECKBOX) {
html_redraw_checkbox(x + padding_left, y - padding_top,
width, height,
box->gadget->data.checkbox.selected);
box->gadget->selected);
} else if (box->gadget && box->gadget->type == GADGET_RADIO) {
html_redraw_radio(x + padding_left, y - padding_top,
width, height,
box->gadget->data.radio.selected);
box->gadget->selected);
} else if (box->gadget && box->gadget->type == GADGET_FILE) {
colourtrans_set_font_colours(box->font->handle,