From cfe6cd43dc6f83885f98bc14837bac195cb69eeb Mon Sep 17 00:00:00 2001 From: Richard Wilson Date: Wed, 7 Jul 2004 22:09:26 +0000 Subject: [project @ 2004-07-07 22:09:26 by rjw] Minor GUI fixes for hotlist. Hotlist toolbar. svn path=/import/netsurf/; revision=1054 --- !NetSurf/Resources/en/Messages | 19 +++- !NetSurf/Resources/en/Templates,fec | Bin 6489 -> 7203 bytes !NetSurf/Resources/fr/Messages | 15 ++- !NetSurf/Resources/fr/Templates,fec | Bin 6568 -> 7282 bytes !NetSurf/Themes/Default/Sprites,ff9 | Bin 53356 -> 63652 bytes riscos/gui.c | 4 +- riscos/gui.h | 18 ++- riscos/hotlist.c | 111 +++++++++++++++---- riscos/theme.c | 73 +++++++++---- riscos/theme.h | 7 +- riscos/toolbar.c | 211 ++++++++++++++++++++---------------- riscos/toolbar.h | 6 +- riscos/window.c | 6 +- 13 files changed, 320 insertions(+), 150 deletions(-) diff --git a/!NetSurf/Resources/en/Messages b/!NetSurf/Resources/en/Messages index 084285e0a..f43dcd8ef 100644 --- a/!NetSurf/Resources/en/Messages +++ b/!NetSurf/Resources/en/Messages @@ -57,8 +57,8 @@ WindowStagr:Stagger window position WindowSize:Maintain window size WindowReset:Reset default position Utilities:Utilities -HotlistAdd:Add page to hotlist -HotlistShow:Show hotlist F6 +HotlistAdd:Bookmark page +HotlistShow:Show bookmarks F6 Help:Help HelpContent:Contents F1 HelpGuide:User guide @@ -66,20 +66,29 @@ HelpInfo:User information HelpInter:Interactive help HelpAbout:About NetSurf -Hotlist:Hotlist +Themes:Themes + +# Hotlist menus +Hotlist:Bookmarks New:New Expand:Expand Collapse:Collapse All:All Folders:Folders -Links:Links +Folder:Folder +Links:Bookmarks +Link:Bookmark SaveSelect:Save Launch:Launch Edit:Edit Delete:Delete ResetUsage:Reset statistics -Themes:Themes +# Hotlist sub-window titles +NewLink:Create new bookmark +NewFolder:Create new folder +EditLink:Edit bookmark +EditFolder:Edit folder # Hotlist window HotlistURL:Address: %s diff --git a/!NetSurf/Resources/en/Templates,fec b/!NetSurf/Resources/en/Templates,fec index 798cc0475..54bfa5712 100644 Binary files a/!NetSurf/Resources/en/Templates,fec and b/!NetSurf/Resources/en/Templates,fec differ diff --git a/!NetSurf/Resources/fr/Messages b/!NetSurf/Resources/fr/Messages index bdd863138..a74c3a338 100644 --- a/!NetSurf/Resources/fr/Messages +++ b/!NetSurf/Resources/fr/Messages @@ -66,20 +66,29 @@ HelpInfo:Information utilisateur HelpInter:Aide interactive HelpAbout:À propos de NetSurf -Hotlist:Hotlist +Themes:Thèmes + +# Hotlist menus +Hotlist:Bookmarks New:New Expand:Expand Collapse:Collapse All:All Folders:Folders -Links:Links +Folder:Folder +Links:Bookmarks +Link:Bookmark SaveSelect:Save Launch:Launch Edit:Edit Delete:Delete ResetUsage:Reset statistics -Themes:Thèmes +# Hotlist sub-window titles +NewLink:Create new bookmark +NewFolder:Create new folder +EditLink:Edit bookmark +EditFolder:Edit folder # Hotlist window HotlistURL:Address: %s diff --git a/!NetSurf/Resources/fr/Templates,fec b/!NetSurf/Resources/fr/Templates,fec index e2e6efeff..5025b10e3 100644 Binary files a/!NetSurf/Resources/fr/Templates,fec and b/!NetSurf/Resources/fr/Templates,fec differ diff --git a/!NetSurf/Themes/Default/Sprites,ff9 b/!NetSurf/Themes/Default/Sprites,ff9 index 715c4461d..1c8947964 100644 Binary files a/!NetSurf/Themes/Default/Sprites,ff9 and b/!NetSurf/Themes/Default/Sprites,ff9 differ diff --git a/riscos/gui.c b/riscos/gui.c index 054defba7..28634412e 100644 --- a/riscos/gui.c +++ b/riscos/gui.c @@ -651,7 +651,7 @@ void ro_gui_open_window_request(wimp_open *open) toolbar = g->data.browser.toolbar; if (toolbar) { toolbar->resize_status = 1; - ro_theme_resize_toolbar(g); + ro_theme_resize_toolbar(g->data.browser.toolbar, g->window); } } } @@ -698,6 +698,8 @@ void ro_gui_mouse_click(wimp_pointer *pointer) else if (g && g->type == GUI_BROWSER_WINDOW && g->data.browser.toolbar->toolbar_handle == pointer->w) ro_gui_toolbar_click(g, pointer); + else if (hotlist_toolbar && hotlist_toolbar->toolbar_handle == pointer->w) + ro_gui_hotlist_toolbar_click(pointer); else if (g && g->type == GUI_BROWSER_WINDOW && g->data.browser.toolbar->status_handle == pointer->w) ro_gui_status_click(g, pointer); diff --git a/riscos/gui.h b/riscos/gui.h index e8df46bbd..3df53141e 100644 --- a/riscos/gui.h +++ b/riscos/gui.h @@ -37,6 +37,7 @@ extern wimp_menu *current_menu; extern gui_window *current_gui; extern gui_window *ro_gui_current_redraw_gui; extern osspriteop_area *gui_sprites; +extern struct toolbar *hotlist_toolbar; typedef enum { GUI_BROWSER_WINDOW } gui_window_type; typedef enum { GUI_SAVE_SOURCE, GUI_SAVE_DRAW, GUI_SAVE_TEXT, @@ -187,6 +188,7 @@ void ro_gui_hotlist_selection_drag_end(wimp_dragged *drag); void ro_gui_hotlist_move_drag_end(wimp_dragged *drag); bool ro_gui_hotlist_keypress(int key); void ro_gui_hotlist_menu_closed(void); +void ro_gui_hotlist_toolbar_click(wimp_pointer* pointer); int ro_gui_hotlist_get_selected(bool folders); void ro_gui_hotlist_set_selected(bool selected); @@ -215,7 +217,11 @@ void ro_gui_debugwin_open(void); void ro_gui_debugwin_close(void); void ro_gui_debugwin_redraw(wimp_draw *redraw); -/* icon numbers */ +/* toolbar types */ +#define TOOLBAR_BROWSER 0 +#define TOOLBAR_HOTLIST 1 + +/* icon numbers for browser toolbars */ #define ICON_TOOLBAR_BACK 0 #define ICON_TOOLBAR_FORWARD 1 #define ICON_TOOLBAR_STOP 2 @@ -231,6 +237,16 @@ void ro_gui_debugwin_redraw(wimp_draw *redraw); #define ICON_TOOLBAR_URL 12 // Must be after highest toolbar icon #define ICON_TOOLBAR_THROBBER 13 +/* icon numbers for hotlist toolbars */ +#define ICON_TOOLBAR_CREATE 0 +#define ICON_TOOLBAR_DELETE 1 +#define ICON_TOOLBAR_EXPAND 2 +#define ICON_TOOLBAR_OPEN 3 +#define ICON_TOOLBAR_LAUNCH 4 +#define ICON_TOOLBAR_SORT 5 +#define ICON_TOOLBAR_HOTLIST_LAST 6 + +/* icon numbers for toolbar status window */ #define ICON_STATUS_TEXT 0 #define ICON_STATUS_RESIZE 1 diff --git a/riscos/hotlist.c b/riscos/hotlist.c index 4e43f5024..6d5374991 100644 --- a/riscos/hotlist.c +++ b/riscos/hotlist.c @@ -20,6 +20,7 @@ #include "oslib/wimpspriteop.h" #include "netsurf/content/content.h" #include "netsurf/riscos/gui.h" +#include "netsurf/riscos/theme.h" #include "netsurf/riscos/wimp.h" #include "netsurf/utils/log.h" #include "netsurf/utils/messages.h" @@ -128,7 +129,7 @@ static wimp_window hotlist_window_definition = { wimp_COLOUR_BLACK, wimp_COLOUR_LIGHT_GREY, wimp_COLOUR_LIGHT_GREY, - wimp_COLOUR_VERY_LIGHT_GREY, + wimp_COLOUR_WHITE, wimp_COLOUR_DARK_GREY, wimp_COLOUR_MID_LIGHT_GREY, wimp_COLOUR_CREAM, @@ -138,8 +139,8 @@ static wimp_window hotlist_window_definition = { (wimp_BUTTON_DOUBLE_CLICK_DRAG << wimp_ICON_BUTTON_TYPE_SHIFT), wimpspriteop_AREA, 1, - 1, - {"Hotlist"}, + 256, + {"Bookmarks"}, 0 }; @@ -161,9 +162,10 @@ static bool reformat_pending = false; static int max_width = 0; static int max_height = 0; -/* The hotlist window and plot origins +/* The hotlist window, toolbar and plot origins */ wimp_w hotlist_window; +struct toolbar *hotlist_toolbar = NULL; static int origin_x, origin_y; /* The current redraw rectangle @@ -224,6 +226,7 @@ static bool ro_gui_hotlist_move_processing(struct hotlist_entry *entry, struct h void ro_gui_hotlist_init(void) { + os_box extent = {0, 0, 0, 0};; os_error *error; /* Set the initial root options @@ -289,6 +292,20 @@ void ro_gui_hotlist_init(void) { warn_user("WimpError", error->errmess); return; } + + /* Create our toolbar + */ + ro_theme_create_hotlist_toolbar(); + + /* Update the extent + */ + if (hotlist_toolbar) { + extent.x1 = 16384; + extent.y1 = hotlist_toolbar->height; + extent.y0 = -16384; + xwimp_set_extent(hotlist_window, &extent); + reformat_pending = true; + } } @@ -337,6 +354,9 @@ void ro_gui_hotlist_show(void) { dimension = state.visible.y1 - state.visible.y0; state.visible.y0 = (screen_height - dimension) / 2; state.visible.y1 = state.visible.y0 + dimension; + state.xscroll = 0; + state.yscroll = 0; + if (hotlist_toolbar) state.yscroll = hotlist_toolbar->height; } /* Open the window at the top of the stack @@ -870,6 +890,7 @@ void ro_gui_hotlist_delink_entry(struct hotlist_entry *entry) { */ if (entry->parent_entry) { entry->parent_entry->children -= 1; + if (entry->parent_entry->children == 0) entry->parent_entry->expanded = false; if (entry->parent_entry->child_entry == entry) { entry->parent_entry->child_entry = entry->next_entry; } @@ -1072,6 +1093,10 @@ void ro_gui_hotlist_redraw(wimp_draw *redraw) { if (max_height > -800) max_height = -800; extent.x1 = max_width; extent.y0 = max_height; + if (hotlist_toolbar) { + extent.y1 += hotlist_toolbar->height; + } + LOG(("Toolbar height: %i", hotlist_toolbar->height)); xwimp_set_extent(hotlist_window, &extent); state.w = hotlist_window; wimp_get_window_state(&state); @@ -1449,18 +1474,20 @@ void ro_gui_hotlist_click(wimp_pointer *pointer) { x_offset = x - entry->x0; y_offset = y - (entry->y0 + entry->height); if (((x_offset < HOTLIST_LEAF_INSET) && (y_offset > -HOTLIST_LINE_HEIGHT) && - ((buttons == wimp_CLICK_SELECT << 8) || (buttons == wimp_CLICK_ADJUST << 8))) || + ((buttons == wimp_CLICK_SELECT << 8) || (buttons == wimp_CLICK_ADJUST << 8))) || ((entry->children != -1) && - ((buttons == wimp_DOUBLE_SELECT) || (buttons == wimp_DOUBLE_ADJUST)))) { - ro_gui_hotlist_update_expansion(entry->child_entry, false, true, true, false, true); - ro_gui_hotlist_selection_state(entry->child_entry, - false, false); - entry->expanded = !entry->expanded; - if (x_offset >= HOTLIST_LEAF_INSET) entry->selected = false; - reformat_pending = true; - xwimp_force_redraw(hotlist_window, - 0, -16384, 16384, - entry->y0 + entry->height); + ((buttons == wimp_DOUBLE_SELECT) || (buttons == wimp_DOUBLE_ADJUST)))) { + if (entry->children != 0) { + ro_gui_hotlist_update_expansion(entry->child_entry, false, true, true, false, true); + ro_gui_hotlist_selection_state(entry->child_entry, + false, false); + entry->expanded = !entry->expanded; + if (x_offset >= HOTLIST_LEAF_INSET) entry->selected = false; + reformat_pending = true; + xwimp_force_redraw(hotlist_window, + 0, -16384, 16384, + entry->y0 + entry->height); + } } else if (x_offset >= HOTLIST_LEAF_INSET) { /* We treat a menu click as a Select click if we have no selections @@ -1593,6 +1620,7 @@ void ro_gui_hotlist_click(wimp_pointer *pointer) { drag.bbox.x1 = state.visible.x1; drag.bbox.y0 = state.visible.y0; drag.bbox.y1 = state.visible.y1; + if (hotlist_toolbar) drag.bbox.y1 -= hotlist_toolbar->height; xwimp_drag_box(&drag); } } @@ -1965,6 +1993,11 @@ void ro_gui_hotlist_selection_drag(struct hotlist_entry *entry, void ro_gui_hotlist_selection_drag_end(wimp_dragged *drag) { wimp_window_state state; int x0, y0, x1, y1; + int toolbar_height = 0; + + /* Get the toolbar height + */ + if (hotlist_toolbar) toolbar_height = hotlist_toolbar->height * 2; /* Get the window state to make everything relative */ @@ -1975,8 +2008,8 @@ void ro_gui_hotlist_selection_drag_end(wimp_dragged *drag) { */ x0 = drag->final.x0 - state.visible.x0 - state.xscroll; x1 = drag->final.x1 - state.visible.x0 - state.xscroll; - y0 = drag->final.y0 - state.visible.y1 - state.yscroll; - y1 = drag->final.y1 - state.visible.y1 - state.yscroll; + y0 = drag->final.y0 - state.visible.y1 - state.yscroll + toolbar_height; + y1 = drag->final.y1 - state.visible.y1 - state.yscroll + toolbar_height; /* Make sure x0 < x1 and y0 > y1 */ @@ -2007,12 +2040,23 @@ void ro_gui_hotlist_selection_drag_end(wimp_dragged *drag) { * \param drag the final drag co-ordinates */ void ro_gui_hotlist_move_drag_end(wimp_dragged *drag) { + wimp_pointer pointer; + int toolbar_height = 0; wimp_window_state state; struct hotlist_entry *test_entry; struct hotlist_entry *entry; int x, y, x0, y0, x1, y1; bool before = false; + + xwimp_get_pointer_info(&pointer); + if (pointer.w != hotlist_window) return; + + + /* Get the toolbar height + */ + if (hotlist_toolbar) toolbar_height = hotlist_toolbar->height * 2; + /* Set the process flag for all selected items */ ro_gui_hotlist_selection_to_process(root.child_entry); @@ -2026,8 +2070,8 @@ void ro_gui_hotlist_move_drag_end(wimp_dragged *drag) { */ x0 = drag->final.x0 - state.visible.x0 - state.xscroll; x1 = drag->final.x1 - state.visible.x0 - state.xscroll; - y0 = drag->final.y0 - state.visible.y1 - state.yscroll; - y1 = drag->final.y1 - state.visible.y1 - state.yscroll; + y0 = drag->final.y0 - state.visible.y1 - state.yscroll + toolbar_height; + y1 = drag->final.y1 - state.visible.y1 - state.yscroll + toolbar_height; x = (x0 + x1) / 2; y = (y0 + y1) / 2; @@ -2168,7 +2212,36 @@ bool ro_gui_hotlist_keypress(int key) { } +void ro_gui_hotlist_toolbar_click(wimp_pointer* pointer) { + int selection; + + /* Reject Menu clicks + */ + if (pointer->buttons == wimp_CLICK_MENU) return; + /* Handle the buttons appropriately + */ + switch (pointer->i) { + case ICON_TOOLBAR_OPEN: + selection = ro_gui_hotlist_get_selected(true); + ro_gui_hotlist_update_expansion(root.child_entry, (selection != 0), true, false, + (pointer->buttons == wimp_CLICK_SELECT), + (pointer->buttons == wimp_CLICK_ADJUST)); + break; + case ICON_TOOLBAR_EXPAND: + selection = ro_gui_hotlist_get_selected(true); + ro_gui_hotlist_update_expansion(root.child_entry, (selection != 0), false, true, + (pointer->buttons == wimp_CLICK_SELECT), + (pointer->buttons == wimp_CLICK_ADJUST)); + break; + case ICON_TOOLBAR_DELETE: + ro_gui_hotlist_delete_selected(); + break; + case ICON_TOOLBAR_LAUNCH: + ro_gui_hotlist_keypress(wimp_KEY_RETURN); + break; + } +} diff --git a/riscos/theme.c b/riscos/theme.c index fb74a3ddd..b63488017 100644 --- a/riscos/theme.c +++ b/riscos/theme.c @@ -118,13 +118,12 @@ void ro_theme_load(char *pathname) { /** - * Create a toolbar from the current theme. + * Create a toolbar from the current theme for a browser window. * * The buffers url_buffer and status_buffer must be at least 256 bytes each, * throbber_buffer at least 12 bytes; */ - -void ro_theme_create_toolbar(gui_window *g) { +void ro_theme_create_browser_toolbar(gui_window *g) { struct toolbar *toolbar; /* Destroy any previous toolbar (paranoia) @@ -135,7 +134,8 @@ void ro_theme_create_toolbar(gui_window *g) { } /* Create a toolbar */ - toolbar = ro_toolbar_create(theme_sprite_area, g->url, g->status, g->throb_buf); + toolbar = ro_toolbar_create(theme_sprite_area, g->url, g->status, + g->throb_buf, TOOLBAR_BROWSER); if (toolbar == NULL) return; /* Set up the throbber @@ -150,24 +150,55 @@ void ro_theme_create_toolbar(gui_window *g) { /* Update the toolbar */ - ro_theme_update_toolbar(g); + ro_theme_update_toolbar(toolbar, g->window); +} + + +/** + * Create a toolbar from the current theme for a hotlist window. + * + * The buffers url_buffer and status_buffer must be at least 256 bytes each, + * throbber_buffer at least 12 bytes; + */ +void ro_theme_create_hotlist_toolbar(void) { + struct toolbar *toolbar; + + /* Destroy any previous toolbar (paranoia) + */ + if (hotlist_toolbar) { + ro_toolbar_destroy(hotlist_toolbar); + hotlist_toolbar = NULL; + } + + /* Create a toolbar + */ + toolbar = ro_toolbar_create(theme_sprite_area, NULL, NULL, + NULL, TOOLBAR_HOTLIST); + if (toolbar == NULL) return; + + /* Store our toolbar + */ + hotlist_toolbar = toolbar; + + /* Update the toolbar + */ + ro_theme_update_toolbar(toolbar, hotlist_window); } + /** * Updates any toolbar flags (eg closes windows, hides icons etc) * * \return non-zero if the toolbar height has changed */ -int ro_theme_update_toolbar(gui_window *g) { +int ro_theme_update_toolbar(struct toolbar *toolbar, wimp_w window) { wimp_outline outline; wimp_window_state state; - struct toolbar *toolbar; int return_value = 0; /* Set an update as pending */ - toolbar = g->data.browser.toolbar; toolbar->update_pending = true; /* Close the status window if we should, or resize it @@ -175,22 +206,22 @@ int ro_theme_update_toolbar(gui_window *g) { if (toolbar->status_window) { /* Update the status height - */ - ro_toolbar_resize_status(toolbar, ro_get_hscroll_height(g->window) - 2); + */ + ro_toolbar_resize_status(toolbar, ro_get_hscroll_height(window) - 2); } else { xwimp_close_window(toolbar->status_handle); } /* Update the toolbar height */ - return_value = ro_theme_resize_toolbar(g); + return_value = ro_theme_resize_toolbar(toolbar, window); /* Open/close the toolbar */ if (toolbar->height > 0) { - outline.w = g->window; + outline.w = window; xwimp_get_window_outline(&outline); - state.w = g->window; + state.w = window; xwimp_get_window_state(&state); state.w = toolbar->toolbar_handle; state.visible.x1 = outline.outline.x1 - 2; @@ -198,7 +229,7 @@ int ro_theme_update_toolbar(gui_window *g) { state.xscroll = 0; state.yscroll = 0; state.next = wimp_TOP; - xwimp_open_window_nested((wimp_open *)&state, g->window, + xwimp_open_window_nested((wimp_open *)&state, window, wimp_CHILD_LINKS_PARENT_VISIBLE_BOTTOM_OR_LEFT << wimp_CHILD_XORIGIN_SHIFT | wimp_CHILD_LINKS_PARENT_VISIBLE_TOP_OR_RIGHT @@ -226,9 +257,8 @@ int ro_theme_update_toolbar(gui_window *g) { * * \return non-zero if the toolbar height has changed */ -int ro_theme_resize_toolbar(gui_window *g) { +int ro_theme_resize_toolbar(struct toolbar *toolbar, wimp_w window) { os_box extent = { 0, 0, 0, 0 }; - struct toolbar *toolbar; wimp_outline outline; wimp_outline status_outline; wimp_window_state state; @@ -237,28 +267,27 @@ int ro_theme_resize_toolbar(gui_window *g) { /* Paranoia */ - toolbar = g->data.browser.toolbar; if (toolbar == NULL) return 0; /* Get the toolbar width */ - outline.w = g->window; + outline.w = window; if (xwimp_get_window_outline(&outline)) return 0; width = outline.outline.x1 - outline.outline.x0 - 2; /* Reformat if we should */ if ((toolbar->width != width) || (toolbar->resize_status) || (toolbar->update_pending)) { - if (toolbar->resize_status) { + if ((toolbar->resize_status) && (toolbar->status_handle)) { status_outline.w = toolbar->status_handle; if (xwimp_get_window_outline(&status_outline)) return 0; toolbar->status_width = width - (status_outline.outline.x1 - status_outline.outline.x0 - 4); toolbar->resize_status = 0; - } else { + } else if (toolbar->status_handle) { /* Update the extent of the status window */ - state.w = g->window; + state.w = window; if (xwimp_get_window_state(&state)) return 0; extent.x1 = state.visible.x1 - state.visible.x0; extent.y1 = toolbar->status_height - 2; @@ -279,7 +308,7 @@ int ro_theme_resize_toolbar(gui_window *g) { state.visible.x1 = outline.outline.x0 + status_width; state.visible.y0 = outline.outline.y0 - toolbar->status_height; state.visible.y1 = outline.outline.y0 - 2; - xwimp_open_window_nested((wimp_open *) &state, g->window, + xwimp_open_window_nested((wimp_open *) &state, window, wimp_CHILD_LINKS_PARENT_VISIBLE_BOTTOM_OR_LEFT << wimp_CHILD_XORIGIN_SHIFT | wimp_CHILD_LINKS_PARENT_VISIBLE_BOTTOM_OR_LEFT diff --git a/riscos/theme.h b/riscos/theme.h index 3f22f7af6..9cbe809f9 100644 --- a/riscos/theme.h +++ b/riscos/theme.h @@ -28,9 +28,10 @@ struct theme_entry { extern int theme_throbs; void ro_theme_load(char *pathname); -void ro_theme_create_toolbar(gui_window *g); -int ro_theme_update_toolbar(gui_window *g); -int ro_theme_resize_toolbar(gui_window *g); +void ro_theme_create_browser_toolbar(gui_window *g); +void ro_theme_create_hotlist_toolbar(void); +int ro_theme_update_toolbar(struct toolbar *toolbar, wimp_w window); +int ro_theme_resize_toolbar(struct toolbar *toolbar, wimp_w window); struct theme_entry *ro_theme_list(unsigned int *entries); void ro_theme_list_free(struct theme_entry *list, unsigned int entries); diff --git a/riscos/toolbar.c b/riscos/toolbar.c index 3023a1a25..a7f0ea8c3 100644 --- a/riscos/toolbar.c +++ b/riscos/toolbar.c @@ -92,13 +92,17 @@ static struct toolbar_icon *ro_toolbar_create_separator(void); static void ro_toolbar_destroy_icon(struct toolbar_icon *icon); static void ro_toolbar_add_icon(struct toolbar *toolbar, struct toolbar_icon *icon); + + + /** * Creates a toolbar with a complete set of icons * * \param sprite_area the sprite area to read from */ struct toolbar *ro_toolbar_create(osspriteop_area *sprite_area, char *url_buffer, - char *status_buffer, char *throbber_buffer) { + char *status_buffer, char *throbber_buffer, + int toolbar_type) { struct toolbar *toolbar; wimp_i icon_handle; @@ -108,14 +112,15 @@ struct toolbar *ro_toolbar_create(osspriteop_area *sprite_area, char *url_buffer if (!toolbar) return NULL; toolbar->update_pending = true; toolbar->standard_buttons = true; - toolbar->url_bar = true; - toolbar->throbber = true; - toolbar->status_window = true; + toolbar->url_bar = (toolbar_type == TOOLBAR_BROWSER); + toolbar->throbber = (toolbar_type == TOOLBAR_BROWSER); + toolbar->status_window = (toolbar_type == TOOLBAR_BROWSER); toolbar->status_old_width = 0xffffffff; + toolbar->type = toolbar_type; /* Load the toolbar icons */ - if (sprite_area) { + if ((sprite_area) && (toolbar_type == TOOLBAR_BROWSER)) { ro_toolbar_add_icon(toolbar, ro_toolbar_initialise_icon(sprite_area, "back", ICON_TOOLBAR_BACK)); ro_toolbar_add_icon(toolbar, ro_toolbar_initialise_icon(sprite_area, "forward", ICON_TOOLBAR_FORWARD)); ro_toolbar_add_icon(toolbar, ro_toolbar_initialise_icon(sprite_area, "stop", ICON_TOOLBAR_STOP)); @@ -132,6 +137,16 @@ struct toolbar *ro_toolbar_create(osspriteop_area *sprite_area, char *url_buffer } ro_toolbar_add_icon(toolbar, ro_toolbar_initialise_icon(sprite_area, "save", ICON_TOOLBAR_SAVE)); /* ro_toolbar_add_icon(toolbar, ro_toolbar_initialise_icon(sprite_area, "print", ICON_TOOLBAR_PRINT)); */ + } else if ((sprite_area) && (toolbar_type == TOOLBAR_HOTLIST)) { + ro_toolbar_add_icon(toolbar, ro_toolbar_initialise_icon(sprite_area, "create", ICON_TOOLBAR_CREATE)); + ro_toolbar_add_icon(toolbar, ro_toolbar_initialise_icon(sprite_area, "delete", ICON_TOOLBAR_DELETE)); + ro_toolbar_add_icon(toolbar, ro_toolbar_initialise_icon(sprite_area, "launch", ICON_TOOLBAR_LAUNCH)); + ro_toolbar_add_icon(toolbar, ro_toolbar_create_separator()); + ro_toolbar_add_icon(toolbar, ro_toolbar_initialise_icon(sprite_area, "open", ICON_TOOLBAR_OPEN)); + ro_toolbar_add_icon(toolbar, ro_toolbar_initialise_icon(sprite_area, "expand", ICON_TOOLBAR_EXPAND)); + ro_toolbar_add_icon(toolbar, ro_toolbar_create_separator()); + ro_toolbar_add_icon(toolbar, ro_toolbar_initialise_icon(sprite_area, "sort", ICON_TOOLBAR_SORT)); + ro_toolbar_add_icon(toolbar, ro_toolbar_create_separator()); } /* Set the sprite area @@ -144,12 +159,13 @@ struct toolbar *ro_toolbar_create(osspriteop_area *sprite_area, char *url_buffer /* Create the basic windows */ - empty_window.ymin = 36; - if (xwimp_create_window(&empty_window, &toolbar->status_handle)) { - ro_toolbar_destroy(toolbar); - return NULL; + if (toolbar_type == TOOLBAR_BROWSER) { + empty_window.ymin = 36; + if (xwimp_create_window(&empty_window, &toolbar->status_handle)) { + ro_toolbar_destroy(toolbar); + return NULL; + } } - empty_window.ymin = 1; if (xwimp_create_window(&empty_window, &toolbar->toolbar_handle)) { ro_toolbar_destroy(toolbar); @@ -158,34 +174,36 @@ struct toolbar *ro_toolbar_create(osspriteop_area *sprite_area, char *url_buffer /* Create the status window icons. First the status text */ - empty_icon.w = toolbar->status_handle; - empty_icon.icon.extent.x0 = 0; - empty_icon.icon.extent.y0 = 0; - empty_icon.icon.extent.x1 = 16384; - empty_icon.icon.extent.y1 = 36; - empty_icon.icon.flags = wimp_ICON_TEXT | (wimp_COLOUR_BLACK << wimp_ICON_FG_COLOUR_SHIFT) | - wimp_ICON_INDIRECTED | wimp_ICON_VCENTRED; - empty_icon.icon.data.indirected_text.text = status_buffer; - empty_icon.icon.data.indirected_text.validation = 0; - empty_icon.icon.data.indirected_text.size = 256; - if (xwimp_create_icon(&empty_icon, &icon_handle)) { - ro_toolbar_destroy(toolbar); - return NULL; - } + if (toolbar->status_handle) { + empty_icon.w = toolbar->status_handle; + empty_icon.icon.extent.x0 = 0; + empty_icon.icon.extent.y0 = 0; + empty_icon.icon.extent.x1 = 16384; + empty_icon.icon.extent.y1 = 36; + empty_icon.icon.flags = wimp_ICON_TEXT | (wimp_COLOUR_BLACK << wimp_ICON_FG_COLOUR_SHIFT) | + wimp_ICON_INDIRECTED | wimp_ICON_VCENTRED; + empty_icon.icon.data.indirected_text.text = status_buffer; + empty_icon.icon.data.indirected_text.validation = 0; + empty_icon.icon.data.indirected_text.size = 256; + if (xwimp_create_icon(&empty_icon, &icon_handle)) { + ro_toolbar_destroy(toolbar); + return NULL; + } - /* And finally the status resize icon - */ - empty_icon.icon.flags = wimp_ICON_TEXT | wimp_ICON_INDIRECTED | - wimp_ICON_BORDER | wimp_ICON_FILLED | - (wimp_COLOUR_LIGHT_GREY << wimp_ICON_BG_COLOUR_SHIFT) | - (wimp_BUTTON_CLICK_DRAG << wimp_ICON_BUTTON_TYPE_SHIFT); - empty_icon.icon.extent.x1 = 0; - empty_icon.icon.data.indirected_text.text = null_text_string; - empty_icon.icon.data.indirected_text.validation = resize_validation; - empty_icon.icon.data.indirected_text.size = 1; - if (xwimp_create_icon(&empty_icon, &icon_handle)) { - ro_toolbar_destroy(toolbar); - return NULL; + /* And finally the status resize icon + */ + empty_icon.icon.flags = wimp_ICON_TEXT | wimp_ICON_INDIRECTED | + wimp_ICON_BORDER | wimp_ICON_FILLED | + (wimp_COLOUR_LIGHT_GREY << wimp_ICON_BG_COLOUR_SHIFT) | + (wimp_BUTTON_CLICK_DRAG << wimp_ICON_BUTTON_TYPE_SHIFT); + empty_icon.icon.extent.x1 = 0; + empty_icon.icon.data.indirected_text.text = null_text_string; + empty_icon.icon.data.indirected_text.validation = resize_validation; + empty_icon.icon.data.indirected_text.size = 1; + if (xwimp_create_icon(&empty_icon, &icon_handle)) { + ro_toolbar_destroy(toolbar); + return NULL; + } } /* Create the icons @@ -209,6 +227,7 @@ static struct toolbar *ro_toolbar_create_icons(struct toolbar *toolbar, ossprite int index; struct toolbar_icon *cur_icon; wimp_i icon_handle; + int max_icon; /* Set the basic icon flags */ @@ -225,7 +244,9 @@ static struct toolbar *ro_toolbar_create_icons(struct toolbar *toolbar, ossprite /* Create all the required icons */ - for (index = 0; index < ICON_TOOLBAR_URL; index++) { + max_icon = ICON_TOOLBAR_URL; + if (toolbar->type == TOOLBAR_HOTLIST) max_icon = ICON_TOOLBAR_HOTLIST_LAST; + for (index = 0; index < max_icon; index++) { /* Find an icon with the correct index and get the validation */ @@ -250,47 +271,51 @@ static struct toolbar *ro_toolbar_create_icons(struct toolbar *toolbar, ossprite /* Now the URL icon */ - empty_icon.icon.flags = wimp_ICON_TEXT | wimp_ICON_INDIRECTED | wimp_ICON_VCENTRED | + if (toolbar->type == TOOLBAR_BROWSER) { + empty_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 << wimp_ICON_BUTTON_TYPE_SHIFT); - empty_icon.icon.data.indirected_text.text = url_buffer; - empty_icon.icon.data.indirected_text.validation = url_validation; - empty_icon.icon.data.indirected_text.size = 256; - if (xwimp_create_icon(&empty_icon, &icon_handle)) { - ro_toolbar_destroy(toolbar); - return NULL; - } + empty_icon.icon.data.indirected_text.text = url_buffer; + empty_icon.icon.data.indirected_text.validation = url_validation; + empty_icon.icon.data.indirected_text.size = 256; + if (xwimp_create_icon(&empty_icon, &icon_handle)) { + ro_toolbar_destroy(toolbar); + return NULL; + } - /* Now the throbber - */ - empty_icon.icon.flags = wimp_ICON_SPRITE | wimp_ICON_INDIRECTED | wimp_ICON_HCENTRED | - wimp_ICON_VCENTRED; - empty_icon.icon.data.indirected_sprite.id = (osspriteop_id)throbber_buffer; - if (sprite_area) { - empty_icon.icon.data.indirected_sprite.area = sprite_area; - } else { - empty_icon.icon.data.indirected_sprite.area = (osspriteop_area *) 1; - } - empty_icon.icon.data.indirected_sprite.size = 12; - if (xwimp_create_icon(&empty_icon, &icon_handle)) { - ro_toolbar_destroy(toolbar); - return NULL; + /* Now the throbber + */ + empty_icon.icon.flags = wimp_ICON_SPRITE | wimp_ICON_INDIRECTED | wimp_ICON_HCENTRED | + wimp_ICON_VCENTRED; + empty_icon.icon.data.indirected_sprite.id = (osspriteop_id)throbber_buffer; + if (sprite_area) { + empty_icon.icon.data.indirected_sprite.area = sprite_area; + } else { + empty_icon.icon.data.indirected_sprite.area = (osspriteop_area *) 1; + } + empty_icon.icon.data.indirected_sprite.size = 12; + if (xwimp_create_icon(&empty_icon, &icon_handle)) { + ro_toolbar_destroy(toolbar); + return NULL; + } } /* And finally the status resize icon */ - empty_icon.w = toolbar->status_handle; - empty_icon.icon.flags = wimp_ICON_TEXT | wimp_ICON_INDIRECTED | + if (toolbar->status_handle) { + empty_icon.w = toolbar->status_handle; + empty_icon.icon.flags = wimp_ICON_TEXT | wimp_ICON_INDIRECTED | wimp_ICON_BORDER | wimp_ICON_FILLED | (wimp_COLOUR_LIGHT_GREY << wimp_ICON_BG_COLOUR_SHIFT) | (wimp_BUTTON_CLICK_DRAG << wimp_ICON_BUTTON_TYPE_SHIFT); - empty_icon.icon.data.indirected_text.text = null_text_string; - empty_icon.icon.data.indirected_text.validation = resize_validation; - empty_icon.icon.data.indirected_text.size = 1; - if (xwimp_create_icon(&empty_icon, &icon_handle)) { - ro_toolbar_destroy(toolbar); - return NULL; + empty_icon.icon.data.indirected_text.text = null_text_string; + empty_icon.icon.data.indirected_text.validation = resize_validation; + empty_icon.icon.data.indirected_text.size = 1; + if (xwimp_create_icon(&empty_icon, &icon_handle)) { + ro_toolbar_destroy(toolbar); + return NULL; + } } /* Success - return what we had @@ -477,7 +502,7 @@ void ro_toolbar_resize_status(struct toolbar *toolbar, int height) { /* Paranoia */ - if (toolbar == NULL) return; + if ((toolbar == NULL) || (toolbar->status_handle == NULL)) return; /* Check if we need to update */ @@ -693,32 +718,34 @@ int ro_toolbar_update(struct toolbar *toolbar) { /* Hide the URL bar if we should (and shade it to stop caret issues) */ - if (!toolbar->url_bar) { - /* Handle losing the caret - */ - if (!xwimp_get_caret_position(&caret)) { - if ((caret.w == toolbar->toolbar_handle) && (caret.i == ICON_TOOLBAR_URL)) { - xwimp_set_caret_position((wimp_w)-1, 0, 0, 0, 0, 0); + if (toolbar->type == TOOLBAR_BROWSER) { + if (!toolbar->url_bar) { + /* Handle losing the caret + */ + if (!xwimp_get_caret_position(&caret)) { + if ((caret.w == toolbar->toolbar_handle) && (caret.i == ICON_TOOLBAR_URL)) { + xwimp_set_caret_position((wimp_w)-1, 0, 0, 0, 0, 0); + } } + xwimp_resize_icon(toolbar->toolbar_handle, ICON_TOOLBAR_URL, + 0, + 1024 + toolbar_height, + 64, + 1024 + toolbar_height + 52); + ro_gui_set_icon_shaded_state(toolbar->toolbar_handle, ICON_TOOLBAR_URL, true); + } else { + ro_gui_set_icon_shaded_state(toolbar->toolbar_handle, ICON_TOOLBAR_URL, false); } - xwimp_resize_icon(toolbar->toolbar_handle, ICON_TOOLBAR_URL, - 0, - 1024 + toolbar_height, - 64, - 1024 + toolbar_height + 52); - ro_gui_set_icon_shaded_state(toolbar->toolbar_handle, ICON_TOOLBAR_URL, true); - } else { - ro_gui_set_icon_shaded_state(toolbar->toolbar_handle, ICON_TOOLBAR_URL, false); - } - /* Hide the throbber if we should - */ - if (!toolbar->throbber) { - xwimp_resize_icon(toolbar->toolbar_handle, ICON_TOOLBAR_THROBBER, - 0, - 1024 + toolbar_height, - toolbar->throbber_width, - 1024 + toolbar_height + toolbar->throbber_height); + /* Hide the throbber if we should + */ + if (!toolbar->throbber) { + xwimp_resize_icon(toolbar->toolbar_handle, ICON_TOOLBAR_THROBBER, + 0, + 1024 + toolbar_height, + toolbar->throbber_width, + 1024 + toolbar_height + toolbar->throbber_height); + } } /* Redraw the entire window diff --git a/riscos/toolbar.h b/riscos/toolbar.h index c7c94cf94..a62bf3d99 100644 --- a/riscos/toolbar.h +++ b/riscos/toolbar.h @@ -43,6 +43,10 @@ struct toolbar { /* The first toolbar icon */ struct toolbar_icon *icon; + + /* The toolbar type + */ + int type; /* Window handles */ @@ -52,7 +56,7 @@ struct toolbar { struct toolbar *ro_toolbar_create(osspriteop_area *sprite_area, char *url_buffer, - char *status_buffer, char *throbber_buffer); + char *status_buffer, char *throbber_buffer, int toolbar_type); void ro_toolbar_destroy(struct toolbar *toolbar); void ro_toolbar_resize_status(struct toolbar *toolbar, int height); int ro_toolbar_reformat(struct toolbar *toolbar, int width); diff --git a/riscos/window.c b/riscos/window.c index bbcc01d99..59cbb8c03 100644 --- a/riscos/window.c +++ b/riscos/window.c @@ -167,7 +167,7 @@ gui_window *gui_create_browser_window(struct browser_window *bw, return 0; } - ro_theme_create_toolbar(g); + ro_theme_create_browser_toolbar(g); g->next = window_list; window_list = g; @@ -577,7 +577,7 @@ void ro_gui_window_open(gui_window *g, wimp_open *open) { g->data.browser.old_height = height; } - ro_theme_resize_toolbar(g); + ro_theme_resize_toolbar(g->data.browser.toolbar, g->window); } @@ -1318,7 +1318,7 @@ void gui_window_clone_options(struct browser_window *new_bw, new_gui->data.browser.toolbar->url_bar = option_toolbar_show_address; new_gui->data.browser.toolbar->throbber = option_toolbar_show_throbber; } - ro_theme_update_toolbar(new_gui); + ro_theme_update_toolbar(new_gui->data.browser.toolbar, new_gui->window); } } -- cgit v1.2.3