[project @ 2004-02-25 15:12:57 by bursa]

Implement scaling; rewrite desktop/browser; add riscos/thumbnail; rewrite history.

svn path=/import/netsurf/; revision=566
This commit is contained in:
James Bursa 2004-02-25 15:12:58 +00:00
parent deaaa4a753
commit 7897a98a4c
37 changed files with 1449 additions and 1155 deletions

View File

@ -23,6 +23,8 @@ Home:Home page
Back:Back one page Back:Back one page
Forward:Forward one page Forward:Forward one page
Reload:Reload this page Reload:Reload this page
View:View
ScaleView:Scale view
Themes:Themes Themes:Themes
@ -42,3 +44,5 @@ cookiejar:<Choices$Write>.WWW.NetSurf.Cookies
ErrorPage:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"><html><head><title>Page error</title></head><body><h1>Sorry, NetSurf was unable to display this page</h1><p><strong>%s</strong></p></body></html> ErrorPage:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"><html><head><title>Page error</title></head><body><h1>Sorry, NetSurf was unable to display this page</h1><p><strong>%s</strong></p></body></html>
InvalidURL:The address <em>%s</em> could not be understood. InvalidURL:The address <em>%s</em> could not be understood.
NoMemory:NetSurf is running out of memory. Please free some memory and try again.

Binary file not shown.

View File

@ -2,7 +2,7 @@
* This file is part of NetSurf, http://netsurf.sourceforge.net/ * This file is part of NetSurf, http://netsurf.sourceforge.net/
* Licensed under the GNU General Public License, * Licensed under the GNU General Public License,
* http://www.opensource.org/licenses/gpl-license * http://www.opensource.org/licenses/gpl-license
* Copyright 2003 James Bursa <bursa@users.sourceforge.net> * Copyright 2004 James Bursa <bursa@users.sourceforge.net>
*/ */
/** \file /** \file
@ -90,7 +90,8 @@ struct handler_entry {
void (*destroy)(struct content *c); void (*destroy)(struct content *c);
void (*redraw)(struct content *c, long x, long y, void (*redraw)(struct content *c, long x, long y,
unsigned long width, unsigned long height, unsigned long width, unsigned long height,
long clip_x0, long clip_y0, long clip_x1, long clip_y1); long clip_x0, long clip_y0, long clip_x1, long clip_y1,
float scale);
void (*add_instance)(struct content *c, struct browser_window *bw, void (*add_instance)(struct content *c, struct browser_window *bw,
struct content *page, struct box *box, struct content *page, struct box *box,
struct object_params *params, void **state); struct object_params *params, void **state);
@ -256,7 +257,7 @@ void content_process_data(struct content *c, char *data, unsigned long size)
* (eg. loading images), the content gets status CONTENT_STATUS_READY, and a * (eg. loading images), the content gets status CONTENT_STATUS_READY, and a
* CONTENT_MSG_READY is sent to all users. * CONTENT_MSG_READY is sent to all users.
* - If the conversion succeeds and is complete, the content gets status * - If the conversion succeeds and is complete, the content gets status
* CONTENT_STATUS_DONE, and CONTENT_MSG_DONE is sent. * CONTENT_STATUS_DONE, and CONTENT_MSG_READY then CONTENT_MSG_DONE are sent.
* - If the conversion fails, CONTENT_MSG_ERROR is sent. The content is then * - If the conversion fails, CONTENT_MSG_ERROR is sent. The content is then
* destroyed and must no longer be used. * destroyed and must no longer be used.
*/ */
@ -278,9 +279,8 @@ void content_convert(struct content *c, unsigned long width, unsigned long heigh
} }
assert(c->status == CONTENT_STATUS_READY || assert(c->status == CONTENT_STATUS_READY ||
c->status == CONTENT_STATUS_DONE); c->status == CONTENT_STATUS_DONE);
if (c->status == CONTENT_STATUS_READY) content_broadcast(c, CONTENT_MSG_READY, 0);
content_broadcast(c, CONTENT_MSG_READY, 0); if (c->status == CONTENT_STATUS_DONE)
else
content_broadcast(c, CONTENT_MSG_DONE, 0); content_broadcast(c, CONTENT_MSG_DONE, 0);
} }
@ -379,12 +379,13 @@ void content_reset(struct content *c)
void content_redraw(struct content *c, long x, long y, void content_redraw(struct content *c, long x, long y,
unsigned long width, unsigned long height, unsigned long width, unsigned long height,
long clip_x0, long clip_y0, long clip_x1, long clip_y1) long clip_x0, long clip_y0, long clip_x1, long clip_y1,
float scale)
{ {
assert(c != 0); assert(c != 0);
if (handler_map[c->type].redraw != 0) if (handler_map[c->type].redraw != 0)
handler_map[c->type].redraw(c, x, y, width, height, handler_map[c->type].redraw(c, x, y, width, height,
clip_x0, clip_y0, clip_x1, clip_y1); clip_x0, clip_y0, clip_x1, clip_y1, scale);
} }

View File

