summaryrefslogtreecommitdiff
path: root/riscos
diff options
context:
space:
mode:
authorJames Bursa <james@netsurf-browser.org>2004-07-17 13:00:38 +0000
committerJames Bursa <james@netsurf-browser.org>2004-07-17 13:00:38 +0000
commite4a6e982e599020060d8e43262d53ade0667f439 (patch)
treea3f76f00f0d2154834036e25b4747b322260ce19 /riscos
parentb6782d609583900d14d51272075408072f2e501c (diff)
downloadnetsurf-e4a6e982e599020060d8e43262d53ade0667f439.tar.gz
netsurf-e4a6e982e599020060d8e43262d53ade0667f439.tar.bz2
[project @ 2004-07-17 13:00:38 by bursa]
Simplify gui_window structure. Clean up various parts of the gui code. svn path=/import/netsurf/; revision=1092
Diffstat (limited to 'riscos')
-rw-r--r--riscos/dialog.c30
-rw-r--r--riscos/gif.c6
-rw-r--r--riscos/gui.c583
-rw-r--r--riscos/gui.h119
-rw-r--r--riscos/help.c33
-rw-r--r--riscos/hotlist.c83
-rw-r--r--riscos/htmlredraw.c12
-rw-r--r--riscos/jpeg.c4
-rw-r--r--riscos/menus.c103
-rw-r--r--riscos/mng.c4
-rw-r--r--riscos/mouseactions.c2
-rw-r--r--riscos/png.c4
-rw-r--r--riscos/textselection.c18
-rw-r--r--riscos/theme.c12
-rw-r--r--riscos/theme.h2
-rw-r--r--riscos/window.c1189
16 files changed, 1245 insertions, 959 deletions
diff --git a/riscos/dialog.c b/riscos/dialog.c
index b3c915035..80386c530 100644
--- a/riscos/dialog.c
+++ b/riscos/dialog.c
@@ -214,7 +214,7 @@ void ro_gui_dialog_open(wimp_w w)
open.visible.y1 = screen_y + dy;
open.next = wimp_TOP;
wimp_open_window((wimp_open *) &open);
-
+
/* Set the caret position
*/
ro_gui_set_caret_first(w);
@@ -233,7 +233,7 @@ void ro_gui_dialog_open_persistant(wimp_w parent, wimp_w w, bool pointer) {
wimp_pointer ptr;
wimp_window_state open;
os_error *error;
-
+
/* Get the pointer position
*/
error = xwimp_get_pointer_info(&ptr);
@@ -260,11 +260,11 @@ void ro_gui_dialog_open_persistant(wimp_w parent, wimp_w w, bool pointer) {
} else {
ro_gui_open_window_centre(parent, w);
}
-
+
/* Set the caret position
*/
ro_gui_set_caret_first(w);
-
+
/* Add a mapping
*/
if (parent == NULL) return;
@@ -277,7 +277,7 @@ void ro_gui_dialog_open_persistant(wimp_w parent, wimp_w w, bool pointer) {
}
/* Log that we failed to create a mapping
- */
+ */
LOG(("Unable to map persistant dialog to parent."));
}
@@ -289,7 +289,7 @@ void ro_gui_dialog_open_persistant(wimp_w parent, wimp_w w, bool pointer) {
*/
void ro_gui_dialog_close_persistant(wimp_w parent) {
int i;
-
+
/* Check our mappings
*/
if (parent == NULL) return;
@@ -318,9 +318,9 @@ bool ro_gui_dialog_keypress(wimp_key *key)
pointer.w = key->w;
pointer.i = (key->w == dialog_folder) ? 3 : 5;
pointer.buttons = wimp_CLICK_SELECT;
- ro_gui_hotlist_dialog_click(&pointer);
+ ro_gui_hotlist_dialog_click(&pointer);
return true;
- }
+ }
}
#ifdef WITH_AUTH
if (key->w == dialog_401li)
@@ -403,15 +403,19 @@ void ro_gui_dialog_click_config(wimp_pointer *pointer)
}
}
+
/**
* Save the current options
*/
-void ro_gui_save_options(void) {
+
+void ro_gui_save_options(void)
+{
xosfile_create_dir("<Choices$Write>.WWW", 0);
xosfile_create_dir("<Choices$Write>.WWW.NetSurf", 0);
options_write("<Choices$Write>.WWW.NetSurf.Choices");
}
+
/**
* Handle clicks in the Browser Choices dialog.
*/
@@ -763,8 +767,8 @@ void ro_gui_dialog_click_zoom(wimp_pointer *pointer)
ro_gui_set_icon_integer(dialog_zoom, ICON_ZOOM_VALUE, scale);
if (pointer->i == ICON_ZOOM_OK) {
- current_gui->scale = scale * 0.01;
- current_gui->data.browser.reformat_pending = true;
+ current_gui->option.scale = scale * 0.01;
+ current_gui->reformat_pending = true;
gui_reformat_pending = true;
}
@@ -785,7 +789,7 @@ void ro_gui_dialog_click_zoom(wimp_pointer *pointer)
void ro_gui_dialog_reset_zoom(void) {
char scale_buffer[8];
- sprintf(scale_buffer, "%.0f", current_gui->scale * 100);
+ sprintf(scale_buffer, "%.0f", current_gui->option.scale * 100);
ro_gui_set_icon_string(dialog_zoom, ICON_ZOOM_VALUE, scale_buffer);
}
@@ -817,7 +821,7 @@ void ro_gui_dialog_close(wimp_w close)
*/
if (!xwimp_get_caret_position(&caret)) {
if (caret.w == close) {
-
+
/* Check if we are a persistant window
*/
for (i = 0; i < MAX_PERSISTANT; i++) {
diff --git a/riscos/gif.c b/riscos/gif.c
index f23c08d81..b6c57984b 100644
--- a/riscos/gif.c
+++ b/riscos/gif.c
@@ -135,9 +135,9 @@ void nsgif_redraw(struct content *c, int x, int y,
drawing a thumbnail unless something has gone very wrong somewhere else.
*/
if (ro_gui_current_redraw_gui) {
- tinct_options = (ro_gui_current_redraw_gui->option_filter_sprites?tinct_BILINEAR_FILTER:0) |
- (ro_gui_current_redraw_gui->option_dither_sprites?tinct_DITHER:0);
- if (ro_gui_current_redraw_gui->option_animate_images) {
+ tinct_options = (ro_gui_current_redraw_gui->option.filter_sprites?tinct_BILINEAR_FILTER:0) |
+ (ro_gui_current_redraw_gui->option.dither_sprites?tinct_DITHER:0);
+ if (ro_gui_current_redraw_gui->option.animate_images) {
current_frame = c->data.gif.current_frame;
} else {
current_frame = 0;
diff --git a/riscos/gui.c b/riscos/gui.c
index cd0f999b3..c629da12b 100644
--- a/riscos/gui.c
+++ b/riscos/gui.c
@@ -9,6 +9,7 @@
*/
#include <assert.h>
+#include <errno.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdlib.h>
@@ -44,6 +45,7 @@
#endif
#include "netsurf/riscos/save_complete.h"
#include "netsurf/riscos/theme.h"
+#include "netsurf/riscos/toolbar.h"
#ifdef WITH_URI
#include "netsurf/riscos/uri.h"
#endif
@@ -62,9 +64,17 @@ int __feature_imagefs_is_file = 1; /**< For UnixLib. */
char *NETSURF_DIR;
wimp_menu *combo_menu;
struct form_control *current_gadget;
-gui_window *over_window = 0; /**< Window which the pointer is over. */
-bool gui_reformat_pending = false; /**< Some windows have been resized,
- and should be reformatted. */
+
+/** The pointer is over a window which is tracking mouse movement. */
+static bool gui_track = false;
+/** Handle of window which the pointer is over. */
+static wimp_w gui_track_wimp_w;
+/** Browser window which the pointer is over, or 0 if none. */
+static struct gui_window *gui_track_gui_window;
+
+/** Some windows have been resized, and should be reformatted. */
+bool gui_reformat_pending = false;
+
gui_drag_type gui_current_drag_type;
wimp_t task_handle; /**< RISC OS wimp task handle. */
static clock_t gui_last_poll; /**< Time of last wimp_poll. */
@@ -122,21 +132,25 @@ static void ro_gui_check_fonts(void);
static void ro_gui_pointers_init(void);
static void ro_gui_icon_bar_create(void);
static void ro_gui_handle_event(wimp_event_no event, wimp_block *block);
-static void ro_gui_poll_queue(wimp_event_no event, wimp_block* block);
+static void ro_gui_poll_queue(wimp_event_no event, wimp_block *block);
static void ro_gui_null_reason_code(void);
static void ro_gui_redraw_window_request(wimp_draw *redraw);
static void ro_gui_open_window_request(wimp_open *open);
static void ro_gui_close_window_request(wimp_close *close);
+static void ro_gui_pointer_leaving_window(wimp_leaving *leaving);
+static void ro_gui_pointer_entering_window(wimp_entering *entering);
static void ro_gui_mouse_click(wimp_pointer *pointer);
-static void ro_gui_icon_bar_click(wimp_pointer* pointer);
+static void ro_gui_icon_bar_click(wimp_pointer *pointer);
static void ro_gui_check_resolvers(void);
static void ro_gui_drag_end(wimp_dragged *drag);
-static void ro_gui_keypress(wimp_key* key);
+static void ro_gui_keypress(wimp_key *key);
static void ro_gui_user_message(wimp_event_no event, wimp_message *message);
-static void ro_msg_datasave(wimp_message* block);
-static void ro_msg_dataload(wimp_message* block);
-static void ro_msg_datasave_ack(wimp_message* message);
-static void ro_msg_dataopen(wimp_message* block);
+static void ro_msg_dataload(wimp_message *block);
+static char *ro_gui_uri_file_parse(const char *file_name);
+static bool ro_gui_uri_file_parse_line(FILE *fp, char *b);
+static char *ro_gui_url_file_parse(const char *file_name);
+static void ro_msg_datasave_ack(wimp_message *message);
+static void ro_msg_dataopen(wimp_message *block);
static char *ro_path_to_url(const char *path);
@@ -406,7 +420,6 @@ void gui_poll(bool active)
wimp_event_no event;
wimp_block block;
const wimp_poll_flags mask = wimp_MASK_LOSE | wimp_MASK_GAIN;
- gui_window *g;
/* Process queued events. */
while (ro_gui_poll_queued_blocks) {
@@ -423,14 +436,14 @@ void gui_poll(bool active)
xhourglass_off();
if (active) {
event = wimp_poll(mask, &block, 0);
- } else if (sched_active && (over_window || gui_reformat_pending)) {
+ } else if (sched_active && (gui_track || gui_reformat_pending)) {
os_t t = os_read_monotonic_time() + 10;
if (sched_time < t)
t = sched_time;
event = wimp_poll_idle(mask, &block, t, 0);
} else if (sched_active) {
event = wimp_poll_idle(mask, &block, sched_time, 0);
- } else if (over_window || gui_reformat_pending) {
+ } else if (gui_track || gui_reformat_pending) {
os_t t = os_read_monotonic_time();
event = wimp_poll_idle(mask, &block, t + 10, 0);
} else {
@@ -441,17 +454,8 @@ void gui_poll(bool active)
ro_gui_handle_event(event, &block);
schedule_run();
- if (gui_reformat_pending && event == wimp_NULL_REASON_CODE) {
- for (g = window_list; g; g = g->next) {
- if (g->type == GUI_BROWSER_WINDOW && g->data.browser.reformat_pending) {
- content_reformat(g->data.browser.bw->current_content,
- g->data.browser.old_width / 2 / g->scale,
- 1000);
- g->data.browser.reformat_pending = false;
- }
- }
- gui_reformat_pending = false;
- }
+ if (gui_reformat_pending && event == wimp_NULL_REASON_CODE)
+ ro_gui_window_process_reformats();
}
@@ -482,16 +486,11 @@ void ro_gui_handle_event(wimp_event_no event, wimp_block *block)
break;
case wimp_POINTER_LEAVING_WINDOW:
- if (over_window == (gui_window*)history_window)
- wimp_close_window(dialog_tooltip);
- over_window = 0;
- gui_window_set_pointer(GUI_POINTER_DEFAULT);
+ ro_gui_pointer_leaving_window(&block->leaving);
break;
case wimp_POINTER_ENTERING_WINDOW:
- over_window = ro_lookup_gui_from_w(block->entering.w);
- if (over_window == 0 && block->entering.w == history_window)
- over_window = (gui_window*)history_window;
+ ro_gui_pointer_entering_window(&block->entering);
break;
case wimp_MOUSE_CLICK:
@@ -594,12 +593,26 @@ void ro_gui_poll_queue(wimp_event_no event, wimp_block *block)
void ro_gui_null_reason_code(void)
{
+ wimp_pointer pointer;
+ os_error *error;
+
ro_gui_throb();
- if (over_window) {
- wimp_pointer pointer;
- wimp_get_pointer_info(&pointer);
- ro_gui_window_mouse_at(&pointer);
+
+ if (!gui_track)
+ return;
+
+ 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);
+ return;
}
+
+ if (gui_track_wimp_w == history_window)
+ ro_gui_history_mouse_at(&pointer);
+ else if (gui_track_gui_window)
+ ro_gui_window_mouse_at(gui_track_gui_window, &pointer);
}
@@ -609,7 +622,9 @@ void ro_gui_null_reason_code(void)
void ro_gui_redraw_window_request(wimp_draw *redraw)
{
- gui_window *g;
+ struct gui_window *g;
+ osbool more;
+ os_error *error;
if (redraw->w == dialog_config_th_pane)
ro_gui_redraw_config_th_pane(redraw);
@@ -619,14 +634,24 @@ void ro_gui_redraw_window_request(wimp_draw *redraw)
ro_gui_hotlist_redraw(redraw);
else if (redraw->w == dialog_debug)
ro_gui_debugwin_redraw(redraw);
+ else if ((g = ro_gui_window_lookup(redraw->w)))
+ ro_gui_window_redraw(g, redraw);
else {
- g = ro_lookup_gui_from_w(redraw->w);
- if (g != NULL)
- ro_gui_window_redraw(g, redraw);
- else {
- osbool more = wimp_redraw_window(redraw);
- while (more)
- more = wimp_get_rectangle(redraw);
+ error = xwimp_redraw_window(redraw, &more);
+ if (error) {
+ LOG(("xwimp_redraw_window: 0x%x: %s",
+ error->errnum, error->errmess));
+ warn_user("WimpError", error->errmess);
+ return;
+ }
+ while (more) {
+ error = xwimp_get_rectangle(redraw, &more);
+ if (error) {
+ LOG(("xwimp_get_rectangle: 0x%x: %s",
+ error->errnum, error->errmess));
+ warn_user("WimpError", error->errmess);
+ return;
+ }
}
}
}
@@ -638,21 +663,25 @@ void ro_gui_redraw_window_request(wimp_draw *redraw)
void ro_gui_open_window_request(wimp_open *open)
{
- struct toolbar *toolbar;
- gui_window *g;
+ struct gui_window *g;
+ os_error *error;
- g = ro_lookup_gui_from_w(open->w);
+ g = ro_gui_window_lookup(open->w);
if (g) {
ro_gui_window_open(g, open);
} else {
- wimp_open_window(open);
- g = ro_lookup_gui_status_from_w(open->w);
- if (g) {
- toolbar = g->data.browser.toolbar;
- if (toolbar) {
- toolbar->resize_status = 1;
- ro_theme_resize_toolbar(g->data.browser.toolbar, g->window);
- }
+ error = xwimp_open_window(open);
+ if (error) {
+ LOG(("xwimp_open_window: 0x%x: %s",
+ error->errnum, error->errmess));
+ warn_user("WimpError", error->errmess);
+ return;
+ }
+
+ g = ro_gui_status_lookup(open->w);
+ if (g && g->toolbar) {
+ g->toolbar->resize_status = 1;
+ ro_theme_resize_toolbar(g->toolbar, g->window);
}
}
}
@@ -664,9 +693,9 @@ void ro_gui_open_window_request(wimp_open *open)
void ro_gui_close_window_request(wimp_close *close)
{
- gui_window *g;
+ struct gui_window *g;
struct gui_download_window *dw;
-
+
/* Check for children
*/
ro_gui_dialog_close_persistant(close->w);
@@ -674,7 +703,7 @@ void ro_gui_close_window_request(wimp_close *close)
if (close->w == dialog_debug)
ro_gui_debugwin_close();
else if ((g = ro_gui_window_lookup(close->w)))
- browser_window_destroy(g->data.browser.bw);
+ browser_window_destroy(g->bw);
else if ((dw = ro_gui_download_window_lookup(close->w)))
ro_gui_download_window_destroy(dw);
else
@@ -683,12 +712,46 @@ void ro_gui_close_window_request(wimp_close *close)
/**
+ * Handle Pointer_Leaving_Window events.
+ */
+
+void ro_gui_pointer_leaving_window(wimp_leaving *leaving)
+{
+ os_error *error;
+
+ if (gui_track_wimp_w == history_window) {
+ error = xwimp_close_window(dialog_tooltip);
+ if (error) {
+ LOG(("xwimp_close_window: 0x%x: %s",
+ error->errnum, error->errmess));
+ warn_user("WimpError", error->errmess);
+ }
+ }
+
+ gui_track = false;
+ gui_window_set_pointer(GUI_POINTER_DEFAULT);
+}
+
+
+/**
+ * Handle Pointer_Entering_Window events.
+ */
+
+void ro_gui_pointer_entering_window(wimp_entering *entering)
+{
+ gui_track_wimp_w = entering->w;
+ gui_track_gui_window = ro_gui_window_lookup(entering->w);
+ gui_track = gui_track_gui_window || gui_track_wimp_w == history_window;
+}
+
+
+/**
* Handle Mouse_Click events.
*/
void ro_gui_mouse_click(wimp_pointer *pointer)
{
- gui_window *g = ro_gui_window_lookup(pointer->w);
+ struct gui_window *g;
struct gui_download_window *dw;
if (pointer->w == wimp_ICON_BAR)
@@ -697,20 +760,19 @@ void ro_gui_mouse_click(wimp_pointer *pointer)
ro_gui_history_click(pointer);
else if (pointer->w == hotlist_window)
ro_gui_hotlist_click(pointer);
- else if (g && g->type == GUI_BROWSER_WINDOW && g->window == pointer->w)
+ else if (pointer->w == dialog_saveas)
+ ro_gui_save_click(pointer);
+ else if (hotlist_toolbar &&
+ hotlist_toolbar->toolbar_handle == pointer->w)
+ ro_gui_hotlist_toolbar_click(pointer);
+ else if ((g = ro_gui_window_lookup(pointer->w)))
ro_gui_window_click(g, pointer);
- else if (g && g->type == GUI_BROWSER_WINDOW &&
- g->data.browser.toolbar->toolbar_handle == pointer->w)
+ else if ((g = ro_gui_toolbar_lookup(pointer->w)))
ro_gui_toolbar_click(g, pointer);
- else if (hotlist_toolbar && hotlist_toolbar->toolbar_handle == pointer->w)
- ro_gui_hotlist_toolbar_click(pointer);
- else if (g && g->type == GUI_BROWSER_WINDOW &&
- g->data.browser.toolbar->status_handle == pointer->w)
+ else if ((g = ro_gui_status_lookup(pointer->w)))
ro_gui_status_click(g, pointer);
else if ((dw = ro_gui_download_window_lookup(pointer->w)))
ro_gui_download_window_click(dw, pointer);
- else if (pointer->w == dialog_saveas)
- ro_gui_save_click(pointer);
else
ro_gui_dialog_click(pointer);
}
@@ -790,35 +852,26 @@ void ro_gui_drag_end(wimp_dragged *drag)
void ro_gui_keypress(wimp_key *key)
{
bool handled = false;
-
- /* Check for hotlist windows
- */
- if (key->w == hotlist_window) {
- handled = ro_gui_hotlist_keypress(key->c);
- if (!handled) wimp_process_key(key->c);
- return;
- }
-
- /* Handle the rest
- */
- gui_window *g = ro_gui_window_lookup(key->w);
+ struct gui_window *g;
+ os_error *error;
- if (!g) {
+ if (key->w == hotlist_window)
+ handled = ro_gui_hotlist_keypress(key->c);
+ else if ((g = ro_gui_window_lookup(key->w)))
+ handled = ro_gui_window_keypress(g, key->c, false);
+ else if ((g = ro_gui_toolbar_lookup(key->w)))
+ handled = ro_gui_window_keypress(g, key->c, true);
+ else
handled = ro_gui_dialog_keypress(key);
- if (!handled)
- wimp_process_key(key->c);
- return;
- }
- switch (g->type) {
- case GUI_BROWSER_WINDOW:
- handled = ro_gui_window_keypress(g, key->c,
- (bool) (g->data.browser.toolbar->toolbar_handle == key->w));
- break;
+ if (!handled) {
+ error = xwimp_process_key(key->c);
+ if (error) {
+ LOG(("xwimp_process_key: 0x%x: %s",
+ error->errnum, error->errmess));
+ warn_user("WimpError", error->errmess);
+ }
}
-
- if (!handled)
- wimp_process_key(key->c);
}
@@ -833,10 +886,6 @@ void ro_gui_user_message(wimp_event_no event, wimp_message *message)
ro_gui_interactive_help_request(message);
break;
- case message_DATA_SAVE:
- ro_msg_datasave(message);
- break;
-
case message_DATA_SAVE_ACK:
ro_msg_datasave_ack(message);
break;
@@ -955,62 +1004,6 @@ void gui_gadget_combo(struct browser_window* bw, struct form_control* g, unsigne
ro_gui_create_menu(combo_menu, pointer.pos.x - 64, pointer.pos.y, bw->window);
}
-void ro_msg_datasave(wimp_message* block)
-{
- gui_window* gui;
- struct browser_window* bw;
- wimp_message_data_xfer* data;
- int x,y;
- struct box_selection* click_boxes;
- int found, plot_index;
- int i;
- wimp_window_state state;
-
- data = &block->data.data_xfer;
-
- gui = ro_lookup_gui_from_w(data->w);
- if (gui == NULL)
- return;
-
- bw = gui->data.browser.bw;
-
- state.w = data->w;
- wimp_get_window_state(&state);
- x = window_x_units(data->pos.x, &state) / 2;
- y = -window_y_units(data->pos.y, &state) / 2;
-
- found = 0;
- click_boxes = NULL;
- plot_index = 0;
-
- box_under_area(bw->current_content,
- bw->current_content->data.html.layout->children,
- (unsigned int)x, (unsigned int)y, 0, 0, &click_boxes,
- &found, &plot_index);
-
- if (found == 0)
- return;
-
- for (i = found - 1; i >= 0; i--)
- {
- if (click_boxes[i].box->gadget != NULL)
- {
- if (click_boxes[i].box->gadget->type == GADGET_TEXTAREA && data->file_type == 0xFFF)
- {
- /* load the text in! */
- fprintf(stderr, "REPLYING TO MESSAGE MATE\n");
- block->action = message_DATA_SAVE_ACK;
- block->your_ref = block->my_ref;
- block->my_ref = 0;
- strcpy(block->data.data_xfer.file_name, "<Wimp$Scrap>");
- wimp_send_message(wimp_USER_MESSAGE, block, block->sender);
- }
- }
- }
-
- xfree(click_boxes);
-}
-
/**
* Handle Message_DataLoad (file dragged in).
@@ -1018,160 +1011,200 @@ void ro_msg_datasave(wimp_message* block)
void ro_msg_dataload(wimp_message *message)
{
+ int file_type = message->data.data_xfer.file_type;
char *url = 0;
- gui_window *gui;
+ struct gui_window *g;
+ os_error *error;
- gui = ro_lookup_gui_from_w(message->data.data_xfer.w);
+ g = ro_gui_window_lookup(message->data.data_xfer.w);
- if (gui) {
- if (ro_gui_window_dataload(gui, message))
- return;
- }
+ if (g && ro_gui_window_dataload(g, message))
+ return;
- if (message->data.data_xfer.file_type != 0xfaf &&
- message->data.data_xfer.file_type != 0x695 &&
- message->data.data_xfer.file_type != 0xaff &&
- message->data.data_xfer.file_type != 0xb60 &&
- message->data.data_xfer.file_type != 0xc85 &&
- message->data.data_xfer.file_type != 0xff9 &&
- message->data.data_xfer.file_type != 0xfff &&
- message->data.data_xfer.file_type != 0xf91 &&
- message->data.data_xfer.file_type != 0xb28)
+ if (file_type == 0xf91) /* Acorn URI file */
+ url = ro_gui_uri_file_parse(message->data.data_xfer.file_name);
+ else if (file_type == 0xb28) /* ANT URL file */
+ url = ro_gui_url_file_parse(message->data.data_xfer.file_name);
+ else if (file_type == 0xfaf ||
+ file_type == 0x695 ||
+ file_type == 0xaff ||
+ file_type == 0xb60 ||
+ file_type == 0xc85 ||
+ file_type == 0xff9 ||
+ file_type == 0xfff) /* display the actual file */
+ url = ro_path_to_url(message->data.data_xfer.file_name);
+ else
return;
- /* uri file
- * Format: Each "line" is separated by a tab.
- * Comments are prefixed by a "#"
- *
- * Line: Content:
- * 1 URI
- * 2 100 (version of file format * 100)
- * 3 An URL (eg http;//www.google.com/)
- * 4 Title associated with URL (eg Google)
- */
- if (message->data.data_xfer.file_type == 0xf91) {
- char *buf, *temp;
- int lineno=0;
- buf = load(message->data.data_xfer.file_name);
- temp = strtok(buf, "\t");
-
- if (!temp) {
- xfree(buf);
- return;
- }
+ /* send DataLoadAck */
+ message->action = message_DATA_LOAD_ACK;
+ message->your_ref = message->my_ref;
+ error = xwimp_send_message(wimp_USER_MESSAGE, message, message->sender);
+ if (error) {
+ LOG(("xwimp_send_message: 0x%x: %s",
+ error->errnum, error->errmess));
+ warn_user("WimpError", error->errmess);
+ return;
+ }
- if (temp[0] != '#') lineno = 1;
+ if (!url)
+ /* error has already been reported by one of the three
+ * functions called above */
+ return;
- while (temp && lineno<=2) {
- temp = strtok('\0', "\t");
- if (!temp) break;
- if (temp[0] == '#') continue; /* ignore commented lines */
- lineno++;
- }
+ if (g)
+ browser_window_go(g->bw, url);
+ else
+ browser_window_create(url, 0);
- if (!temp) {
- xfree(buf);
- return;
- }
+ free(url);
+}
- url = xstrdup(temp);
- xfree(buf);
+/**
+ * Parse an Acorn URI file.
+ *
+ * \param file_name file to read
+ * \return URL from file, or 0 on error and error reported
+ */
+
+char *ro_gui_uri_file_parse(const char *file_name)
+{
+ /* See the "Acorn URI Handler Functional Specification" for the
+ * definition of the URI file format. */
+ char line[400];
+ char *url;
+ FILE *fp;
+
+ fp = fopen(file_name, "rb");
+ if (!fp) {
+ LOG(("fopen(\"%s\", \"rb\"): %i: %s",
+ file_name, errno, strerror(errno)));
+ warn_user("LoadError", strerror(errno));
+ return 0;
}
- /* url file */
- if (message->data.data_xfer.file_type == 0xb28) {
- char *temp;
- FILE *fp = fopen(message->data.data_xfer.file_name, "r");
+ /* "URI" */
+ if (!ro_gui_uri_file_parse_line(fp, line) || strcmp(line, "URI") != 0)
+ goto uri_syntax_error;
- if (!fp) return;
+ /* version */
+ if (!ro_gui_uri_file_parse_line(fp, line) ||
+ strspn(line, "0123456789") != strlen(line))
+ goto uri_syntax_error;
- url = xcalloc(256, sizeof(char));
+ /* URI */
+ if (!ro_gui_uri_file_parse_line(fp, line))
+ goto uri_syntax_error;
- temp = fgets(url, 256, fp);
+ fclose(fp);
- fclose(fp);
+ url = strdup(line);
+ if (!url) {
+ warn_user("NoMemory", 0);
+ return 0;
+ }
- if (!temp) return;
+ return url;
- if (url[strlen(url)-1] == '\n') {
- url[strlen(url)-1] = '\0';
- }
- }
+uri_syntax_error:
+ fclose(fp);
+ warn_user("URIError", 0);
+ return 0;
+}
- /* send DataLoadAck */
- message->action = message_DATA_LOAD_ACK;
- message->your_ref = message->my_ref;
- wimp_send_message(wimp_USER_MESSAGE, message, message->sender);
- /* create a new window with the file */
- if (message->data.data_xfer.file_type != 0xb28 &&
- message->data.data_xfer.file_type != 0xf91) {
- url = ro_path_to_url(message->data.data_xfer.file_name);
- }
- if (!url)
- return;
+/**
+ * Read a "line" from an Acorn URI file.
+ *
+ * \param fp file pointer to read from
+ * \param b buffer for line, size 400 bytes
+ * \return true on success, false on EOF
+ */
- if (gui) {
- gui_window_set_url(gui, url);
- browser_window_go(gui->data.browser.bw, url);
- }
- else {
- browser_window_create(url, NULL);
+bool ro_gui_uri_file_parse_line(FILE *fp, char *b)
+{
+ int c;
+ unsigned int i = 0;
+
+ c = getc(fp);
+ if (c == EOF)
+ return false;
+
+ /* skip comment lines */
+ while (c == '#') {
+ do { c = getc(fp); } while (c != EOF && 32 <= c);
+ if (c == EOF)
+ return false;
+ do { c = getc(fp); } while (c != EOF && c < 32);
+ if (c == EOF)
+ return false;
}
- free(url);
+ /* read "line" */
+ do {
+ if (i == 399)
+ return false;
+ b[i++] = c;
+ c = getc(fp);
+ } while (c != EOF && 32 <= c);
+ /* skip line ending control characters */
+ while (c != EOF && c < 32)
+ c = getc(fp);
-#if 0
- gui_window* gui;
- struct browser_window* bw;
- wimp_message_data_xfer* data;
- int x,y;
- struct box_selection* click_boxes;
- int found, plot_index;
- int i;
- wimp_window_state state;
+ if (c != EOF)
+ ungetc(c, fp);
- data = &block->data.data_xfer;
+ b[i] = 0;
+ return true;
+}
- gui = ro_lookup_gui_from_w(data->w);
- if (gui == NULL)
- return;
- bw = gui->data.browser.bw;
+/**
+ * Parse an ANT URL file.
+ *
+ * \param file_name file to read
+ * \return URL from file, or 0 on error and error reported
+ */
- state.w = data->w;
- wimp_get_window_state(&state);
- x = window_x_units(data->pos.x, &state) / 2;
- y = -window_y_units(data->pos.y, &state) / 2;
+char *ro_gui_url_file_parse(const char *file_name)
+{
+ char line[400];
+ char *url;
+ FILE *fp;
+
+ fp = fopen(file_name, "r");
+ if (!fp) {
+ LOG(("fopen(\"%s\", \"r\"): %i: %s",
+ file_name, errno, strerror(errno)));
+ warn_user("LoadError", strerror(errno));
+ return 0;
+ }
- found = 0;
- click_boxes = NULL;
- plot_index = 0;
+ if (!fgets(line, sizeof line, fp)) {
+ if (ferror(fp)) {
+ LOG(("fgets: %i: %s",
+ errno, strerror(errno)));
+ warn_user("LoadError", strerror(errno));
+ } else
+ warn_user("LoadError", messages_get("EmptyError"));
+ fclose(fp);
+ return 0;
+ }
- box_under_area(bw->current_content,
- bw->current_content->data.html.layout->children,
- (unsigned int)x, (unsigned int)y, 0, 0, &click_boxes,
- &found, &plot_index);
+ fclose(fp);
- if (found == 0)
- return;
+ if (line[strlen(line) - 1] == '\n')
+ line[strlen(line) - 1] = '\0';
- for (i = found - 1; i >= 0; i--)
- {
- if (click_boxes[i].box->gadget != NULL)
- {
- if (click_boxes[i].box->gadget->type == GADGET_TEXTAREA && data->file_type == 0xFFF)
- {
- /* load the text in! */
- /* TODO */
- }
- }
+ url = strdup(line);
+ if (!url) {
+ warn_user("NoMemory", 0);
+ return 0;
}
- xfree(click_boxes);
-#endif
+ return url;
}
@@ -1354,16 +1387,6 @@ void gui_launch_url(const char *url)
}
-/**
- * Called when the gui_window has new content
- *
- * \g the gui_window that has new content
- */
-void gui_window_new_content(gui_window *g) {
- ro_gui_dialog_close_persistant(g->window);
-}
-
-
static char warn_buffer[300];
/**
diff --git a/riscos/gui.h b/riscos/gui.h
index a4516d15e..4a1736a4a 100644
--- a/riscos/gui.h
+++ b/riscos/gui.h
@@ -17,10 +17,11 @@
#include "netsurf/desktop/netsurf.h"
#include "netsurf/desktop/gui.h"
#include "netsurf/desktop/options.h"
-#include "netsurf/riscos/toolbar.h"
#define THEMES_DIR "<NetSurf$Dir>.Themes"
+struct toolbar;
+
extern wimp_w dialog_info, dialog_saveas, dialog_config, dialog_config_br,
dialog_config_prox, dialog_config_th, dialog_zoom, dialog_pageinfo,
dialog_objinfo, dialog_tooltip, dialog_warning, dialog_config_th_pane,
@@ -30,18 +31,13 @@ extern wimp_w hotlist_window;
extern wimp_menu *iconbar_menu, *browser_menu, *combo_menu, *hotlist_menu;
extern int iconbar_menu_height;
extern struct form_control *current_gadget;
-extern gui_window *window_list;
extern bool gui_reformat_pending;
extern bool gui_redraw_debug;
extern wimp_menu *current_menu;
-extern gui_window *current_gui;
-extern gui_window *ro_gui_current_redraw_gui;
extern osspriteop_area *gui_sprites;
extern struct toolbar *hotlist_toolbar;
extern bool dialog_folder_add, dialog_entry_add, hotlist_insert;
-typedef enum { GUI_BROWSER_WINDOW } gui_window_type;
-
typedef enum {
GUI_SAVE_SOURCE,
GUI_SAVE_DRAW,
@@ -60,51 +56,48 @@ typedef enum { GUI_DRAG_SELECTION, GUI_DRAG_DOWNLOAD_SAVE,
GUI_DRAG_HOTLIST_SELECT, GUI_DRAG_HOTLIST_MOVE } gui_drag_type;
extern gui_drag_type gui_current_drag_type;
+
+/** RISC OS data for a browser window. */
struct gui_window {
- gui_window_type type;
-
- wimp_w window;
-
- union {
- struct {
- struct toolbar *toolbar;
- int toolbar_width;
- struct browser_window* bw;
- bool reformat_pending;
- int old_width;
- int old_height;
- } browser;
- } data;
-
- char status[256];
- char title[256];
- char url[256];
- gui_window *next;
-
- int throbber;
- char throb_buf[12];
- float throbtime;
-
- enum { drag_NONE, drag_UNKNOWN, drag_BROWSER_TEXT_SELECTION }
- drag_status;
-
- /* Options
- */
- float scale;
- bool option_dither_sprites;
- bool option_filter_sprites;
- int option_toolbar_status_width;
- bool option_toolbar_show_status;
- bool option_toolbar_show_buttons;
- bool option_toolbar_show_address;
- bool option_toolbar_show_throbber;
- bool option_animate_images;
- bool option_background_images;
+ /** Associated platform-independent browser window data. */
+ struct browser_window *bw;
+
+ struct toolbar *toolbar; /**< Toolbar, or 0 if not present. */
+
+ wimp_w window; /**< RISC OS window handle. */
+
+ /** Window has been resized, and content needs reformatting. */
+ bool reformat_pending;
+ int old_width; /**< Width when last opened / os units. */
+ int old_height; /**< Height when last opened / os units. */
+
+ char status[256]; /**< Buffer for status bar. */
+ char title[256]; /**< Buffer for window title. */
+ char url[256]; /**< Buffer for url entry field. */
+
+ int throbber; /**< Current frame of throbber animation. */
+ char throb_buf[12]; /**< Buffer for throbber sprite name. */
+ int throbtime; /**< Time of last throbber frame. */
+
+ /** Options. */
+ struct {
+ float scale; /**< Scale, 1.0 = 100%. */
+ bool dither_sprites; /**< Images should be dithered. */
+ bool filter_sprites; /**< Images should be smoothed. */
+ bool animate_images; /**< Animations should run. */
+ bool background_images; /**< Display background images. */
+ } option;
+
+ struct gui_window *prev; /**< Previous in linked list. */
+ struct gui_window *next; /**< Next in linked list. */
};
+extern struct gui_window *current_gui;
+extern struct gui_window *ro_gui_current_redraw_gui;
+
+
/* in gui.c */
-void ro_gui_copy_selection(gui_window* g);
void ro_gui_open_help_page(const char *page);
void ro_gui_screen_size(int *width, int *height);
void ro_gui_view_source(struct content *content);
@@ -112,11 +105,11 @@ void ro_gui_drag_box_start(wimp_pointer *pointer);
/* in menus.c */
void ro_gui_menus_init(void);
-void ro_gui_create_menu(wimp_menu* menu, int x, int y, gui_window* g);
+void ro_gui_create_menu(wimp_menu* menu, int x, int y, struct gui_window *g);
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_prepare_navigate(gui_window *gui);
+void ro_gui_prepare_navigate(struct gui_window *gui);
void ro_gui_menu_prepare_scale(void);
void ro_gui_menu_prepare_pageinfo(void);
@@ -143,12 +136,13 @@ void ro_gui_download_datasave_ack(wimp_message *message);
void ro_gui_download_window_destroy(struct gui_download_window *dw);
/* in mouseactions.c */
-void ro_gui_mouse_action(gui_window* g);
+void ro_gui_mouse_action(struct gui_window *g);
/* in textselection.c */
void ro_gui_start_selection(wimp_pointer *pointer, wimp_window_state *state,
- gui_window *g);
+ struct gui_window *g);
void ro_gui_selection_drag_end(wimp_dragged *drag);
+void ro_gui_copy_selection(struct gui_window *g);
/* in 401login.c */
#ifdef WITH_AUTH
@@ -159,24 +153,25 @@ bool ro_gui_401login_keypress(wimp_key *key);
#endif
/* in window.c */
-void ro_gui_window_click(gui_window* g, wimp_pointer* mouse);
-void ro_gui_window_open(gui_window* g, wimp_open* open);
-void ro_gui_window_redraw(gui_window* g, wimp_draw* redraw);
-void ro_gui_window_mouse_at(wimp_pointer* pointer);
-void ro_gui_toolbar_click(gui_window* g, wimp_pointer* pointer);
-void ro_gui_status_click(gui_window* g, wimp_pointer* pointer);
+void ro_gui_window_click(struct gui_window *g, wimp_pointer *mouse);
+void ro_gui_window_open(struct gui_window *g, wimp_open *open);
+void ro_gui_window_redraw(struct gui_window *g, wimp_draw *redraw);
+void ro_gui_window_mouse_at(struct gui_window *g, wimp_pointer *pointer);
+void ro_gui_toolbar_click(struct gui_window *g, wimp_pointer *pointer);
+void ro_gui_status_click(struct gui_window *g, wimp_pointer *pointer);
void ro_gui_throb(void);
-gui_window* ro_lookup_gui_from_w(wimp_w window);
-gui_window* ro_lookup_gui_toolbar_from_w(wimp_w window);
-gui_window* ro_lookup_gui_status_from_w(wimp_w window);
-gui_window *ro_gui_window_lookup(wimp_w w);
-bool ro_gui_window_keypress(gui_window *g, int key, bool toolbar);
+struct gui_window *ro_gui_window_lookup(wimp_w window);
+struct gui_window *ro_gui_toolbar_lookup(wimp_w window);
+struct gui_window *ro_gui_status_lookup(wimp_w window);
+bool ro_gui_window_keypress(struct gui_window *g, int key, bool toolbar);
void ro_gui_scroll_request(wimp_scroll *scroll);
//#define window_x_units(x, state) (x - (state->visible.x0 - state->xscroll))
//#define window_y_units(y, state) (y - (state->visible.y1 - state->yscroll))
int window_x_units(int x, wimp_window_state *state);
int window_y_units(int y, wimp_window_state *state);
-bool ro_gui_window_dataload(gui_window *g, wimp_message *message);
+bool ro_gui_window_dataload(struct gui_window *g, wimp_message *message);
+void ro_gui_window_process_reformats(void);
+void ro_gui_window_default_options(struct browser_window *bw);
/* in history.c */
void ro_gui_history_init(void);
diff --git a/riscos/help.c b/riscos/help.c
index a35a90238..2aa4bf7a6 100644
--- a/riscos/help.c
+++ b/riscos/help.c
@@ -18,6 +18,7 @@
#include "oslib/wimp.h"
#include "netsurf/riscos/gui.h"
#include "netsurf/riscos/help.h"
+#include "netsurf/riscos/toolbar.h"
#include "netsurf/utils/messages.h"
#include "netsurf/utils/log.h"
@@ -49,7 +50,7 @@
of numbers representing the menu structure (eg 'HelpBrowserMenu3-1-2').
If '<key><identifier>' is not available, then simply '<key>' is then used. For example
if 'HelpToolbar7' is not available then 'HelpToolbar' is then tried.
-
+
For items marked with an asterisk [*] a call must be made to determine the required
help text as the window does not contain any icons. An example of this is the hotlist
window where ro_gui_hotlist_help() is called.
@@ -70,7 +71,7 @@ void ro_gui_interactive_help_request(wimp_message *message) {
help_full_message_request *message_data;
wimp_w window;
wimp_i icon;
- gui_window *g;
+ struct gui_window *g;
unsigned int index;
/* Ensure we have a help request
@@ -113,25 +114,17 @@ void ro_gui_interactive_help_request(wimp_message *message) {
sprintf(message_token, "HelpHotEntry%i", (int)icon);
} else if (window == hotlist_window) {
sprintf(message_token, "HelpHotlist%i",
- ro_gui_hotlist_help(message_data->pos.x, message_data->pos.y));
- } else if ((hotlist_toolbar) && (window == hotlist_toolbar->toolbar_handle)) {
+ ro_gui_hotlist_help(message_data->pos.x,
+ message_data->pos.y));
+ } else if (hotlist_toolbar &&
+ window == hotlist_toolbar->toolbar_handle) {
sprintf(message_token, "HelpHotToolbar%i", (int)icon);
- } else {
-
- /* Check if we have a browser window, toolbar window or status window
- */
- g = ro_gui_window_lookup(window);
- if (g) {
- if (g->window == window) {
- sprintf(message_token, "HelpBrowser%i", (int)icon);
- } else if ((g->data.browser.toolbar) &&
- (g->data.browser.toolbar->toolbar_handle == window)) {
- sprintf(message_token, "HelpToolbar%i", (int)icon);
- } else if ((g->data.browser.toolbar) &&
- (g->data.browser.toolbar->status_handle == window)) {
- sprintf(message_token, "HelpStatus%i", (int)icon);
- }
- }
+ } else if ((g = ro_gui_window_lookup(window))) {
+ sprintf(message_token, "HelpBrowser%i", (int)icon);
+ } else if ((g = ro_gui_toolbar_lookup(window))) {
+ sprintf(message_token, "HelpToolbar%i", (int)icon);
+ } else if ((g = ro_gui_status_lookup(window))) {
+ sprintf(message_token, "HelpStatus%i", (int)icon);
}
/* If we've managed to find something so far then we broadcast it
diff --git a/riscos/hotlist.c b/riscos/hotlist.c
index d8616ed84..0024336f0 100644
--- a/riscos/hotlist.c
+++ b/riscos/hotlist.c
@@ -24,6 +24,7 @@
#include "netsurf/riscos/gui.h"
#include "netsurf/riscos/theme.h"
#include "netsurf/riscos/tinct.h"
+#include "netsurf/riscos/toolbar.h"
#include "netsurf/riscos/wimp.h"
#include "netsurf/utils/log.h"
#include "netsurf/utils/messages.h"
@@ -58,7 +59,7 @@ struct hotlist_entry {
/** The hotlist entry that has this entry as its next entry
*/
struct hotlist_entry *previous_entry;
-
+
/** The hotlist entry that this is a child of
*/
struct hotlist_entry *parent_entry;
@@ -111,7 +112,7 @@ struct hotlist_entry {
/** The width of the various lines sub-text
*/
int widths[4];
-
+
/** Whether the item is awaiting processing
*/
bool process;
@@ -261,13 +262,13 @@ void ro_gui_hotlist_init(void) {
/* Get our sprite ids for faster plotting.
*/
if (ro_gui_hotlist_initialise_sprite("expand", HOTLIST_EXPAND) ||
- ro_gui_hotlist_initialise_sprite("collapse", HOTLIST_COLLAPSE) ||
- ro_gui_hotlist_initialise_sprite("entry", HOTLIST_ENTRY) ||
- ro_gui_hotlist_initialise_sprite("line", HOTLIST_LINE) ||
- ro_gui_hotlist_initialise_sprite("halflinet", HOTLIST_TLINE) ||
+ ro_gui_hotlist_initialise_sprite("collapse", HOTLIST_COLLAPSE) ||
+ ro_gui_hotlist_initialise_sprite("entry", HOTLIST_ENTRY) ||
+ ro_gui_hotlist_initialise_sprite("line", HOTLIST_LINE) ||
+ ro_gui_hotlist_initialise_sprite("halflinet", HOTLIST_TLINE) ||
ro_gui_hotlist_initialise_sprite("halflineb", HOTLIST_BLINE)) {
return;
- }
+ }
/* Update our text icon
*/
@@ -297,7 +298,7 @@ void ro_gui_hotlist_init(void) {
warn_user("WimpError", error->errmess);
return;
}
-
+
/* Create our toolbar
*/
ro_theme_create_hotlist_toolbar();
@@ -393,7 +394,7 @@ void ro_gui_hotlist_show(void) {
warn_user("WimpError", error->errmess);
return;
}
-
+
/* Set the caret position
*/
xwimp_set_caret_position(state.w, -1, -100,
@@ -413,7 +414,7 @@ bool ro_gui_hotlist_load(void) {
*/
xosfile_read_stamped_no_path("<Choices$Write>.WWW.NetSurf.Hotlist", &obj_type,
(bits)0, (bits)0, (int *)0, (fileswitch_attr)0, (bits)0);
- if (obj_type != 0) {
+ if (obj_type != 0) {
/* Read our file
*/
encoding = xmlGetCharEncodingName(XML_CHAR_ENCODING_8859_1);
@@ -427,7 +428,7 @@ bool ro_gui_hotlist_load(void) {
/* Perform our recursive load
*/
ro_gui_hotlist_load_entry(doc->children, &root);
-
+
/* Exit cleanly
*/
xmlFreeDoc(doc);
@@ -461,14 +462,14 @@ void ro_gui_hotlist_load_entry(xmlNode *cur, struct hotlist_entry *entry) {
int add_date = -1;
int last_date = -1;
int visits = 0;
-
+
while (cur) {
/* Add any items that have had all the data they can have
*/
if ((load_title != NULL) && ((cur->next == NULL) || ((cur->type == XML_ELEMENT_NODE) &&
((!(strcmp(cur->name, "li"))) || (!(strcmp(cur->name, "h4"))) ||
(!(strcmp(cur->name, "ul"))))))) {
-
+
/* Add the entry
*/
last_entry = ro_gui_hotlist_create_entry(load_title, load_url, filetype, entry);
@@ -478,7 +479,7 @@ void ro_gui_hotlist_load_entry(xmlNode *cur, struct hotlist_entry *entry) {
last_entry->visits = visits;
last_entry->filetype = filetype;
}
-
+
/* Reset our variables
*/
if (load_title) xmlFree(load_title);
@@ -490,7 +491,7 @@ void ro_gui_hotlist_load_entry(xmlNode *cur, struct hotlist_entry *entry) {
last_date = -1;
visits = 0;
}
-
+
/* Gather further information and recurse
*/
if (cur->type == XML_ELEMENT_NODE) {
@@ -499,18 +500,18 @@ void ro_gui_hotlist_load_entry(xmlNode *cur, struct hotlist_entry *entry) {
} else if (!(strcmp(cur->name, "a"))) {
load_url = (char *)xmlGetProp(cur, (const xmlChar *)"href");
}
-
+
if ((cur->children) && (strcmp(cur->name, "h4"))) {
ro_gui_hotlist_load_entry(cur->children, last_entry);
}
-
+
} else {
/* Check for comment data
*/
if (!(strcmp(cur->name, "comment"))) {
xml_comment = xmlNodeGetContent(cur);
comment = xml_comment;
- while (comment[0] == ' ') comment++;
+ while (comment[0] == ' ') comment++;
if (strncmp("Added:", comment, 6) == 0) {
add_date = atoi(comment + 6);
} else if (strncmp("LastVisit:", comment, 10) == 0) {
@@ -828,7 +829,7 @@ void ro_gui_hotlist_delink_entry(struct hotlist_entry *entry) {
}
entry->parent_entry = NULL;
}
-
+
/* Remove the entry from siblings
*/
if (entry->previous_entry) {
@@ -857,11 +858,11 @@ void ro_gui_hotlist_delink_entry(struct hotlist_entry *entry) {
void ro_gui_hotlist_delete_entry(struct hotlist_entry *entry, bool siblings) {
struct hotlist_entry *next_entry = NULL;
while (entry) {
-
+
/* Recurse to children first
*/
if (entry->child_entry) ro_gui_hotlist_delete_entry(entry->child_entry, true);
-
+
/* Free our memory
*/
if (entry->url) {
@@ -872,11 +873,11 @@ void ro_gui_hotlist_delete_entry(struct hotlist_entry *entry, bool siblings) {
free(entry->title);
entry->title = NULL;
}
-
+
/* Get the next entry before we de-link and delete
*/
if (siblings) next_entry = entry->next_entry;
-
+
/* Delink and delete our entry and move on
*/
ro_gui_hotlist_delink_entry(entry);
@@ -1405,7 +1406,7 @@ void ro_gui_hotlist_click(wimp_pointer *pointer) {
xwimp_close_window(hotlist_window);
}
}
-
+
/* Check if we should start a drag
*/
if ((buttons == (wimp_CLICK_SELECT <<4)) || (buttons == (wimp_CLICK_ADJUST << 4))) {
@@ -1707,7 +1708,7 @@ void ro_gui_hotlist_selection_to_process(struct hotlist_entry *entry) {
void ro_gui_hotlist_update_expansion(struct hotlist_entry *entry, bool only_selected,
bool folders, bool links, bool expand, bool contract) {
bool current;
-
+
/* Set a reformat to be pending
*/
reformat_pending = true;
@@ -1857,7 +1858,7 @@ void ro_gui_hotlist_selection_drag_end(wimp_dragged *drag) {
wimp_window_state state;
int x0, y0, x1, y1;
int toolbar_height = 0;
-
+
/* Reset our dragging state
*/
dragging = false;
@@ -1914,7 +1915,7 @@ void ro_gui_hotlist_move_drag_end(wimp_dragged *drag) {
struct hotlist_entry *entry;
int x, y, x0, y0, x1, y1;
bool before = false;
-
+
/* Reset our dragging state
*/
dragging = false;
@@ -1931,7 +1932,7 @@ void ro_gui_hotlist_move_drag_end(wimp_dragged *drag) {
/* Set the process flag for all selected items
*/
ro_gui_hotlist_selection_to_process(root.child_entry);
-
+
/* Get the window state to make everything relative
*/
state.w = hotlist_window;
@@ -1950,7 +1951,7 @@ void ro_gui_hotlist_move_drag_end(wimp_dragged *drag) {
*/
entry = ro_gui_hotlist_find_entry(x, y, root.child_entry);
if (!entry) entry = &root;
-
+
/* No parent of the destination can be processed
*/
test_entry = entry;
@@ -1962,7 +1963,7 @@ void ro_gui_hotlist_move_drag_end(wimp_dragged *drag) {
/* Check for before/after
*/
before = ((y - (entry->y0 + entry->height)) > (-HOTLIST_LINE_HEIGHT / 2));
-
+
/* Start our recursive moving
*/
while (ro_gui_hotlist_move_processing(root.child_entry, entry, before));
@@ -2117,7 +2118,7 @@ void ro_gui_hotlist_toolbar_click(wimp_pointer* pointer) {
void ro_gui_hotlist_prepare_folder_dialog(bool selected) {
struct hotlist_entry *entry = NULL;
if (selected) entry = ro_gui_hotlist_first_selection(root.child_entry);
-
+
/* Update the title
*/
dialog_folder_add = selected;
@@ -2126,7 +2127,7 @@ void ro_gui_hotlist_prepare_folder_dialog(bool selected) {
} else {
ro_gui_set_window_title(dialog_folder, messages_get("NewFolder"));
}
-
+
/* Update the icons
*/
if (entry == NULL) {
@@ -2139,7 +2140,7 @@ void ro_gui_hotlist_prepare_folder_dialog(bool selected) {
void ro_gui_hotlist_prepare_entry_dialog(bool selected) {
struct hotlist_entry *entry = NULL;
if (selected) entry = ro_gui_hotlist_first_selection(root.child_entry);
-
+
/* Update the title
*/
dialog_entry_add = selected;
@@ -2148,7 +2149,7 @@ void ro_gui_hotlist_prepare_entry_dialog(bool selected) {
} else {
ro_gui_set_window_title(dialog_entry, messages_get("NewLink"));
}
-
+
/* Update the icons
*/
if (entry == NULL) {
@@ -2156,7 +2157,7 @@ void ro_gui_hotlist_prepare_entry_dialog(bool selected) {
ro_gui_set_icon_string(dialog_entry, 3, "");
} else {
ro_gui_set_icon_string(dialog_entry, 1, entry->title);
- ro_gui_set_icon_string(dialog_entry, 3, entry->url);
+ ro_gui_set_icon_string(dialog_entry, 3, entry->url);
}
}
@@ -2224,7 +2225,7 @@ void ro_gui_hotlist_dialog_click(wimp_pointer *pointer) {
int close_icon, ok_icon;
bool folder;
bool add;
-
+
/* Get our data
*/
if (pointer->w == dialog_entry) {
@@ -2240,7 +2241,7 @@ void ro_gui_hotlist_dialog_click(wimp_pointer *pointer) {
ok_icon = 3;
folder = true;
add = !dialog_folder_add;
- }
+ }
/* Check for cancelling
*/
@@ -2255,7 +2256,7 @@ void ro_gui_hotlist_dialog_click(wimp_pointer *pointer) {
} else {
ro_gui_hotlist_prepare_entry_dialog(dialog_entry_add);
}
- return;
+ return;
}
/* Check for ok
@@ -2272,7 +2273,7 @@ void ro_gui_hotlist_dialog_click(wimp_pointer *pointer) {
warn_user("NoURLError", 0);
return;
}
-
+
/* Update/insert our data
*/
if (add) {
@@ -2304,7 +2305,7 @@ void ro_gui_hotlist_dialog_click(wimp_pointer *pointer) {
}
ro_gui_hotlist_update_entry_size(entry);
}
-
+
/* Close if we should
*/
if (pointer->buttons == wimp_CLICK_SELECT) {
@@ -2312,7 +2313,7 @@ void ro_gui_hotlist_dialog_click(wimp_pointer *pointer) {
ro_gui_dialog_close(pointer->w);
return;
}
-
+
/* Update our display
*/
if (folder) {
diff --git a/riscos/htmlredraw.c b/riscos/htmlredraw.c
index fb08ae060..9a285fb3c 100644
--- a/riscos/htmlredraw.c
+++ b/riscos/htmlredraw.c
@@ -639,9 +639,10 @@ void html_redraw_background(long xi, long yi, int width, int height,
}
/* Set the plot options */
- if (!ro_gui_current_redraw_gui->option_background_images) return;
- tinct_options = (ro_gui_current_redraw_gui->option_filter_sprites?tinct_BILINEAR_FILTER:0) |
- (ro_gui_current_redraw_gui->option_dither_sprites?tinct_DITHER:0);
+ if (!ro_gui_current_redraw_gui->option.background_images)
+ return;
+ tinct_options = (ro_gui_current_redraw_gui->option.filter_sprites?tinct_BILINEAR_FILTER:0) |
+ (ro_gui_current_redraw_gui->option.dither_sprites?tinct_DITHER:0);
} else {
if (!option_background_images) return;
tinct_options = (option_filter_sprites?tinct_BILINEAR_FILTER:0) |
@@ -688,8 +689,9 @@ void html_redraw_background(long xi, long yi, int width, int height,
/* get toolbar height */
if (ro_gui_current_redraw_gui &&
- ro_gui_current_redraw_gui->data.browser.toolbar)
- toolbar_height = ro_gui_current_redraw_gui->data.browser.toolbar->height;
+ ro_gui_current_redraw_gui->toolbar)
+ toolbar_height = ro_gui_current_redraw_gui->
+ toolbar->height;
/* top left of viewport, taking account of toolbar height */
x = state.visible.x0;
diff --git a/riscos/jpeg.c b/riscos/jpeg.c
index 9cbcd68f9..48792a46e 100644
--- a/riscos/jpeg.c
+++ b/riscos/jpeg.c
@@ -254,8 +254,8 @@ void nsjpeg_redraw(struct content *c, int x, int y,
settings as we are drawing a thumbnail.
*/
if (ro_gui_current_redraw_gui) {
- tinct_options = (ro_gui_current_redraw_gui->option_filter_sprites?tinct_BILINEAR_FILTER:0) |
- (ro_gui_current_redraw_gui->option_dither_sprites?tinct_DITHER:0);
+ tinct_options = (ro_gui_current_redraw_gui->option.filter_sprites?tinct_BILINEAR_FILTER:0) |
+ (ro_gui_current_redraw_gui->option.dither_sprites?tinct_DITHER:0);
} else {
tinct_options = (option_filter_sprites?tinct_BILINEAR_FILTER:0) |
(option_dither_sprites?tinct_DITHER:0);
diff --git a/riscos/menus.c b/riscos/menus.c
index a2c223706..4211642c2 100644
--- a/riscos/menus.c
+++ b/riscos/menus.c
@@ -20,8 +20,9 @@
#include "netsurf/desktop/gui.h"
#include "netsurf/riscos/gui.h"
#include "netsurf/riscos/help.h"
-#include "netsurf/riscos/theme.h"
#include "netsurf/riscos/options.h"
+#include "netsurf/riscos/theme.h"
+#include "netsurf/riscos/toolbar.h"
#include "netsurf/riscos/wimp.h"
#include "netsurf/utils/log.h"
#include "netsurf/utils/messages.h"
@@ -52,9 +53,9 @@ static void ro_gui_menu_browser_warning(wimp_message_menu_warning *warning);
static void ro_gui_menu_hotlist_warning(wimp_message_menu_warning *warning);
static void ro_gui_menu_prepare_hotlist(void);
+struct gui_window *current_gui;
wimp_menu *current_menu;
static int current_menu_x, current_menu_y;
-gui_window *current_gui;
/* Default menu item flags
*/
@@ -467,7 +468,7 @@ void translate_menu(wimp_menu *menu)
* Display a menu.
*/
-void ro_gui_create_menu(wimp_menu *menu, int x, int y, gui_window *g)
+void ro_gui_create_menu(wimp_menu *menu, int x, int y, struct gui_window *g)
{
current_menu = menu;
current_menu_x = x;
@@ -522,7 +523,7 @@ void ro_gui_menu_selection(wimp_selection *selection)
msg.type = act_GADGET_SELECT;
msg.data.gadget_select.g = current_gadget;
msg.data.gadget_select.item = selection->items[0];
- browser_window_action(current_gui->data.browser.bw, &msg);
+ browser_window_action(current_gui->bw, &msg);
} else if (current_menu == iconbar_menu) {
switch (selection->items[0]) {
@@ -591,7 +592,7 @@ void ro_gui_menu_selection(wimp_selection *selection)
break;
}
} else if (current_menu == browser_menu) {
- struct content *c = current_gui->data.browser.bw->current_content;
+ struct content *c = current_gui->bw->current_content;
switch (selection->items[0]) {
case MENU_PAGE:
switch (selection->items[1]) {
@@ -616,7 +617,7 @@ void ro_gui_menu_selection(wimp_selection *selection)
case 5: /* Print */
break;
case 6: /* New window */
- browser_window_create(current_gui->url, current_gui->data.browser.bw);
+ browser_window_create(current_gui->url, current_gui->bw);
break;
case 7: /* Page source */
ro_gui_view_source(c);
@@ -655,7 +656,7 @@ void ro_gui_menu_selection(wimp_selection *selection)
break;
case 2: /* Clear */
msg.type = act_CLEAR_SELECTION;
- browser_window_action(current_gui->data.browser.bw, &msg);
+ browser_window_action(current_gui->bw, &msg);
break;
}
break;
@@ -664,20 +665,20 @@ void ro_gui_menu_selection(wimp_selection *selection)
case 0: /* Home */
break;
case 1: /* Back */
- history_back(current_gui->data.browser.bw,
- current_gui->data.browser.bw->history);
+ history_back(current_gui->bw,
+ current_gui->bw->history);
ro_gui_prepare_navigate(current_gui);
break;
case 2: /* Forward */
- history_forward(current_gui->data.browser.bw,
- current_gui->data.browser.bw->history);
+ history_forward(current_gui->bw,
+ current_gui->bw->history);
ro_gui_prepare_navigate(current_gui);
break;
case 3: /* Reload */
- browser_window_reload(current_gui->data.browser.bw, false);
+ browser_window_reload(current_gui->bw, false);
break;
case 4: /* Stop */
- browser_window_stop(current_gui->data.browser.bw);
+ browser_window_stop(current_gui->bw);
break;
}
break;
@@ -686,14 +687,14 @@ void ro_gui_menu_selection(wimp_selection *selection)
case 0: /* Scale view */
break;
case 1: /* Images -> */
- if (selection->items[2] == 1) current_gui->option_background_images =
- !current_gui->option_background_images;
- if (selection->items[2] == 2) current_gui->option_animate_images =
- !current_gui->option_animate_images;
- if (selection->items[2] == 3) current_gui->option_dither_sprites =
- !current_gui->option_dither_sprites;
- if (selection->items[2] == 4) current_gui->option_filter_sprites =
- !current_gui->option_filter_sprites;
+ if (selection->items[2] == 1) current_gui->option.background_images =
+ !current_gui->option.background_images;
+ if (selection->items[2] == 2) current_gui->option.animate_images =
+ !current_gui->option.animate_images;
+ if (selection->items[2] == 3) current_gui->option.dither_sprites =
+ !current_gui->option.dither_sprites;
+ if (selection->items[2] == 4) current_gui->option.filter_sprites =
+ !current_gui->option.filter_sprites;
if (selection->items[2] >= 1) {
ro_gui_menu_prepare_images();
gui_window_redraw_window(current_gui);
@@ -703,33 +704,33 @@ void ro_gui_menu_selection(wimp_selection *selection)
case 2: /* Toolbars -> */
switch (selection->items[2]) {
case 0:
- current_gui->data.browser.toolbar->standard_buttons =
- !current_gui->data.browser.toolbar->standard_buttons;
+ current_gui->toolbar->standard_buttons =
+ !current_gui->toolbar->standard_buttons;
break;
case 1:
- current_gui->data.browser.toolbar->url_bar =
- !current_gui->data.browser.toolbar->url_bar;
+ current_gui->toolbar->url_bar =
+ !current_gui->toolbar->url_bar;
break;
case 2:
- current_gui->data.browser.toolbar->throbber =
- !current_gui->data.browser.toolbar->throbber;
+ current_gui->toolbar->throbber =
+ !current_gui->toolbar->throbber;
break;
case 3:
- current_gui->data.browser.toolbar->status_window =
- !current_gui->data.browser.toolbar->status_window;
+ current_gui->toolbar->status_window =
+ !current_gui->toolbar->status_window;
}
- if (ro_theme_update_toolbar(current_gui->data.browser.toolbar,
+ if (ro_theme_update_toolbar(current_gui->toolbar,
current_gui->window) || true) {
wimp_window_state state;
state.w = current_gui->window;
wimp_get_window_state(&state);
- current_gui->data.browser.old_height = 0xffffffff;
+ current_gui->old_height = 0xffffffff;
ro_gui_window_open(current_gui, (wimp_open *)&state);
}
ro_gui_menu_prepare_toolbars();
break;
case 3: /* Make default */
- gui_window_default_options(current_gui->data.browser.bw);
+ ro_gui_window_default_options(current_gui->bw);
ro_gui_save_options();
break;
}
@@ -740,7 +741,7 @@ void ro_gui_menu_selection(wimp_selection *selection)
switch (selection->items[2]) {
case 0: /* Add to hotlist */
ro_gui_hotlist_add(current_gui->title,
- current_gui->data.browser.bw->current_content);
+ current_gui->bw->current_content);
break;
case 1: /* Show hotlist */
ro_gui_hotlist_show();
@@ -751,7 +752,7 @@ void ro_gui_menu_selection(wimp_selection *selection)
switch (selection->items[2]) {
case 0:
ro_gui_screen_size(&option_window_screen_width, &option_window_screen_height);
- state.w = current_gui->data.browser.bw->window->window;
+ state.w = current_gui->bw->window->window;
error = xwimp_get_window_state(&state);
if (error) {
LOG(("xwimp_get_window_state: 0x%x: %s",
@@ -807,7 +808,7 @@ void ro_gui_menu_selection(wimp_selection *selection)
if (pointer.buttons == wimp_CLICK_ADJUST) {
if (current_menu == combo_menu)
- gui_gadget_combo(current_gui->data.browser.bw, current_gadget, (unsigned int)current_menu_x, (unsigned int)current_menu_y);
+ gui_gadget_combo(current_gui->bw, current_gadget, (unsigned int)current_menu_x, (unsigned int)current_menu_y);
else
ro_gui_create_menu(current_menu, current_menu_x, current_menu_y, current_gui);
} else {
@@ -841,7 +842,7 @@ void ro_gui_menu_browser_warning(wimp_message_menu_warning *warning)
struct box *box;
os_error *error = 0;
- c = current_gui->data.browser.bw->current_content;
+ c = current_gui->bw->current_content;
switch (warning->selection.items[0]) {
case MENU_PAGE: /* Page -> */
@@ -1086,7 +1087,7 @@ void ro_gui_menu_hotlist_warning(wimp_message_menu_warning *warning)
*
* /param gui_window the gui_window to update
*/
-void ro_gui_prepare_navigate(gui_window *gui) {
+void ro_gui_prepare_navigate(struct gui_window *gui) {
struct browser_window *bw;
struct history *h;
struct content *c;
@@ -1103,10 +1104,10 @@ void ro_gui_prepare_navigate(gui_window *gui) {
/* Get the data we need to work with
*/
- bw = gui->data.browser.bw;
+ bw = gui->bw;
h = bw->history;
c = bw->current_content;
- t = gui->data.browser.toolbar;
+ t = gui->toolbar;
/* Get the initial menu state to check for changes
*/
@@ -1200,13 +1201,13 @@ static void ro_gui_menu_prepare_images(void) {
/* We don't currently have any local options so we update from the global ones
*/
browser_image_menu->entries[1].menu_flags &= ~wimp_MENU_TICKED;
- if (current_gui->option_background_images) browser_image_menu->entries[1].menu_flags |= wimp_MENU_TICKED;
+ if (current_gui->option.background_images) browser_image_menu->entries[1].menu_flags |= wimp_MENU_TICKED;
browser_image_menu->entries[2].menu_flags &= ~wimp_MENU_TICKED;
- if (current_gui->option_animate_images) browser_image_menu->entries[2].menu_flags |= wimp_MENU_TICKED;
+ if (current_gui->option.animate_images) browser_image_menu->entries[2].menu_flags |= wimp_MENU_TICKED;
browser_image_menu->entries[3].menu_flags &= ~wimp_MENU_TICKED;
- if (current_gui->option_dither_sprites) browser_image_menu->entries[3].menu_flags |= wimp_MENU_TICKED;
+ if (current_gui->option.dither_sprites) browser_image_menu->entries[3].menu_flags |= wimp_MENU_TICKED;
browser_image_menu->entries[4].menu_flags &= ~wimp_MENU_TICKED;
- if (current_gui->option_filter_sprites) browser_image_menu->entries[4].menu_flags |= wimp_MENU_TICKED;
+ if (current_gui->option.filter_sprites) browser_image_menu->entries[4].menu_flags |= wimp_MENU_TICKED;
}
@@ -1255,7 +1256,7 @@ static void ro_gui_menu_prepare_toolbars(void) {
/* Check we have a toolbar
*/
- toolbar = current_gui->data.browser.toolbar;
+ toolbar = current_gui->toolbar;
/* Set our ticks, or shade everything if there's no toolbar
*/
@@ -1283,7 +1284,7 @@ static void ro_gui_menu_prepare_toolbars(void) {
void ro_gui_menu_prepare_scale(void) {
char scale_buffer[8];
if (current_menu != browser_menu) return;
- sprintf(scale_buffer, "%.0f", current_gui->scale * 100);
+ sprintf(scale_buffer, "%.0f", current_gui->option.scale * 100);
ro_gui_set_icon_string(dialog_zoom, ICON_ZOOM_VALUE, scale_buffer);
}
@@ -1339,7 +1340,7 @@ void ro_gui_menu_prepare_help(int forced) {
void ro_gui_menu_prepare_pageinfo(void)
{
- struct content *c = current_gui->data.browser.bw->current_content;
+ struct content *c = current_gui->bw->current_content;
char icon_buf[20] = "file_xxx";
const char *icon = icon_buf;
const char *title = "-";
@@ -1372,7 +1373,7 @@ void ro_gui_menu_prepare_pageinfo(void)
void ro_gui_menu_objectinfo(wimp_message_menu_warning *warning)
{
- struct content *c = current_gui->data.browser.bw->current_content;
+ struct content *c = current_gui->bw->current_content;
struct box *box;
os_error *error;
char icon_buf[20] = "file_xxx";
@@ -1412,7 +1413,7 @@ void ro_gui_menu_objectinfo(wimp_message_menu_warning *warning)
struct box *ro_gui_menu_find_object_box(void)
{
- struct content *c = current_gui->data.browser.bw->current_content;
+ struct content *c = current_gui->bw->current_content;
struct box_selection *boxes = NULL;
struct box *box = NULL;
int found = 0, plot_index = 0, i, x, y;
@@ -1424,8 +1425,8 @@ struct box *ro_gui_menu_find_object_box(void)
/* The menu is initially created 64 units to the left
* of the mouse position. Therefore, we negate the offset here
*/
- x = window_x_units(current_menu_x+64, &state) / 2 / current_gui->scale;
- y = -window_y_units(current_menu_y, &state) / 2 / current_gui->scale;
+ x = window_x_units(current_menu_x+64, &state) / 2 / current_gui->option.scale;
+ y = -window_y_units(current_menu_y, &state) / 2 / current_gui->option.scale;
if (c->type == CONTENT_HTML) {
@@ -1453,7 +1454,7 @@ void ro_gui_menu_object_reload(void)
if (box) {
box->object->fresh = false;
- browser_window_reload(current_gui->data.browser.bw, false);
+ browser_window_reload(current_gui->bw, false);
}
}
diff --git a/riscos/mng.c b/riscos/mng.c
index c5c124ed0..1f25f9e1b 100644
--- a/riscos/mng.c
+++ b/riscos/mng.c
@@ -52,8 +52,8 @@ void nsmng_redraw(struct content *c, int x, int y,
settings as we are drawing a thumbnail.
*/
if (ro_gui_current_redraw_gui) {
- tinct_options = (ro_gui_current_redraw_gui->option_filter_sprites?tinct_BILINEAR_FILTER:0) |
- (ro_gui_current_redraw_gui->option_dither_sprites?tinct_DITHER:0);
+ tinct_options = (ro_gui_current_redraw_gui->option.filter_sprites?tinct_BILINEAR_FILTER:0) |
+ (ro_gui_current_redraw_gui->option.dither_sprites?tinct_DITHER:0);
} else {
tinct_options = (option_filter_sprites?tinct_BILINEAR_FILTER:0) |
(option_dither_sprites?tinct_DITHER:0);
diff --git a/riscos/mouseactions.c b/riscos/mouseactions.c
index db5db2af8..09324eac7 100644
--- a/riscos/mouseactions.c
+++ b/riscos/mouseactions.c
@@ -27,7 +27,7 @@ static int anglesDifferent(double a, double b);
static mouseaction ro_gui_try_mouse_action(void);
-void ro_gui_mouse_action(gui_window *g) {
+void ro_gui_mouse_action(struct gui_window *g) {
int x, y;
mouseaction ma = mouseaction_NONE;
diff --git a/riscos/png.c b/riscos/png.c
index 1cc2bf622..63b9c651d 100644
--- a/riscos/png.c
+++ b/riscos/png.c
@@ -277,8 +277,8 @@ void nspng_redraw(struct content *c, int x, int y,
settings as we are drawing a thumbnail.
*/
if (ro_gui_current_redraw_gui) {
- tinct_options = (ro_gui_current_redraw_gui->option_filter_sprites?tinct_BILINEAR_FILTER:0) |
- (ro_gui_current_redraw_gui->option_dither_sprites?tinct_DITHER:0);
+ tinct_options = (ro_gui_current_redraw_gui->option.filter_sprites?tinct_BILINEAR_FILTER:0) |
+ (ro_gui_current_redraw_gui->option.dither_sprites?tinct_DITHER:0);
} else {
tinct_options = (option_filter_sprites?tinct_BILINEAR_FILTER:0) |
(option_dither_sprites?tinct_DITHER:0);
diff --git a/riscos/textselection.c b/riscos/textselection.c
index 6b0c71888..34be842d7 100644
--- a/riscos/textselection.c
+++ b/riscos/textselection.c
@@ -13,7 +13,7 @@
void ro_gui_start_selection(wimp_pointer *pointer, wimp_window_state *state,
- gui_window *g)
+ struct gui_window *g)
{
wimp_drag drag;
@@ -48,24 +48,22 @@ void ro_gui_selection_drag_end(wimp_dragged *drag)
msg.data.mouse.x = final_x0;
msg.data.mouse.y = final_y0;
msg.type = act_ALTER_SELECTION;
- browser_window_action(current_gui->data.browser.bw, &msg);
+ browser_window_action(current_gui->bw, &msg);
- if (box_position_eq(&(current_gui->data.browser.bw->current_content->data.html.text_selection.start),
- &(current_gui->data.browser.bw->current_content->data.html.text_selection.end)))
+ if (box_position_eq(&(current_gui->bw->current_content->data.html.text_selection.start),
+ &(current_gui->bw->current_content->data.html.text_selection.end)))
{
msg.type = act_CLEAR_SELECTION;
- browser_window_action(current_gui->data.browser.bw, &msg);
+ browser_window_action(current_gui->bw, &msg);
}
- current_gui->drag_status = drag_NONE;
- current_gui->data.browser.bw->current_content->data.html.text_selection.altering = alter_UNKNOWN;
+ current_gui->bw->current_content->data.html.text_selection.altering = alter_UNKNOWN;
}
-void ro_gui_copy_selection(gui_window* g)
+void ro_gui_copy_selection(struct gui_window* g)
{
- if (g->type == GUI_BROWSER_WINDOW)
{
-// if (g->data.browser.bw->text_selection->selected == 1)
+// if (g->bw->text_selection->selected == 1)
// {
// }
}
diff --git a/riscos/theme.c b/riscos/theme.c
index a706ac87c..fca63da51 100644
--- a/riscos/theme.c
+++ b/riscos/theme.c
@@ -123,14 +123,14 @@ void ro_theme_load(char *pathname) {
* The buffers url_buffer and status_buffer must be at least 256 bytes each,
* throbber_buffer at least 12 bytes;
*/
-void ro_theme_create_browser_toolbar(gui_window *g) {
+void ro_theme_create_browser_toolbar(struct gui_window *g) {
struct toolbar *toolbar;
/* Destroy any previous toolbar (paranoia)
*/
- if (g->data.browser.toolbar) {
- ro_toolbar_destroy(g->data.browser.toolbar);
- g->data.browser.toolbar = NULL;
+ if (g->toolbar) {
+ ro_toolbar_destroy(g->toolbar);
+ g->toolbar = NULL;
}
/* Create a toolbar
*/
@@ -146,7 +146,7 @@ void ro_theme_create_browser_toolbar(gui_window *g) {
/* Store our toolbar
*/
- g->data.browser.toolbar = toolbar;
+ g->toolbar = toolbar;
/* Update the toolbar
*/
@@ -179,7 +179,7 @@ void ro_theme_create_hotlist_toolbar(void) {
/* Store our toolbar
*/
hotlist_toolbar = toolbar;
-
+
/* Update the toolbar
*/
ro_theme_update_toolbar(toolbar, hotlist_window);
diff --git a/riscos/theme.h b/riscos/theme.h
index 2cca6b8ab..613da245c 100644
--- a/riscos/theme.h
+++ b/riscos/theme.h
@@ -30,7 +30,7 @@ struct theme_entry {
extern int theme_throbs;
void ro_theme_load(char *pathname);
-void ro_theme_create_browser_toolbar(gui_window *g);
+void ro_theme_create_browser_toolbar(struct gui_window *g);
void ro_theme_create_hotlist_toolbar(void);
int ro_theme_update_toolbar(struct toolbar *toolbar, wimp_w window);
int ro_theme_resize_toolbar(struct toolbar *toolbar, wimp_w window);
diff --git a/riscos/window.c b/riscos/window.c
index 5d70e72c8..2c86918d1 100644
--- a/riscos/window.c
+++ b/riscos/window.c
@@ -26,14 +26,23 @@
#include "netsurf/riscos/options.h"
#include "netsurf/riscos/theme.h"
#include "netsurf/riscos/thumbnail.h"
+#include "netsurf/riscos/toolbar.h"
#include "netsurf/riscos/wimp.h"
#include "netsurf/render/form.h"
#include "netsurf/utils/log.h"
#include "netsurf/utils/url.h"
#include "netsurf/utils/utils.h"
-gui_window *ro_gui_current_redraw_gui;
-gui_window *window_list = 0;
+
+/** List of all browser windows. */
+static struct gui_window *window_list = 0;
+/** Browser window which is being redrawn. Valid only during redraw. */
+struct gui_window *ro_gui_current_redraw_gui;
+
+
+static void ro_gui_window_clone_options(struct browser_window *new_bw,
+ struct browser_window *old_bw);
+
/**
@@ -44,7 +53,7 @@ gui_window *window_list = 0;
* \return gui_window, or 0 on error and error reported
*/
-gui_window *gui_create_browser_window(struct browser_window *bw,
+struct gui_window *gui_create_browser_window(struct browser_window *bw,
struct browser_window *clone)
{
int screen_width, screen_height, win_width, win_height, scroll_width;
@@ -53,22 +62,23 @@ gui_window *gui_create_browser_window(struct browser_window *bw,
wimp_window_state state;
os_error *error;
bool open_centred = true;
+ struct gui_window *g;
- gui_window *g = malloc(sizeof *g);
+ g = malloc(sizeof *g);
if (!g) {
warn_user("NoMemory", 0);
return 0;
}
- g->type = GUI_BROWSER_WINDOW;
- g->data.browser.bw = bw;
- g->data.browser.toolbar = 0;
- g->data.browser.reformat_pending = false;
- g->data.browser.old_width = 0;
+ g->bw = bw;
+ g->toolbar = 0;
+ g->reformat_pending = false;
+ g->old_width = 0;
+ g->old_height = 0;
strcpy(g->status, "");
strcpy(g->title, "NetSurf");
strcpy(g->url, "");
- strcpy(g->throb_buf, "throbber0");
g->throbber = 0;
+ strcpy(g->throb_buf, "throbber0");
g->throbtime = 0;
/* Set the window position
@@ -91,17 +101,25 @@ gui_window *gui_create_browser_window(struct browser_window *bw,
/* Check if we have a preferred position
*/
- if ((option_window_screen_width != 0) && (option_window_screen_height != 0)) {
- win_width = (option_window_width * screen_width) / option_window_screen_width;
- win_height = (option_window_height * screen_height) / option_window_screen_height;
- window.visible.x0 = (option_window_x * screen_width) / option_window_screen_width;
- window.visible.y0 = (option_window_y * screen_height) / option_window_screen_height;
+ if ((option_window_screen_width != 0) &&
+ (option_window_screen_height != 0)) {
+ win_width = (option_window_width * screen_width) /
+ option_window_screen_width;
+ win_height = (option_window_height * screen_height) /
+ option_window_screen_height;
+ window.visible.x0 = (option_window_x * screen_width) /
+ option_window_screen_width;
+ window.visible.y0 = (option_window_y * screen_height) /
+ option_window_screen_height;
if (option_window_stagger) {
- window.visible.y0 += 96 - (48 * (window_count % 5));
+ window.visible.y0 += 96 -
+ (48 * (window_count % 5));
}
open_centred = false;
- if (win_width < 100) win_width = 100;
- if (win_height < 100) win_height = 100;
+ if (win_width < 100)
+ win_width = 100;
+ if (win_height < 100)
+ win_height = 100;
} else {
win_width = screen_width * 3 / 4;
if (1600 < win_width)
@@ -109,8 +127,8 @@ gui_window *gui_create_browser_window(struct browser_window *bw,
win_height = win_width * 3 / 4;
window.visible.x0 = (screen_width - win_width) / 2;
- window.visible.y0 = ((screen_height - win_height) / 2) + 96 -
- (48 * (window_count % 5));
+ window.visible.y0 = ((screen_height - win_height) / 2) +
+ 96 - (48 * (window_count % 5));
}
window.visible.x1 = window.visible.x0 + win_width;
window.visible.y1 = window.visible.y0 + win_height;
@@ -169,6 +187,7 @@ gui_window *gui_create_browser_window(struct browser_window *bw,
ro_theme_create_browser_toolbar(g);
+ g->prev = 0;
g->next = window_list;
window_list = g;
window_count++;
@@ -176,7 +195,7 @@ gui_window *gui_create_browser_window(struct browser_window *bw,
/* Set the window options
*/
bw->window = g;
- gui_window_clone_options(bw, clone);
+ ro_gui_window_clone_options(bw, clone);
/* Open the window
*/
@@ -203,9 +222,9 @@ gui_window *gui_create_browser_window(struct browser_window *bw,
/* Set the caret position to the URL bar
*/
- if (g->data.browser.toolbar && g->data.browser.toolbar->url_bar)
+ if (g->toolbar && g->toolbar->url_bar)
error = xwimp_set_caret_position(
- g->data.browser.toolbar->toolbar_handle,
+ g->toolbar->toolbar_handle,
ICON_TOOLBAR_URL, -1, -1, -1, 0);
else
error = xwimp_set_caret_position(g->window,
@@ -222,107 +241,182 @@ gui_window *gui_create_browser_window(struct browser_window *bw,
}
-void gui_window_set_title(gui_window* g, char* title) {
- strncpy(g->title, title, 255);
- wimp_force_redraw_title(g->window);
+/**
+ * Close a browser window and free any related resources.
+ *
+ * \param g gui_window to destroy
+ */
+
+void gui_window_destroy(struct gui_window *g)
+{
+ os_error *error;
+
+ assert(g);
+
+ /* remove from list */
+ if (g->prev)
+ g->prev->next = g->next;
+ else
+ window_list = g->next;
+ if (g->next)
+ g->next->prev = g->prev;
+
+ ro_toolbar_destroy(g->toolbar);
+
+ /* delete window */
+ error = xwimp_delete_window(g->window);
+ if (error) {
+ LOG(("xwimp_delete_window: 0x%x: %s",
+ error->errnum, error->errmess));
+ warn_user("WimpError", error->errmess);
+ }
+
+ free(g);
}
-void gui_window_destroy(gui_window* g)
+/**
+ * Set the title of a browser window.
+ *
+ * \param g gui_window to update
+ * \param title new window title, copied
+ */
+
+void gui_window_set_title(struct gui_window *g, const char *title)
{
- assert(g != 0);
-
- if (g == window_list)
- window_list = g->next;
- else
- {
- gui_window* gg;
- assert(window_list != NULL);
- gg = window_list;
- while (gg->next != g && gg->next != NULL)
- gg = gg->next;
- assert(gg->next != NULL);
- gg->next = g->next;
- }
-
- ro_toolbar_destroy(g->data.browser.toolbar);
- xwimp_delete_window(g->window);
-
- free(g);
+ os_error *error;
+
+ assert(g);
+ assert(title);
+
+ strncpy(g->title, title, sizeof g->title);
+ error = xwimp_force_redraw_title(g->window);
+ if (error) {
+ LOG(("xwimp_force_redraw_title: 0x%x: %s",
+ error->errnum, error->errmess));
+ warn_user("WimpError", error->errmess);
+ }
}
-void gui_window_redraw(gui_window* g, unsigned long x0, unsigned long y0,
- unsigned long x1, unsigned long y1)
+
+/**
+ * Force a redraw of part of the contents of a browser window.
+ *
+ * \param g gui_window to redraw
+ * \param x0 rectangle to redraw
+ * \param y0 rectangle to redraw
+ * \param x1 rectangle to redraw
+ * \param y1 rectangle to redraw
+ */
+
+void gui_window_redraw(struct gui_window *g, int x0, int y0, int x1, int y1)
{
- if (g == NULL)
- return;
+ os_error *error;
- wimp_force_redraw(g->window, x0 * 2, -y1 * 2, x1 * 2, -y0 * 2);
+ assert(g);
+
+ error = xwimp_force_redraw(g->window, x0 * 2, -y1 * 2, x1 * 2, -y0 * 2);
+ if (error) {
+ LOG(("xwimp_force_redraw: 0x%x: %s",
+ error->errnum, error->errmess));
+ warn_user("WimpError", error->errmess);
+ }
}
-void gui_window_redraw_window(gui_window* g)
+
+/**
+ * Force a redraw of the entire contents of a browser window.
+ *
+ * \param g gui_window to redraw
+ */
+
+void gui_window_redraw_window(struct gui_window *g)
{
- wimp_window_info info;
- if (g == NULL)
- return;
- info.w = g->window;
- wimp_get_window_info_header_only(&info);
- wimp_force_redraw(g->window, info.extent.x0, info.extent.y0, info.extent.x1, info.extent.y1);
+ wimp_window_info info;
+ os_error *error;
+
+ assert(g);
+
+ info.w = g->window;
+ error = xwimp_get_window_info_header_only(&info);
+ if (error) {
+ LOG(("xwimp_get_window_info_header_only: 0x%x: %s",
+ error->errnum, error->errmess));
+ warn_user("WimpError", error->errmess);
+ return;
+ }
+
+ error = xwimp_force_redraw(g->window, info.extent.x0, info.extent.y0,
+ info.extent.x1, info.extent.y1);
+ if (error) {
+ LOG(("xwimp_force_redraw: 0x%x: %s",
+ error->errnum, error->errmess));
+ warn_user("WimpError", error->errmess);
+ }
}
-void ro_gui_window_redraw(gui_window* g, wimp_draw* redraw) {
+/**
+ * Handle a Redraw_Window_Request for a browser window.
+ */
+
+void ro_gui_window_redraw(struct gui_window *g, wimp_draw *redraw)
+{
osbool more;
bool clear_background = false;
- struct content *c = g->data.browser.bw->current_content;
- unsigned long background_colour = 0xffffff;
+ struct content *c = g->bw->current_content;
+ os_error *error;
/* Set the current redraw gui_window to get options from
*/
ro_gui_current_redraw_gui = g;
- /* Perform the update
+ /* We should clear the background, except for HTML.
*/
- if (g->type == GUI_BROWSER_WINDOW && c != NULL) {
+ if (!c || c->type != CONTENT_HTML)
+ clear_background = true;
- /* We should clear the background for GIFs and PNGs
- */
- if ((c->type != CONTENT_HTML) &&
- (c->type != CONTENT_TEXTPLAIN)) {
- clear_background = true;
+ error = xwimp_redraw_window(redraw, &more);
+ if (error) {
+ LOG(("xwimp_redraw_window: 0x%x: %s",
+ error->errnum, error->errmess));
+ warn_user("WimpError", error->errmess);
+ return;
+ }
+ while (more) {
+ if (clear_background) {
+ error = xcolourtrans_set_gcol(os_COLOUR_WHITE,
+ colourtrans_SET_BG,
+ os_ACTION_OVERWRITE, 0, 0);
+ if (error) {
+ LOG(("xcolourtrans_set_gcol: 0x%x: %s",
+ error->errnum, error->errmess));
+ warn_user("MiscError", error->errmess);
+ }
+ os_clg();
}
- more = wimp_redraw_window(redraw);
- wimp_set_font_colours(wimp_COLOUR_WHITE, wimp_COLOUR_BLACK);
+ if (c) {
+ content_redraw(c,
+ redraw->box.x0 - redraw->xscroll,
+ redraw->box.y1 - redraw->yscroll,
+ c->width * 2,
+ c->height * 2,
+ redraw->clip.x0,
+ redraw->clip.y0,
+ redraw->clip.x1 - 1,
+ redraw->clip.y1 - 1,
+ g->option.scale);
+ }
- while (more) {
- if (clear_background) {
- colourtrans_set_gcol(background_colour << 8,
- colourtrans_SET_BG | colourtrans_USE_ECFS,
- os_ACTION_OVERWRITE, 0);
- os_clg();
- }
- content_redraw(c,
- (int) redraw->box.x0 - (int) redraw->xscroll,
- (int) redraw->box.y1 - (int) redraw->yscroll,
- c->width * 2, c->height * 2,
- redraw->clip.x0, redraw->clip.y0,
- redraw->clip.x1 - 1, redraw->clip.y1 - 1,
- g->scale);
- more = wimp_get_rectangle(redraw);
- }
- } else {
- more = wimp_redraw_window(redraw);
- while (more) {
- if (g->type == GUI_BROWSER_WINDOW && c == NULL) {
- colourtrans_set_gcol(background_colour << 8,
- colourtrans_SET_BG | colourtrans_USE_ECFS,
- os_ACTION_OVERWRITE, 0);
- os_clg();
- }
- more = wimp_get_rectangle(redraw);
- }
- }
+ error = xwimp_get_rectangle(redraw, &more);
+ if (error) {
+ LOG(("xwimp_get_rectangle: 0x%x: %s",
+ error->errnum, error->errmess));
+ warn_user("WimpError", error->errmess);
+ return;
+ }
+ }
/* Reset the current redraw gui_window to prevent thumbnails from
retaining options
@@ -338,27 +432,28 @@ void ro_gui_window_redraw(gui_window* g, wimp_draw* redraw) {
* \param data content_msg_data union with filled in redraw data
*/
-void gui_window_update_box(gui_window *g, const union content_msg_data *data)
+void gui_window_update_box(struct gui_window *g,
+ const union content_msg_data *data)
{
- struct content *c = g->data.browser.bw->current_content;
+ struct content *c = g->bw->current_content;
osbool more;
bool clear_background = false;
- unsigned long background_colour = 0xffffff;
- os_error *error;
wimp_draw update;
+ os_error *error;
update.w = g->window;
- update.box.x0 = floorf(data->redraw.x * 2 * g->scale);
+ update.box.x0 = floorf(data->redraw.x * 2 * g->option.scale);
update.box.y0 = -ceilf((data->redraw.y + data->redraw.height) * 2 *
- g->scale);
+ g->option.scale);
update.box.x1 = ceilf((data->redraw.x + data->redraw.width) * 2 *
- g->scale) + 1;
- update.box.y1 = -floorf(data->redraw.y * 2 * g->scale) + 1;
+ g->option.scale) + 1;
+ update.box.y1 = -floorf(data->redraw.y * 2 * g->option.scale) + 1;
error = xwimp_update_window(&update, &more);
if (error) {
LOG(("xwimp_update_window: 0x%x: %s",
error->errnum, error->errmess));
+ warn_user("WimpError", error->errmess);
return;
}
@@ -366,50 +461,58 @@ void gui_window_update_box(gui_window *g, const union content_msg_data *data)
*/
ro_gui_current_redraw_gui = g;
- /* We should clear the background for content that isn't HTML or plain text
+ /* We should clear the background, except for HTML.
*/
- if ((c->type != CONTENT_HTML) &&
- (c->type != CONTENT_TEXTPLAIN)) {
- clear_background = true;
- }
+ if (c->type != CONTENT_HTML)
+ clear_background = true;
while (more) {
if (data->redraw.full_redraw) {
if (clear_background) {
- colourtrans_set_gcol(background_colour << 8,
- colourtrans_SET_BG | colourtrans_USE_ECFS,
- os_ACTION_OVERWRITE, 0);
+ error = xcolourtrans_set_gcol(os_COLOUR_WHITE,
+ colourtrans_SET_BG,
+ os_ACTION_OVERWRITE, 0, 0);
+ if (error) {
+ LOG(("xcolourtrans_set_gcol: 0x%x: %s",
+ error->errnum,
+ error->errmess));
+ warn_user("MiscError", error->errmess);
+ }
os_clg();
}
+
content_redraw(c,
update.box.x0 - update.xscroll,
update.box.y1 - update.yscroll,
c->width * 2, c->height * 2,
update.clip.x0, update.clip.y0,
update.clip.x1 - 1, update.clip.y1 - 1,
- g->scale);
- } else {
+ g->option.scale);
+ } else {
assert(data->redraw.object);
content_redraw(data->redraw.object,
update.box.x0 - update.xscroll +
floorf(data->redraw.object_x * 2 *
- g->scale),
+ g->option.scale),
update.box.y1 - update.yscroll -
ceilf(data->redraw.object_y * 2 *
- g->scale),
- data->redraw.object_width * 2 * g->scale,
- data->redraw.object_height * 2 * g->scale,
+ g->option.scale),
+ data->redraw.object_width * 2 *
+ g->option.scale,
+ data->redraw.object_height * 2 *
+ g->option.scale,
update.clip.x0, update.clip.y0,
update.clip.x1 - 1, update.clip.y1 - 1,
- g->scale);
+ g->option.scale);
}
error = xwimp_get_rectangle(&update, &more);
if (error) {
LOG(("xwimp_get_rectangle: 0x%x: %s",
error->errnum, error->errmess));
-// return;
+ warn_user("WimpError", error->errmess);
+ return;
}
}
@@ -419,77 +522,173 @@ void gui_window_update_box(gui_window *g, const union content_msg_data *data)
ro_gui_current_redraw_gui = NULL;
}
-void gui_window_set_scroll(gui_window* g, unsigned long sx, unsigned long sy)
+
+/**
+ * Set the scroll position of a browser window.
+ *
+ * \param g gui_window to scroll
+ * \param sx point to place at top-left of window
+ * \param sy point to place at top-left of window
+ */
+
+void gui_window_set_scroll(struct gui_window *g, int sx, int sy)
{
- wimp_window_state state;
- if (g == NULL)
- return;
- state.w = g->window;
- wimp_get_window_state(&state);
- state.xscroll = sx * 2;
- state.yscroll = -sy * 2;
- state.yscroll += g->data.browser.toolbar->height;
- ro_gui_window_open(g, (wimp_open*)&state);
+ wimp_window_state state;
+ os_error *error;
+
+ assert(g);
+
+ state.w = g->window;
+ 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;
+ }
+
+ state.xscroll = sx * 2;
+ state.yscroll = -sy * 2;
+ if (g->toolbar)
+ state.yscroll += g->toolbar->height;
+ ro_gui_window_open(g, (wimp_open *) &state);
}
-unsigned long gui_window_get_width(gui_window* g) {
- wimp_window_state state;
- state.w = g->window;
- wimp_get_window_state(&state);
- return (state.visible.x1 - state.visible.x0) / 2;
+
+/**
+ * Find the current width of a browser window.
+ *
+ * \param g gui_window to measure
+ * \return width of window
+ */
+
+int gui_window_get_width(struct gui_window *g)
+{
+ wimp_window_state state;
+ os_error *error;
+
+ state.w = g->window;
+ 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 800;
+ }
+ return (state.visible.x1 - state.visible.x0) / 2;
}
-void gui_window_set_extent(gui_window *g, unsigned long width, unsigned long height) {
+/**
+ * Set the extent of the inside of a browser window.
+ *
+ * \param g gui_window to resize
+ * \param width new extent
+ * \param height new extent
+ */
+
+void gui_window_set_extent(struct gui_window *g, int width, int height)
+{
os_box extent = { 0, 0, 0, 0 };
wimp_window_state state;
int toolbar_height = 0;
+ os_error *error;
- width *= 2 * g->scale;
- height *= 2 * g->scale;
+ width *= 2 * g->option.scale;
+ height *= 2 * g->option.scale;
state.w = g->window;
- wimp_get_window_state(&state);
+ 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;
+ }
/* account for toolbar height, if present */
- if (g->data.browser.toolbar) toolbar_height = g->data.browser.toolbar->height;
+ if (g->toolbar)
+ toolbar_height = g->toolbar->height;
- if (width < (unsigned int)(state.visible.x1 - state.visible.x0))
+ if (width < state.visible.x1 - state.visible.x0)
width = state.visible.x1 - state.visible.x0;
- if (height < (unsigned int)(state.visible.y1 - state.visible.y0 - toolbar_height))
+ if (height < state.visible.y1 - state.visible.y0 - toolbar_height)
height = state.visible.y1 - state.visible.y0 - toolbar_height;
extent.y0 = -height;
extent.x1 = width;
extent.y1 = toolbar_height;
- wimp_set_extent(g->window, &extent);
- wimp_open_window((wimp_open *) &state);
+ error = xwimp_set_extent(g->window, &extent);
+ if (error) {
+ LOG(("xwimp_set_extent: 0x%x: %s",
+ error->errnum, error->errmess));
+ warn_user("WimpError", error->errmess);
+ return;
+ }
+
+ 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);
+ }
}
-void gui_window_set_status(gui_window* g, const char* text) {
- if (g->data.browser.toolbar) {
- ro_gui_set_icon_string(g->data.browser.toolbar->status_handle, ICON_STATUS_TEXT, text);
- }
+/**
+ * Set the status bar of a browser window.
+ *
+ * \param g gui_window to update
+ * \param text new status text
+ */
+
+void gui_window_set_status(struct gui_window *g, const char *text)
+{
+ if (!g->toolbar)
+ return;
+
+ ro_gui_set_icon_string(g->toolbar->status_handle,
+ ICON_STATUS_TEXT, text);
}
+
/**
* Set the contents of a window's address bar.
+ *
+ * \param g gui_window to update
+ * \param url new url for address bar
*/
-void gui_window_set_url(gui_window *g, char *url) {
- wimp_caret c;
- if (g->data.browser.toolbar) {
- ro_gui_set_icon_string(g->data.browser.toolbar->toolbar_handle, ICON_TOOLBAR_URL, url);
+void gui_window_set_url(struct gui_window *g, const char *url)
+{
+ wimp_caret caret;
+ os_error *error;
+
+ if (!g->toolbar)
+ return;
- /* Move the caret to the URL bar
- */
- if (!xwimp_get_caret_position(&c)) {
- if (c.w == g->window || c.w == g->data.browser.toolbar->toolbar_handle) {
- xwimp_set_caret_position(g->data.browser.toolbar->toolbar_handle,
- ICON_TOOLBAR_URL, 0, 0, -1, (int)strlen(g->url));
- }
- }
+ ro_gui_set_icon_string(g->toolbar->toolbar_handle,
+ ICON_TOOLBAR_URL, url);
+
+ /* if the caret is in the address bar, move it to the end */
+ 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;
+ }
+
+ if (!(caret.w == g->toolbar->toolbar_handle &&
+ caret.i == ICON_TOOLBAR_URL))
+ return;
+
+ error = xwimp_set_caret_position(g->toolbar->toolbar_handle,
+ ICON_TOOLBAR_URL, 0, 0, -1, (int) strlen(g->url));
+ if (error) {
+ LOG(("xwimp_set_caret_position: 0x%x: %s",
+ error->errnum, error->errmess));
+ warn_user("WimpError", error->errmess);
}
}
@@ -498,7 +697,8 @@ void gui_window_set_url(gui_window *g, char *url) {
* Open a window using the given wimp_open, handling toolbars and resizing.
*/
-void ro_gui_window_open(gui_window *g, wimp_open *open) {
+void ro_gui_window_open(struct gui_window *g, wimp_open *open)
+{
int width = open->visible.x1 - open->visible.x0;
int height = open->visible.y1 - open->visible.y0;
int toolbar_height = 0;
@@ -506,24 +706,26 @@ void ro_gui_window_open(gui_window *g, wimp_open *open) {
wimp_window_state state;
bool toggle_hack = false;
int screen_height, screen_width;
+ os_error *error;
- if (g->type != GUI_BROWSER_WINDOW) {
- wimp_open_window(open);
- return;
- }
-
- content = g->data.browser.bw->current_content;
+ content = g->bw->current_content;
/* check for toggle to full size - NOW FEATURING "TEMPORARY HACK" */
state.w = g->window;
- wimp_get_window_state(&state);
+ 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;
+ }
if ((state.flags & wimp_WINDOW_TOGGLED) &&
(state.flags & wimp_WINDOW_BOUNDED_ONCE) &&
!(state.flags & wimp_WINDOW_FULL_SIZE)) {
/* Check if we need to perform our hack
*/
ro_gui_screen_size(&screen_width, &screen_height);
- if ((content->height * 2 * g->scale) < screen_height) {
+ if ((content->height * 2 * g->option.scale) < screen_height) {
open->visible.y0 = 0;
open->visible.y1 = 0x1000;
height = 0x1000;
@@ -532,165 +734,188 @@ void ro_gui_window_open(gui_window *g, wimp_open *open) {
}
/* account for toolbar height, if present */
- if (g->data.browser.toolbar) toolbar_height = g->data.browser.toolbar->height;
+ if (g->toolbar)
+ toolbar_height = g->toolbar->height;
height -= toolbar_height;
/* The height should be no less than the content height
*/
- if (content && (unsigned int)height < content->height * 2 * g->scale) {
- height = content->height * 2 * g->scale;
- }
+ if (content && height < content->height * 2 * g->option.scale)
+ height = content->height * 2 * g->option.scale;
/* change extent if necessary */
- if (g->data.browser.old_width != width ||
- g->data.browser.old_height != height) {
- if (content && g->data.browser.old_width != width) {
- g->data.browser.reformat_pending = true;
+ if (g->old_width != width || g->old_height != height) {
+ if (content && g->old_width != width) {
+ g->reformat_pending = true;
gui_reformat_pending = true;
}
- g->data.browser.old_width = width;
- g->data.browser.old_height = height;
+ g->old_width = width;
+ g->old_height = height;
- if (content && (unsigned int)width <
- content->width * 2 * g->scale)
- width = content->width * 2 * g->scale;
+ if (content && width < content->width * 2 * g->option.scale)
+ width = content->width * 2 * g->option.scale;
else {
os_box extent = { 0, -height, width, toolbar_height };
- wimp_set_extent(g->window, &extent);
+ error = xwimp_set_extent(g->window, &extent);
+ if (error) {
+ LOG(("xwimp_set_extent: 0x%x: %s",
+ error->errnum, error->errmess));
+ warn_user("WimpError", error->errmess);
+ return;
+ }
}
}
- wimp_open_window(open);
+ error = xwimp_open_window(open);
+ if (error) {
+ LOG(("xwimp_open_window: 0x%x: %s",
+ error->errnum, error->errmess));
+ warn_user("WimpError", error->errmess);
+ return;
+ }
/* update extent to actual size if toggled */
if (toggle_hack) {
width = open->visible.x1 - open->visible.x0;
height = open->visible.y1 - open->visible.y0 - toolbar_height;
- if (content && (unsigned int)height <
- content->height * 2 * g->scale)
- height = content->height * 2 * g->scale;
+ if (content && height < content->height * 2 * g->option.scale)
+ height = content->height * 2 * g->option.scale;
{
os_box extent = { 0, -height, width, toolbar_height };
- wimp_set_extent(g->window, &extent);
+ error = xwimp_set_extent(g->window, &extent);
+ if (error) {
+ LOG(("xwimp_set_extent: 0x%x: %s",
+ error->errnum, error->errmess));
+ warn_user("WimpError", error->errmess);
+ return;
+ }
}
- g->data.browser.old_width = width;
- g->data.browser.old_height = height;
+ g->old_width = width;
+ g->old_height = height;
}
- ro_theme_resize_toolbar(g->data.browser.toolbar, g->window);
+ if (g->toolbar)
+ ro_theme_resize_toolbar(g->toolbar, g->window);
}
-void ro_gui_throb(void) {
- gui_window* g;
+/**
+ * Animate the "throbbers" of all browser windows.
+ */
- /* Abort on no throbs
- */
- if (theme_throbs == 0) return;
+void ro_gui_throb(void)
+{
+ os_t t;
+ struct gui_window *g;
- /* Animate
- */
- float nowtime = (float) (clock() / (CLOCKS_PER_SEC/(15*23/theme_throbs)));
- for (g = window_list; g != NULL; g = g->next) {
- if ((g->type == GUI_BROWSER_WINDOW) && (g->data.browser.bw->throbbing)) {
- if (nowtime > g->throbtime + 0.2) {
- g->throbtime = nowtime;
- g->throbber++;
- if (g->throbber > theme_throbs) g->throbber = 0;
- sprintf(g->throb_buf, "throbber%i", g->throbber);
- ro_gui_redraw_icon(g->data.browser.toolbar->toolbar_handle, ICON_TOOLBAR_THROBBER);
- }
- }
- }
-}
+ if (theme_throbs == 0)
+ return;
+
+ xos_read_monotonic_time(&t);
-gui_window *ro_lookup_gui_from_w(wimp_w window) {
- gui_window* g;
- for (g = window_list; g != NULL; g = g->next) {
- if ((g->type == GUI_BROWSER_WINDOW) && (g->window == window)) return g;
+ for (g = window_list; g; g = g->next) {
+ if (!g->bw->throbbing || !g->toolbar)
+ continue;
+ if (t < g->throbtime + 10)
+ continue;
+
+ g->throbtime = t;
+ g->throbber++;
+ if (theme_throbs < g->throbber)
+ g->throbber = 0;
+ sprintf(g->throb_buf, "throbber%i", g->throbber);
+ ro_gui_redraw_icon(g->toolbar->toolbar_handle,
+ ICON_TOOLBAR_THROBBER);
}
- return NULL;
}
-gui_window *ro_lookup_gui_toolbar_from_w(wimp_w window) {
- gui_window* g;
- for (g = window_list; g != NULL; g = g->next) {
- if ((g->type == GUI_BROWSER_WINDOW) && (g->data.browser.toolbar) &&
- (g->data.browser.toolbar->toolbar_handle == window)) return g;
- }
- return NULL;
+
+/**
+ * Convert a RISC OS window handle to a gui_window.
+ *
+ * \param w RISC OS window handle
+ * \return pointer to a structure if found, 0 otherwise
+ */
+
+struct gui_window *ro_gui_window_lookup(wimp_w window)
+{
+ struct gui_window *g;
+ for (g = window_list; g; g = g->next)
+ if (g->window == window)
+ return g;
+ return 0;
}
-gui_window *ro_lookup_gui_status_from_w(wimp_w window) {
- gui_window* g;
- for (g = window_list; g != NULL; g = g->next) {
- if ((g->type == GUI_BROWSER_WINDOW) && (g->data.browser.toolbar) &&
- (g->data.browser.toolbar->status_handle == window)) return g;
- }
- return NULL;
+
+/**
+ * Convert a toolbar RISC OS window handle to a gui_window.
+ *
+ * \param w RISC OS window handle of a toolbar
+ * \return pointer to a structure if found, 0 otherwise
+ */
+
+struct gui_window *ro_gui_toolbar_lookup(wimp_w window)
+{
+ struct gui_window *g;
+ for (g = window_list; g; g = g->next)
+ if (g->toolbar && g->toolbar->toolbar_handle == window)
+ return g;
+ return 0;
}
/**
- * Convert a wimp window handle to the owning gui_window structure.
+ * Convert a status bar RISC OS window handle to a gui_window.
+ *
+ * \param w RISC OS window handle of a status bar
+ * \return pointer to a structure if found, 0 otherwise
*/
-gui_window *ro_gui_window_lookup(wimp_w w) {
- gui_window *g;
- for (g = window_list; g; g = g->next) {
- if (g->window == w) {
+
+struct gui_window *ro_gui_status_lookup(wimp_w window)
+{
+ struct gui_window *g;
+ for (g = window_list; g; g = g->next)
+ if (g->toolbar && g->toolbar->status_handle == window)
return g;
- } else if (g->type == GUI_BROWSER_WINDOW) {
- if ((g->data.browser.toolbar) &&
- ((g->data.browser.toolbar->toolbar_handle == w) ||
- (g->data.browser.toolbar->status_handle == w))) return g;
- }
- }
- return NULL;
+ return 0;
}
-void ro_gui_window_mouse_at(wimp_pointer* pointer)
+/**
+ * Handle pointer movements in a browser window.
+ *
+ * \param g browser window that the pointer is in
+ * \param pointer new mouse position
+ */
+
+void ro_gui_window_mouse_at(struct gui_window *g, wimp_pointer *pointer)
{
- int x, y;
- wimp_window_state state;
- gui_window* g;
-
- if (pointer->w == history_window) {
- ro_gui_history_mouse_at(pointer);
- return;
- }
-
- g = ro_lookup_gui_from_w(pointer->w);
-
- if (g == NULL)
- return;
-
- state.w = pointer->w;
- wimp_get_window_state(&state);
-
- x = window_x_units(pointer->pos.x, &state) / 2 / g->scale;
- y = -window_y_units(pointer->pos.y, &state) / 2 / g->scale;
-
- if (g->drag_status == drag_BROWSER_TEXT_SELECTION)
- {
- struct browser_action msg;
- msg.type = act_ALTER_SELECTION;
- msg.data.mouse.x = x;
- msg.data.mouse.y = y;
- browser_window_action(g->data.browser.bw, &msg);
- }
-
- if (g->type == GUI_BROWSER_WINDOW)
- {
- if (g->data.browser.bw->current_content != NULL)
+ int x, y;
+ wimp_window_state state;
+ os_error *error;
+
+ assert(g);
+
+ state.w = pointer->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;
+ }
+
+ x = window_x_units(pointer->pos.x, &state) / 2 / g->option.scale;
+ y = -window_y_units(pointer->pos.y, &state) / 2 / g->option.scale;
+
+ if (g->bw->current_content != NULL)
{
struct browser_action msg;
msg.type = act_MOUSE_AT;
msg.data.mouse.x = x;
msg.data.mouse.y = y;
- browser_window_action(g->data.browser.bw, &msg);
+ browser_window_action(g->bw, &msg);
}
- }
}
@@ -698,36 +923,39 @@ void ro_gui_window_mouse_at(wimp_pointer* pointer)
* Process Mouse_Click events in a toolbar.
*/
-void ro_gui_toolbar_click(gui_window* g, wimp_pointer* pointer) {
+void ro_gui_toolbar_click(struct gui_window *g, wimp_pointer *pointer)
+{
+ os_error *error;
/* Reject Menu clicks
*/
- if (pointer->buttons == wimp_CLICK_MENU) return;
+ if (pointer->buttons == wimp_CLICK_MENU)
+ return;
/* Handle the buttons appropriately
*/
switch (pointer->i) {
case ICON_TOOLBAR_BACK:
- history_back(g->data.browser.bw, g->data.browser.bw->history);
+ history_back(g->bw, g->bw->history);
break;
case ICON_TOOLBAR_FORWARD:
- history_forward(g->data.browser.bw, g->data.browser.bw->history);
+ history_forward(g->bw, g->bw->history);
break;
case ICON_TOOLBAR_STOP:
- browser_window_stop(g->data.browser.bw);
+ browser_window_stop(g->bw);
break;
case ICON_TOOLBAR_RELOAD:
if (pointer->buttons == wimp_CLICK_SELECT)
- browser_window_reload(g->data.browser.bw, false);
+ browser_window_reload(g->bw, false);
else if (pointer->buttons == wimp_CLICK_ADJUST)
- browser_window_reload(g->data.browser.bw, true);
+ browser_window_reload(g->bw, true);
break;
case ICON_TOOLBAR_HISTORY:
- ro_gui_history_open(g->data.browser.bw,
- g->data.browser.bw->history,
+ ro_gui_history_open(g->bw,
+ g->bw->history,
pointer->pos.x, pointer->pos.y);
break;
@@ -735,12 +963,21 @@ void ro_gui_toolbar_click(gui_window* g, wimp_pointer* pointer) {
current_gui = g;
ro_gui_menu_prepare_scale();
/** \todo make scale window persistent */
- xwimp_create_menu((wimp_menu *) dialog_zoom,
+ error = xwimp_create_menu((wimp_menu *) dialog_zoom,
pointer->pos.x, pointer->pos.y);
+ if (error) {
+ LOG(("xwimp_create_menu: 0x%x: %s",
+ error->errnum, error->errmess));
+ warn_user("WimpError", error->errmess);
+ return;
+ }
break;
+
case ICON_TOOLBAR_BOOKMARK:
if (pointer->buttons == wimp_CLICK_ADJUST) {
- ro_gui_hotlist_add(g->title, g->data.browser.bw->current_content);
+ if (g->bw->current_content)
+ ro_gui_hotlist_add(g->title,
+ g->bw->current_content);
} else {
ro_gui_hotlist_show();
}
@@ -748,43 +985,61 @@ void ro_gui_toolbar_click(gui_window* g, wimp_pointer* pointer) {
case ICON_TOOLBAR_SAVE:
current_gui = g;
- ro_gui_save_open(GUI_SAVE_SOURCE,
- g->data.browser.bw->current_content,
- false, 0, 0, g->window, false);
+ if (g->bw->current_content)
+ ro_gui_save_open(GUI_SAVE_SOURCE,
+ g->bw->current_content,
+ false, 0, 0, g->window, false);
break;
}
}
-void ro_gui_status_click(gui_window* g, wimp_pointer* pointer) {
+/**
+ * Handle Mouse_Click events in the status bar.
+ *
+ * \param g browser window that owns the status bar
+ * \param pointer details of mouse click
+ */
+
+void ro_gui_status_click(struct gui_window *g, wimp_pointer *pointer)
+{
wimp_drag drag;
os_error *error;
switch (pointer->i) {
case ICON_STATUS_RESIZE:
gui_current_drag_type = GUI_DRAG_STATUS_RESIZE;
- drag.w = g->data.browser.toolbar->status_handle;
- drag.type = wimp_DRAG_SYSTEM_SIZE;
- drag.initial.x0 = pointer->pos.x;
- drag.initial.x1 = pointer->pos.x;
- drag.initial.y0 = pointer->pos.y;
- drag.initial.y1 = pointer->pos.y;
- error = xwimp_drag_box(&drag);
+ drag.w = g->toolbar->status_handle;
+ drag.type = wimp_DRAG_SYSTEM_SIZE;
+ drag.initial.x0 = pointer->pos.x;
+ drag.initial.x1 = pointer->pos.x;
+ drag.initial.y0 = pointer->pos.y;
+ drag.initial.y1 = pointer->pos.y;
+ error = xwimp_drag_box(&drag);
+ if (error) {
+ LOG(("xwimp_drag_box: 0x%x: %s",
+ error->errnum, error->errmess));
+ warn_user("WimpError", error->errmess);
+ }
break;
}
}
-void ro_gui_window_click(gui_window* g, wimp_pointer* pointer) {
+/**
+ * Handle Mouse_Click events in a browser window.
+ *
+ * \param g browser window
+ * \param pointer details of mouse click
+ */
+
+void ro_gui_window_click(struct gui_window *g, wimp_pointer *pointer)
+{
struct browser_action msg;
- int x,y;
+ int x, y;
wimp_window_state state;
- wimp_caret caret;
os_error *error;
- assert(g != NULL);
- assert(pointer != NULL);
-
- if (g->type != GUI_BROWSER_WINDOW) return;
+ assert(g);
state.w = pointer->w;
error = xwimp_get_window_state(&state);
@@ -795,26 +1050,17 @@ void ro_gui_window_click(gui_window* g, wimp_pointer* pointer) {
return;
}
- x = window_x_units(pointer->pos.x, &state) / 2 / g->scale;
- y = -window_y_units(pointer->pos.y, &state) / 2 / g->scale;
+ x = window_x_units(pointer->pos.x, &state) / 2 / g->option.scale;
+ y = -window_y_units(pointer->pos.y, &state) / 2 / g->option.scale;
/* set input focus */
- 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;
- }
-
- if (((pointer->buttons == wimp_CLICK_SELECT) ||
- (pointer->buttons == wimp_CLICK_ADJUST)) &&
- (caret.w != state.w)) {
- error = xwimp_set_caret_position(state.w, -1, -100,
- -100, 32, -1);
+ if (pointer->buttons == wimp_CLICK_SELECT ||
+ pointer->buttons == wimp_CLICK_ADJUST) {
+ error = xwimp_set_caret_position(state.w, -1,
+ -100, -100, 32, -1);
if (error) {
LOG(("xwimp_set_caret_position: 0x%x: %s",
- error->errnum, error->errmess));
+ error->errnum, error->errmess));
warn_user("WimpError", error->errmess);
return;
}
@@ -823,82 +1069,85 @@ void ro_gui_window_click(gui_window* g, wimp_pointer* pointer) {
if (pointer->buttons == wimp_CLICK_MENU) {
ro_gui_create_menu(browser_menu, pointer->pos.x - 64,
pointer->pos.y, g);
+ return;
}
- else {
- if (g->data.browser.bw != NULL &&
- g->data.browser.bw->current_content != NULL &&
- g->data.browser.bw->current_content->type == CONTENT_HTML) {
- if (pointer->buttons == wimp_CLICK_SELECT) {
- msg.type = act_MOUSE_CLICK;
- msg.data.mouse.x = x;
- msg.data.mouse.y = y;
- if (browser_window_action(
- g->data.browser.bw, &msg) == 1)
- return;
- msg.type = act_UNKNOWN;
- }
- if (pointer->buttons == wimp_CLICK_SELECT && g->data.browser.bw->current_content->data.html.text_selection.selected == 1)
- msg.type = act_CLEAR_SELECTION;
-
- else if (pointer->buttons == wimp_CLICK_ADJUST && g->data.browser.bw->current_content->data.html.text_selection.selected == 1)
- msg.type = act_ALTER_SELECTION;
-
- else if (pointer->buttons == wimp_DRAG_SELECT ||
- pointer->buttons == wimp_DRAG_ADJUST) {
- msg.type = act_START_NEW_SELECTION;
- if (pointer->buttons == wimp_DRAG_ADJUST && g->data.browser.bw->current_content->data.html.text_selection.selected == 1)
- msg.type = act_ALTER_SELECTION;
-
- ro_gui_start_selection(pointer, &state, g);
- g->drag_status = drag_BROWSER_TEXT_SELECTION;
- }
- msg.data.mouse.x = x;
- msg.data.mouse.y = y;
- if (msg.type != act_UNKNOWN)
- browser_window_action(g->data.browser.bw, &msg);
-
- if (pointer->buttons == wimp_CLICK_ADJUST &&
- g->data.browser.bw->current_content->data.html.text_selection.selected == 1 &&
- current_gui != NULL &&
- current_gui->data.browser.bw != NULL &&
- current_gui->data.browser.bw->current_content != NULL) {
- current_gui->data.browser.bw->current_content->data.html.text_selection.altering = alter_UNKNOWN;
- }
+ if (pointer->buttons == wimp_CLICK_SELECT) {
+ msg.type = act_MOUSE_CLICK;
+ msg.data.mouse.x = x;
+ msg.data.mouse.y = y;
+ if (browser_window_action(
+ g->bw, &msg) == 1)
+ return;
+ msg.type = act_UNKNOWN;
+ }
- if (pointer->buttons == wimp_CLICK_SELECT
- || pointer->buttons == wimp_CLICK_ADJUST) {
+ if (pointer->buttons == wimp_CLICK_SELECT
+ || pointer->buttons == wimp_CLICK_ADJUST) {
- if (pointer->buttons == wimp_CLICK_SELECT)
- msg.type = act_FOLLOW_LINK;
- else
- msg.type = act_FOLLOW_LINK_NEW_WINDOW;
- msg.data.mouse.x = x;
- msg.data.mouse.y = y;
- browser_window_action(g->data.browser.bw, &msg);
- }
- }
+ if (pointer->buttons == wimp_CLICK_SELECT)
+ msg.type = act_FOLLOW_LINK;
+ else
+ msg.type = act_FOLLOW_LINK_NEW_WINDOW;
+ msg.data.mouse.x = x;
+ msg.data.mouse.y = y;
+ browser_window_action(g->bw, &msg);
}
}
-void gui_window_start_throbber(struct gui_window* g) {
+/**
+ * Update the interface to reflect start of page loading.
+ *
+ * \param g window with start of load
+ */
+
+void gui_window_start_throbber(struct gui_window *g)
+{
ro_gui_prepare_navigate(g);
- if (theme_throbs == 0) return;
- g->throbtime = (float) (clock() + 0) / CLOCKS_PER_SEC; /* workaround compiler warning */
+ if (theme_throbs == 0)
+ return;
+ xos_read_monotonic_time(&g->throbtime);
g->throbber = 0;
}
-void gui_window_stop_throbber(gui_window* g) {
+
+
+/**
+ * Update the interface to reflect page loading stopped.
+ *
+ * \param g window with start of load
+ */
+
+void gui_window_stop_throbber(struct gui_window *g)
+{
ro_gui_prepare_navigate(g);
g->throbber = 0;
- sprintf(g->throb_buf, "throbber%u", g->throbber);
- ro_gui_redraw_icon(g->data.browser.toolbar->toolbar_handle, ICON_TOOLBAR_THROBBER);
+ strcpy(g->throb_buf, "throbber0");
+ ro_gui_redraw_icon(g->toolbar->toolbar_handle, ICON_TOOLBAR_THROBBER);
}
-void gui_window_place_caret(gui_window *g, int x, int y, int height) {
- wimp_set_caret_position(g->window, -1,
+
+/**
+ * Place the caret in a browser window.
+ *
+ * \param g window with caret
+ * \param x coordinates of caret
+ * \param y coordinates of caret
+ * \param height height of caret
+ */
+
+void gui_window_place_caret(struct gui_window *g, int x, int y, int height)
+{
+ os_error *error;
+
+ error = xwimp_set_caret_position(g->window, -1,
x * 2, -(y + height) * 2, height * 2, -1);
+ if (error) {
+ LOG(("xwimp_set_caret_position: 0x%x: %s",
+ error->errnum, error->errmess));
+ warn_user("WimpError", error->errmess);
+ }
}
@@ -906,9 +1155,9 @@ void gui_window_place_caret(gui_window *g, int x, int y, int height) {
* Process Key_Pressed events in a browser window.
*/
-bool ro_gui_window_keypress(gui_window *g, int key, bool toolbar)
+bool ro_gui_window_keypress(struct gui_window *g, int key, bool toolbar)
{
- struct content *content = g->data.browser.bw->current_content;
+ struct content *content = g->bw->current_content;
wimp_window_state state;
int y;
char *url;
@@ -923,8 +1172,6 @@ bool ro_gui_window_keypress(gui_window *g, int key, bool toolbar)
return false;
}
- assert(g->type == GUI_BROWSER_WINDOW);
-
/* First send the key to the browser window, eg. form fields. */
if (!toolbar) {
int c = key;
@@ -941,7 +1188,7 @@ bool ro_gui_window_keypress(gui_window *g, int key, bool toolbar)
else if (c == 398) c = 31; /* Down */
else if (c == 399) c = 30; /* Up */
if (c < 256)
- if (browser_window_key_press(g->data.browser.bw,
+ if (browser_window_key_press(g->bw,
(char) c))
return true;
}
@@ -983,16 +1230,16 @@ bool ro_gui_window_keypress(gui_window *g, int key, bool toolbar)
return true;
case wimp_KEY_F2:
- if (!g->data.browser.toolbar)
+ if (!g->toolbar)
return false;
- ro_gui_set_icon_string(g->data.browser.toolbar->toolbar_handle,
+ ro_gui_set_icon_string(g->toolbar->toolbar_handle,
ICON_TOOLBAR_URL, "www.");
- xwimp_set_caret_position(g->data.browser.toolbar->toolbar_handle,
+ xwimp_set_caret_position(g->toolbar->toolbar_handle,
ICON_TOOLBAR_URL, 0, 0, -1, 4);
return true;
case wimp_KEY_CONTROL + wimp_KEY_F2: /* Close window. */
- browser_window_destroy(g->data.browser.bw);
+ browser_window_destroy(g->bw);
return true;
case wimp_KEY_F3:
@@ -1025,40 +1272,40 @@ bool ro_gui_window_keypress(gui_window *g, int key, bool toolbar)
url = url_normalize(g->url);
if (url) {
gui_window_set_url(g, url);
- browser_window_go(g->data.browser.bw, url);
+ browser_window_go(g->bw, url);
free(url);
}
return true;
case wimp_KEY_ESCAPE:
- browser_window_stop(g->data.browser.bw);
+ browser_window_stop(g->bw);
return true;
case 14: /* CTRL+N */
current_gui = g;
- browser_window_create(g->url, g->data.browser.bw);
+ browser_window_create(g->url, g->bw);
return true;
case 18: /* CTRL+R */
- browser_window_reload(g->data.browser.bw, false);
+ browser_window_reload(g->bw, false);
return true;
case 17: /* CTRL+Q (Zoom out) */
current_gui = g;
- if (0.1 < current_gui->scale) {
- current_gui->scale -= 0.1;
- if (current_gui->scale < 0.1)
- current_gui->scale = 0.1;
- current_gui->data.browser.reformat_pending = true;
+ if (0.1 < current_gui->option.scale) {
+ current_gui->option.scale -= 0.1;
+ if (current_gui->option.scale < 0.1)
+ current_gui->option.scale = 0.1;
+ current_gui->reformat_pending = true;
gui_reformat_pending = true;
}
return true;
case 23: /* CTRL+W (Zoom in) */
current_gui = g;
- if (current_gui->scale < 10.0) {
- current_gui->scale += 0.1;
- if (10.0 < current_gui->scale)
- current_gui->scale = 10.0;
- current_gui->data.browser.reformat_pending = true;
+ if (current_gui->option.scale < 10.0) {
+ current_gui->option.scale += 0.1;
+ if (10.0 < current_gui->option.scale)
+ current_gui->option.scale = 10.0;
+ current_gui->reformat_pending = true;
gui_reformat_pending = true;
}
return true;
@@ -1078,7 +1325,7 @@ bool ro_gui_window_keypress(gui_window *g, int key, bool toolbar)
state.w = g->window;
wimp_get_window_state(&state);
y = state.visible.y1 - state.visible.y0 - 32;
- y -= g->data.browser.toolbar->height;
+ y -= g->toolbar->height;
switch (key) {
case wimp_KEY_UP:
@@ -1112,14 +1359,14 @@ bool ro_gui_window_keypress(gui_window *g, int key, bool toolbar)
void ro_gui_scroll_request(wimp_scroll *scroll)
{
int x, y;
- gui_window *g = ro_gui_window_lookup(scroll->w);
+ struct gui_window *g = ro_gui_window_lookup(scroll->w);
- if (!g || g->type != GUI_BROWSER_WINDOW)
+ if (!g)
return;
x = scroll->visible.x1 - scroll->visible.x0 - 32;
y = scroll->visible.y1 - scroll->visible.y0 - 32;
- y -= g->data.browser.toolbar->height;
+ y -= g->toolbar->height;
switch (scroll->xmin) {
case wimp_SCROLL_PAGE_LEFT:
@@ -1195,9 +1442,9 @@ int window_y_units(int y, wimp_window_state *state) {
* If the file was dragged into a form file input, it is used as the value.
*/
-bool ro_gui_window_dataload(gui_window *g, wimp_message *message)
+bool ro_gui_window_dataload(struct gui_window *g, wimp_message *message)
{
- struct browser_window *bw = g->data.browser.bw;
+ struct browser_window *bw = g->bw;
struct box_selection *click_boxes = 0;
int x, y;
int i;
@@ -1256,63 +1503,75 @@ bool ro_gui_window_dataload(gui_window *g, wimp_message *message)
/**
+ * Process pending reformats
+ */
+
+void ro_gui_window_process_reformats(void)
+{
+ struct gui_window *g;
+
+ for (g = window_list; g; g = g->next) {
+ if (!g->reformat_pending)
+ continue;
+ content_reformat(g->bw->current_content,
+ g->old_width / 2 / g->option.scale,
+ 1000);
+ g->reformat_pending = false;
+ }
+ gui_reformat_pending = false;
+}
+
+
+/**
* Clones a browser window's options.
*
* \param new_bw the new browser window
* \param old_bw the browser window to clone from, or NULL for default
*/
-void gui_window_clone_options(struct browser_window *new_bw,
+void ro_gui_window_clone_options(struct browser_window *new_bw,
struct browser_window *old_bw) {
- gui_window *old_gui = NULL;
- gui_window *new_gui;
+ struct gui_window *old_gui = NULL;
+ struct gui_window *new_gui;
- /* Abort on bad input
- */
- if (new_bw == NULL) return;
+ assert(new_bw);
/* Get our GUIs
*/
new_gui = new_bw->window;
- /* Abort on bad input
- */
- if (!new_gui) return;
- if (old_bw) old_gui = old_bw->window;
+ if (old_bw)
+ old_gui = old_bw->window;
/* Clone the basic options
*/
if (!old_gui) {
- new_gui->scale = ((float)option_scale) / 100;
- new_gui->option_dither_sprites = option_dither_sprites;
- new_gui->option_filter_sprites = option_filter_sprites;
- new_gui->option_animate_images = option_animate_images;
- new_gui->option_background_images = option_background_images;
+ new_gui->option.scale = ((float)option_scale) / 100;
+ new_gui->option.dither_sprites = option_dither_sprites;
+ new_gui->option.filter_sprites = option_filter_sprites;
+ new_gui->option.animate_images = option_animate_images;
+ new_gui->option.background_images = option_background_images;
} else {
- new_gui->scale = old_gui->scale;
- new_gui->option_dither_sprites = old_gui->option_dither_sprites;
- new_gui->option_filter_sprites = old_gui->option_filter_sprites;
- new_gui->option_animate_images = old_gui->option_animate_images;
- new_gui->option_background_images = old_gui->option_background_images;
+ new_gui->option = old_gui->option;
}
/* Set up the toolbar
*/
- if (new_gui->data.browser.toolbar) {
- if ((old_gui) && (old_gui->data.browser.toolbar)) {
- new_gui->data.browser.toolbar->status_width = old_gui->data.browser.toolbar->status_width;
- new_gui->data.browser.toolbar->status_window = old_gui->data.browser.toolbar->status_window;
- new_gui->data.browser.toolbar->standard_buttons = old_gui->data.browser.toolbar->standard_buttons;
- new_gui->data.browser.toolbar->url_bar = old_gui->data.browser.toolbar->url_bar;
- new_gui->data.browser.toolbar->throbber = old_gui->data.browser.toolbar->throbber;
+ if (new_gui->toolbar) {
+ if ((old_gui) && (old_gui->toolbar)) {
+ new_gui->toolbar->status_width = old_gui->toolbar->status_width;
+ new_gui->toolbar->status_window = old_gui->toolbar->status_window;
+ new_gui->toolbar->standard_buttons = old_gui->toolbar->standard_buttons;
+ new_gui->toolbar->url_bar = old_gui->toolbar->url_bar;
+ new_gui->toolbar->throbber = old_gui->toolbar->throbber;
} else {
- new_gui->data.browser.toolbar->status_width = option_toolbar_status_width;
- new_gui->data.browser.toolbar->status_window = option_toolbar_show_status;
- new_gui->data.browser.toolbar->standard_buttons = option_toolbar_show_buttons;
- new_gui->data.browser.toolbar->url_bar = option_toolbar_show_address;
- new_gui->data.browser.toolbar->throbber = option_toolbar_show_throbber;
+ new_gui->toolbar->status_width = option_toolbar_status_width;
+ new_gui->toolbar->status_window = option_toolbar_show_status;
+ new_gui->toolbar->standard_buttons = option_toolbar_show_buttons;
+ new_gui->toolbar->url_bar = option_toolbar_show_address;
+ new_gui->toolbar->throbber = option_toolbar_show_throbber;
}
- ro_theme_update_toolbar(new_gui->data.browser.toolbar, new_gui->window);
+ ro_theme_update_toolbar(new_gui->toolbar, new_gui->window);
}
}
@@ -1323,12 +1582,10 @@ void gui_window_clone_options(struct browser_window *new_bw,
* \param bw the browser window to read options from
*/
-void gui_window_default_options(struct browser_window *bw) {
- gui_window *gui;
+void ro_gui_window_default_options(struct browser_window *bw) {
+ struct gui_window *gui;
- /* Abort on bad input
- */
- if (bw == NULL) return;
+ assert(bw);
/* Get our GUI
*/
@@ -1337,19 +1594,19 @@ void gui_window_default_options(struct browser_window *bw) {
/* Save the basic options
*/
- option_scale = gui->scale * 100;
- option_dither_sprites = gui->option_dither_sprites;
- option_filter_sprites = gui->option_filter_sprites;
- option_animate_images = gui->option_animate_images;
+ option_scale = gui->option.scale * 100;
+ option_dither_sprites = gui->option.dither_sprites;
+ option_filter_sprites = gui->option.filter_sprites;
+ option_animate_images = gui->option.animate_images;
/* Set up the toolbar
*/
- if (gui->data.browser.toolbar) {
- option_toolbar_status_width = gui->data.browser.toolbar->status_width;
- option_toolbar_show_status = gui->data.browser.toolbar->status_window;
- option_toolbar_show_buttons = gui->data.browser.toolbar->standard_buttons;
- option_toolbar_show_address = gui->data.browser.toolbar->url_bar;
- option_toolbar_show_throbber = gui->data.browser.toolbar->throbber;
+ if (gui->toolbar) {
+ option_toolbar_status_width = gui->toolbar->status_width;
+ option_toolbar_show_status = gui->toolbar->status_window;
+ option_toolbar_show_buttons = gui->toolbar->standard_buttons;
+ option_toolbar_show_address = gui->toolbar->url_bar;
+ option_toolbar_show_throbber = gui->toolbar->throbber;
}
}
@@ -1419,3 +1676,15 @@ void gui_window_set_pointer(gui_pointer_shape shape)
curr_pointer = shape;
}
+
+
+/**
+ * Called when the gui_window has new content.
+ *
+ * \param g the gui_window that has new content
+ */
+
+void gui_window_new_content(struct gui_window *g)
+{
+ ro_gui_dialog_close_persistant(g->window);
+}