From ddb2b9871649a38eec0a3e2465fe433fc82186e4 Mon Sep 17 00:00:00 2001 From: John Mark Bell Date: Tue, 9 Sep 2003 19:25:28 +0000 Subject: [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 --- riscos/gui.c | 56 +++++++++++++++++++++++++++++++++++++++- riscos/htmlredraw.c | 74 +++++++++++++++++++++++++++++++++++++++++++---------- 2 files changed, 116 insertions(+), 14 deletions(-) (limited to 'riscos') diff --git a/riscos/gui.c b/riscos/gui.c index 5f964c6e0..40113dc0e 100644 --- a/riscos/gui.c +++ b/riscos/gui.c @@ -35,6 +35,7 @@ const char *__dynamic_da_name = "NetSurf"; static char empty_text[] = ""; +static char password_v[] = "D*"; char *NETSURF_DIR; gui_window *window_list = 0; @@ -1318,7 +1319,7 @@ void gui_multitask(void) case message_QUIT : netsurf_quit = 1; break; - + default: ro_gui_poll_queue(event, &block); break; @@ -1860,6 +1861,59 @@ void gui_edit_textbox(struct browser_window* bw, struct gui_gadget* g) wimp_set_caret_position(current_textbox_w, current_textbox_i, 0,0,-1, offset); } +void gui_edit_password(struct browser_window* bw, struct gui_gadget* g) +{ + wimp_icon_create icon; + wimp_pointer pointer; + wimp_window_state state; + int pointer_x; + int letter_x; + int textbox_x; + int offset; + + wimp_get_pointer_info(&pointer); + + if (current_textbox != 0) + { + wimp_delete_icon(current_textbox_w, current_textbox_i); + gui_redraw_gadget(current_textbox_bw, current_textbox); + } + + current_textbox_bw = bw; + current_textbox_w = bw->window->data.browser.window; + + icon.w = current_textbox_w; + gui_set_gadget_extent(bw->current_content->data.html.layout->children, 0, 0, &icon.icon.extent, g); + fprintf(stderr, "ICON EXTENT %d %d %d %d\n", icon.icon.extent.x0, icon.icon.extent.y0, icon.icon.extent.x1, icon.icon.extent.y1); + icon.icon.flags = wimp_ICON_TEXT | wimp_ICON_BORDER | + wimp_ICON_VCENTRED | wimp_ICON_FILLED | + wimp_ICON_INDIRECTED | + (wimp_COLOUR_BLACK << wimp_ICON_FG_COLOUR_SHIFT) | + (wimp_COLOUR_WHITE << wimp_ICON_BG_COLOUR_SHIFT) | + (wimp_BUTTON_WRITABLE << wimp_ICON_BUTTON_TYPE_SHIFT); + icon.icon.data.indirected_text.text = g->data.password.text; + icon.icon.data.indirected_text.size = g->data.password.maxlength + 1; + icon.icon.data.indirected_text.validation = password_v; + current_textbox_i = wimp_create_icon(&icon); + current_textbox = g; + gui_redraw_gadget(bw, current_textbox); + + state.w = current_textbox_w; + wimp_get_window_state(&state); + pointer_x = window_x_units(pointer.pos.x, &state); + textbox_x = icon.icon.extent.x0; + offset = strlen(g->data.password.text); + while (offset > 0) + { + letter_x = wimptextop_string_width(g->data.password.text, offset); + if (letter_x < pointer_x - textbox_x) + break; + offset--; + } + + wimp_set_caret_position(current_textbox_w, current_textbox_i, 0,0,-1, offset); +} + void gui_remove_gadget(struct gui_gadget* g) { if (g == current_textbox && g != 0) diff --git a/riscos/htmlredraw.c b/riscos/htmlredraw.c index d3ef7d500..588dde2a3 100644 --- a/riscos/htmlredraw.c +++ b/riscos/htmlredraw.c @@ -50,6 +50,7 @@ void html_redraw(struct content *c, long x, long y, /* validation strings can't be const */ static char validation_textarea[] = "R7;L"; static char validation_textbox[] = ""; +static char validation_password[] = "D*"; static char validation_actionbutton[] = "R5"; static char validation_actionbutton_pressed[] = "R5,3"; static char validation_select[] = "R2"; @@ -72,6 +73,7 @@ void html_redraw_box(struct content *content, struct box * box, struct box * c; char* select_text; struct formoption* opt; + int i; if (x + (signed long) (box->x*2 + box->width*2) /* right edge */ >= clip->x0 && x + (signed long) (box->x*2) /* left edge */ <= clip->x1 && @@ -143,6 +145,19 @@ void html_redraw_box(struct content *content, struct box * box, wimp_plot_icon(&icon); break; + case GADGET_PASSWORD: + icon.flags = wimp_ICON_TEXT | wimp_ICON_BORDER | + wimp_ICON_VCENTRED | wimp_ICON_FILLED | + wimp_ICON_INDIRECTED | + (wimp_COLOUR_DARK_GREY << wimp_ICON_FG_COLOUR_SHIFT) | + (wimp_COLOUR_WHITE << wimp_ICON_BG_COLOUR_SHIFT); + icon.data.indirected_text.text = box->gadget->data.password.text; + icon.data.indirected_text.size = box->gadget->data.password.maxlength + 1; + icon.data.indirected_text.validation = validation_password; + LOG(("writing GADGET PASSWORD")); + wimp_plot_icon(&icon); + break; + case GADGET_ACTIONBUTTON: icon.flags = wimp_ICON_TEXT | wimp_ICON_BORDER | wimp_ICON_VCENTRED | wimp_ICON_FILLED | @@ -172,20 +187,52 @@ void html_redraw_box(struct content *content, struct box * box, (wimp_COLOUR_VERY_LIGHT_GREY << wimp_ICON_BG_COLOUR_SHIFT); select_text = 0; opt = box->gadget->data.select.items; - while (opt != NULL) - { - if (opt->selected) - { - if (select_text == 0) - select_text = opt->text; - else - select_text = select_text_multiple; - } - opt = opt->next; +// if (box->gadget->data.select.size == 1) { + while (opt != NULL) + { + if (opt->selected) + { + if (select_text == 0) + select_text = opt->text; + else + select_text = select_text_multiple; + } + opt = opt->next; + } + if (select_text == 0) + select_text = select_text_none; +/* } + else { + while (opt != NULL) + { + if (opt->selected) + { + select_text = opt->text; + opt = opt->next; + break; + } + opt = opt->next; + } + if (select_text == 0) { + // display the first n options + opt = box->gadget->data.select.items; + select_text = opt->text; + opt = opt->next; + for(i = box->gadget->data.select.size-1; + i != 0; i--, opt=opt->next) { + strcat(select_text, "\n"); + strcat(select_text, opt->text); + } + } + else { + for(i = box->gadget->data.select.size-1; + i != 0; i--, opt=opt->next) { + strcat(select_text, "\n"); + strcat(select_text, opt->text); + } + } } - if (select_text == 0) - select_text = select_text_none; - icon.data.indirected_text.text = select_text; +*/ icon.data.indirected_text.text = select_text; icon.data.indirected_text.size = strlen(icon.data.indirected_text.text); icon.data.indirected_text.validation = validation_select; LOG(("writing GADGET ACTION")); @@ -218,6 +265,7 @@ void html_redraw_box(struct content *content, struct box * box, break; case GADGET_HIDDEN: + case GADGET_IMAGE: break; } LOG(("gadgets finished")); -- cgit v1.2.3