[project @ 2003-11-07 23:51:13 by bursa]

Split out window.c, implement DataOpen and tidy up gui code.

svn path=/import/netsurf/; revision=408
This commit is contained in:
James Bursa 2003-11-07 23:51:13 +00:00
parent e8def12ba2
commit b055948973
14 changed files with 1146 additions and 1099 deletions

View File

@ -9,4 +9,4 @@ If "<Alias$Open_URI_https>" = "" Then Set Alias$Open_URI_https <NetSurf$Dir>.URI
If "<Alias$Open_URI_file>" = "" Then Set Alias$Open_URI_file <NetSurf$Dir>.URILaunch If "<Alias$Open_URI_file>" = "" Then Set Alias$Open_URI_file <NetSurf$Dir>.URILaunch
| Claim URI files | Claim URI files
If "<Alias$@RunType_F91>" = "" Then Set Alias$@RunType_F91 <NetSurf$Dir>.URILaunch |If "<Alias$@RunType_F91>" = "" Then Set Alias$@RunType_F91 <NetSurf$Dir>.URILaunch

View File

@ -25,11 +25,11 @@ RMEnsure SharedUnixLibrary 1.02 Error NetSurf requires SharedUnixLibrary 1.02 or
| Load AcornURI if it isn't already | Load AcornURI if it isn't already
| http://sudden.recoil.org/ | http://sudden.recoil.org/
Set NetSurf$Start_URI_Handler "no" Unset NetSurf$Start_URI_Handler
RMEnsure AcornURI 0.12 Set NetSurf$Start_URI_Handler "yes" RMEnsure AcornURI 0.12 Set NetSurf$Start_URI_Handler 1
RMEnsure AcornURI 0.12 RMLoad System:Modules.Network.URI RMEnsure AcornURI 0.12 RMLoad System:Modules.Network.URI
RMEnsure AcornURI 0.12 Error NetSurf requires AcornURI 0.12 or later. A version of this can be found at http://sudden.recoil.org/others/ RMEnsure AcornURI 0.12 Error NetSurf requires AcornURI 0.12 or later. A version of this can be found at http://sudden.recoil.org/others/
RMEnsure AcornURI 0.12 Set NetSurf$Start_URI_Handler "no" RMEnsure AcornURI 0.12 Unset NetSurf$Start_URI_Handler
| Check for mime map module | Check for mime map module
If "<InetDBase$Path>" = "" Then Error Inet databases can not be found If "<InetDBase$Path>" = "" Then Error Inet databases can not be found

View File

@ -53,6 +53,7 @@ void gui_download_window_error(gui_window *g, const char *error);
void gui_init(int argc, char** argv); void gui_init(int argc, char** argv);
void gui_multitask(void); void gui_multitask(void);
void gui_poll(bool active); void gui_poll(bool active);
void gui_quit(void);
gui_safety gui_window_set_redraw_safety(gui_window* g, gui_safety s); gui_safety gui_window_set_redraw_safety(gui_window* g, gui_safety s);

View File

@ -76,4 +76,5 @@ void netsurf_exit(void)
{ {
cache_quit(); cache_quit();
fetch_quit(); fetch_quit();
gui_quit();
} }

View File

@ -14,7 +14,7 @@ OBJECTS = $(OBJECTS_COMMON) \
browser.o loginlist.o netsurf.o \ browser.o loginlist.o netsurf.o \
htmlredraw.o \ htmlredraw.o \
401login.o dialog.o download.o gui.o menus.o mouseactions.o \ 401login.o dialog.o download.o gui.o menus.o mouseactions.o \
options.o textselection.o theme.o \ options.o textselection.o theme.o window.o \
draw.o gif.o jpeg.o plugin.o png.o sprite.o \ draw.o gif.o jpeg.o plugin.o png.o sprite.o \
about.o filetype.o font.o uri.o about.o filetype.o font.o uri.o
OBJECTS_DEBUG = $(OBJECTS_COMMON) \ OBJECTS_DEBUG = $(OBJECTS_COMMON) \

View File

