summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Wilson <rjw@netsurf-browser.org>2005-12-31 04:40:49 +0000
committerRichard Wilson <rjw@netsurf-browser.org>2005-12-31 04:40:49 +0000
commitd1094d12387238932ee49a6dc6091a8fef8ede66 (patch)
tree625ad27f9db82010fed500c8e689f5f94b303ed2
parentf11b834daf4a51dff1f6307531c0e41e622a8c6f (diff)
downloadnetsurf-d1094d12387238932ee49a6dc6091a8fef8ede66.tar.gz
netsurf-d1094d12387238932ee49a6dc6091a8fef8ede66.tar.bz2
[project @ 2005-12-31 04:40:48 by rjw]
Use new wimp_event system. svn path=/import/netsurf/; revision=1916
-rw-r--r--riscos/debugwin.c13
-rw-r--r--riscos/dialog.c1656
-rw-r--r--riscos/download.c2
-rw-r--r--riscos/help.c74
-rw-r--r--riscos/history.c22
-rw-r--r--riscos/menus.c279
-rw-r--r--riscos/menus.h4
-rw-r--r--riscos/print.c130
-rw-r--r--riscos/query.c6
-rw-r--r--riscos/save.c49
-rw-r--r--riscos/theme.c89
-rw-r--r--riscos/theme.h13
-rw-r--r--riscos/theme_install.c119
-rw-r--r--riscos/url_complete.c2
-rw-r--r--riscos/wimp.c112
-rw-r--r--riscos/wimp.h4
-rw-r--r--riscos/window.c25
17 files changed, 785 insertions, 1814 deletions
diff --git a/riscos/debugwin.c b/riscos/debugwin.c
index 203f90a80..d271eb890 100644
--- a/riscos/debugwin.c
+++ b/riscos/debugwin.c
@@ -12,7 +12,8 @@
#include <stdio.h>
#include <stdlib.h>
#include "oslib/wimp.h"
-#include "netsurf/riscos/gui.h"
+#include "netsurf/riscos/dialog.h"
+#include "netsurf/riscos/wimp_event.h"
#include "netsurf/utils/log.h"
#include "netsurf/utils/utils.h"
@@ -21,11 +22,16 @@
static void ro_gui_debugwin_resize(void);
static void ro_gui_debugwin_update(void *p);
+static void ro_gui_debugwin_close(wimp_w w);
static void ro_gui_debugwin_redraw_plot(wimp_draw *redraw);
-
+static void ro_gui_debugwin_redraw(wimp_draw *redraw);
void ro_gui_debugwin_open(void)
{
+ ro_gui_wimp_event_register_close_window(dialog_debug,
+ ro_gui_debugwin_close);
+ ro_gui_wimp_event_register_redraw_window(dialog_debug,
+ ro_gui_debugwin_redraw);
ro_gui_debugwin_resize();
ro_gui_dialog_open(dialog_debug);
schedule_remove(ro_gui_debugwin_update, 0);
@@ -70,7 +76,7 @@ void ro_gui_debugwin_update(void *p)
}
-void ro_gui_debugwin_close(void)
+void ro_gui_debugwin_close(wimp_w w)
{
os_error *error;
error = xwimp_close_window(dialog_debug);
@@ -80,6 +86,7 @@ void ro_gui_debugwin_close(void)
warn_user("WimpError", error->errmess);
}
schedule_remove(ro_gui_debugwin_update, 0);
+ ro_gui_wimp_event_finalise(dialog_debug);
}
diff --git a/riscos/dialog.c b/riscos/dialog.c
index 00c1c005e..009398ef5 100644
--- a/riscos/dialog.c
+++ b/riscos/dialog.c
@@ -5,7 +5,7 @@
* Copyright 2003 Phil Mellor <monkeyson@users.sourceforge.net>
* Copyright 2005 James Bursa <bursa@users.sourceforge.net>
* Copyright 2003 John M Bell <jmb202@ecs.soton.ac.uk>
- * Copyright 2005 Richard Wilson <not_ginger_matt@users.sourceforge.net>
+ * Copyright 2005 Richard Wilson <info@tinct.net>
* Copyright 2004 Andrew Timmins <atimmins@blueyonder.co.uk>
* Copyright 2005 Adrian Lees <adrianl@users.sourceforge.net>
*/
@@ -23,11 +23,15 @@
#include "netsurf/utils/config.h"
#include "netsurf/desktop/netsurf.h"
#include "netsurf/render/font.h"
+#include "netsurf/riscos/configure.h"
+#include "netsurf/riscos/dialog.h"
#include "netsurf/riscos/gui.h"
#include "netsurf/riscos/menus.h"
#include "netsurf/riscos/options.h"
#include "netsurf/riscos/theme.h"
+#include "netsurf/riscos/url_complete.h"
#include "netsurf/riscos/wimp.h"
+#include "netsurf/riscos/wimp_event.h"
#include "netsurf/utils/log.h"
#include "netsurf/utils/messages.h"
#include "netsurf/utils/url.h"
@@ -35,59 +39,20 @@
/* The maximum number of persistent dialogues
*/
-#define MAX_PERSISTENT 8
+#define MAX_PERSISTENT 16
-wimp_w dialog_info, dialog_saveas, dialog_config, dialog_config_br,
- dialog_config_prox, dialog_config_th,
+wimp_w dialog_info, dialog_saveas,
#ifdef WITH_AUTH
dialog_401li,
#endif
dialog_zoom, dialog_pageinfo, dialog_objinfo, dialog_tooltip,
- dialog_warning, dialog_config_th_pane, dialog_debug,
+ dialog_warning, dialog_debug,
dialog_folder, dialog_entry, dialog_search, dialog_print,
- dialog_config_font, dialog_config_image, dialog_url_complete,
- dialog_openurl;
-
-static int ro_gui_choices_font_size;
-static int ro_gui_choices_font_min_size;
-static int config_font_icon = -1;
-static bool ro_gui_choices_http_proxy;
-static int ro_gui_choices_http_proxy_auth;
-static int config_br_icon = -1;
-static const char *ro_gui_choices_lang = 0;
-static const char *ro_gui_choices_alang = 0;
-static int ro_gui_choices_image_edit_type = 0;
-static unsigned int ro_gui_choices_fg_plot_style = 0;
-static unsigned int ro_gui_choices_bg_plot_style = 0;
-
+ dialog_url_complete, dialog_openurl;
struct gui_window *ro_gui_current_zoom_gui;
-struct toolbar_display {
- struct toolbar *toolbar;
- struct theme_descriptor *descriptor;
- int icon_number;
- struct toolbar_display *next;
-};
-
-static struct theme_descriptor *theme_choice = NULL;
-static struct theme_descriptor *theme_list = NULL;
-static int theme_count = 0;
-static struct toolbar_display *toolbars = NULL;
-static char theme_radio_validation[] = "Sradiooff,radioon\0";
-static char theme_null_validation[] = "\0";
-static char theme_line_validation[] = "R2\0";
-
-
-static const char *ro_gui_proxy_auth_name[] = {
- "ProxyNone", "ProxyBasic", "ProxyNTLM"
-};
-
-static const char *ro_gui_image_name[] = {
- "ImgStyle0", "ImgStyle1", "ImgStyle2", "ImgStyle3"
-};
-
/* A simple mapping of parent and child
*/
@@ -96,28 +61,10 @@ static struct {
wimp_w parent;
} persistent_dialog[MAX_PERSISTENT];
-static void ro_gui_dialog_config_prepare(void);
-static void ro_gui_dialog_set_image_quality(int icon, unsigned int tinct_options);
-static void ro_gui_dialog_config_set(void);
-static void ro_gui_dialog_click_config(wimp_pointer *pointer);
-static void ro_gui_dialog_click_config_br(wimp_pointer *pointer);
-static void ro_gui_dialog_click_config_prox(wimp_pointer *pointer);
-static void ro_gui_dialog_click_config_image(wimp_pointer *pointer);
-static void ro_gui_dialog_config_proxy_update(void);
-static void ro_gui_dialog_click_config_th(wimp_pointer *pointer);
-static void ro_gui_dialog_click_config_th_pane(wimp_pointer *pointer);
-static void ro_gui_dialog_update_config_font(void);
-static void ro_gui_dialog_click_config_font(wimp_pointer *pointer);
-static unsigned ro_gui_clamp_scale(unsigned scale);
-static void ro_gui_dialog_click_zoom(wimp_pointer *pointer);
-static bool ro_gui_zoom_keypress(wimp_key *key);
-static void ro_gui_dialog_click_open_url(wimp_pointer *pointer);
-static void ro_gui_dialog_click_warning(wimp_pointer *pointer);
-static const char *language_name(const char *code);
-
-static void ro_gui_dialog_load_themes(void);
-static void ro_gui_dialog_free_themes(void);
+static bool ro_gui_dialog_openurl_apply(wimp_w w);
+static bool ro_gui_dialog_zoom_click(wimp_pointer *pointer);
+static bool ro_gui_dialog_zoom_apply(wimp_w w);
/**
* Load and create dialogs from template file.
@@ -125,31 +72,108 @@ static void ro_gui_dialog_free_themes(void);
void ro_gui_dialog_init(void)
{
+ dialog_tooltip = ro_gui_dialog_create("tooltip");
+
+ /* configure window */
+ ro_gui_configure_initialise();
+
+ /* warning dialog */
+ dialog_warning = ro_gui_dialog_create("warning");
+ ro_gui_wimp_event_register_ok(dialog_warning, ICON_WARNING_CONTINUE,
+ NULL);
+ ro_gui_wimp_event_set_help_prefix(dialog_debug, "HelpWarning");
+
+ /* theme installation */
+ dialog_theme_install = ro_gui_dialog_create("theme_inst");
+ ro_gui_wimp_event_register_cancel(dialog_theme_install,
+ ICON_THEME_INSTALL_CANCEL);
+ ro_gui_wimp_event_register_ok(dialog_theme_install,
+ ICON_THEME_INSTALL_INSTALL,
+ ro_gui_theme_install_apply);
+ ro_gui_wimp_event_set_help_prefix(dialog_theme_install, "HelpThemeInst");
+
+ /* debug window */
+ dialog_debug = ro_gui_dialog_create("debug");
+ ro_gui_wimp_event_set_help_prefix(dialog_debug, "HelpDebug");
+
+ /* search */
+#ifdef WITH_SEARCH
+ ro_gui_search_init();
+#endif
+
+ /* print */
+#ifdef WITH_PRINT
+ ro_gui_print_init();
+#endif
+
+ /* about us */
dialog_info = ro_gui_dialog_create("info");
- /* fill in about box version info */
ro_gui_set_icon_string(dialog_info, 4, netsurf_version);
+ ro_gui_wimp_event_set_help_prefix(dialog_info, "HelpAppInfo");
- dialog_saveas = ro_gui_saveas_create("saveas");
- dialog_config = ro_gui_dialog_create("config");
- dialog_config_br = ro_gui_dialog_create("config_br");
- dialog_config_prox = ro_gui_dialog_create("config_prox");
- dialog_config_th = ro_gui_dialog_create("config_th");
- dialog_config_th_pane = ro_gui_dialog_create("config_th_p");
- dialog_zoom = ro_gui_dialog_create("zoom");
+ /* page info */
dialog_pageinfo = ro_gui_dialog_create("pageinfo");
+ ro_gui_wimp_event_set_help_prefix(dialog_pageinfo, "HelpPageInfo");
+
+ /* object info */
dialog_objinfo = ro_gui_dialog_create("objectinfo");
- dialog_tooltip = ro_gui_dialog_create("tooltip");
- dialog_warning = ro_gui_dialog_create("warning");
- dialog_debug = ro_gui_dialog_create("debug");
+ ro_gui_wimp_event_set_help_prefix(dialog_objinfo, "HelpObjInfo");
+
+ /* hotlist folder editing */
dialog_folder = ro_gui_dialog_create("new_folder");
+ ro_gui_wimp_event_register_text_field(dialog_folder, ICON_FOLDER_NAME);
+ ro_gui_wimp_event_register_menu_gright(dialog_openurl, ICON_OPENURL_URL,
+ ICON_OPENURL_MENU, url_suggest_menu);
+ ro_gui_wimp_event_register_cancel(dialog_folder, ICON_FOLDER_CANCEL);
+ ro_gui_wimp_event_register_ok(dialog_folder, ICON_FOLDER_OK,
+ ro_gui_hotlist_dialog_apply);
+ ro_gui_wimp_event_set_help_prefix(dialog_folder, "HelpHotFolder");
+
+ /* hotlist entry editing */
dialog_entry = ro_gui_dialog_create("new_entry");
- dialog_search = ro_gui_dialog_create("search");
- dialog_print = ro_gui_dialog_create("print");
- dialog_config_font = ro_gui_dialog_create("config_font");
- dialog_config_image = ro_gui_dialog_create("config_img");
- dialog_theme_install = ro_gui_dialog_create("theme_inst");
+ ro_gui_wimp_event_register_text_field(dialog_entry, ICON_ENTRY_NAME);
+ ro_gui_wimp_event_register_menu_gright(dialog_entry, ICON_ENTRY_URL,
+ ICON_ENTRY_RECENT, url_suggest_menu);
+ ro_gui_wimp_event_register_cancel(dialog_entry, ICON_ENTRY_CANCEL);
+ ro_gui_wimp_event_register_ok(dialog_entry, ICON_ENTRY_OK,
+ ro_gui_hotlist_dialog_apply);
+ ro_gui_wimp_event_set_help_prefix(dialog_entry, "HelpHotEntry");
+
+ /* save as */
+ dialog_saveas = ro_gui_saveas_create("saveas");
+ ro_gui_wimp_event_register_button(dialog_saveas, ICON_SAVE_ICON,
+ ro_gui_save_start_drag);
+ ro_gui_wimp_event_register_text_field(dialog_saveas, ICON_SAVE_PATH);
+ ro_gui_wimp_event_register_cancel(dialog_saveas, ICON_SAVE_CANCEL);
+ ro_gui_wimp_event_register_ok(dialog_saveas, ICON_SAVE_OK,
+ ro_gui_save_ok);
+ ro_gui_wimp_event_set_help_prefix(dialog_saveas, "HelpSaveAs");
+
+ /* url suggestion */
dialog_url_complete = ro_gui_dialog_create("url_suggest");
+ ro_gui_wimp_event_register_redraw_window(dialog_url_complete,
+ ro_gui_url_complete_redraw);
+ ro_gui_wimp_event_set_help_prefix(dialog_url_complete, "HelpAutoURL");
+
+ /* open URL */
dialog_openurl = ro_gui_dialog_create("open_url");
+ ro_gui_wimp_event_register_menu_gright(dialog_openurl, ICON_OPENURL_URL,
+ ICON_OPENURL_MENU, url_suggest_menu);
+ ro_gui_wimp_event_register_cancel(dialog_openurl, ICON_OPENURL_CANCEL);
+ ro_gui_wimp_event_register_ok(dialog_openurl, ICON_OPENURL_OPEN,
+ ro_gui_dialog_openurl_apply);
+ ro_gui_wimp_event_set_help_prefix(dialog_openurl, "HelpOpenURL");
+
+ /* scale view */
+ dialog_zoom = ro_gui_dialog_create("zoom");
+ ro_gui_wimp_event_register_numeric_field(dialog_zoom, ICON_ZOOM_VALUE,
+ ICON_ZOOM_INC, ICON_ZOOM_DEC, 10, 1600, 10, 0);
+ ro_gui_wimp_event_register_mouse_click(dialog_zoom,
+ ro_gui_dialog_zoom_click);
+ ro_gui_wimp_event_register_cancel(dialog_zoom, ICON_ZOOM_CANCEL);
+ ro_gui_wimp_event_register_ok(dialog_zoom, ICON_ZOOM_OK,
+ ro_gui_dialog_zoom_apply);
+ ro_gui_wimp_event_set_help_prefix(dialog_zoom, "HelpScaleView");
}
@@ -171,6 +195,7 @@ wimp_w ro_gui_dialog_create(const char *template_name)
window = ro_gui_dialog_load_template(template_name);
/* create window */
+ window->sprite_area = gui_sprites;
error = xwimp_create_window(window, &w);
if (error) {
LOG(("xwimp_create_window: 0x%x: %s",
@@ -289,529 +314,286 @@ void ro_gui_dialog_open(wimp_w w)
/**
- * Open a persistent dialog box relative to the pointer.
- *
- * \param parent the owning window (NULL for no owner)
- * \param w the dialog window
- * \param pointer open the window at the pointer (centre of the parent
- * otherwise)
+ * Close a dialog box.
*/
-void ro_gui_dialog_open_persistent(wimp_w parent, wimp_w w, bool pointer) {
- int dx, dy, i;
- wimp_window_state open;
+void ro_gui_dialog_close(wimp_w close)
+{
+ int i;
+ wimp_caret caret;
os_error *error;
- /* Move and open
+ /* Give the caret back to the parent window. This code relies on
+ the fact that only tree windows and browser windows open
+ persistent dialogues, as the caret gets placed to no icon.
*/
- if (pointer) {
- wimp_pointer ptr;
-
- /* Get the pointer position
+ error = xwimp_get_caret_position(&caret);
+ if (error) {
+ LOG(("xwimp_get_caret_position: 0x%x: %s",
+ error->errnum, error->errmess));
+ warn_user("WimpError", error->errmess);
+ } else if (caret.w == close) {
+ /* Check if we are a persistent window
*/
- error = xwimp_get_pointer_info(&ptr);
- if (error) {
- LOG(("xwimp_get_pointer_info: 0x%x: %s",
- error->errnum, error->errmess));
- warn_user("WimpError", error->errmess);
- return;
- }
-
- open.w = w;
- error = xwimp_get_window_state(&open);
- if (error) {
- LOG(("xwimp_get_window_state: 0x%x: %s",
- error->errnum, error->errmess));
- warn_user("WimpError", error->errmess);
- return;
- }
- dx = (open.visible.x1 - open.visible.x0);
- dy = (open.visible.y1 - open.visible.y0);
- open.visible.x0 = ptr.pos.x - 64;
- open.visible.x1 = ptr.pos.x - 64 + dx;
- open.visible.y0 = ptr.pos.y - dy;
- open.visible.y1 = ptr.pos.y;
- open.next = wimp_TOP;
- error = xwimp_open_window((wimp_open *) &open);
- if (error) {
- LOG(("xwimp_open_window: 0x%x: %s",
- error->errnum, error->errmess));
- warn_user("WimpError", error->errmess);
- return;
+ for (i = 0; i < MAX_PERSISTENT; i++) {
+ if (persistent_dialog[i].dialog == close) {
+ persistent_dialog[i].dialog = NULL;
+ error = xwimp_set_caret_position(
+ persistent_dialog[i].parent,
+ wimp_ICON_WINDOW, -100, -100,
+ 32, -1);
+ if (error) {
+ LOG(("xwimp_set_caret_position: "
+ "0x%x: %s",
+ error->errnum,
+ error->errmess));
+ warn_user("WimpError", error->errmess);
+ }
+ break;
+ }
}
- } else {
- ro_gui_open_window_centre(parent, w);
}
-
- /* Set the caret position and window furniture
- */
- if ((w == dialog_pageinfo) || (w == dialog_objinfo))
- ro_gui_wimp_update_window_furniture(w, wimp_WINDOW_CLOSE_ICON,
- wimp_WINDOW_CLOSE_ICON);
- ro_gui_wimp_update_window_furniture(w, wimp_WINDOW_BACK_ICON,
- wimp_WINDOW_BACK_ICON);
- ro_gui_set_caret_first(w);
-
- /* Add a mapping
- */
- if (parent == NULL)
- return;
- for (i = 0; i < MAX_PERSISTENT; i++) {
- if (persistent_dialog[i].dialog == NULL ||
- persistent_dialog[i].dialog == w) {
- persistent_dialog[i].dialog = w;
- persistent_dialog[i].parent = parent;
- return;
- }
+
+ error = xwimp_close_window(close);
+ if (error) {
+ LOG(("xwimp_close_window: 0x%x: %s",
+ error->errnum, error->errmess));
+ warn_user("WimpError", error->errmess);
}
-
- /* Log that we failed to create a mapping
- */
- LOG(("Unable to map persistent dialog to parent."));
+ ro_gui_wimp_event_close_window(close);
}
/**
- * Close persistent dialogs associated with a window.
+ * Moves a window to the top of the stack.
+ *
+ * If the window is currently closed then:
*
- * \param parent the window to close children of
- */
-
-void ro_gui_dialog_close_persistent(wimp_w parent) {
- int i;
+ * * The window is opened in the centre of the screen (at the supplied size)
+ * * Any toolbar editing session is stopped
+ * * The scroll position is set to the top of the window
+ *
+ * If the window is currently open then:
+ *
+ * * The window is brought to the top of the stack
+ *
+ * \param w the window to show
+ * \param toolbar the toolbar to consider
+ * \param width the window width if it is currently closed (or 0 to retain)
+ * \param height the window height if it is currently closed (or 0 to retain)
+ * \return true if the window was previously open
+ */
+bool ro_gui_dialog_open_top(wimp_w w, struct toolbar *toolbar,
+ int width, int height) {
+ os_error *error;
+ int screen_width, screen_height;
+ wimp_window_state state;
+ int dimension;
+ int scroll_width;
+ bool open;
- /* Check our mappings
- */
- for (i = 0; i < MAX_PERSISTENT; i++) {
- if (persistent_dialog[i].parent == parent &&
- persistent_dialog[i].dialog != NULL) {
- ro_gui_dialog_close(persistent_dialog[i].dialog);
- persistent_dialog[i].dialog = NULL;
- }
+ state.w = w;
+ error = xwimp_get_window_state(&state);
+ if (error) {
+ warn_user("WimpError", error->errmess);
+ return false;
+ }
+
+ /* if we're open we jump to the top of the stack, if not then we
+ * open in the centre of the screen. */
+ open = state.flags & wimp_WINDOW_OPEN;
+ if (!open) {
+ /* cancel any editing */
+ if ((toolbar) && (toolbar->editor))
+ ro_gui_theme_toggle_edit(toolbar);
+
+ /* move to the centre */
+ ro_gui_screen_size(&screen_width, &screen_height);
+ dimension = ((width == 0) ?
+ (state.visible.x1 - state.visible.x0) : width);
+ scroll_width = ro_get_vscroll_width(w);
+ state.visible.x0 = (screen_width - (dimension + scroll_width)) / 2;
+ state.visible.x1 = state.visible.x0 + dimension;
+ dimension = ((height == 0) ?
+ (state.visible.y1 - state.visible.y0) : height);
+ state.visible.y0 = (screen_height - dimension) / 2;
+ state.visible.y1 = state.visible.y0 + dimension;
+ state.xscroll = 0;
+ state.yscroll = 0;
+ if (toolbar)
+ state.yscroll = ro_gui_theme_toolbar_height(toolbar);
}
+
+ /* open the window at the top of the stack */
+ state.next = wimp_TOP;
+ ro_gui_open_window_request((wimp_open*)&state);
+ return open;
}
/**
- * Handle key presses in one of the dialog boxes.
+ * Open window at the location of the pointer.
*/
-bool ro_gui_dialog_keypress(wimp_key *key)
+void ro_gui_dialog_open_at_pointer(wimp_w w)
{
- wimp_pointer pointer;
-
-#ifdef WITH_SEARCH
- if (key->w == dialog_search)
- return ro_gui_search_keypress(key);
-#endif
-#ifdef WITH_PRINT
- if (key->w == dialog_print)
- return ro_gui_print_keypress(key);
-#endif
- if (key->w == dialog_zoom)
- return ro_gui_zoom_keypress(key);
+ int dx, dy;
+ wimp_window_state state;
+ wimp_pointer ptr;
+ os_error *error;
- if (key->c == wimp_KEY_ESCAPE) {
- ro_gui_dialog_close(key->w);
- return true;
- }
- else if (key->c == wimp_KEY_RETURN) {
- if ((key->w == dialog_folder) || (key->w == dialog_entry)) {
- pointer.w = key->w;
- /** \todo replace magic numbers with defines */
- pointer.i = (key->w == dialog_folder) ? 3 : 5;
- pointer.buttons = wimp_CLICK_SELECT;
- ro_gui_hotlist_dialog_click(&pointer);
- return true;
- } else if (key->w == dialog_saveas)
- ro_gui_save_ok(key->w);
- else if (key->w == dialog_openurl) {
- pointer.w = key->w;
- pointer.i = ICON_OPENURL_OPEN;
- pointer.buttons = wimp_CLICK_SELECT;
- ro_gui_dialog_click_open_url(&pointer);
- }
+ /* get the pointer position */
+ error = xwimp_get_pointer_info(&ptr);
+ if (error) {
+ LOG(("xwimp_get_pointer_info: 0x%x: %s",
+ error->errnum, error->errmess));
+ warn_user("WimpError", error->errmess);
+ return;
}
-#ifdef WITH_AUTH
- if (key->w == dialog_401li)
- return ro_gui_401login_keypress(key);
-#endif
- return false;
-}
-
-
-/**
- * Handle clicks in one of the dialog boxes.
- */
-
-void ro_gui_dialog_click(wimp_pointer *pointer)
-{
- if (pointer->buttons == wimp_CLICK_MENU)
+ /* move the window */
+ state.w = w;
+ error = xwimp_get_window_state(&state);
+ if (error) {
+ LOG(("xwimp_get_window_state: 0x%x: %s",
+ error->errnum, error->errmess));
+ warn_user("WimpError", error->errmess);
return;
+ }
+ dx = (state.visible.x1 - state.visible.x0);
+ dy = (state.visible.y1 - state.visible.y0);
+ state.visible.x0 = ptr.pos.x - 64;
+ state.visible.x1 = ptr.pos.x - 64 + dx;
+ state.visible.y0 = ptr.pos.y - dy;
+ state.visible.y1 = ptr.pos.y;
- if (pointer->w == dialog_config)
- ro_gui_dialog_click_config(pointer);
- else if (pointer->w == dialog_config_br)
- ro_gui_dialog_click_config_br(pointer);
- else if (pointer->w == dialog_config_prox)
- ro_gui_dialog_click_config_prox(pointer);
- else if (pointer->w == dialog_config_image)
- ro_gui_dialog_click_config_image(pointer);
- else if (pointer->w == dialog_config_th)
- ro_gui_dialog_click_config_th(pointer);
- else if (pointer->w == dialog_config_th_pane)
- ro_gui_dialog_click_config_th_pane(pointer);
-#ifdef WITH_AUTH
- else if (pointer->w == dialog_401li)
- ro_gui_401login_click(pointer);
-#endif
- else if (pointer->w == dialog_zoom)
- ro_gui_dialog_click_zoom(pointer);
- else if (pointer->w == dialog_warning)
- ro_gui_dialog_click_warning(pointer);
- else if ((pointer->w == dialog_folder) || (pointer->w == dialog_entry))
- ro_gui_hotlist_dialog_click(pointer);
-#ifdef WITH_SEARCH
- else if (pointer->w == dialog_search)
- ro_gui_search_click(pointer);
-#endif
-#ifdef WITH_PRINT
- else if (pointer->w == dialog_print)
- ro_gui_print_click(pointer);
-#endif
- else if (pointer->w == dialog_config_font)
- ro_gui_dialog_click_config_font(pointer);
- else if (pointer->w == dialog_theme_install)
- ro_gui_theme_install_click(pointer);
- else if (pointer->w == dialog_openurl)
- ro_gui_dialog_click_open_url(pointer);
+ /* open the window at the top of the stack */
+ state.next = wimp_TOP;
+ ro_gui_open_window_request((wimp_open*)&state);
}
/**
- * Redraw a dialog window
+ * Opens a window at the centre of either another window or the screen
+ *
+ * /param parent the parent window (NULL for centre of screen)
+ * /param child the child window
*/
+void ro_gui_dialog_open_centre_parent(wimp_w parent, wimp_w child) {
+ os_error *error;
+ wimp_window_state state;
+ int mid_x, mid_y;
+ int dimension, scroll_width;
-void ro_gui_dialog_redraw(wimp_draw *redraw)
-{
- struct toolbar_display *display;
-
- for (display = toolbars; display; display = display->next)
- if ((display->toolbar) && (display->toolbar->toolbar_handle ==
- redraw->w)) {
- ro_gui_theme_redraw(display->toolbar, redraw);
+ /* get the parent window state */
+ if (parent) {
+ state.w = parent;
+ error = xwimp_get_window_state(&state);
+ if (error) {
+ LOG(("xwimp_get_window_state: 0x%x: %s",
+ error->errnum, error->errmess));
+ warn_user("WimpError", error->errmess);
return;
}
+ scroll_width = ro_get_vscroll_width(parent);
+ mid_x = (state.visible.x0 + state.visible.x1 + scroll_width);
+ mid_y = (state.visible.y0 + state.visible.y1);
+ } else {
+ ro_gui_screen_size(&mid_x, &mid_y);
+ }
+ mid_x /= 2;
+ mid_y /= 2;
- ro_gui_user_redraw(redraw, false, (os_gcol)0);
-}
-
-
-/**
- * Prepare and open the Choices dialog.
- */
+ /* get the child window state */
+ state.w = child;
+ error = xwimp_get_window_state(&state);
+ if (error) {
+ LOG(("xwimp_get_window_state: 0x%x: %s",
+ error->errnum, error->errmess));
+ warn_user("WimpError", error->errmess);
+ return;
+ }
-void ro_gui_dialog_open_config(void)
-{
- ro_gui_dialog_config_prepare();
- ro_gui_set_icon_selected_state(dialog_config, ICON_CONFIG_BROWSER,
- true);
- ro_gui_set_icon_selected_state(dialog_config, ICON_CONFIG_PROXY,
- false);
- ro_gui_set_icon_selected_state(dialog_config, ICON_CONFIG_THEME,
- false);
- ro_gui_set_icon_selected_state(dialog_config, ICON_CONFIG_FONT,
- false);
- ro_gui_set_icon_selected_state(dialog_config, ICON_CONFIG_IMAGE,
- false);
- ro_gui_dialog_open(dialog_config);
- ro_gui_open_pane(dialog_config, dialog_config_br, 0);
+ /* move to the centre of the parent at the top of the stack */
+ dimension = state.visible.x1 - state.visible.x0;
+ scroll_width = ro_get_vscroll_width(history_window);
+ state.visible.x0 = mid_x - (dimension + scroll_width) / 2;
+ state.visible.x1 = state.visible.x0 + dimension;
+ dimension = state.visible.y1 - state.visible.y0;
+ state.visible.y0 = mid_y - dimension / 2;
+ state.visible.y1 = state.visible.y0 + dimension;
+ state.next = wimp_TOP;
+ ro_gui_open_window_request((wimp_open*)&state);
}
/**
- * Set the choices panes with the current options.
+ * Open a persistent dialog box relative to the pointer.
+ *
+ * \param parent the owning window (NULL for no owner)
+ * \param w the dialog window
+ * \param pointer open the window at the pointer (centre of the parent
+ * otherwise)
*/
-void ro_gui_dialog_config_prepare(void)
-{
- /* browser pane */
- ro_gui_choices_lang = option_language;
- ro_gui_choices_alang = option_accept_language;
- ro_gui_set_icon_string(dialog_config_br, ICON_CONFIG_BR_LANG,
- language_name(option_language ?
- option_language : "en"));
- ro_gui_set_icon_string(dialog_config_br, ICON_CONFIG_BR_ALANG,
- language_name(option_accept_language ?
- option_accept_language : "en"));
- ro_gui_set_icon_string(dialog_config_br, ICON_CONFIG_BR_HOMEPAGE,
- option_homepage_url ? option_homepage_url : "");
- ro_gui_set_icon_selected_state(dialog_config_br,
- ICON_CONFIG_BR_OPENBROWSER,
- option_open_browser_at_startup);
- ro_gui_set_icon_selected_state(dialog_config_br,
- ICON_CONFIG_BR_BLOCKADS,
- option_block_ads);
- ro_gui_set_icon_selected_state(dialog_config_br,
- ICON_CONFIG_BR_PLUGINS,
- option_no_plugins);
-
- /* proxy pane */
- ro_gui_choices_http_proxy = option_http_proxy;
- ro_gui_set_icon_selected_state(dialog_config_prox,
- ICON_CONFIG_PROX_HTTP,
- option_http_proxy);
- ro_gui_set_icon_string(dialog_config_prox, ICON_CONFIG_PROX_HTTPHOST,
- option_http_proxy_host ? option_http_proxy_host : "");
- ro_gui_set_icon_integer(dialog_config_prox, ICON_CONFIG_PROX_HTTPPORT,
- option_http_proxy_port);
- ro_gui_choices_http_proxy_auth = option_http_proxy_auth;
- ro_gui_set_icon_string(dialog_config_prox,
- ICON_CONFIG_PROX_AUTHTYPE,
- messages_get(ro_gui_proxy_auth_name[
- ro_gui_choices_http_proxy_auth]));
- ro_gui_set_icon_string(dialog_config_prox, ICON_CONFIG_PROX_AUTHUSER,
- option_http_proxy_auth_user ?
- option_http_proxy_auth_user : "");
- ro_gui_set_icon_string(dialog_config_prox, ICON_CONFIG_PROX_AUTHPASS,
- option_http_proxy_auth_pass ?
- option_http_proxy_auth_pass : "");
- ro_gui_set_icon_selected_state(dialog_config_prox,
- ICON_CONFIG_PROX_REFERER, option_send_referer);
- ro_gui_dialog_config_proxy_update();
-
- /* themes pane */
- ro_gui_dialog_load_themes();
- theme_choice = ro_gui_theme_find(option_theme);
-
- /* font pane */
- ro_gui_choices_font_size = option_font_size;
- ro_gui_choices_font_min_size = option_font_min_size;
- ro_gui_dialog_update_config_font();
- ro_gui_set_icon_string(dialog_config_font, ICON_CONFIG_FONT_SANS,
- option_font_sans);
- ro_gui_set_icon_string(dialog_config_font, ICON_CONFIG_FONT_SERIF,
- option_font_serif);
- ro_gui_set_icon_string(dialog_config_font, ICON_CONFIG_FONT_MONO,
- option_font_mono);
- ro_gui_set_icon_string(dialog_config_font, ICON_CONFIG_FONT_CURS,
- option_font_cursive);
- ro_gui_set_icon_string(dialog_config_font, ICON_CONFIG_FONT_FANT,
- option_font_fantasy);
- ro_gui_set_icon_string(dialog_config_font, ICON_CONFIG_FONT_DEF,
- css_font_family_name[option_font_default]);
-
- /* image pane */
- ro_gui_choices_fg_plot_style = option_fg_plot_style;
- ro_gui_choices_bg_plot_style = option_bg_plot_style;
- ro_gui_dialog_set_image_quality(ICON_CONFIG_IMG_FG_DISP,
- option_fg_plot_style);
- ro_gui_dialog_set_image_quality(ICON_CONFIG_IMG_BG_DISP,
- option_bg_plot_style);
-}
-
+void ro_gui_dialog_open_persistent(wimp_w parent, wimp_w w, bool pointer) {
-/**
- * Set an icon in the Image config window with Tinct options.
- */
+ if (pointer)
+ ro_gui_dialog_open_at_pointer(w);
+ else
+ ro_gui_dialog_open_centre_parent(parent, w);
-void ro_gui_dialog_set_image_quality(int icon, unsigned int tinct_options)
-{
- int i = 1;
- if (tinct_options & tinct_USE_OS_SPRITE_OP) {
- i = 0;
- } else if (tinct_options & tinct_ERROR_DIFFUSE) {
- i = 3;
- } else if (tinct_options & tinct_DITHER) {
- i = 2;
- }
- ro_gui_set_icon_string(dialog_config_image, icon,
- messages_get(ro_gui_image_name[i]));
- ro_gui_set_icon_selected_state(dialog_config_image, icon + 3,
- (tinct_options & tinct_BILINEAR_FILTER));
+ /* todo: use wimp_event definitions rather than special cases */
+ if ((w == dialog_pageinfo) || (w == dialog_objinfo))
+ ro_gui_wimp_update_window_furniture(w, wimp_WINDOW_CLOSE_ICON,
+ wimp_WINDOW_CLOSE_ICON);
+ ro_gui_dialog_add_persistent(parent, w);
+ ro_gui_set_caret_first(w);
}
-/**
- * Set the current options to the settings in the choices panes.
- */
-
-void ro_gui_dialog_config_set(void)
-{
- char *font_default;
-
- /* browser pane */
- if (option_homepage_url)
- free(option_homepage_url);
- option_homepage_url = strdup(ro_gui_get_icon_string(dialog_config_br,
- ICON_CONFIG_BR_HOMEPAGE));
- option_open_browser_at_startup = ro_gui_get_icon_selected_state(
- dialog_config_br,
- ICON_CONFIG_BR_OPENBROWSER);
- option_block_ads = ro_gui_get_icon_selected_state(
- dialog_config_br,
- ICON_CONFIG_BR_BLOCKADS);
- option_no_plugins = ro_gui_get_icon_selected_state(
- dialog_config_br,
- ICON_CONFIG_BR_PLUGINS);
- if (ro_gui_choices_lang != option_language) {
- free(option_language);
- option_language = strdup(ro_gui_choices_lang);
- ro_gui_choices_lang = option_language;
- }
- if (ro_gui_choices_alang != option_accept_language) {
- free(option_accept_language);
- option_accept_language = strdup(ro_gui_choices_alang);
- ro_gui_choices_alang = option_accept_language;
- }
+void ro_gui_dialog_add_persistent(wimp_w parent, wimp_w w) {
+ int i;
- /* proxy pane */
- option_http_proxy = ro_gui_choices_http_proxy;
- if (option_http_proxy_host)
- free(option_http_proxy_host);
- option_http_proxy_host = strdup(ro_gui_get_icon_string(
- dialog_config_prox,
- ICON_CONFIG_PROX_HTTPHOST));
- option_http_proxy_port = atoi(ro_gui_get_icon_string(dialog_config_prox,
- ICON_CONFIG_PROX_HTTPPORT));
- option_http_proxy_auth = ro_gui_choices_http_proxy_auth;
- if (option_http_proxy_auth_user)
- free(option_http_proxy_auth_user);
- option_http_proxy_auth_user = strdup(ro_gui_get_icon_string(
- dialog_config_prox,
- ICON_CONFIG_PROX_AUTHUSER));
- if (option_http_proxy_auth_pass)
- free(option_http_proxy_auth_pass);
- option_http_proxy_auth_pass = strdup(ro_gui_get_icon_string(
- dialog_config_prox,
- ICON_CONFIG_PROX_AUTHPASS));
- option_send_referer = ro_gui_get_icon_selected_state(
- dialog_config_prox,
- ICON_CONFIG_PROX_REFERER);
-
- /* theme pane */
- if (option_theme) {
- free(option_theme);
- option_theme = NULL;
- }
- if (theme_choice) {
- option_theme = strdup(theme_choice->leafname);
- ro_gui_theme_apply(theme_choice);
- }
+ /* all persistant windows have a back icon */
+ ro_gui_wimp_update_window_furniture(w, wimp_WINDOW_BACK_ICON,
+ wimp_WINDOW_BACK_ICON);
- /* font pane */
- option_font_size = ro_gui_choices_font_size;
- option_font_min_size = ro_gui_choices_font_min_size;
- free(option_font_sans);
- option_font_sans = strdup(ro_gui_get_icon_string(dialog_config_font,
- ICON_CONFIG_FONT_SANS));
- free(option_font_serif);
- option_font_serif = strdup(ro_gui_get_icon_string(dialog_config_font,
- ICON_CONFIG_FONT_SERIF));
- free(option_font_mono);
- option_font_mono = strdup(ro_gui_get_icon_string(dialog_config_font,
- ICON_CONFIG_FONT_MONO));
- free(option_font_cursive);
- option_font_cursive = strdup(ro_gui_get_icon_string(
- dialog_config_font, ICON_CONFIG_FONT_CURS));
- free(option_font_fantasy);
- option_font_fantasy = strdup(ro_gui_get_icon_string(
- dialog_config_font, ICON_CONFIG_FONT_FANT));
- font_default = ro_gui_get_icon_string(dialog_config_font,
- ICON_CONFIG_FONT_DEF);
- option_font_default = css_font_family_parse(font_default,
- strlen(font_default));
-
- /* image pane */
- if ((option_fg_plot_style != (int)ro_gui_choices_fg_plot_style) ||
- (option_bg_plot_style !=
- (int) ro_gui_choices_bg_plot_style)) {
- option_fg_plot_style = ro_gui_choices_fg_plot_style;
- option_bg_plot_style = ro_gui_choices_bg_plot_style;
- ro_gui_window_redraw_all();
+ /* Add a mapping
+ */
+ if ((parent == NULL) || (parent == wimp_ICON_BAR))
+ return;
+ for (i = 0; i < MAX_PERSISTENT; i++) {
+ if (persistent_dialog[i].dialog == NULL ||
+ persistent_dialog[i].dialog == w) {
+ persistent_dialog[i].dialog = w;
+ persistent_dialog[i].parent = parent;
+ return;
+ }
}
+ LOG(("Unable to map persistent dialog to parent."));
+ return;
}
/**
- * Handle clicks in the main Choices dialog.
+ * Close persistent dialogs associated with a window.
+ *
+ * \param parent the window to close children of
*/
-void ro_gui_dialog_click_config(wimp_pointer *pointer)
-{
- wimp_window_state state;
- switch (pointer->i) {
- case ICON_CONFIG_SAVE:
- ro_gui_dialog_config_set();
- ro_gui_save_options();
- if (pointer->buttons == wimp_CLICK_SELECT) {
- ro_gui_dialog_close(dialog_config);
- ro_gui_dialog_free_themes();
- }
- break;
- case ICON_CONFIG_CANCEL:
- if (pointer->buttons == wimp_CLICK_SELECT) {
- ro_gui_dialog_close(dialog_config);
- ro_gui_dialog_free_themes();
- } else {
- ro_gui_dialog_config_prepare();
- }
- break;
- case ICON_CONFIG_BROWSER:
- /* set selected state of radio icon to prevent
- * de-selection of all radio icons */
- if (pointer->buttons == wimp_CLICK_ADJUST)
- ro_gui_set_icon_selected_state(dialog_config,
- ICON_CONFIG_BROWSER, true);
- ro_gui_open_pane(dialog_config, dialog_config_br, 0);
- break;
- case ICON_CONFIG_PROXY:
- if (pointer->buttons == wimp_CLICK_ADJUST)
- ro_gui_set_icon_selected_state(dialog_config,
- ICON_CONFIG_PROXY, true);
- ro_gui_open_pane(dialog_config, dialog_config_prox, 0);
- break;
- case ICON_CONFIG_THEME:
- if (pointer->buttons == wimp_CLICK_ADJUST)
- ro_gui_set_icon_selected_state(dialog_config,
- ICON_CONFIG_THEME, true);
- ro_gui_open_pane(dialog_config, dialog_config_th, 0);
- state.w = dialog_config_th;
- xwimp_get_window_state(&state);
- state.w = dialog_config_th_pane;
- state.visible.x0 += 12;
- state.visible.x1 -= 12;
- state.visible.y0 += 128;
- state.visible.y1 -= 12;
- xwimp_open_window_nested((wimp_open *) &state,
- dialog_config_th,
- wimp_CHILD_LINKS_PARENT_VISIBLE_BOTTOM_OR_LEFT
- << wimp_CHILD_XORIGIN_SHIFT |
- wimp_CHILD_LINKS_PARENT_VISIBLE_TOP_OR_RIGHT
- << wimp_CHILD_YORIGIN_SHIFT |
- wimp_CHILD_LINKS_PARENT_VISIBLE_BOTTOM_OR_LEFT
- << wimp_CHILD_LS_EDGE_SHIFT |
- wimp_CHILD_LINKS_PARENT_VISIBLE_TOP_OR_RIGHT
- << wimp_CHILD_BS_EDGE_SHIFT |
- wimp_CHILD_LINKS_PARENT_VISIBLE_TOP_OR_RIGHT
- << wimp_CHILD_RS_EDGE_SHIFT |
- wimp_CHILD_LINKS_PARENT_VISIBLE_TOP_OR_RIGHT
- << wimp_CHILD_TS_EDGE_SHIFT);
- break;
- case ICON_CONFIG_FONT:
- if (pointer->buttons == wimp_CLICK_ADJUST)
- ro_gui_set_icon_selected_state(dialog_config,
- ICON_CONFIG_FONT, true);
- ro_gui_open_pane(dialog_config, dialog_config_font, 0);
- break;
- case ICON_CONFIG_IMAGE:
- if (pointer->buttons == wimp_CLICK_ADJUST)
- ro_gui_set_icon_selected_state(dialog_config,
- ICON_CONFIG_IMAGE, true);
- ro_gui_open_pane(dialog_config, dialog_config_image, 0);
- break;
+void ro_gui_dialog_close_persistent(wimp_w parent) {
+ int i;
+
+ /* Check our mappings
+ */
+ for (i = 0; i < MAX_PERSISTENT; i++) {
+ if (persistent_dialog[i].parent == parent &&
+ persistent_dialog[i].dialog != NULL) {
+ ro_gui_dialog_close(persistent_dialog[i].dialog);
+ persistent_dialog[i].dialog = NULL;
+ }
}
}
@@ -833,408 +615,38 @@ void ro_gui_save_options(void)
/**
- * Handle clicks in the Browser Choices pane.
- */
-
-void ro_gui_dialog_click_config_br(wimp_pointer *pointer)
-{
- switch (pointer->i) {
- case ICON_CONFIG_BR_LANG_PICK:
- ro_gui_menu_prepare_languages(false, ro_gui_choices_lang);
- config_br_icon = pointer->i;
- ro_gui_popup_menu(languages_menu, dialog_config_br,
- pointer->i);
- break;
- case ICON_CONFIG_BR_ALANG_PICK:
- ro_gui_menu_prepare_languages(true, ro_gui_choices_alang);
- config_br_icon = pointer->i;
- ro_gui_popup_menu(languages_menu, dialog_config_br,
- pointer->i);
- break;
- }
-}
-
-/**
- * Handle a selection from the language selection popup menu.
- *
- * \param lang The language messages key
- */
-
-void ro_gui_dialog_languages_menu_selection(const char *lang)
-{
- int offset = strlen("lang_");
-
- switch (config_br_icon) {
- case ICON_CONFIG_BR_LANG_PICK:
- ro_gui_choices_lang = lang + offset;
- ro_gui_set_icon_string(dialog_config_br, ICON_CONFIG_BR_LANG,
- messages_get(lang));
- ro_gui_menu_prepare_languages(false, ro_gui_choices_lang);
- break;
- case ICON_CONFIG_BR_ALANG_PICK:
- ro_gui_choices_alang = lang + offset;
- ro_gui_set_icon_string(dialog_config_br,
- ICON_CONFIG_BR_ALANG, messages_get(lang));
- ro_gui_menu_prepare_languages(true, ro_gui_choices_alang);
- break;
- }
-}
-
-
-/**
- * Handle clicks in the Proxy Choices pane.
- */
-
-void ro_gui_dialog_click_config_prox(wimp_pointer *pointer)
-{
- switch (pointer->i) {
- case ICON_CONFIG_PROX_HTTP:
- ro_gui_choices_http_proxy = !ro_gui_choices_http_proxy;
- ro_gui_dialog_config_proxy_update();
- break;
- case ICON_CONFIG_PROX_AUTHTYPE_PICK:
- ro_gui_popup_menu(proxy_auth_menu, dialog_config_prox,
- ICON_CONFIG_PROX_AUTHTYPE_PICK);
- break;
- }
-}
-
-
-/**
- * Handle clicks in the Proxy Choices pane.
- */
-
-void ro_gui_dialog_click_config_image(wimp_pointer *pointer)
-{
- switch (pointer->i) {
- case ICON_CONFIG_IMG_FG_MENU:
- ro_gui_choices_image_edit_type = 1;
- ro_gui_menu_prepare_image_quality(ro_gui_choices_fg_plot_style);
- ro_gui_popup_menu(image_quality_menu, dialog_config_image,
- pointer->i);
- break;
- case ICON_CONFIG_IMG_FG_FILTER:
- if (ro_gui_get_icon_selected_state(dialog_config_image,
- ICON_CONFIG_IMG_FG_FILTER)) {
- ro_gui_choices_fg_plot_style |= tinct_BILINEAR_FILTER;
- } else {
- ro_gui_choices_fg_plot_style &= ~tinct_BILINEAR_FILTER;
- }
- break;
- case ICON_CONFIG_IMG_BG_MENU:
- ro_gui_choices_image_edit_type = 2;
- ro_gui_menu_prepare_image_quality(ro_gui_choices_bg_plot_style);
- ro_gui_popup_menu(image_quality_menu, dialog_config_image,
- pointer->i);
- break;
- case ICON_CONFIG_IMG_BG_FILTER:
- if (ro_gui_get_icon_selected_state(dialog_config_image,
- ICON_CONFIG_IMG_BG_FILTER)) {
- ro_gui_choices_bg_plot_style |= tinct_BILINEAR_FILTER;
- } else {
- ro_gui_choices_bg_plot_style &= ~tinct_BILINEAR_FILTER;
- }
- break;
- }
-}
-
-
-/**
- * Handle a selection from the proxy auth method popup menu.
- */
-
-void ro_gui_dialog_proxyauth_menu_selection(int item)
-{
- ro_gui_choices_http_proxy_auth = item;
- ro_gui_set_icon_string(dialog_config_prox,
- ICON_CONFIG_PROX_AUTHTYPE,
- messages_get(ro_gui_proxy_auth_name[
- ro_gui_choices_http_proxy_auth]));
- ro_gui_dialog_config_proxy_update();
-}
-
-
-/**
- * Handle a selection from the image quality popup menu.
- */
-
-void ro_gui_dialog_image_menu_selection(int item)
-{
- unsigned int tinct_options = 0;
- if (item == 0) {
- tinct_options = tinct_USE_OS_SPRITE_OP;
- } else if (item == 2) {
- tinct_options = tinct_DITHER;
- } else if (item == 3) {
- tinct_options = tinct_ERROR_DIFFUSE;
- }
- if (ro_gui_choices_image_edit_type == 1) {
- ro_gui_choices_fg_plot_style &= tinct_BILINEAR_FILTER;
- ro_gui_choices_fg_plot_style |= tinct_options;
- ro_gui_dialog_set_image_quality(ICON_CONFIG_IMG_FG_DISP,
- ro_gui_choices_fg_plot_style);
- } else {
- ro_gui_choices_bg_plot_style &= tinct_BILINEAR_FILTER;
- ro_gui_choices_bg_plot_style |= tinct_options;
- ro_gui_dialog_set_image_quality(ICON_CONFIG_IMG_BG_DISP,
- ro_gui_choices_bg_plot_style);
- }
- ro_gui_menu_prepare_image_quality(tinct_options);
-}
-
-
-/**
- * Update greying of icons in the proxy choices pane.
- */
-
-void ro_gui_dialog_config_proxy_update(void)
-{
- int icon;
- for (icon = ICON_CONFIG_PROX_HTTPHOST;
- icon <= ICON_CONFIG_PROX_AUTHTYPE_PICK;
- icon++)
- ro_gui_set_icon_shaded_state(dialog_config_prox,
- icon, !ro_gui_choices_http_proxy);
- for (icon = ICON_CONFIG_PROX_AUTHTYPE_PICK + 1;
- icon <= ICON_CONFIG_PROX_AUTHPASS;
- icon++)
- ro_gui_set_icon_shaded_state(dialog_config_prox,
- icon, !ro_gui_choices_http_proxy ||
- ro_gui_choices_http_proxy_auth ==
- OPTION_HTTP_PROXY_AUTH_NONE);
-}
-
-
-/**
- * Handle clicks in the Theme Choices pane.
- */
-
-void ro_gui_dialog_click_config_th(wimp_pointer *pointer)
-{
- switch (pointer->i) {
- case ICON_CONFIG_TH_MANAGE:
- os_cli("Filer_OpenDir Choices:WWW.NetSurf.Themes");
- break;
- case ICON_CONFIG_TH_GET:
- browser_window_create(
- "http://netsurf.sourceforge.net/themes/",
- NULL, 0);
- break;
- }
-}
-
-
-#define THEME_HEIGHT 80
-#define THEME_WIDTH 705
-
-/**
- * Handle clicks in the scrolling Theme Choices list pane.
- */
-void ro_gui_dialog_click_config_th_pane(wimp_pointer *pointer) {
- struct toolbar_display *link;
- int i = pointer->i;
- if (i < 0) return;
-
- /* Set the clicked theme as selected
- */
- link = toolbars;
- while (link) {
- if ((link->icon_number == i) || (link->icon_number == (i - 1))) {
- theme_choice = link->descriptor;
- ro_gui_set_icon_selected_state(dialog_config_th_pane,
- link->icon_number, true);
- } else {
- ro_gui_set_icon_selected_state(dialog_config_th_pane,
- link->icon_number, false);
- }
- link = link->next;
- }
-}
-
-
-/**
- * Update font size icons in font choices pane.
- */
-
-void ro_gui_dialog_update_config_font(void)
-{
- char s[10];
- sprintf(s, "%i.%ipt", ro_gui_choices_font_size / 10,
- ro_gui_choices_font_size % 10);
- ro_gui_set_icon_string(dialog_config_font,
- ICON_CONFIG_FONT_FONTSIZE, s);
- sprintf(s, "%i.%ipt", ro_gui_choices_font_min_size / 10,
- ro_gui_choices_font_min_size % 10);
- ro_gui_set_icon_string(dialog_config_font,
- ICON_CONFIG_FONT_MINSIZE, s);
-}
-
-
-/**
- * Handle clicks in the font choices pane
- */
-
-void ro_gui_dialog_click_config_font(wimp_pointer *pointer)
-{
- int stepping = 1;
-
- if (pointer->buttons == wimp_CLICK_ADJUST)
- stepping = -stepping;
-
- switch (pointer->i) {
- case ICON_CONFIG_FONT_FONTSIZE_DEC:
- ro_gui_choices_font_size -= stepping;
- if (ro_gui_choices_font_size < 50)
- ro_gui_choices_font_size = 50;
- if (ro_gui_choices_font_size > 1000)
- ro_gui_choices_font_size = 1000;
-
- if (ro_gui_choices_font_size <
- ro_gui_choices_font_min_size)
- ro_gui_choices_font_min_size =
- ro_gui_choices_font_size;
- ro_gui_dialog_update_config_font();
- break;
- case ICON_CONFIG_FONT_FONTSIZE_INC:
- ro_gui_choices_font_size += stepping;
- if (ro_gui_choices_font_size < 50)
- ro_gui_choices_font_size = 50;
- if (ro_gui_choices_font_size > 1000)
- ro_gui_choices_font_size = 1000;
- ro_gui_dialog_update_config_font();
- break;
- case ICON_CONFIG_FONT_MINSIZE_DEC:
- ro_gui_choices_font_min_size -= stepping;
- if (ro_gui_choices_font_min_size < 10)
- ro_gui_choices_font_min_size = 10;
- if (ro_gui_choices_font_min_size > 500)
- ro_gui_choices_font_min_size = 500;
- ro_gui_dialog_update_config_font();
- break;
- case ICON_CONFIG_FONT_MINSIZE_INC:
- ro_gui_choices_font_min_size += stepping;
- if (ro_gui_choices_font_min_size < 10)
- ro_gui_choices_font_min_size = 10;
- if (ro_gui_choices_font_min_size > 500)
- ro_gui_choices_font_min_size = 500;
-
- if (ro_gui_choices_font_size <
- ro_gui_choices_font_min_size)
- ro_gui_choices_font_size =
- ro_gui_choices_font_min_size;
- ro_gui_dialog_update_config_font();
- break;
- case ICON_CONFIG_FONT_SANS:
- case ICON_CONFIG_FONT_SANS_PICK:
- case ICON_CONFIG_FONT_SERIF:
- case ICON_CONFIG_FONT_SERIF_PICK:
- case ICON_CONFIG_FONT_MONO:
- case ICON_CONFIG_FONT_MONO_PICK:
- case ICON_CONFIG_FONT_CURS:
- case ICON_CONFIG_FONT_CURS_PICK:
- case ICON_CONFIG_FONT_FANT:
- case ICON_CONFIG_FONT_FANT_PICK:
- config_font_icon = pointer->i & ~1;
- ro_gui_popup_menu(font_menu, dialog_config_font,
- pointer->i | 1);
- break;
- case ICON_CONFIG_FONT_DEF_PICK:
- break;
- }
-}
-
-
-/**
- * Handle font menu selections.
- */
-
-void ro_gui_dialog_font_menu_selection(int item)
-{
- if (item < 0 || rufl_family_list_entries <= (unsigned int) item)
- return;
- ro_gui_set_icon_string(dialog_config_font, config_font_icon,
- rufl_family_list[item]);
-}
-
-
-/**
- * Ensure that a scale percentage lies within a sensible range.
- *
- * \param scale scale percentage
- * \return corrected scale value
- */
-
-unsigned ro_gui_clamp_scale(unsigned scale)
-{
- if (scale < 10)
- scale = 10;
- else if (1600 < scale)
- scale = 1600;
- return scale;
-}
-
-
-/**
* Handle clicks in the Scale view dialog.
*/
-void ro_gui_dialog_click_zoom(wimp_pointer *pointer)
+bool ro_gui_dialog_zoom_click(wimp_pointer *pointer)
{
- unsigned int scale;
- int stepping = 10;
- scale = atoi(ro_gui_get_icon_string(dialog_zoom, ICON_ZOOM_VALUE));
-
- /* Adjust moves values the opposite direction
- */
- if (pointer->buttons == wimp_CLICK_ADJUST)
- stepping = -stepping;
-
switch (pointer->i) {
- case ICON_ZOOM_DEC: scale -= stepping; break;
- case ICON_ZOOM_INC: scale += stepping; break;
- case ICON_ZOOM_75: scale = 75; break;
- case ICON_ZOOM_100: scale = 100; break;
- case ICON_ZOOM_150: scale = 150; break;
- case ICON_ZOOM_200: scale = 200; break;
- }
-
- scale = ro_gui_clamp_scale(scale);
- ro_gui_set_icon_integer(dialog_zoom, ICON_ZOOM_VALUE, scale);
-
- if (pointer->i == ICON_ZOOM_OK)
- ro_gui_window_set_scale(ro_gui_current_zoom_gui, scale * 0.01);
-
- if (pointer->buttons == wimp_CLICK_ADJUST &&
- pointer->i == ICON_ZOOM_CANCEL)
- ro_gui_dialog_prepare_zoom(ro_gui_current_zoom_gui);
-
- if (pointer->buttons == wimp_CLICK_SELECT &&
- (pointer->i == ICON_ZOOM_CANCEL ||
- pointer->i == ICON_ZOOM_OK)) {
- ro_gui_dialog_close(dialog_zoom);
- ro_gui_menu_closed();
+ case ICON_ZOOM_75:
+ ro_gui_set_icon_integer(dialog_zoom,
+ ICON_ZOOM_VALUE, 75);
+ return true;
+ case ICON_ZOOM_100:
+ ro_gui_set_icon_integer(dialog_zoom,
+ ICON_ZOOM_VALUE, 100);
+ return true;
+ case ICON_ZOOM_150:
+ ro_gui_set_icon_integer(dialog_zoom,
+ ICON_ZOOM_VALUE, 150);
+ return true;
+ case ICON_ZOOM_200:
+ ro_gui_set_icon_integer(dialog_zoom,
+ ICON_ZOOM_VALUE, 200);
+ return true;
}
+ return false;
}
+bool ro_gui_dialog_zoom_apply(wimp_w w) {
+ unsigned int scale;
-/**
- * Handle keypresses in the Scale view dialog.
- *
- * \param key keypress info from Wimp
- */
-
-bool ro_gui_zoom_keypress(wimp_key *key)
-{
- if (key->c == wimp_KEY_RETURN) {
- unsigned int scale;
- scale = atoi(ro_gui_get_icon_string(dialog_zoom, ICON_ZOOM_VALUE));
- scale = ro_gui_clamp_scale(scale);
- ro_gui_window_set_scale(ro_gui_current_zoom_gui, scale * 0.01);
- ro_gui_dialog_close(dialog_zoom);
- ro_gui_menu_closed();
- return true;
- }
- return false;
+ scale = atoi(ro_gui_get_icon_string(w, ICON_ZOOM_VALUE));
+ ro_gui_window_set_scale(ro_gui_current_zoom_gui, scale * 0.01);
+ return true;
}
@@ -1249,98 +661,24 @@ void ro_gui_dialog_prepare_zoom(struct gui_window *g)
ro_gui_set_icon_string(dialog_zoom, ICON_ZOOM_VALUE, scale_buffer);
ro_gui_current_zoom_gui = g;
+ ro_gui_wimp_event_memorise(dialog_zoom);
}
-/**
- * Handle clicks in the Open URL dialog.
- */
-
-void ro_gui_dialog_click_open_url(wimp_pointer *pointer)
-{
- wimp_window_state open;
+bool ro_gui_dialog_openurl_apply(wimp_w w) {
url_func_result res;
const char *url;
char *url2;
- bool reopen_window = false;
- wimp_caret caret;
- os_error *error;
-
- if (pointer->i == ICON_OPENURL_MENU) {
- /* we can't have two open menus, so we close the iconbar menu
- * and detach our window from it */
- if (current_menu == iconbar_menu) {
- reopen_window = true;
- open.w = dialog_openurl;
- error = xwimp_get_window_state(&open);
- if (error) {
- LOG(("xwimp_get_window_state: 0x%x: %s",
- error->errnum, error->errmess));
- warn_user("WimpError", error->errmess);
- return;
- }
- error = xwimp_get_caret_position(&caret);
- if (error) {
- LOG(("xwimp_get_caret_position: 0x%x: %s",
- error->errnum, error->errmess));
- warn_user("WimpError", error->errmess);
- return;
- }
- ro_gui_menu_closed();
- gui_poll(true);
- ro_gui_wimp_update_window_furniture(dialog_openurl,
- wimp_WINDOW_BACK_ICON,
- wimp_WINDOW_BACK_ICON);
- error = xwimp_open_window((wimp_open *) &open);
- if (error) {
- LOG(("xwimp_open_window: 0x%x: %s",
- error->errnum, error->errmess));
- warn_user("WimpError", error->errmess);
- return;
- }
- if (caret.w == dialog_openurl) {
- error = xwimp_set_caret_position(dialog_openurl,
- ICON_OPENURL_URL,
- caret.pos.x, caret.pos.y,
- -1, caret.index);
- if (error) {
- LOG(("xwimp_set_caret_position: 0x%x: %s",
- error->errnum, error->errmess));
- warn_user("WimpError", error->errmess);
- }
- }
- }
- ro_gui_popup_menu(url_suggest_menu,
- dialog_openurl,
- ICON_OPENURL_MENU);
- return;
- }
-
- if ((pointer->i != ICON_OPENURL_OPEN) &&
- (pointer->i != ICON_OPENURL_CANCEL))
- return;
-
- if (pointer->i == ICON_OPENURL_OPEN) {
- url = ro_gui_get_icon_string(dialog_openurl,
- ICON_OPENURL_URL);
- res = url_normalize(url, &url2);
- if (res == URL_FUNC_OK) {
- browser_window_create(url2, 0, 0);
- global_history_add_recent(url2);
- free(url2);
- }
- }
-
- if (pointer->buttons == wimp_CLICK_ADJUST &&
- pointer->i == ICON_OPENURL_CANCEL)
- ro_gui_dialog_prepare_open_url();
-
- if (pointer->buttons == wimp_CLICK_SELECT) {
- ro_gui_dialog_close(dialog_openurl);
- ro_gui_menu_closed();
+ url = ro_gui_get_icon_string(w, ICON_OPENURL_URL);
+ res = url_normalize(url, &url2);
+ if (res == URL_FUNC_OK) {
+ browser_window_create(url2, 0, 0);
+ global_history_add_recent(url2);
+ free(url2);
+ return true;
}
-
+ return false;
}
@@ -1355,277 +693,5 @@ void ro_gui_dialog_prepare_open_url(void)
global_history_get_recent(&suggestions);
ro_gui_set_icon_shaded_state(dialog_openurl,
ICON_OPENURL_MENU, (suggestions <= 0));
-}
-
-
-/**
- * Handle clicks in the warning dialog.
- */
-
-void ro_gui_dialog_click_warning(wimp_pointer *pointer)
-{
- if (pointer->i == ICON_WARNING_CONTINUE)
- ro_gui_dialog_close(dialog_warning);
-}
-
-
-/**
- * Close a dialog box.
- */
-
-void ro_gui_dialog_close(wimp_w close)
-{
- int i;
- wimp_caret caret;
- os_error *error;
-
- /* Give the caret back to the parent window. This code relies on
- the fact that only tree windows and browser windows open
- persistent dialogues, as the caret gets placed to no icon.
- */
- error = xwimp_get_caret_position(&caret);
- if (error) {
- LOG(("xwimp_get_caret_position: 0x%x: %s",
- error->errnum, error->errmess));
- warn_user("WimpError", error->errmess);
- } else if (caret.w == close) {
- /* Check if we are a persistent window
- */
- for (i = 0; i < MAX_PERSISTENT; i++) {
- if (persistent_dialog[i].dialog == close) {
- persistent_dialog[i].dialog = NULL;
- error = xwimp_set_caret_position(
- persistent_dialog[i].parent,
- wimp_ICON_WINDOW, -100, -100,
- 32, -1);
- if (error) {
- LOG(("xwimp_set_caret_position: "
- "0x%x: %s",
- error->errnum,
- error->errmess));
- warn_user("WimpError", error->errmess);
- }
- break;
- }
- }
- }
-
- error = xwimp_close_window(close);
- if (error) {
- LOG(("xwimp_close_window: 0x%x: %s",
- error->errnum, error->errmess));
- warn_user("WimpError", error->errmess);
- }
-}
-
-
-/**
- * Convert a 2-letter ISO language code to the language name.
- *
- * \param code 2-letter ISO language code
- * \return language name, or code if unknown
- */
-
-const char *language_name(const char *code)
-{
- char key[] = "lang_xx";
- key[5] = code[0];
- key[6] = code[1];
- return messages_get(key);
-}
-
-
-/**
- * Loads and nests all available themes in the theme pane.
- */
-
-void ro_gui_dialog_load_themes(void)
-{
- os_error *error;
- os_box extent = { 0, 0, 0, 0 };
- struct theme_descriptor *descriptor;
- struct toolbar_display *link;
- struct toolbar_display *toolbar_display;
- struct toolbar *toolbar;
- wimp_icon_create new_icon;
- wimp_window_state state;
- int parent_width, nested_y, min_extent, base_extent;
- int item_height;
-
- /* Delete our old list and get/open a new one
- */
- ro_gui_dialog_free_themes();
- theme_list = ro_gui_theme_get_available();
- ro_gui_theme_open(theme_list, true);
- theme_choice = ro_gui_theme_find(option_theme);
-
- /* Create toolbars for each theme
- */
- theme_count = 0;
- descriptor = theme_list;
- while (descriptor) {
- /* Try to create a toolbar
- */
- toolbar = ro_gui_theme_create_toolbar(descriptor,
- THEME_BROWSER_TOOLBAR);
- if (toolbar) {
- toolbar_display = calloc(sizeof(struct toolbar_display), 1);
- if (!toolbar_display) {
- LOG(("No memory for calloc()"));
- warn_user("NoMemory", 0);
- return;
- }
- toolbar_display->toolbar = toolbar;
- toolbar_display->descriptor = descriptor;
- if (!toolbars) {
- toolbars = toolbar_display;
- } else {
- link = toolbars;
- while (link->next) link = link->next;
- link->next = toolbar_display;
- }
- theme_count++;
- }
- descriptor = descriptor->next;
- }
-
- /* Nest the toolbars
- */
- state.w = dialog_config_th_pane;
- error = xwimp_get_window_state(&state);
- if (error) {
- LOG(("xwimp_get_window_state: 0x%x: %s",
- error->errnum, error->errmess));
- warn_user("WimpError", error->errmess);
- return;
- }
-
- parent_width = state.visible.x1 - state.visible.x0;
- min_extent = state.visible.y0 - state.visible.y1;
- nested_y = 0;
- base_extent = state.visible.y1 - state.yscroll;
- extent.x1 = parent_width;
- link = toolbars;
- new_icon.w = dialog_config_th_pane;
- new_icon.icon.flags = wimp_ICON_TEXT | wimp_ICON_INDIRECTED |
- wimp_ICON_VCENTRED |
- (wimp_COLOUR_BLACK << wimp_ICON_FG_COLOUR_SHIFT) |
- (wimp_COLOUR_VERY_LIGHT_GREY << wimp_ICON_BG_COLOUR_SHIFT) |
- (wimp_BUTTON_CLICK << wimp_ICON_BUTTON_TYPE_SHIFT);
- while (link) {
- /* Update the toolbar
- */
- item_height = 44 + 44 + 16;
- if (link->next) item_height += 16;
- ro_gui_theme_process_toolbar(link->toolbar, parent_width);
- extent.y0 = nested_y - link->toolbar->height - item_height;
- if (link->next) extent.y0 -= 16;
- if (extent.y0 > min_extent) extent.y0 = min_extent;
- xwimp_set_extent(dialog_config_th_pane, &extent);
- ro_gui_set_icon_button_type(link->toolbar->toolbar_handle,
- ICON_TOOLBAR_URL, wimp_BUTTON_NEVER);
-
- /* Create the descriptor icons and separator line
- */
- new_icon.icon.extent.x0 = 8;
- new_icon.icon.extent.x1 = parent_width - 8;
- new_icon.icon.flags &= ~wimp_ICON_BORDER;
- new_icon.icon.flags |= wimp_ICON_SPRITE;
- new_icon.icon.extent.y1 = nested_y - link->toolbar->height - 8;
- new_icon.icon.extent.y0 = nested_y - link->toolbar->height - 52;
- new_icon.icon.data.indirected_text_and_sprite.text =
- (char *)&link->descriptor->name;
- new_icon.icon.data.indirected_text_and_sprite.size =
- strlen(link->descriptor->name) + 1;
- new_icon.icon.data.indirected_text_and_sprite.validation =
- theme_radio_validation;
- xwimp_create_icon(&new_icon, &link->icon_number);
- new_icon.icon.flags &= ~wimp_ICON_SPRITE;
- new_icon.icon.extent.x0 = 52;
- new_icon.icon.extent.y1 -= 44;
- new_icon.icon.extent.y0 -= 44;
- new_icon.icon.data.indirected_text.text =
- (char *)&link->descriptor->author;
- new_icon.icon.data.indirected_text.size =
- strlen(link->descriptor->filename) + 1;
- new_icon.icon.data.indirected_text.validation =
- theme_null_validation;
- xwimp_create_icon(&new_icon, 0);
- if (link->next) {
- new_icon.icon.flags |= wimp_ICON_BORDER;
- new_icon.icon.extent.x0 = -8;
- new_icon.icon.extent.x1 = parent_width + 8;
- new_icon.icon.extent.y1 -= 52;
- new_icon.icon.extent.y0 = new_icon.icon.extent.y1 - 8;
- new_icon.icon.data.indirected_text.text =
- theme_null_validation;
- new_icon.icon.data.indirected_text.validation =
- theme_line_validation;
- new_icon.icon.data.indirected_text.size = 1;
- strlen(link->descriptor->filename) + 1;
- xwimp_create_icon(&new_icon, 0);
- }
-
- /* Nest the toolbar window
- */
- state.w = link->toolbar->toolbar_handle;
- state.yscroll = 0;
- state.visible.y1 = nested_y + base_extent;
- state.visible.y0 = state.visible.y1 - link->toolbar->height + 2;
- xwimp_open_window_nested((wimp_open *)&state,
- dialog_config_th_pane,
- wimp_CHILD_LINKS_PARENT_WORK_AREA
- << wimp_CHILD_BS_EDGE_SHIFT |
- wimp_CHILD_LINKS_PARENT_WORK_AREA
- << wimp_CHILD_TS_EDGE_SHIFT);
-
- /* Continue processing
- */
- nested_y -= link->toolbar->height + item_height;
- link = link->next;
- }
-
- /* Set the current theme as selected
- */
- link = toolbars;
- while (link) {
- ro_gui_set_icon_selected_state(dialog_config_th_pane,
- link->icon_number,
- (link->descriptor == theme_choice));
- link = link->next;
- }
- xwimp_force_redraw(dialog_config_th_pane, 0, -16384, 16384, 16384);
-}
-
-
-/**
- * Removes and closes all themes in the theme pane.
- */
-
-void ro_gui_dialog_free_themes(void)
-{
- struct toolbar_display *toolbar;
- struct toolbar_display *next_toolbar;
-
- /* Free all our toolbars
- */
- next_toolbar = toolbars;
- while ((toolbar = next_toolbar) != NULL) {
- xwimp_delete_icon(dialog_config_th_pane, toolbar->icon_number);
- xwimp_delete_icon(dialog_config_th_pane, toolbar->icon_number + 1);
- if (toolbar->next)
- xwimp_delete_icon(dialog_config_th_pane,
- toolbar->icon_number + 2);
- ro_gui_theme_destroy_toolbar(toolbar->toolbar);
- next_toolbar = toolbar->next;
- free(toolbar);
- }
- toolbars = NULL;
-
- /* Close all our themes
- */
- if (theme_list) ro_gui_theme_close(theme_list, true);
- theme_list = NULL;
- theme_count = 0;
- theme_choice = NULL;
+ ro_gui_wimp_event_memorise(dialog_openurl);
}
diff --git a/riscos/download.c b/riscos/download.c
index 56612075b..db336077e 100644
--- a/riscos/download.c
+++ b/riscos/download.c
@@ -32,8 +32,8 @@
#include "oslib/wimpspriteop.h"
#include "netsurf/content/fetch.h"
#include "netsurf/desktop/gui.h"
+#include "netsurf/riscos/dialog.h"
#include "netsurf/riscos/options.h"
-#include "netsurf/riscos/gui.h"
#include "netsurf/riscos/query.h"
#include "netsurf/riscos/wimp.h"
#include "netsurf/utils/log.h"
diff --git a/riscos/help.c b/riscos/help.c
index 6db6b9649..de42f8f30 100644
--- a/riscos/help.c
+++ b/riscos/help.c
@@ -23,6 +23,7 @@
#include "netsurf/riscos/menus.h"
#include "netsurf/riscos/theme.h"
#include "netsurf/riscos/wimp.h"
+#include "netsurf/riscos/wimp_event.h"
#include "netsurf/utils/messages.h"
#include "netsurf/utils/log.h"
#include "netsurf/utils/utf8.h"
@@ -31,27 +32,13 @@
/* Recognised help keys
====================
+ Help keys should be registered using the wimp_event system to be
+ recognised. The only special case help values are:
HelpIconbar Iconbar (no icon suffix is used)
-
- HelpAppInfo Application info window
- HelpBrowser Browser window [*]
- HelpHistory History window [*]
- HelpObjInfo Object info window
- HelpPageInfo Page info window
- HelpPrint Print window
- HelpSaveAs Save as window
- HelpScaleView Scale view window
- HelpSearch Search window
- HelpStatus Status window
- HelpToolbar Toolbar window
HelpHotlist Hotlist window [*]
- HelpHotToolbar Hotlist window toolbar
- HelpHotEntry Hotlist entry window
- HelpHotFolder Hotlist entry window
HelpGHistory Global history window [*]
- HelpGHistToolbar Global history window toolbar
- HelpEditToolbar Toolbars in edit mode
+ HelpBrowser Browser window [*]
HelpIconMenu Iconbar menu
HelpBrowserMenu Browser window menu
@@ -93,11 +80,11 @@ void ro_gui_interactive_help_request(wimp_message *message) {
wimp_w window;
wimp_i icon;
struct gui_window *g;
- struct toolbar *toolbar = NULL;
unsigned int index;
bool greyed = false;
wimp_menu *test_menu;
os_error *error;
+ const char *auto_text;
/* only accept help requests */
if ((!message) || (message->action != message_HELP_REQUEST))
@@ -113,28 +100,11 @@ void ro_gui_interactive_help_request(wimp_message *message) {
icon = message_data->i;
/* do the basic window checks */
- if (window == wimp_ICON_BAR)
+ auto_text = ro_gui_wimp_event_get_help_prefix(window);
+ if (auto_text)
+ sprintf(message_token, "%s%i", auto_text, (int)icon);
+ else if (window == wimp_ICON_BAR)
sprintf(message_token, "HelpIconbar");
- else if (window == dialog_info)
- sprintf(message_token, "HelpAppInfo%i", (int)icon);
- else if (window == history_window)
- sprintf(message_token, "HelpHistory%i", (int)icon);
- else if (window == dialog_objinfo)
- sprintf(message_token, "HelpObjInfo%i", (int)icon);
- else if (window == dialog_pageinfo)
- sprintf(message_token, "HelpPageInfo%i", (int)icon);
- else if (window == dialog_print)
- sprintf(message_token, "HelpPrint%i", (int)icon);
- else if (window == dialog_saveas)
- sprintf(message_token, "HelpSaveAs%i", (int)icon);
- else if (window == dialog_zoom)
- sprintf(message_token, "HelpScaleView%i", (int)icon);
- else if (window == dialog_search)
- sprintf(message_token, "HelpSearch%i", (int)icon);
- else if (window == dialog_folder)
- sprintf(message_token, "HelpHotFolder%i", (int)icon);
- else if (window == dialog_entry)
- sprintf(message_token, "HelpHotEntry%i", (int)icon);
else if ((hotlist_tree) && (window == (wimp_w)hotlist_tree->handle))
sprintf(message_token, "HelpHotlist%i",
ro_gui_hotlist_help(message_data->pos.x,
@@ -144,32 +114,8 @@ void ro_gui_interactive_help_request(wimp_message *message) {
sprintf(message_token, "HelpGHistory%i",
ro_gui_global_history_help(message_data->pos.x,
message_data->pos.y));
- else if ((hotlist_tree) && (hotlist_tree->toolbar) &&
- ((window == hotlist_tree->toolbar->toolbar_handle) ||
- ((hotlist_tree->toolbar->editor) &&
- (window == hotlist_tree->toolbar->
- editor->toolbar_handle)))) {
- toolbar = hotlist_tree->toolbar;
- sprintf(message_token, "HelpHotToolbar%i", (int)icon);
- } else if ((global_history_tree) && (global_history_tree->toolbar) &&
- ((window == global_history_tree->toolbar->
- toolbar_handle) ||
- ((global_history_tree->toolbar->editor) &&
- (window == global_history_tree->toolbar->
- editor->toolbar_handle)))) {
- toolbar = global_history_tree->toolbar;
- sprintf(message_token, "HelpGHistToolbar%i", (int)icon);
- } else if ((g = ro_gui_window_lookup(window)) != NULL)
+ else if ((g = ro_gui_window_lookup(window)) != NULL)
sprintf(message_token, "HelpBrowser%i", (int)icon);
- else if ((g = ro_gui_toolbar_lookup(window)) != NULL) {
- toolbar = g->toolbar;
- sprintf(message_token, "HelpToolbar%i", (int)icon);
- } else if ((g = ro_gui_status_lookup(window)) != NULL)
- sprintf(message_token, "HelpStatus%i", (int)icon);
-
- /* change toolbars to editors where appropriate */
- if ((toolbar) && (toolbar->editor))
- sprintf(message_token, "HelpEditToolbar%i", (int)icon);
/* if we've managed to find something so far then we broadcast it */
if (message_token[0]) {
diff --git a/riscos/history.c b/riscos/history.c
index 4a2ac9456..4cb5c7e73 100644
--- a/riscos/history.c
+++ b/riscos/history.c
@@ -20,23 +20,24 @@
#include "netsurf/content/url_store.h"
#include "netsurf/image/bitmap.h"
#include "netsurf/riscos/bitmap.h"
+#include "netsurf/riscos/dialog.h"
#include "netsurf/riscos/image.h"
#include "netsurf/riscos/options.h"
#include "netsurf/riscos/gui.h"
#include "netsurf/riscos/thumbnail.h"
#include "netsurf/riscos/tinct.h"
#include "netsurf/riscos/wimp.h"
+#include "netsurf/riscos/wimp_event.h"
#include "netsurf/utils/log.h"
#include "netsurf/utils/url.h"
#include "netsurf/utils/utils.h"
#define SIZE 10
-#define WIDTH 200
-#define HEIGHT 152
+#define WIDTH (THUMBNAIL_WIDTH << 1)
+#define HEIGHT (THUMBNAIL_HEIGHT << 1)
#define MARGIN 32
#define FULL_WIDTH (WIDTH + MARGIN + MARGIN)
#define FULL_HEIGHT (HEIGHT + MARGIN + MARGIN)
-#define SPRITE_SIZE (16 + 44 + ((WIDTH / 2 + 3) & ~3) * HEIGHT / 2)
/** A node in the history tree. */
struct history_entry {
@@ -77,7 +78,8 @@ static struct history_entry * ro_gui_history_click_find(
int x, int y);
static void history_go(struct browser_window *bw,
struct history_entry *entry, bool new_window);
-
+static void ro_gui_history_redraw(wimp_draw *redraw);
+static bool ro_gui_history_click(wimp_pointer *pointer);
/**
* Create a new history tree for a window.
@@ -249,6 +251,11 @@ void ro_gui_history_init(void)
{
history_window = ro_gui_dialog_create("history");
history_font = font_find_font("Homerton.Medium", 112, 128, 0, 0, 0, 0);
+ ro_gui_wimp_event_register_redraw_window(history_window,
+ ro_gui_history_redraw);
+ ro_gui_wimp_event_register_mouse_click(history_window,
+ ro_gui_history_click);
+ ro_gui_wimp_event_set_help_prefix(history_window, "HelpHistory");
}
@@ -512,9 +519,11 @@ void ro_gui_history_mouse_at(wimp_pointer *pointer)
/**
* Handle mouse clicks in the history window.
+ *
+ * \return true if the event was handled, false to pass it on
*/
-void ro_gui_history_click(wimp_pointer *pointer)
+bool ro_gui_history_click(wimp_pointer *pointer)
{
int x, y;
struct history_entry *he;
@@ -523,7 +532,7 @@ void ro_gui_history_click(wimp_pointer *pointer)
if (pointer->buttons != wimp_CLICK_SELECT &&
pointer->buttons != wimp_CLICK_ADJUST)
/* return if not select or adjust click */
- return;
+ return true;
state.w = history_window;
wimp_get_window_state(&state);
@@ -539,6 +548,7 @@ void ro_gui_history_click(wimp_pointer *pointer)
history_go(history_bw, he,
pointer->buttons == wimp_CLICK_ADJUST);
}
+ return true;
}
diff --git a/riscos/menus.c b/riscos/menus.c
index db5dae112..776b91903 100644
--- a/riscos/menus.c
+++ b/riscos/menus.c
@@ -22,7 +22,9 @@
#include "oslib/wimp.h"
#include "netsurf/desktop/gui.h"
#include "netsurf/render/box.h"
+#include "netsurf/riscos/dialog.h"
#include "netsurf/render/form.h"
+#include "netsurf/riscos/configure.h"
#include "netsurf/riscos/gui.h"
#include "netsurf/riscos/global_history.h"
#include "netsurf/riscos/help.h"
@@ -32,6 +34,7 @@
#include "netsurf/riscos/theme.h"
#include "netsurf/riscos/treeview.h"
#include "netsurf/riscos/wimp.h"
+#include "netsurf/riscos/wimp_event.h"
#include "netsurf/utils/log.h"
#include "netsurf/utils/messages.h"
#include "netsurf/utils/url.h"
@@ -102,13 +105,14 @@ static bool ro_gui_menu_translate(struct menu_definition *menu);
(wimp_COLOUR_BLACK << wimp_ICON_FG_COLOUR_SHIFT) | \
(wimp_COLOUR_WHITE << wimp_ICON_BG_COLOUR_SHIFT))
-
+/** Whether the search box was opened as a sub-menu */
+static bool ro_gui_menu_search_window_menu;
/** The currently defined menus to perform actions for */
static struct menu_definition *ro_gui_menu_definitions;
/** The current menu being worked with (may not be open) */
wimp_menu *current_menu;
/** Whether a menu is currently open */
-static bool current_menu_open = false;
+bool current_menu_open = false;
/** Box for object under menu, or 0 if no object. */
static struct box *current_menu_object_box = 0;
/** Menu of options for form select controls. */
@@ -116,7 +120,9 @@ static wimp_menu *gui_form_select_menu = 0;
/** Form control which gui_form_select_menu is for. */
static struct form_control *gui_form_select_control;
/** Window that owns the current menu */
-static wimp_w current_menu_window;
+wimp_w current_menu_window;
+/** Icon that owns the current menu (only valid for popup menus) */
+static wimp_i current_menu_icon;
/** The height of the iconbar menu */
int iconbar_menu_height = 5 * 44;
/** The available menus */
@@ -131,7 +137,7 @@ wimp_menu *url_suggest_menu = (wimp_menu *)&url_suggest;
* incorrect so we use a hack of checking if the sub-menu has bit 0
* set which is undocumented but true of window handles on
* all target OS versions */
-#define IS_MENU(menu, submenu) !((int)(submenu) & 1)
+#define IS_MENU(menu) !((int)(menu) & 1)
/**
@@ -155,6 +161,7 @@ void ro_gui_menu_init(void)
};
iconbar_menu = ro_gui_menu_define_menu(
(struct ns_menu *)&iconbar_definition);
+ ro_gui_menu_set_entry_shaded(iconbar_menu, CHOICES_SHOW, true);
/* browser menu */
NS_MENU(66) browser_definition = {
@@ -252,7 +259,6 @@ void ro_gui_menu_init(void)
{ "Selection.Edit", TREE_SELECTION_EDIT, (wimp_w)1 },
{ "Selection.Launch", TREE_SELECTION_LAUNCH, 0 },
{ "Selection.Delete", TREE_SELECTION_DELETE, 0 },
- { "Selection.ResetUsage", TREE_SELECTION_RESET, 0 },
{ "SelectAll", TREE_SELECT_ALL, 0 },
{ "Clear", TREE_CLEAR_SELECTION, 0 },
{NULL, 0, 0}
@@ -343,13 +349,7 @@ void ro_gui_menu_init(void)
/* special case menus */
url_suggest_menu->title_data.indirected_text.text =
(char*)messages_get("URLSuggest");
- url_suggest_menu->title_fg = wimp_COLOUR_BLACK;
- url_suggest_menu->title_bg = wimp_COLOUR_LIGHT_GREY;
- url_suggest_menu->work_fg = wimp_COLOUR_BLACK;
- url_suggest_menu->work_bg = wimp_COLOUR_WHITE;
- url_suggest_menu->width = 200;
- url_suggest_menu->height = wimp_MENU_ITEM_HEIGHT;
- url_suggest_menu->gap = wimp_MENU_ITEM_GAP;
+ ro_gui_menu_init_structure(url_suggest_menu, GLOBAL_HISTORY_RECENT_URLS);
/* Note: This table *must* be kept in sync with the LangNames file */
NS_MENU(48) lang_definition = {
@@ -459,11 +459,16 @@ void ro_gui_menu_create(wimp_menu *menu, int x, int y, wimp_w w) {
/* store the menu characteristics */
current_menu = menu;
current_menu_window = w;
+ current_menu_icon = -1;
+ ro_gui_menu_search_window_menu = false;
/* prepare the menu state */
if (menu == url_suggest_menu) {
if (!ro_gui_menu_prepare_url_suggest())
return;
+ } else if (menu == recent_search_menu) {
+ if (!ro_gui_search_prepare_menu())
+ return;
} else {
i = 0;
do {
@@ -481,7 +486,7 @@ void ro_gui_menu_create(wimp_menu *menu, int x, int y, wimp_w w) {
LOG(("xwimp_create_menu: 0x%x: %s",
error->errnum, error->errmess));
warn_user("MenuError", error->errmess);
- ro_gui_menu_closed();
+ ro_gui_menu_closed(true);
}
}
@@ -516,18 +521,21 @@ void ro_gui_popup_menu(wimp_menu *menu, wimp_w w, wimp_i i) {
warn_user("MenuError", error->errmess);
return;
}
-
+
ro_gui_menu_create(menu,
state.visible.x0 + icon_state.icon.extent.x1 + 64,
state.visible.y1 + icon_state.icon.extent.y1 -
state.yscroll, w);
+ current_menu_icon = i;
}
/**
* Clean up after a menu has been closed, or forcible close an open menu.
+ *
+ * \param cleanup Call any terminating functions (sub-window isn't going to be instantly re-opened)
*/
-void ro_gui_menu_closed(void) {
+void ro_gui_menu_closed(bool cleanup) {
struct gui_window *g;
struct browser_window *bw;
struct content *c;
@@ -547,15 +555,19 @@ void ro_gui_menu_closed(void) {
&g, &bw, &c, &t, &tree);
current_menu = NULL;
- /* end any search operation that was started so that
- the text doesn't remain highlighted */
- ro_gui_search_end();
-
- if (tree)
- ro_gui_tree_menu_closed(tree);
+ if (cleanup) {
+ /* end any search operation that was started so that
+ the text doesn't remain highlighted */
+ if (ro_gui_menu_search_window_menu)
+ ro_gui_search_end(dialog_search);
+
+ if (tree)
+ ro_gui_tree_menu_closed(tree);
+ }
}
current_menu_window = NULL;
+ current_menu_icon = NULL;
current_menu_open = false;
gui_form_select_control = NULL;
}
@@ -570,7 +582,7 @@ void ro_gui_menu_objects_moved(void) {
ro_gui_menu_prepare_action(0, BROWSER_OBJECT, false);
if ((current_menu) && (current_menu == gui_form_select_menu))
- ro_gui_menu_closed();
+ ro_gui_menu_closed(true);
}
@@ -585,6 +597,8 @@ void ro_gui_menu_selection(wimp_selection *selection) {
struct gui_window *g = NULL;
wimp_menu *menu;
os_error *error;
+ int previous_menu_icon = current_menu_icon;
+
/* if we are using gui_multitask then menu selection events
* may be delivered after the menu has been closed. As such,
@@ -592,7 +606,7 @@ void ro_gui_menu_selection(wimp_selection *selection) {
if (!current_menu)
return
assert(current_menu_window);
-
+
/* get the menu entry and associated action */
menu_entry = &current_menu->entries[selection->items[0]];
for (i = 1; selection->items[i] != -1; i++)
@@ -612,32 +626,6 @@ void ro_gui_menu_selection(wimp_selection *selection) {
browser_window_go(g->bw,
url_suggest_menu->entries[selection->items[0]].
data.indirected_text.text, 0);
- else
- ro_gui_set_icon_string(dialog_openurl, ICON_OPENURL_URL,
- url_suggest_menu->entries[selection->items[0]].
- data.indirected_text.text);
- global_history_add_recent(url_suggest_menu->
- entries[selection->items[0]].
- data.indirected_text.text);
- } else if (current_menu == proxy_auth_menu) {
- ro_gui_dialog_proxyauth_menu_selection(selection->items[0]);
- } else if (current_menu == image_quality_menu) {
- ro_gui_dialog_image_menu_selection(selection->items[0]);
- } else if (current_menu == languages_menu) {
- struct menu_definition *desc;
- struct menu_definition_entry *entry;
-
- /* find the relevant menu definition entry */
- desc = ro_gui_menu_find_menu(current_menu);
- for (entry = desc->entries; entry; entry = entry->next)
- if (entry->menu_entry == menu_entry)
- break;
- if (entry)
- /* found it, so handle the seletion */
- ro_gui_dialog_languages_menu_selection(
- entry->entry_key);
- } else if (current_menu == font_menu) {
- ro_gui_dialog_font_menu_selection(selection->items[0]);
} else if ((current_menu == gui_form_select_menu) &&
(selection->items[0] >= 0)) {
g = ro_gui_window_lookup(current_menu_window);
@@ -647,18 +635,22 @@ void ro_gui_menu_selection(wimp_selection *selection) {
selection->items[0]);
}
+ /* allow automatic menus to have their data updated */
+ ro_gui_wimp_event_menu_selection(current_menu_window, current_menu_icon,
+ current_menu, selection);
+
/* re-open the menu for Adjust clicks */
error = xwimp_get_pointer_info(&pointer);
if (error) {
LOG(("xwimp_get_pointer_info: 0x%x: %s",
error->errnum, error->errmess));
warn_user("WimpError", error->errmess);
- ro_gui_menu_closed();
+ ro_gui_menu_closed(true);
return;
}
if (pointer.buttons != wimp_CLICK_ADJUST) {
- ro_gui_menu_closed();
+ ro_gui_menu_closed(true);
return;
}
@@ -686,6 +678,7 @@ void ro_gui_menu_selection(wimp_selection *selection) {
gui_form_select_control);
else
ro_gui_menu_create(current_menu, 0, 0, current_menu_window);
+ current_menu_icon = previous_menu_icon;
}
@@ -710,7 +703,7 @@ void ro_gui_menu_warning(wimp_message_menu_warning *warning) {
menu_entry = &menu_entry->sub_menu->
entries[warning->selection.items[i]];
- if (IS_MENU(menu_entry, menu_entry->sub_menu)) {
+ if (IS_MENU(menu_entry->sub_menu)) {
sub_menu = menu_entry->sub_menu;
i = 0;
do {
@@ -784,13 +777,8 @@ bool ro_gui_menu_prepare_url_suggest(void) {
for (i = 0; i < suggestions; i++) {
url_suggest_menu->entries[i].menu_flags = 0;
- url_suggest_menu->entries[i].sub_menu = wimp_NO_SUB_MENU;
- url_suggest_menu->entries[i].icon_flags =
- DEFAULT_FLAGS | wimp_ICON_INDIRECTED;
url_suggest_menu->entries[i].data.indirected_text.text =
suggest_text[i];
- url_suggest_menu->entries[i].data.indirected_text.validation =
- (char *)-1;
url_suggest_menu->entries[i].data.indirected_text.size =
strlen(suggest_text[i]) + 1;
}
@@ -970,7 +958,7 @@ void ro_gui_menu_prepare_languages(bool accept, const char *lang)
*/
void gui_create_form_select_menu(struct browser_window *bw,
struct form_control *control) {
- unsigned int i = 0, j;
+ unsigned int i, entries;
char *text_convert, *temp;
struct form_option *option;
wimp_pointer pointer;
@@ -980,19 +968,19 @@ void gui_create_form_select_menu(struct browser_window *bw,
assert(control);
- for (option = control->data.select.items; option;
+ for (entries = 0, option = control->data.select.items; option;
option = option->next)
- i++;
- if (i == 0) {
- ro_gui_menu_closed();
+ entries++;
+ if (entries == 0) {
+ ro_gui_menu_closed(true);
return;
}
if ((gui_form_select_menu) && (control != gui_form_select_control)) {
- for (j = 0; ; j++) {
- free(gui_form_select_menu->entries[j].data.
+ for (i = 0; ; i++) {
+ free(gui_form_select_menu->entries[i].data.
indirected_text.text);
- if (gui_form_select_menu->entries[j].menu_flags &
+ if (gui_form_select_menu->entries[i].menu_flags &
wimp_MENU_LAST)
break;
}
@@ -1003,10 +991,10 @@ void gui_create_form_select_menu(struct browser_window *bw,
if (!gui_form_select_menu) {
reopen = false;
- gui_form_select_menu = malloc(wimp_SIZEOF_MENU(i));
+ gui_form_select_menu = malloc(wimp_SIZEOF_MENU(entries));
if (!gui_form_select_menu) {
warn_user("NoMemory", 0);
- ro_gui_menu_closed();
+ ro_gui_menu_closed(true);
return;
}
err = utf8_to_local_encoding(messages_get("SelectMenu"), 0,
@@ -1016,18 +1004,12 @@ void gui_create_form_select_menu(struct browser_window *bw,
assert(err != UTF8_CONVERT_BADENC);
LOG(("utf8_to_local_encoding failed"));
warn_user("NoMemory", 0);
- ro_gui_menu_closed();
+ ro_gui_menu_closed(true);
return;
}
gui_form_select_menu->title_data.indirected_text.text =
text_convert;
- gui_form_select_menu->title_fg = wimp_COLOUR_BLACK;
- gui_form_select_menu->title_bg = wimp_COLOUR_LIGHT_GREY;
- gui_form_select_menu->work_fg = wimp_COLOUR_BLACK;
- gui_form_select_menu->work_bg = wimp_COLOUR_WHITE;
- gui_form_select_menu->width = 200;
- gui_form_select_menu->height = wimp_MENU_ITEM_HEIGHT;
- gui_form_select_menu->gap = wimp_MENU_ITEM_GAP;
+ ro_gui_menu_init_structure(gui_form_select_menu, entries);
}
for (i = 0, option = control->data.select.items; option;
@@ -1037,13 +1019,6 @@ void gui_create_form_select_menu(struct browser_window *bw,
gui_form_select_menu->entries[i].menu_flags =
wimp_MENU_TICKED;
if (!reopen) {
- gui_form_select_menu->entries[i].sub_menu = wimp_NO_SUB_MENU;
- gui_form_select_menu->entries[i].icon_flags = wimp_ICON_TEXT |
- wimp_ICON_INDIRECTED | wimp_ICON_FILLED |
- (wimp_COLOUR_BLACK <<
- wimp_ICON_FG_COLOUR_SHIFT) |
- (wimp_COLOUR_WHITE <<
- wimp_ICON_BG_COLOUR_SHIFT);
/* convert spaces to hard spaces to stop things
* like 'Go Home' being treated as if 'Home' is a
@@ -1054,7 +1029,7 @@ void gui_create_form_select_menu(struct browser_window *bw,
if (!temp) {
LOG(("cnv_space2nbsp failed"));
warn_user("NoMemory", 0);
- ro_gui_menu_closed();
+ ro_gui_menu_closed(true);
return;
}
@@ -1066,7 +1041,7 @@ void gui_create_form_select_menu(struct browser_window *bw,
assert(err != UTF8_CONVERT_BADENC);
LOG(("utf8_to_enc failed"));
warn_user("NoMemory", 0);
- ro_gui_menu_closed();
+ ro_gui_menu_closed(true);
return;
}
@@ -1074,9 +1049,6 @@ void gui_create_form_select_menu(struct browser_window *bw,
gui_form_select_menu->entries[i].data.indirected_text.text =
text_convert;
-
- gui_form_select_menu->entries[i].data.indirected_text.
- validation = (char *)-1;
gui_form_select_menu->entries[i].data.indirected_text.size =
strlen(gui_form_select_menu->entries[i].
data.indirected_text.text) + 1;
@@ -1092,7 +1064,7 @@ void gui_create_form_select_menu(struct browser_window *bw,
LOG(("xwimp_get_pointer_info: 0x%x: %s",
error->errnum, error->errmess));
warn_user("WimpError", error->errmess);
- ro_gui_menu_closed();
+ ro_gui_menu_closed(true);
return;
}
@@ -1209,13 +1181,7 @@ void ro_gui_menu_define_menu_add(struct menu_definition *definition,
new_menu->title_data.indirected_text.text = NULL;
/* fill in menu flags */
- new_menu->title_fg = wimp_COLOUR_BLACK;
- new_menu->title_bg = wimp_COLOUR_LIGHT_GREY;
- new_menu->work_fg = wimp_COLOUR_BLACK;
- new_menu->work_bg = wimp_COLOUR_WHITE;
- new_menu->width = 200;
- new_menu->height = wimp_MENU_ITEM_HEIGHT;
- new_menu->gap = wimp_MENU_ITEM_GAP;
+ ro_gui_menu_init_structure(new_menu, entries);
/* and then create the entries */
for (entry = 0; entry < entries; entry++) {
@@ -1245,12 +1211,6 @@ void ro_gui_menu_define_menu_add(struct menu_definition *definition,
if (menu->entries[id].sub_window)
new_menu->entries[entry].sub_menu =
(wimp_menu *)menu->entries[id].sub_window;
- else
- new_menu->entries[entry].sub_menu = wimp_NO_SUB_MENU;
-
- /* icon flags */
- new_menu->entries[entry].icon_flags = DEFAULT_FLAGS |
- wimp_ICON_INDIRECTED;
/* this is fixed up in ro_gui_menu_translate() */
new_menu->entries[entry].data.indirected_text.text = NULL;
@@ -1279,13 +1239,39 @@ void ro_gui_menu_define_menu_add(struct menu_definition *definition,
new_menu->entries[entry].menu_flags |=
wimp_MENU_GIVE_WARNING;
}
-
new_menu->entries[0].menu_flags |= wimp_MENU_TITLE_INDIRECTED;
new_menu->entries[entries - 1].menu_flags |= wimp_MENU_LAST;
}
/**
+ * Initialise the basic state of a menu structure so all entries are
+ * indirected text with no flags, no submenu.
+ */
+void ro_gui_menu_init_structure(wimp_menu *menu, int entries) {
+ int i;
+
+ menu->title_fg = wimp_COLOUR_BLACK;
+ menu->title_bg = wimp_COLOUR_LIGHT_GREY;
+ menu->work_fg = wimp_COLOUR_BLACK;
+ menu->work_bg = wimp_COLOUR_WHITE;
+ menu->width = 200;
+ menu->height = wimp_MENU_ITEM_HEIGHT;
+ menu->gap = wimp_MENU_ITEM_GAP;
+
+ for (i = 0; i < entries; i++) {
+ menu->entries[i].menu_flags = 0;
+ menu->entries[i].sub_menu = wimp_NO_SUB_MENU;
+ menu->entries[i].icon_flags =
+ DEFAULT_FLAGS | wimp_ICON_INDIRECTED;
+ menu->entries[i].data.indirected_text.validation =
+ (char *)-1;
+ }
+ menu->entries[0].menu_flags |= wimp_MENU_TITLE_INDIRECTED;
+}
+
+
+/**
* Finds the menu_definition corresponding to a wimp_menu.
*
* \param menu the menu to find the definition for
@@ -1408,8 +1394,7 @@ bool ro_gui_menu_handle_action(wimp_w owner, menu_action action,
struct node *node;
os_error *error;
char url[80];
- url_func_result res;
- char *norm_url = NULL;
+ struct url_content *data;
ro_gui_menu_get_window_details(owner, &g, &bw, &c, &t, &tree);
@@ -1449,25 +1434,19 @@ bool ro_gui_menu_handle_action(wimp_w owner, menu_action action,
case HOTLIST_ADD_URL:
if ((!hotlist_tree) || (!c) || (!c->url))
return false;
- res = url_normalize(c->url, &norm_url);
- if (res != URL_FUNC_OK) {
- warn_user("NoMemory", 0);
- return false;
- }
- node = tree_create_URL_node(hotlist_tree->root,
- c->title, norm_url,
- ro_content_filetype(c),
- time(NULL), -1, 0);
- free(norm_url);
- if (node) {
- tree_redraw_area(hotlist_tree,
- node->box.x - NODE_INSTEP, 0,
- NODE_INSTEP, 16384);
- tree_handle_node_changed(hotlist_tree, node,
- false, true);
- ro_gui_tree_scroll_visible(hotlist_tree,
- &node->data);
- ro_gui_hotlist_save();
+ data = url_store_find(c->url);
+ if (data) {
+ node = tree_create_URL_node(hotlist_tree->root, data, NULL);
+ if (node) {
+ tree_redraw_area(hotlist_tree,
+ node->box.x - NODE_INSTEP, 0,
+ NODE_INSTEP, 16384);
+ tree_handle_node_changed(hotlist_tree, node,
+ false, true);
+ ro_gui_tree_scroll_visible(hotlist_tree,
+ &node->data);
+ ro_gui_hotlist_save();
+ }
}
return true;
case HOTLIST_SHOW:
@@ -1594,6 +1573,7 @@ bool ro_gui_menu_handle_action(wimp_w owner, menu_action action,
if (!c || c->type != CONTENT_HTML)
return false;
ro_gui_menu_prepare_action(owner, action, true);
+ ro_gui_menu_search_window_menu = false;
ro_gui_dialog_open_persistent(g->window,
dialog_search, windows_at_pointer);
return true;
@@ -1688,16 +1668,28 @@ bool ro_gui_menu_handle_action(wimp_w owner, menu_action action,
ro_gui_tree_launch_selected(tree);
return true;
case TREE_SELECTION_DELETE:
+ ro_gui_tree_stop_edit(tree);
tree_delete_selected_nodes(tree, tree->root);
- return true;
- case TREE_SELECTION_RESET:
- tree_reset_URL_nodes(tree, tree->root, true);
+ if (tree == hotlist_tree)
+ ro_gui_hotlist_save();
+ ro_gui_menu_prepare_action(owner, TREE_CLEAR_SELECTION, true);
+ ro_gui_menu_prepare_action(owner, TREE_SELECTION, true);
return true;
case TREE_SELECT_ALL:
- ro_gui_tree_keypress(1, tree); /* CTRL-A */
+ ro_gui_tree_stop_edit(tree);
+ if (tree->root->child) {
+ tree->temp_selection = NULL;
+ tree_set_node_selected(tree, tree->root, true);
+ }
+ ro_gui_menu_prepare_action(owner, TREE_CLEAR_SELECTION, true);
+ ro_gui_menu_prepare_action(owner, TREE_SELECTION, true);
return true;
case TREE_CLEAR_SELECTION:
- ro_gui_tree_keypress(26, tree); /* CTRL-Z */
+ tree->temp_selection = NULL;
+ ro_gui_tree_stop_edit(tree);
+ tree_set_node_selected(tree, tree->root, false);
+ ro_gui_menu_prepare_action(owner, TREE_CLEAR_SELECTION, true);
+ ro_gui_menu_prepare_action(owner, TREE_SELECTION, true);
return true;
/* toolbar actions */
@@ -1736,7 +1728,7 @@ bool ro_gui_menu_handle_action(wimp_w owner, menu_action action,
}
return true;
case CHOICES_SHOW:
- ro_gui_dialog_open_config();
+ ro_gui_configure_show();
return true;
/* unknown action */
@@ -2007,8 +1999,10 @@ void ro_gui_menu_prepare_action(wimp_w owner, menu_action action,
result = !c || c->type != CONTENT_HTML;
ro_gui_menu_set_entry_shaded(current_menu,
action, result);
- if ((c) && (windows))
+ if ((!result) && (windows)) {
+ ro_gui_menu_search_window_menu = true;
ro_gui_search_prepare(g);
+ }
if ((t) && (!t->editor) &&
(t->type == THEME_BROWSER_TOOLBAR))
ro_gui_set_icon_shaded_state(
@@ -2110,7 +2104,7 @@ void ro_gui_menu_prepare_action(wimp_w owner, menu_action action,
break;
case TREE_SELECTION_LAUNCH:
case TREE_SELECTION_DELETE:
- case TREE_SELECTION_RESET:
+ case TREE_CLEAR_SELECTION:
if ((!tree) || (!tree->root))
break;
if (tree->root->child)
@@ -2122,14 +2116,6 @@ void ro_gui_menu_prepare_action(wimp_w owner, menu_action action,
ro_gui_menu_set_entry_shaded(current_menu, action,
!tree->root->child);
break;
- case TREE_CLEAR_SELECTION:
- if ((!tree) || (!tree->root))
- break;
- if (tree->root->child)
- result = tree_has_selection(tree->root->child);
- ro_gui_menu_set_entry_shaded(current_menu,
- action, !result);
- break;
/* toolbar actions */
case TOOLBAR_BUTTONS:
@@ -2237,7 +2223,7 @@ int ro_gui_menu_get_checksum(void) {
}
menu = current_menu;
- while (menu_tree.items[i] != -1) {
+ do {
j = 0;
do {
if (menu->entries[j].icon_flags & wimp_ICON_SHADED)
@@ -2247,10 +2233,12 @@ int ro_gui_menu_get_checksum(void) {
} while (!(menu->entries[j++].menu_flags & wimp_MENU_LAST));
j = menu_tree.items[i++];
- menu = menu->entries[j].sub_menu;
- if ((!menu) || (menu == wimp_NO_SUB_MENU))
- break;
- }
+ if (j != -1) {
+ menu = menu->entries[j].sub_menu;
+ if ((!menu) || (menu == wimp_NO_SUB_MENU) || (!IS_MENU(menu)))
+ break;
+ }
+ } while (j != -1);
return checksum;
}
@@ -2318,8 +2306,7 @@ bool ro_gui_menu_translate(struct menu_definition *menu)
/* child menu title - this is the same as the text of
* the parent menu entry, so just copy the pointer */
- if (submenu != wimp_NO_SUB_MENU &&
- IS_MENU(entry->menu_entry, submenu)) {
+ if (submenu != wimp_NO_SUB_MENU && IS_MENU(submenu)) {
submenu->title_data.indirected_text.text =
translated;
}
diff --git a/riscos/menus.h b/riscos/menus.h
index 818018f7c..e42849206 100644
--- a/riscos/menus.h
+++ b/riscos/menus.h
@@ -103,7 +103,6 @@ typedef enum {
TREE_SELECTION_EDIT,
TREE_SELECTION_LAUNCH,
TREE_SELECTION_DELETE,
- TREE_SELECTION_RESET,
TREE_SELECT_ALL,
TREE_CLEAR_SELECTION,
@@ -126,11 +125,12 @@ bool ro_gui_menu_handle_action(wimp_w owner, menu_action action,
bool windows_at_pointer);
void ro_gui_menu_prepare_action(wimp_w owner, menu_action action,
bool windows);
-void ro_gui_menu_closed(void);
+void ro_gui_menu_closed(bool cleanup);
void ro_gui_menu_objects_moved(void);
void ro_gui_popup_menu(wimp_menu *menu, wimp_w w, wimp_i i);
void ro_gui_menu_selection(wimp_selection* selection);
void ro_gui_menu_warning(wimp_message_menu_warning *warning);
+void ro_gui_menu_init_structure(wimp_menu *menu, int entries);
void ro_gui_prepare_navigate(struct gui_window *gui);
void ro_gui_menu_prepare_image_quality(unsigned int tinct_options);
void ro_gui_menu_prepare_languages(bool accept, const char *lang);
diff --git a/riscos/print.c b/riscos/print.c
index 29663f259..e07431f1a 100644
--- a/riscos/print.c
+++ b/riscos/print.c
@@ -21,10 +21,12 @@
#include "netsurf/render/font.h"
#include "netsurf/render/html.h"
#include "netsurf/render/layout.h"
+#include "netsurf/riscos/dialog.h"
#include "netsurf/riscos/gui.h"
#include "netsurf/riscos/menus.h"
#include "netsurf/riscos/print.h"
#include "netsurf/riscos/wimp.h"
+#include "netsurf/riscos/wimp_event.h"
#include "netsurf/utils/log.h"
#include "netsurf/utils/messages.h"
#include "netsurf/utils/utils.h"
@@ -66,6 +68,29 @@ static const char *print_declare_fonts(struct box *box);
static bool print_find_fonts(struct box *box, struct print_font **print_fonts,
int *font_count);
+static bool ro_gui_print_click(wimp_pointer *pointer);
+static bool ro_gui_print_apply(wimp_w w);
+
+
+void ro_gui_print_init(void) {
+ wimp_i radio_print_type[] = {ICON_PRINT_TO_BOTTOM, ICON_PRINT_SHEETS, -1};
+ wimp_i radio_print_orientation[] = {ICON_PRINT_UPRIGHT, ICON_PRINT_SIDEWAYS, -1};
+
+ dialog_print = ro_gui_dialog_create("print");
+ ro_gui_wimp_event_register_radio(dialog_print, radio_print_type);
+ ro_gui_wimp_event_register_radio(dialog_print, radio_print_orientation);
+ ro_gui_wimp_event_register_text_field(dialog_print, ICON_PRINT_SHEETS_TEXT);
+ ro_gui_wimp_event_register_numeric_field(dialog_print, ICON_PRINT_COPIES,
+ ICON_PRINT_COPIES_UP, ICON_PRINT_COPIES_DOWN, 1, 99, 1, 0);
+ ro_gui_wimp_event_register_numeric_field(dialog_print, ICON_PRINT_SHEETS_VALUE,
+ ICON_PRINT_SHEETS_UP, ICON_PRINT_SHEETS_DOWN, 1, 99, 1, 0);
+ ro_gui_wimp_event_register_cancel(dialog_print, ICON_PRINT_CANCEL);
+ ro_gui_wimp_event_register_mouse_click(dialog_print, ro_gui_print_click);
+ ro_gui_wimp_event_register_ok(dialog_print, ICON_PRINT_PRINT,
+ ro_gui_print_apply);
+ ro_gui_wimp_event_set_help_prefix(dialog_info, "HelpPrint");
+}
+
/**
* Prepares all aspects of the print dialog prior to opening.
*
@@ -94,8 +119,6 @@ void ro_gui_print_prepare(struct gui_window *g) {
ro_gui_set_icon_selected_state(dialog_print, ICON_PRINT_SHEETS, false);
ro_gui_set_icon_integer(dialog_print, ICON_PRINT_SHEETS_VALUE, 1);
- ro_gui_set_icon_string(dialog_print, ICON_PRINT_SHEETS_TEXT,
- messages_get("PrintSheetFilled"));
print_update_sheets_shaded_state(true);
ro_gui_set_icon_selected_state(dialog_print, ICON_PRINT_FG_IMAGES, true);
@@ -119,6 +142,7 @@ void ro_gui_print_prepare(struct gui_window *g) {
ro_gui_set_icon_shaded_state(dialog_print, ICON_PRINT_PRINT, false);
ro_gui_set_window_title(dialog_print, pdName);
}
+ ro_gui_wimp_event_memorise(dialog_print);
}
@@ -127,99 +151,37 @@ void ro_gui_print_prepare(struct gui_window *g) {
*
* \param pointer wimp_pointer block
*/
-void ro_gui_print_click(wimp_pointer *pointer)
+bool ro_gui_print_click(wimp_pointer *pointer)
{
- int copies = atoi(ro_gui_get_icon_string(dialog_print,
- ICON_PRINT_COPIES));
- int sheets = atoi(ro_gui_get_icon_string(dialog_print,
- ICON_PRINT_SHEETS_VALUE));
-
if (pointer->buttons == wimp_CLICK_MENU)
- return;
+ return true;
switch (pointer->i) {
case ICON_PRINT_SHEETS:
- /* retain selection state */
- ro_gui_set_icon_selected_state(dialog_print,
- pointer->i, true);
- print_update_sheets_shaded_state(false);
- break;
case ICON_PRINT_TO_BOTTOM:
print_update_sheets_shaded_state(true);
- case ICON_PRINT_UPRIGHT:
- case ICON_PRINT_SIDEWAYS:
- /* retain selection state */
- ro_gui_set_icon_selected_state(dialog_print,
- pointer->i, true);
- break;
- case ICON_PRINT_COPIES_UP: copies += 1; break;
- case ICON_PRINT_COPIES_DOWN: copies -= 1; break;
- case ICON_PRINT_SHEETS_UP: sheets += 1; break;
- case ICON_PRINT_SHEETS_DOWN: sheets -= 1; break;
- case ICON_PRINT_CANCEL:
- print_cleanup();
- break;
- case ICON_PRINT_PRINT:
- print_in_background = ro_gui_get_icon_selected_state(dialog_print, ICON_PRINT_IN_BACKGROUND);
- print_text_black = ro_gui_get_icon_selected_state(dialog_print, ICON_PRINT_TEXT_BLACK);
- print_num_copies = copies;
- if (ro_gui_get_icon_selected_state(dialog_print, ICON_PRINT_SHEETS))
- print_max_sheets = sheets;
- else
- print_max_sheets = -1;
- print_current_window->option.background_images = ro_gui_get_icon_selected_state(dialog_print, ICON_PRINT_BG_IMAGES);
- print_send_printsave(print_current_window->bw->current_content);
break;
}
-
- if (copies < 1)
- copies = 1;
- else if (copies > 99)
- copies = 99;
- ro_gui_set_icon_integer(dialog_print, ICON_PRINT_COPIES, copies);
-
- if (sheets < 1)
- sheets = 1;
- else if (sheets > 99)
- sheets = 99;
- ro_gui_set_icon_integer(dialog_print, ICON_PRINT_SHEETS_VALUE, sheets);
- if (sheets > 1)
- ro_gui_set_icon_string(dialog_print, ICON_PRINT_SHEETS_TEXT,
- messages_get("PrintSheetsFilled"));
- else
- ro_gui_set_icon_string(dialog_print, ICON_PRINT_SHEETS_TEXT,
- messages_get("PrintSheetFilled"));
+ return false;
}
-/**
- * Handle keypresses in print dialog
- *
- * \param key wimp_key block
- * \return true if keypress dealt with, false otherwise.
- */
-bool ro_gui_print_keypress(wimp_key *key)
-{
- switch (key->c) {
- case wimp_KEY_ESCAPE:
- print_cleanup();
- return true;
- case wimp_KEY_RETURN:
- if (ro_gui_get_icon_shaded_state(dialog_print, ICON_PRINT_PRINT))
- return true;
-
- print_in_background = ro_gui_get_icon_selected_state(dialog_print, ICON_PRINT_IN_BACKGROUND);
- print_text_black = ro_gui_get_icon_selected_state(dialog_print, ICON_PRINT_TEXT_BLACK);
- print_num_copies = atoi(ro_gui_get_icon_string(dialog_print, ICON_PRINT_COPIES));
- if (ro_gui_get_icon_selected_state(dialog_print, ICON_PRINT_SHEETS))
- print_max_sheets = atoi(ro_gui_get_icon_string(dialog_print, ICON_PRINT_SHEETS_VALUE));
- else
- print_max_sheets = -1;
- print_current_window->option.background_images = ro_gui_get_icon_selected_state(dialog_print, ICON_PRINT_BG_IMAGES);
- print_send_printsave(print_current_window->bw->current_content);
- return true;
- }
- return false;
+bool ro_gui_print_apply(wimp_w w) {
+ int copies = atoi(ro_gui_get_icon_string(dialog_print,
+ ICON_PRINT_COPIES));
+ int sheets = atoi(ro_gui_get_icon_string(dialog_print,
+ ICON_PRINT_SHEETS_VALUE));
+
+ print_in_background = ro_gui_get_icon_selected_state(dialog_print, ICON_PRINT_IN_BACKGROUND);
+ print_text_black = ro_gui_get_icon_selected_state(dialog_print, ICON_PRINT_TEXT_BLACK);
+ print_num_copies = copies;
+ if (ro_gui_get_icon_selected_state(dialog_print, ICON_PRINT_SHEETS))
+ print_max_sheets = sheets;
+ else
+ print_max_sheets = -1;
+ print_current_window->option.background_images = ro_gui_get_icon_selected_state(dialog_print, ICON_PRINT_BG_IMAGES);
+ print_send_printsave(print_current_window->bw->current_content);
+ return true;
}
/**
@@ -453,7 +415,7 @@ void print_cleanup(void)
print_text_black = false;
print_prev_message = 0;
print_max_sheets = -1;
- ro_gui_menu_closed();
+ ro_gui_menu_closed(true);
ro_gui_dialog_close(dialog_print);
}
diff --git a/riscos/query.c b/riscos/query.c
index 8d3383f16..c04aeeb14 100644
--- a/riscos/query.c
+++ b/riscos/query.c
@@ -7,7 +7,7 @@
#include <stdlib.h>
-#include "netsurf/riscos/gui.h"
+#include "netsurf/riscos/dialog.h"
#include "netsurf/riscos/query.h"
#include "netsurf/riscos/wimp.h"
#include "netsurf/utils/log.h"
@@ -126,7 +126,7 @@ query_id query_user(const char *query, const char *detail, const query_callback
xwimp_set_icon_state(qw->window, ICON_QUERY_HELP,
wimp_ICON_DELETED, wimp_ICON_DELETED);
- ro_gui_open_window_centre(NULL, qw->window);
+ ro_gui_dialog_open(qw->window);
error = xwimp_set_caret_position(qw->window, (wimp_i)-1, 0, 0, 1 << 25, -1);
if (error) {
@@ -196,7 +196,7 @@ void ro_gui_query_window_bring_to_front(query_id id)
if (qw) {
os_error *error;
- ro_gui_open_window_centre(NULL, qw->window);
+ ro_gui_dialog_open(qw->window);
error = xwimp_set_caret_position(qw->window, (wimp_i)-1, 0, 0, 1 << 25, -1);
if (error) {
diff --git a/riscos/save.c b/riscos/save.c
index 4d9c93df6..e2a315a56 100644
--- a/riscos/save.c
+++ b/riscos/save.c
@@ -27,6 +27,7 @@
#include "netsurf/desktop/save_text.h"
#include "netsurf/desktop/selection.h"
#include "netsurf/image/bitmap.h"
+#include "netsurf/riscos/dialog.h"
#include "netsurf/riscos/gui.h"
#include "netsurf/riscos/menus.h"
#include "netsurf/riscos/options.h"
@@ -34,6 +35,7 @@
#include "netsurf/riscos/save_draw.h"
#include "netsurf/riscos/thumbnail.h"
#include "netsurf/riscos/wimp.h"
+#include "netsurf/riscos/wimp_event.h"
#include "netsurf/utils/config.h"
#include "netsurf/utils/log.h"
#include "netsurf/utils/messages.h"
@@ -200,37 +202,22 @@ void ro_gui_save_prepare(gui_save_type save_type, struct content *c)
icon_buf);
ro_gui_set_icon_string(dialog_saveas, ICON_SAVE_PATH, name_buf);
+ ro_gui_wimp_event_memorise(dialog_saveas);
}
/**
- * Handle clicks in the save dialog.
+ * Starts a drag for the save dialog
*
* \param pointer mouse position info from Wimp
*/
-
-void ro_gui_save_click(wimp_pointer *pointer)
+void ro_gui_save_start_drag(wimp_pointer *pointer)
{
- switch (pointer->i) {
- case ICON_SAVE_OK:
- ro_gui_save_ok(pointer->w);
- break;
- case ICON_SAVE_CANCEL:
- if (pointer->buttons == wimp_CLICK_SELECT) {
- xwimp_create_menu(wimp_CLOSE_MENU, 0, 0);
- ro_gui_dialog_close(pointer->w);
- } else if (pointer->buttons == wimp_CLICK_ADJUST) {
- ro_gui_save_prepare(gui_save_current_type, gui_save_content);
- }
- break;
- case ICON_SAVE_ICON:
- if (pointer->buttons == wimp_DRAG_SELECT) {
- const char *sprite = ro_gui_get_icon_string(pointer->w, pointer->i);
- gui_current_drag_type = GUI_DRAG_SAVE;
- gui_save_sourcew = pointer->w;
- saving_from_dialog = true;
- ro_gui_drag_icon(pointer->pos.x, pointer->pos.y, sprite);
- }
- break;
+ if (pointer->buttons == wimp_DRAG_SELECT) {
+ const char *sprite = ro_gui_get_icon_string(pointer->w, pointer->i);
+ gui_current_drag_type = GUI_DRAG_SAVE;
+ gui_save_sourcew = pointer->w;
+ saving_from_dialog = true;
+ ro_gui_drag_icon(pointer->pos.x, pointer->pos.y, sprite);
}
}
@@ -239,26 +226,22 @@ void ro_gui_save_click(wimp_pointer *pointer)
* Handle OK click/keypress in the save dialog.
*
* \param w window handle of save dialog
+ * \return true on success, false on failure
*/
-
-void ro_gui_save_ok(wimp_w w)
+bool ro_gui_save_ok(wimp_w w)
{
char *name = ro_gui_get_icon_string(w, ICON_SAVE_PATH);
char path[256];
- if (!strrchr(name, '.'))
- {
+ if (!strrchr(name, '.')) {
warn_user("NoPathError", NULL);
- return;
+ return false;
}
ro_gui_convert_save_path(path, sizeof path, name);
gui_save_sourcew = w;
saving_from_dialog = true;
- if (ro_gui_save_content(gui_save_content, path)) {
- xwimp_create_menu(wimp_CLOSE_MENU, 0, 0);
- ro_gui_dialog_close(w);
- }
+ return ro_gui_save_content(gui_save_content, path);
}
diff --git a/riscos/theme.c b/riscos/theme.c
index f71d6f3c1..929e3d281 100644
--- a/riscos/theme.c
+++ b/riscos/theme.c
@@ -30,7 +30,9 @@
#include "netsurf/riscos/menus.h"
#include "netsurf/riscos/options.h"
#include "netsurf/riscos/theme.h"
+#include "netsurf/riscos/treeview.h"
#include "netsurf/riscos/wimp.h"
+#include "netsurf/riscos/wimp_event.h"
#include "netsurf/utils/log.h"
#include "netsurf/utils/utils.h"
@@ -53,7 +55,7 @@ static const char * theme_hotlist_icons[] = {"delete", "expand", "open",
static const char * theme_history_icons[] = {"delete", "expand", "open",
"launch", NULL};
-
+static void ro_gui_theme_redraw(wimp_draw *redraw);
static void ro_gui_theme_get_available_in_dir(const char *directory);
static void ro_gui_theme_free(struct theme_descriptor *descriptor);
static struct toolbar_icon *ro_gui_theme_add_toolbar_icon(
@@ -70,6 +72,8 @@ static struct toolbar_icon *ro_gui_theme_toolbar_get_insert_icon(
struct toolbar *toolbar, int x, int y, bool *before);
static void ro_gui_theme_add_toolbar_icons(struct toolbar *toolbar,
const char* icons[], const char* ident);
+static void ro_gui_theme_set_help_prefix(struct toolbar *toolbar);
+
/* A basic window for the toolbar and status
*/
@@ -169,17 +173,13 @@ struct theme_descriptor *ro_gui_theme_get_available(void) {
*/
ro_gui_theme_free(theme_descriptors);
- /* Open a variety of directories
- */
+ /* scan !NetSurf.Resources.* and our choices directory */
snprintf(pathname, 256, "%s.Resources", NETSURF_DIR);
pathname[255] = '\0';
ro_gui_theme_get_available_in_dir(pathname);
-#ifndef NCOS
- ro_gui_theme_get_available_in_dir("Choices:WWW.NetSurf.Themes");
-#else
- ro_gui_theme_get_available_in_dir(
- "<User$Path>.Choices.NetSurf.Choices.Themes");
-#endif
+ snprintf(pathname, 256, "%s%s", THEME_PATH_R, THEME_LEAFNAME);
+ pathname[255] = '\0';
+ ro_gui_theme_get_available_in_dir(pathname);
/* Sort alphabetically in a very rubbish way
*/
@@ -595,8 +595,8 @@ void ro_gui_theme_close(struct theme_descriptor *descriptor, bool list) {
* \param redraw the redraw area
* \param toolbar the toolbar to redraw
*/
-void ro_gui_theme_redraw(struct toolbar *toolbar, wimp_draw *redraw) {
- assert(toolbar);
+void ro_gui_theme_redraw(wimp_draw *redraw) {
+ struct toolbar *toolbar;
struct toolbar_icon *icon;
osbool more;
@@ -604,6 +604,10 @@ void ro_gui_theme_redraw(struct toolbar *toolbar, wimp_draw *redraw) {
os_error *error;
bool perform_redraw = false;
+ toolbar = (struct toolbar *)ro_gui_wimp_event_get_user_data(redraw->w);
+
+ assert(toolbar);
+
/* set up the icon */
if ((toolbar->descriptor) && (toolbar->descriptor->theme) &&
(toolbar->descriptor->theme->sprite_area)) {
@@ -855,6 +859,7 @@ bool ro_gui_theme_update_toolbar(struct theme_descriptor *descriptor,
if (error)
LOG(("xwimp_delete_window: 0x%x: %s",
error->errnum, error->errmess));
+ ro_gui_wimp_event_finalise(toolbar->toolbar_handle);
toolbar->toolbar_handle = NULL;
}
error = xwimp_create_window(&theme_toolbar_window,
@@ -865,6 +870,23 @@ bool ro_gui_theme_update_toolbar(struct theme_descriptor *descriptor,
warn_user("WimpError", error->errmess);
return false;
}
+ ro_gui_wimp_event_register_redraw_window(toolbar->toolbar_handle,
+ ro_gui_theme_redraw);
+ ro_gui_wimp_event_set_user_data(toolbar->toolbar_handle, toolbar);
+ switch (toolbar->type) {
+ case THEME_BROWSER_TOOLBAR:
+ case THEME_BROWSER_EDIT_TOOLBAR:
+ ro_gui_wimp_event_register_mouse_click(toolbar->toolbar_handle,
+ ro_gui_toolbar_click);
+ break;
+ case THEME_HOTLIST_TOOLBAR:
+ case THEME_HOTLIST_EDIT_TOOLBAR:
+ case THEME_HISTORY_TOOLBAR:
+ case THEME_HISTORY_EDIT_TOOLBAR:
+ ro_gui_wimp_event_register_mouse_click(toolbar->toolbar_handle,
+ ro_gui_tree_toolbar_click);
+ break;
+ }
/* Create the basic icons
*/
@@ -993,6 +1015,7 @@ bool ro_gui_theme_update_toolbar(struct theme_descriptor *descriptor,
if (toolbar->status_handle) {
xwimp_delete_window(toolbar->status_handle);
toolbar->status_handle = NULL;
+ ro_gui_wimp_event_finalise(toolbar->status_handle);
}
if (toolbar->descriptor)
theme_toolbar_window.work_bg =
@@ -1014,6 +1037,9 @@ bool ro_gui_theme_update_toolbar(struct theme_descriptor *descriptor,
warn_user("WimpError", error->errmess);
return false;
}
+ ro_gui_wimp_event_register_mouse_click(toolbar->status_handle,
+ ro_gui_status_click);
+ ro_gui_wimp_event_set_help_prefix(toolbar->status_handle, "HelpStatus");
/* Create the status resize icon
*/
@@ -1077,6 +1103,7 @@ bool ro_gui_theme_update_toolbar(struct theme_descriptor *descriptor,
/* Keep menus up to date etc
*/
+ ro_gui_theme_set_help_prefix(toolbar);
switch (toolbar->type) {
case THEME_BROWSER_TOOLBAR:
g = ro_gui_window_lookup(toolbar->parent_handle);
@@ -1616,11 +1643,15 @@ void ro_gui_theme_destroy_toolbar(struct toolbar *toolbar) {
/* Delete our windows
*/
- if (toolbar->toolbar_handle)
+ if (toolbar->toolbar_handle) {
xwimp_delete_window(toolbar->toolbar_handle);
- if (toolbar->status_handle)
+ ro_gui_wimp_event_finalise(toolbar->toolbar_handle);
+ }
+ if (toolbar->status_handle) {
xwimp_delete_window(toolbar->status_handle);
+ ro_gui_wimp_event_finalise(toolbar->status_handle);
+ }
/* Free the Wimp buffer (we only created one for them all)
*/
free(toolbar->url_buffer);
@@ -1762,6 +1793,7 @@ void ro_gui_theme_toggle_edit(struct toolbar *toolbar) {
ro_gui_theme_process_toolbar(toolbar, -1);
ro_gui_theme_toolbar_editor_sync(toolbar);
}
+ ro_gui_theme_set_help_prefix(toolbar);
}
@@ -2223,3 +2255,34 @@ void ro_gui_theme_add_toolbar_icons(struct toolbar *toolbar,
}
}
}
+
+
+/**
+ * Sets the correct help prefix for a 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");
+ return;
+ }
+ switch (toolbar->type) {
+ case THEME_BROWSER_TOOLBAR:
+ ro_gui_wimp_event_set_help_prefix(toolbar->toolbar_handle,
+ "HelpToolbar");
+ break;
+ case THEME_HOTLIST_TOOLBAR:
+ ro_gui_wimp_event_set_help_prefix(toolbar->toolbar_handle,
+ "HelpHotToolbar");
+ break;
+ case THEME_HISTORY_TOOLBAR:
+ ro_gui_wimp_event_set_help_prefix(toolbar->toolbar_handle,
+ "HelpGHistToolbar");
+ break;
+ case THEME_BROWSER_EDIT_TOOLBAR:
+ case THEME_HOTLIST_EDIT_TOOLBAR:
+ case THEME_HISTORY_EDIT_TOOLBAR:
+ ro_gui_wimp_event_set_help_prefix(toolbar->toolbar_handle,
+ "HelpEditToolbar");
+ break;
+ }
+}
diff --git a/riscos/theme.h b/riscos/theme.h
index d0a9f0428..1cf99dbc1 100644
--- a/riscos/theme.h
+++ b/riscos/theme.h
@@ -14,6 +14,18 @@
#ifndef _NETSURF_RISCOS_THEME_H_
#define _NETSURF_RISCOS_THEME_H_
+
+#ifndef NCOS
+#define THEME_LEAFNAME "WWW.NetSurf.Themes"
+#define THEME_PATH_W "<Choices$Write>."
+#define THEME_PATH_R "Choices:"
+#else
+#define THEME_LEAFNAME "NetSurf.Choices.Themes"
+#define THEME_PATH_W "<User$Path>.Choices."
+#define THEME_PATH_R THEME_PATH_W
+#endif
+
+
typedef enum {
THEME_BROWSER_TOOLBAR,
THEME_HOTLIST_TOOLBAR,
@@ -112,7 +124,6 @@ bool ro_gui_theme_read_file_header(struct theme_descriptor *descriptor,
bool ro_gui_theme_open(struct theme_descriptor *descriptor, bool list);
bool ro_gui_theme_apply(struct theme_descriptor *descriptor);
void ro_gui_theme_close(struct theme_descriptor *descriptor, bool list);
-void ro_gui_theme_redraw(struct toolbar *toolbar, wimp_draw *redraw);
struct toolbar *ro_gui_theme_create_toolbar(struct theme_descriptor *descriptor, toolbar_type type);
bool ro_gui_theme_update_toolbar(struct theme_descriptor *descriptor, struct toolbar *toolbar);
diff --git a/riscos/theme_install.c b/riscos/theme_install.c
index 9c483ba8b..37ad83ff7 100644
--- a/riscos/theme_install.c
+++ b/riscos/theme_install.c
@@ -14,38 +14,27 @@
#include "oslib/osfile.h"
#include "netsurf/content/content.h"
#include "netsurf/desktop/browser.h"
+#include "netsurf/riscos/dialog.h"
#include "netsurf/riscos/gui.h"
#include "netsurf/riscos/options.h"
#include "netsurf/riscos/theme.h"
#include "netsurf/riscos/wimp.h"
+#include "netsurf/riscos/wimp_event.h"
#include "netsurf/utils/log.h"
#include "netsurf/utils/messages.h"
#include "netsurf/utils/url.h"
#include "netsurf/utils/utils.h"
-static bool theme_install_active;
static struct content *theme_install_content = NULL;
static struct theme_descriptor theme_install_descriptor;
wimp_w dialog_theme_install;
-static void theme_install_close(void);
+static void theme_install_close(wimp_w w);
static void theme_install_callback(content_msg msg, struct content *c,
void *p1, void *p2, union content_msg_data data);
static bool theme_install_read(char *source_data, unsigned long source_size);
-static void theme_install_install(bool apply);
-
-
-#ifndef NCOS
-#define THEME_LEAFNAME "WWW.NetSurf.Themes"
-#define THEME_PATH_W "<Choices$Write>."
-#define THEME_PATH_R "Choices:"
-#else
-#define THEME_LEAFNAME "NetSurf.Choices.Themes"
-#define THEME_PATH_W "<User$Path>.Choices."
-#define THEME_PATH_R THEME_PATH_W
-#endif
/**
@@ -57,27 +46,24 @@ void theme_install_start(struct content *c)
assert(c);
assert(c->type == CONTENT_THEME);
- if (theme_install_active) {
+ if (ro_gui_dialog_open_top(dialog_theme_install, NULL, 0, 0)) {
warn_user("ThemeInstActive", 0);
- /* raise & centre dialog */
return;
}
/* stop theme sitting in memory cache */
c->fresh = false;
-
if (!content_add_user(c, theme_install_callback, 0, 0)) {
warn_user("NoMemory", 0);
return;
}
- theme_install_active = true;
-
ro_gui_set_icon_string(dialog_theme_install, ICON_THEME_INSTALL_MESSAGE,
messages_get("ThemeInstDown"));
ro_gui_set_icon_shaded_state(dialog_theme_install,
ICON_THEME_INSTALL_INSTALL, true);
- ro_gui_dialog_open(dialog_theme_install);
+ ro_gui_wimp_event_register_close_window(dialog_theme_install,
+ theme_install_close);
}
@@ -99,7 +85,7 @@ void theme_install_callback(content_msg msg, struct content *c,
theme_install_content = c;
if (!theme_install_read(c->source_data, c->source_size)) {
warn_user("ThemeInvalid", 0);
- theme_install_close();
+ theme_install_close(dialog_theme_install);
break;
}
@@ -120,7 +106,7 @@ void theme_install_callback(content_msg msg, struct content *c,
break;
case CONTENT_MSG_ERROR:
- theme_install_close();
+ theme_install_close(dialog_theme_install);
warn_user(data.error, 0);
break;
@@ -165,40 +151,16 @@ bool theme_install_read(char *source_data, unsigned long source_size)
/**
- * Handle clicks in the theme install window.
- */
-
-void ro_gui_theme_install_click(wimp_pointer *pointer)
-{
- switch (pointer->i) {
- case ICON_THEME_INSTALL_INSTALL:
- theme_install_install(pointer->buttons == wimp_CLICK_SELECT);
- theme_install_close();
- break;
- case ICON_THEME_INSTALL_CANCEL:
- if (pointer->buttons == wimp_CLICK_ADJUST)
- break;
- theme_install_close();
- break;
- }
-}
-
-
-/**
* Install the downloaded theme.
*
- * \param apply make the theme the current theme
+ * \param w the theme install window handle
*/
-void theme_install_install(bool apply)
+bool ro_gui_theme_install_apply(wimp_w w)
{
char theme_save[256];
- char theme_leaf[256];
char *theme_file;
- int theme_number = 1;
- bool theme_found;
struct theme_descriptor *theme_install;
- fileswitch_object_type obj_type;
os_error *error;
assert(theme_install_content);
@@ -206,37 +168,14 @@ void theme_install_install(bool apply)
if (url_nice(theme_install_descriptor.name, &theme_file, true) !=
URL_FUNC_OK) {
warn_user("ThemeInstallErr", 0);
- theme_install_close();
- return;
+ return false;
}
- theme_found = false;
- while (!theme_found) {
- if (theme_number == 1)
- snprintf(theme_leaf, sizeof theme_leaf, "%s.%s",
- THEME_LEAFNAME, theme_file);
- else
- snprintf(theme_leaf, sizeof theme_leaf, "%s.%s%i",
- THEME_LEAFNAME, theme_file,
- theme_number);
- theme_leaf[sizeof theme_leaf - 1] = '\0';
- theme_number++;
- snprintf(theme_save, sizeof theme_save, "%s%s",
- THEME_PATH_W, theme_leaf);
- theme_save[sizeof theme_save - 1] = '\0';
- error = xosfile_read_stamped_no_path(theme_save,
- &obj_type, 0, 0, 0, 0, 0);
- if (error) {
- LOG(("xosfile_read_stamped_no_path: 0x%x: %s",
- error->errnum, error->errmess));
- warn_user("ThemeInstallErr", 0);
- theme_install_close();
- free(theme_file);
- return;
- }
- theme_found = (obj_type == osfile_NOT_FOUND);
- }
+ /* simply overwrite previous theme versions */
+ snprintf(theme_save, sizeof theme_save, "%s%s.%s",
+ THEME_PATH_W, THEME_LEAFNAME, theme_file);
+ theme_save[sizeof theme_save - 1] = '\0';
error = xosfile_save_stamped(theme_save, 0xffd,
theme_install_content->source_data,
theme_install_content->source_data +
@@ -245,22 +184,22 @@ void theme_install_install(bool apply)
LOG(("xosfile_save_stamped: 0x%x: %s",
error->errnum, error->errmess));
warn_user("ThemeInstallErr", 0);
- theme_install_close();
free(theme_file);
- return;
+ return false;
}
-
- if (apply) {
- ro_gui_theme_get_available();
- theme_install = ro_gui_theme_find(theme_file);
- if (!theme_install || !ro_gui_theme_apply(theme_install)) {
- warn_user("ThemeApplyErr", 0);
- } else {
- free(option_theme);
- option_theme = strdup(theme_install->leafname);
- }
+
+ /* apply the new theme */
+ ro_gui_theme_get_available();
+ theme_install = ro_gui_theme_find(theme_file);
+ if (!theme_install || !ro_gui_theme_apply(theme_install)) {
+ warn_user("ThemeApplyErr", 0);
+ } else {
+ free(option_theme);
+ option_theme = strdup(theme_install->leafname);
}
free(theme_file);
+ ro_gui_save_options();
+ return true;
}
@@ -268,12 +207,10 @@ void theme_install_install(bool apply)
* Close the theme installer and free resources.
*/
-void theme_install_close(void)
+void theme_install_close(wimp_w w)
{
- theme_install_active = false;
if (theme_install_content)
content_remove_user(theme_install_content,
theme_install_callback, 0, 0);
theme_install_content = NULL;
- ro_gui_dialog_close(dialog_theme_install);
}
diff --git a/riscos/url_complete.c b/riscos/url_complete.c
index d8fa10bfe..2926cbcc4 100644
--- a/riscos/url_complete.c
+++ b/riscos/url_complete.c
@@ -511,7 +511,7 @@ void ro_gui_url_complete_redraw(wimp_draw *redraw) {
* Handle mouse movements/clicks over the URL completion window.
*
* \param pointer the pointer state
- * \param buttons whethere to react to mouse buttons
+ * \param buttons whether to react to mouse buttons
*/
void ro_gui_url_complete_mouse_at(wimp_pointer *pointer, bool buttons) {
wimp_window_state state;
diff --git a/riscos/wimp.c b/riscos/wimp.c
index 820835b58..f738dbc87 100644
--- a/riscos/wimp.c
+++ b/riscos/wimp.c
@@ -23,6 +23,7 @@
#include "oslib/wimpspriteop.h"
#include "netsurf/desktop/gui.h"
#include "netsurf/riscos/gui.h"
+#include "netsurf/riscos/theme.h"
#include "netsurf/riscos/wimp.h"
#include "netsurf/utils/log.h"
#include "netsurf/utils/utf8.h"
@@ -295,6 +296,53 @@ void ro_gui_set_icon_integer(wimp_w w, wimp_i i, int value) {
/**
+ * Set the contents of an icon to a number.
+ *
+ * \param w window handle
+ * \param i icon handle
+ * \param value value
+ */
+void ro_gui_set_icon_decimal(wimp_w w, wimp_i i, int value, int decimal_places) {
+ char buffer[20]; // Big enough for 64-bit int
+
+ switch (decimal_places) {
+ case 0:
+ sprintf(buffer, "%d", value);
+ break;
+ case 1:
+ sprintf(buffer, "%.1f", (float)value / 10);
+ break;
+ case 2:
+ sprintf(buffer, "%.2f", (float)value / 100);
+ break;
+ default:
+ assert("Unsupported decimal format");
+ break;
+ }
+ ro_gui_set_icon_string(w, i, buffer);
+}
+
+
+/**
+ * Set the contents of an icon to a number.
+ *
+ * \param w window handle
+ * \param i icon handle
+ * \param value value
+ */
+int ro_gui_get_icon_decimal(wimp_w w, wimp_i i, int decimal_places) {
+ double value;
+ int multiple = 1;
+
+ for (; decimal_places > 0; decimal_places--)
+ multiple *= 10;
+
+ value = atof(ro_gui_get_icon_string(w, i)) * multiple;
+ return (int)value;
+}
+
+
+/**
* Set the selected state of an icon.
*
* \param w window handle
@@ -549,66 +597,6 @@ void ro_gui_set_caret_first(wimp_w w) {
/**
- * Opens a window at the centre of either another window or the screen
- *
- * /param parent the parent window (NULL for centre of screen)
- * /param child the child window
- */
-void ro_gui_open_window_centre(wimp_w parent, wimp_w child) {
- os_error *error;
- wimp_window_state state;
- int mid_x, mid_y;
- int dimension, scroll_width;
-
- /* get the parent window state */
- if (parent) {
- state.w = parent;
- error = xwimp_get_window_state(&state);
- if (error) {
- LOG(("xwimp_get_window_state: 0x%x: %s",
- error->errnum, error->errmess));
- warn_user("WimpError", error->errmess);
- return;
- }
- scroll_width = ro_get_vscroll_width(parent);
- mid_x = (state.visible.x0 + state.visible.x1 + scroll_width);
- mid_y = (state.visible.y0 + state.visible.y1);
- } else {
- ro_gui_screen_size(&mid_x, &mid_y);
- }
- mid_x /= 2;
- mid_y /= 2;
-
- /* get the child window state */
- state.w = child;
- error = xwimp_get_window_state(&state);
- if (error) {
- LOG(("xwimp_get_window_state: 0x%x: %s",
- error->errnum, error->errmess));
- warn_user("WimpError", error->errmess);
- return;
- }
-
- /* move to the centre of the parent at the top of the stack */
- dimension = state.visible.x1 - state.visible.x0;
- scroll_width = ro_get_vscroll_width(history_window);
- state.visible.x0 = mid_x - (dimension + scroll_width) / 2;
- state.visible.x1 = state.visible.x0 + dimension;
- dimension = state.visible.y1 - state.visible.y0;
- state.visible.y0 = mid_y - dimension / 2;
- state.visible.y1 = state.visible.y0 + dimension;
- state.next = wimp_TOP;
- error = xwimp_open_window((wimp_open *) &state);
- if (error) {
- LOG(("xwimp_open_window: 0x%x: %s",
- error->errnum, error->errmess));
- warn_user("WimpError", error->errmess);
- return;
- }
-}
-
-
-/**
* Load a sprite file into memory.
*
* \param pathname file to load
@@ -687,7 +675,7 @@ bool ro_gui_wimp_sprite_exists(const char *sprite)
/**
* Locate a sprite in the Wimp sprite pool, returning a pointer to it.
*
- * \param name sprite name
+ * \param name sprite name
* \param sprite receives pointer to sprite if found
* \return error ptr iff not found
*/
@@ -856,7 +844,7 @@ void ro_gui_wimp_update_window_furniture(wimp_w w, wimp_window_flags bic_mask,
* Checks whether a piece of window furniture is present for a window.
*
* \param w the window to modify
- * \param mask the furniture flags to check
+ * \param mask the furniture flags to check
*/
bool ro_gui_wimp_check_window_furniture(wimp_w w, wimp_window_flags mask) {
wimp_window_state state;
diff --git a/riscos/wimp.h b/riscos/wimp.h
index 8ec3ab3bd..8a93f03f5 100644
--- a/riscos/wimp.h
+++ b/riscos/wimp.h
@@ -31,7 +31,11 @@ void ro_convert_pixels_to_os_units(os_coord *pixels, os_mode mode);
void ro_gui_force_redraw_icon(wimp_w w, wimp_i i);
char *ro_gui_get_icon_string(wimp_w w, wimp_i i);
void ro_gui_set_icon_string(wimp_w w, wimp_i i, const char *text);
+
void ro_gui_set_icon_integer(wimp_w w, wimp_i i, int value);
+void ro_gui_set_icon_decimal(wimp_w w, wimp_i i, int value, int decimal_places);
+int ro_gui_get_icon_decimal(wimp_w w, wimp_i i, int decimal_places);
+
void ro_gui_set_icon_selected_state(wimp_w w, wimp_i i, bool state);
bool ro_gui_get_icon_selected_state(wimp_w w, wimp_i i);
void ro_gui_set_icon_shaded_state(wimp_w w, wimp_i i, bool state);
diff --git a/riscos/window.c b/riscos/window.c
index 3fec73cdd..0a63b0b31 100644
--- a/riscos/window.c
+++ b/riscos/window.c
@@ -37,6 +37,7 @@
#include "netsurf/render/box.h"
#include "netsurf/render/form.h"
#include "netsurf/riscos/buffer.h"
+#include "netsurf/riscos/dialog.h"
#include "netsurf/riscos/global_history.h"
#include "netsurf/riscos/gui.h"
#include "netsurf/riscos/menus.h"
@@ -1302,8 +1303,12 @@ void ro_gui_window_mouse_at(struct gui_window *g, wimp_pointer *pointer)
* Process Mouse_Click events in a toolbar.
*/
-void ro_gui_toolbar_click(struct gui_window *g, wimp_pointer *pointer)
+bool ro_gui_toolbar_click(wimp_pointer *pointer)
{
+ struct gui_window *g = ro_gui_toolbar_lookup(pointer->w);
+
+ assert(g);
+
/* try to close url-completion */
ro_gui_url_complete_close(g, pointer->i);
@@ -1312,14 +1317,14 @@ void ro_gui_toolbar_click(struct gui_window *g, wimp_pointer *pointer)
if (pointer->buttons == wimp_CLICK_MENU) {
ro_gui_menu_create(browser_toolbar_menu, pointer->pos.x,
pointer->pos.y, g->window);
- return;
+ return true;
}
/* Handle toolbar edits
*/
if ((g->toolbar->editor) && (pointer->i < ICON_TOOLBAR_URL)) {
ro_gui_theme_toolbar_editor_click(g->toolbar, pointer);
- return;
+ return true;
}
/* Handle the buttons appropriately
@@ -1415,6 +1420,7 @@ void ro_gui_toolbar_click(struct gui_window *g, wimp_pointer *pointer)
ICON_TOOLBAR_SUGGEST);
break;
}
+ return true;
}
@@ -1425,14 +1431,18 @@ void ro_gui_toolbar_click(struct gui_window *g, wimp_pointer *pointer)
* \param pointer details of mouse click
*/
-void ro_gui_status_click(struct gui_window *g, wimp_pointer *pointer)
+bool ro_gui_status_click(wimp_pointer *pointer)
{
+ struct gui_window *g = ro_gui_status_lookup(pointer->w);
wimp_drag drag;
os_error *error;
+
+ assert(g);
+
switch (pointer->i) {
case ICON_STATUS_RESIZE:
gui_current_drag_type = GUI_DRAG_STATUS_RESIZE;
- drag.w = g->toolbar->status_handle;
+ drag.w = pointer->w;
drag.type = wimp_DRAG_SYSTEM_SIZE;
drag.initial.x0 = pointer->pos.x;
drag.initial.x1 = pointer->pos.x;
@@ -1446,6 +1456,7 @@ void ro_gui_status_click(struct gui_window *g, wimp_pointer *pointer)
}
break;
}
+ return true;
}
@@ -1897,10 +1908,6 @@ bool ro_gui_window_keypress(struct gui_window *g, int key, bool toolbar)
}
return true;
- case wimp_KEY_CONTROL + wimp_KEY_F9: /* Dump url_store. */
- url_store_dump();
- return true;
-
case wimp_KEY_CONTROL + wimp_KEY_SHIFT + wimp_KEY_F9:
talloc_report_full(0, stderr);
return true;