[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
This commit is contained in:
James Bursa 2004-07-17 13:00:38 +00:00
parent b6782d6095
commit e4a6e982e5
18 changed files with 1280 additions and 996 deletions

View File

@ -17,11 +17,11 @@
#include <time.h>
#include "netsurf/utils/config.h"
#include "netsurf/content/content.h"
#include "netsurf/desktop/gui.h"
struct box;
struct history;
struct form_successful_control;
struct gui_window;
struct history;
/** Browser window data. */
struct browser_window
@ -41,8 +41,8 @@ struct browser_window
/** User parameter for caret_callback. */
void *caret_p;
/** Platform specific window handle. */
gui_window *window;
/** Platform specific window data. */
struct gui_window *window;
/** Busy indicator is active. */
bool throbbing;

View File

@ -15,7 +15,7 @@
struct gui_window;
struct gui_download_window;
typedef struct gui_window gui_window;
typedef enum { GUI_POINTER_DEFAULT, GUI_POINTER_POINT, GUI_POINTER_CARET,
GUI_POINTER_MENU, GUI_POINTER_UD, GUI_POINTER_LR,
GUI_POINTER_LD, GUI_POINTER_RD, GUI_POINTER_CROSS,
@ -25,20 +25,20 @@ typedef enum { GUI_POINTER_DEFAULT, GUI_POINTER_POINT, GUI_POINTER_CARET,
#include "netsurf/content/content.h"
#include "netsurf/desktop/browser.h"
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);
void gui_window_destroy(gui_window* g);
void gui_window_redraw(gui_window* g, unsigned long x0, unsigned long y0,
unsigned long x1, unsigned long y1);
void gui_window_redraw_window(gui_window* g);
void gui_window_update_box(gui_window *g, const union content_msg_data *data);
void gui_window_set_scroll(gui_window* g, unsigned long sx, unsigned long sy);
unsigned long gui_window_get_width(gui_window* g);
void gui_window_set_extent(gui_window* g, unsigned long width, unsigned long height);
void gui_window_set_status(gui_window* g, const char* text);
void gui_window_destroy(struct gui_window *g);
void gui_window_set_title(struct gui_window *g, const char *title);
void gui_window_redraw(struct gui_window *g, int x0, int y0, int x1, int y1);
void gui_window_redraw_window(struct gui_window *g);
void gui_window_update_box(struct gui_window *g,
const union content_msg_data *data);
void gui_window_set_scroll(struct gui_window *g, int sx, int sy);
int gui_window_get_width(struct gui_window *g);
void gui_window_set_extent(struct gui_window *g, int width, int height);
void gui_window_set_status(struct gui_window *g, const char *text);
void gui_window_set_pointer(gui_pointer_shape shape);
void gui_window_set_title(gui_window* g, char* title);
void gui_window_set_url(gui_window *g, char *url);
void gui_window_set_url(struct gui_window *g, const char *url);
struct gui_download_window *gui_download_window_create(const char *url,
const char *mime_type, struct fetch *fetch,
@ -50,21 +50,19 @@ void gui_download_window_error(struct gui_download_window *dw,
void gui_download_window_done(struct gui_download_window *dw);
void gui_init(int argc, char** argv);
void gui_window_clone_options(struct browser_window *new_bw, struct browser_window *old_bw);
void gui_window_default_options(struct browser_window *bw);
void gui_multitask(void);
void gui_poll(bool active);
void gui_quit(void);
void gui_window_start_throbber(gui_window* g);
void gui_window_stop_throbber(gui_window* g);
void gui_window_start_throbber(struct gui_window *g);
void gui_window_stop_throbber(struct gui_window *g);
void gui_gadget_combo(struct browser_window* bw, struct form_control* g, unsigned long mx, unsigned long my);
void gui_window_place_caret(gui_window *g, int x, int y, int height);
void gui_window_place_caret(struct gui_window *g, int x, int y, int height);
void gui_launch_url(const char *url);
void gui_window_new_content(gui_window *g);
void gui_window_new_content(struct gui_window *g);
#endif

View File

@ -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++) {

View File

@ -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;

View File

@ -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
@ -682,13 +711,47 @@ 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)
ro_gui_window_click(g, pointer);
else if (g && g->type == GUI_BROWSER_WINDOW &&
g->data.browser.toolbar->toolbar_handle == pointer->w)
ro_gui_toolbar_click(g, pointer);
else if (hotlist_toolbar && hotlist_toolbar->toolbar_handle == pointer->w)
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 && g->type == GUI_BROWSER_WINDOW &&
g->data.browser.toolbar->status_handle == pointer->w)
else if ((g = ro_gui_window_lookup(pointer->w)))
ro_gui_window_click(g, pointer);
else if ((g = ro_gui_toolbar_lookup(pointer->w)))
ro_gui_toolbar_click(g, pointer);
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) {
struct gui_window *g;
os_error *error;
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);
if (!g) {
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 (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 (g && ro_gui_window_dataload(g, message))
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;
}
if (temp[0] != '#') lineno = 1;
while (temp && lineno<=2) {
temp = strtok('\0', "\t");
if (!temp) break;
if (temp[0] == '#') continue; /* ignore commented lines */
lineno++;
}
if (!temp) {
xfree(buf);
return;
}
url = xstrdup(temp);
xfree(buf);
}
/* url file */
if (message->data.data_xfer.file_type == 0xb28) {
char *temp;
FILE *fp = fopen(message->data.data_xfer.file_name, "r");
if (!fp) return;
url = xcalloc(256, sizeof(char));
temp = fgets(url, 256, fp);
fclose(fp);
if (!temp) return;
if (url[strlen(url)-1] == '\n') {
url[strlen(url)-1] = '\0';
}
}
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;
/* 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);
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 (!url)
/* error has already been reported by one of the three
* functions called above */
return;
if (gui) {
gui_window_set_url(gui, url);
browser_window_go(gui->data.browser.bw, url);
}
else {
browser_window_create(url, NULL);
}
if (g)
browser_window_go(g->bw, url);
else
browser_window_create(url, 0);
free(url);
}
#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;
/**
* Parse an Acorn URI file.
*
* \param file_name file to read
* \return URL from file, or 0 on error and error reported
*/
data = &block->data.data_xfer;
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;
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! */
/* TODO */
}
}
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;
}
xfree(click_boxes);
#endif
/* "URI" */
if (!ro_gui_uri_file_parse_line(fp, line) || strcmp(line, "URI") != 0)
goto uri_syntax_error;
/* version */
if (!ro_gui_uri_file_parse_line(fp, line) ||
strspn(line, "0123456789") != strlen(line))
goto uri_syntax_error;
/* URI */
if (!ro_gui_uri_file_parse_line(fp, line))
goto uri_syntax_error;
fclose(fp);
url = strdup(line);
if (!url) {
warn_user("NoMemory", 0);
return 0;
}
return url;
uri_syntax_error:
fclose(fp);
warn_user("URIError", 0);
return 0;
}
/**
* 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
*/
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;
}
/* 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 (c != EOF)
ungetc(c, fp);
b[i] = 0;
return true;
}
/**
* Parse an ANT URL file.
*
* \param file_name file to read
* \return URL from file, or 0 on error and error reported
*/
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;
}
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;
}
fclose(fp);
if (line[strlen(line) - 1] == '\n')
line[strlen(line) - 1] = '\0';
url = strdup(line);
if (!url) {
warn_user("NoMemory", 0);
return 0;
}
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];
/**

View File

@ -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;
/** Associated platform-independent browser window data. */
struct browser_window *bw;
wimp_w window;
struct toolbar *toolbar; /**< Toolbar, or 0 if not present. */
union {
struct {
struct toolbar *toolbar;
int toolbar_width;
struct browser_window* bw;
bool reformat_pending;
int old_width;
int old_height;
} browser;
} data;
wimp_w window; /**< RISC OS window handle. */
char status[256];
char title[256];
char url[256];
gui_window *next;
/** 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. */
int throbber;
char throb_buf[12];
float throbtime;
char status[256]; /**< Buffer for status bar. */
char title[256]; /**< Buffer for window title. */
char url[256]; /**< Buffer for url entry field. */
enum { drag_NONE, drag_UNKNOWN, drag_BROWSER_TEXT_SELECTION }
drag_status;
int throbber; /**< Current frame of throbber animation. */
char throb_buf[12]; /**< Buffer for throbber sprite name. */
int throbtime; /**< Time of last throbber frame. */
/* 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;
/** 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);

View File

@ -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

View File

@ -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) {

View File

@ -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;

View File

@ -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);

View File

@ -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);
}
}

View File

@ -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);

View File

@ -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;

View File

@ -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);

View File

@ -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)
// {
// }
}

View File

@ -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);

View File

@ -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);

File diff suppressed because it is too large Load Diff