diff options
author | James Bursa <james@netsurf-browser.org> | 2003-09-28 23:41:07 +0000 |
---|---|---|
committer | James Bursa <james@netsurf-browser.org> | 2003-09-28 23:41:07 +0000 |
commit | 73f7db2a75a7cee2add50973e8861b767f5bb650 (patch) | |
tree | bc546b7a31ae7b7f95e83ae42d6568c4df23fdc4 /riscos | |
parent | fd7078b1ad470c3de96d32c3699eb862259df990 (diff) | |
download | netsurf-73f7db2a75a7cee2add50973e8861b767f5bb650.tar.gz netsurf-73f7db2a75a7cee2add50973e8861b767f5bb650.tar.bz2 |
[project @ 2003-09-28 23:41:06 by bursa]
Rewrite text and password inputs to stop using wimp icons.
svn path=/import/netsurf/; revision=330
Diffstat (limited to 'riscos')
-rw-r--r-- | riscos/gui.c | 145 | ||||
-rw-r--r-- | riscos/htmlredraw.c | 34 |
2 files changed, 3 insertions, 176 deletions
diff --git a/riscos/gui.c b/riscos/gui.c index 3d10ba4f7..0ef0911c9 100644 --- a/riscos/gui.c +++ b/riscos/gui.c @@ -41,8 +41,6 @@ static char password_v[] = "D*"; char *NETSURF_DIR; gui_window *window_list = 0; -int gadget_subtract_x; -int gadget_subtract_y; const char* HOME_URL = "file:///%3CNetSurf$Dir%3E/Resources/intro"; const char* HELP_URL = "file:///%3CNetSurf$Dir%3E/Docs/en/index"; @@ -66,8 +64,6 @@ void ro_gui_window_click(gui_window* g, wimp_pointer* mouse); void ro_gui_window_open(gui_window* g, wimp_open* open); void ro_gui_window_redraw(gui_window* g, wimp_draw* redraw); //void ro_gui_window_keypress(gui_window* g, wimp_key* key); -void gui_remove_gadget(struct gui_gadget* g); - static int window_x_units(int scr_units, wimp_window_state* win); @@ -90,7 +86,6 @@ static void ro_gui_poll_queue(wimp_event_no event, wimp_block* block); static void ro_gui_keypress(wimp_key* key); static void ro_msg_datasave(wimp_message* block); static void ro_msg_dataload(wimp_message* block); -static void gui_set_gadget_extent(struct box* box, int x, int y, os_box* extent, struct gui_gadget* g); static void ro_gui_screen_size(int *width, int *height); @@ -1804,146 +1799,6 @@ void ro_msg_dataload(wimp_message* block) } -static struct browser_window* current_textbox_bw; -static struct gui_gadget* current_textbox = 0; -static wimp_w current_textbox_w; -static wimp_i current_textbox_i; - -void gui_set_gadget_extent(struct box* box, int x, int y, os_box* extent, struct gui_gadget* g) -{ - struct box* c; - if (box->gadget == g) - { - extent->x0 = x + box->x * 2; - extent->y0 = y - box->y * 2 - box->height * 2; - extent->x1 = x + box->x * 2 + box->width * 2; - extent->y1 = y - box->y * 2; - return; - } - for (c = box->children; c != 0; c = c->next) - if (c->type != BOX_FLOAT_LEFT && c->type != BOX_FLOAT_RIGHT) - gui_set_gadget_extent(c, x + box->x * 2, y - box->y * 2, extent, g); - - for (c = box->float_children; c != 0; c = c->next_float) - gui_set_gadget_extent(c, x + box->x * 2, y - box->y * 2, extent, g); -} - -void gui_edit_textbox(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.textbox.text; - icon.icon.data.indirected_text.size = g->data.textbox.maxlength + 1; - icon.icon.data.indirected_text.validation = empty_text; - 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.textbox.text); - while (offset > 0) - { - letter_x = wimptextop_string_width(g->data.textbox.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_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) - { - wimp_delete_icon(current_textbox_w, current_textbox_i); - gui_redraw_gadget(current_textbox_bw, current_textbox); - current_textbox = 0; - } -} - /** * Find screen size in OS units. diff --git a/riscos/htmlredraw.c b/riscos/htmlredraw.c index fcfd663eb..d0bce76dc 100644 --- a/riscos/htmlredraw.c +++ b/riscos/htmlredraw.c @@ -126,11 +126,10 @@ void html_redraw_box(struct content *content, struct box * box, content_redraw(box->object, x, y, width, height, x0, y0, x1, y1); } else if (box->gadget && - box->gadget->type != GADGET_TEXTAREA && - box->gadget->type != GADGET_SUBMIT && - box->gadget->type != GADGET_RESET) { + (box->gadget->type == GADGET_SELECT || + box->gadget->type == GADGET_CHECKBOX || + box->gadget->type == GADGET_RADIO)) { wimp_icon icon; - LOG(("writing GADGET")); icon.extent.x0 = -gadget_subtract_x + x; icon.extent.y0 = -gadget_subtract_y + y - height; @@ -138,28 +137,6 @@ void html_redraw_box(struct content *content, struct box * box, icon.extent.y1 = -gadget_subtract_y + y; switch (box->gadget->type) { - case GADGET_TEXTBOX: - colourtrans_set_font_colours(box->font->handle, current_background_color << 8, - box->style->color << 8, 14, 0, 0, 0); - font_paint(box->font->handle, box->gadget->data.textbox.text, - font_OS_UNITS | font_GIVEN_FONT | font_KERN, - x, y - (int) (box->height * 1.5), - NULL, NULL, 0); - 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_SELECT: icon.flags = wimp_ICON_TEXT | wimp_ICON_BORDER | wimp_ICON_VCENTRED | wimp_ICON_FILLED | @@ -242,12 +219,7 @@ void html_redraw_box(struct content *content, struct box * box, LOG(("writing GADGET RADIO")); wimp_plot_icon(&icon); break; - - case GADGET_HIDDEN: - case GADGET_IMAGE: - break; } - LOG(("gadgets finished")); } else if (box->text && box->font) { |