@ -2,7 +2,7 @@
* This file is part of NetSurf, http://netsurf.sourceforge.net/ * This file is part of NetSurf, http://netsurf.sourceforge.net/
* Licensed under the GNU General Public License, * Licensed under the GNU General Public License,
* http://www.opensource.org/licenses/gpl-license * http://www.opensource.org/licenses/gpl-license
* Copyright 2003 James Bursa <bursa@users.sourceforge.net> * Copyright 2004 James Bursa <bursa@users.sourceforge.net>
* Copyright 2003 Philip Pemberton <philpem@users.sourceforge.net> * Copyright 2003 Philip Pemberton <philpem@users.sourceforge.net>
*/ */
@ -161,7 +161,8 @@ void content_destroy(struct content *c);
void content_reset(struct content *c); void content_reset(struct content *c);
void content_redraw(struct content *c, long x, long y, void content_redraw(struct content *c, long x, long y,
unsigned long width, unsigned long height, unsigned long width, unsigned long height,
long clip_x0, long clip_y0, long clip_x1, long clip_y1); long clip_x0, long clip_y0, long clip_x1, long clip_y1,
float scale);
void content_add_user(struct content *c, void content_add_user(struct content *c,
void (*callback)(content_msg msg, struct content *c, void *p1, void (*callback)(content_msg msg, struct content *c, void *p1,
void *p2, const char *error), void *p2, const char *error),

View File

@ -103,7 +103,8 @@ void plugin_decode(void *a, void *b, void *c, void *d)
void html_redraw(struct content *c, long x, long y, void html_redraw(struct content *c, long x, long y,
unsigned long width, unsigned long height, unsigned long width, unsigned long height,
long x0, long y0, long x1, long y1) long x0, long y0, long x1, long y1,
float scale)
{ {
} }

File diff suppressed because it is too large Load Diff

View File

@ -3,7 +3,11 @@
* Licensed under the GNU General Public License, * Licensed under the GNU General Public License,
* http://www.opensource.org/licenses/gpl-license * http://www.opensource.org/licenses/gpl-license
* Copyright 2003 Phil Mellor <monkeyson@users.sourceforge.net> * Copyright 2003 Phil Mellor <monkeyson@users.sourceforge.net>
* Copyright 2003 James Bursa <bursa@users.sourceforge.net> * Copyright 2004 James Bursa <bursa@users.sourceforge.net>
*/
/** \file
* Browser window creation and manipulation (interface).
*/ */
#ifndef _NETSURF_DESKTOP_BROWSER_H_ #ifndef _NETSURF_DESKTOP_BROWSER_H_
@ -14,47 +18,39 @@
#include "netsurf/utils/config.h" #include "netsurf/utils/config.h"
#include "netsurf/content/content.h" #include "netsurf/content/content.h"
#include "netsurf/desktop/gui.h" #include "netsurf/desktop/gui.h"
#include "netsurf/render/box.h"
typedef int browser_window_flags; struct box;
#define browser_TOOLBAR ((browser_window_flags) 1) struct history;
#define browser_TITLE ((browser_window_flags) 2)
#define browser_SCROLL_X_NONE ((browser_window_flags) 4)
#define browser_SCROLL_X_AUTO ((browser_window_flags) 8)
#define browser_SCROLL_X_ALWAYS ((browser_window_flags) 16)
#define browser_SCROLL_Y_NONE ((browser_window_flags) 32)
#define browser_SCROLL_Y_AUTO ((browser_window_flags) 64)
#define browser_SCROLL_Y_ALWAYS ((browser_window_flags) 128)
typedef int action_buttons;
#define act_BUTTON_NORMAL ((action_buttons) 4)
#define act_BUTTON_ALTERNATIVE ((action_buttons) 1)
#define act_BUTTON_CONTEXT_MENU ((action_buttons) 2)
struct history_entry;
/** Browser window data. */
struct browser_window struct browser_window
{ {
unsigned long format_width; /** Page currently displayed, or 0. Must have status READY or DONE. */
unsigned long format_height; struct content *current_content;
struct { int mult; int div; } scale; /** Instance state pointer for current_content. */
void *current_content_state;
/** Page being loaded, or 0. */
struct content *loading_content;
struct content* current_content; /** Window history structure. */
void *current_content_state; struct history *history;
struct content* loading_content;
struct history_entry *history_entry;
bool history_add;
clock_t time0;
char* url; /** Handler for keyboard input, or 0. */
void (*caret_callback)(struct browser_window *bw, char key, void *p);
/** User parameter for caret_callback. */
void *caret_p;
browser_window_flags flags; /** Platform specific window handle. */
gui_window* window; gui_window *window;
/** Busy indicator is active. */
bool throbbing;
/** Add loading_content to the window history when it loads. */
bool history_add;
/** Start time of fetching loading_content. */
clock_t time0;
int throbbing;
void (*caret_callback)(struct browser_window *bw, char key, void *p);
void *caret_p;
#ifdef WITH_FRAMES #ifdef WITH_FRAMES
struct browser_window *parent; struct browser_window *parent;
unsigned int no_children; unsigned int no_children;
@ -75,7 +71,6 @@ struct browser_action
struct { struct {
unsigned long x; unsigned long x;
unsigned long y; unsigned long y;
action_buttons buttons;
} mouse; } mouse;
struct { struct {
struct form_control* g; struct form_control* g;
@ -92,32 +87,21 @@ struct box_selection
int plot_index; int plot_index;
}; };
/* public functions */
struct browser_window* create_browser_window(int flags, int width, int height void browser_window_create(const char *url);
#ifdef WITH_FRAMES void browser_window_go(struct browser_window *bw, const char *url);
, struct browser_window *parent void browser_window_go_post(struct browser_window *bw, const char *url,
#endif char *post_urlenc,
); struct form_successful_control *post_multipart,
void browser_window_destroy(struct browser_window* bw bool history_add);
#ifdef WITH_FRAMES void browser_window_stop(struct browser_window *bw);
, bool self void browser_window_destroy(struct browser_window *bw);
#endif
);
void browser_window_open_location(struct browser_window* bw, const char* url);
void browser_window_open_location_historical(struct browser_window* bw,
const char* url
#ifdef WITH_POST
, char *post_urlenc,
struct form_successful_control *post_multipart
#endif
);
int browser_window_action(struct browser_window* bw, struct browser_action* act);
void browser_window_set_status(struct browser_window* bw, const char* text);
void browser_window_back(struct browser_window* bw); void browser_window_back(struct browser_window* bw);
void browser_window_forward(struct browser_window* bw); void browser_window_forward(struct browser_window* bw);
int browser_window_action(struct browser_window* bw, struct browser_action* act);
void box_under_area(struct box* box, unsigned long x, unsigned long y, unsigned long ox, unsigned long oy, void box_under_area(struct box* box, unsigned long x, unsigned long y, unsigned long ox, unsigned long oy,
struct box_selection** found, int* count, int* plot_index); struct box_selection** found, int* count, int* plot_index);
@ -128,12 +112,12 @@ int box_position_distance(struct box_position* x, struct box_position* y);
void gui_redraw_gadget(struct browser_window* bw, struct form_control* g); void gui_redraw_gadget(struct browser_window* bw, struct form_control* g);
void browser_window_stop_throbber(struct browser_window* bw);
void browser_window_reformat(struct browser_window* bw, int scroll_to_top);
bool browser_window_key_press(struct browser_window *bw, char key); bool browser_window_key_press(struct browser_window *bw, char key);
struct history_entry * history_add(struct history_entry *current, /* In platform specific history.c. */
char *url, char *title); struct history *history_create(void);
void history_add(struct history *history, struct content *content);
void history_update(struct history *history, struct content *content);
void history_destroy(struct history *history);
#endif #endif

View File

@ -3,15 +3,16 @@
* Licensed under the GNU General Public License, * Licensed under the GNU General Public License,
* http://www.opensource.org/licenses/gpl-license * http://www.opensource.org/licenses/gpl-license
* Copyright 2003 Phil Mellor <monkeyson@users.sourceforge.net> * Copyright 2003 Phil Mellor <monkeyson@users.sourceforge.net>
* Copyright 2003 James Bursa <bursa@users.sourceforge.net> * Copyright 2004 James Bursa <bursa@users.sourceforge.net>
*/
/** \file
* Interface to platform-specific gui functions.
*/ */
#ifndef _NETSURF_DESKTOP_GUI_H_ #ifndef _NETSURF_DESKTOP_GUI_H_
#define _NETSURF_DESKTOP_GUI_H_ #define _NETSURF_DESKTOP_GUI_H_
typedef enum { GUI_BROWSER_WINDOW, GUI_DOWNLOAD_WINDOW } gui_window_type;
typedef enum { SAFE, UNSAFE } gui_safety;
struct gui_window; struct gui_window;
typedef struct gui_window gui_window; typedef struct gui_window gui_window;
@ -43,8 +44,6 @@ void gui_multitask(void);
void gui_poll(bool active); void gui_poll(bool active);
void gui_quit(void); void gui_quit(void);
gui_safety gui_window_set_redraw_safety(gui_window* g, gui_safety s);
void gui_window_start_throbber(gui_window* g); void gui_window_start_throbber(gui_window* g);
void gui_window_stop_throbber(gui_window* g); void gui_window_stop_throbber(gui_window* g);
@ -52,4 +51,6 @@ void gui_gadget_combo(struct browser_window* bw, struct form_control* g, unsigne
void gui_window_place_caret(gui_window *g, int x, int y, int height); void gui_window_place_caret(gui_window *g, int x, int y, int height);
void warn_user(const char *warning);
#endif #endif

View File

@ -18,7 +18,7 @@ OBJECTS = $(OBJECTS_COMMON) \
textselection.o theme.o window.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 url.o history.o \ about.o filetype.o font.o uri.o url.o history.o \
version.o save_draw.o save_complete.o version.o save_draw.o save_complete.o thumbnail.o
OBJECTS_DEBUG = $(OBJECTS_COMMON) \ OBJECTS_DEBUG = $(OBJECTS_COMMON) \
netsurfd.o \ netsurfd.o \
options.o filetyped.o fontd.o options.o filetyped.o fontd.o

View File

@ -102,6 +102,7 @@ void html_remove_instance(struct content *c, struct browser_window *bw,
/* in riscos/htmlredraw.c */ /* in riscos/htmlredraw.c */
void html_redraw(struct content *c, long x, long y, void html_redraw(struct content *c, long x, long y,
unsigned long width, unsigned long height, unsigned long width, unsigned long height,
long clip_x0, long clip_y0, long clip_x1, long clip_y1); long clip_x0, long clip_y0, long clip_x1, long clip_y1,
float scale);
#endif #endif

View File

@ -117,7 +117,7 @@ bool ro_gui_401login_keypress(wimp_key *key) {
case wimp_KEY_RETURN: case wimp_KEY_RETURN:
get_unamepwd(); get_unamepwd();
ro_gui_dialog_close(dialog_401li); ro_gui_dialog_close(dialog_401li);
browser_window_open_location(bwin, url); browser_window_go(bwin, url);
return true; return true;
case wimp_KEY_ESCAPE: case wimp_KEY_ESCAPE:
ro_gui_dialog_close(dialog_401li); ro_gui_dialog_close(dialog_401li);
@ -139,7 +139,7 @@ void ro_gui_401login_click(wimp_pointer *pointer) {
case ICON_401LOGIN_LOGIN: case ICON_401LOGIN_LOGIN:
get_unamepwd(); get_unamepwd();
ro_gui_dialog_close(dialog_401li); ro_gui_dialog_close(dialog_401li);
browser_window_open_location(bwin, url); browser_window_go(bwin, url);
break; break;
case ICON_401LOGIN_CANCEL: case ICON_401LOGIN_CANCEL:
ro_gui_dialog_close(dialog_401li); ro_gui_dialog_close(dialog_401li);

View File

@ -25,10 +25,11 @@
#include "netsurf/utils/utils.h" #include "netsurf/utils/utils.h"
wimp_w dialog_info, dialog_saveas, dialog_config, dialog_config_br, wimp_w dialog_info, dialog_saveas, dialog_config, dialog_config_br,
dialog_config_prox, dialog_config_th, download_template dialog_config_prox, dialog_config_th, download_template,
#ifdef WITH_AUTH #ifdef WITH_AUTH
,dialog_401li dialog_401li,
#endif #endif
dialog_zoom;
; ;
wimp_menu* theme_menu = NULL; wimp_menu* theme_menu = NULL;
@ -41,6 +42,7 @@ static void ro_gui_dialog_click_config_br(wimp_pointer *pointer);
static void ro_gui_dialog_update_config_br(void); static void ro_gui_dialog_update_config_br(void);
static void ro_gui_dialog_click_config_prox(wimp_pointer *pointer); static void ro_gui_dialog_click_config_prox(wimp_pointer *pointer);
static void ro_gui_dialog_click_config_th(wimp_pointer *pointer); static void ro_gui_dialog_click_config_th(wimp_pointer *pointer);
static void ro_gui_dialog_click_zoom(wimp_pointer *pointer);
static void set_browser_choices(void); static void set_browser_choices(void);
static void get_browser_choices(void); static void get_browser_choices(void);
static void set_proxy_choices(void); static void set_proxy_choices(void);
@ -73,6 +75,7 @@ void ro_gui_dialog_init(void)
dialog_config_br = ro_gui_dialog_create("config_br"); dialog_config_br = ro_gui_dialog_create("config_br");
dialog_config_prox = ro_gui_dialog_create("config_prox"); dialog_config_prox = ro_gui_dialog_create("config_prox");
dialog_config_th = ro_gui_dialog_create("config_th"); dialog_config_th = ro_gui_dialog_create("config_th");
dialog_zoom = ro_gui_dialog_create("zoom");
set_browser_choices(); set_browser_choices();
set_proxy_choices(); set_proxy_choices();
@ -176,6 +179,8 @@ void ro_gui_dialog_click(wimp_pointer *pointer)
else if (pointer->w == dialog_401li) else if (pointer->w == dialog_401li)
ro_gui_401login_click(pointer); ro_gui_401login_click(pointer);
#endif #endif
else if (pointer->w == dialog_zoom)
ro_gui_dialog_click_zoom(pointer);
} }
@ -243,14 +248,7 @@ void ro_gui_dialog_click_config_br(wimp_pointer *pointer)
set_browser_choices(); set_browser_choices();
break; break;
case ICON_CONFIG_BR_EXPLAIN: case ICON_CONFIG_BR_EXPLAIN:
bw = create_browser_window(browser_TITLE | browser_TOOLBAR | browser_window_create(GESTURES_URL);
browser_SCROLL_X_ALWAYS | browser_SCROLL_Y_ALWAYS, 320, 256
#ifdef WITH_FRAMES
, NULL
#endif
);
gui_window_show(bw->window);
browser_window_open_location(bw, GESTURES_URL);
break; break;
case ICON_CONFIG_BR_FONTSIZE_DEC: case ICON_CONFIG_BR_FONTSIZE_DEC:
if (font_size == 50) if (font_size == 50)
@ -295,8 +293,6 @@ void ro_gui_dialog_update_config_br(void)
set_icon_string(dialog_config_br, ICON_CONFIG_BR_FONTSIZE, s); set_icon_string(dialog_config_br, ICON_CONFIG_BR_FONTSIZE, s);
sprintf(s, "%i.%ipt", font_min_size / 10, font_min_size % 10); sprintf(s, "%i.%ipt", font_min_size / 10, font_min_size % 10);
set_icon_string(dialog_config_br, ICON_CONFIG_BR_MINSIZE, s); set_icon_string(dialog_config_br, ICON_CONFIG_BR_MINSIZE, s);
wimp_set_icon_state(dialog_config_br, ICON_CONFIG_BR_FONTSIZE, 0, 0);
wimp_set_icon_state(dialog_config_br, ICON_CONFIG_BR_MINSIZE, 0, 0);
} }
@ -348,19 +344,49 @@ void ro_gui_dialog_click_config_th(wimp_pointer *pointer)
os_cli("Filer_OpenDir " THEMES_DIR); os_cli("Filer_OpenDir " THEMES_DIR);
break; break;
case ICON_CONFIG_TH_GET: case ICON_CONFIG_TH_GET:
bw = create_browser_window(browser_TITLE | browser_TOOLBAR | browser_window_create(THEMES_URL);
browser_SCROLL_X_ALWAYS | browser_SCROLL_Y_ALWAYS, 480, 320
#ifdef WITH_FRAMES
, NULL
#endif
);
gui_window_show(bw->window);
browser_window_open_location(bw, THEMES_URL);
break; break;
} }
} }
/**
* Handle clicks in the Scale view dialog.
*/
void ro_gui_dialog_click_zoom(wimp_pointer *pointer)
{
unsigned int scale;
scale = atoi(get_icon_string(dialog_zoom, ICON_ZOOM_VALUE));
switch (pointer->i) {
case ICON_ZOOM_DEC: scale -= 10; break;
case ICON_ZOOM_INC: scale += 10; break;
case ICON_ZOOM_50: scale = 50; break;
case ICON_ZOOM_80: scale = 80; break;
case ICON_ZOOM_100: scale = 100; break;
case ICON_ZOOM_120: scale = 120; break;
}
if (scale < 10)
scale = 10;
else if (500 < scale)
scale = 500;
set_icon_string_i(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;
gui_reformat_pending = true;
}
if (pointer->buttons == wimp_CLICK_SELECT &&
(pointer->i == ICON_ZOOM_CANCEL ||
pointer->i == ICON_ZOOM_OK))
wimp_create_menu(wimp_CLOSE_MENU, 0, 0);
}
/** /**
* Close a dialog box. * Close a dialog box.
*/ */
@ -637,9 +663,7 @@ void ro_gui_theme_menu_selection(char *theme)
{ {
set_icon_string(dialog_config_th, ICON_CONFIG_TH_NAME, theme); set_icon_string(dialog_config_th, ICON_CONFIG_TH_NAME, theme);
load_theme_preview(theme); load_theme_preview(theme);
wimp_set_icon_state(dialog_config_th, ICON_CONFIG_TH_NAME, 0, 0);
wimp_set_icon_state(dialog_config_th, ICON_CONFIG_TH_PREVIEW, 0, 0); wimp_set_icon_state(dialog_config_th, ICON_CONFIG_TH_PREVIEW, 0, 0);
} }
int file_exists(const char* base, const char* dir, const char* leaf, bits ftype) int file_exists(const char* base, const char* dir, const char* leaf, bits ftype)
@ -695,6 +719,7 @@ void set_icon_string(wimp_w w, wimp_i i, const char *text)
wimp_get_icon_state(&ic); wimp_get_icon_state(&ic);
strncpy(ic.icon.data.indirected_text.text, text, strncpy(ic.icon.data.indirected_text.text, text,
(unsigned int)ic.icon.data.indirected_text.size); (unsigned int)ic.icon.data.indirected_text.size);
wimp_set_icon_state(w, i, 0, 0);
} }
char* get_icon_string(wimp_w w, wimp_i i) char* get_icon_string(wimp_w w, wimp_i i)

View File

