From 25a995931da1be77df132f7355218e86b0d0c00d Mon Sep 17 00:00:00 2001 From: Richard Wilson Date: Sat, 4 Mar 2006 20:46:35 +0000 Subject: [project @ 2006-03-04 20:46:35 by rjw] Continue work towards favicon support. svn path=/import/netsurf/; revision=2104 --- !NetSurf/Resources/de/Messages | 6 +- !NetSurf/Resources/en/Messages | 6 +- !NetSurf/Resources/fr/Messages | 6 +- !NetSurf/Resources/nl/Messages | 6 +- content/url_store.c | 8 +- content/url_store.h | 2 +- desktop/browser.c | 2 +- riscos/gui.h | 30 ------- riscos/theme.c | 192 ++++++++++++++++++++++++++++++----------- riscos/theme.h | 33 +++++++ riscos/url_complete.c | 56 ++++++++---- riscos/wimp.h | 1 - riscos/window.c | 2 + 13 files changed, 233 insertions(+), 117 deletions(-) diff --git a/!NetSurf/Resources/de/Messages b/!NetSurf/Resources/de/Messages index 3a96920d1..9b8d0f5e2 100644 --- a/!NetSurf/Resources/de/Messages +++ b/!NetSurf/Resources/de/Messages @@ -525,9 +525,9 @@ HelpToolbar7:Drucken der aktuellen Seite.|MAnklicken öffnet den 'Drucken' Dialo HelpToolbar8:Das ist der Hotlist Schaltknopf.|MKlicken mit AUSWAHL öffnet die Hotlist.|MKlicken mit SPEZIAL trägt die aktuelle Seite in die Hotlist ein. HelpToolbar9:Anklicken öffnet den Vergrößerungs-Dialog.|MDie Vergrößerung betrifft Text und Bilder. HelpToolbar10:Anklicken öffnet das Fenster zur Textsuche. -HelpToolbar11:Das ist die Adressleiste.|MHier die Adresse (URL) eingeben und Entertaste drücken, um eine neue Seite zu laden. -HelpToolbar12:Das ist die Ladeaktivitätsanzeige.|MSie wird animiert, wenn NetSurf aktiv ist. -HelpToolbar13:Das ist das URL-Schnellwahl Symbol.|MKlicken mit AUSWAHL öffnet eine Liste der zuletzt eingegebenen Web-Adressen. +HelpToolbar13:Das ist die Adressleiste.|MHier die Adresse (URL) eingeben und Entertaste drücken, um eine neue Seite zu laden. +HelpToolbar14:Das ist die Ladeaktivitätsanzeige.|MSie wird animiert, wenn NetSurf aktiv ist. +HelpToolbar15:Das ist das URL-Schnellwahl Symbol.|MKlicken mit AUSWAHL öffnet eine Liste der zuletzt eingegebenen Web-Adressen. HelpStatus0:Das ist die Begrenzung der Statusanzeige.|MKlicken und Ziehen verändert die Länge der Statusanzeige. HelpStatus1:Das ist die Statusanzeige|MSie zeigt an, was gerade im Browserfenster geschieht. diff --git a/!NetSurf/Resources/en/Messages b/!NetSurf/Resources/en/Messages index ee17b8321..8b8fba880 100644 --- a/!NetSurf/Resources/en/Messages +++ b/!NetSurf/Resources/en/Messages @@ -524,9 +524,9 @@ HelpToolbar7:\Tprint button.|M\Sopen the print dialogue box. HelpToolbar8:\Thotlist button.|M\Sopen the hotlist management \w.|M\Aadd this address to the hotlist. HelpToolbar9:\Tscale view button.|M\Sscale the page, affecting both text and images. HelpToolbar10:\Tsearch button.|M\Sfind instances of a string of text on the page. -HelpToolbar11:\TURL bar.|MType in the address of a site to visit and press Return to go there. -HelpToolbar12:\Tthrobber.|MIt animates while this \w is active. -HelpToolbar13:\TURL suggestion icon.|M\Sopen a list of recently typed URLs. +HelpToolbar13:\TURL bar.|MType in the address of a site to visit and press Return to go there. +HelpToolbar14:\Tthrobber.|MIt animates while this \w is active. +HelpToolbar15:\TURL suggestion icon.|M\Sopen a list of recently typed URLs. HelpStatus0:\Tstatus bar resizer.|MDrag to alter the size of the status bar. HelpStatus1:\Tstatus bar.|MIt displays information on what the browser \w is doing. diff --git a/!NetSurf/Resources/fr/Messages b/!NetSurf/Resources/fr/Messages index 9960d3b96..4f8ece132 100644 --- a/!NetSurf/Resources/fr/Messages +++ b/!NetSurf/Resources/fr/Messages @@ -525,9 +525,9 @@ HelpToolbar7:\Tle bouton d'impression.|M\Simprimer cette page.|MOuvre une bo HelpToolbar8:\Tle bouton de favoris.|M\Souvrir la \w de gestion des favoris.|M\Aajouter cette adresse aux favoris. HelpToolbar9:\Tle bouton de changement d'échelle.|M\Sredimensionner la page, texte et images comprises. HelpToolbar10:\Tle bouton de recherche.|M\Sfind instances of a string of text on the page. -HelpToolbar11:\Tla barre d'URL.|MTapez l'adresse d'un site à visiter et appuyez sur Return pour y aller. -HelpToolbar12:\Tle pulseur.|MIl s'anime lorsque cette \w est active. -HelpToolbar13:\Tl'icône de suggestion d'URL.|M\Souvrir une liste d'URLs tapées récemment. +HelpToolbar13:\Tla barre d'URL.|MTapez l'adresse d'un site à visiter et appuyez sur Return pour y aller. +HelpToolbar14:\Tle pulseur.|MIl s'anime lorsque cette \w est active. +HelpToolbar15:\Tl'icône de suggestion d'URL.|M\Souvrir une liste d'URLs tapées récemment. HelpStatus0:\Tla glissière de la barre d'état.|MDéplacez-la pour changer la taille de la barre d'état. HelpStatus1:\Tla barre d'état.|MElle affiche des informations sur ce que fait la \w de navigateur. diff --git a/!NetSurf/Resources/nl/Messages b/!NetSurf/Resources/nl/Messages index 23b4db27a..bdcf72761 100644 --- a/!NetSurf/Resources/nl/Messages +++ b/!NetSurf/Resources/nl/Messages @@ -527,9 +527,9 @@ HelpToolbar7:\Tprint button.|M\Sopen the print dialogue box. HelpToolbar8:\Thotlist button.|M\Sopen the hotlist management \w.|M\Aadd this address to the hotlist. HelpToolbar9:\Tscale view button.|M\Sscale the page, affecting both text and images. HelpToolbar10:\Tsearch button.|M\Sfind instances of a string of text on the page. -HelpToolbar11:\TURL bar.|MType in the address of a site to visit and press Return to go there. -HelpToolbar12:\Tthrobber.|MIt animates while this \w is active. -HelpToolbar13:\TURL suggestion icon.|M\Sopen a list of recently typed URLs. +HelpToolbar13:\TURL bar.|MType in the address of a site to visit and press Return to go there. +HelpToolbar14:\Tthrobber.|MIt animates while this \w is active. +HelpToolbar15:\TURL suggestion icon.|M\Sopen a list of recently typed URLs. HelpStatus0:\Tstatus bar resizer.|MDrag to alter the size of the status bar. HelpStatus1:\Tstatus bar.|MIt displays information on what the browser \w is doing. diff --git a/content/url_store.c b/content/url_store.c index 02ecaf6c9..fde956e46 100644 --- a/content/url_store.c +++ b/content/url_store.c @@ -356,7 +356,7 @@ struct hostname_data *url_store_match_hostname( * \param reference internal reference (NULL for first call) * \return the next URL that matches */ -char *url_store_match(const char *url, struct url_data **reference) { +struct url_content *url_store_match(const char *url, struct url_data **reference) { struct hostname_data *hostname; struct url_data *search = NULL; url_func_result res; @@ -404,7 +404,7 @@ char *url_store_match(const char *url, struct url_data **reference) { hostname = url_store_match_hostname(NULL); if (!hostname) return NULL; - } else { + } else { search = *reference; hostname = search->parent; } @@ -429,7 +429,7 @@ char *url_store_match(const char *url, struct url_data **reference) { (!strncmp(search->data.url, url, current_match_url_length))) { *reference = search; - return search->data.url; + return &search->data; } /* try with 'www.' inserted after the scheme */ if (current_match_www_test && @@ -448,7 +448,7 @@ char *url_store_match(const char *url, struct url_data **reference) { current_match_url_length - current_match_scheme_length - 3))) { *reference = search; - return search->data.url; + return &search->data; } } } diff --git a/content/url_store.h b/content/url_store.h index afd121680..c10bc90d0 100644 --- a/content/url_store.h +++ b/content/url_store.h @@ -47,7 +47,7 @@ struct url_data { extern struct hostname_data *url_store_hostnames; struct url_content *url_store_find(const char *url); -char *url_store_match(const char *url, struct url_data **reference); +struct url_content *url_store_match(const char *url, struct url_data **reference); char *url_store_match_string(const char *text); void url_store_add_thumbnail(const char *url, struct bitmap *bitmap); diff --git a/desktop/browser.c b/desktop/browser.c index eb354d047..85f90a74b 100644 --- a/desktop/browser.c +++ b/desktop/browser.c @@ -121,7 +121,6 @@ void browser_window_create(const char *url, struct browser_window *clone, free(bw); return; } - gui_window_set_url(bw->window, url); browser_window_go(bw, url, referer); } @@ -187,6 +186,7 @@ void browser_window_go_post(struct browser_window *bw, const char *url, free(url2); return; } + gui_window_set_url(bw->window, url2); /* find any fragment identifier on end of URL */ hash = strchr(url2, '#'); diff --git a/riscos/gui.h b/riscos/gui.h index e4d70bca3..c6266bc9a 100644 --- a/riscos/gui.h +++ b/riscos/gui.h @@ -217,36 +217,6 @@ void ro_plot_set_scale(float scale); /* in theme_install.c */ bool ro_gui_theme_install_apply(wimp_w w); -/* icon numbers for browser toolbars */ -#define ICON_TOOLBAR_BACK 0 -#define ICON_TOOLBAR_FORWARD 1 -#define ICON_TOOLBAR_STOP 2 -#define ICON_TOOLBAR_RELOAD 3 -#define ICON_TOOLBAR_HOME 4 -#define ICON_TOOLBAR_HISTORY 5 -#define ICON_TOOLBAR_SAVE 6 -#define ICON_TOOLBAR_PRINT 7 -#define ICON_TOOLBAR_BOOKMARK 8 -#define ICON_TOOLBAR_SCALE 9 -#define ICON_TOOLBAR_SEARCH 10 -#define ICON_TOOLBAR_URL 11 // Must be after highest toolbar icon -#define ICON_TOOLBAR_THROBBER 12 -#define ICON_TOOLBAR_SUGGEST 13 - -/* icon numbers for hotlist/history toolbars */ -#define ICON_TOOLBAR_DELETE 0 -#define ICON_TOOLBAR_EXPAND 1 -#define ICON_TOOLBAR_OPEN 2 -#define ICON_TOOLBAR_LAUNCH 3 -#define ICON_TOOLBAR_HISTORY_LAST 4 -#define ICON_TOOLBAR_CREATE 4 // must be after last history icon -#define ICON_TOOLBAR_HOTLIST_LAST 5 - -/* editing toolbar separator number */ -#define ICON_TOOLBAR_SEPARATOR_BROWSER 11 -#define ICON_TOOLBAR_SEPARATOR_HOTLIST 5 -#define ICON_TOOLBAR_SEPARATOR_HISTORY 4 - /* icon numbers for toolbar status window */ #define ICON_STATUS_RESIZE 0 #define ICON_STATUS_TEXT 1 diff --git a/riscos/theme.c b/riscos/theme.c index fb980a8e4..88871744a 100644 --- a/riscos/theme.c +++ b/riscos/theme.c @@ -112,6 +112,7 @@ static char theme_url_validation[] = "Pptr_write;KN\0"; static char theme_resize_validation[] = "R1;Pptr_lr,8,6\0"; static char theme_null_text_string[] = "\0"; static char theme_separator_name[] = "separator\0"; +static char theme_favicon_sprite[12]; /** @@ -609,6 +610,7 @@ void ro_gui_theme_close(struct theme_descriptor *descriptor, bool list) { */ void ro_gui_theme_redraw(wimp_draw *redraw) { struct toolbar *toolbar; + struct gui_window *g; struct toolbar_icon *icon; osbool more; @@ -619,6 +621,20 @@ void ro_gui_theme_redraw(wimp_draw *redraw) { toolbar = (struct toolbar *)ro_gui_wimp_event_get_user_data(redraw->w); assert(toolbar); + + /* set the content-type icon */ + g = ro_gui_toolbar_lookup(toolbar->toolbar_handle); + assert(g); + assert(g->bw); + if (g->bw->current_content) { + sprintf(theme_favicon_sprite, "Ssmall_%.3x", + ro_content_filetype_from_type( + g->bw->current_content->type)); + if (!ro_gui_wimp_sprite_exists(theme_favicon_sprite + 1)) + sprintf(theme_favicon_sprite, "Ssmall_xxx"); + } else { + sprintf(theme_favicon_sprite, "Ssmall_xxx"); + } /* set up the icon */ if ((toolbar->descriptor) && (toolbar->descriptor->theme) && @@ -911,7 +927,7 @@ bool ro_gui_theme_update_toolbar(struct theme_descriptor *descriptor, (toolbar->type == THEME_HISTORY_EDIT_TOOLBAR)) max_icon = ICON_TOOLBAR_HISTORY_LAST; else - max_icon = ICON_TOOLBAR_URL; + max_icon = ICON_TOOLBAR_LAST; new_icon.w = toolbar->toolbar_handle; new_icon.icon.data.indirected_text.size = 1; new_icon.icon.flags = wimp_ICON_TEXT | wimp_ICON_SPRITE | @@ -961,16 +977,27 @@ bool ro_gui_theme_update_toolbar(struct theme_descriptor *descriptor, /* Create the URL/throbber icons */ if (toolbar->type == THEME_BROWSER_TOOLBAR) { - new_icon.icon.flags = wimp_ICON_TEXT | wimp_ICON_INDIRECTED | - wimp_ICON_VCENTRED | wimp_ICON_BORDER | - wimp_ICON_FILLED | (wimp_COLOUR_BLACK << - wimp_ICON_FG_COLOUR_SHIFT) | - (wimp_BUTTON_WRITE_CLICK_DRAG << + /* container for all URL bits (ie border) */ + new_icon.icon.flags = wimp_ICON_BORDER | (wimp_COLOUR_BLACK << + wimp_ICON_FG_COLOUR_SHIFT); + error = xwimp_create_icon(&new_icon, 0); + if (error) { + LOG(("xwimp_create_icon: 0x%x: %s", + error->errnum, error->errmess)); + warn_user("WimpError", error->errmess); + return false; + } + + /* favicon image */ + new_icon.icon.flags = wimp_ICON_TEXT | wimp_ICON_SPRITE | + wimp_ICON_INDIRECTED | wimp_ICON_FILLED | + wimp_ICON_HCENTRED | wimp_ICON_VCENTRED | + (wimp_BUTTON_CLICK_DRAG << wimp_ICON_BUTTON_TYPE_SHIFT); - new_icon.icon.data.indirected_text.text = toolbar->url_buffer; + new_icon.icon.data.indirected_text.text = theme_null_text_string; new_icon.icon.data.indirected_text.validation = - theme_url_validation; - new_icon.icon.data.indirected_text.size = THEME_URL_MEMORY; + theme_favicon_sprite; + new_icon.icon.data.indirected_text.size = 1; error = xwimp_create_icon(&new_icon, 0); if (error) { LOG(("xwimp_create_icon: 0x%x: %s", @@ -979,15 +1006,17 @@ bool ro_gui_theme_update_toolbar(struct theme_descriptor *descriptor, return false; } - /* Now the throbber - */ - new_icon.icon.flags = wimp_ICON_SPRITE | wimp_ICON_INDIRECTED | - wimp_ICON_HCENTRED | wimp_ICON_VCENTRED; - new_icon.icon.data.indirected_sprite.id = - (osspriteop_id)toolbar->throbber_buffer; - new_icon.icon.data.indirected_sprite.area = sprite_area; - new_icon.icon.data.indirected_sprite.size = - THEME_THROBBER_MEMORY; + /* Writable text portion */ + new_icon.icon.flags = wimp_ICON_TEXT | wimp_ICON_INDIRECTED | + wimp_ICON_VCENTRED | + wimp_ICON_FILLED | (wimp_COLOUR_BLACK << + wimp_ICON_FG_COLOUR_SHIFT) | + (wimp_BUTTON_WRITE_CLICK_DRAG << + wimp_ICON_BUTTON_TYPE_SHIFT); + new_icon.icon.data.indirected_text.text = toolbar->url_buffer; + new_icon.icon.data.indirected_text.validation = + theme_url_validation; + new_icon.icon.data.indirected_text.size = THEME_URL_MEMORY; error = xwimp_create_icon(&new_icon, 0); if (error) { LOG(("xwimp_create_icon: 0x%x: %s", @@ -1016,10 +1045,26 @@ bool ro_gui_theme_update_toolbar(struct theme_descriptor *descriptor, warn_user("WimpError", error->errmess); return false; } + + /* Now the throbber + */ + new_icon.icon.flags = wimp_ICON_SPRITE | wimp_ICON_INDIRECTED | + wimp_ICON_HCENTRED | wimp_ICON_VCENTRED; + new_icon.icon.data.indirected_sprite.id = + (osspriteop_id)toolbar->throbber_buffer; + new_icon.icon.data.indirected_sprite.area = sprite_area; + new_icon.icon.data.indirected_sprite.size = + THEME_THROBBER_MEMORY; + error = xwimp_create_icon(&new_icon, 0); + if (error) { + LOG(("xwimp_create_icon: 0x%x: %s", + error->errnum, error->errmess)); + warn_user("WimpError", error->errmess); + return false; + } } - if (toolbar->parent_handle) { + if (toolbar->parent_handle) ro_gui_theme_attach_toolbar(toolbar, toolbar->parent_handle); - } /* Recreate the status window */ @@ -1301,6 +1346,14 @@ bool ro_gui_theme_process_toolbar(struct toolbar *toolbar, int width) { struct toolbar_icon *toolbar_icon; bool visible_icon = false; int collapse_height; + int xeig, yeig; + os_coord pixel = {1, 1}; + int top, bottom, right; + + /* calculate 1px in OS units */ + ro_convert_pixels_to_os_units(&pixel, (os_mode)-1); + xeig = pixel.x; + yeig = pixel.y; /* find the parent window handle if we need to process the status * window, or the caller has requested we calculate the width ourself */ @@ -1335,8 +1388,8 @@ bool ro_gui_theme_process_toolbar(struct toolbar *toolbar, int width) { height = state.visible.y1 - state.visible.y0 + 2; - /* We can't obscure the height of the scroll bar as we lose the resize - icon if we do. + /* We can't obscure the height of the scroll bar as we + lose the resize icon if we do. */ if ((state.flags & wimp_WINDOW_SIZE_ICON) && !(state.flags & wimp_WINDOW_HSCROLL)) @@ -1380,7 +1433,8 @@ bool ro_gui_theme_process_toolbar(struct toolbar *toolbar, int width) { if ((toolbar->type == THEME_BROWSER_TOOLBAR) && (toolbar->display_url)) { if (toolbar->height < 52 + 8) toolbar->height = 52 + 8; - if ((toolbar->suggest) && (toolbar->height < (toolbar->suggest->height + 8))) + if ((toolbar->suggest) && (toolbar->height < + (toolbar->suggest->height + 8))) toolbar->height = toolbar->suggest->height + 8; } @@ -1409,7 +1463,7 @@ bool ro_gui_theme_process_toolbar(struct toolbar *toolbar, int width) { if (toolbar->type == THEME_BROWSER_TOOLBAR) { if (!toolbar->reformat_buttons) left_edge = bottom_edge; if (toolbar->display_url) { - bottom_edge += 64; + bottom_edge += 112; if (toolbar->suggest) bottom_edge += toolbar->suggest->width + 8; } @@ -1420,7 +1474,8 @@ bool ro_gui_theme_process_toolbar(struct toolbar *toolbar, int width) { (toolbar->descriptor->throbber_right)) { bottom_edge += toolbar->descriptor->theme->throbber_width; if (bottom_edge > right_edge) right_edge = bottom_edge; - throbber_x = right_edge - toolbar->descriptor->theme->throbber_width; + throbber_x = right_edge - + toolbar->descriptor->theme->throbber_width; right_edge -= toolbar->descriptor->theme->throbber_width + 8; } } @@ -1430,12 +1485,14 @@ bool ro_gui_theme_process_toolbar(struct toolbar *toolbar, int width) { if (toolbar->reformat_buttons) { /* Hide the URL bar if we should */ - if ((!toolbar->display_url) && (toolbar->type == THEME_BROWSER_TOOLBAR)) { + if ((!toolbar->display_url) && + (toolbar->type == THEME_BROWSER_TOOLBAR)) { if (!xwimp_get_caret_position(&caret)) { if ((caret.w == toolbar->toolbar_handle) && (caret.i == ICON_TOOLBAR_URL)) { if (toolbar->parent_handle) - xwimp_set_caret_position(toolbar->parent_handle, + xwimp_set_caret_position( + toolbar->parent_handle, wimp_ICON_WINDOW, -100, -100, 32, -1); else @@ -1443,16 +1500,20 @@ bool ro_gui_theme_process_toolbar(struct toolbar *toolbar, int width) { 0, 0, 0, 0, 0); } } + xwimp_resize_icon(toolbar->toolbar_handle, ICON_TOOLBAR_SURROUND, + 0, -16384, 0, -16384); + xwimp_resize_icon(toolbar->toolbar_handle, ICON_TOOLBAR_FAVICON, + 0, -16384, 0, -16384); xwimp_resize_icon(toolbar->toolbar_handle, ICON_TOOLBAR_URL, - 0, -16384, 0, -16384); + 0, -16384, 0, -16384); xwimp_resize_icon(toolbar->toolbar_handle, ICON_TOOLBAR_SUGGEST, - 0, -16384, 0, -16384); + 0, -16384, 0, -16384); } else if (toolbar->type == THEME_BROWSER_TOOLBAR) { - ro_gui_set_icon_shaded_state(toolbar->toolbar_handle, ICON_TOOLBAR_URL, - !toolbar->display_url); + ro_gui_set_icon_shaded_state(toolbar->toolbar_handle, + ICON_TOOLBAR_URL, !toolbar->display_url); } xwimp_force_redraw(toolbar->toolbar_handle, - 0, 0, 16384, 16384); + 0, 0, 16384, 16384); /* Move the buttons */ @@ -1487,26 +1548,46 @@ bool ro_gui_theme_process_toolbar(struct toolbar *toolbar, int width) { /* Move the URL bar */ if (toolbar->display_url) { + top = (toolbar->height / 2) + 26; + bottom = (toolbar->height / 2) - 26; if (toolbar->suggest) { - xwimp_resize_icon(toolbar->toolbar_handle, ICON_TOOLBAR_URL, - left_edge, (toolbar->height / 2) - 26, - right_edge - toolbar->suggest->width - 8, - (toolbar->height / 2) + 26); - xwimp_resize_icon(toolbar->toolbar_handle, ICON_TOOLBAR_SUGGEST, + right = right_edge - toolbar->suggest->width - 8; + xwimp_resize_icon(toolbar->toolbar_handle, + ICON_TOOLBAR_SUGGEST, right_edge - toolbar->suggest->width, (toolbar->height - toolbar->suggest->height) / 2, right_edge, (toolbar->height + toolbar->suggest->height) / 2); - xwimp_force_redraw(toolbar->toolbar_handle, - right_edge - toolbar->suggest->width - 8, 0, - 16384, 16384); } else { - xwimp_resize_icon(toolbar->toolbar_handle, ICON_TOOLBAR_URL, - left_edge, (toolbar->height / 2) - 26, - right_edge, (toolbar->height / 2) + 26); - xwimp_force_redraw(toolbar->toolbar_handle, - right_edge, 0, 16384, 16384); + right = right_edge; } + xwimp_resize_icon(toolbar->toolbar_handle, ICON_TOOLBAR_URL, + left_edge + 52, + bottom + yeig, + right - xeig, + top - yeig); + xwimp_resize_icon(toolbar->toolbar_handle, ICON_TOOLBAR_FAVICON, + left_edge + xeig, + bottom + yeig, + left_edge + 52, + top - yeig); + xwimp_resize_icon(toolbar->toolbar_handle, ICON_TOOLBAR_SURROUND, + left_edge, + bottom, + right, + top); + xwimp_force_redraw(toolbar->toolbar_handle, + right - xeig, 0, 16384, 16384); + xwimp_force_redraw(toolbar->toolbar_handle, + left_edge, + bottom, + right, + bottom + yeig); + xwimp_force_redraw(toolbar->toolbar_handle, + left_edge, + top - yeig, + right, + top); if (!xwimp_get_caret_position(&caret)) { if ((caret.w == toolbar->toolbar_handle) && (caret.i == ICON_TOOLBAR_URL)) { @@ -1764,15 +1845,18 @@ void ro_gui_theme_toggle_edit(struct toolbar *toolbar) { /* create/initialise the toolbar editor */ switch (toolbar->type) { case THEME_BROWSER_TOOLBAR: - toolbar->editor = ro_gui_theme_create_toolbar(toolbar->descriptor, + toolbar->editor = ro_gui_theme_create_toolbar( + toolbar->descriptor, THEME_BROWSER_EDIT_TOOLBAR); break; case THEME_HOTLIST_TOOLBAR: - toolbar->editor = ro_gui_theme_create_toolbar(toolbar->descriptor, + toolbar->editor = ro_gui_theme_create_toolbar( + toolbar->descriptor, THEME_HOTLIST_EDIT_TOOLBAR); break; case THEME_HISTORY_TOOLBAR: - toolbar->editor = ro_gui_theme_create_toolbar(toolbar->descriptor, + toolbar->editor = ro_gui_theme_create_toolbar( + toolbar->descriptor, THEME_HISTORY_EDIT_TOOLBAR); break; default: @@ -1788,7 +1872,8 @@ void ro_gui_theme_toggle_edit(struct toolbar *toolbar) { switch (toolbar->type) { case THEME_BROWSER_TOOLBAR: if (g) - ro_gui_window_update_dimensions(g, -toolbar->editor->height); + ro_gui_window_update_dimensions(g, + -toolbar->editor->height); break; default: if (toolbar->parent_handle) { @@ -1830,8 +1915,10 @@ void ro_gui_theme_toolbar_editor_sync(struct toolbar *toolbar) { for (icon_edit = toolbar->editor->icon; icon_edit; icon_edit = icon_edit->next) if (icon_edit->icon_number == icon->icon_number) - ro_gui_set_icon_shaded_state(toolbar->editor->toolbar_handle, - icon_edit->icon_number, icon->display); + ro_gui_set_icon_shaded_state( + toolbar->editor->toolbar_handle, + icon_edit->icon_number, + icon->display); } @@ -2278,7 +2365,8 @@ void ro_gui_theme_add_toolbar_icons(struct toolbar *toolbar, */ void ro_gui_theme_set_help_prefix(struct toolbar *toolbar) { if (toolbar->editor) { - ro_gui_wimp_event_set_help_prefix(toolbar->toolbar_handle, "HelpEditToolbar"); + ro_gui_wimp_event_set_help_prefix(toolbar->toolbar_handle, + "HelpEditToolbar"); return; } switch (toolbar->type) { diff --git a/riscos/theme.h b/riscos/theme.h index 4c21d0296..bd6a4783c 100644 --- a/riscos/theme.h +++ b/riscos/theme.h @@ -14,6 +14,39 @@ #ifndef _NETSURF_RISCOS_THEME_H_ #define _NETSURF_RISCOS_THEME_H_ +/* icon numbers for browser toolbars */ +#define ICON_TOOLBAR_BACK 0 +#define ICON_TOOLBAR_FORWARD 1 +#define ICON_TOOLBAR_STOP 2 +#define ICON_TOOLBAR_RELOAD 3 +#define ICON_TOOLBAR_HOME 4 +#define ICON_TOOLBAR_HISTORY 5 +#define ICON_TOOLBAR_SAVE 6 +#define ICON_TOOLBAR_PRINT 7 +#define ICON_TOOLBAR_BOOKMARK 8 +#define ICON_TOOLBAR_SCALE 9 +#define ICON_TOOLBAR_SEARCH 10 +#define ICON_TOOLBAR_LAST 11 +#define ICON_TOOLBAR_SURROUND 11 // Must be after highest toolbar icon +#define ICON_TOOLBAR_FAVICON 12 +#define ICON_TOOLBAR_URL 13 +#define ICON_TOOLBAR_SUGGEST 14 +#define ICON_TOOLBAR_THROBBER 15 + +/* icon numbers for hotlist/history toolbars */ +#define ICON_TOOLBAR_DELETE 0 +#define ICON_TOOLBAR_EXPAND 1 +#define ICON_TOOLBAR_OPEN 2 +#define ICON_TOOLBAR_LAUNCH 3 +#define ICON_TOOLBAR_HISTORY_LAST 4 +#define ICON_TOOLBAR_CREATE 4 // must be after last history icon +#define ICON_TOOLBAR_HOTLIST_LAST 5 + +/* editing toolbar separator number */ +#define ICON_TOOLBAR_SEPARATOR_BROWSER 11 +#define ICON_TOOLBAR_SEPARATOR_HOTLIST 5 +#define ICON_TOOLBAR_SEPARATOR_HISTORY 4 + typedef enum { THEME_BROWSER_TOOLBAR, THEME_HOTLIST_TOOLBAR, diff --git a/riscos/url_complete.c b/riscos/url_complete.c index 0e0e360ce..88b2ad8e5 100644 --- a/riscos/url_complete.c +++ b/riscos/url_complete.c @@ -27,7 +27,7 @@ #define MAXIMUM_VISIBLE_LINES 7 -static char **url_complete_matches = NULL; +static struct url_content **url_complete_matches = NULL; static int url_complete_matches_allocated = 0; static int url_complete_matches_available = 0; static char *url_complete_matched_string = NULL; @@ -37,9 +37,11 @@ static wimp_w url_complete_parent = 0; static bool url_complete_matches_reset = false; static char *url_complete_original_url = NULL; -static char *url_complete_redraw[MAXIMUM_VISIBLE_LINES]; +static struct url_content *url_complete_redraw[MAXIMUM_VISIBLE_LINES]; static char url_complete_icon_null[] = "\0"; +static char url_complete_icon_sprite[12]; static wimp_icon url_complete_icon; +static wimp_icon url_complete_sprite; static int mouse_x; static int mouse_y; @@ -71,11 +73,11 @@ void ro_gui_url_complete_start(struct gui_window *g) { */ bool ro_gui_url_complete_keypress(struct gui_window *g, int key) { wimp_window_state state; - char **array_extend; + struct url_content **array_extend; struct url_data *reference = NULL; char *match_url; char *url; - char *output; + struct url_content *output; int i, lines; int old_selection; bool ignore_changes = false; @@ -119,7 +121,7 @@ bool ro_gui_url_complete_keypress(struct gui_window *g, int key) { /* check if we should ignore text changes */ if ((url_complete_keypress_selection >= 0) && (url_complete_matches)) ignore_changes = !strcmp(url, - url_complete_matches[url_complete_keypress_selection]); + url_complete_matches[url_complete_keypress_selection]->url); /* if the text to match has changed then update it */ if (!ignore_changes && ((!url_complete_matched_string) || @@ -168,9 +170,10 @@ bool ro_gui_url_complete_keypress(struct gui_window *g, int key) { if (url_complete_matches_available > url_complete_matches_allocated) { - array_extend = realloc(url_complete_matches, + array_extend = (struct url_content **)realloc( + url_complete_matches, (url_complete_matches_allocated + 64) * - sizeof(char *)); + sizeof(struct url_content *)); if (!array_extend) { ro_gui_url_complete_close(NULL, 0); return false; @@ -276,7 +279,7 @@ bool ro_gui_url_complete_keypress(struct gui_window *g, int key) { } else { ro_gui_set_icon_string(g->toolbar->toolbar_handle, ICON_TOOLBAR_URL, - url_complete_matches[url_complete_matches_selection]); + url_complete_matches[url_complete_matches_selection]->url); } url_complete_keypress_selection = url_complete_matches_selection; @@ -355,7 +358,7 @@ void ro_gui_url_complete_resize(struct gui_window *g, wimp_open *open) { return; } url_state.w = g->toolbar->toolbar_handle; - url_state.i = ICON_TOOLBAR_URL; + url_state.i = ICON_TOOLBAR_SURROUND; error = xwimp_get_icon_state(&url_state); if (error) { LOG(("xwimp_get_window_state: 0x%x: %s", @@ -463,9 +466,17 @@ void ro_gui_url_complete_redraw(wimp_draw *redraw) { wimp_ICON_TEXT | wimp_ICON_FILLED | (wimp_COLOUR_BLACK << wimp_ICON_FG_COLOUR_SHIFT) | (wimp_COLOUR_WHITE << wimp_ICON_BG_COLOUR_SHIFT); - url_complete_icon.extent.x0 = 0; + url_complete_icon.extent.x0 = 50; url_complete_icon.extent.x1 = 16384; url_complete_icon.data.indirected_text.validation = url_complete_icon_null; + url_complete_sprite.flags = wimp_ICON_TEXT | wimp_ICON_SPRITE | + wimp_ICON_INDIRECTED | wimp_ICON_FILLED | + wimp_ICON_HCENTRED | wimp_ICON_VCENTRED; + url_complete_sprite.extent.x0 = 0; + url_complete_sprite.extent.x1 = 50; + url_complete_sprite.data.indirected_text.text = url_complete_icon_null; + url_complete_sprite.data.indirected_text.validation = url_complete_icon_sprite; + url_complete_sprite.data.indirected_text.size = 1; /* no matches? no redraw */ if (!url_complete_matches) { @@ -492,15 +503,28 @@ void ro_gui_url_complete_redraw(wimp_draw *redraw) { url_complete_icon.extent.y1 = -line * 44; url_complete_icon.extent.y0 = -(line + 1) * 44; url_complete_icon.data.indirected_text.text = - url_complete_matches[line]; + url_complete_matches[line]->url; url_complete_icon.data.indirected_text.size = - strlen(url_complete_matches[line]); + strlen(url_complete_matches[line]->url); error = xwimp_plot_icon(&url_complete_icon); if (error) { LOG(("xwimp_plot_icon: 0x%x: %s", error->errnum, error->errmess)); warn_user("WimpError", error->errmess); } + sprintf(url_complete_icon_sprite, "Ssmall_%.3x", + ro_content_filetype_from_type( + url_complete_matches[line]->type)); + if (!ro_gui_wimp_sprite_exists(url_complete_icon_sprite + 1)) + sprintf(url_complete_icon_sprite, "Ssmall_xxx"); + url_complete_sprite.extent.y1 = -line * 44; + url_complete_sprite.extent.y0 = -(line + 1) * 44; + error = xwimp_plot_icon(&url_complete_sprite); + if (error) { + LOG(("xwimp_plot_icon: 0x%x: %s", + error->errnum, error->errmess)); + warn_user("WimpError", error->errmess); + } } more = wimp_get_rectangle(redraw); } @@ -593,18 +617,18 @@ bool ro_gui_url_complete_click(wimp_pointer *pointer) { if (pointer->buttons == wimp_CLICK_SELECT) { ro_gui_set_icon_string(g->toolbar->toolbar_handle, ICON_TOOLBAR_URL, - url_complete_matches[url_complete_matches_selection]); + url_complete_matches[url_complete_matches_selection]->url); browser_window_go(g->bw, - url_complete_matches[url_complete_matches_selection], + url_complete_matches[url_complete_matches_selection]->url, 0); - global_history_add_recent(url_complete_matches[url_complete_matches_selection]); + global_history_add_recent(url_complete_matches[url_complete_matches_selection]->url); ro_gui_url_complete_close(NULL, 0); /* Adjust just sets the text */ } else if (pointer->buttons == wimp_CLICK_ADJUST) { ro_gui_set_icon_string(g->toolbar->toolbar_handle, ICON_TOOLBAR_URL, - url_complete_matches[url_complete_matches_selection]); + url_complete_matches[url_complete_matches_selection]->url); ro_gui_url_complete_keypress(g, 0); } return true; diff --git a/riscos/wimp.h b/riscos/wimp.h index a7777d28d..f63357551 100644 --- a/riscos/wimp.h +++ b/riscos/wimp.h @@ -23,7 +23,6 @@ int ro_get_hscroll_height(wimp_w w); int ro_get_vscroll_width(wimp_w w); -struct eig_factors ro_read_eig_factors(os_mode mode); void ro_convert_os_units_to_pixels(os_coord *os_units, os_mode mode); void ro_convert_pixels_to_os_units(os_coord *pixels, os_mode mode); diff --git a/riscos/window.c b/riscos/window.c index 9ba7d02a4..c5af2fbb1 100644 --- a/riscos/window.c +++ b/riscos/window.c @@ -1020,6 +1020,8 @@ void gui_window_set_url(struct gui_window *g, const char *url) ro_gui_set_icon_string(g->toolbar->toolbar_handle, ICON_TOOLBAR_URL, url); + ro_gui_force_redraw_icon(g->toolbar->toolbar_handle, + ICON_TOOLBAR_FAVICON); /* if the caret is in the address bar, move it to the end */ error = xwimp_get_caret_position(&caret); -- cgit v1.2.3