@ -118,17 +118,13 @@ wimp_w ro_gui_dialog_create(const char *template_name)
void ro_gui_dialog_open(wimp_w w) void ro_gui_dialog_open(wimp_w w)
{ {
int xeig_factor, yeig_factor, xwind_limit, ywind_limit, int screen_x, screen_y, dx, dy;
screen_x, screen_y, dx, dy;
wimp_window_state open; wimp_window_state open;
/* find screen centre in os units */ /* find screen centre in os units */
os_read_mode_variable(os_CURRENT_MODE, os_MODEVAR_XEIG_FACTOR, &xeig_factor); ro_gui_screen_size(&screen_x, &screen_y);
os_read_mode_variable(os_CURRENT_MODE, os_MODEVAR_YEIG_FACTOR, &yeig_factor); screen_x /= 2;
os_read_mode_variable(os_CURRENT_MODE, os_MODEVAR_XWIND_LIMIT, &xwind_limit); screen_y /= 2;
os_read_mode_variable(os_CURRENT_MODE, os_MODEVAR_YWIND_LIMIT, &ywind_limit);
screen_x = (xwind_limit + 1) << (xeig_factor - 1);
screen_y = (ywind_limit + 1) << (yeig_factor - 1);
/* centre and open */ /* centre and open */
open.w = w; open.w = w;

View File

@ -91,8 +91,8 @@ gui_window *gui_create_download_window(struct content *content)
256; 256;
/* create and open the download window */ /* create and open the download window */
g->data.download.window = wimp_create_window(download_template); g->window = wimp_create_window(download_template);
ro_gui_dialog_open(g->data.download.window); ro_gui_dialog_open(g->window);
g->data.download.download_status = download_INCOMPLETE; g->data.download.download_status = download_INCOMPLETE;
@ -141,7 +141,7 @@ void ro_gui_download_leaf(const char *url, char *leaf)
void gui_download_window_update_status(gui_window *g) void gui_download_window_update_status(gui_window *g)
{ {
strncpy(g->status, g->data.download.content->status_message, 256); strncpy(g->status, g->data.download.content->status_message, 256);
wimp_set_icon_state(g->data.download.window, wimp_set_icon_state(g->window,
ICON_DOWNLOAD_STATUS, 0, 0); ICON_DOWNLOAD_STATUS, 0, 0);
} }
@ -156,15 +156,15 @@ void gui_download_window_error(gui_window *g, const char *error)
/* place error message in status icon in red */ /* place error message in status icon in red */
strncpy(g->status, error, 256); strncpy(g->status, error, 256);
wimp_set_icon_state(g->data.download.window, wimp_set_icon_state(g->window,
ICON_DOWNLOAD_STATUS, ICON_DOWNLOAD_STATUS,
wimp_COLOUR_RED << wimp_ICON_FG_COLOUR_SHIFT, wimp_COLOUR_RED << wimp_ICON_FG_COLOUR_SHIFT,
wimp_ICON_FG_COLOUR); wimp_ICON_FG_COLOUR);
/* grey out file and pathname icons */ /* grey out file and pathname icons */
wimp_set_icon_state(g->data.download.window, wimp_set_icon_state(g->window,
ICON_DOWNLOAD_ICON, wimp_ICON_SHADED, 0); ICON_DOWNLOAD_ICON, wimp_ICON_SHADED, 0);
wimp_set_icon_state(g->data.download.window, wimp_set_icon_state(g->window,
ICON_DOWNLOAD_PATH, wimp_ICON_SHADED, 0); ICON_DOWNLOAD_PATH, wimp_ICON_SHADED, 0);
g->data.download.download_status = download_ERROR; g->data.download.download_status = download_ERROR;
@ -179,13 +179,13 @@ void gui_download_window_done(gui_window *g)
{ {
snprintf(g->status, 256, messages_get("Downloaded"), snprintf(g->status, 256, messages_get("Downloaded"),
g->data.download.content->data.other.length); g->data.download.content->data.other.length);
wimp_set_icon_state(g->data.download.window, wimp_set_icon_state(g->window,
ICON_DOWNLOAD_STATUS, 0, 0); ICON_DOWNLOAD_STATUS, 0, 0);
// clear shaded path and icon icons // clear shaded path and icon icons
wimp_set_icon_state(g->data.download.window, wimp_set_icon_state(g->window,
ICON_DOWNLOAD_ICON, 0, wimp_ICON_SHADED); ICON_DOWNLOAD_ICON, 0, wimp_ICON_SHADED);
wimp_set_icon_state(g->data.download.window, wimp_set_icon_state(g->window,
ICON_DOWNLOAD_PATH, 0, wimp_ICON_SHADED); ICON_DOWNLOAD_PATH, 0, wimp_ICON_SHADED);
g->data.download.download_status = download_COMPLETE; g->data.download.download_status = download_COMPLETE;
@ -223,7 +223,7 @@ struct gui_window * ro_lookup_download_window_from_w(wimp_w window)
{ {
if (g->type == GUI_DOWNLOAD_WINDOW) if (g->type == GUI_DOWNLOAD_WINDOW)
{ {
if (g->data.browser.window == window) if (g->window == window)
{ {
return g; return g;
} }
@ -236,5 +236,5 @@ void ro_download_window_close(struct gui_window *g)
{ {
// free contexts etc??? // free contexts etc???
wimp_close_window(g->data.download.window); wimp_close_window(g->window);
} }

File diff suppressed because it is too large Load Diff

View File

@ -25,14 +25,16 @@ extern int current_menu_x, current_menu_y, iconbar_menu_height;
extern struct form_control *current_gadget; extern struct form_control *current_gadget;
extern const char *HOME_URL; extern const char *HOME_URL;
extern gui_window *window_list; extern gui_window *window_list;
extern bool gui_reformat_pending;
struct gui_window struct gui_window
{ {
gui_window_type type; gui_window_type type;
wimp_w window;
union { union {
struct { struct {
wimp_w window;
wimp_w toolbar; wimp_w toolbar;
int toolbar_width; int toolbar_width;
struct browser_window* bw; struct browser_window* bw;
@ -40,7 +42,6 @@ struct gui_window
int old_width; int old_width;
} browser; } browser;
struct { struct {
wimp_w window;
struct content *content; struct content *content;
bits file_type; bits file_type;
char sprite_name[20]; char sprite_name[20];
@ -91,6 +92,7 @@ int window_x_units(int scr_units, wimp_window_state* win);
int window_y_units(int scr_units, wimp_window_state* win); int window_y_units(int scr_units, wimp_window_state* win);
void ro_gui_copy_selection(gui_window* g); void ro_gui_copy_selection(gui_window* g);
void ro_gui_open_help_page(void); void ro_gui_open_help_page(void);
void ro_gui_screen_size(int *width, int *height);
/* in menus.c */ /* in menus.c */
void ro_gui_menus_init(void); void ro_gui_menus_init(void);
@ -125,6 +127,17 @@ void ro_gui_401login_init(void);
void ro_gui_401login_open(char* host, char * realm, char* fetchurl); void ro_gui_401login_open(char* host, char * realm, char* fetchurl);
void ro_gui_401login_click(wimp_pointer *pointer); void ro_gui_401login_click(wimp_pointer *pointer);
/* 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_redraw(gui_window* g, wimp_draw* redraw);
void ro_gui_toolbar_click(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);
/* icon numbers */ /* icon numbers */
#define ICON_CONFIG_SAVE 0 #define ICON_CONFIG_SAVE 0
#define ICON_CONFIG_CANCEL 1 #define ICON_CONFIG_CANCEL 1

View File

@ -183,7 +183,7 @@ void plugin_add_instance(struct content *c, struct browser_window *bw,
pmo->flags = 0; pmo->flags = 0;
pmo->reserved = 0; pmo->reserved = 0;
pmo->browser = (plugin_b)params->browser; pmo->browser = (plugin_b)params->browser;
pmo->parent_window = bw->window->data.browser.window; pmo->parent_window = bw->window->window;
pmo->bbox = b; pmo->bbox = b;
xmimemaptranslate_mime_type_to_filetype(c->mime_type, &pmo->file_type); xmimemaptranslate_mime_type_to_filetype(c->mime_type, &pmo->file_type);
pmo->filename.pointer = params->filename; pmo->filename.pointer = params->filename;
@ -421,7 +421,7 @@ void plugin_reshape_instance(struct content *c, struct browser_window *bw,
pmr->flags = 0; pmr->flags = 0;
pmr->plugin = (plugin_p) params->plugin; pmr->plugin = (plugin_p) params->plugin;
pmr->browser = (plugin_b) params->browser; pmr->browser = (plugin_b) params->browser;
pmr->parent_window = (wimp_w) bw->window->data.browser.window; pmr->parent_window = (wimp_w) bw->window->window;
pmr->bbox = bbox; pmr->bbox = bbox;
m.size = 52; m.size = 52;

View File

@ -55,7 +55,7 @@ void ro_gui_drag_end(wimp_dragged* drag)
int final_x0, final_y0; int final_x0, final_y0;
wimp_window_state state; wimp_window_state state;
state.w = current_drag.data.selection.gui->data.browser.window; state.w = current_drag.data.selection.gui->window;
wimp_get_window_state(&state); wimp_get_window_state(&state);
final_x0 = browser_x_units(window_x_units(drag->final.x0, &state)); final_x0 = browser_x_units(window_x_units(drag->final.x0, &state));

View File

@ -13,6 +13,8 @@
#include "netsurf/utils/utils.h" #include "netsurf/utils/utils.h"
#include <stdio.h> #include <stdio.h>
ro_theme* current_theme = NULL;
void ro_theme_preload_template(ro_theme* theme, char* template_name, void ro_theme_preload_template(ro_theme* theme, char* template_name,
int* total_winicon, int* total_indirected) int* total_winicon, int* total_indirected)
{ {

View File

@ -63,6 +63,8 @@ struct ro_theme_window
typedef struct ro_theme_window ro_theme_window; typedef struct ro_theme_window ro_theme_window;
typedef struct ro_theme ro_theme; typedef struct ro_theme ro_theme;
extern ro_theme *current_theme;
typedef enum {theme_TOOLBAR_UNKNOWN, typedef enum {theme_TOOLBAR_UNKNOWN,
theme_TOOLBAR_BACK, theme_TOOLBAR_FORWARD, theme_TOOLBAR_RELOAD, theme_TOOLBAR_BACK, theme_TOOLBAR_FORWARD, theme_TOOLBAR_RELOAD,
theme_TOOLBAR_URL, theme_TOOLBAR_STATUS} theme_gadget; theme_TOOLBAR_URL, theme_TOOLBAR_STATUS} theme_gadget;

612
riscos/window.c Normal file
View File

@ -0,0 +1,612 @@
/*
* 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>
*/
#include <string.h>
#include "oslib/wimp.h"
#include "oslib/wimpspriteop.h"
#include "netsurf/riscos/gui.h"
#include "netsurf/riscos/theme.h"
#include "netsurf/utils/utils.h"
gui_window *window_list = 0;
static void gui_disable_icon(wimp_w w, wimp_i i);
static void gui_enable_icon(wimp_w w, wimp_i i);
gui_window *gui_create_browser_window(struct browser_window *bw)
{
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 |
wimp_WINDOW_HSCROLL | wimp_WINDOW_SIZE_ICON | wimp_WINDOW_TOGGLE_ICON |
wimp_WINDOW_IGNORE_XEXTENT;
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);
window.extent.x1 = 8192;//ro_x_units(bw->format_width);
if ((bw->flags & browser_TOOLBAR) != 0)
{
window.extent.y1 = ro_theme_toolbar_height(current_theme);
}
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;
window.sprite_area = wimpspriteop_AREA;
window.xmin = 100;
window.ymin = window.extent.y1 + 100;
window.title_data.indirected_text.text = g->title;
window.title_data.indirected_text.validation = -1;
window.title_data.indirected_text.size = 255;
window.icon_count = 0;
g->window = wimp_create_window(&window);
strcpy(g->title, "NetSurf");
g->data.browser.toolbar = 0;
if ((bw->flags & browser_TOOLBAR) != 0)
{
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;
}
g->redraw_safety = SAFE;
g->data.browser.reformat_pending = false;
g->data.browser.old_width = 0;
g->next = window_list;
window_list = g;
return g;
}
void gui_window_set_title(gui_window* g, char* title)
{
strncpy(g->title, title, 255);
wimp_force_redraw_title(g->window);
}
void gui_window_destroy(gui_window* g)
{
assert(g != 0);
if (g == window_list)
window_list = g->next;
else
{
gui_window* gg;
assert(window_list != NULL);
gg = window_list;
while (gg->next != g && gg->next != NULL)
gg = gg->next;
assert(gg->next != NULL);
gg->next = g->next;
}
xwimp_delete_window(g->window);
if (g->data.browser.toolbar)
xwimp_delete_window(g->data.browser.toolbar);
xfree(g);
}
void gui_window_show(gui_window* g)
{
wimp_window_state state;
if (g == NULL)
return;
state.w = g->window;
wimp_get_window_state(&state);
state.next = wimp_TOP;
ro_gui_window_open(g, (wimp_open*)&state);
}
void gui_window_redraw(gui_window* g, unsigned long x0, unsigned long y0,
unsigned long x1, unsigned long y1)
{
if (g == NULL)
return;
wimp_force_redraw(g->window,
ro_x_units(x0), ro_y_units(y1), ro_x_units(x1), ro_y_units(y0));
}
void gui_window_redraw_window(gui_window* g)
{
wimp_window_info info;
if (g == NULL)
return;
info.w = g->window;
wimp_get_window_info_header_only(&info);
wimp_force_redraw(g->window, info.extent.x0, info.extent.y0, info.extent.x1, info.extent.y1);
}
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;
}
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;
snprintf(throbber.icon.data.sprite, 12, "throbber%d", g->throbber);
more = wimp_redraw_window(redraw);
while (more)
{
wimp_plot_icon(&throbber.icon);
more = wimp_get_rectangle(redraw);
}
return;
}
void ro_gui_window_redraw(gui_window* g, wimp_draw* redraw)
{
osbool more;
struct content *c = g->data.browser.bw->current_content;
if (g->redraw_safety == SAFE && g->type == GUI_BROWSER_WINDOW && c != NULL)
{
more = wimp_redraw_window(redraw);
wimp_set_font_colours(wimp_COLOUR_WHITE, wimp_COLOUR_BLACK);
while (more)
{
content_redraw(c,
(int) redraw->box.x0 - (int) redraw->xscroll,
(int) redraw->box.y1 - (int) redraw->yscroll,
c->width * 2, c->height * 2,
redraw->clip.x0, redraw->clip.y0,
redraw->clip.x1 - 1, redraw->clip.y1 - 1);
more = wimp_get_rectangle(redraw);
}
}
else
{
more = wimp_redraw_window(redraw);
while (more)
more = wimp_get_rectangle(redraw);
}
}
void gui_window_set_scroll(gui_window* g, unsigned long sx, unsigned long sy)
{
wimp_window_state state;
if (g == NULL)
return;
state.w = g->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)
state.yscroll += ro_theme_toolbar_height(current_theme);
ro_gui_window_open(g, (wimp_open*)&state);
}
unsigned long gui_window_get_width(gui_window* g)
{
wimp_window_state state;
state.w = g->window;
wimp_get_window_state(&state);
return browser_x_units(state.visible.x1 - state.visible.x0);
}
void gui_window_set_extent(gui_window* g, unsigned long width, unsigned long height)
{
os_box extent;
if (g == 0)
return;
extent.x0 = 0;
extent.y0 = ro_y_units(height);
if (extent.y0 > -960)
extent.y0 = -960;
extent.x1 = ro_x_units(width);
if ((g->data.browser.bw->flags & browser_TOOLBAR) != 0)
{
extent.y1 = ro_theme_toolbar_height(current_theme);
}
else
{
extent.y1 = 0;
}
wimp_set_extent(g->window, &extent);
}
void gui_window_set_status(gui_window* g, const char* text)
{
if (strcmp(g->status, text) != 0)
{
strncpy(g->status, text, 255);
wimp_set_icon_state(g->data.browser.toolbar, ro_theme_icon(current_theme, THEME_TOOLBAR, "TOOLBAR_STATUS"), 0, 0);
}
}
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);
}
void gui_window_message(gui_window* g, gui_message* msg)
{
if (g == NULL || msg == NULL)
return;
switch (msg->type)
{
case msg_SET_URL:
fprintf(stderr, "Set URL '%s'\n", msg->data.set_url.url);
strncpy(g->url, msg->data.set_url.url, 255);
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"));
}
break;
default:
break;
}
}
void ro_gui_window_open(gui_window* g, wimp_open* open)
{
if (g->type == GUI_BROWSER_WINDOW)
{
wimp_window_state state;
state.w = g->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);
}
if (g->data.browser.bw->current_content != 0) {
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),
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);
g->data.browser.old_width = width;
g->data.browser.reformat_pending = true;
gui_reformat_pending = true;
}
}
wimp_open_window(open);
if ((g->data.browser.bw->flags & browser_TOOLBAR) != 0)
{
wimp_outline outline;
wimp_window_state tstate;
outline.w = g->window;
wimp_get_window_outline(&outline);
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;
tstate.visible.y0 = tstate.visible.y1 - ro_theme_toolbar_height(current_theme);
tstate.xscroll = 0;
tstate.yscroll = 0;
tstate.next = wimp_TOP;
wimp_open_window_nested((wimp_open *) &tstate, g->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);
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);
}
}
} else {
wimp_open_window(open);
}
}
void ro_gui_throb(void)
{
gui_window* g;
float nowtime = (float) clock() / CLOCKS_PER_SEC;
for (g = window_list; g != NULL; g = g->next)
{
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);
}
}
}
}
}
}
gui_window* ro_lookup_gui_from_w(wimp_w window)
{
gui_window* g;
for (g = window_list; g != NULL; g = g->next)
{
if (g->type == GUI_BROWSER_WINDOW)
{
if (g->window == window)
{
return g;
}
}
}
return NULL;
}
gui_window* ro_lookup_gui_toolbar_from_w(wimp_w window)
{
gui_window* g;
for (g = window_list; g != NULL; g = g->next)
{
if (g->type == GUI_BROWSER_WINDOW)
{
if (g->data.browser.toolbar == window)
{
return g;
}
}
}
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;
if (g->redraw_safety != SAFE)
{
fprintf(stderr, "mouse at UNSAFE\n");
return;
}
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);
}
}
}
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"))
{
browser_window_open_location_historical(g->data.browser.bw,
g->data.browser.bw->url, 0, 0);
}
}
void ro_gui_window_click(gui_window* g, wimp_pointer* pointer)
{
struct browser_action msg;
int x,y;
wimp_window_state state;
if (g->redraw_safety != SAFE)
{
fprintf(stderr, "gui_window_click UNSAFE\n");
return;
}
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));
if (pointer->buttons == wimp_CLICK_MENU)
{
/* check for mouse gestures */
ro_gui_mouse_action(g);
}
else if (g->data.browser.bw->current_content != NULL)
{
if (g->data.browser.bw->current_content->type == CONTENT_HTML)
{
if (pointer->buttons == wimp_CLICK_SELECT)
{
msg.type = act_MOUSE_CLICK;
msg.data.mouse.x = x;
msg.data.mouse.y = y;
msg.data.mouse.buttons = act_BUTTON_NORMAL;
if (browser_window_action(g->data.browser.bw, &msg) == 1)
return;
msg.type = act_UNKNOWN;
}
if (pointer->buttons == wimp_CLICK_SELECT && g->data.browser.bw->current_content->data.html.text_selection.selected == 1)
msg.type = act_CLEAR_SELECTION;
else if (pointer->buttons == wimp_CLICK_ADJUST && g->data.browser.bw->current_content->data.html.text_selection.selected == 1)
msg.type = act_ALTER_SELECTION;
else if (pointer->buttons == wimp_DRAG_SELECT ||
pointer->buttons == wimp_DRAG_ADJUST)
{
msg.type = act_START_NEW_SELECTION;
if (pointer->buttons == wimp_DRAG_ADJUST && g->data.browser.bw->current_content->data.html.text_selection.selected == 1)
msg.type = act_ALTER_SELECTION;
ro_gui_start_selection(pointer, &state, g);
g->drag_status = drag_BROWSER_TEXT_SELECTION;
}
msg.data.mouse.x = x;
msg.data.mouse.y = y;
if (msg.type != act_UNKNOWN)
browser_window_action(g->data.browser.bw, &msg);
if (pointer->buttons == wimp_CLICK_ADJUST && g->data.browser.bw->current_content->data.html.text_selection.selected == 1)
{
current_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);
}
}
}
}
}
void gui_window_start_throbber(struct gui_window* g)
{
g->throbtime = (float) (clock() + 0) / CLOCKS_PER_SEC; /* workaround compiler warning */
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);
}
void gui_window_place_caret(gui_window *g, int x, int y, int height)
{
wimp_set_caret_position(g->window, -1,
x * 2, -(y + height) * 2, height * 2, -1);
}