@ -92,7 +92,8 @@ void draw_destroy(struct content *c)
void draw_redraw(struct content *c, long x, long y, void draw_redraw(struct content *c, long x, long y,
unsigned long width, unsigned long height, unsigned long width, unsigned long height,
long clip_x0, long clip_y0, long clip_x1, long clip_y1) long clip_x0, long clip_y0, long clip_x1, long clip_y1,
float scale)
{ {
os_trfm *matrix = xcalloc(1, sizeof(os_trfm)); os_trfm *matrix = xcalloc(1, sizeof(os_trfm));

View File

@ -25,5 +25,6 @@ void draw_reformat(struct content *c, unsigned int width, unsigned int height);
void draw_destroy(struct content *c); void draw_destroy(struct content *c);
void draw_redraw(struct content *c, long x, long y, void draw_redraw(struct content *c, long x, long y,
unsigned long width, unsigned long height, unsigned long width, unsigned long height,
long clip_x0, long clip_y0, long clip_x1, long clip_y1); long clip_x0, long clip_y0, long clip_x1, long clip_y1,
float scale);
#endif #endif

View File

@ -76,7 +76,6 @@ void frame_add_instance(struct content *c, struct browser_window *parent,
g->type = GUI_BROWSER_WINDOW; g->type = GUI_BROWSER_WINDOW;
g->data.browser.bw = bw; g->data.browser.bw = bw;
g->data.browser.toolbar = 0; g->data.browser.toolbar = 0;
g->redraw_safety = SAFE;
g->data.browser.reformat_pending = false; g->data.browser.reformat_pending = false;
g->data.browser.old_width = 0; g->data.browser.old_width = 0;

View File

@ -133,7 +133,8 @@ void nsgif_reformat(struct content *c, unsigned int width, unsigned int height)
void nsgif_redraw(struct content *c, long x, long y, void nsgif_redraw(struct content *c, long x, long y,
unsigned long width, unsigned long height, unsigned long width, unsigned long height,
long clip_x0, long clip_y0, long clip_x1, long clip_y1) long clip_x0, long clip_y0, long clip_x1, long clip_y1,
float scale)
{ {
unsigned int size; unsigned int size;
osspriteop_trans_tab *table; osspriteop_trans_tab *table;

View File

@ -29,5 +29,6 @@ void nsgif_reformat(struct content *c, unsigned int width, unsigned int height);
void nsgif_destroy(struct content *c); void nsgif_destroy(struct content *c);
void nsgif_redraw(struct content *c, long x, long y, void nsgif_redraw(struct content *c, long x, long y,
unsigned long width, unsigned long height, unsigned long width, unsigned long height,
long clip_x0, long clip_y0, long clip_x1, long clip_y1); long clip_x0, long clip_y0, long clip_x1, long clip_y1,
float scale);
#endif #endif

View File

@ -245,7 +245,8 @@ void gui_poll(bool active)
for (g = window_list; g; g = g->next) { for (g = window_list; g; g = g->next) {
if (g->type == GUI_BROWSER_WINDOW && g->data.browser.reformat_pending) { if (g->type == GUI_BROWSER_WINDOW && g->data.browser.reformat_pending) {
content_reformat(g->data.browser.bw->current_content, content_reformat(g->data.browser.bw->current_content,
browser_x_units(g->data.browser.old_width), 1000); g->data.browser.old_width / 2 / g->scale,
1000);
g->data.browser.reformat_pending = false; g->data.browser.reformat_pending = false;
} }
} }
@ -475,14 +476,9 @@ void ro_gui_mouse_click(wimp_pointer *pointer)
ro_gui_icon_bar_click(pointer); ro_gui_icon_bar_click(pointer);
else if (pointer->w == history_window) else if (pointer->w == history_window)
ro_gui_history_click(pointer); ro_gui_history_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 && else if (g && g->type == GUI_BROWSER_WINDOW &&
g->window == pointer->w) {
if (g->redraw_safety == SAFE)
ro_gui_window_click(g, pointer);
else
ro_gui_poll_queue(wimp_MOUSE_CLICK,
(wimp_block *) pointer);
} else if (g && g->type == GUI_BROWSER_WINDOW &&
g->data.browser.toolbar == pointer->w) g->data.browser.toolbar == pointer->w)
ro_gui_toolbar_click(g, pointer); ro_gui_toolbar_click(g, pointer);
else if (g && g->type == GUI_DOWNLOAD_WINDOW) else if (g && g->type == GUI_DOWNLOAD_WINDOW)
@ -502,21 +498,7 @@ void ro_gui_icon_bar_click(wimp_pointer *pointer)
ro_gui_create_menu(iconbar_menu, pointer->pos.x - 64, ro_gui_create_menu(iconbar_menu, pointer->pos.x - 64,
96 + iconbar_menu_height, NULL); 96 + iconbar_menu_height, NULL);
} else if (pointer->buttons == wimp_CLICK_SELECT) { } else if (pointer->buttons == wimp_CLICK_SELECT) {
struct browser_window *bw; browser_window_create(HOME_URL);
bw = create_browser_window(browser_TITLE | browser_TOOLBAR
| browser_SCROLL_X_ALWAYS |
browser_SCROLL_Y_ALWAYS, 640,
480
#ifdef WITH_FRAMES
, NULL
#endif
);
gui_window_show(bw->window);
browser_window_open_location(bw, HOME_URL);
wimp_set_caret_position(bw->window->data.browser.toolbar,
ICON_TOOLBAR_URL,
0, 0, -1,
(int) strlen(bw->window->url));
} }
} }
@ -690,8 +672,8 @@ void ro_msg_datasave(wimp_message* block)
state.w = data->w; state.w = data->w;
wimp_get_window_state(&state); wimp_get_window_state(&state);
x = browser_x_units(window_x_units(data->pos.x, &state)); x = window_x_units(data->pos.x, &state) / 2;
y = browser_y_units(window_y_units(data->pos.y, &state)); y = -window_y_units(data->pos.y, &state) / 2;
found = 0; found = 0;
click_boxes = NULL; click_boxes = NULL;
@ -745,8 +727,8 @@ void ro_msg_dataload(wimp_message* block)
state.w = data->w; state.w = data->w;
wimp_get_window_state(&state); wimp_get_window_state(&state);
x = browser_x_units(window_x_units(data->pos.x, &state)); x = window_x_units(data->pos.x, &state) / 2;
y = browser_y_units(window_y_units(data->pos.y, &state)); y = -window_y_units(data->pos.y, &state) / 2;
found = 0; found = 0;
click_boxes = NULL; click_boxes = NULL;
@ -832,7 +814,6 @@ int ro_save_data(void *data, unsigned long length, char *file_name, bits file_ty
void ro_msg_dataopen(wimp_message *message) void ro_msg_dataopen(wimp_message *message)
{ {
char *url; char *url;
struct browser_window *bw;
if (message->data.data_xfer.file_type != 0xfaf) if (message->data.data_xfer.file_type != 0xfaf)
/* ignore all but HTML */ /* ignore all but HTML */
@ -844,15 +825,8 @@ void ro_msg_dataopen(wimp_message *message)
wimp_send_message(wimp_USER_MESSAGE, message, message->sender); wimp_send_message(wimp_USER_MESSAGE, message, message->sender);
/* create a new window with the file */ /* create a new window with the file */
bw = create_browser_window(browser_TITLE | browser_TOOLBAR |
browser_SCROLL_X_ALWAYS | browser_SCROLL_Y_ALWAYS, 640, 480
#ifdef WITH_FRAMES
, NULL
#endif
);
gui_window_show(bw->window);
url = ro_path_to_url(message->data.data_xfer.file_name); url = ro_path_to_url(message->data.data_xfer.file_name);
browser_window_open_location(bw, url); browser_window_create(url);
free(url); free(url);
} }
@ -888,21 +862,9 @@ void ro_gui_screen_size(int *width, int *height)
} }
void ro_gui_open_help_page (void) void ro_gui_open_help_page(void)
{ {
struct browser_window *bw; browser_window_create(HELP_URL);
bw = create_browser_window(browser_TITLE | browser_TOOLBAR |
browser_SCROLL_X_ALWAYS |
browser_SCROLL_Y_ALWAYS, 640, 480
#ifdef WITH_FRAMES
, NULL
#endif
);
gui_window_show(bw->window);
browser_window_open_location(bw, HELP_URL);
wimp_set_caret_position(bw->window->data.browser.toolbar,
ICON_TOOLBAR_URL,
0,0,-1, (int) strlen(bw->window->url));
} }
@ -985,32 +947,24 @@ void ro_gui_drag_box_start(wimp_pointer *pointer)
} }
int ro_x_units(unsigned long browser_units)
{
return (browser_units << 1);
}
int ro_y_units(unsigned long browser_units) static os_error warn_error = { 1, "" };
{
return -(browser_units << 1);
}
unsigned long browser_x_units(int ro_units)
{
return (ro_units >> 1);
}
unsigned long browser_y_units(int ro_units) /**
{ * Display a warning for a serious problem (eg memory exhaustion).
return -(ro_units >> 1); *
} * \param warning message key for warning message
*/
int window_x_units(int scr_units, wimp_window_state* win) void warn_user(const char *warning)
{ {
return scr_units - (win->visible.x0 - win->xscroll); strncpy(warn_error.errmess, messages_get(warning), 252);
} /** \todo get rid of cancel button, appears for unknown reason */
xwimp_report_error_by_category(&warn_error,
int window_y_units(int scr_units, wimp_window_state* win) wimp_ERROR_BOX_OK_ICON |
{ wimp_ERROR_BOX_GIVEN_CATEGORY |
return scr_units - (win->visible.y1 - win->yscroll); wimp_ERROR_BOX_CATEGORY_PROGRAM,
"NetSurf", "!netsurf",
(osspriteop_area *) 1, 0, 0);
} }

View File

@ -20,15 +20,17 @@
#define THEMES_DIR "<NetSurf$Dir>.Themes" #define THEMES_DIR "<NetSurf$Dir>.Themes"
extern wimp_w dialog_info, dialog_saveas, dialog_config, dialog_config_br, extern wimp_w dialog_info, dialog_saveas, dialog_config, dialog_config_br,
dialog_config_prox, dialog_config_th; dialog_config_prox, dialog_config_th, dialog_zoom;
extern wimp_w history_window; extern wimp_w history_window;
extern wimp_menu *current_menu, *iconbar_menu, *browser_menu, extern wimp_menu *iconbar_menu, *browser_menu, *combo_menu, *theme_menu;
*combo_menu, *theme_menu; extern int iconbar_menu_height;
extern int current_menu_x, current_menu_y, iconbar_menu_height;
extern struct form_control *current_gadget; extern struct form_control *current_gadget;
extern gui_window *window_list; extern gui_window *window_list;
extern bool gui_reformat_pending; extern bool gui_reformat_pending;
extern bool gui_redraw_debug; extern bool gui_redraw_debug;
extern gui_window *current_gui;
typedef enum { GUI_BROWSER_WINDOW, GUI_DOWNLOAD_WINDOW } gui_window_type;
struct gui_window struct gui_window
{ {
@ -67,8 +69,9 @@ struct gui_window
char throb_buf[12]; char throb_buf[12];
float throbtime; float throbtime;
gui_safety redraw_safety;
enum { drag_NONE, drag_UNKNOWN, drag_BROWSER_TEXT_SELECTION } drag_status; enum { drag_NONE, drag_UNKNOWN, drag_BROWSER_TEXT_SELECTION } drag_status;
float scale;
}; };
struct ro_gui_drag_info struct ro_gui_drag_info
@ -89,12 +92,6 @@ struct ro_gui_drag_info
}; };
/* in gui.c */ /* in gui.c */
int ro_x_units(unsigned long browser_units);
int ro_y_units(unsigned long browser_units);
unsigned long browser_x_units(int ro_units);
unsigned long browser_y_units(int ro_units);
int window_x_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); void ro_gui_screen_size(int *width, int *height);
@ -152,12 +149,14 @@ gui_window* ro_lookup_gui_toolbar_from_w(wimp_w window);
gui_window *ro_gui_window_lookup(wimp_w w); gui_window *ro_gui_window_lookup(wimp_w w);
bool ro_gui_window_keypress(gui_window *g, int key, bool toolbar); bool ro_gui_window_keypress(gui_window *g, int key, bool toolbar);
void ro_gui_scroll_request(wimp_scroll *scroll); void ro_gui_scroll_request(wimp_scroll *scroll);
int window_x_units(int x, wimp_window_state *state);
int window_y_units(int y, wimp_window_state *state);
/* in history.c */ /* in history.c */
void ro_gui_history_init(void); void ro_gui_history_init(void);
void ro_gui_history_quit(void); void ro_gui_history_quit(void);
void ro_gui_history_open(struct browser_window *bw, void ro_gui_history_open(struct browser_window *bw,
struct history_entry *entry, int wx, int wy); struct history *history, int wx, int wy);
void ro_gui_history_redraw(wimp_draw *redraw); void ro_gui_history_redraw(wimp_draw *redraw);
void ro_gui_history_click(wimp_pointer *pointer); void ro_gui_history_click(wimp_pointer *pointer);
@ -223,4 +222,14 @@ void ro_gui_history_click(wimp_pointer *pointer);
#define ICON_401LOGIN_USERNAME 4 #define ICON_401LOGIN_USERNAME 4
#define ICON_401LOGIN_PASSWORD 5 #define ICON_401LOGIN_PASSWORD 5
#define ICON_ZOOM_VALUE 1
#define ICON_ZOOM_DEC 2
#define ICON_ZOOM_INC 3
#define ICON_ZOOM_50 5
#define ICON_ZOOM_80 6
#define ICON_ZOOM_100 7
#define ICON_ZOOM_120 8
#define ICON_ZOOM_CANCEL 9
#define ICON_ZOOM_OK 10
#endif #endif

