2003-06-30 16:44:03 +04:00
|
|
|
/*
|
|
|
|
* This file is part of NetSurf, http://netsurf.sourceforge.net/
|
|
|
|
* Licensed under the GNU General Public License,
|
|
|
|
* http://www.opensource.org/licenses/gpl-license
|
|
|
|
* Copyright 2003 Phil Mellor <monkeyson@users.sourceforge.net>
|
|
|
|
* Copyright 2003 James Bursa <bursa@users.sourceforge.net>
|
|
|
|
* Copyright 2003 John M Bell <jmb202@ecs.soton.ac.uk>
|
2002-09-11 18:24:02 +04:00
|
|
|
*/
|
|
|
|
|
2003-07-15 18:37:34 +04:00
|
|
|
#include <assert.h>
|
|
|
|
#include <math.h>
|
|
|
|
#include <stdbool.h>
|
2003-08-27 02:37:32 +04:00
|
|
|
#include <stddef.h>
|
2003-07-15 18:37:34 +04:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <time.h>
|
2003-01-11 20:33:31 +03:00
|
|
|
#include "oslib/os.h"
|
2003-07-15 18:37:34 +04:00
|
|
|
#include "oslib/osfile.h"
|
|
|
|
#include "oslib/osgbpb.h"
|
2003-08-25 02:39:55 +04:00
|
|
|
#include "oslib/plugin.h"
|
2002-09-11 18:24:02 +04:00
|
|
|
#include "oslib/wimp.h"
|
2003-03-08 23:26:31 +03:00
|
|
|
#include "oslib/wimpspriteop.h"
|
2003-07-30 17:06:22 +04:00
|
|
|
#include "oslib/uri.h"
|
2003-07-15 18:37:34 +04:00
|
|
|
#include "netsurf/desktop/gui.h"
|
|
|
|
#include "netsurf/desktop/netsurf.h"
|
|
|
|
#include "netsurf/desktop/options.h"
|
2003-07-18 03:01:02 +04:00
|
|
|
#include "netsurf/render/font.h"
|
2003-10-25 04:35:49 +04:00
|
|
|
#include "netsurf/render/form.h"
|
2003-07-15 18:37:34 +04:00
|
|
|
#include "netsurf/render/html.h"
|
2003-09-17 00:02:55 +04:00
|
|
|
#include "netsurf/riscos/about.h"
|
2003-07-30 17:06:22 +04:00
|
|
|
#include "netsurf/riscos/gui.h"
|
2003-08-25 02:39:55 +04:00
|
|
|
#include "netsurf/riscos/plugin.h"
|
2002-10-15 14:41:12 +04:00
|
|
|
#include "netsurf/riscos/theme.h"
|
2003-07-30 17:06:22 +04:00
|
|
|
#include "netsurf/riscos/uri.h"
|
2003-01-11 20:33:31 +03:00
|
|
|
#include "netsurf/utils/log.h"
|
2003-10-01 04:26:42 +04:00
|
|
|
#include "netsurf/utils/messages.h"
|
2003-07-15 18:37:34 +04:00
|
|
|
#include "netsurf/utils/utils.h"
|
2002-09-11 18:24:02 +04:00
|
|
|
|
2003-04-12 01:06:51 +04:00
|
|
|
const char *__dynamic_da_name = "NetSurf";
|
2003-10-01 04:26:42 +04:00
|
|
|
//static char empty_text[] = "";
|
|
|
|
//static char password_v[] = "D*";
|
2003-04-12 01:06:51 +04:00
|
|
|
|
2003-06-25 03:22:00 +04:00
|
|
|
char *NETSURF_DIR;
|
2003-08-28 23:21:27 +04:00
|
|
|
gui_window *window_list = 0;
|
2003-06-25 03:22:00 +04:00
|
|
|
|
2003-03-15 18:53:20 +03:00
|
|
|
const char* HOME_URL = "file:///%3CNetSurf$Dir%3E/Resources/intro";
|
2003-09-26 20:52:53 +04:00
|
|
|
const char* HELP_URL = "file:///%3CNetSurf$Dir%3E/Docs/en/index";
|
2002-10-15 14:41:12 +04:00
|
|
|
|
2003-07-18 03:01:02 +04:00
|
|
|
void ro_gui_window_click(gui_window* g, wimp_pointer* mouse);
|
|
|
|
//void ro_gui_window_mouse_at(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_keypress(gui_window* g, wimp_key* key);
|
|
|
|
|
2003-03-04 14:59:36 +03:00
|
|
|
static void ro_gui_toolbar_redraw(gui_window* g, wimp_draw* redraw);
|
|
|
|
static void gui_disable_icon(wimp_w w, wimp_i i);
|
|
|
|
static void gui_enable_icon(wimp_w w, wimp_i i);
|
|
|
|
static void ro_gui_icon_bar_click(wimp_pointer* pointer);
|
|
|
|
static void ro_gui_throb(void);
|
|
|
|
static gui_window* ro_lookup_gui_from_w(wimp_w window);
|
|
|
|
static gui_window* ro_lookup_gui_toolbar_from_w(wimp_w window);
|
|
|
|
static void ro_gui_window_mouse_at(wimp_pointer* pointer);
|
|
|
|
static void ro_gui_toolbar_click(gui_window* g, wimp_pointer* pointer);
|
|
|
|
static void ro_gui_poll_queue(wimp_event_no event, wimp_block* block);
|
|
|
|
static void ro_gui_keypress(wimp_key* key);
|
|
|
|
static void ro_msg_datasave(wimp_message* block);
|
|
|
|
static void ro_msg_dataload(wimp_message* block);
|
2003-10-06 03:30:21 +04:00
|
|
|
static void ro_msg_datasave_ack(wimp_message* message);
|
2003-09-11 01:44:11 +04:00
|
|
|
static void ro_gui_screen_size(int *width, int *height);
|
2003-10-06 03:30:21 +04:00
|
|
|
int ro_save_data(void *data, unsigned long length, char *file_name, bits file_type);
|
2002-12-27 20:27:24 +03:00
|
|
|
|
2002-10-15 14:41:12 +04:00
|
|
|
|
|
|
|
|
2002-12-31 01:56:30 +03:00
|
|
|
wimp_menu* combo_menu;
|
2003-10-25 04:35:49 +04:00
|
|
|
struct form_control* current_gadget;
|
2002-12-31 01:56:30 +03:00
|
|
|
|
2002-10-15 14:41:12 +04:00
|
|
|
|
|
|
|
int TOOLBAR_HEIGHT = 128;
|
|
|
|
|
|
|
|
ro_theme* current_theme = NULL;
|
2002-09-11 18:24:02 +04:00
|
|
|
|
2003-03-04 01:40:39 +03:00
|
|
|
const char* BROWSER_VALIDATION = "\0";
|
2002-09-11 18:24:02 +04:00
|
|
|
|
|
|
|
const char* task_name = "NetSurf";
|
2003-10-06 03:30:21 +04:00
|
|
|
const wimp_MESSAGE_LIST(23) task_messages = {
|
2003-08-25 02:39:55 +04:00
|
|
|
{message_DATA_SAVE,
|
2003-10-06 03:30:21 +04:00
|
|
|
message_DATA_SAVE_ACK,
|
2003-08-25 02:39:55 +04:00
|
|
|
message_DATA_LOAD,
|
|
|
|
message_URI_PROCESS,
|
|
|
|
message_PLUG_IN_OPENING,
|
|
|
|
message_PLUG_IN_CLOSED,
|
|
|
|
message_PLUG_IN_RESHAPE_REQUEST,
|
|
|
|
message_PLUG_IN_FOCUS,
|
|
|
|
message_PLUG_IN_URL_ACCESS,
|
|
|
|
message_PLUG_IN_STATUS,
|
|
|
|
message_PLUG_IN_BUSY,
|
|
|
|
message_PLUG_IN_STREAM_NEW,
|
|
|
|
message_PLUG_IN_STREAM_WRITE,
|
|
|
|
message_PLUG_IN_STREAM_WRITTEN,
|
|
|
|
message_PLUG_IN_STREAM_DESTROY,
|
|
|
|
message_PLUG_IN_OPEN,
|
|
|
|
message_PLUG_IN_CLOSE,
|
|
|
|
message_PLUG_IN_RESHAPE,
|
|
|
|
message_PLUG_IN_STREAM_AS_FILE,
|
|
|
|
message_PLUG_IN_NOTIFY,
|
|
|
|
message_PLUG_IN_ABORT,
|
|
|
|
message_PLUG_IN_ACTION,
|
|
|
|
/* message_PLUG_IN_INFORMED, (not provided by oslib) */
|
|
|
|
0} };
|
2002-09-11 18:24:02 +04:00
|
|
|
wimp_t task_handle;
|
|
|
|
|
|
|
|
wimp_i ro_gui_iconbar_i;
|
|
|
|
|
|
|
|
gui_window* over_window = NULL;
|
|
|
|
|
2003-03-08 23:26:31 +03:00
|
|
|
int ro_x_units(unsigned long browser_units)
|
2002-09-11 18:24:02 +04:00
|
|
|
{
|
|
|
|
return (browser_units << 1);
|
|
|
|
}
|
|
|
|
|
2003-03-08 23:26:31 +03:00
|
|
|
int ro_y_units(unsigned long browser_units)
|
2002-09-11 18:24:02 +04:00
|
|
|
{
|
|
|
|
return -(browser_units << 1);
|
|
|
|
}
|
|
|
|
|
2003-03-08 23:26:31 +03:00
|
|
|
unsigned long browser_x_units(int ro_units)
|
2002-09-11 18:24:02 +04:00
|
|
|
{
|
|
|
|
return (ro_units >> 1);
|
|
|
|
}
|
|
|
|
|
2003-03-08 23:26:31 +03:00
|
|
|
unsigned long browser_y_units(int ro_units)
|
2002-09-11 18:24:02 +04:00
|
|
|
{
|
|
|
|
return -(ro_units >> 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
int window_x_units(int scr_units, wimp_window_state* win)
|
|
|
|
{
|
|
|
|
return scr_units - (win->visible.x0 - win->xscroll);
|
|
|
|
}
|
|
|
|
|
|
|
|
int window_y_units(int scr_units, wimp_window_state* win)
|
|
|
|
{
|
|
|
|
return scr_units - (win->visible.y1 - win->yscroll);
|
|
|
|
}
|
|
|
|
|
2002-12-30 01:27:35 +03:00
|
|
|
|
2003-08-28 23:21:27 +04:00
|
|
|
gui_window *gui_create_browser_window(struct browser_window *bw)
|
2002-09-11 18:24:02 +04:00
|
|
|
{
|
|
|
|
struct wimp_window window;
|
|
|
|
|
|
|
|
gui_window* g = (gui_window*) xcalloc(1, sizeof(gui_window));
|
|
|
|
g->type = GUI_BROWSER_WINDOW;
|
|
|
|
g->data.browser.bw = bw;
|
|
|
|
/* create browser and toolbar windows here */
|
|
|
|
|
|
|
|
window.visible.x0 = 0;
|
|
|
|
window.visible.y0 = 0;
|
|
|
|
window.visible.x1 = ro_x_units(bw->format_width);
|
|
|
|
window.visible.y1 = 2000;
|
|
|
|
window.xscroll = 0;
|
|
|
|
window.yscroll = 0;
|
|
|
|
window.next = wimp_TOP;
|
|
|
|
window.flags =
|
|
|
|
wimp_WINDOW_MOVEABLE | wimp_WINDOW_NEW_FORMAT | wimp_WINDOW_BACK_ICON |
|
|
|
|
wimp_WINDOW_CLOSE_ICON | wimp_WINDOW_TITLE_ICON | wimp_WINDOW_VSCROLL |
|
2003-04-15 21:53:00 +04:00
|
|
|
wimp_WINDOW_HSCROLL | wimp_WINDOW_SIZE_ICON | wimp_WINDOW_TOGGLE_ICON |
|
|
|
|
wimp_WINDOW_IGNORE_XEXTENT;
|
2002-09-11 18:24:02 +04:00
|
|
|
window.title_fg = wimp_COLOUR_BLACK;
|
|
|
|
window.title_bg = wimp_COLOUR_LIGHT_GREY;
|
|
|
|
window.work_fg = wimp_COLOUR_LIGHT_GREY;
|
|
|
|
window.work_bg = wimp_COLOUR_WHITE;
|
|
|
|
window.scroll_outer = wimp_COLOUR_DARK_GREY;
|
|
|
|
window.scroll_inner = wimp_COLOUR_MID_LIGHT_GREY;
|
|
|
|
window.highlight_bg = wimp_COLOUR_CREAM;
|
|
|
|
window.extra_flags = 0;
|
|
|
|
window.extent.x0 = 0;
|
|
|
|
window.extent.y0 = ro_y_units(bw->format_height);
|
2002-10-15 14:41:12 +04:00
|
|
|
window.extent.x1 = 8192;//ro_x_units(bw->format_width);
|
2002-09-11 18:24:02 +04:00
|
|
|
if ((bw->flags & browser_TOOLBAR) != 0)
|
|
|
|
{
|
2002-10-15 14:41:12 +04:00
|
|
|
window.extent.y1 = ro_theme_toolbar_height(current_theme);
|
2002-09-11 18:24:02 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
window.extent.y1 = 0;
|
|
|
|
}
|
|
|
|
window.title_flags = wimp_ICON_TEXT | wimp_ICON_INDIRECTED | wimp_ICON_HCENTRED;
|
|
|
|
window.work_flags = wimp_BUTTON_CLICK_DRAG << wimp_ICON_BUTTON_TYPE_SHIFT;
|
2003-03-08 23:26:31 +03:00
|
|
|
window.sprite_area = wimpspriteop_AREA;
|
2002-12-27 20:27:24 +03:00
|
|
|
window.xmin = 100;
|
|
|
|
window.ymin = window.extent.y1 + 100;
|
2002-09-11 18:24:02 +04:00
|
|
|
window.title_data.indirected_text.text = g->title;
|
|
|
|
window.title_data.indirected_text.validation = BROWSER_VALIDATION;
|
|
|
|
window.title_data.indirected_text.size = 255;
|
|
|
|
window.icon_count = 0;
|
|
|
|
g->data.browser.window = wimp_create_window(&window);
|
|
|
|
|
|
|
|
strcpy(g->title, "NetSurf");
|
|
|
|
|
2003-07-18 03:01:02 +04:00
|
|
|
g->data.browser.toolbar = 0;
|
2002-09-11 18:24:02 +04:00
|
|
|
if ((bw->flags & browser_TOOLBAR) != 0)
|
|
|
|
{
|
2002-10-15 14:41:12 +04:00
|
|
|
ro_theme_window create_toolbar;
|
|
|
|
|
|
|
|
create_toolbar.type = THEME_TOOLBAR;
|
|
|
|
create_toolbar.data.toolbar.indirected_url = g->url;
|
|
|
|
create_toolbar.data.toolbar.indirected_status = g->status;
|
|
|
|
g->data.browser.toolbar = ro_theme_create_window(current_theme, &create_toolbar);
|
|
|
|
g->data.browser.toolbar_width = -1;
|
2002-09-11 18:24:02 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
g->redraw_safety = SAFE;
|
2003-09-11 01:44:11 +04:00
|
|
|
g->data.browser.reformat_pending = false;
|
|
|
|
g->data.browser.old_width = 0;
|
2002-09-11 18:24:02 +04:00
|
|
|
|
2003-07-18 03:01:02 +04:00
|
|
|
g->next = window_list;
|
|
|
|
window_list = g;
|
2002-09-11 18:24:02 +04:00
|
|
|
return g;
|
|
|
|
}
|
|
|
|
|
2003-01-11 20:33:31 +03:00
|
|
|
void gui_window_set_title(gui_window* g, char* title)
|
|
|
|
{
|
|
|
|
if (title != NULL)
|
|
|
|
strncpy(g->title, title, 255);
|
|
|
|
else
|
|
|
|
strcpy(g->title, "NetSurf (untitled document)");
|
|
|
|
wimp_force_redraw_title(g->data.browser.window);
|
|
|
|
}
|
|
|
|
|
2002-09-11 18:24:02 +04:00
|
|
|
void gui_window_destroy(gui_window* g)
|
|
|
|
{
|
2003-07-18 03:01:02 +04:00
|
|
|
assert(g != 0);
|
2002-09-11 18:24:02 +04:00
|
|
|
|
2003-07-18 03:01:02 +04:00
|
|
|
if (g == window_list)
|
|
|
|
window_list = g->next;
|
2002-09-11 18:24:02 +04:00
|
|
|
else
|
|
|
|
{
|
|
|
|
gui_window* gg;
|
2003-07-18 03:01:02 +04:00
|
|
|
assert(window_list != NULL);
|
|
|
|
gg = window_list;
|
2002-09-11 18:24:02 +04:00
|
|
|
while (gg->next != g && gg->next != NULL)
|
|
|
|
gg = gg->next;
|
2003-07-18 03:01:02 +04:00
|
|
|
assert(gg->next != NULL);
|
|
|
|
gg->next = g->next;
|
2002-09-11 18:24:02 +04:00
|
|
|
}
|
2003-07-18 03:01:02 +04:00
|
|
|
|
|
|
|
xwimp_delete_window(g->data.browser.window);
|
|
|
|
if (g->data.browser.toolbar)
|
|
|
|
xwimp_delete_window(g->data.browser.toolbar);
|
|
|
|
|
2002-09-11 18:24:02 +04:00
|
|
|
xfree(g);
|
|
|
|
}
|
|
|
|
|
|
|
|
void gui_window_show(gui_window* g)
|
|
|
|
{
|
|
|
|
wimp_window_state state;
|
|
|
|
if (g == NULL)
|
|
|
|
return;
|
|
|
|
state.w = g->data.browser.window;
|
|
|
|
wimp_get_window_state(&state);
|
|
|
|
state.next = wimp_TOP;
|
|
|
|
ro_gui_window_open(g, (wimp_open*)&state);
|
|
|
|
}
|
|
|
|
|
2003-03-04 01:40:39 +03:00
|
|
|
void gui_window_redraw(gui_window* g, unsigned long x0, unsigned long y0,
|
|
|
|
unsigned long x1, unsigned long y1)
|
2002-09-11 18:24:02 +04:00
|
|
|
{
|
|
|
|
if (g == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
wimp_force_redraw(g->data.browser.window,
|
2003-03-08 23:26:31 +03:00
|
|
|
ro_x_units(x0), ro_y_units(y1), ro_x_units(x1), ro_y_units(y0));
|
2002-09-11 18:24:02 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void gui_window_redraw_window(gui_window* g)
|
|
|
|
{
|
|
|
|
wimp_window_info info;
|
|
|
|
if (g == NULL)
|
|
|
|
return;
|
|
|
|
info.w = g->data.browser.window;
|
|
|
|
wimp_get_window_info_header_only(&info);
|
|
|
|
wimp_force_redraw(g->data.browser.window, info.extent.x0, info.extent.y0, info.extent.x1, info.extent.y1);
|
|
|
|
}
|
|
|
|
|
|
|
|
gui_safety gui_window_set_redraw_safety(gui_window* g, gui_safety s)
|
|
|
|
{
|
|
|
|
gui_safety old;
|
|
|
|
|
|
|
|
if (g == NULL)
|
|
|
|
return SAFE;
|
|
|
|
|
|
|
|
old = g->redraw_safety;
|
|
|
|
g->redraw_safety = s;
|
|
|
|
|
|
|
|
return old;
|
|
|
|
}
|
|
|
|
|
2003-07-15 18:37:34 +04:00
|
|
|
|
2002-09-11 18:24:02 +04:00
|
|
|
|
|
|
|
|
2002-10-15 14:41:12 +04:00
|
|
|
void ro_gui_toolbar_redraw(gui_window* g, wimp_draw* redraw)
|
|
|
|
{
|
|
|
|
osbool more;
|
|
|
|
wimp_icon_state throbber;
|
|
|
|
|
|
|
|
throbber.w = g->data.browser.toolbar;
|
|
|
|
throbber.i = ro_theme_icon(current_theme, THEME_TOOLBAR, "TOOLBAR_THROBBER");
|
|
|
|
wimp_get_icon_state(&throbber);
|
|
|
|
|
|
|
|
throbber.icon.flags = wimp_ICON_SPRITE;
|
2003-09-17 16:57:43 +04:00
|
|
|
snprintf(throbber.icon.data.sprite, 12, "throbber%d", g->throbber);
|
2002-10-15 14:41:12 +04:00
|
|
|
|
|
|
|
more = wimp_redraw_window(redraw);
|
|
|
|
while (more)
|
|
|
|
{
|
|
|
|
wimp_plot_icon(&throbber.icon);
|
|
|
|
more = wimp_get_rectangle(redraw);
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2002-09-11 18:24:02 +04:00
|
|
|
void ro_gui_window_redraw(gui_window* g, wimp_draw* redraw)
|
|
|
|
{
|
|
|
|
osbool more;
|
2003-02-26 00:00:27 +03:00
|
|
|
struct content *c = g->data.browser.bw->current_content;
|
2002-09-11 18:24:02 +04:00
|
|
|
|
2003-02-26 00:00:27 +03:00
|
|
|
if (g->redraw_safety == SAFE && g->type == GUI_BROWSER_WINDOW && c != NULL)
|
2002-09-11 18:24:02 +04:00
|
|
|
{
|
2003-02-26 00:00:27 +03:00
|
|
|
more = wimp_redraw_window(redraw);
|
|
|
|
wimp_set_font_colours(wimp_COLOUR_WHITE, wimp_COLOUR_BLACK);
|
2002-09-11 18:24:02 +04:00
|
|
|
|
2003-02-26 00:00:27 +03:00
|
|
|
while (more)
|
|
|
|
{
|
2003-07-15 18:37:34 +04:00
|
|
|
content_redraw(c,
|
|
|
|
(int) redraw->box.x0 - (int) redraw->xscroll,
|
|
|
|
(int) redraw->box.y1 - (int) redraw->yscroll,
|
2003-09-10 21:10:25 +04:00
|
|
|
c->width * 2, c->height * 2,
|
|
|
|
redraw->clip.x0, redraw->clip.y0,
|
|
|
|
redraw->clip.x1 - 1, redraw->clip.y1 - 1);
|
2003-02-26 00:00:27 +03:00
|
|
|
more = wimp_get_rectangle(redraw);
|
2002-09-11 18:24:02 +04:00
|
|
|
}
|
|
|
|
}
|
2003-02-26 00:00:27 +03:00
|
|
|
else
|
|
|
|
{
|
|
|
|
more = wimp_redraw_window(redraw);
|
|
|
|
while (more)
|
|
|
|
more = wimp_get_rectangle(redraw);
|
|
|
|
}
|
2002-09-11 18:24:02 +04:00
|
|
|
}
|
|
|
|
|
2003-03-04 14:59:36 +03:00
|
|
|
void gui_window_set_scroll(gui_window* g, unsigned long sx, unsigned long sy)
|
2002-09-11 18:24:02 +04:00
|
|
|
{
|
|
|
|
wimp_window_state state;
|
|
|
|
if (g == NULL)
|
|
|
|
return;
|
|
|
|
state.w = g->data.browser.window;
|
|
|
|
wimp_get_window_state(&state);
|
|
|
|
state.xscroll = ro_x_units(sx);
|
|
|
|
state.yscroll = ro_y_units(sy);
|
|
|
|
if ((g->data.browser.bw->flags & browser_TOOLBAR) != 0)
|
2002-10-15 14:41:12 +04:00
|
|
|
state.yscroll += ro_theme_toolbar_height(current_theme);
|
2002-09-11 18:24:02 +04:00
|
|
|
ro_gui_window_open(g, (wimp_open*)&state);
|
|
|
|
}
|
|
|
|
|
2003-03-04 01:40:39 +03:00
|
|
|
unsigned long gui_window_get_width(gui_window* g)
|
2002-10-15 14:41:12 +04:00
|
|
|
{
|
|
|
|
wimp_window_state state;
|
|
|
|
state.w = g->data.browser.window;
|
|
|
|
wimp_get_window_state(&state);
|
2003-03-08 23:26:31 +03:00
|
|
|
return browser_x_units(state.visible.x1 - state.visible.x0);
|
2002-10-15 14:41:12 +04:00
|
|
|
}
|
|
|
|
|
2003-03-04 01:40:39 +03:00
|
|
|
void gui_window_set_extent(gui_window* g, unsigned long width, unsigned long height)
|
2002-09-11 18:24:02 +04:00
|
|
|
{
|
|
|
|
os_box extent;
|
|
|
|
|
|
|
|
if (g == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
extent.x0 = 0;
|
|
|
|
extent.y0 = ro_y_units(height);
|
|
|
|
if (extent.y0 > -960)
|
|
|
|
extent.y0 = -960;
|
2003-04-15 21:53:00 +04:00
|
|
|
extent.x1 = ro_x_units(width);
|
2002-09-11 18:24:02 +04:00
|
|
|
if ((g->data.browser.bw->flags & browser_TOOLBAR) != 0)
|
|
|
|
{
|
2002-10-15 14:41:12 +04:00
|
|
|
extent.y1 = ro_theme_toolbar_height(current_theme);
|
2002-09-11 18:24:02 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
extent.y1 = 0;
|
|
|
|
}
|
|
|
|
wimp_set_extent(g->data.browser.window, &extent);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2003-03-04 01:40:39 +03:00
|
|
|
void gui_window_set_status(gui_window* g, const char* text)
|
2002-09-11 18:24:02 +04:00
|
|
|
{
|
|
|
|
if (strcmp(g->status, text) != 0)
|
|
|
|
{
|
|
|
|
strncpy(g->status, text, 255);
|
2002-10-15 14:41:12 +04:00
|
|
|
wimp_set_icon_state(g->data.browser.toolbar, ro_theme_icon(current_theme, THEME_TOOLBAR, "TOOLBAR_STATUS"), 0, 0);
|
2002-09-11 18:24:02 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-10-15 14:41:12 +04:00
|
|
|
void gui_disable_icon(wimp_w w, wimp_i i)
|
|
|
|
{
|
|
|
|
wimp_set_icon_state(w, i, wimp_ICON_SHADED, wimp_ICON_SHADED);
|
|
|
|
}
|
|
|
|
|
|
|
|
void gui_enable_icon(wimp_w w, wimp_i i)
|
|
|
|
{
|
|
|
|
wimp_set_icon_state(w, i, 0, wimp_ICON_SHADED);
|
|
|
|
}
|
|
|
|
|
2002-09-11 18:24:02 +04:00
|
|
|
void gui_window_message(gui_window* g, gui_message* msg)
|
|
|
|
{
|
|
|
|
if (g == NULL || msg == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
switch (msg->type)
|
|
|
|
{
|
|
|
|
case msg_SET_URL:
|
2003-08-25 02:39:55 +04:00
|
|
|
fprintf(stderr, "Set URL '%s'\n", msg->data.set_url.url);
|
2002-09-11 18:24:02 +04:00
|
|
|
strncpy(g->url, msg->data.set_url.url, 255);
|
2002-10-15 14:41:12 +04:00
|
|
|
wimp_set_icon_state(g->data.browser.toolbar, ro_theme_icon(current_theme, THEME_TOOLBAR, "TOOLBAR_URL"), 0, 0);
|
|
|
|
if (g->data.browser.bw->history != NULL)
|
|
|
|
{
|
|
|
|
if (g->data.browser.bw->history->earlier != NULL)
|
|
|
|
gui_enable_icon(g->data.browser.toolbar, ro_theme_icon(current_theme, THEME_TOOLBAR, "TOOLBAR_BACK"));
|
|
|
|
else
|
|
|
|
gui_disable_icon(g->data.browser.toolbar, ro_theme_icon(current_theme, THEME_TOOLBAR, "TOOLBAR_BACK"));
|
|
|
|
if (g->data.browser.bw->history->later != NULL)
|
|
|
|
gui_enable_icon(g->data.browser.toolbar, ro_theme_icon(current_theme, THEME_TOOLBAR, "TOOLBAR_FORWARD"));
|
|
|
|
else
|
|
|
|
gui_disable_icon(g->data.browser.toolbar, ro_theme_icon(current_theme, THEME_TOOLBAR, "TOOLBAR_FORWARD"));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gui_disable_icon(g->data.browser.toolbar, ro_theme_icon(current_theme, THEME_TOOLBAR, "TOOLBAR_BACK"));
|
|
|
|
gui_disable_icon(g->data.browser.toolbar, ro_theme_icon(current_theme, THEME_TOOLBAR, "TOOLBAR_FORWARD"));
|
|
|
|
}
|
2002-09-11 18:24:02 +04:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ro_gui_window_open(gui_window* g, wimp_open* open)
|
|
|
|
{
|
|
|
|
if (g->type == GUI_BROWSER_WINDOW)
|
|
|
|
{
|
2003-09-11 01:44:11 +04:00
|
|
|
wimp_window_state state;
|
|
|
|
state.w = g->data.browser.window;
|
|
|
|
wimp_get_window_state(&state);
|
|
|
|
if (state.flags & wimp_WINDOW_TOGGLED) {
|
|
|
|
open->visible.x0 = open->visible.y0 = 0;
|
|
|
|
ro_gui_screen_size(&open->visible.x1, &open->visible.y1);
|
|
|
|
}
|
|
|
|
|
2003-04-15 21:53:00 +04:00
|
|
|
if (g->data.browser.bw->current_content != 0) {
|
2003-09-11 01:44:11 +04:00
|
|
|
int width = open->visible.x1 - open->visible.x0;
|
|
|
|
if (g->data.browser.old_width != width) {
|
|
|
|
if (g->data.browser.bw->current_content->width
|
|
|
|
< browser_x_units(width))
|
|
|
|
gui_window_set_extent(g, browser_x_units(width),
|
2003-04-15 22:07:25 +04:00
|
|
|
g->data.browser.bw->current_content->height);
|
|
|
|
else
|
|
|
|
gui_window_set_extent(g, g->data.browser.bw->current_content->width,
|
|
|
|
g->data.browser.bw->current_content->height);
|
2003-09-11 01:44:11 +04:00
|
|
|
g->data.browser.old_width = width;
|
|
|
|
g->data.browser.reformat_pending = true;
|
2003-04-15 22:07:25 +04:00
|
|
|
}
|
2003-04-15 21:53:00 +04:00
|
|
|
}
|
|
|
|
wimp_open_window(open);
|
|
|
|
|
2002-09-11 18:24:02 +04:00
|
|
|
if ((g->data.browser.bw->flags & browser_TOOLBAR) != 0)
|
|
|
|
{
|
|
|
|
wimp_outline outline;
|
|
|
|
wimp_window_state tstate;
|
|
|
|
|
|
|
|
outline.w = g->data.browser.window;
|
|
|
|
wimp_get_window_outline(&outline);
|
|
|
|
|
2002-10-15 14:41:12 +04:00
|
|
|
|
2002-09-11 18:24:02 +04:00
|
|
|
tstate.w = g->data.browser.toolbar;
|
|
|
|
tstate.visible.x0 = open->visible.x0;
|
|
|
|
tstate.visible.x1 = outline.outline.x1 - 2;
|
|
|
|
tstate.visible.y1 = open->visible.y1;
|
2002-10-15 14:41:12 +04:00
|
|
|
tstate.visible.y0 = tstate.visible.y1 - ro_theme_toolbar_height(current_theme);
|
2002-09-11 18:24:02 +04:00
|
|
|
tstate.xscroll = 0;
|
|
|
|
tstate.yscroll = 0;
|
|
|
|
tstate.next = wimp_TOP;
|
|
|
|
|
|
|
|
wimp_open_window_nested((wimp_open *) &tstate, g->data.browser.window,
|
|
|
|
wimp_CHILD_LINKS_PARENT_VISIBLE_BOTTOM_OR_LEFT
|
|
|
|
<< wimp_CHILD_LS_EDGE_SHIFT |
|
|
|
|
wimp_CHILD_LINKS_PARENT_VISIBLE_BOTTOM_OR_LEFT
|
|
|
|
<< wimp_CHILD_BS_EDGE_SHIFT |
|
|
|
|
wimp_CHILD_LINKS_PARENT_VISIBLE_BOTTOM_OR_LEFT
|
|
|
|
<< wimp_CHILD_RS_EDGE_SHIFT |
|
|
|
|
wimp_CHILD_LINKS_PARENT_VISIBLE_TOP_OR_RIGHT
|
|
|
|
<< wimp_CHILD_TS_EDGE_SHIFT);
|
2002-10-15 14:41:12 +04:00
|
|
|
|
|
|
|
if (tstate.visible.x1 - tstate.visible.x0 != g->data.browser.toolbar_width)
|
|
|
|
{
|
|
|
|
g->data.browser.toolbar_width = tstate.visible.x1 - tstate.visible.x0;
|
|
|
|
ro_theme_resize(current_theme, THEME_TOOLBAR, g->data.browser.toolbar, g->data.browser.toolbar_width, tstate.visible.y1 - tstate.visible.y0);
|
|
|
|
}
|
|
|
|
|
2002-09-11 18:24:02 +04:00
|
|
|
}
|
2003-04-15 21:53:00 +04:00
|
|
|
} else {
|
|
|
|
wimp_open_window(open);
|
2002-09-11 18:24:02 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ro_gui_icon_bar_click(wimp_pointer* pointer)
|
|
|
|
{
|
2002-10-15 14:41:12 +04:00
|
|
|
if (pointer->buttons == wimp_CLICK_MENU)
|
|
|
|
{
|
2003-08-22 01:39:07 +04:00
|
|
|
ro_gui_create_menu(iconbar_menu, pointer->pos.x - 64, 96 + iconbar_menu_height, NULL);
|
2002-10-15 14:41:12 +04:00
|
|
|
}
|
|
|
|
else if (pointer->buttons == wimp_CLICK_SELECT)
|
2002-09-11 18:24:02 +04:00
|
|
|
{
|
|
|
|
struct browser_window* bw;
|
|
|
|
bw = create_browser_window(browser_TITLE | browser_TOOLBAR
|
2003-04-15 21:53:00 +04:00
|
|
|
| browser_SCROLL_X_ALWAYS | browser_SCROLL_Y_ALWAYS, 640, 480);
|
2002-09-11 18:24:02 +04:00
|
|
|
gui_window_show(bw->window);
|
2002-10-15 14:41:12 +04:00
|
|
|
browser_window_open_location(bw, HOME_URL);
|
2003-03-04 14:59:36 +03:00
|
|
|
wimp_set_caret_position(bw->window->data.browser.toolbar,
|
|
|
|
ro_theme_icon(current_theme, THEME_TOOLBAR, "TOOLBAR_URL"),
|
|
|
|
0,0,-1, (int) strlen(bw->window->url) - 1);
|
2002-09-11 18:24:02 +04:00
|
|
|
}
|
2002-10-15 14:41:12 +04:00
|
|
|
// else if (pointer->buttons == wimp_CLICK_ADJUST)
|
|
|
|
// netsurf_quit = 1;
|
2002-09-11 18:24:02 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*** bodge to fix filenames in unixlib. there's probably a proper way
|
|
|
|
of doing this, but 'ck knows what it is. ***/
|
|
|
|
extern int __riscosify_control;
|
|
|
|
#define __RISCOSIFY_NO_PROCESS 0x0040
|
|
|
|
|
|
|
|
void gui_init(int argc, char** argv)
|
|
|
|
{
|
|
|
|
wimp_icon_create iconbar;
|
|
|
|
wimp_version_no version;
|
2003-06-02 03:02:56 +04:00
|
|
|
char theme_fname[256];
|
2003-06-08 08:00:05 +04:00
|
|
|
int *varsize;
|
|
|
|
char *var;
|
|
|
|
os_error *e;
|
|
|
|
fileswitch_object_type *ot;
|
2002-09-11 18:24:02 +04:00
|
|
|
|
2003-06-25 03:22:00 +04:00
|
|
|
NETSURF_DIR = getenv("NetSurf$Dir");
|
2003-08-22 01:39:07 +04:00
|
|
|
messages_load("<NetSurf$Dir>.Resources.en.Messages");
|
2003-06-25 03:22:00 +04:00
|
|
|
|
2003-01-06 03:04:43 +03:00
|
|
|
/* __riscosify_control = __RISCOSIFY_NO_PROCESS; */
|
2002-09-11 18:24:02 +04:00
|
|
|
|
|
|
|
task_handle = wimp_initialise(wimp_VERSION_RO38, task_name, (wimp_message_list*) &task_messages, &version);
|
|
|
|
|
2003-08-25 02:39:55 +04:00
|
|
|
/* Issue a *Desktop to poke AcornURI into life */
|
|
|
|
if(strcasecmp(getenv("NetSurf$Start_URI_Handler"), "yes") == 0)
|
|
|
|
xwimp_start_task("Desktop", NULL);
|
|
|
|
xos_cli("UnSet NetSurf$Start_Uri_Handler");
|
|
|
|
|
2002-09-11 18:24:02 +04:00
|
|
|
iconbar.w = wimp_ICON_BAR_RIGHT;
|
|
|
|
iconbar.icon.extent.x0 = 0;
|
|
|
|
iconbar.icon.extent.y0 = 0;
|
|
|
|
iconbar.icon.extent.x1 = 68;
|
|
|
|
iconbar.icon.extent.y1 = 68;
|
|
|
|
iconbar.icon.flags = wimp_ICON_SPRITE | wimp_ICON_HCENTRED
|
|
|
|
| wimp_ICON_VCENTRED | (wimp_BUTTON_CLICK << wimp_ICON_BUTTON_TYPE_SHIFT);
|
|
|
|
strcpy(iconbar.icon.data.sprite, "!netsurf");
|
|
|
|
ro_gui_iconbar_i = wimp_create_icon(&iconbar);
|
2002-10-15 14:41:12 +04:00
|
|
|
|
2003-06-08 08:00:05 +04:00
|
|
|
if (OPTIONS.theme != NULL) {
|
|
|
|
|
|
|
|
/* get size of <netsurf$dir> */
|
|
|
|
e = xos_read_var_val_size ("NetSurf$Dir",0,os_VARTYPE_STRING,
|
|
|
|
&varsize, NULL, NULL);
|
|
|
|
var = xcalloc((~((int)varsize) + 10),sizeof(char));
|
|
|
|
/* get real value of <netsurf$dir> */
|
|
|
|
e = xos_read_var_val ("NetSurf$Dir", var, (~(int)varsize), 0,
|
|
|
|
os_VARTYPE_STRING, NULL, NULL, NULL);
|
2003-10-01 04:26:42 +04:00
|
|
|
|
2003-06-08 08:00:05 +04:00
|
|
|
strcat(var, ".Themes.");
|
|
|
|
/* check if theme directory exists */
|
|
|
|
e = xosfile_read_stamped_path ((const char*)OPTIONS.theme,
|
|
|
|
(const char*)var,
|
|
|
|
&ot, NULL, NULL, NULL, NULL, NULL);
|
|
|
|
xfree(var);
|
|
|
|
/* yes -> use this theme */
|
|
|
|
if (ot != fileswitch_NOT_FOUND && ot == fileswitch_IS_DIR) {
|
|
|
|
sprintf(theme_fname, "<NetSurf$Dir>.Themes.%s", OPTIONS.theme);
|
|
|
|
}
|
|
|
|
/* no -> use default theme */
|
|
|
|
else {
|
|
|
|
OPTIONS.theme = strdup("Default");
|
|
|
|
sprintf(theme_fname, "<NetSurf$Dir>.Themes.Default");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2003-06-02 03:02:56 +04:00
|
|
|
sprintf(theme_fname, "<NetSurf$Dir>.Themes.Default");
|
2003-06-08 08:00:05 +04:00
|
|
|
OPTIONS.theme = strdup("Default");
|
|
|
|
}
|
2003-06-02 03:02:56 +04:00
|
|
|
LOG(("Using theme '%s' - from '%s'",theme_fname, OPTIONS.theme));
|
|
|
|
current_theme = ro_theme_create(theme_fname);
|
2002-10-15 14:41:12 +04:00
|
|
|
|
2003-08-28 23:21:27 +04:00
|
|
|
wimp_open_template("<NetSurf$Dir>.Resources.Templates");
|
2003-08-27 02:37:32 +04:00
|
|
|
ro_gui_dialog_init();
|
2003-08-28 23:21:27 +04:00
|
|
|
ro_gui_download_init();
|
2003-08-22 01:39:07 +04:00
|
|
|
ro_gui_menus_init();
|
2003-10-23 04:09:17 +04:00
|
|
|
ro_gui_401login_init();
|
2003-08-28 23:21:27 +04:00
|
|
|
wimp_close_template();
|
2002-10-15 14:41:12 +04:00
|
|
|
}
|
|
|
|
|
2003-03-04 14:59:36 +03:00
|
|
|
void ro_gui_throb(void)
|
2002-10-15 14:41:12 +04:00
|
|
|
{
|
2003-07-18 03:01:02 +04:00
|
|
|
gui_window* g;
|
2003-03-15 18:53:20 +03:00
|
|
|
float nowtime = (float) clock() / CLOCKS_PER_SEC;
|
2002-10-15 14:41:12 +04:00
|
|
|
|
2003-07-18 03:01:02 +04:00
|
|
|
for (g = window_list; g != NULL; g = g->next)
|
2002-10-15 14:41:12 +04:00
|
|
|
{
|
|
|
|
if (g->type == GUI_BROWSER_WINDOW)
|
|
|
|
{
|
|
|
|
if ((g->data.browser.bw->flags & browser_TOOLBAR) != 0)
|
|
|
|
{
|
|
|
|
if (g->data.browser.bw->throbbing != 0)
|
|
|
|
{
|
|
|
|
if (nowtime > g->throbtime + 0.2)
|
|
|
|
{
|
|
|
|
g->throbtime = nowtime;
|
|
|
|
g->throbber++;
|
|
|
|
if (g->throbber > current_theme->throbs)
|
|
|
|
g->throbber = 0;
|
|
|
|
|
|
|
|
wimp_set_icon_state(g->data.browser.toolbar, ro_theme_icon(current_theme, THEME_TOOLBAR, "TOOLBAR_THROBBER"), 0, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2002-09-11 18:24:02 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
gui_window* ro_lookup_gui_from_w(wimp_w window)
|
|
|
|
{
|
2003-07-18 03:01:02 +04:00
|
|
|
gui_window* g;
|
|
|
|
for (g = window_list; g != NULL; g = g->next)
|
2002-09-11 18:24:02 +04:00
|
|
|
{
|
|
|
|
if (g->type == GUI_BROWSER_WINDOW)
|
|
|
|
{
|
|
|
|
if (g->data.browser.window == window)
|
2002-10-15 14:41:12 +04:00
|
|
|
{
|
2002-09-11 18:24:02 +04:00
|
|
|
return g;
|
2002-10-15 14:41:12 +04:00
|
|
|
}
|
2002-09-11 18:24:02 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
gui_window* ro_lookup_gui_toolbar_from_w(wimp_w window)
|
|
|
|
{
|
2003-07-18 03:01:02 +04:00
|
|
|
gui_window* g;
|
2002-10-15 14:41:12 +04:00
|
|
|
|
2003-07-18 03:01:02 +04:00
|
|
|
for (g = window_list; g != NULL; g = g->next)
|
2002-09-11 18:24:02 +04:00
|
|
|
{
|
|
|
|
if (g->type == GUI_BROWSER_WINDOW)
|
|
|
|
{
|
|
|
|
if (g->data.browser.toolbar == window)
|
2002-10-15 14:41:12 +04:00
|
|
|
{
|
2002-09-11 18:24:02 +04:00
|
|
|
return g;
|
2002-10-15 14:41:12 +04:00
|
|
|
}
|
2002-09-11 18:24:02 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ro_gui_window_mouse_at(wimp_pointer* pointer)
|
|
|
|
{
|
|
|
|
int x,y;
|
|
|
|
wimp_window_state state;
|
|
|
|
gui_window* g;
|
|
|
|
|
|
|
|
g = ro_lookup_gui_from_w(pointer->w);
|
|
|
|
|
|
|
|
if (g == NULL)
|
|
|
|
return;
|
|
|
|
|
2002-10-15 14:41:12 +04:00
|
|
|
if (g->redraw_safety != SAFE)
|
|
|
|
{
|
|
|
|
fprintf(stderr, "mouse at UNSAFE\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2002-09-11 18:24:02 +04:00
|
|
|
state.w = pointer->w;
|
|
|
|
wimp_get_window_state(&state);
|
|
|
|
|
|
|
|
x = browser_x_units(window_x_units(pointer->pos.x, &state));
|
|
|
|
y = browser_y_units(window_y_units(pointer->pos.y, &state));
|
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-10-15 14:41:12 +04:00
|
|
|
void ro_gui_toolbar_click(gui_window* g, wimp_pointer* pointer)
|
|
|
|
{
|
|
|
|
if (pointer->i == ro_theme_icon(current_theme, THEME_TOOLBAR, "TOOLBAR_BACK"))
|
|
|
|
{
|
|
|
|
browser_window_back(g->data.browser.bw);
|
|
|
|
}
|
|
|
|
else if (pointer->i == ro_theme_icon(current_theme, THEME_TOOLBAR, "TOOLBAR_FORWARD"))
|
|
|
|
{
|
|
|
|
browser_window_forward(g->data.browser.bw);
|
|
|
|
}
|
|
|
|
else if (pointer->i == ro_theme_icon(current_theme, THEME_TOOLBAR, "TOOLBAR_RELOAD"))
|
|
|
|
{
|
2003-10-25 18:13:49 +04:00
|
|
|
browser_window_open_location_historical(g->data.browser.bw,
|
|
|
|
g->data.browser.bw->url, 0, 0);
|
2002-10-15 14:41:12 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-08-27 02:37:32 +04:00
|
|
|
|
2002-09-11 18:24:02 +04:00
|
|
|
void ro_gui_window_click(gui_window* g, wimp_pointer* pointer)
|
|
|
|
{
|
|
|
|
struct browser_action msg;
|
|
|
|
int x,y;
|
|
|
|
wimp_window_state state;
|
2002-10-15 14:41:12 +04:00
|
|
|
|
|
|
|
if (g->redraw_safety != SAFE)
|
|
|
|
{
|
|
|
|
fprintf(stderr, "gui_window_click UNSAFE\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2002-09-11 18:24:02 +04:00
|
|
|
state.w = pointer->w;
|
|
|
|
wimp_get_window_state(&state);
|
|
|
|
|
|
|
|
if (g->type == GUI_BROWSER_WINDOW)
|
|
|
|
{
|
|
|
|
x = browser_x_units(window_x_units(pointer->pos.x, &state));
|
|
|
|
y = browser_y_units(window_y_units(pointer->pos.y, &state));
|
|
|
|
|
2002-10-15 14:41:12 +04:00
|
|
|
if (pointer->buttons == wimp_CLICK_MENU)
|
|
|
|
{
|
2003-01-11 20:33:31 +03:00
|
|
|
/* check for mouse gestures */
|
2003-10-01 03:30:36 +04:00
|
|
|
ro_gui_mouse_action(g);
|
2002-10-15 14:41:12 +04:00
|
|
|
}
|
|
|
|
else if (g->data.browser.bw->current_content != NULL)
|
2002-09-11 18:24:02 +04:00
|
|
|
{
|
|
|
|
if (g->data.browser.bw->current_content->type == CONTENT_HTML)
|
|
|
|
{
|
2002-12-31 01:56:30 +03:00
|
|
|
if (pointer->buttons == wimp_CLICK_SELECT)
|
|
|
|
{
|
|
|
|
msg.type = act_MOUSE_CLICK;
|
|
|
|
msg.data.mouse.x = x;
|
|
|
|
msg.data.mouse.y = y;
|
|
|
|
msg.data.mouse.buttons = act_BUTTON_NORMAL;
|
|
|
|
if (browser_window_action(g->data.browser.bw, &msg) == 1)
|
|
|
|
return;
|
|
|
|
msg.type = act_UNKNOWN;
|
|
|
|
}
|
2002-09-11 18:24:02 +04:00
|
|
|
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;
|
|
|
|
|
2003-10-01 04:26:42 +04:00
|
|
|
ro_gui_start_selection(pointer, &state, g);
|
2002-09-11 18:24:02 +04:00
|
|
|
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_drag.data.selection.gui->data.browser.bw->current_content->data.html.text_selection.altering = alter_UNKNOWN;
|
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
struct ro_gui_poll_block
|
|
|
|
{
|
|
|
|
wimp_event_no event;
|
|
|
|
wimp_block* block;
|
|
|
|
struct ro_gui_poll_block* next;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ro_gui_poll_block* ro_gui_poll_queued_blocks = NULL;
|
|
|
|
|
|
|
|
void ro_gui_poll_queue(wimp_event_no event, wimp_block* block)
|
|
|
|
{
|
|
|
|
struct ro_gui_poll_block* q = xcalloc(1, sizeof(struct ro_gui_poll_block));
|
|
|
|
|
|
|
|
q->event = event;
|
2003-09-17 16:57:43 +04:00
|
|
|
q->block = xcalloc(1, sizeof(*block));
|
|
|
|
memcpy(q->block, block, sizeof(*block));
|
2002-09-11 18:24:02 +04:00
|
|
|
q->next = NULL;
|
|
|
|
|
|
|
|
if (ro_gui_poll_queued_blocks == NULL)
|
|
|
|
{
|
|
|
|
ro_gui_poll_queued_blocks = q;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
struct ro_gui_poll_block* current = ro_gui_poll_queued_blocks;
|
|
|
|
while (current->next != NULL)
|
|
|
|
current = current->next;
|
|
|
|
current->next = q;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
void gui_multitask(void)
|
|
|
|
{
|
|
|
|
wimp_event_no event;
|
|
|
|
wimp_block block;
|
|
|
|
gui_window* g;
|
|
|
|
|
|
|
|
event = wimp_poll(wimp_QUEUE_KEY |
|
|
|
|
wimp_MASK_LOSE | wimp_MASK_GAIN | wimp_MASK_POLLWORD, &block, 0);
|
|
|
|
|
|
|
|
switch (event)
|
|
|
|
{
|
|
|
|
case wimp_NULL_REASON_CODE:
|
|
|
|
if (over_window != NULL)
|
|
|
|
{
|
|
|
|
wimp_pointer pointer;
|
|
|
|
wimp_get_pointer_info(&pointer);
|
|
|
|
ro_gui_window_mouse_at(&pointer);
|
|
|
|
}
|
2002-10-15 14:41:12 +04:00
|
|
|
ro_gui_throb();
|
2002-09-11 18:24:02 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case wimp_REDRAW_WINDOW_REQUEST :
|
2003-09-17 16:57:43 +04:00
|
|
|
if (block.redraw.w == dialog_config_th)
|
|
|
|
ro_gui_redraw_config_th(&block.redraw);
|
|
|
|
else {
|
|
|
|
g = ro_lookup_gui_from_w(block.redraw.w);
|
|
|
|
if (g)
|
|
|
|
ro_gui_window_redraw(g, &(block.redraw));
|
|
|
|
else {
|
|
|
|
g = ro_lookup_gui_toolbar_from_w(block.redraw.w);
|
|
|
|
if (g)
|
|
|
|
ro_gui_toolbar_redraw(g, &(block.redraw));
|
|
|
|
else {
|
|
|
|
osbool more = wimp_redraw_window(&block.redraw);
|
|
|
|
while (more)
|
|
|
|
more = wimp_get_rectangle(&block.redraw);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2002-09-11 18:24:02 +04:00
|
|
|
|
|
|
|
case wimp_OPEN_WINDOW_REQUEST :
|
|
|
|
g = ro_lookup_gui_from_w(block.open.w);
|
|
|
|
if (g != NULL)
|
|
|
|
ro_gui_window_open(g, &(block.open));
|
2002-10-15 14:41:12 +04:00
|
|
|
else
|
2003-06-02 03:02:56 +04:00
|
|
|
{
|
2002-10-15 14:41:12 +04:00
|
|
|
wimp_open_window(&block.open);
|
2003-06-02 03:02:56 +04:00
|
|
|
}
|
2002-09-11 18:24:02 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case wimp_CLOSE_WINDOW_REQUEST :
|
|
|
|
ro_gui_poll_queue(event, &block);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case wimp_MOUSE_CLICK :
|
|
|
|
if (block.pointer.w == wimp_ICON_BAR)
|
|
|
|
ro_gui_icon_bar_click(&(block.pointer));
|
|
|
|
else
|
|
|
|
{
|
|
|
|
g = ro_lookup_gui_from_w(block.pointer.w);
|
|
|
|
if (g != NULL)
|
|
|
|
{
|
|
|
|
if (g->redraw_safety == SAFE)
|
|
|
|
ro_gui_window_click(g, &(block.pointer));
|
|
|
|
else
|
|
|
|
ro_gui_poll_queue(event, &block);
|
|
|
|
}
|
|
|
|
else
|
2002-10-15 14:41:12 +04:00
|
|
|
{
|
|
|
|
g = ro_lookup_gui_toolbar_from_w(block.pointer.w);
|
|
|
|
if (g != NULL)
|
|
|
|
{
|
|
|
|
ro_gui_toolbar_click(g, &(block.pointer));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ro_gui_poll_queue(event, &block);
|
|
|
|
}
|
|
|
|
}
|
2002-09-11 18:24:02 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case wimp_POINTER_LEAVING_WINDOW :
|
|
|
|
over_window = NULL;
|
|
|
|
break;
|
|
|
|
case wimp_POINTER_ENTERING_WINDOW :
|
|
|
|
over_window = ro_lookup_gui_from_w(block.leaving.w);
|
|
|
|
break;
|
|
|
|
case wimp_USER_DRAG_BOX :
|
|
|
|
ro_gui_drag_end(&(block.dragged));
|
|
|
|
break;
|
|
|
|
case wimp_MENU_SELECTION :
|
|
|
|
case wimp_USER_MESSAGE :
|
|
|
|
case wimp_USER_MESSAGE_RECORDED :
|
|
|
|
case wimp_USER_MESSAGE_ACKNOWLEDGE:
|
2003-07-30 17:06:22 +04:00
|
|
|
|
2003-03-04 14:59:36 +03:00
|
|
|
fprintf(stderr, "MESSAGE %d (%x) HAS ARRIVED\n", block.message.action, block.message.action);
|
2003-07-30 17:06:22 +04:00
|
|
|
|
|
|
|
switch (block.message.action)
|
|
|
|
{
|
|
|
|
case message_DATA_SAVE :
|
|
|
|
ro_msg_datasave(&(block.message));
|
|
|
|
break;
|
|
|
|
|
2003-10-06 03:30:21 +04:00
|
|
|
case message_DATA_SAVE_ACK :
|
|
|
|
ro_msg_datasave_ack(&(block.message));
|
|
|
|
break;
|
|
|
|
|
2003-07-30 17:06:22 +04:00
|
|
|
case message_DATA_LOAD :
|
|
|
|
ro_msg_dataload(&(block.message));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case message_URI_PROCESS :
|
|
|
|
ro_uri_message_received(&(block.message));
|
|
|
|
break;
|
2003-08-25 02:39:55 +04:00
|
|
|
|
|
|
|
case message_PLUG_IN_OPENING:
|
|
|
|
case message_PLUG_IN_CLOSED:
|
|
|
|
case message_PLUG_IN_RESHAPE_REQUEST:
|
|
|
|
case message_PLUG_IN_FOCUS:
|
|
|
|
case message_PLUG_IN_URL_ACCESS:
|
|
|
|
case message_PLUG_IN_STATUS:
|
|
|
|
case message_PLUG_IN_BUSY:
|
|
|
|
case message_PLUG_IN_STREAM_NEW:
|
|
|
|
case message_PLUG_IN_STREAM_WRITE:
|
|
|
|
case message_PLUG_IN_STREAM_WRITTEN:
|
|
|
|
case message_PLUG_IN_STREAM_DESTROY:
|
|
|
|
case message_PLUG_IN_OPEN:
|
|
|
|
case message_PLUG_IN_CLOSE:
|
|
|
|
case message_PLUG_IN_RESHAPE:
|
|
|
|
case message_PLUG_IN_STREAM_AS_FILE:
|
|
|
|
case message_PLUG_IN_NOTIFY:
|
|
|
|
case message_PLUG_IN_ABORT:
|
|
|
|
case message_PLUG_IN_ACTION:
|
|
|
|
plugin_msg_parse(&(block.message),
|
|
|
|
(event == wimp_USER_MESSAGE_ACKNOWLEDGE ? 1 : 0));
|
|
|
|
break;
|
2003-07-30 17:06:22 +04:00
|
|
|
|
2003-09-05 18:35:36 +04:00
|
|
|
case message_QUIT :
|
|
|
|
netsurf_quit = 1;
|
|
|
|
break;
|
2003-09-09 23:25:28 +04:00
|
|
|
|
2003-09-05 18:35:36 +04:00
|
|
|
default:
|
|
|
|
ro_gui_poll_queue(event, &block);
|
|
|
|
break;
|
|
|
|
|
2003-08-25 02:39:55 +04:00
|
|
|
}
|
2002-09-11 18:24:02 +04:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void ro_gui_keypress(wimp_key* key)
|
|
|
|
{
|
|
|
|
gui_window* g;
|
|
|
|
|
2003-09-29 06:47:11 +04:00
|
|
|
if (key->i == -1 && (key->c < 256 || (key->c >= 396 && key->c <= 399))) {
|
2003-09-23 01:55:08 +04:00
|
|
|
g = ro_lookup_gui_from_w(key->w);
|
|
|
|
if (g) {
|
2003-09-29 06:47:11 +04:00
|
|
|
/* Munge cursor keys into unused control chars */
|
|
|
|
if (key->c == 396) key->c = 29; /* Left */
|
|
|
|
else if (key->c == 397) key->c = 28; /* Right */
|
|
|
|
else if (key->c == 398) key->c = 31; /* Down */
|
|
|
|
else if (key->c == 399) key->c = 30; /* Up */
|
2003-09-23 01:55:08 +04:00
|
|
|
browser_window_key_press(g->data.browser.bw, (char) key->c);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2002-09-11 18:24:02 +04:00
|
|
|
|
|
|
|
g = ro_lookup_gui_toolbar_from_w(key->w);
|
|
|
|
if (g != NULL)
|
|
|
|
{
|
|
|
|
if (key->c == wimp_KEY_RETURN)
|
|
|
|
{
|
|
|
|
if (g->data.browser.bw->url != NULL)
|
|
|
|
{
|
|
|
|
xfree(g->data.browser.bw->url);
|
|
|
|
g->data.browser.bw->url = NULL;
|
|
|
|
}
|
2003-09-17 00:02:55 +04:00
|
|
|
if (strcasecmp(g->url, "about:") == 0) {
|
|
|
|
about_create();
|
|
|
|
browser_window_open_location(g->data.browser.bw,
|
|
|
|
"file:///%3CWimp$ScrapDir%3E/WWW/NetSurf/About");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
browser_window_open_location(g->data.browser.bw, g->url);
|
|
|
|
}
|
2002-09-11 18:24:02 +04:00
|
|
|
return;
|
|
|
|
}
|
2003-07-23 02:13:44 +04:00
|
|
|
else if (key->c == wimp_KEY_F8)
|
|
|
|
{
|
|
|
|
/* TODO: use some protocol so it's type as HTML not Text. */
|
|
|
|
if(g->data.browser.bw->current_content->type == CONTENT_HTML ||
|
|
|
|
g->data.browser.bw->current_content->type == CONTENT_TEXTPLAIN)
|
|
|
|
xosfile_save_stamped("Pipe:$.Source", osfile_TYPE_TEXT,
|
|
|
|
g->data.browser.bw->current_content->data.html.source,
|
|
|
|
(g->data.browser.bw->current_content->data.html.source +
|
|
|
|
g->data.browser.bw->current_content->data.html.length));
|
|
|
|
xosfile_set_type("Pipe:$.Source", osfile_TYPE_TEXT);
|
|
|
|
xos_cli("Filer_Run Pipe:$.Source");
|
|
|
|
}
|
2003-07-15 22:06:52 +04:00
|
|
|
else if (key->c == wimp_KEY_F9)
|
|
|
|
{
|
|
|
|
if (g->data.browser.bw->current_content->type == CONTENT_HTML)
|
|
|
|
box_dump(g->data.browser.bw->current_content->data.html.layout->children, 0);
|
|
|
|
}
|
2003-07-16 21:39:07 +04:00
|
|
|
else if (key->c == wimp_KEY_F10)
|
|
|
|
{
|
|
|
|
cache_dump();
|
|
|
|
}
|
2003-08-25 02:39:55 +04:00
|
|
|
else if (key->c == (wimp_KEY_CONTROL + wimp_KEY_F2))
|
|
|
|
{
|
|
|
|
browser_window_destroy(g->data.browser.bw);
|
|
|
|
}
|
2002-09-11 18:24:02 +04:00
|
|
|
}
|
|
|
|
wimp_process_key(key->c);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
void gui_poll(void)
|
|
|
|
{
|
|
|
|
wimp_event_no event;
|
|
|
|
wimp_block block;
|
|
|
|
gui_window* g;
|
|
|
|
int finished = 0;
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
if (ro_gui_poll_queued_blocks == NULL)
|
|
|
|
{
|
2002-10-15 14:41:12 +04:00
|
|
|
event = wimp_poll(wimp_MASK_LOSE | wimp_MASK_GAIN, &block, 0);
|
2002-09-11 18:24:02 +04:00
|
|
|
finished = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
struct ro_gui_poll_block* next;
|
|
|
|
event = ro_gui_poll_queued_blocks->event;
|
|
|
|
memcpy(&block, ro_gui_poll_queued_blocks->block, sizeof(block));
|
|
|
|
next = ro_gui_poll_queued_blocks->next;
|
|
|
|
xfree(ro_gui_poll_queued_blocks->block);
|
|
|
|
xfree(ro_gui_poll_queued_blocks);
|
|
|
|
ro_gui_poll_queued_blocks = next;
|
|
|
|
finished = 0;
|
|
|
|
}
|
|
|
|
switch (event)
|
|
|
|
{
|
|
|
|
case wimp_NULL_REASON_CODE :
|
2003-04-15 21:53:00 +04:00
|
|
|
ro_gui_throb();
|
2002-09-11 18:24:02 +04:00
|
|
|
if (over_window != NULL
|
|
|
|
|| current_drag.type == draginfo_BROWSER_TEXT_SELECTION)
|
|
|
|
{
|
|
|
|
wimp_pointer pointer;
|
|
|
|
wimp_get_pointer_info(&pointer);
|
|
|
|
ro_gui_window_mouse_at(&pointer);
|
|
|
|
}
|
2003-09-11 01:44:11 +04:00
|
|
|
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,
|
|
|
|
browser_x_units(g->data.browser.old_width), 1000);
|
|
|
|
g->data.browser.reformat_pending = false;
|
|
|
|
}
|
|
|
|
}
|
2002-09-11 18:24:02 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case wimp_REDRAW_WINDOW_REQUEST :
|
2003-09-17 16:57:43 +04:00
|
|
|
if (block.redraw.w == dialog_config_th)
|
|
|
|
ro_gui_redraw_config_th(&block.redraw);
|
|
|
|
else {
|
|
|
|
g = ro_lookup_gui_from_w(block.redraw.w);
|
|
|
|
if (g != NULL)
|
|
|
|
ro_gui_window_redraw(g, &(block.redraw));
|
|
|
|
else {
|
|
|
|
g = ro_lookup_gui_toolbar_from_w(block.redraw.w);
|
|
|
|
if (g != NULL) {
|
|
|
|
ro_gui_toolbar_redraw(g, &(block.redraw));
|
|
|
|
} else {
|
|
|
|
osbool more = wimp_redraw_window(&block.redraw);
|
|
|
|
while (more)
|
|
|
|
more = wimp_get_rectangle(&block.redraw);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2002-09-11 18:24:02 +04:00
|
|
|
|
|
|
|
case wimp_OPEN_WINDOW_REQUEST :
|
|
|
|
g = ro_lookup_gui_from_w(block.open.w);
|
|
|
|
if (g != NULL)
|
|
|
|
ro_gui_window_open(g, &(block.open));
|
2002-10-15 14:41:12 +04:00
|
|
|
else
|
2003-06-02 03:02:56 +04:00
|
|
|
{
|
2002-10-15 14:41:12 +04:00
|
|
|
wimp_open_window(&block.open);
|
2003-06-02 03:02:56 +04:00
|
|
|
}
|
2002-09-11 18:24:02 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case wimp_CLOSE_WINDOW_REQUEST :
|
|
|
|
g = ro_lookup_gui_from_w(block.close.w);
|
|
|
|
if (g != NULL)
|
2003-07-18 03:01:02 +04:00
|
|
|
browser_window_destroy(g->data.browser.bw);
|
2002-10-15 14:41:12 +04:00
|
|
|
else
|
2003-08-27 02:37:32 +04:00
|
|
|
ro_gui_dialog_close(&(block.close.w));
|
2002-09-11 18:24:02 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case wimp_POINTER_LEAVING_WINDOW :
|
|
|
|
g = ro_lookup_gui_from_w(block.leaving.w);
|
|
|
|
if (g == over_window)
|
|
|
|
over_window = NULL;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case wimp_POINTER_ENTERING_WINDOW :
|
|
|
|
g = ro_lookup_gui_from_w(block.entering.w);
|
|
|
|
if (g != NULL)
|
|
|
|
over_window = g;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case wimp_MOUSE_CLICK :
|
|
|
|
if (block.pointer.w == wimp_ICON_BAR)
|
|
|
|
ro_gui_icon_bar_click(&(block.pointer));
|
|
|
|
else
|
|
|
|
{
|
|
|
|
g = ro_lookup_gui_from_w(block.pointer.w);
|
|
|
|
if (g != NULL)
|
2002-10-15 14:41:12 +04:00
|
|
|
{
|
2002-09-11 18:24:02 +04:00
|
|
|
ro_gui_window_click(g, &(block.pointer));
|
2002-10-15 14:41:12 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
g = ro_lookup_gui_toolbar_from_w(block.pointer.w);
|
|
|
|
if (g != NULL)
|
|
|
|
{
|
|
|
|
ro_gui_toolbar_click(g, &(block.pointer));
|
|
|
|
}
|
|
|
|
else
|
2003-10-06 03:30:21 +04:00
|
|
|
{
|
|
|
|
g = ro_lookup_download_window_from_w(block.pointer.w);
|
|
|
|
if (g != NULL)
|
|
|
|
{
|
|
|
|
ro_download_window_click(g, &(block.pointer));
|
|
|
|
}
|
|
|
|
|
|
|
|
else ro_gui_dialog_click(&(block.pointer));
|
2002-10-15 14:41:12 +04:00
|
|
|
}
|
2002-09-11 18:24:02 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case wimp_USER_DRAG_BOX :
|
|
|
|
ro_gui_drag_end(&(block.dragged));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case wimp_KEY_PRESSED :
|
|
|
|
ro_gui_keypress(&(block.key));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case wimp_MENU_SELECTION :
|
2002-10-15 14:41:12 +04:00
|
|
|
ro_gui_menu_selection(&(block.selection));
|
2002-09-11 18:24:02 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case wimp_LOSE_CARET :
|
|
|
|
break;
|
|
|
|
case wimp_GAIN_CARET :
|
|
|
|
break;
|
|
|
|
|
|
|
|
case wimp_USER_MESSAGE :
|
|
|
|
case wimp_USER_MESSAGE_RECORDED :
|
|
|
|
case wimp_USER_MESSAGE_ACKNOWLEDGE:
|
2003-07-30 17:06:22 +04:00
|
|
|
|
2003-03-04 14:59:36 +03:00
|
|
|
fprintf(stderr, "MESSAGE %d (%x) HAS ARRIVED\n", block.message.action, block.message.action);
|
2003-07-30 17:06:22 +04:00
|
|
|
|
|
|
|
switch (block.message.action)
|
|
|
|
{
|
|
|
|
case message_DATA_SAVE :
|
|
|
|
ro_msg_datasave(&(block.message));
|
|
|
|
break;
|
|
|
|
|
2003-10-06 03:30:21 +04:00
|
|
|
case message_DATA_SAVE_ACK :
|
|
|
|
ro_msg_datasave_ack(&(block.message));
|
|
|
|
break;
|
|
|
|
|
2003-07-30 17:06:22 +04:00
|
|
|
case message_DATA_LOAD :
|
|
|
|
ro_msg_dataload(&(block.message));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case message_URI_PROCESS :
|
|
|
|
ro_uri_message_received(&(block.message));
|
|
|
|
break;
|
|
|
|
|
2003-08-25 02:39:55 +04:00
|
|
|
case message_PLUG_IN_OPENING:
|
|
|
|
case message_PLUG_IN_CLOSED:
|
|
|
|
case message_PLUG_IN_RESHAPE_REQUEST:
|
|
|
|
case message_PLUG_IN_FOCUS:
|
|
|
|
case message_PLUG_IN_URL_ACCESS:
|
|
|
|
case message_PLUG_IN_STATUS:
|
|
|
|
case message_PLUG_IN_BUSY:
|
|
|
|
case message_PLUG_IN_STREAM_NEW:
|
|
|
|
case message_PLUG_IN_STREAM_WRITE:
|
|
|
|
case message_PLUG_IN_STREAM_WRITTEN:
|
|
|
|
case message_PLUG_IN_STREAM_DESTROY:
|
|
|
|
case message_PLUG_IN_OPEN:
|
|
|
|
case message_PLUG_IN_CLOSE:
|
|
|
|
case message_PLUG_IN_RESHAPE:
|
|
|
|
case message_PLUG_IN_STREAM_AS_FILE:
|
|
|
|
case message_PLUG_IN_NOTIFY:
|
|
|
|
case message_PLUG_IN_ABORT:
|
|
|
|
case message_PLUG_IN_ACTION:
|
|
|
|
plugin_msg_parse(&(block.message),
|
|
|
|
(event == wimp_USER_MESSAGE_ACKNOWLEDGE ? 1 : 0));
|
|
|
|
break;
|
|
|
|
|
2003-07-30 17:06:22 +04:00
|
|
|
case message_QUIT :
|
|
|
|
netsurf_quit = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
2002-09-11 18:24:02 +04:00
|
|
|
}
|
2003-10-06 03:30:21 +04:00
|
|
|
}
|
2002-09-11 18:24:02 +04:00
|
|
|
} while (finished == 0);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2003-10-06 03:30:21 +04:00
|
|
|
void gui_window_start_throbber(struct gui_window* g)
|
2002-10-15 14:41:12 +04:00
|
|
|
{
|
2003-03-04 14:59:36 +03:00
|
|
|
g->throbtime = (float) (clock() + 0) / CLOCKS_PER_SEC; /* workaround compiler warning */
|
2002-10-15 14:41:12 +04:00
|
|
|
g->throbber = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void gui_window_stop_throbber(gui_window* g)
|
|
|
|
{
|
|
|
|
g->throbber = 0;
|
|
|
|
wimp_set_icon_state(g->data.browser.toolbar, ro_theme_icon(current_theme, THEME_TOOLBAR, "TOOLBAR_THROBBER"), 0, 0);
|
|
|
|
}
|
2002-12-31 01:56:30 +03:00
|
|
|
|
2003-10-25 04:35:49 +04:00
|
|
|
void gui_gadget_combo(struct browser_window* bw, struct form_control* g, unsigned long mx, unsigned long my)
|
2002-12-31 01:56:30 +03:00
|
|
|
{
|
|
|
|
int count = 0;
|
2003-10-25 04:35:49 +04:00
|
|
|
struct form_option* o;
|
2002-12-31 01:56:30 +03:00
|
|
|
wimp_pointer pointer;
|
2003-01-06 03:04:43 +03:00
|
|
|
|
2002-12-31 01:56:30 +03:00
|
|
|
if (combo_menu != NULL)
|
|
|
|
xfree(combo_menu);
|
2003-01-06 03:04:43 +03:00
|
|
|
|
2002-12-31 01:56:30 +03:00
|
|
|
o = g->data.select.items;
|
|
|
|
while (o != NULL)
|
|
|
|
{
|
|
|
|
count++;
|
|
|
|
o = o->next;
|
|
|
|
}
|
|
|
|
|
2003-08-27 02:37:32 +04:00
|
|
|
combo_menu = xcalloc(1, wimp_SIZEOF_MENU(count));
|
2002-12-31 01:56:30 +03:00
|
|
|
|
|
|
|
combo_menu->title_data.indirected_text.text = "Select";
|
|
|
|
combo_menu->title_fg = wimp_COLOUR_BLACK;
|
|
|
|
combo_menu->title_bg = wimp_COLOUR_LIGHT_GREY;
|
|
|
|
combo_menu->work_fg = wimp_COLOUR_BLACK;
|
|
|
|
combo_menu->work_bg = wimp_COLOUR_WHITE;
|
|
|
|
combo_menu->width = 0;
|
|
|
|
combo_menu->height = wimp_MENU_ITEM_HEIGHT;
|
|
|
|
combo_menu->gap = wimp_MENU_ITEM_GAP;
|
|
|
|
|
|
|
|
o = g->data.select.items;
|
|
|
|
count = 0;
|
|
|
|
while (o != NULL)
|
|
|
|
{
|
|
|
|
combo_menu->entries[count].menu_flags = 0;
|
|
|
|
if (count == 0)
|
|
|
|
combo_menu->entries[count].menu_flags = wimp_MENU_TITLE_INDIRECTED;
|
|
|
|
if (o->selected)
|
|
|
|
combo_menu->entries[count].menu_flags |= wimp_MENU_TICKED;
|
|
|
|
if (o->next == NULL)
|
|
|
|
combo_menu->entries[count].menu_flags |= wimp_MENU_LAST;
|
|
|
|
|
|
|
|
combo_menu->entries[count].sub_menu = wimp_NO_SUB_MENU;
|
|
|
|
combo_menu->entries[count].icon_flags = wimp_ICON_TEXT | wimp_ICON_INDIRECTED | wimp_ICON_FILLED | wimp_ICON_VCENTRED | (wimp_COLOUR_BLACK << wimp_ICON_FG_COLOUR_SHIFT) | (wimp_COLOUR_WHITE << wimp_ICON_BG_COLOUR_SHIFT) | (wimp_BUTTON_MENU_ICON << wimp_ICON_BUTTON_TYPE_SHIFT);
|
|
|
|
combo_menu->entries[count].data.indirected_text.text = o->text;
|
|
|
|
combo_menu->entries[count].data.indirected_text.validation = "\0";
|
|
|
|
combo_menu->entries[count].data.indirected_text.size = strlen(o->text);
|
|
|
|
count++;
|
|
|
|
o = o->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
wimp_get_pointer_info(&pointer);
|
|
|
|
//wimp_create_menu(combo_menu, pointer.pos.x - 64, pointer.pos.y);
|
|
|
|
current_gadget = g;
|
|
|
|
ro_gui_create_menu(combo_menu, pointer.pos.x - 64, pointer.pos.y, bw->window);
|
|
|
|
}
|
|
|
|
|
2003-09-23 01:55:08 +04:00
|
|
|
void gui_window_place_caret(gui_window *g, int x, int y, int height)
|
2002-12-31 01:56:30 +03:00
|
|
|
{
|
2003-09-23 01:55:08 +04:00
|
|
|
wimp_set_caret_position(g->data.browser.window, -1,
|
|
|
|
x * 2, -(y + height) * 2, height * 2, -1);
|
2002-12-31 01:56:30 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void ro_msg_datasave(wimp_message* block)
|
|
|
|
{
|
|
|
|
gui_window* gui;
|
|
|
|
struct browser_window* bw;
|
2003-03-04 14:59:36 +03:00
|
|
|
wimp_message_data_xfer* data;
|
2002-12-31 01:56:30 +03:00
|
|
|
int x,y;
|
|
|
|
struct box_selection* click_boxes;
|
|
|
|
int found, plot_index;
|
|
|
|
int i;
|
|
|
|
int done = 0;
|
|
|
|
wimp_window_state state;
|
|
|
|
|
2003-03-04 14:59:36 +03:00
|
|
|
data = &block->data.data_xfer;
|
2002-12-31 01:56:30 +03:00
|
|
|
|
|
|
|
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 = browser_x_units(window_x_units(data->pos.x, &state));
|
|
|
|
y = browser_y_units(window_y_units(data->pos.y, &state));
|
2003-01-06 03:04:43 +03:00
|
|
|
|
2002-12-31 01:56:30 +03:00
|
|
|
found = 0;
|
|
|
|
click_boxes = NULL;
|
|
|
|
plot_index = 0;
|
|
|
|
|
|
|
|
box_under_area(bw->current_content->data.html.layout->children,
|
|
|
|
x, y, 0, 0, &click_boxes, &found, &plot_index);
|
|
|
|
|
|
|
|
if (found == 0)
|
2003-03-04 14:59:36 +03:00
|
|
|
return;
|
2002-12-31 01:56:30 +03:00
|
|
|
|
|
|
|
for (i = found - 1; i >= 0; i--)
|
|
|
|
{
|
|
|
|
if (click_boxes[i].box->gadget != NULL)
|
|
|
|
{
|
2003-03-04 14:59:36 +03:00
|
|
|
if (click_boxes[i].box->gadget->type == GADGET_TEXTAREA && data->file_type == 0xFFF)
|
2002-12-31 01:56:30 +03:00
|
|
|
{
|
|
|
|
/* 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;
|
2003-03-04 14:59:36 +03:00
|
|
|
strcpy(block->data.data_xfer.file_name, "<Wimp$Scrap>");
|
2002-12-31 01:56:30 +03:00
|
|
|
wimp_send_message(wimp_USER_MESSAGE, block, block->sender);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2003-01-06 03:04:43 +03:00
|
|
|
|
2002-12-31 01:56:30 +03:00
|
|
|
xfree(click_boxes);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ro_msg_dataload(wimp_message* block)
|
|
|
|
{
|
|
|
|
gui_window* gui;
|
|
|
|
struct browser_window* bw;
|
2003-03-04 14:59:36 +03:00
|
|
|
wimp_message_data_xfer* data;
|
2002-12-31 01:56:30 +03:00
|
|
|
int x,y;
|
|
|
|
struct box_selection* click_boxes;
|
|
|
|
int found, plot_index;
|
|
|
|
int i;
|
|
|
|
int done = 0;
|
|
|
|
wimp_window_state state;
|
|
|
|
|
2003-03-04 14:59:36 +03:00
|
|
|
data = &block->data.data_xfer;
|
2002-12-31 01:56:30 +03:00
|
|
|
|
|
|
|
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 = browser_x_units(window_x_units(data->pos.x, &state));
|
|
|
|
y = browser_y_units(window_y_units(data->pos.y, &state));
|
2003-01-06 03:04:43 +03:00
|
|
|
|
2002-12-31 01:56:30 +03:00
|
|
|
found = 0;
|
|
|
|
click_boxes = NULL;
|
|
|
|
plot_index = 0;
|
|
|
|
|
|
|
|
box_under_area(bw->current_content->data.html.layout->children,
|
|
|
|
x, y, 0, 0, &click_boxes, &found, &plot_index);
|
|
|
|
|
|
|
|
if (found == 0)
|
2003-03-04 14:59:36 +03:00
|
|
|
return;
|
2002-12-31 01:56:30 +03:00
|
|
|
|
|
|
|
for (i = found - 1; i >= 0; i--)
|
|
|
|
{
|
|
|
|
if (click_boxes[i].box->gadget != NULL)
|
|
|
|
{
|
2003-03-04 14:59:36 +03:00
|
|
|
if (click_boxes[i].box->gadget->type == GADGET_TEXTAREA && data->file_type == 0xFFF)
|
2002-12-31 01:56:30 +03:00
|
|
|
{
|
|
|
|
/* load the text in! */
|
2003-09-23 01:55:08 +04:00
|
|
|
/* TODO */
|
2002-12-31 01:56:30 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2003-01-06 03:04:43 +03:00
|
|
|
|
2002-12-31 01:56:30 +03:00
|
|
|
xfree(click_boxes);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2003-09-11 01:44:11 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Find screen size in OS units.
|
|
|
|
*/
|
|
|
|
|
|
|
|
void ro_gui_screen_size(int *width, int *height)
|
|
|
|
{
|
|
|
|
int xeig_factor, yeig_factor, xwind_limit, ywind_limit;
|
|
|
|
|
|
|
|
os_read_mode_variable(os_CURRENT_MODE, os_MODEVAR_XEIG_FACTOR, &xeig_factor);
|
|
|
|
os_read_mode_variable(os_CURRENT_MODE, os_MODEVAR_YEIG_FACTOR, &yeig_factor);
|
|
|
|
os_read_mode_variable(os_CURRENT_MODE, os_MODEVAR_XWIND_LIMIT, &xwind_limit);
|
|
|
|
os_read_mode_variable(os_CURRENT_MODE, os_MODEVAR_YWIND_LIMIT, &ywind_limit);
|
|
|
|
*width = (xwind_limit + 1) << xeig_factor;
|
|
|
|
*height = (ywind_limit + 1) << yeig_factor;
|
|
|
|
}
|
|
|
|
|
2003-09-26 20:52:53 +04:00
|
|
|
void ro_gui_open_help_page (void)
|
|
|
|
{
|
|
|
|
struct browser_window *bw;
|
|
|
|
bw = create_browser_window(browser_TITLE | browser_TOOLBAR |
|
|
|
|
browser_SCROLL_X_ALWAYS |
|
|
|
|
browser_SCROLL_Y_ALWAYS, 640, 480);
|
|
|
|
gui_window_show(bw->window);
|
|
|
|
browser_window_open_location(bw, HELP_URL);
|
|
|
|
wimp_set_caret_position(bw->window->data.browser.toolbar,
|
|
|
|
ro_theme_icon(current_theme, THEME_TOOLBAR,
|
|
|
|
"TOOLBAR_URL"),
|
|
|
|
0,0,-1, (int) strlen(bw->window->url) - 1);
|
|
|
|
}
|
|
|
|
|
2003-10-06 03:30:21 +04:00
|
|
|
void ro_gui_drag_box_start(wimp_pointer *pointer)
|
|
|
|
{
|
|
|
|
wimp_drag *drag_box;
|
|
|
|
wimp_window_state *icon_window;
|
|
|
|
wimp_icon_state *icon_icon;
|
|
|
|
int x0, y0;
|
|
|
|
|
|
|
|
/* TODO: support drag_a_sprite */
|
|
|
|
|
|
|
|
icon_window = xcalloc(1, sizeof(*icon_window));
|
|
|
|
icon_icon = xcalloc(1, sizeof(*icon_icon));
|
|
|
|
drag_box = xcalloc(1, sizeof(*drag_box));
|
|
|
|
|
|
|
|
drag_box->w = pointer->i;
|
|
|
|
drag_box->type = wimp_DRAG_USER_FIXED;
|
|
|
|
|
|
|
|
icon_window->w = pointer->w;
|
|
|
|
wimp_get_window_state(icon_window);
|
|
|
|
|
|
|
|
x0 = icon_window->visible.x0 - icon_window->xscroll;
|
|
|
|
y0 = icon_window->visible.y1 - icon_window->yscroll;
|
|
|
|
|
|
|
|
icon_icon->w = pointer->w;
|
|
|
|
icon_icon->i = pointer->i;
|
|
|
|
wimp_get_icon_state(icon_icon);
|
|
|
|
|
|
|
|
drag_box->initial.x0 = x0 + icon_icon->icon.extent.x0;
|
|
|
|
drag_box->initial.y0 = y0 + icon_icon->icon.extent.y0;
|
|
|
|
drag_box->initial.x1 = x0 + icon_icon->icon.extent.x1;
|
|
|
|
drag_box->initial.y1 = y0 + icon_icon->icon.extent.y1;
|
|
|
|
|
|
|
|
drag_box->bbox.x0 = 0x80000000;
|
|
|
|
drag_box->bbox.y0 = 0x80000000;
|
|
|
|
drag_box->bbox.x1 = 0x7FFFFFFF; // CHANGE
|
|
|
|
drag_box->bbox.y1 = 0x7FFFFFFF;
|
|
|
|
|
|
|
|
/*if(USE_DRAGASPRITE == DRAGASPRITE_AVAILABLE)
|
|
|
|
xdragasprite_start((dragasprite_HPOS_CENTRE ^
|
|
|
|
dragasprite_VPOS_CENTRE ^
|
|
|
|
dragasprite_NO_BOUND ^
|
|
|
|
dragasprite_BOUND_POINTER),
|
|
|
|
(osspriteop_area*) 1,
|
|
|
|
"file_fff",
|
|
|
|
(os_box*)&drag_box->initial,0);*/
|
|
|
|
|
|
|
|
wimp_drag_box(drag_box);
|
|
|
|
|
|
|
|
xfree(drag_box);
|
|
|
|
xfree(icon_window);
|
|
|
|
xfree(icon_icon);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void ro_msg_datasave_ack(wimp_message *message)
|
|
|
|
{
|
|
|
|
int save_status = 0;
|
|
|
|
|
|
|
|
LOG(("ACK Message: filename = %s", message->data.data_xfer.file_name));
|
|
|
|
|
|
|
|
if (current_drag.type == draginfo_DOWNLOAD_SAVE)
|
|
|
|
{
|
|
|
|
assert(current_drag.data.download.gui->data.download.download_status ==
|
|
|
|
download_COMPLETE);
|
|
|
|
|
|
|
|
|
|
|
|
save_status = ro_save_data(current_drag.data.download.gui->data.download.content->data.other.data,
|
|
|
|
current_drag.data.download.gui->data.download.content->data.other.length,
|
|
|
|
message->data.data_xfer.file_name,
|
|
|
|
current_drag.data.download.gui->data.download.file_type);
|
|
|
|
|
|
|
|
|
|
|
|
if (save_status != 1)
|
|
|
|
{
|
|
|
|
LOG(("Could not save download data"));
|
|
|
|
//Report_Error
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ro_download_window_close(current_drag.data.download.gui);
|
|
|
|
current_drag.type = draginfo_NONE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int ro_save_data(void *data, unsigned long length, char *file_name, bits file_type)
|
|
|
|
{
|
|
|
|
os_error *written = NULL;
|
|
|
|
|
|
|
|
void *end_data = (int)data + length;
|
|
|
|
|
|
|
|
written = xosfile_save_stamped(file_name, file_type, data, end_data);
|
|
|
|
|
|
|
|
if (written != NULL)
|
|
|
|
{
|
|
|
|
LOG(("Unable to create stamped file"));
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|