View File

@ -2,41 +2,61 @@
* This file is part of NetSurf, http://netsurf.sourceforge.net/ * This file is part of NetSurf, http://netsurf.sourceforge.net/
* Licensed under the GNU General Public License, * Licensed under the GNU General Public License,
* http://www.opensource.org/licenses/gpl-license * http://www.opensource.org/licenses/gpl-license
* Copyright 2003 James Bursa <bursa@users.sourceforge.net> * Copyright 2004 James Bursa <bursa@users.sourceforge.net>
*/
/** \file
* Browser history tree and window (implementation).
*/ */
#include <stdbool.h> #include <stdbool.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h>
#include "oslib/colourtrans.h" #include "oslib/colourtrans.h"
#include "oslib/font.h" #include "oslib/font.h"
#include "oslib/wimp.h" #include "oslib/wimp.h"
#include "netsurf/utils/config.h"
#include "netsurf/riscos/gui.h" #include "netsurf/riscos/gui.h"
#include "netsurf/riscos/thumbnail.h"
#include "netsurf/utils/log.h" #include "netsurf/utils/log.h"
#include "netsurf/utils/utils.h" #include "netsurf/utils/utils.h"
#define SIZE 10 #define SIZE 10
#define WIDTH 300 #define WIDTH 200
#define HEIGHT 100 #define HEIGHT 150
#define MARGIN 32 #define MARGIN 32
#define FULL_WIDTH (WIDTH + MARGIN + MARGIN)
#define FULL_HEIGHT (HEIGHT + MARGIN + MARGIN)
#define SPRITE_SIZE (16 + 44 + ((WIDTH / 2 + 3) & ~3) * HEIGHT / 2)
/** A node in the history tree. */ /** A node in the history tree. */
struct history_entry { struct history_entry {
char *url; /**< Page URL. */ char *url; /**< Page URL. */
char *title; /**< Page title. */ char *title; /**< Page title. */
struct history_entry *back; struct history_entry *back; /**< Parent. */
struct history_entry *forward, *forward_pref, *forward_last; struct history_entry *next; /**< Next sibling. */
struct history_entry *prev, *next; struct history_entry *forward; /**< First child. */
unsigned int children; struct history_entry *forward_pref; /**< Child in direction of
current entry. */
struct history_entry *forward_last; /**< Last child. */
unsigned int children; /**< Number of children. */
int x, y, width; int x, y, width;
osspriteop_area *sprite_area; /**< Thumbnail sprite area, or 0. */
};
/** History tree for a window. */
struct history {
/** First page in tree (page that window opened with). */
struct history_entry *start;
/** Current position in tree. */
struct history_entry *current;
}; };
static struct browser_window *history_bw; static struct browser_window *history_bw;
static struct history_entry *history_start; static struct history *history_current;
static struct history_entry *history_current;
wimp_w history_window; wimp_w history_window;
font_f history_font; font_f history_font;
static void history_free_entry(struct history_entry *entry);
static void ro_gui_history_redraw_tree(struct history_entry *he, static void ro_gui_history_redraw_tree(struct history_entry *he,
int x0, int y0); int x0, int y0);
static struct history_entry * ro_gui_history_click_find(struct history_entry *he, static struct history_entry * ro_gui_history_click_find(struct history_entry *he,
@ -44,46 +64,169 @@ static struct history_entry * ro_gui_history_click_find(struct history_entry *he
/** /**
* Insert a url into the history tree. * Create a new history tree for a window.
* *
* Takes a copy of the url and title and inserts an entry into the tree forward * \return pointer to an opaque history structure, 0 on failure.
* from current, returning the new entry. current may be 0 to start a new tree.
*/ */
struct history_entry * history_add(struct history_entry *current, struct history *history_create(void)
char *url, char *title)
{ {
struct history_entry *entry = xcalloc(1, sizeof(*entry)); struct history *history;
history = malloc(sizeof *history);
if (!history) {
warn_user("NoMemory");
return 0;
}
history->start = 0;
history->current = 0;
return history;
}
/**
* Insert a url into the history tree.
*
* \param history opaque history structure, as returned by history_create()
* \param content content to add to history
*
* The page is added after the current entry and becomes current.
*/
void history_add(struct history *history, struct content *content)
{
struct history_entry *entry;
char *url;
char *title;
char *split; char *split;
int width; int width;
osspriteop_area *area;
os_error *error;
font_scan_string(history_font, title, font_GIVEN_FONT | font_KERN, if (!history)
(WIDTH - MARGIN - MARGIN) * 400, 0x7fffffff, return;
0, 0, 0, &split, &width, 0, 0);
entry->url = xstrdup(url); /* allocate space */
entry->title = xstrdup(title); entry = malloc(sizeof *entry);
if (entry->title[split - title]) { url = strdup(content->url);
entry->title[split - title - 2] = 0x8c; /* ellipsis */ title = strdup(content->title ? content->title : url);
entry->title[split - title - 1] = 0; if (!entry || !url || !title) {
warn_user("NoMemory");
free(entry);
free(url);
free(title);
return;
} }
entry->back = current;
entry->forward = entry->forward_pref = entry->forward_last = 0; /* truncate title to available width */
font_scan_string(history_font, title, font_GIVEN_FONT | font_KERN,
WIDTH * 400, 0x7fffffff,
0, 0, 0, &split, &width, 0, 0);
if (title[split - title]) {
title[split - title - 2] = 0x8c; /* ellipsis */
title[split - title - 1] = 0;
}
entry->url = url;
entry->title = title;
entry->back = history->current;
entry->next = 0; entry->next = 0;
entry->forward = entry->forward_pref = entry->forward_last = 0;
entry->children = 0; entry->children = 0;
entry->width = width / 400; entry->width = width / 400;
if (current) { entry->sprite_area = 0;
entry->prev = current->forward_last; if (history->current) {
if (current->forward_last) if (history->current->forward_last)
current->forward_last->next = entry; history->current->forward_last->next = entry;
else else
current->forward = entry; history->current->forward = entry;
current->forward_pref = current->forward_last = entry; history->current->forward_pref = entry;
current->children++; history->current->forward_last = entry;
history->current->children++;
} else { } else {
entry->prev = 0; history->start = entry;
} }
return entry; history->current = entry;
area = malloc(SPRITE_SIZE);
if (!area) {
LOG(("malloc failed"));
return;
}
area->size = SPRITE_SIZE;
area->sprite_count = 0;
area->first = 16;
area->used = 16;
error = xosspriteop_create_sprite(osspriteop_NAME,
area, "thumbnail", false,
WIDTH / 2, HEIGHT / 2, os_MODE8BPP90X90);
if (error) {
LOG(("0x%x: %s", error->errnum, error->errmess));
return;
}
thumbnail_create(content, area,
(osspriteop_header *) ((char *) area + 16),
WIDTH / 2, HEIGHT / 2);
/* xosspriteop_save_sprite_file(osspriteop_NAME,
area, "thumbnail");*/
entry->sprite_area = area;
}
/**
* Update the thumbnail for the current entry.
*
* \param history opaque history structure, as returned by history_create()
* \param content content for current entry
*/
void history_update(struct history *history, struct content *content)
{
if (!history || !history->current->sprite_area)
return;
thumbnail_create(content, history->current->sprite_area,
(osspriteop_header *)
((char *) history->current->sprite_area + 16),
WIDTH / 2, HEIGHT / 2);
}
/**
* Free a history structure.
*
* \param history opaque history structure, as returned by history_create()
*/
void history_destroy(struct history *history)
{
if (!history)
return;
history_free_entry(history->start);
free(history);
}
/**
* Free an entry in the tree recursively.
*/
void history_free_entry(struct history_entry *entry)
{
if (!entry)
return;
history_free_entry(entry->forward);
history_free_entry(entry->next);
free(entry->url);
free(entry->title);
free(entry->sprite_area);
free(entry);
} }
@ -109,11 +252,11 @@ void ro_gui_history_quit(void)
/** /**
* Open history window at a specified entry. * Open history window.
*/ */
void ro_gui_history_open(struct browser_window *bw, void ro_gui_history_open(struct browser_window *bw,
struct history_entry *entry, int wx, int wy) struct history *history, int wx, int wy)
{ {
bool done = false; bool done = false;
unsigned int i, j, max_y = 0; unsigned int i, j, max_y = 0;
@ -123,18 +266,14 @@ void ro_gui_history_open(struct browser_window *bw,
os_box box = {0, 0, 0, 0}; os_box box = {0, 0, 0, 0};
history_bw = bw; history_bw = bw;
history_current = entry; history_current = history;
for (history_start = entry;
history_start->back;
history_start = history_start->back)
;
/* calculate layout */ /* calculate layout */
for (i = 0; i != SIZE; i++) for (i = 0; i != SIZE; i++)
row[i] = row2[i] = 0; row[i] = row2[i] = 0;
row[0] = history_start; row[0] = history->start;
history_start->x = 0; history->start->x = 0;
history_start->y = 0; history->start->y = 0;
for (x = 1; !done; x++) { for (x = 1; !done; x++) {
for (i = 0; i != SIZE; i++) { for (i = 0; i != SIZE; i++) {
if (row[i]) { if (row[i]) {
@ -171,8 +310,8 @@ void ro_gui_history_open(struct browser_window *bw,
} }
} }
box.x1 = WIDTH * (x - 1); box.x1 = FULL_WIDTH * (x - 1);
box.y0 = -(HEIGHT * (max_y + 1)); box.y0 = -(FULL_HEIGHT * (max_y + 1));
wimp_set_extent(history_window, &box); wimp_set_extent(history_window, &box);
wimp_create_menu((wimp_menu *) history_window, wx, wy); wimp_create_menu((wimp_menu *) history_window, wx, wy);
} }
@ -190,7 +329,7 @@ void ro_gui_history_redraw(wimp_draw *redraw)
colourtrans_set_gcol(os_COLOUR_WHITE, 0, os_ACTION_OVERWRITE, 0); colourtrans_set_gcol(os_COLOUR_WHITE, 0, os_ACTION_OVERWRITE, 0);
while (more) { while (more) {
ro_gui_history_redraw_tree(history_start, ro_gui_history_redraw_tree(history_current->start,
redraw->box.x0 - redraw->xscroll, redraw->box.x0 - redraw->xscroll,
redraw->box.y1 - redraw->yscroll); redraw->box.y1 - redraw->yscroll);
more = wimp_get_rectangle(redraw); more = wimp_get_rectangle(redraw);
@ -207,30 +346,62 @@ void ro_gui_history_redraw_tree(struct history_entry *he,
{ {
struct history_entry *c; struct history_entry *c;
os_plot(os_MOVE_TO, x0 + he->x * WIDTH + MARGIN, os_plot(os_MOVE_TO, x0 + he->x * FULL_WIDTH + MARGIN,
y0 - he->y * HEIGHT - MARGIN); y0 - he->y * FULL_HEIGHT - MARGIN);
os_plot(os_PLOT_RECTANGLE | os_PLOT_BY, WIDTH - MARGIN - MARGIN, os_plot(os_PLOT_RECTANGLE | os_PLOT_BY, WIDTH, -HEIGHT);
-(HEIGHT - MARGIN - MARGIN));
if (he == history_current) if (he->sprite_area) {
unsigned int size;
osspriteop_area *area = he->sprite_area;
osspriteop_trans_tab *table;
os_factors factors;
xcolourtrans_generate_table_for_sprite(
area,
(char *) area + 16,
colourtrans_CURRENT_MODE, colourtrans_CURRENT_PALETTE,
0, colourtrans_GIVEN_SPRITE, 0, 0, &size);
table = xcalloc(size, 1);
xcolourtrans_generate_table_for_sprite(
area,
(char *) area + 16,
colourtrans_CURRENT_MODE, colourtrans_CURRENT_PALETTE,
table, colourtrans_GIVEN_SPRITE, 0, 0, 0);
factors.xmul = 1;
factors.ymul = 1;
factors.xdiv = 1;
factors.ydiv = 1;
xosspriteop_put_sprite_scaled(osspriteop_PTR,
area,
(char *) area + 16,
x0 + he->x * FULL_WIDTH + MARGIN,
y0 - he->y * FULL_HEIGHT - FULL_HEIGHT + MARGIN,
osspriteop_USE_MASK | osspriteop_USE_PALETTE, &factors, table);
xfree(table);
}
if (he == history_current->current)
wimp_set_font_colours(wimp_COLOUR_WHITE, wimp_COLOUR_RED); wimp_set_font_colours(wimp_COLOUR_WHITE, wimp_COLOUR_RED);
else else
wimp_set_font_colours(wimp_COLOUR_WHITE, wimp_COLOUR_BLACK); wimp_set_font_colours(wimp_COLOUR_WHITE, wimp_COLOUR_BLACK);
font_paint(history_font, he->title, font_paint(history_font, he->title,
font_OS_UNITS | font_GIVEN_FONT | font_KERN, font_OS_UNITS | font_GIVEN_FONT | font_KERN,
x0 + he->x * WIDTH + (WIDTH - he->width) / 2, x0 + he->x * FULL_WIDTH + (FULL_WIDTH - he->width) / 2,
y0 - he->y * HEIGHT - MARGIN - 24, y0 - he->y * FULL_HEIGHT - MARGIN - 24,
0, 0, 0); 0, 0, 0);
for (c = he->forward; c; c = c->next) { for (c = he->forward; c; c = c->next) {
if (c->x == -1) if (c->x == -1)
continue; continue;
os_plot(os_MOVE_TO, x0 + c->x * WIDTH - MARGIN, os_plot(os_MOVE_TO, x0 + c->x * FULL_WIDTH - MARGIN,
y0 - he->y * HEIGHT - HEIGHT / 2); y0 - he->y * FULL_HEIGHT - FULL_HEIGHT / 2);
os_plot(os_PLOT_SOLID | os_PLOT_TO, os_plot(os_PLOT_SOLID | os_PLOT_TO,
x0 + c->x * WIDTH + MARGIN, x0 + c->x * FULL_WIDTH + MARGIN,
y0 - c->y * HEIGHT - HEIGHT / 2); y0 - c->y * FULL_HEIGHT - FULL_HEIGHT / 2);
ro_gui_history_redraw_tree(c, x0, y0); ro_gui_history_redraw_tree(c, x0, y0);
} }
} }
@ -249,19 +420,14 @@ void ro_gui_history_click(wimp_pointer *pointer)
state.w = history_window; state.w = history_window;
wimp_get_window_state(&state); wimp_get_window_state(&state);
x = (pointer->pos.x - (state.visible.x0 - state.xscroll)) / WIDTH; x = (pointer->pos.x - (state.visible.x0 - state.xscroll)) / FULL_WIDTH;
y = -(pointer->pos.y - (state.visible.y1 - state.yscroll)) / HEIGHT; y = -(pointer->pos.y - (state.visible.y1 - state.yscroll)) / FULL_HEIGHT;
LOG(("x = %i, y = %i", x, y)); LOG(("x = %i, y = %i", x, y));
he = ro_gui_history_click_find(history_start, x, y); he = ro_gui_history_click_find(history_current->start, x, y);
if (he) { if (he) {
history_bw->history_entry = he; history_current->current = he;
wimp_create_menu(wimp_CLOSE_MENU, 0, 0); wimp_create_menu(wimp_CLOSE_MENU, 0, 0);
browser_window_open_location_historical(history_bw, browser_window_go_post(history_bw, he->url, 0, 0, false);
he->url
#ifdef WITH_POST
, 0, 0
#endif
);
} }
} }

View File

@ -3,7 +3,7 @@
* Licensed under the GNU General Public License, * Licensed under the GNU General Public License,
* http://www.opensource.org/licenses/gpl-license * http://www.opensource.org/licenses/gpl-license
* Copyright 2003 Phil Mellor <monkeyson@users.sourceforge.net> * Copyright 2003 Phil Mellor <monkeyson@users.sourceforge.net>
* Copyright 2003 James Bursa <bursa@users.sourceforge.net> * Copyright 2004 James Bursa <bursa@users.sourceforge.net>
*/ */
#include <assert.h> #include <assert.h>
@ -25,7 +25,8 @@ static void html_redraw_box(struct content *content, struct box * box,
unsigned long current_background_color, unsigned long current_background_color,
signed long gadget_subtract_x, signed long gadget_subtract_y, signed long gadget_subtract_x, signed long gadget_subtract_y,
bool *select_on, bool *select_on,
long clip_x0, long clip_y0, long clip_x1, long clip_y1); long clip_x0, long clip_y0, long clip_x1, long clip_y1,
float scale);
static void html_redraw_clip(long clip_x0, long clip_y0, static void html_redraw_clip(long clip_x0, long clip_y0,
long clip_x1, long clip_y1); long clip_x1, long clip_y1);
void html_redraw_rectangle(int x0, int y0, int width, int height, void html_redraw_rectangle(int x0, int y0, int width, int height,
@ -33,10 +34,16 @@ void html_redraw_rectangle(int x0, int y0, int width, int height,
bool gui_redraw_debug = false; bool gui_redraw_debug = false;
static os_trfm trfm = { {
{ 65536, 0 },
{ 0, 65536 },
{ 0, 0 } } };
void html_redraw(struct content *c, long x, long y, void html_redraw(struct content *c, long x, long y,
unsigned long width, unsigned long height, unsigned long width, unsigned long height,
long clip_x0, long clip_y0, long clip_x1, long clip_y1) long clip_x0, long clip_y0, long clip_x1, long clip_y1,
float scale)
{ {
bool select_on = false; bool select_on = false;
unsigned long background_colour = 0xffffff; unsigned long background_colour = 0xffffff;
@ -55,8 +62,10 @@ void html_redraw(struct content *c, long x, long y,
background_colour = c->data.html.background_colour; background_colour = c->data.html.background_colour;
} }
trfm.entries[0][0] = trfm.entries[1][1] = 65536 * scale;
html_redraw_box(c, box, x, y, background_colour, x, y, html_redraw_box(c, box, x, y, background_colour, x, y,
&select_on, clip_x0, clip_y0, clip_x1, clip_y1); &select_on, clip_x0, clip_y0, clip_x1, clip_y1, scale);
} }
@ -71,15 +80,16 @@ void html_redraw_box(struct content *content, struct box * box,
unsigned long current_background_color, unsigned long current_background_color,
signed long gadget_subtract_x, signed long gadget_subtract_y, signed long gadget_subtract_x, signed long gadget_subtract_y,
bool *select_on, bool *select_on,
long clip_x0, long clip_y0, long clip_x1, long clip_y1) long clip_x0, long clip_y0, long clip_x1, long clip_y1,
float scale)
{ {
struct box *c; struct box *c;
int width, height, x0, y0, x1, y1, colour; int width, height, x0, y0, x1, y1, colour;
x += box->x * 2; x += box->x * 2 * scale;
y -= box->y * 2; y -= box->y * 2 * scale;
width = (box->padding[LEFT] + box->width + box->padding[RIGHT]) * 2; width = (box->padding[LEFT] + box->width + box->padding[RIGHT]) * 2 * scale;
height = (box->padding[TOP] + box->height + box->padding[BOTTOM]) * 2; height = (box->padding[TOP] + box->height + box->padding[BOTTOM]) * 2 * scale;
x0 = x; x0 = x;
y1 = y - 1; y1 = y - 1;
@ -91,14 +101,15 @@ void html_redraw_box(struct content *content, struct box * box,
for (c = box->children; c; c = c->next) for (c = box->children; c; c = c->next)
html_redraw_box(content, c, x, y, current_background_color, html_redraw_box(content, c, x, y, current_background_color,
gadget_subtract_x, gadget_subtract_y, select_on, gadget_subtract_x, gadget_subtract_y, select_on,
x0, y0, x1, y1); x0, y0, x1, y1, scale);
return; return;
} }
if (gui_redraw_debug) { if (gui_redraw_debug) {
html_redraw_rectangle(x, y, width, height, os_COLOUR_MAGENTA); html_redraw_rectangle(x, y, width, height, os_COLOUR_MAGENTA);
html_redraw_rectangle(x + box->padding[LEFT] * 2, y - box->padding[TOP] * 2, html_redraw_rectangle(x + box->padding[LEFT] * 2, y - box->padding[TOP] * 2,
box->width * 2, box->height * 2, os_COLOUR_CYAN); box->width * 2 * scale, box->height * 2 * scale,
os_COLOUR_CYAN);
html_redraw_rectangle(x - (box->border[LEFT] + box->margin[LEFT]) * 2, html_redraw_rectangle(x - (box->border[LEFT] + box->margin[LEFT]) * 2,
y + (box->border[TOP] + box->margin[TOP]) * 2, y + (box->border[TOP] + box->margin[TOP]) * 2,
width + (box->border[LEFT] + box->margin[LEFT] + width + (box->border[LEFT] + box->margin[LEFT] +
@ -143,7 +154,7 @@ void html_redraw_box(struct content *content, struct box * box,
if (box->object) { if (box->object) {
content_redraw(box->object, x, y, (unsigned int)width, content_redraw(box->object, x, y, (unsigned int)width,
(unsigned int)height, x0, y0, x1, y1); (unsigned int)height, x0, y0, x1, y1, scale);
} else if (box->gadget && } else if (box->gadget &&
(box->gadget->type == GADGET_CHECKBOX || (box->gadget->type == GADGET_CHECKBOX ||
@ -249,40 +260,49 @@ void html_redraw_box(struct content *content, struct box * box,
os_ACTION_OVERWRITE, 0); os_ACTION_OVERWRITE, 0);
if (box->style->text_decoration & CSS_TEXT_DECORATION_UNDERLINE) { if (box->style->text_decoration & CSS_TEXT_DECORATION_UNDERLINE) {
os_plot(os_MOVE_TO, x, y - (int) (box->height * 1.8)); os_plot(os_MOVE_TO, x, y - (int) (box->height * 1.8 * scale));
os_plot(os_PLOT_SOLID_EX_END | os_PLOT_BY, box->width * 2, 0); os_plot(os_PLOT_SOLID_EX_END | os_PLOT_BY, box->width * 2 * scale, 0);
} }
if (box->parent->parent->style->text_decoration & CSS_TEXT_DECORATION_UNDERLINE && box->parent->parent->type == BOX_BLOCK) { if (box->parent->parent->style->text_decoration & CSS_TEXT_DECORATION_UNDERLINE && box->parent->parent->type == BOX_BLOCK) {
colourtrans_set_gcol((unsigned int)box->parent->parent->style->color << 8, colourtrans_USE_ECFS, os_ACTION_OVERWRITE, 0); colourtrans_set_gcol((unsigned int)box->parent->parent->style->color << 8, colourtrans_USE_ECFS, os_ACTION_OVERWRITE, 0);
os_plot(os_MOVE_TO, x, y - (int) (box->height * 1.8)); os_plot(os_MOVE_TO, x, y - (int) (box->height * 1.8 * scale));
os_plot(os_PLOT_SOLID_EX_END | os_PLOT_BY, box->width * 2, 0); os_plot(os_PLOT_SOLID_EX_END | os_PLOT_BY, box->width * 2 * scale, 0);
colourtrans_set_gcol((unsigned int)box->style->color << 8, colourtrans_USE_ECFS, os_ACTION_OVERWRITE, 0); colourtrans_set_gcol((unsigned int)box->style->color << 8, colourtrans_USE_ECFS, os_ACTION_OVERWRITE, 0);
} }
if (box->style->text_decoration & CSS_TEXT_DECORATION_OVERLINE) { if (box->style->text_decoration & CSS_TEXT_DECORATION_OVERLINE) {
os_plot(os_MOVE_TO, x, y - (int) (box->height * 0.2)); os_plot(os_MOVE_TO, x, y - (int) (box->height * 0.2 * scale));
os_plot(os_PLOT_SOLID_EX_END | os_PLOT_BY, box->width * 2, 0); os_plot(os_PLOT_SOLID_EX_END | os_PLOT_BY, box->width * 2 * scale, 0);
} }
if (box->parent->parent->style->text_decoration & CSS_TEXT_DECORATION_OVERLINE && box->parent->parent->type == BOX_BLOCK) { if (box->parent->parent->style->text_decoration & CSS_TEXT_DECORATION_OVERLINE && box->parent->parent->type == BOX_BLOCK) {
colourtrans_set_gcol((unsigned int)box->parent->parent->style->color << 8, colourtrans_USE_ECFS, os_ACTION_OVERWRITE, 0); colourtrans_set_gcol((unsigned int)box->parent->parent->style->color << 8, colourtrans_USE_ECFS, os_ACTION_OVERWRITE, 0);
os_plot(os_MOVE_TO, x, y - (int) (box->height * 0.2)); os_plot(os_MOVE_TO, x, y - (int) (box->height * 0.2 * scale));
os_plot(os_PLOT_SOLID_EX_END | os_PLOT_BY, box->width * 2, 0); os_plot(os_PLOT_SOLID_EX_END | os_PLOT_BY, box->width * 2 * scale, 0);
colourtrans_set_gcol((unsigned int)box->style->color << 8, colourtrans_USE_ECFS, os_ACTION_OVERWRITE, 0); colourtrans_set_gcol((unsigned int)box->style->color << 8, colourtrans_USE_ECFS, os_ACTION_OVERWRITE, 0);
} }
if (box->style->text_decoration & CSS_TEXT_DECORATION_LINE_THROUGH) { if (box->style->text_decoration & CSS_TEXT_DECORATION_LINE_THROUGH) {
os_plot(os_MOVE_TO, x, y - (int) (box->height * 1.0)); os_plot(os_MOVE_TO, x, y - (int) (box->height * 1.0 * scale));
os_plot(os_PLOT_SOLID_EX_END | os_PLOT_BY, box->width * 2, 0); os_plot(os_PLOT_SOLID_EX_END | os_PLOT_BY, box->width * 2 * scale, 0);
} }
if (box->parent->parent->style->text_decoration & CSS_TEXT_DECORATION_LINE_THROUGH && box->parent->parent->type == BOX_BLOCK) { if (box->parent->parent->style->text_decoration & CSS_TEXT_DECORATION_LINE_THROUGH && box->parent->parent->type == BOX_BLOCK) {
colourtrans_set_gcol((unsigned int)box->parent->parent->style->color << 8, colourtrans_USE_ECFS, os_ACTION_OVERWRITE, 0); colourtrans_set_gcol((unsigned int)box->parent->parent->style->color << 8, colourtrans_USE_ECFS, os_ACTION_OVERWRITE, 0);
os_plot(os_MOVE_TO, x, y - (int) (box->height * 1.0)); os_plot(os_MOVE_TO, x, y - (int) (box->height * 1.0 * scale));
os_plot(os_PLOT_SOLID_EX_END | os_PLOT_BY, box->width * 2, 0); os_plot(os_PLOT_SOLID_EX_END | os_PLOT_BY, box->width * 2 * scale, 0);
colourtrans_set_gcol((unsigned int)box->style->color << 8, colourtrans_USE_ECFS, os_ACTION_OVERWRITE, 0); colourtrans_set_gcol((unsigned int)box->style->color << 8, colourtrans_USE_ECFS, os_ACTION_OVERWRITE, 0);
} }
font_paint(box->font->handle, box->text, if (scale == 1)
font_OS_UNITS | font_GIVEN_FONT | font_KERN | font_GIVEN_LENGTH, font_paint(box->font->handle, box->text,
x, y - (int) (box->height * 1.5), font_OS_UNITS | font_GIVEN_FONT |
NULL, NULL, (int) box->length); font_KERN | font_GIVEN_LENGTH,
x, y - (int) (box->height * 1.5),
0, 0, (int) box->length);
else
font_paint(box->font->handle, box->text,
font_OS_UNITS | font_GIVEN_FONT |
font_KERN | font_GIVEN_LENGTH |
font_GIVEN_TRFM,
x, y - (int) (box->height * 1.5 * scale),
0, &trfm, (int) box->length);
} else { } else {
@ -291,13 +311,13 @@ void html_redraw_box(struct content *content, struct box * box,
html_redraw_box(content, c, x, html_redraw_box(content, c, x,
y, current_background_color, y, current_background_color,
gadget_subtract_x, gadget_subtract_y, select_on, gadget_subtract_x, gadget_subtract_y, select_on,
x0, y0, x1, y1); x0, y0, x1, y1, scale);
for (c = box->float_children; c != 0; c = c->next_float) for (c = box->float_children; c != 0; c = c->next_float)
html_redraw_box(content, c, x, html_redraw_box(content, c, x,
y, current_background_color, y, current_background_color,
gadget_subtract_x, gadget_subtract_y, select_on, gadget_subtract_x, gadget_subtract_y, select_on,
x0, y0, x1, y1); x0, y0, x1, y1, scale);
} }
if (box->type == BOX_BLOCK || box->type == BOX_INLINE_BLOCK || if (box->type == BOX_BLOCK || box->type == BOX_INLINE_BLOCK ||

View File

@ -329,7 +329,8 @@ void nsjpeg_destroy(struct content *c)
void nsjpeg_redraw(struct content *c, long x, long y, void nsjpeg_redraw(struct content *c, long x, long y,
unsigned long width, unsigned long height, unsigned long width, unsigned long height,
long clip_x0, long clip_y0, long clip_x1, long clip_y1) long clip_x0, long clip_y0, long clip_x1, long clip_y1,
float scale)
{ {
unsigned int size; unsigned int size;
osspriteop_trans_tab *table; osspriteop_trans_tab *table;

View File

@ -30,6 +30,7 @@ void nsjpeg_reformat(struct content *c, unsigned int width, unsigned int height)
void nsjpeg_destroy(struct content *c); void nsjpeg_destroy(struct content *c);
void nsjpeg_redraw(struct content *c, long x, long y, void nsjpeg_redraw(struct content *c, long x, long y,
unsigned long width, unsigned long height, unsigned long width, unsigned long height,
long clip_x0, long clip_y0, long clip_x1, long clip_y1); long clip_x0, long clip_y0, long clip_x1, long clip_y1,
float scale);
#endif #endif

View File

@ -3,10 +3,14 @@
* Licensed under the GNU General Public License, * Licensed under the GNU General Public License,
* http://www.opensource.org/licenses/gpl-license * http://www.opensource.org/licenses/gpl-license
* Copyright 2003 Phil Mellor <monkeyson@users.sourceforge.net> * Copyright 2003 Phil Mellor <monkeyson@users.sourceforge.net>
* Copyright 2003 James Bursa <bursa@users.sourceforge.net> * Copyright 2004 James Bursa <bursa@users.sourceforge.net>
* Copyright 2003 John M Bell <jmb202@ecs.soton.ac.uk> * Copyright 2003 John M Bell <jmb202@ecs.soton.ac.uk>
*/ */
/** \file
* Menu creation and handling (implementation).
*/
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include "oslib/wimp.h" #include "oslib/wimp.h"
@ -21,8 +25,8 @@
static void translate_menu(wimp_menu *menu); static void translate_menu(wimp_menu *menu);
wimp_menu *current_menu; static wimp_menu *current_menu;
int current_menu_x, current_menu_y; static int current_menu_x, current_menu_y;
gui_window *current_gui; gui_window *current_gui;
@ -44,7 +48,6 @@ wimp_menu *iconbar_menu = (wimp_menu *) & (wimp_MENU(4)) {
int iconbar_menu_height = 4 * 44; int iconbar_menu_height = 4 * 44;
/* browser window menu structure - based on Style Guide */ /* browser window menu structure - based on Style Guide */
/*wimp_menu *browser_page_menu = (wimp_menu *) & (wimp_MENU(4)) {*/
static wimp_MENU(4) page_menu = { static wimp_MENU(4) page_menu = {
{ "Page" }, 7,2,7,0, 200, 44, 0, { "Page" }, 7,2,7,0, 200, 44, 0,
{ {
@ -78,12 +81,21 @@ static wimp_MENU(5) navigate_menu = {
}; };
static wimp_menu *browser_navigate_menu = (wimp_menu *) &navigate_menu; static wimp_menu *browser_navigate_menu = (wimp_menu *) &navigate_menu;
wimp_menu *browser_menu = (wimp_menu *) & (wimp_MENU(3)) { static wimp_MENU(1) view_menu = {
{ "View" }, 7,2,7,0, 300, 44, 0,
{
{ wimp_MENU_LAST, wimp_NO_SUB_MENU, DEFAULT_FLAGS, { "ScaleView" } }
}
};
static wimp_menu *browser_view_menu = (wimp_menu *) &view_menu;
wimp_menu *browser_menu = (wimp_menu *) & (wimp_MENU(4)) {
{ "NetSurf" }, 7,2,7,0, 200, 44, 0, { "NetSurf" }, 7,2,7,0, 200, 44, 0,
{ {
{ 0, (wimp_menu *) &page_menu, DEFAULT_FLAGS, { "Page" } }, { 0, (wimp_menu *) &page_menu, DEFAULT_FLAGS, { "Page" } },
{ 0, (wimp_menu *) &selection_menu, DEFAULT_FLAGS, { "Selection" } }, { 0, (wimp_menu *) &selection_menu, DEFAULT_FLAGS, { "Selection" } },
{ wimp_MENU_LAST, (wimp_menu *) &navigate_menu, DEFAULT_FLAGS, { "Navigate" } } { 0, (wimp_menu *) &navigate_menu, DEFAULT_FLAGS, { "Navigate" } },
{ wimp_MENU_LAST, (wimp_menu *) &view_menu, DEFAULT_FLAGS, { "View" } }
} }
}; };
@ -99,9 +111,11 @@ void ro_gui_menus_init(void)
translate_menu(browser_page_menu); translate_menu(browser_page_menu);
translate_menu(browser_selection_menu); translate_menu(browser_selection_menu);
translate_menu(browser_navigate_menu); translate_menu(browser_navigate_menu);
translate_menu(browser_view_menu);
iconbar_menu->entries[0].sub_menu = (wimp_menu *) dialog_info; iconbar_menu->entries[0].sub_menu = (wimp_menu *) dialog_info;
browser_page_menu->entries[1].sub_menu = (wimp_menu *) dialog_saveas; browser_page_menu->entries[1].sub_menu = (wimp_menu *) dialog_saveas;
browser_view_menu->entries[0].sub_menu = (wimp_menu *) dialog_zoom;
} }
@ -126,7 +140,7 @@ void translate_menu(wimp_menu *menu)
menu->entries[i].data.indirected_text.size = menu->entries[i].data.indirected_text.size =
strlen(menu->entries[i].data.indirected_text.text) + 1; strlen(menu->entries[i].data.indirected_text.text) + 1;
i++; i++;
} while ((menu->entries[i].menu_flags & wimp_MENU_LAST) == 0); } while ((menu->entries[i - 1].menu_flags & wimp_MENU_LAST) == 0);
} }
@ -228,7 +242,8 @@ void ro_gui_menu_selection(wimp_selection *selection)
case 0: /* Open URL... */ case 0: /* Open URL... */
break; break;
case 1: /* Home */ case 1: /* Home */
browser_window_open_location(current_gui->data.browser.bw, HOME_URL); browser_window_go(current_gui->data.browser.bw,
HOME_URL);
break; break;
case 2: /* Back */ case 2: /* Back */
browser_window_back(current_gui->data.browser.bw); browser_window_back(current_gui->data.browser.bw);

View File

@ -56,12 +56,12 @@ void ro_gui_mouse_action(gui_window *g) {
break; break;
case mouseaction_RELOAD: case mouseaction_RELOAD:
browser_window_open_location_historical(g->data.browser.bw, /* browser_window_open_location_historical(g->data.browser.bw,
g->data.browser.bw->url g->data.browser.bw->url
#ifdef WITH_POST #ifdef WITH_POST
, 0, 0 , 0, 0
#endif #endif
); );*/
break; break;
default: break; default: break;

View File

@ -1287,20 +1287,10 @@ void plugin_url_access(wimp_message *message) {
strcasecmp(window, "_parent") == 0 || strcasecmp(window, "_parent") == 0 ||
strcasecmp(window, "_top") == 0 || strcasecmp(window, "_top") == 0 ||
strcasecmp(window, "") == 0) { strcasecmp(window, "") == 0) {
browser_window_open_location(npl->bw, url); browser_window_go(npl->bw, url);
} }
else if (strcasecmp(window, "_blank") == 0) { else if (strcasecmp(window, "_blank") == 0) {
struct browser_window *bwnew; browser_window_create(url);
bwnew = create_browser_window(browser_TITLE
| browser_TOOLBAR | browser_SCROLL_X_ALWAYS
| browser_SCROLL_Y_ALWAYS, 640, 480
#ifdef WITH_FRAMES
, NULL
#endif
);
gui_window_show(bwnew->window);
bwnew->url = xstrdup(url);
browser_window_open_location(bwnew, url);
} }
} }
else { /* POST request */ else { /* POST request */

View File

@ -376,7 +376,8 @@ void nspng_destroy(struct content *c)
void nspng_redraw(struct content *c, long x, long y, void nspng_redraw(struct content *c, long x, long y,
unsigned long width, unsigned long height, unsigned long width, unsigned long height,
long clip_x0, long clip_y0, long clip_x1, long clip_y1) long clip_x0, long clip_y0, long clip_x1, long clip_y1,
float scale)
{ {
int size; int size;
osspriteop_trans_tab *table; osspriteop_trans_tab *table;

View File

@ -35,5 +35,6 @@ void nspng_reformat(struct content *c, unsigned int width, unsigned int height);
void nspng_destroy(struct content *c); void nspng_destroy(struct content *c);
void nspng_redraw(struct content *c, long x, long y, void nspng_redraw(struct content *c, long x, long y,
unsigned long width, unsigned long height, unsigned long width, unsigned long height,
long clip_x0, long clip_y0, long clip_x1, long clip_y1); long clip_x0, long clip_y0, long clip_x1, long clip_y1,
float scale);
#endif #endif

View File

@ -82,7 +82,8 @@ void sprite_destroy(struct content *c)
void sprite_redraw(struct content *c, long x, long y, void sprite_redraw(struct content *c, long x, long y,
unsigned long width, unsigned long height, unsigned long width, unsigned long height,
long clip_x0, long clip_y0, long clip_x1, long clip_y1) long clip_x0, long clip_y0, long clip_x1, long clip_y1,
float scale)
{ {
unsigned int size; unsigned int size;
osspriteop_area *area = (osspriteop_area*)c->data.sprite.data; osspriteop_area *area = (osspriteop_area*)c->data.sprite.data;

View File

@ -26,5 +26,6 @@ void sprite_reformat(struct content *c, unsigned int width, unsigned int height)
void sprite_destroy(struct content *c); void sprite_destroy(struct content *c);
void sprite_redraw(struct content *c, long x, long y, void sprite_redraw(struct content *c, long x, long y,
unsigned long width, unsigned long height, unsigned long width, unsigned long height,
long clip_x0, long clip_y0, long clip_x1, long clip_y1); long clip_x0, long clip_y0, long clip_x1, long clip_y1,
float scale);
#endif #endif

View File

@ -59,8 +59,8 @@ void ro_gui_drag_end(wimp_dragged* drag)
state.w = current_drag.data.selection.gui->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 = window_x_units(drag->final.x0, &state) / 2;
final_y0 = browser_y_units(window_y_units(drag->final.y0, &state)); final_y0 = window_y_units(drag->final.y0, &state) / 2;
msg.data.mouse.x = final_x0; msg.data.mouse.x = final_x0;
msg.data.mouse.y = final_y0; msg.data.mouse.y = final_y0;

68
riscos/thumbnail.c Normal file
View File

@ -0,0 +1,68 @@
/*
* 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 2004 James Bursa <bursa@users.sourceforge.net>
*/
/** \file
* Page thumbnail creation (implementation).
*
* Thumbnails are created by redirecting output to a sprite and rendering the
* page at a small scale.
*/
#include "oslib/colourtrans.h"
#include "oslib/osspriteop.h"
#include "netsurf/content/content.h"
#include "netsurf/riscos/thumbnail.h"
#include "netsurf/utils/log.h"
/**
* Create a thumbnail of a page.
*
* \param content content structure to thumbnail
* \param area sprite area containing thumbnail sprite
* \param sprite pointer to sprite
* \param width sprite width / pixels
* \param height sprite height / pixels
*
* The thumbnail is rendered in the given sprite.
*/
void thumbnail_create(struct content *content, osspriteop_area *area,
osspriteop_header *sprite, int width, int height)
{
float scale;
os_error *error;
scale = (float) width / (float) content->width;
/* switch output to sprite */
error = xosspriteop_switch_output_to_sprite(osspriteop_PTR, area,
(osspriteop_id) sprite, 0, 0, 0, 0, 0);
if (error) {
LOG(("xosspriteop_switch_output_to_sprite failed: %s",
error->errmess));
return;
}
/* clear background to white */
colourtrans_set_gcol(os_COLOUR_WHITE, colourtrans_SET_BG,
os_ACTION_OVERWRITE, 0);
os_clg();
/* render content */
content_redraw(content, 0, height * 2, width * 2, height * 2,
0, 0, width * 2, height * 2, scale);
/* switch output back to screen */
error = xosspriteop_switch_output_to_sprite(osspriteop_PTR, area,
0, 0, 0, 0, 0, 0);
if (error) {
LOG(("xosspriteop_switch_output_to_sprite failed: %s",
error->errmess));
return;
}
}

15
riscos/thumbnail.h Normal file
View File

@ -0,0 +1,15 @@
/*
* 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 2004 James Bursa <bursa@users.sourceforge.net>
*/
/** \file
* Page thumbnail creation (interface).
*/
#include "oslib/osspriteop.h"
void thumbnail_create(struct content *content, osspriteop_area *area,
osspriteop_header *sprite, int width, int height);

View File

@ -57,20 +57,7 @@ void ro_uri_message_received(uri_full_message_process* uri_message)
xuri_request_uri(0, uri_requested, uri_length, uri_handle, NULL); xuri_request_uri(0, uri_requested, uri_length, uri_handle, NULL);
bw = create_browser_window(browser_TITLE | browser_TOOLBAR browser_window_create(uri_requested);
| browser_SCROLL_X_ALWAYS | browser_SCROLL_Y_ALWAYS, 640, 480
#ifdef WITH_FRAMES
, NULL
#endif
);
gui_window_show(bw->window);
browser_window_open_location(bw, uri_requested);
wimp_set_caret_position(bw->window->data.browser.toolbar,
ICON_TOOLBAR_URL,
0,0,-1, (int) strlen(bw->window->url) - 1);
xfree(uri_requested); xfree(uri_requested);
} }

View File

@ -99,29 +99,16 @@ void ro_url_message_received(wimp_message* message)
message->sender); message->sender);
/* create new browser window */ /* create new browser window */
bw = create_browser_window(browser_TITLE | browser_TOOLBAR browser_window_create(uri_requested);
| browser_SCROLL_X_ALWAYS | browser_SCROLL_Y_ALWAYS, 640, 480
#ifdef WITH_FRAMES
, NULL
#endif
);
gui_window_show(bw->window); #if 0
#ifdef ALLOW_POST
if (post) { if (post) {
/* TODO - create urlencoded data from file contents. /* TODO - create urlencoded data from file contents.
* Delete the file when finished with it. * Delete the file when finished with it.
*/ */
browser_window_open_location_historical(bw, uri_requested, /*data*/0, 0); browser_window_open_location_historical(bw, uri_requested, /*data*/0, 0);
} }
else
#endif #endif
browser_window_open_location(bw, uri_requested);
wimp_set_caret_position(bw->window->data.browser.toolbar,
ICON_TOOLBAR_URL,
0,0,-1, (int) strlen(bw->window->url));
#ifdef ALLOW_POST #ifdef ALLOW_POST
xfree(filename); xfree(filename);

View File

@ -3,7 +3,7 @@
* Licensed under the GNU General Public License, * Licensed under the GNU General Public License,
* http://www.opensource.org/licenses/gpl-license * http://www.opensource.org/licenses/gpl-license
* Copyright 2003 Phil Mellor <monkeyson@users.sourceforge.net> * Copyright 2003 Phil Mellor <monkeyson@users.sourceforge.net>
* Copyright 2003 James Bursa <bursa@users.sourceforge.net> * Copyright 2004 James Bursa <bursa@users.sourceforge.net>
* Copyright 2003 John M Bell <jmb202@ecs.soton.ac.uk> * Copyright 2003 John M Bell <jmb202@ecs.soton.ac.uk>
*/ */
@ -14,15 +14,18 @@
#include <assert.h> #include <assert.h>
#include <stdbool.h> #include <stdbool.h>
#include <string.h> #include <string.h>
#include "oslib/osspriteop.h"
#include "oslib/wimp.h" #include "oslib/wimp.h"
#include "oslib/wimpspriteop.h" #include "oslib/wimpspriteop.h"
#include "netsurf/css/css.h" #include "netsurf/css/css.h"
#include "netsurf/utils/config.h" #include "netsurf/utils/config.h"
#include "netsurf/riscos/constdata.h" #include "netsurf/riscos/constdata.h"
#include "netsurf/riscos/gui.h" #include "netsurf/riscos/gui.h"
#include "netsurf/riscos/options.h"
#include "netsurf/riscos/save_complete.h" #include "netsurf/riscos/save_complete.h"
#include "netsurf/riscos/save_draw.h" #include "netsurf/riscos/save_draw.h"
#include "netsurf/riscos/theme.h" #include "netsurf/riscos/theme.h"
#include "netsurf/riscos/thumbnail.h"
#include "netsurf/utils/log.h" #include "netsurf/utils/log.h"
#include "netsurf/utils/utils.h" #include "netsurf/utils/utils.h"
@ -62,7 +65,7 @@ gui_window *gui_create_browser_window(struct browser_window *bw)
ro_gui_screen_size(&screen_width, &screen_height); ro_gui_screen_size(&screen_width, &screen_height);
if (bw->flags & browser_TOOLBAR) if (option_show_toolbar)
toolbar_height = ro_theme_toolbar_height(); toolbar_height = ro_theme_toolbar_height();
win_width = screen_width * 3 / 4; win_width = screen_width * 3 / 4;
@ -109,7 +112,7 @@ gui_window *gui_create_browser_window(struct browser_window *bw)
strcpy(g->title, "NetSurf"); strcpy(g->title, "NetSurf");
g->data.browser.toolbar = 0; g->data.browser.toolbar = 0;
if ((bw->flags & browser_TOOLBAR) != 0) if (option_show_toolbar)
{ {
g->data.browser.toolbar = ro_theme_create_toolbar(g->url, g->status, g->data.browser.toolbar = ro_theme_create_toolbar(g->url, g->status,
g->throb_buf); g->throb_buf);
@ -117,9 +120,9 @@ gui_window *gui_create_browser_window(struct browser_window *bw)
sprintf(g->throb_buf, "throbber0"); sprintf(g->throb_buf, "throbber0");
} }
g->redraw_safety = SAFE;
g->data.browser.reformat_pending = false; g->data.browser.reformat_pending = false;
g->data.browser.old_width = 0; g->data.browser.old_width = 0;
g->scale = 1;
g->next = window_list; g->next = window_list;
window_list = g; window_list = g;
@ -199,8 +202,7 @@ void gui_window_redraw(gui_window* g, unsigned long x0, unsigned long y0,
if (g == NULL) if (g == NULL)
return; return;
wimp_force_redraw(g->window, wimp_force_redraw(g->window, x0 * 2, -y1 * 2, x1 * 2, -y0 * 2);
ro_x_units(x0), ro_y_units(y1), ro_x_units(x1), ro_y_units(y0));
} }
void gui_window_redraw_window(gui_window* g) void gui_window_redraw_window(gui_window* g)
@ -213,26 +215,13 @@ void gui_window_redraw_window(gui_window* g)
wimp_force_redraw(g->window, info.extent.x0, info.extent.y0, info.extent.x1, info.extent.y1); 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_window_redraw(gui_window* g, wimp_draw* redraw) void ro_gui_window_redraw(gui_window* g, wimp_draw* redraw)
{ {
osbool more; osbool more;
struct content *c = g->data.browser.bw->current_content; struct content *c = g->data.browser.bw->current_content;
if (g->redraw_safety == SAFE && g->type == GUI_BROWSER_WINDOW && c != NULL) if (g->type == GUI_BROWSER_WINDOW && c != NULL)
{ {
more = wimp_redraw_window(redraw); more = wimp_redraw_window(redraw);
wimp_set_font_colours(wimp_COLOUR_WHITE, wimp_COLOUR_BLACK); wimp_set_font_colours(wimp_COLOUR_WHITE, wimp_COLOUR_BLACK);
@ -244,7 +233,8 @@ void ro_gui_window_redraw(gui_window* g, wimp_draw* redraw)
(int) redraw->box.y1 - (int) redraw->yscroll, (int) redraw->box.y1 - (int) redraw->yscroll,
c->width * 2, c->height * 2, c->width * 2, c->height * 2,
redraw->clip.x0, redraw->clip.y0, redraw->clip.x0, redraw->clip.y0,
redraw->clip.x1 - 1, redraw->clip.y1 - 1); redraw->clip.x1 - 1, redraw->clip.y1 - 1,
g->scale);
more = wimp_get_rectangle(redraw); more = wimp_get_rectangle(redraw);
} }
} }
@ -263,9 +253,9 @@ void gui_window_set_scroll(gui_window* g, unsigned long sx, unsigned long sy)
return; return;
state.w = g->window; state.w = g->window;
wimp_get_window_state(&state); wimp_get_window_state(&state);
state.xscroll = ro_x_units(sx); state.xscroll = sx * 2;
state.yscroll = ro_y_units(sy); state.yscroll = -sy * 2;
if ((g->data.browser.bw->flags & browser_TOOLBAR) != 0) if (option_show_toolbar)
state.yscroll += ro_theme_toolbar_height(); state.yscroll += ro_theme_toolbar_height();
ro_gui_window_open(g, (wimp_open*)&state); ro_gui_window_open(g, (wimp_open*)&state);
} }
@ -275,7 +265,7 @@ unsigned long gui_window_get_width(gui_window* g)
wimp_window_state state; wimp_window_state state;
state.w = g->window; state.w = g->window;
wimp_get_window_state(&state); wimp_get_window_state(&state);
return browser_x_units(state.visible.x1 - state.visible.x0); return (state.visible.x1 - state.visible.x0) / 2;
} }
@ -286,14 +276,14 @@ void gui_window_set_extent(gui_window *g, unsigned long width,
wimp_window_state state; wimp_window_state state;
int toolbar_height = 0; int toolbar_height = 0;
width *= 2; width *= 2 * g->scale;
height *= 2; height *= 2 * g->scale;
state.w = g->window; state.w = g->window;
wimp_get_window_state(&state); wimp_get_window_state(&state);
/* account for toolbar height, if present */ /* account for toolbar height, if present */
if (g->data.browser.bw->flags & browser_TOOLBAR) if (option_show_toolbar)
toolbar_height = ro_theme_toolbar_height(); toolbar_height = ro_theme_toolbar_height();
if (width < (unsigned int)(state.visible.x1 - state.visible.x0)) if (width < (unsigned int)(state.visible.x1 - state.visible.x0))
@ -372,7 +362,7 @@ void ro_gui_window_open(gui_window *g, wimp_open *open)
} }
/* account for toolbar height, if present */ /* account for toolbar height, if present */
if (g->data.browser.bw->flags & browser_TOOLBAR) { if (option_show_toolbar) {
toolbar_height = ro_theme_toolbar_height(); toolbar_height = ro_theme_toolbar_height();
height -= toolbar_height; height -= toolbar_height;
} }
@ -443,7 +433,7 @@ void ro_gui_throb(void)
{ {
if (g->type == GUI_BROWSER_WINDOW) if (g->type == GUI_BROWSER_WINDOW)
{ {
if ((g->data.browser.bw->flags & browser_TOOLBAR) != 0) if (option_show_toolbar)
{ {
if (g->data.browser.bw->throbbing != 0) if (g->data.browser.bw->throbbing != 0)
{ {
@ -517,7 +507,7 @@ gui_window *ro_gui_window_lookup(wimp_w w)
void ro_gui_window_mouse_at(wimp_pointer* pointer) void ro_gui_window_mouse_at(wimp_pointer* pointer)
{ {
int x,y; int x, y;
wimp_window_state state; wimp_window_state state;
gui_window* g; gui_window* g;
@ -526,17 +516,11 @@ void ro_gui_window_mouse_at(wimp_pointer* pointer)
if (g == NULL) if (g == NULL)
return; return;
if (g->redraw_safety != SAFE)
{
fprintf(stderr, "mouse at UNSAFE\n");
return;
}
state.w = pointer->w; state.w = pointer->w;
wimp_get_window_state(&state); wimp_get_window_state(&state);
x = browser_x_units(window_x_units(pointer->pos.x, &state)); x = window_x_units(pointer->pos.x, &state) / 2 / g->scale;
y = browser_y_units(window_y_units(pointer->pos.y, &state)); y = -window_y_units(pointer->pos.y, &state) / 2 / g->scale;
if (g->drag_status == drag_BROWSER_TEXT_SELECTION) if (g->drag_status == drag_BROWSER_TEXT_SELECTION)
{ {
@ -565,17 +549,17 @@ void ro_gui_toolbar_click(gui_window* g, wimp_pointer* pointer)
switch (pointer->i) { switch (pointer->i) {
case ICON_TOOLBAR_HISTORY: case ICON_TOOLBAR_HISTORY:
ro_gui_history_open(g->data.browser.bw, ro_gui_history_open(g->data.browser.bw,
g->data.browser.bw->history_entry, g->data.browser.bw->history,
pointer->pos.x - 200, pointer->pos.x - 200,
pointer->pos.y + 100); pointer->pos.y + 100);
break; break;
case ICON_TOOLBAR_RELOAD: case ICON_TOOLBAR_RELOAD:
browser_window_open_location_historical(g->data.browser.bw, /* browser_window_open_location_historical(g->data.browser.bw,
g->data.browser.bw->url g->data.browser.bw->url
#ifdef WITH_POST #ifdef WITH_POST
, 0, 0 , 0, 0
#endif #endif
); );*/
break; break;
} }
} }
@ -587,19 +571,13 @@ void ro_gui_window_click(gui_window* g, wimp_pointer* pointer)
int x,y; int x,y;
wimp_window_state state; wimp_window_state state;
if (g->redraw_safety != SAFE)
{
fprintf(stderr, "gui_window_click UNSAFE\n");
return;
}
state.w = pointer->w; state.w = pointer->w;
wimp_get_window_state(&state); wimp_get_window_state(&state);
if (g->type == GUI_BROWSER_WINDOW) if (g->type == GUI_BROWSER_WINDOW)
{ {
x = browser_x_units(window_x_units(pointer->pos.x, &state)); x = window_x_units(pointer->pos.x, &state) / 2 / g->scale;
y = browser_y_units(window_y_units(pointer->pos.y, &state)); y = -window_y_units(pointer->pos.y, &state) / 2 / g->scale;
if (pointer->buttons == wimp_CLICK_MENU) if (pointer->buttons == wimp_CLICK_MENU)
{ {
@ -615,7 +593,6 @@ void ro_gui_window_click(gui_window* g, wimp_pointer* pointer)
msg.type = act_MOUSE_CLICK; msg.type = act_MOUSE_CLICK;
msg.data.mouse.x = x; msg.data.mouse.x = x;
msg.data.mouse.y = y; msg.data.mouse.y = y;
msg.data.mouse.buttons = act_BUTTON_NORMAL;
if (browser_window_action(g->data.browser.bw, &msg) == 1) if (browser_window_action(g->data.browser.bw, &msg) == 1)
return; return;
msg.type = act_UNKNOWN; msg.type = act_UNKNOWN;
@ -770,7 +747,7 @@ bool ro_gui_window_keypress(gui_window *g, int key, bool toolbar)
free(url); free(url);
if (url2) { if (url2) {
gui_window_set_url(g, url2); gui_window_set_url(g, url2);
browser_window_open_location(g->data.browser.bw, url2); browser_window_go(g->data.browser.bw, url2);
free(url2); free(url2);
} }
} }
@ -791,7 +768,7 @@ bool ro_gui_window_keypress(gui_window *g, int key, bool toolbar)
state.w = g->window; state.w = g->window;
wimp_get_window_state(&state); wimp_get_window_state(&state);
y = state.visible.y1 - state.visible.y0 - 32; y = state.visible.y1 - state.visible.y0 - 32;
if (g->data.browser.bw->flags & browser_TOOLBAR) if (option_show_toolbar)
y -= ro_theme_toolbar_height(); y -= ro_theme_toolbar_height();
switch (key) { switch (key) {
@ -833,7 +810,7 @@ void ro_gui_scroll_request(wimp_scroll *scroll)
x = scroll->visible.x1 - scroll->visible.x0 - 32; x = scroll->visible.x1 - scroll->visible.x0 - 32;
y = scroll->visible.y1 - scroll->visible.y0 - 32; y = scroll->visible.y1 - scroll->visible.y0 - 32;
if (g->data.browser.bw->flags & browser_TOOLBAR) if (option_show_toolbar)
y -= ro_theme_toolbar_height(); y -= ro_theme_toolbar_height();
switch (scroll->xmin) { switch (scroll->xmin) {
@ -872,3 +849,31 @@ void ro_gui_scroll_request(wimp_scroll *scroll)
wimp_open_window((wimp_open *) scroll); wimp_open_window((wimp_open *) scroll);
} }
/**
* Convert x from screen to window coordinates.
*
* \param x x coordinate / os units
* \param state window state
* \return x coordinate in window / os units
*/
int window_x_units(int x, wimp_window_state *state)
{
return x - (state->visible.x0 - state->xscroll);
}
/**
* Convert y from screen to window coordinates.
*
* \param y y coordinate / os units
* \param state window state
* \return y coordinate in window / os units
*/
int window_y_units(int y, wimp_window_state *state)
{
return y - (state->visible.y1 - state->yscroll);
}

View File

@ -23,6 +23,7 @@
#include "netsurf/riscos/about.h" #include "netsurf/riscos/about.h"
#include "netsurf/riscos/constdata.h" #include "netsurf/riscos/constdata.h"
#endif #endif
#define NDEBUG
#include "netsurf/utils/log.h" #include "netsurf/utils/log.h"
#include "netsurf/utils/messages.h" #include "netsurf/utils/messages.h"
#include "netsurf/utils/utils.h" #include "netsurf/utils/utils.h"