mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-12-24 13:06:49 +03:00
[project @ 2004-05-04 22:21:37 by rjw]
Revised GUI. svn path=/import/netsurf/; revision=823
This commit is contained in:
parent
1692e9c33d
commit
e7da747f5f
@ -25,6 +25,7 @@
|
||||
#include "netsurf/desktop/401login.h"
|
||||
#endif
|
||||
#include "netsurf/desktop/browser.h"
|
||||
#include "netsurf/desktop/gui.h"
|
||||
#include "netsurf/desktop/imagemap.h"
|
||||
#include "netsurf/render/box.h"
|
||||
#include "netsurf/render/font.h"
|
||||
@ -88,14 +89,14 @@ static gui_pointer_shape get_pointer_shape(css_cursor cursor);
|
||||
* \param url URL to start fetching in the new window (copied)
|
||||
*/
|
||||
|
||||
void browser_window_create(const char *url)
|
||||
void browser_window_create(const char *url, struct browser_window *clone)
|
||||
{
|
||||
struct browser_window *bw;
|
||||
|
||||
bw = malloc(sizeof *bw);
|
||||
if (!bw) {
|
||||
warn_user("NoMemory");
|
||||
return;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bw->current_content = 0;
|
||||
@ -103,12 +104,11 @@ void browser_window_create(const char *url)
|
||||
bw->history = history_create();
|
||||
bw->throbbing = false;
|
||||
bw->caret_callback = 0;
|
||||
bw->window = gui_create_browser_window(bw);
|
||||
bw->window = gui_create_browser_window(bw, clone);
|
||||
if (!bw->window) {
|
||||
free(bw);
|
||||
return;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
browser_window_go(bw, url);
|
||||
}
|
||||
|
||||
@ -1451,6 +1451,7 @@ void browser_window_follow_link(struct browser_window *bw,
|
||||
int done = 0;
|
||||
struct css_style *style;
|
||||
gui_pointer_shape pointer = GUI_POINTER_DEFAULT;
|
||||
struct browser_window *new_bw;
|
||||
|
||||
found = 0;
|
||||
click_boxes = NULL;
|
||||
@ -1489,7 +1490,7 @@ void browser_window_follow_link(struct browser_window *bw,
|
||||
}
|
||||
} else if (click_type == 2) {
|
||||
if (fetch_can_fetch(url)) {
|
||||
browser_window_create(url);
|
||||
browser_window_create(url, bw);
|
||||
}
|
||||
else {
|
||||
gui_launch_url(url);
|
||||
@ -1530,7 +1531,7 @@ void browser_window_follow_link(struct browser_window *bw,
|
||||
}
|
||||
} else if (click_type == 2) {
|
||||
if (fetch_can_fetch(url)) {
|
||||
browser_window_create(url);
|
||||
browser_window_create(url, NULL);
|
||||
}
|
||||
else {
|
||||
gui_launch_url(url);
|
||||
|
@ -89,7 +89,7 @@ struct box_selection
|
||||
};
|
||||
|
||||
|
||||
void browser_window_create(const char *url);
|
||||
void browser_window_create(const char *url, struct browser_window *clone);
|
||||
void browser_window_go(struct browser_window *bw, const char *url);
|
||||
void browser_window_go_post(struct browser_window *bw, const char *url,
|
||||
char *post_urlenc,
|
||||
|
@ -23,9 +23,11 @@ typedef enum { GUI_POINTER_DEFAULT, GUI_POINTER_POINT, GUI_POINTER_CARET,
|
||||
#include <stdbool.h>
|
||||
#include "netsurf/content/content.h"
|
||||
#include "netsurf/desktop/browser.h"
|
||||
#include "netsurf/riscos/gui.h"
|
||||
#include "netsurf/riscos/wimp.h"
|
||||
|
||||
bool gui_window_in_list(gui_window *g);
|
||||
gui_window *gui_create_browser_window(struct browser_window *bw);
|
||||
gui_window *gui_create_browser_window(struct browser_window *bw, struct browser_window *clone);
|
||||
gui_window *gui_create_download_window(struct content *content);
|
||||
void gui_window_destroy(gui_window* g);
|
||||
void gui_window_show(gui_window* g);
|
||||
@ -47,6 +49,8 @@ void gui_download_window_done(gui_window *g);
|
||||
void gui_download_window_error(gui_window *g, const char *error);
|
||||
|
||||
void gui_init(int argc, char** argv);
|
||||
void gui_window_clone_options(struct browser_window *new_bw, struct browser_window *old_bw);
|
||||
void gui_window_default_options(struct browser_window *bw);
|
||||
void gui_multitask(void);
|
||||
void gui_poll(bool active);
|
||||
void gui_quit(void);
|
||||
|
4
makefile
4
makefile
@ -14,9 +14,9 @@ OBJECTS_COMMON = cache.o content.o fetch.o fetchcache.o \
|
||||
OBJECTS = $(OBJECTS_COMMON) \
|
||||
browser.o netsurf.o options.o \
|
||||
htmlinstance.o htmlredraw.o \
|
||||
401login.o constdata.o dialog.o download.o frames.o gui.o \
|
||||
401login.o constdata.o dialog.o download.o frames.o wimp.o gui.o \
|
||||
menus.o mouseactions.o \
|
||||
textselection.o theme.o window.o \
|
||||
textselection.o toolbar.o theme.o window.o \
|
||||
draw.o plugin.o png.o sprite.o \
|
||||
about.o filetype.o font.o uri.o url_protocol.o history.o \
|
||||
version.o thumbnail.o \
|
||||
|
113
riscos/dialog.c
113
riscos/dialog.c
@ -21,6 +21,7 @@
|
||||
#include "netsurf/riscos/constdata.h"
|
||||
#include "netsurf/riscos/gui.h"
|
||||
#include "netsurf/riscos/options.h"
|
||||
#include "netsurf/riscos/wimp.h"
|
||||
#include "netsurf/utils/log.h"
|
||||
#include "netsurf/utils/messages.h"
|
||||
#include "netsurf/utils/utils.h"
|
||||
@ -54,9 +55,6 @@ static void load_theme_preview(char* thname);
|
||||
/*static void ro_gui_destroy_theme_menu(void);*/
|
||||
static void ro_gui_build_theme_menu(void);
|
||||
static int file_exists(const char* base, const char* dir, const char* leaf, bits ftype);
|
||||
static void set_icon_state(wimp_w w, wimp_i i, int state);
|
||||
static int get_icon_state(wimp_w w, wimp_i i);
|
||||
static void set_icon_string_i(wimp_w w, wimp_i i, int num);
|
||||
static const char *language_name(const char *code);
|
||||
|
||||
|
||||
@ -339,7 +337,7 @@ void ro_gui_dialog_click_config_th(wimp_pointer *pointer)
|
||||
os_cli("Filer_OpenDir " THEMES_DIR);
|
||||
break;
|
||||
case ICON_CONFIG_TH_GET:
|
||||
browser_window_create(THEMES_URL);
|
||||
browser_window_create(THEMES_URL, NULL);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -372,7 +370,7 @@ void ro_gui_dialog_click_zoom(wimp_pointer *pointer)
|
||||
scale = 10;
|
||||
else if (500 < scale)
|
||||
scale = 500;
|
||||
set_icon_string_i(dialog_zoom, ICON_ZOOM_VALUE, scale);
|
||||
ro_gui_set_icon_integer(dialog_zoom, ICON_ZOOM_VALUE, scale);
|
||||
|
||||
if (pointer->i == ICON_ZOOM_OK) {
|
||||
current_gui->scale = scale * 0.01;
|
||||
@ -415,8 +413,7 @@ void ro_gui_dialog_close(wimp_w close)
|
||||
* Update the browser choices dialog with the current options.
|
||||
*/
|
||||
|
||||
void set_browser_choices(void)
|
||||
{
|
||||
void set_browser_choices(void) {
|
||||
font_size = option_font_size;
|
||||
font_min_size = option_font_min_size;
|
||||
ro_gui_dialog_update_config_br();
|
||||
@ -433,8 +430,7 @@ void set_browser_choices(void)
|
||||
* Set the current options to the settings in the browser choices dialog.
|
||||
*/
|
||||
|
||||
void get_browser_choices(void)
|
||||
{
|
||||
void get_browser_choices(void) {
|
||||
option_font_size = font_size;
|
||||
option_font_min_size = font_min_size;
|
||||
}
|
||||
@ -446,11 +442,11 @@ void get_browser_choices(void)
|
||||
|
||||
void set_proxy_choices(void)
|
||||
{
|
||||
set_icon_state(dialog_config_prox, ICON_CONFIG_PROX_HTTP,
|
||||
ro_gui_set_icon_selected_state(dialog_config_prox, ICON_CONFIG_PROX_HTTP,
|
||||
option_http_proxy);
|
||||
ro_gui_set_icon_string(dialog_config_prox, ICON_CONFIG_PROX_HTTPHOST,
|
||||
option_http_proxy_host ? option_http_proxy_host : "");
|
||||
set_icon_string_i(dialog_config_prox, ICON_CONFIG_PROX_HTTPPORT,
|
||||
ro_gui_set_icon_integer(dialog_config_prox, ICON_CONFIG_PROX_HTTPPORT,
|
||||
option_http_proxy_port);
|
||||
}
|
||||
|
||||
@ -461,7 +457,7 @@ void set_proxy_choices(void)
|
||||
|
||||
void get_proxy_choices(void)
|
||||
{
|
||||
option_http_proxy = get_icon_state(dialog_config_prox,
|
||||
option_http_proxy = ro_gui_get_icon_selected_state(dialog_config_prox,
|
||||
ICON_CONFIG_PROX_HTTP);
|
||||
free(option_http_proxy_host);
|
||||
option_http_proxy_host = strdup(ro_gui_get_icon_string(dialog_config_prox,
|
||||
@ -693,99 +689,6 @@ int file_exists(const char* base, const char* dir, const char* leaf, bits ftype)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void set_icon_state(wimp_w w, wimp_i i, int state)
|
||||
{
|
||||
if (state)
|
||||
wimp_set_icon_state(w,i, wimp_ICON_SELECTED, wimp_ICON_SELECTED);
|
||||
else
|
||||
wimp_set_icon_state(w,i, 0, wimp_ICON_SELECTED);
|
||||
}
|
||||
|
||||
int get_icon_state(wimp_w w, wimp_i i)
|
||||
{
|
||||
wimp_icon_state ic;
|
||||
ic.w = w;
|
||||
ic.i = i;
|
||||
wimp_get_icon_state(&ic);
|
||||
return (ic.icon.flags & wimp_ICON_SELECTED) != 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the contents of an icon to a string.
|
||||
*
|
||||
* \param w window handle
|
||||
* \param i icon handle
|
||||
* \param text string (copied)
|
||||
*/
|
||||
|
||||
void ro_gui_set_icon_string(wimp_w w, wimp_i i, const char *text) {
|
||||
wimp_caret caret;
|
||||
wimp_icon_state ic;
|
||||
unsigned int old_len, len;
|
||||
|
||||
/* Get the icon data
|
||||
*/
|
||||
ic.w = w;
|
||||
ic.i = i;
|
||||
wimp_get_icon_state(&ic);
|
||||
|
||||
/* Check that the existing text is not the same as the updated text
|
||||
to stop flicker
|
||||
*/
|
||||
if (!strcmp(ic.icon.data.indirected_text.text, text))
|
||||
return;
|
||||
|
||||
/* Copy the text across
|
||||
*/
|
||||
old_len = strlen(ic.icon.data.indirected_text.text);
|
||||
if (ic.icon.data.indirected_text.size > 0) {
|
||||
strncpy(ic.icon.data.indirected_text.text, text,
|
||||
(unsigned int)ic.icon.data.indirected_text.size);
|
||||
ic.icon.data.indirected_text.text[ic.icon.data.indirected_text.size - 1] = '\0';
|
||||
}
|
||||
|
||||
/* Handle the caret being in the icon
|
||||
*/
|
||||
if (!xwimp_get_caret_position(&caret)) {
|
||||
if ((caret.w == w) && (caret.i == i)) {
|
||||
len = strlen(text);
|
||||
if ((caret.index > len) || (caret.index == old_len)) caret.index = len;
|
||||
xwimp_set_caret_position(w, i, caret.pos.x, caret.pos.y, -1, caret.index);
|
||||
}
|
||||
}
|
||||
|
||||
/* Redraw the icon
|
||||
*/
|
||||
wimp_set_icon_state(w, i, 0, 0);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Read the contents of an icon.
|
||||
*
|
||||
* \param w window handle
|
||||
* \param i icon handle
|
||||
* \return string in icon
|
||||
*/
|
||||
|
||||
char *ro_gui_get_icon_string(wimp_w w, wimp_i i)
|
||||
{
|
||||
wimp_icon_state ic;
|
||||
ic.w = w;
|
||||
ic.i = i;
|
||||
wimp_get_icon_state(&ic);
|
||||
return ic.icon.data.indirected_text.text;
|
||||
}
|
||||
|
||||
void set_icon_string_i(wimp_w w, wimp_i i, int num)
|
||||
{
|
||||
char buffer[255];
|
||||
sprintf(buffer, "%d", num);
|
||||
ro_gui_set_icon_string(w, i, buffer);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Convert a 2-letter ISO language code to the language name.
|
||||
*
|
||||
|
132
riscos/gui.c
132
riscos/gui.c
@ -206,6 +206,100 @@ void gui_init(int argc, char** argv)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Clones a browser window's options.
|
||||
*
|
||||
* \param new_bw the new browser window
|
||||
* \param old_bw the browser window to clone from, or NULL for default
|
||||
*/
|
||||
void gui_window_clone_options(struct browser_window *new_bw, struct browser_window *old_bw) {
|
||||
gui_window *old_gui = NULL;
|
||||
gui_window *new_gui;
|
||||
|
||||
/* Abort on bad input
|
||||
*/
|
||||
if (new_bw == NULL) return;
|
||||
|
||||
/* Get our GUIs
|
||||
*/
|
||||
new_gui = new_bw->window;
|
||||
|
||||
/* Abort on bad input
|
||||
*/
|
||||
if (!new_gui) return;
|
||||
if (old_bw) old_gui = old_bw->window;
|
||||
|
||||
/* Clone the basic options
|
||||
*/
|
||||
if (!old_gui) {
|
||||
new_gui->scale = ((float)option_scale) / 100;
|
||||
new_gui->option_dither_sprites = option_dither_sprites;
|
||||
new_gui->option_filter_sprites = option_filter_sprites;
|
||||
new_gui->option_animate_images = option_animate_images;
|
||||
} else {
|
||||
new_gui->scale = old_gui->scale;
|
||||
new_gui->option_dither_sprites = old_gui->option_dither_sprites;
|
||||
new_gui->option_filter_sprites = old_gui->option_filter_sprites;
|
||||
new_gui->option_animate_images = old_gui->option_animate_images;
|
||||
}
|
||||
|
||||
/* Set up the toolbar
|
||||
*/
|
||||
if (new_gui->data.browser.toolbar) {
|
||||
if ((old_gui) && (old_gui->data.browser.toolbar)) {
|
||||
new_gui->data.browser.toolbar->status_width = old_gui->data.browser.toolbar->status_width;
|
||||
new_gui->data.browser.toolbar->status_window = old_gui->data.browser.toolbar->status_window;
|
||||
new_gui->data.browser.toolbar->standard_buttons = old_gui->data.browser.toolbar->standard_buttons;
|
||||
new_gui->data.browser.toolbar->url_bar = old_gui->data.browser.toolbar->url_bar;
|
||||
new_gui->data.browser.toolbar->throbber = old_gui->data.browser.toolbar->throbber;
|
||||
} else {
|
||||
new_gui->data.browser.toolbar->status_width = option_toolbar_status_width;
|
||||
new_gui->data.browser.toolbar->status_window = option_toolbar_show_status;
|
||||
new_gui->data.browser.toolbar->standard_buttons = option_toolbar_show_buttons;
|
||||
new_gui->data.browser.toolbar->url_bar = option_toolbar_show_address;
|
||||
new_gui->data.browser.toolbar->throbber = option_toolbar_show_throbber;
|
||||
}
|
||||
ro_theme_update_toolbar(new_gui);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Makes a browser window's options the default.
|
||||
*
|
||||
* \param bw the browser window to read options from
|
||||
*/
|
||||
void gui_window_default_options(struct browser_window *bw) {
|
||||
gui_window *gui;
|
||||
|
||||
/* Abort on bad input
|
||||
*/
|
||||
if (bw == NULL) return;
|
||||
|
||||
/* Get our GUI
|
||||
*/
|
||||
gui = bw->window;
|
||||
if (!gui) return;
|
||||
|
||||
/* Save the basic options
|
||||
*/
|
||||
option_scale = gui->scale * 100;
|
||||
option_dither_sprites = gui->option_dither_sprites;
|
||||
option_filter_sprites = gui->option_filter_sprites;
|
||||
option_animate_images = gui->option_animate_images;
|
||||
|
||||
/* Set up the toolbar
|
||||
*/
|
||||
if (gui->data.browser.toolbar) {
|
||||
option_toolbar_status_width = gui->data.browser.toolbar->status_width;
|
||||
option_toolbar_show_status = gui->data.browser.toolbar->status_window;
|
||||
option_toolbar_show_buttons = gui->data.browser.toolbar->standard_buttons;
|
||||
option_toolbar_show_address = gui->data.browser.toolbar->url_bar;
|
||||
option_toolbar_show_throbber = gui->data.browser.toolbar->throbber;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Determine the language to use.
|
||||
*
|
||||
@ -588,7 +682,7 @@ void gui_window_set_pointer(gui_pointer_shape shape)
|
||||
break;
|
||||
case GUI_POINTER_CARET:
|
||||
xosspriteop_set_pointer_shape(0x100, pointers,
|
||||
(osspriteop_id)"ptr_caret", 1, 5, 10, 0, 0);
|
||||
(osspriteop_id)"ptr_caret", 1, 5, 0, 0, 0);
|
||||
break;
|
||||
case GUI_POINTER_MENU:
|
||||
xosspriteop_set_pointer_shape(0x100, pointers,
|
||||
@ -662,15 +756,24 @@ void ro_gui_redraw_window_request(wimp_draw *redraw)
|
||||
* Handle Open_Window_Request events.
|
||||
*/
|
||||
|
||||
void ro_gui_open_window_request(wimp_open *open)
|
||||
{
|
||||
void ro_gui_open_window_request(wimp_open *open) {
|
||||
struct toolbar *toolbar;
|
||||
gui_window *g;
|
||||
|
||||
g = ro_lookup_gui_from_w(open->w);
|
||||
if (g)
|
||||
if (g) {
|
||||
ro_gui_window_open(g, open);
|
||||
else
|
||||
} else {
|
||||
wimp_open_window(open);
|
||||
g = ro_lookup_gui_status_from_w(open->w);
|
||||
if (g) {
|
||||
toolbar = g->data.browser.toolbar;
|
||||
if (toolbar) {
|
||||
toolbar->resize_status = 1;
|
||||
ro_theme_resize_toolbar(g);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -710,8 +813,11 @@ void ro_gui_mouse_click(wimp_pointer *pointer)
|
||||
else if (g && g->type == GUI_BROWSER_WINDOW && g->window == pointer->w)
|
||||
ro_gui_window_click(g, pointer);
|
||||
else if (g && g->type == GUI_BROWSER_WINDOW &&
|
||||
g->data.browser.toolbar == pointer->w)
|
||||
g->data.browser.toolbar->toolbar_handle == pointer->w)
|
||||
ro_gui_toolbar_click(g, pointer);
|
||||
else if (g && g->type == GUI_BROWSER_WINDOW &&
|
||||
g->data.browser.toolbar->status_handle == pointer->w)
|
||||
ro_gui_status_click(g, pointer);
|
||||
else if (g && g->type == GUI_DOWNLOAD_WINDOW)
|
||||
ro_download_window_click(g, pointer);
|
||||
else if (pointer->w == dialog_saveas)
|
||||
@ -734,7 +840,7 @@ void ro_gui_icon_bar_click(wimp_pointer *pointer)
|
||||
char url[80];
|
||||
sprintf(url, "file:///%%3CNetSurf$Dir%%3E/Docs/intro_%s",
|
||||
option_language);
|
||||
browser_window_create(url);
|
||||
browser_window_create(url, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
@ -757,6 +863,10 @@ void ro_gui_drag_end(wimp_dragged *drag)
|
||||
case GUI_DRAG_SAVE:
|
||||
ro_gui_save_drag_end(drag);
|
||||
break;
|
||||
|
||||
case GUI_DRAG_STATUS_RESIZE:
|
||||
// ro_gui_save_drag_end(drag);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -780,7 +890,7 @@ void ro_gui_keypress(wimp_key *key)
|
||||
switch (g->type) {
|
||||
case GUI_BROWSER_WINDOW:
|
||||
handled = ro_gui_window_keypress(g, key->c,
|
||||
(bool) (g->data.browser.toolbar == key->w));
|
||||
(bool) (g->data.browser.toolbar->toolbar_handle == key->w));
|
||||
break;
|
||||
|
||||
case GUI_DOWNLOAD_WINDOW:
|
||||
@ -1092,7 +1202,7 @@ void ro_msg_dataload(wimp_message *message)
|
||||
browser_window_go(gui->data.browser.bw, url);
|
||||
}
|
||||
else {
|
||||
browser_window_create(url);
|
||||
browser_window_create(url, NULL);
|
||||
}
|
||||
|
||||
free(url);
|
||||
@ -1214,7 +1324,7 @@ void ro_msg_dataopen(wimp_message *message)
|
||||
url = ro_path_to_url(message->data.data_xfer.file_name);
|
||||
}
|
||||
if (url) {
|
||||
browser_window_create(url);
|
||||
browser_window_create(url, NULL);
|
||||
free(url);
|
||||
}
|
||||
}
|
||||
@ -1293,7 +1403,7 @@ void ro_gui_open_help_page(void)
|
||||
char url[80];
|
||||
sprintf(url, "file:///%%3CNetSurf$Dir%%3E/Docs/docs_%s",
|
||||
option_language);
|
||||
browser_window_create(url);
|
||||
browser_window_create(url, NULL);
|
||||
}
|
||||
|
||||
|
||||
|
53
riscos/gui.h
53
riscos/gui.h
@ -16,6 +16,7 @@
|
||||
#include "netsurf/desktop/netsurf.h"
|
||||
#include "netsurf/desktop/gui.h"
|
||||
#include "netsurf/desktop/options.h"
|
||||
#include "netsurf/riscos/toolbar.h"
|
||||
|
||||
#define THEMES_DIR "<NetSurf$Dir>.Themes"
|
||||
|
||||
@ -36,7 +37,7 @@ typedef enum { GUI_SAVE_SOURCE, GUI_SAVE_DRAW, GUI_SAVE_TEXT,
|
||||
GUI_SAVE_COMPLETE } gui_save_type;
|
||||
extern gui_save_type gui_current_save_type;
|
||||
typedef enum { GUI_DRAG_SELECTION, GUI_DRAG_DOWNLOAD_SAVE,
|
||||
GUI_DRAG_SAVE } gui_drag_type;
|
||||
GUI_DRAG_SAVE, GUI_DRAG_STATUS_RESIZE } gui_drag_type;
|
||||
extern gui_drag_type gui_current_drag_type;
|
||||
|
||||
struct gui_window
|
||||
@ -47,7 +48,7 @@ struct gui_window
|
||||
|
||||
union {
|
||||
struct {
|
||||
wimp_w toolbar;
|
||||
struct toolbar *toolbar;
|
||||
int toolbar_width;
|
||||
struct browser_window* bw;
|
||||
bool reformat_pending;
|
||||
@ -78,7 +79,17 @@ struct gui_window
|
||||
|
||||
enum { drag_NONE, drag_UNKNOWN, drag_BROWSER_TEXT_SELECTION } drag_status;
|
||||
|
||||
float scale;
|
||||
/* Options
|
||||
*/
|
||||
float scale;
|
||||
bool option_dither_sprites;
|
||||
bool option_filter_sprites;
|
||||
int option_toolbar_status_width;
|
||||
bool option_toolbar_show_status;
|
||||
bool option_toolbar_show_buttons;
|
||||
bool option_toolbar_show_address;
|
||||
bool option_toolbar_show_throbber;
|
||||
bool option_animate_images;
|
||||
};
|
||||
|
||||
|
||||
@ -96,6 +107,7 @@ void ro_gui_popup_menu(wimp_menu *menu, wimp_w w, wimp_i i);
|
||||
void ro_gui_menu_selection(wimp_selection* selection);
|
||||
void ro_gui_menu_warning(wimp_message_menu_warning *warning);
|
||||
void ro_gui_menu_prepare_save(struct content *c);
|
||||
void ro_gui_menu_prepare_scale(void);
|
||||
|
||||
/* in dialog.c */
|
||||
void ro_gui_dialog_init(void);
|
||||
@ -106,8 +118,6 @@ bool ro_gui_dialog_keypress(wimp_key *key);
|
||||
void ro_gui_dialog_close(wimp_w close);
|
||||
void ro_gui_redraw_config_th(wimp_draw* redraw);
|
||||
void ro_gui_theme_menu_selection(char *theme);
|
||||
void ro_gui_set_icon_string(wimp_w w, wimp_i i, const char *text);
|
||||
char *ro_gui_get_icon_string(wimp_w w, wimp_i i);
|
||||
|
||||
/* in download.c */
|
||||
void ro_gui_download_init(void);
|
||||
@ -139,12 +149,16 @@ void ro_gui_window_open(gui_window* g, wimp_open* open);
|
||||
void ro_gui_window_redraw(gui_window* g, wimp_draw* redraw);
|
||||
void ro_gui_window_mouse_at(wimp_pointer* pointer);
|
||||
void ro_gui_toolbar_click(gui_window* g, wimp_pointer* pointer);
|
||||
void ro_gui_status_click(gui_window* g, wimp_pointer* pointer);
|
||||
void ro_gui_throb(void);
|
||||
gui_window* ro_lookup_gui_from_w(wimp_w window);
|
||||
gui_window* ro_lookup_gui_toolbar_from_w(wimp_w window);
|
||||
gui_window* ro_lookup_gui_status_from_w(wimp_w window);
|
||||
gui_window *ro_gui_window_lookup(wimp_w w);
|
||||
bool ro_gui_window_keypress(gui_window *g, int key, bool toolbar);
|
||||
void ro_gui_scroll_request(wimp_scroll *scroll);
|
||||
//#define window_x_units(x, state) (x - (state->visible.x0 - state->xscroll))
|
||||
//#define window_y_units(y, state) (y - (state->visible.y1 - state->yscroll))
|
||||
int window_x_units(int x, wimp_window_state *state);
|
||||
int window_y_units(int y, wimp_window_state *state);
|
||||
bool ro_gui_window_dataload(gui_window *g, wimp_message *message);
|
||||
@ -175,18 +189,23 @@ void schedule_remove(void (*callback)(void *p), void *p);
|
||||
void schedule_run(void);
|
||||
|
||||
/* icon numbers */
|
||||
#define ICON_TOOLBAR_THROBBER 1
|
||||
#define ICON_TOOLBAR_URL 2
|
||||
#define ICON_TOOLBAR_STATUS 3
|
||||
#define ICON_TOOLBAR_HISTORY 4
|
||||
#define ICON_TOOLBAR_RELOAD 5
|
||||
#define ICON_TOOLBAR_STOP 6
|
||||
#define ICON_TOOLBAR_BACK 7
|
||||
#define ICON_TOOLBAR_FORWARD 8
|
||||
#define ICON_TOOLBAR_BOOKMARK 9
|
||||
#define ICON_TOOLBAR_SAVE 10
|
||||
#define ICON_TOOLBAR_PRINT 11
|
||||
#define ICON_TOOLBAR_HOME 12
|
||||
#define ICON_TOOLBAR_BACK 0
|
||||
#define ICON_TOOLBAR_FORWARD 1
|
||||
#define ICON_TOOLBAR_STOP 2
|
||||
#define ICON_TOOLBAR_RELOAD 3
|
||||
#define ICON_TOOLBAR_HOME 4
|
||||
#define ICON_TOOLBAR_HISTORY 5
|
||||
#define ICON_TOOLBAR_SAVE 6
|
||||
#define ICON_TOOLBAR_PRINT 7
|
||||
#define ICON_TOOLBAR_BOOKMARK 8
|
||||
#define ICON_TOOLBAR_SCALE 9
|
||||
#define ICON_TOOLBAR_SEARCH 10
|
||||
#define ICON_TOOLBAR_UP 11
|
||||
#define ICON_TOOLBAR_URL 12 // Must be after highest toolbar icon
|
||||
#define ICON_TOOLBAR_THROBBER 13
|
||||
|
||||
#define ICON_STATUS_TEXT 0
|
||||
#define ICON_STATUS_RESIZE 1
|
||||
|
||||
#define ICON_CONFIG_SAVE 0
|
||||
#define ICON_CONFIG_CANCEL 1
|
||||
|
349
riscos/menus.c
349
riscos/menus.c
@ -26,8 +26,20 @@
|
||||
#include "netsurf/utils/utils.h"
|
||||
|
||||
|
||||
/* Menu index definitions used by menu decoding code so that entries can
|
||||
be quickly commented out. Use -ve numbers below -1 to hide an entry.
|
||||
*/
|
||||
#define MENU_PAGE 0
|
||||
#define MENU_OBJECT -2
|
||||
#define MENU_SELECTION -2
|
||||
#define MENU_NAVIGATE 1
|
||||
#define MENU_VIEW 2
|
||||
#define MENU_UTILITIES -2
|
||||
#define MENU_HELP 3
|
||||
|
||||
static void translate_menu(wimp_menu *menu);
|
||||
static void ro_gui_menu_prepare_images(void);
|
||||
static void ro_gui_menu_prepare_toolbars(void);
|
||||
static void ro_gui_menu_pageinfo(wimp_message_menu_warning *warning);
|
||||
|
||||
|
||||
@ -36,13 +48,16 @@ static int current_menu_x, current_menu_y;
|
||||
gui_window *current_gui;
|
||||
|
||||
|
||||
/* default menu item flags */
|
||||
/* Default menu item flags
|
||||
*/
|
||||
#define DEFAULT_FLAGS (wimp_ICON_TEXT | wimp_ICON_FILLED | \
|
||||
(wimp_COLOUR_BLACK << wimp_ICON_FG_COLOUR_SHIFT) | \
|
||||
(wimp_COLOUR_WHITE << wimp_ICON_BG_COLOUR_SHIFT))
|
||||
|
||||
/* iconbar menu */
|
||||
wimp_menu *iconbar_menu = (wimp_menu *) & (wimp_MENU(4)) {
|
||||
|
||||
/* Iconbar menu
|
||||
*/
|
||||
wimp_menu *iconbar_menu = (wimp_menu *)&(wimp_MENU(4)) {
|
||||
{ "NetSurf" }, 7,2,7,0, 200, 44, 0,
|
||||
{
|
||||
{ 0, wimp_NO_SUB_MENU, DEFAULT_FLAGS, { "Info" } },
|
||||
@ -53,70 +68,149 @@ wimp_menu *iconbar_menu = (wimp_menu *) & (wimp_MENU(4)) {
|
||||
};
|
||||
int iconbar_menu_height = 4 * 44;
|
||||
|
||||
/* browser window menu structure - based on Style Guide */
|
||||
|
||||
/* Export submenu
|
||||
*/
|
||||
static wimp_MENU(2) export_menu = {
|
||||
{ "ExportAs" }, 7,2,7,0, 200, 44, 0,
|
||||
{
|
||||
{ wimp_MENU_GIVE_WARNING, wimp_NO_SUB_MENU, DEFAULT_FLAGS, { "Draw" } },
|
||||
{ wimp_MENU_LAST | wimp_MENU_GIVE_WARNING, wimp_NO_SUB_MENU, DEFAULT_FLAGS, { "Text" } }
|
||||
{ wimp_MENU_GIVE_WARNING, (wimp_menu *)1, DEFAULT_FLAGS, { "Draw" } },
|
||||
{ wimp_MENU_LAST | wimp_MENU_GIVE_WARNING, (wimp_menu *)1, DEFAULT_FLAGS, { "Text" } }
|
||||
}
|
||||
};
|
||||
static wimp_menu *browser_export_menu = (wimp_menu *) &export_menu;
|
||||
|
||||
static wimp_MENU(5) page_menu = {
|
||||
|
||||
/* Page submenu
|
||||
*/
|
||||
static wimp_MENU(7) page_menu = {
|
||||
{ "Page" }, 7,2,7,0, 200, 44, 0,
|
||||
{
|
||||
{ wimp_MENU_GIVE_WARNING, wimp_NO_SUB_MENU, DEFAULT_FLAGS, { "PageInfo" } },
|
||||
{ wimp_MENU_GIVE_WARNING, wimp_NO_SUB_MENU, DEFAULT_FLAGS, { "Save" } },
|
||||
{ wimp_MENU_GIVE_WARNING, wimp_NO_SUB_MENU, DEFAULT_FLAGS, { "SaveComp" } },
|
||||
{ 0, (wimp_menu *) &export_menu, DEFAULT_FLAGS, { "Export" } },
|
||||
{ wimp_MENU_LAST, wimp_NO_SUB_MENU, DEFAULT_FLAGS | wimp_ICON_SHADED, { "Print" } }
|
||||
{ wimp_MENU_GIVE_WARNING, (wimp_menu *)1, DEFAULT_FLAGS, { "PageInfo" } },
|
||||
{ wimp_MENU_GIVE_WARNING, (wimp_menu *)1, DEFAULT_FLAGS, { "Save" } },
|
||||
{ wimp_MENU_GIVE_WARNING, (wimp_menu *)1, DEFAULT_FLAGS, { "SaveComp" } },
|
||||
{ 0, (wimp_menu *)&export_menu, DEFAULT_FLAGS, { "Export" } },
|
||||
{ wimp_MENU_GIVE_WARNING, (wimp_menu *)1, DEFAULT_FLAGS, { "SaveURL" } },
|
||||
{ wimp_MENU_SEPARATE, wimp_NO_SUB_MENU, DEFAULT_FLAGS | wimp_ICON_SHADED, { "Print" } },
|
||||
{ wimp_MENU_LAST, wimp_NO_SUB_MENU, DEFAULT_FLAGS, { "ViewSrc" } }
|
||||
}
|
||||
};
|
||||
static wimp_menu *browser_page_menu = (wimp_menu *) &page_menu;
|
||||
|
||||
|
||||
/* Object export submenu
|
||||
*/
|
||||
static wimp_MENU(2) object_export_menu = {
|
||||
{ "ExportAs" }, 7,2,7,0, 200, 44, 0,
|
||||
{
|
||||
{ wimp_MENU_LAST | wimp_MENU_GIVE_WARNING, (wimp_menu *)1, DEFAULT_FLAGS, { "Sprite" } }
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/* Object submenu
|
||||
*/
|
||||
static wimp_MENU(5) object_menu = {
|
||||
{ "Object" }, 7,2,7,0, 300, 44, 0,
|
||||
{
|
||||
{ wimp_MENU_GIVE_WARNING, (wimp_menu *)1, DEFAULT_FLAGS, { "ObjInfo" } },
|
||||
{ wimp_MENU_GIVE_WARNING, (wimp_menu *)1, DEFAULT_FLAGS, { "ObjSave" } },
|
||||
{ 0, (wimp_menu *)&object_export_menu, DEFAULT_FLAGS, { "Export" } },
|
||||
{ wimp_MENU_GIVE_WARNING | wimp_MENU_SEPARATE, (wimp_menu *)1, DEFAULT_FLAGS, { "SaveURL" } },
|
||||
{ wimp_MENU_LAST, wimp_NO_SUB_MENU, DEFAULT_FLAGS, { "ObjReload" } }
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/* Selection submenu
|
||||
*/
|
||||
static wimp_MENU(3) selection_menu = {
|
||||
{ "Selection" }, 7,2,7,0, 300, 44, 0,
|
||||
{
|
||||
{ 0, wimp_NO_SUB_MENU, DEFAULT_FLAGS | wimp_ICON_SHADED, { "Copy" } },
|
||||
{ 0, wimp_NO_SUB_MENU, DEFAULT_FLAGS | wimp_ICON_SHADED, { "SelectAll" } },
|
||||
{ wimp_MENU_LAST, wimp_NO_SUB_MENU, DEFAULT_FLAGS | wimp_ICON_SHADED, { "Clear" } }
|
||||
{ wimp_MENU_SEPARATE, wimp_NO_SUB_MENU, DEFAULT_FLAGS | wimp_ICON_SHADED, { "Copy" } },
|
||||
{ 0, wimp_NO_SUB_MENU, DEFAULT_FLAGS | wimp_ICON_SHADED, { "SelectAll" } },
|
||||
{ wimp_MENU_LAST, wimp_NO_SUB_MENU, DEFAULT_FLAGS | wimp_ICON_SHADED, { "Clear" } }
|
||||
}
|
||||
};
|
||||
static wimp_menu *browser_selection_menu = (wimp_menu *) &selection_menu;
|
||||
|
||||
|
||||
/* Navigate submenu
|
||||
*/
|
||||
static wimp_MENU(5) navigate_menu = {
|
||||
{ "Navigate" }, 7,2,7,0, 300, 44, 0,
|
||||
{
|
||||
{ 0, wimp_NO_SUB_MENU, DEFAULT_FLAGS | wimp_ICON_SHADED, { "OpenURL" } },
|
||||
{ 0, wimp_NO_SUB_MENU, DEFAULT_FLAGS, { "Home" } },
|
||||
{ 0, wimp_NO_SUB_MENU, DEFAULT_FLAGS, { "Back" } },
|
||||
{ 0, wimp_NO_SUB_MENU, DEFAULT_FLAGS, { "Forward" } },
|
||||
{ wimp_MENU_LAST, wimp_NO_SUB_MENU, DEFAULT_FLAGS | wimp_ICON_SHADED, { "Reload" } }
|
||||
{ 0, wimp_NO_SUB_MENU, DEFAULT_FLAGS, { "Home" } },
|
||||
{ 0, wimp_NO_SUB_MENU, DEFAULT_FLAGS, { "Back" } },
|
||||
{ wimp_MENU_SEPARATE, wimp_NO_SUB_MENU, DEFAULT_FLAGS, { "Forward" } },
|
||||
{ wimp_MENU_LAST, wimp_NO_SUB_MENU, DEFAULT_FLAGS | wimp_ICON_SHADED, { "Reload" } }
|
||||
}
|
||||
};
|
||||
static wimp_menu *browser_navigate_menu = (wimp_menu *) &navigate_menu;
|
||||
|
||||
static wimp_MENU(2) image_menu = {
|
||||
|
||||
/* Image submenu
|
||||
*/
|
||||
static wimp_MENU(5) image_menu = {
|
||||
{ "Images" }, 7,2,7,0, 300, 44, 0,
|
||||
{
|
||||
{ 0, wimp_NO_SUB_MENU, DEFAULT_FLAGS, { "DitherImg" } },
|
||||
{ wimp_MENU_LAST, wimp_NO_SUB_MENU, DEFAULT_FLAGS | wimp_ICON_SHADED, { "FilterImg" } }
|
||||
{ 0, wimp_NO_SUB_MENU, DEFAULT_FLAGS | wimp_ICON_SHADED, { "ForeImg" } },
|
||||
{ 0, wimp_NO_SUB_MENU, DEFAULT_FLAGS | wimp_ICON_SHADED, { "BackImg" } },
|
||||
{ wimp_MENU_SEPARATE, wimp_NO_SUB_MENU, DEFAULT_FLAGS, { "AnimImg" } },
|
||||
{ 0, wimp_NO_SUB_MENU, DEFAULT_FLAGS, { "DitherImg" } },
|
||||
{ wimp_MENU_LAST, wimp_NO_SUB_MENU, DEFAULT_FLAGS, { "FilterImg" } }
|
||||
}
|
||||
};
|
||||
static wimp_menu *browser_image_menu = (wimp_menu *) &image_menu;
|
||||
|
||||
static wimp_MENU(3) view_menu = {
|
||||
|
||||
/* Toolbar submenu
|
||||
*/
|
||||
static wimp_MENU(4) toolbar_menu = {
|
||||
{ "Toolbars" }, 7,2,7,0, 300, 44, 0,
|
||||
{
|
||||
{ 0, wimp_NO_SUB_MENU, DEFAULT_FLAGS, { "ToolButtons" } },
|
||||
{ 0, wimp_NO_SUB_MENU, DEFAULT_FLAGS, { "ToolAddress" } },
|
||||
{ wimp_MENU_SEPARATE, wimp_NO_SUB_MENU, DEFAULT_FLAGS, { "ToolThrob" } },
|
||||
{ wimp_MENU_LAST, wimp_NO_SUB_MENU, DEFAULT_FLAGS, { "ToolStatus" } }
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/* View submenu
|
||||
*/
|
||||
static wimp_MENU(4) view_menu = {
|
||||
{ "View" }, 7,2,7,0, 300, 44, 0,
|
||||
{
|
||||
{ 0, wimp_NO_SUB_MENU, DEFAULT_FLAGS, { "ScaleView" } },
|
||||
{ wimp_MENU_SEPARATE | wimp_MENU_GIVE_WARNING, (wimp_menu *) &image_menu, DEFAULT_FLAGS, { "Images" } },
|
||||
{ wimp_MENU_LAST, wimp_NO_SUB_MENU, DEFAULT_FLAGS, { "ViewSrc" } }
|
||||
{ wimp_MENU_GIVE_WARNING, (wimp_menu *)1, DEFAULT_FLAGS, { "ScaleView" } },
|
||||
{ wimp_MENU_GIVE_WARNING, (wimp_menu *)&image_menu, DEFAULT_FLAGS, { "Images" } },
|
||||
{ wimp_MENU_SEPARATE | wimp_MENU_GIVE_WARNING, (wimp_menu *)&toolbar_menu, DEFAULT_FLAGS, { "Toolbars" } },
|
||||
{ wimp_MENU_LAST, wimp_NO_SUB_MENU, DEFAULT_FLAGS, { "OptDefault" } }
|
||||
}
|
||||
};
|
||||
static wimp_menu *browser_view_menu = (wimp_menu *) &view_menu;
|
||||
|
||||
|
||||
/* Hotlist submenu
|
||||
*/
|
||||
static wimp_MENU(2) hotlist_menu = {
|
||||
{ "Hotlist" }, 7,2,7,0, 300, 44, 0,
|
||||
{
|
||||
{ 0, wimp_NO_SUB_MENU, DEFAULT_FLAGS, { "HotlistAdd" } },
|
||||
{ wimp_MENU_LAST, wimp_NO_SUB_MENU, DEFAULT_FLAGS, { "HotlistShow" } }
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/* Utilities submenu
|
||||
*/
|
||||
static wimp_MENU(4) utilities_menu = {
|
||||
{ "Utilities" }, 7,2,7,0, 300, 44, 0,
|
||||
{
|
||||
{ wimp_MENU_SEPARATE, (wimp_menu *)&hotlist_menu, DEFAULT_FLAGS, { "Hotlist" } },
|
||||
{ 0, wimp_NO_SUB_MENU, DEFAULT_FLAGS, { "FindText" } },
|
||||
{ 0, wimp_NO_SUB_MENU, DEFAULT_FLAGS, { "HistLocal" } },
|
||||
{ wimp_MENU_LAST, wimp_NO_SUB_MENU, DEFAULT_FLAGS, { "HistGlobal" } }
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/* Help submenu
|
||||
*/
|
||||
static wimp_MENU(4) help_menu = {
|
||||
{ "Help" }, 7,2,7,0, 300, 44, 0,
|
||||
{
|
||||
@ -126,22 +220,39 @@ static wimp_MENU(4) help_menu = {
|
||||
{ wimp_MENU_LAST, wimp_NO_SUB_MENU, DEFAULT_FLAGS | wimp_ICON_SHADED, { "HelpInter" } }
|
||||
}
|
||||
};
|
||||
static wimp_menu *browser_help_menu = (wimp_menu *) &help_menu;
|
||||
|
||||
|
||||
/* Main browser menu
|
||||
*/
|
||||
static wimp_MENU(5) menu = {
|
||||
{ "NetSurf" }, 7,2,7,0, 200, 44, 0,
|
||||
{
|
||||
{ 0, (wimp_menu *) &page_menu, DEFAULT_FLAGS, { "Page" } },
|
||||
{ wimp_MENU_SUB_MENU_WHEN_SHADED, (wimp_menu *) &selection_menu, DEFAULT_FLAGS | wimp_ICON_SHADED, { "Selection" } },
|
||||
{ 0, (wimp_menu *) &navigate_menu, DEFAULT_FLAGS, { "Navigate" } },
|
||||
{ 0, (wimp_menu *) &view_menu, DEFAULT_FLAGS, { "View" } },
|
||||
{ wimp_MENU_LAST, (wimp_menu *) &help_menu, DEFAULT_FLAGS, { "Help" } }
|
||||
{ 0, (wimp_menu *)&page_menu, DEFAULT_FLAGS, { "Page" } },
|
||||
// { 0, (wimp_menu *)&object_menu, DEFAULT_FLAGS, { "Object" } },
|
||||
// { 0, (wimp_menu *)&selection_menu, DEFAULT_FLAGS, { "Selection" } },
|
||||
{ 0, (wimp_menu *)&navigate_menu, DEFAULT_FLAGS, { "Navigate" } },
|
||||
{ 0, (wimp_menu *)&view_menu, DEFAULT_FLAGS, { "View" } },
|
||||
// { 0, (wimp_menu *)&utilities_menu, DEFAULT_FLAGS, { "Utilities" } },
|
||||
{ wimp_MENU_LAST, (wimp_menu *)&help_menu, DEFAULT_FLAGS, { "Help" } }
|
||||
}
|
||||
};
|
||||
wimp_menu *browser_menu = (wimp_menu *) &menu;
|
||||
|
||||
|
||||
static wimp_menu *browser_page_menu = (wimp_menu *)&page_menu;
|
||||
static wimp_menu *browser_export_menu = (wimp_menu *)&export_menu;
|
||||
static wimp_menu *browser_object_menu = (wimp_menu *)&object_menu;
|
||||
static wimp_menu *browser_object_export_menu = (wimp_menu *)&object_export_menu;
|
||||
static wimp_menu *browser_selection_menu = (wimp_menu *)&selection_menu;
|
||||
static wimp_menu *browser_navigate_menu = (wimp_menu *)&navigate_menu;
|
||||
static wimp_menu *browser_view_menu = (wimp_menu *)&view_menu;
|
||||
static wimp_menu *browser_image_menu = (wimp_menu *)&image_menu;
|
||||
static wimp_menu *browser_toolbar_menu = (wimp_menu *)&toolbar_menu;
|
||||
static wimp_menu *browser_utilities_menu = (wimp_menu *)&utilities_menu;
|
||||
static wimp_menu *browser_hotlist_menu = (wimp_menu *)&hotlist_menu;
|
||||
static wimp_menu *browser_help_menu = (wimp_menu *)&help_menu;
|
||||
|
||||
|
||||
/**
|
||||
* Create menu structures.
|
||||
*/
|
||||
@ -152,19 +263,24 @@ void ro_gui_menus_init(void)
|
||||
translate_menu(browser_menu);
|
||||
translate_menu(browser_page_menu);
|
||||
translate_menu(browser_export_menu);
|
||||
translate_menu(browser_object_menu);
|
||||
translate_menu(browser_object_export_menu);
|
||||
translate_menu(browser_selection_menu);
|
||||
translate_menu(browser_navigate_menu);
|
||||
translate_menu(browser_view_menu);
|
||||
translate_menu(browser_image_menu);
|
||||
translate_menu(browser_toolbar_menu);
|
||||
translate_menu(browser_utilities_menu);
|
||||
translate_menu(browser_hotlist_menu);
|
||||
translate_menu(browser_help_menu);
|
||||
|
||||
iconbar_menu->entries[0].sub_menu = (wimp_menu *) dialog_info;
|
||||
browser_page_menu->entries[0].sub_menu = (wimp_menu*) dialog_pageinfo;
|
||||
browser_page_menu->entries[1].sub_menu = (wimp_menu *) dialog_saveas;
|
||||
browser_page_menu->entries[2].sub_menu = (wimp_menu *) dialog_saveas;
|
||||
browser_export_menu->entries[0].sub_menu = (wimp_menu *) dialog_saveas;
|
||||
browser_export_menu->entries[1].sub_menu = (wimp_menu *) dialog_saveas;
|
||||
browser_view_menu->entries[0].sub_menu = (wimp_menu *) dialog_zoom;
|
||||
// browser_page_menu->entries[1].sub_menu = (wimp_menu *) dialog_saveas;
|
||||
// browser_page_menu->entries[2].sub_menu = (wimp_menu *) dialog_saveas;
|
||||
// browser_export_menu->entries[0].sub_menu = (wimp_menu *) dialog_saveas;
|
||||
// browser_export_menu->entries[1].sub_menu = (wimp_menu *) dialog_saveas;
|
||||
// browser_view_menu->entries[0].sub_menu = (wimp_menu *) dialog_zoom;
|
||||
}
|
||||
|
||||
|
||||
@ -272,21 +388,26 @@ void ro_gui_menu_selection(wimp_selection *selection)
|
||||
} else if (current_menu == browser_menu) {
|
||||
struct content *c = current_gui->data.browser.bw->current_content;
|
||||
switch (selection->items[0]) {
|
||||
case 0: /* Page -> */
|
||||
case MENU_PAGE:
|
||||
switch (selection->items[1]) {
|
||||
case 0: /* Info */
|
||||
break;
|
||||
case 1: /* Save */
|
||||
break;
|
||||
case 2: /* Save complete */
|
||||
case 2: /* Full save */
|
||||
break;
|
||||
case 3: /* Export */
|
||||
break;
|
||||
case 4: /* Print */
|
||||
case 4: /* Save location */
|
||||
break;
|
||||
case 5: /* Print */
|
||||
break;
|
||||
case 6: /* Page source */
|
||||
ro_gui_view_source(c);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 1: /* Selection -> */
|
||||
case MENU_SELECTION:
|
||||
switch (selection->items[1]) {
|
||||
case 0: /* Copy to clipboard */
|
||||
ro_gui_copy_selection(current_gui);
|
||||
@ -299,43 +420,72 @@ void ro_gui_menu_selection(wimp_selection *selection)
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 2: /* Navigate -> */
|
||||
case MENU_NAVIGATE:
|
||||
switch (selection->items[1]) {
|
||||
case 0: /* Open URL... */
|
||||
case 0: /* Home */
|
||||
break;
|
||||
case 1: /* Home */
|
||||
break;
|
||||
case 2: /* Back */
|
||||
case 1: /* Back */
|
||||
history_back(current_gui->data.browser.bw,
|
||||
current_gui->data.browser.bw->history);
|
||||
break;
|
||||
case 3: /* Forward */
|
||||
case 2: /* Forward */
|
||||
history_forward(current_gui->data.browser.bw,
|
||||
current_gui->data.browser.bw->history);
|
||||
break;
|
||||
case 4: /* Reload */
|
||||
case 3: /* Reload */
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 3: /* View -> */
|
||||
case MENU_VIEW:
|
||||
switch (selection->items[1]) {
|
||||
case 0: /* Scale view */
|
||||
break;
|
||||
case 1: /* Images -> */
|
||||
if (selection->items[2] == 0) option_dither_sprites = !option_dither_sprites;
|
||||
if (selection->items[2] == 1) option_filter_sprites = !option_filter_sprites;
|
||||
if (selection->items[2] >= 0) {
|
||||
if (selection->items[2] == 2) current_gui->option_animate_images =
|
||||
!current_gui->option_animate_images;
|
||||
if (selection->items[2] == 3) current_gui->option_dither_sprites =
|
||||
!current_gui->option_dither_sprites;
|
||||
if (selection->items[2] == 4) current_gui->option_filter_sprites =
|
||||
!current_gui->option_filter_sprites;
|
||||
if (selection->items[2] >= 2) {
|
||||
ro_gui_menu_prepare_images();
|
||||
/* content_broadcast(c, CONTENT_MSG_REDRAW, 0); */
|
||||
|
||||
gui_window_redraw_window(current_gui);
|
||||
// content_broadcast(c, CONTENT_MSG_REDRAW, 0);
|
||||
}
|
||||
break;
|
||||
case 2: /* Page source */
|
||||
ro_gui_view_source(c);
|
||||
case 2: /* Toolbars -> */
|
||||
switch (selection->items[2]) {
|
||||
case 0:
|
||||
current_gui->data.browser.toolbar->standard_buttons =
|
||||
!current_gui->data.browser.toolbar->standard_buttons;
|
||||
break;
|
||||
case 1:
|
||||
current_gui->data.browser.toolbar->url_bar =
|
||||
!current_gui->data.browser.toolbar->url_bar;
|
||||
break;
|
||||
case 2:
|
||||
current_gui->data.browser.toolbar->throbber =
|
||||
!current_gui->data.browser.toolbar->throbber;
|
||||
break;
|
||||
case 3:
|
||||
current_gui->data.browser.toolbar->status_window =
|
||||
!current_gui->data.browser.toolbar->status_window;
|
||||
}
|
||||
if (ro_theme_update_toolbar(current_gui) || true) {
|
||||
wimp_window_state state;
|
||||
state.w = current_gui->window;
|
||||
wimp_get_window_state(&state);
|
||||
current_gui->data.browser.old_height = 0xffffffff;
|
||||
ro_gui_window_open(current_gui, (wimp_open *)&state);
|
||||
}
|
||||
ro_gui_menu_prepare_toolbars();
|
||||
break;
|
||||
case 3: /* Make default */
|
||||
gui_window_default_options(current_gui->data.browser.bw);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 4: /* Help -> */
|
||||
case MENU_HELP:
|
||||
switch (selection->items[1]) {
|
||||
case -1: /* No sub-item */
|
||||
case 0: /* Contents */
|
||||
@ -373,11 +523,8 @@ void ro_gui_menu_warning(wimp_message_menu_warning *warning)
|
||||
struct content *c = current_gui->data.browser.bw->current_content;
|
||||
os_error *error = NULL; // No warnings
|
||||
|
||||
// if ((warning->selection.items[0] != 0) && (warning->selection.items[0] != 3))
|
||||
// return;
|
||||
|
||||
switch (warning->selection.items[0]) {
|
||||
case 0: /* Page -> */
|
||||
case MENU_PAGE: /* Page -> */
|
||||
switch (warning->selection.items[1]) {
|
||||
case 3: /* Export as -> */
|
||||
switch (warning->selection.items[2]) {
|
||||
@ -409,13 +556,23 @@ void ro_gui_menu_warning(wimp_message_menu_warning *warning)
|
||||
error = xwimp_create_sub_menu((wimp_menu *) dialog_saveas,
|
||||
warning->pos.x, warning->pos.y);
|
||||
break;
|
||||
case 3: /* View -> */
|
||||
case MENU_VIEW: /* View -> */
|
||||
switch (warning->selection.items[1]) {
|
||||
case 0: /* Scale view -> */
|
||||
ro_gui_menu_prepare_scale();
|
||||
error = xwimp_create_sub_menu((wimp_menu *) dialog_zoom,
|
||||
warning->pos.x, warning->pos.y);
|
||||
break;
|
||||
case 1: /* Images -> */
|
||||
ro_gui_menu_prepare_images();
|
||||
error = xwimp_create_sub_menu(browser_image_menu,
|
||||
warning->pos.x, warning->pos.y);
|
||||
break;
|
||||
case 2: /* Toolbars -> */
|
||||
ro_gui_menu_prepare_toolbars();
|
||||
error = xwimp_create_sub_menu(browser_toolbar_menu,
|
||||
warning->pos.x, warning->pos.y);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -473,22 +630,64 @@ void ro_gui_menu_prepare_save(struct content *c)
|
||||
ro_gui_set_icon_string(dialog_saveas, ICON_SAVE_PATH, name);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Update image menu status
|
||||
*/
|
||||
|
||||
static void ro_gui_menu_prepare_images(void) {
|
||||
if (current_menu != browser_menu) return;
|
||||
|
||||
/* We don't currently have any local options so we update from the global ones
|
||||
*/
|
||||
browser_image_menu->entries[0].menu_flags &= ~wimp_MENU_TICKED;
|
||||
if (option_dither_sprites) browser_image_menu->entries[0].menu_flags |= wimp_MENU_TICKED;
|
||||
browser_image_menu->entries[1].menu_flags &= ~wimp_MENU_TICKED;
|
||||
if (option_filter_sprites) browser_image_menu->entries[1].menu_flags |= wimp_MENU_TICKED;
|
||||
browser_image_menu->entries[2].menu_flags &= ~wimp_MENU_TICKED;
|
||||
if (current_gui->option_animate_images) browser_image_menu->entries[2].menu_flags |= wimp_MENU_TICKED;
|
||||
browser_image_menu->entries[3].menu_flags &= ~wimp_MENU_TICKED;
|
||||
if (current_gui->option_dither_sprites) browser_image_menu->entries[3].menu_flags |= wimp_MENU_TICKED;
|
||||
browser_image_menu->entries[4].menu_flags &= ~wimp_MENU_TICKED;
|
||||
if (current_gui->option_filter_sprites) browser_image_menu->entries[4].menu_flags |= wimp_MENU_TICKED;
|
||||
}
|
||||
|
||||
|
||||
// content_broadcast(c, CONTENT_MSG_REDRAW, 0);
|
||||
/**
|
||||
* Update toolbar menu status
|
||||
*/
|
||||
static void ro_gui_menu_prepare_toolbars(void) {
|
||||
int index;
|
||||
struct toolbar *toolbar;
|
||||
if (current_menu != browser_menu) return;
|
||||
|
||||
/* Check we have a toolbar
|
||||
*/
|
||||
toolbar = current_gui->data.browser.toolbar;
|
||||
|
||||
/* Set our ticks, or shade everything if there's no toolbar
|
||||
*/
|
||||
if (toolbar) {
|
||||
for (index = 0; index < 4; index++) {
|
||||
browser_toolbar_menu->entries[index].icon_flags &= ~wimp_ICON_SHADED;
|
||||
browser_toolbar_menu->entries[index].menu_flags &= ~wimp_MENU_TICKED;
|
||||
}
|
||||
if (toolbar->standard_buttons) browser_toolbar_menu->entries[0].menu_flags |= wimp_MENU_TICKED;
|
||||
if (toolbar->url_bar) browser_toolbar_menu->entries[1].menu_flags |= wimp_MENU_TICKED;
|
||||
if (toolbar->throbber) browser_toolbar_menu->entries[2].menu_flags |= wimp_MENU_TICKED;
|
||||
if (toolbar->status_window) browser_toolbar_menu->entries[3].menu_flags |= wimp_MENU_TICKED;
|
||||
} else {
|
||||
for (index = 0; index < 4; index++) {
|
||||
browser_toolbar_menu->entries[index].icon_flags |= wimp_ICON_SHADED;
|
||||
browser_toolbar_menu->entries[index].menu_flags &= ~wimp_MENU_TICKED;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Update scale to current document value
|
||||
*/
|
||||
void ro_gui_menu_prepare_scale(void) {
|
||||
char scale_buffer[8];
|
||||
if (current_menu != browser_menu) return;
|
||||
sprintf(scale_buffer, "%.0f", current_gui->scale * 100);
|
||||
ro_gui_set_icon_string(dialog_zoom, ICON_ZOOM_VALUE, scale_buffer);
|
||||
}
|
||||
|
||||
void ro_gui_menu_pageinfo(wimp_message_menu_warning *warning)
|
||||
|
@ -25,6 +25,13 @@ extern bool option_filter_sprites;
|
||||
extern bool option_thumbnail_32bpp;
|
||||
extern int option_thumbnail_oversampling;
|
||||
extern bool option_history_tooltip;
|
||||
extern int option_scale;
|
||||
extern int option_toolbar_status_width;
|
||||
extern bool option_toolbar_show_status;
|
||||
extern bool option_toolbar_show_buttons;
|
||||
extern bool option_toolbar_show_address;
|
||||
extern bool option_toolbar_show_throbber;
|
||||
extern bool option_animate_images;
|
||||
|
||||
#define EXTRA_OPTION_DEFINE \
|
||||
bool option_use_mouse_gestures = false;\
|
||||
@ -36,7 +43,14 @@ bool option_dither_sprites = true;\
|
||||
bool option_filter_sprites = false;\
|
||||
bool option_thumbnail_32bpp = true;\
|
||||
int option_thumbnail_oversampling = 0;\
|
||||
bool option_history_tooltip = true;
|
||||
bool option_history_tooltip = true; \
|
||||
int option_scale = 100; \
|
||||
int option_toolbar_status_width = 640; \
|
||||
bool option_toolbar_show_status = true; \
|
||||
bool option_toolbar_show_buttons = true; \
|
||||
bool option_toolbar_show_address = true; \
|
||||
bool option_toolbar_show_throbber = true; \
|
||||
bool option_animate_images = true;
|
||||
|
||||
#define EXTRA_OPTION_TABLE \
|
||||
{ "use_mouse_gestures", OPTION_BOOL, &option_use_mouse_gestures },\
|
||||
@ -48,6 +62,13 @@ bool option_history_tooltip = true;
|
||||
{ "filter_sprites", OPTION_BOOL, &option_filter_sprites },\
|
||||
{ "thumbnail_32bpp", OPTION_BOOL, &option_thumbnail_32bpp },\
|
||||
{ "thumbnail_oversampling", OPTION_INTEGER, &option_thumbnail_oversampling },\
|
||||
{ "history_tooltip", OPTION_BOOL, &option_history_tooltip }
|
||||
{ "history_tooltip", OPTION_BOOL, &option_history_tooltip }, \
|
||||
{ "scale", OPTION_INTEGER, &option_scale }, \
|
||||
{ "toolbar_show_status", OPTION_BOOL, &option_toolbar_show_status }, \
|
||||
{ "toolbar_status_width", OPTION_INTEGER, &option_toolbar_status_width }, \
|
||||
{ "toolbar_show_buttons", OPTION_BOOL, &option_toolbar_show_buttons }, \
|
||||
{ "toolbar_show_address", OPTION_BOOL, &option_toolbar_show_address }, \
|
||||
{ "toolbar_show_throbber", OPTION_BOOL, &option_toolbar_show_throbber }, \
|
||||
{ "animate_images", OPTION_BOOL, &option_animate_images }
|
||||
|
||||
#endif
|
||||
|
@ -1290,7 +1290,7 @@ void plugin_url_access(wimp_message *message) {
|
||||
browser_window_go(npl->bw, url);
|
||||
}
|
||||
else if (strcasecmp(window, "_blank") == 0) {
|
||||
browser_window_create(url);
|
||||
browser_window_create(url, NULL);
|
||||
}
|
||||
}
|
||||
else { /* POST request */
|
||||
|
326
riscos/theme.c
326
riscos/theme.c
@ -4,6 +4,7 @@
|
||||
* http://www.opensource.org/licenses/gpl-license
|
||||
* Copyright 2003 Phil Mellor <monkeyson@users.sourceforge.net>
|
||||
* Copyright 2003 James Bursa <bursa@users.sourceforge.net>
|
||||
* Copyright 2004 Richard Wilson <not_ginger_matt@users.sourceforge.net>
|
||||
*/
|
||||
|
||||
/** \file
|
||||
@ -14,16 +15,27 @@
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "oslib/os.h"
|
||||
#include "oslib/osfile.h"
|
||||
#include "oslib/osspriteop.h"
|
||||
#include "oslib/wimp.h"
|
||||
#include "oslib/wimpspriteop.h"
|
||||
#include "netsurf/riscos/gui.h"
|
||||
#include "netsurf/riscos/theme.h"
|
||||
#include "netsurf/riscos/toolbar.h"
|
||||
#include "netsurf/riscos/wimp.h"
|
||||
#include "netsurf/utils/utils.h"
|
||||
#include "netsurf/utils/log.h"
|
||||
|
||||
static wimp_window *theme_toolbar_template = 0;
|
||||
/* Current sprite area
|
||||
*/
|
||||
static osspriteop_area *theme_sprite_area = 0;
|
||||
unsigned int theme_throbs;
|
||||
|
||||
/* Throbber details
|
||||
*/
|
||||
int theme_throbs;
|
||||
static int throbber_width;
|
||||
static int throbber_height;
|
||||
|
||||
|
||||
/**
|
||||
@ -33,72 +45,74 @@ unsigned int theme_throbs;
|
||||
* and a Sprites file containing icons.
|
||||
*/
|
||||
|
||||
void ro_theme_load(char *pathname)
|
||||
{
|
||||
char name[] = "toolbar";
|
||||
int context, window_size, data_size, size, i;
|
||||
static char *data = 0;
|
||||
char *filename = alloca(strlen(pathname) + 12);
|
||||
void ro_theme_load(char *pathname) {
|
||||
osbool mask;
|
||||
os_mode mode;
|
||||
os_coord dimensions;
|
||||
int size, i, n;
|
||||
char filename[strlen(pathname) + 16];
|
||||
fileswitch_object_type obj_type;
|
||||
|
||||
/* free old theme data */
|
||||
free(theme_toolbar_template);
|
||||
free(data);
|
||||
/* Release previous sprite are
|
||||
*/
|
||||
free(theme_sprite_area);
|
||||
theme_sprite_area = NULL;
|
||||
|
||||
/* load template */
|
||||
sprintf(filename, "%s.Templates", pathname);
|
||||
wimp_open_template(filename);
|
||||
|
||||
/* find required buffer sizes */
|
||||
context = wimp_load_template(wimp_GET_SIZE, 0, 0, wimp_NO_FONTS,
|
||||
name, 0, &window_size, &data_size);
|
||||
assert(context != 0);
|
||||
|
||||
theme_toolbar_template = xcalloc((unsigned int) window_size, 1);
|
||||
data = xcalloc((unsigned int) data_size, 1);
|
||||
|
||||
/* load */
|
||||
wimp_load_template(theme_toolbar_template, data, data + data_size,
|
||||
wimp_NO_FONTS, name, 0, 0, 0);
|
||||
|
||||
wimp_close_template();
|
||||
|
||||
assert(ICON_TOOLBAR_RELOAD < theme_toolbar_template->icon_count);
|
||||
theme_toolbar_template->flags |= wimp_WINDOW_FURNITURE_WINDOW;
|
||||
theme_toolbar_template->icons[ICON_TOOLBAR_URL].data.indirected_text.size = 256;
|
||||
theme_toolbar_template->icons[ICON_TOOLBAR_STATUS].data.indirected_text.size = 256;
|
||||
|
||||
/* load sprites */
|
||||
sprintf(filename, "%s.Sprites", pathname);
|
||||
obj_type = osfile_read_no_path(filename, 0, 0, &size, 0);
|
||||
assert(obj_type & fileswitch_IS_FILE);
|
||||
|
||||
theme_sprite_area = xcalloc((unsigned int)(size + 16), 1);
|
||||
theme_sprite_area->size = size + 16;
|
||||
theme_sprite_area->sprite_count = 0;
|
||||
theme_sprite_area->first = 16;
|
||||
theme_sprite_area->used = 16;
|
||||
osspriteop_clear_sprites(osspriteop_USER_AREA, theme_sprite_area);
|
||||
osspriteop_load_sprite_file(osspriteop_USER_AREA, theme_sprite_area,
|
||||
filename);
|
||||
|
||||
theme_toolbar_template->sprite_area = theme_sprite_area;
|
||||
theme_toolbar_template->icons[ICON_TOOLBAR_THROBBER].data.indirected_sprite.area =
|
||||
theme_sprite_area;
|
||||
|
||||
/* find the highest sprite called throbber%i */
|
||||
/* Reset the throbber variables
|
||||
*/
|
||||
theme_throbs = 0;
|
||||
for (i = 1; i <= theme_sprite_area->sprite_count; i++) {
|
||||
char name[32];
|
||||
osspriteop_return_name(osspriteop_USER_AREA,
|
||||
theme_sprite_area, name, 32, i);
|
||||
if (strncmp(name, "throbber", 8) == 0) {
|
||||
unsigned int n = atoi(name + 8);
|
||||
if (theme_throbs < n)
|
||||
theme_throbs = n;
|
||||
throbber_height = 0;
|
||||
throbber_width = 0;
|
||||
|
||||
/* Load the sprites
|
||||
*/
|
||||
sprintf(filename, "%s.Sprites", pathname);
|
||||
xosfile_read_no_path(filename, &obj_type, 0, 0, &size, 0);
|
||||
|
||||
/* Claim memory for a sprite file if we have one
|
||||
*/
|
||||
if (obj_type & fileswitch_IS_FILE) theme_sprite_area = malloc(size + 16);
|
||||
|
||||
/* Load the sprite file if we have any memory
|
||||
*/
|
||||
if (theme_sprite_area) {
|
||||
|
||||
/* Initialise then load
|
||||
*/
|
||||
theme_sprite_area->size = size + 16;
|
||||
theme_sprite_area->sprite_count = 0;
|
||||
theme_sprite_area->first = 16;
|
||||
theme_sprite_area->used = 16;
|
||||
xosspriteop_clear_sprites(osspriteop_USER_AREA, theme_sprite_area);
|
||||
xosspriteop_load_sprite_file(osspriteop_USER_AREA, theme_sprite_area,
|
||||
filename);
|
||||
|
||||
/* Find the highest sprite called 'throbber%i', and get the maximum
|
||||
dimensions for all 'thobber%i' icons. We use the filename buffer
|
||||
as the temporary spritename buffer as it is guaranteed to be at
|
||||
least 12 bytes (max sprite name size).
|
||||
*/
|
||||
for (i = 1; i <= theme_sprite_area->sprite_count; i++) {
|
||||
osspriteop_return_name(osspriteop_USER_AREA,
|
||||
theme_sprite_area, filename, 12, i);
|
||||
if (strncmp(filename, "throbber", 8) == 0) {
|
||||
/* Get the max sprite width/height
|
||||
*/
|
||||
xosspriteop_read_sprite_info(osspriteop_USER_AREA,
|
||||
theme_sprite_area, (osspriteop_id)filename,
|
||||
&dimensions.x, &dimensions.y, &mask, &mode);
|
||||
ro_convert_pixels_to_os_units(&dimensions, mode);
|
||||
if (dimensions.x > throbber_width) throbber_width = dimensions.x;
|
||||
if (dimensions.y > throbber_height) throbber_height = dimensions.y;
|
||||
|
||||
/* Get the throbber number
|
||||
*/
|
||||
n = atoi(filename + 8);
|
||||
if (theme_throbs < n) theme_throbs = n;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -109,44 +123,184 @@ void ro_theme_load(char *pathname)
|
||||
* throbber_buffer at least 12 bytes;
|
||||
*/
|
||||
|
||||
wimp_w ro_theme_create_toolbar(char *url_buffer, char *status_buffer,
|
||||
char *throbber_buffer)
|
||||
{
|
||||
wimp_w w;
|
||||
void ro_theme_create_toolbar(gui_window *g) {
|
||||
struct toolbar *toolbar;
|
||||
|
||||
theme_toolbar_template->icons[ICON_TOOLBAR_URL].data.indirected_text.text = url_buffer;
|
||||
theme_toolbar_template->icons[ICON_TOOLBAR_STATUS].data.indirected_text.text = status_buffer;
|
||||
theme_toolbar_template->icons[ICON_TOOLBAR_THROBBER].data.indirected_sprite.id =
|
||||
(osspriteop_id) throbber_buffer;
|
||||
/* Destroy any previous toolbar (paranoia)
|
||||
*/
|
||||
if (g->data.browser.toolbar) {
|
||||
ro_toolbar_destroy(g->data.browser.toolbar);
|
||||
g->data.browser.toolbar = NULL;
|
||||
}
|
||||
/* Create a toolbar
|
||||
*/
|
||||
toolbar = ro_toolbar_create(theme_sprite_area, g->url, g->status, g->throb_buf);
|
||||
if (toolbar == NULL) return;
|
||||
|
||||
w = wimp_create_window(theme_toolbar_template);
|
||||
return w;
|
||||
/* Set up the throbber
|
||||
*/
|
||||
toolbar->throbber_width = throbber_width;
|
||||
toolbar->throbber_height = throbber_height;
|
||||
toolbar->status_width = 640;
|
||||
|
||||
/* Store our toolbar
|
||||
*/
|
||||
g->data.browser.toolbar = toolbar;
|
||||
|
||||
/* Update the toolbar
|
||||
*/
|
||||
ro_theme_update_toolbar(g);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the height of the current toolbar.
|
||||
* Updates any toolbar flags (eg closes windows, hides icons etc)
|
||||
*
|
||||
* \return non-zero if the toolbar height has changed
|
||||
*/
|
||||
int ro_theme_update_toolbar(gui_window *g) {
|
||||
wimp_outline outline;
|
||||
wimp_window_state state;
|
||||
struct toolbar *toolbar;
|
||||
int return_value = 0;
|
||||
|
||||
int ro_theme_toolbar_height(void)
|
||||
{
|
||||
return abs(theme_toolbar_template->extent.y1 - theme_toolbar_template->extent.y0) + 2;
|
||||
/* Set an update as pending
|
||||
*/
|
||||
toolbar = g->data.browser.toolbar;
|
||||
toolbar->update_pending = true;
|
||||
|
||||
/* Close the status window if we should, or resize it
|
||||
*/
|
||||
if (toolbar->status_window) {
|
||||
|
||||
/* Update the status height
|
||||
*/
|
||||
ro_toolbar_resize_status(toolbar, ro_get_hscroll_height(g->window) - 2);
|
||||
} else {
|
||||
xwimp_close_window(toolbar->status_handle);
|
||||
}
|
||||
|
||||
/* Update the toolbar height
|
||||
*/
|
||||
return_value = ro_theme_resize_toolbar(g);
|
||||
|
||||
/* Open/close the toolbar
|
||||
*/
|
||||
if (toolbar->height > 0) {
|
||||
outline.w = g->window;
|
||||
xwimp_get_window_outline(&outline);
|
||||
state.w = g->window;
|
||||
xwimp_get_window_state(&state);
|
||||
state.w = toolbar->toolbar_handle;
|
||||
state.visible.x1 = outline.outline.x1 - 2;
|
||||
state.visible.y0 = state.visible.y1 - toolbar->height;
|
||||
state.xscroll = 0;
|
||||
state.yscroll = 0;
|
||||
state.next = wimp_TOP;
|
||||
xwimp_open_window_nested((wimp_open *)&state, g->window,
|
||||
wimp_CHILD_LINKS_PARENT_VISIBLE_BOTTOM_OR_LEFT
|
||||
<< wimp_CHILD_XORIGIN_SHIFT |
|
||||
wimp_CHILD_LINKS_PARENT_VISIBLE_TOP_OR_RIGHT
|
||||
<< wimp_CHILD_YORIGIN_SHIFT |
|
||||
wimp_CHILD_LINKS_PARENT_VISIBLE_BOTTOM_OR_LEFT
|
||||
<< wimp_CHILD_LS_EDGE_SHIFT |
|
||||
wimp_CHILD_LINKS_PARENT_VISIBLE_TOP_OR_RIGHT
|
||||
<< wimp_CHILD_BS_EDGE_SHIFT |
|
||||
wimp_CHILD_LINKS_PARENT_VISIBLE_TOP_OR_RIGHT
|
||||
<< wimp_CHILD_RS_EDGE_SHIFT |
|
||||
wimp_CHILD_LINKS_PARENT_VISIBLE_TOP_OR_RIGHT
|
||||
<< wimp_CHILD_TS_EDGE_SHIFT);
|
||||
} else {
|
||||
xwimp_close_window(toolbar->toolbar_handle);
|
||||
}
|
||||
|
||||
/* Return
|
||||
*/
|
||||
return return_value;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Resize the URL icon in a toolbar.
|
||||
* Resize the status and toolbar windows.
|
||||
*
|
||||
* \return non-zero if the toolbar height has changed
|
||||
*/
|
||||
int ro_theme_resize_toolbar(gui_window *g) {
|
||||
os_box extent = { 0, 0, 0, 0 };
|
||||
struct toolbar *toolbar;
|
||||
wimp_outline outline;
|
||||
wimp_outline status_outline;
|
||||
wimp_window_state state;
|
||||
int width, status_width;
|
||||
int return_value = 0;
|
||||
|
||||
void ro_theme_resize_toolbar(wimp_w w, int width, int height)
|
||||
{
|
||||
wimp_icon_state ic;
|
||||
ic.w = w;
|
||||
ic.i = ICON_TOOLBAR_URL;
|
||||
wimp_get_icon_state(&ic);
|
||||
/* Paranoia
|
||||
*/
|
||||
toolbar = g->data.browser.toolbar;
|
||||
if (toolbar == NULL) return 0;
|
||||
|
||||
wimp_resize_icon(w, ICON_TOOLBAR_URL, ic.icon.extent.x0, ic.icon.extent.y0,
|
||||
width - 8, ic.icon.extent.y1);
|
||||
wimp_force_redraw(w, ic.icon.extent.x0, ic.icon.extent.y0,
|
||||
width, ic.icon.extent.y1);
|
||||
/* Get the toolbar width
|
||||
*/
|
||||
outline.w = g->window;
|
||||
if (xwimp_get_window_outline(&outline)) return 0;
|
||||
width = outline.outline.x1 - outline.outline.x0 - 2;
|
||||
|
||||
/* Reformat if we should
|
||||
*/
|
||||
if ((toolbar->width != width) || (toolbar->resize_status) || (toolbar->update_pending)) {
|
||||
if (toolbar->resize_status) {
|
||||
status_outline.w = toolbar->status_handle;
|
||||
if (xwimp_get_window_outline(&status_outline)) return 0;
|
||||
toolbar->status_width = width -
|
||||
(status_outline.outline.x1 - status_outline.outline.x0 - 4);
|
||||
toolbar->resize_status = 0;
|
||||
} else {
|
||||
/* Update the extent of the status window
|
||||
*/
|
||||
state.w = g->window;
|
||||
if (xwimp_get_window_state(&state)) return 0;
|
||||
extent.x1 = state.visible.x1 - state.visible.x0;
|
||||
extent.y1 = toolbar->status_height - 2;
|
||||
xwimp_set_extent(toolbar->status_handle, &extent);
|
||||
|
||||
/* Re-open the status window as we can't use the nested
|
||||
wimp to manage everything as it would keep extending
|
||||
the size incorrectly.
|
||||
*/
|
||||
status_width = width - toolbar->status_width;
|
||||
if (status_width < 12) status_width = 12;
|
||||
if (toolbar->status_window) {
|
||||
state.w = toolbar->status_handle;
|
||||
state.xscroll = 0;
|
||||
state.yscroll = 0;
|
||||
state.next = wimp_TOP;
|
||||
state.visible.x0 = outline.outline.x0;
|
||||
state.visible.x1 = outline.outline.x0 + status_width;
|
||||
state.visible.y0 = outline.outline.y0 - toolbar->status_height;
|
||||
state.visible.y1 = outline.outline.y0 - 2;
|
||||
xwimp_open_window_nested((wimp_open *) &state, g->window,
|
||||
wimp_CHILD_LINKS_PARENT_VISIBLE_BOTTOM_OR_LEFT
|
||||
<< wimp_CHILD_XORIGIN_SHIFT |
|
||||
wimp_CHILD_LINKS_PARENT_VISIBLE_BOTTOM_OR_LEFT
|
||||
<< wimp_CHILD_YORIGIN_SHIFT |
|
||||
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_TOP_OR_RIGHT
|
||||
<< wimp_CHILD_RS_EDGE_SHIFT |
|
||||
wimp_CHILD_LINKS_PARENT_VISIBLE_BOTTOM_OR_LEFT
|
||||
<< wimp_CHILD_TS_EDGE_SHIFT);
|
||||
} else {
|
||||
if (toolbar->update_pending) {
|
||||
xwimp_close_window(toolbar->status_handle);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Resize the toolbar
|
||||
*/
|
||||
return ro_toolbar_reformat(toolbar, width);
|
||||
}
|
||||
return return_value;
|
||||
}
|
||||
|
@ -4,14 +4,14 @@
|
||||
* http://www.opensource.org/licenses/gpl-license
|
||||
* Copyright 2003 Phil Mellor <monkeyson@users.sourceforge.net>
|
||||
* Copyright 2003 James Bursa <bursa@users.sourceforge.net>
|
||||
* Copyright 2004 Richard Wilson <not_ginger_matt@users.sourceforge.net>
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* Toolbar themes (interface).
|
||||
*
|
||||
* A theme consists of a template for the toolbar and icons. There is one
|
||||
* current theme, which is changed by ro_theme_load(). A toolbar can then be
|
||||
* created and manipulated.
|
||||
* A theme consists of a simple sprite file. There is one current theme, which
|
||||
* is changed by ro_theme_load(). A toolbar can then be created and manipulated.
|
||||
*/
|
||||
|
||||
#ifndef _NETSURF_RISCOS_THEME_H_
|
||||
@ -19,12 +19,11 @@
|
||||
|
||||
#include "oslib/wimp.h"
|
||||
|
||||
extern unsigned int theme_throbs;
|
||||
extern int theme_throbs;
|
||||
|
||||
void ro_theme_load(char *pathname);
|
||||
wimp_w ro_theme_create_toolbar(char *url_buffer, char *status_buffer,
|
||||
char *throbber_buffer);
|
||||
int ro_theme_toolbar_height(void);
|
||||
void ro_theme_resize_toolbar(wimp_w w, int width, int height);
|
||||
void ro_theme_create_toolbar(gui_window *g);
|
||||
int ro_theme_update_toolbar(gui_window *g);
|
||||
int ro_theme_resize_toolbar(gui_window *g);
|
||||
|
||||
#endif
|
||||
|
696
riscos/toolbar.c
Normal file
696
riscos/toolbar.c
Normal file
@ -0,0 +1,696 @@
|
||||
/*
|
||||
* 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 Richard Wilson <not_ginger_matt@users.sourceforge.net>
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* Customisable toolbars (implementation).
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "oslib/os.h"
|
||||
#include "oslib/osspriteop.h"
|
||||
#include "oslib/wimp.h"
|
||||
#include "oslib/wimpspriteop.h"
|
||||
#include "netsurf/riscos/gui.h"
|
||||
#include "netsurf/riscos/toolbar.h"
|
||||
#include "netsurf/riscos/wimp.h"
|
||||
#include "netsurf/utils/log.h"
|
||||
|
||||
/* A basic window for the toolbar and status
|
||||
*/
|
||||
static wimp_window empty_window = {
|
||||
{0, 0, 16384, 16384},
|
||||
0,
|
||||
0,
|
||||
wimp_TOP,
|
||||
wimp_WINDOW_NEW_FORMAT | wimp_WINDOW_MOVEABLE | wimp_WINDOW_AUTO_REDRAW | wimp_WINDOW_FURNITURE_WINDOW,
|
||||
wimp_COLOUR_BLACK,
|
||||
wimp_COLOUR_LIGHT_GREY,
|
||||
wimp_COLOUR_LIGHT_GREY,
|
||||
wimp_COLOUR_VERY_LIGHT_GREY,
|
||||
wimp_COLOUR_DARK_GREY,
|
||||
wimp_COLOUR_MID_LIGHT_GREY,
|
||||
wimp_COLOUR_CREAM,
|
||||
wimp_WINDOW_NEVER3D,
|
||||
{0, 0, 16384, 16384},
|
||||
0,
|
||||
0,
|
||||
wimpspriteop_AREA,
|
||||
12,
|
||||
1,
|
||||
{""},
|
||||
0
|
||||
};
|
||||
|
||||
/* Holder for quick icon creation
|
||||
*/
|
||||
static wimp_icon_create empty_icon;
|
||||
|
||||
/* Shared URL validation
|
||||
*/
|
||||
static char *url_validation = "Pptr_write\0";
|
||||
static char *resize_validation = "R1;Pptr_lr,8,6\0";
|
||||
static char *null_text_string = "\0";
|
||||
|
||||
|
||||
static struct toolbar *ro_toolbar_create_icons(struct toolbar *toolbar, osspriteop_area *sprite_area,
|
||||
char *url_buffer, char *throbber_buffer);
|
||||
static struct toolbar_icon *ro_toolbar_create_icon(osspriteop_area *sprite_area, char *sprite, unsigned int icon);
|
||||
static struct toolbar_icon *ro_toolbar_create_separator(void);
|
||||
static void ro_toolbar_destroy_icon(struct toolbar_icon *icon);
|
||||
static void ro_toolbar_add_icon(struct toolbar *toolbar, struct toolbar_icon *icon);
|
||||
|
||||
/**
|
||||
* Creates a toolbar with a complete set of icons
|
||||
*
|
||||
* \param sprite_area the sprite area to read from
|
||||
*/
|
||||
struct toolbar *ro_toolbar_create(osspriteop_area *sprite_area, char *url_buffer,
|
||||
char *status_buffer, char *throbber_buffer) {
|
||||
struct toolbar *toolbar;
|
||||
wimp_i icon_handle;
|
||||
|
||||
/* Create a new toolbar
|
||||
*/
|
||||
toolbar = calloc(1, sizeof(struct toolbar));
|
||||
if (!toolbar) return NULL;
|
||||
toolbar->update_pending = true;
|
||||
toolbar->standard_buttons = true;
|
||||
toolbar->url_bar = true;
|
||||
toolbar->throbber = true;
|
||||
toolbar->status_window = true;
|
||||
toolbar->status_old_width = 0xffffffff;
|
||||
|
||||
/* Load the toolbar icons
|
||||
*/
|
||||
if (sprite_area) {
|
||||
ro_toolbar_add_icon(toolbar, ro_toolbar_create_icon(sprite_area, "back", ICON_TOOLBAR_BACK));
|
||||
ro_toolbar_add_icon(toolbar, ro_toolbar_create_icon(sprite_area, "forward", ICON_TOOLBAR_FORWARD));
|
||||
ro_toolbar_add_icon(toolbar, ro_toolbar_create_icon(sprite_area, "stop", ICON_TOOLBAR_STOP));
|
||||
ro_toolbar_add_icon(toolbar, ro_toolbar_create_icon(sprite_area, "reload", ICON_TOOLBAR_RELOAD));
|
||||
ro_toolbar_add_icon(toolbar, ro_toolbar_create_separator());
|
||||
ro_toolbar_add_icon(toolbar, ro_toolbar_create_icon(sprite_area, "home", ICON_TOOLBAR_HOME));
|
||||
ro_toolbar_add_icon(toolbar, ro_toolbar_create_icon(sprite_area, "up", ICON_TOOLBAR_UP));
|
||||
ro_toolbar_add_icon(toolbar, ro_toolbar_create_icon(sprite_area, "search", ICON_TOOLBAR_SEARCH));
|
||||
ro_toolbar_add_icon(toolbar, ro_toolbar_create_icon(sprite_area, "history", ICON_TOOLBAR_HISTORY));
|
||||
ro_toolbar_add_icon(toolbar, ro_toolbar_create_icon(sprite_area, "scale", ICON_TOOLBAR_SCALE));
|
||||
ro_toolbar_add_icon(toolbar, ro_toolbar_create_separator());
|
||||
ro_toolbar_add_icon(toolbar, ro_toolbar_create_icon(sprite_area, "mark", ICON_TOOLBAR_BOOKMARK));
|
||||
ro_toolbar_add_icon(toolbar, ro_toolbar_create_icon(sprite_area, "save", ICON_TOOLBAR_SAVE));
|
||||
ro_toolbar_add_icon(toolbar, ro_toolbar_create_icon(sprite_area, "print", ICON_TOOLBAR_PRINT));
|
||||
}
|
||||
|
||||
/* Set the sprite area
|
||||
*/
|
||||
if (sprite_area) {
|
||||
empty_window.sprite_area = sprite_area;
|
||||
} else {
|
||||
empty_window.sprite_area = 1;
|
||||
}
|
||||
|
||||
/* Create the basic windows
|
||||
*/
|
||||
empty_window.ymin = 36;
|
||||
if (xwimp_create_window(&empty_window, &toolbar->status_handle)) {
|
||||
ro_toolbar_destroy(toolbar);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
empty_window.ymin = 1;
|
||||
if (xwimp_create_window(&empty_window, &toolbar->toolbar_handle)) {
|
||||
ro_toolbar_destroy(toolbar);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Create the status window icons. First the status text
|
||||
*/
|
||||
empty_icon.w = toolbar->status_handle;
|
||||
empty_icon.icon.extent.x0 = 0;
|
||||
empty_icon.icon.extent.y0 = 0;
|
||||
empty_icon.icon.extent.x1 = 16384;
|
||||
empty_icon.icon.extent.y1 = 36;
|
||||
empty_icon.icon.flags = wimp_ICON_TEXT | (wimp_COLOUR_BLACK << wimp_ICON_FG_COLOUR_SHIFT) |
|
||||
wimp_ICON_INDIRECTED | wimp_ICON_VCENTRED;
|
||||
empty_icon.icon.data.indirected_text.text = status_buffer;
|
||||
empty_icon.icon.data.indirected_text.validation = 0;
|
||||
empty_icon.icon.data.indirected_text.size = 256;
|
||||
if (xwimp_create_icon(&empty_icon, &icon_handle)) {
|
||||
ro_toolbar_destroy(toolbar);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* And finally the status resize icon
|
||||
*/
|
||||
empty_icon.icon.flags = wimp_ICON_TEXT | wimp_ICON_INDIRECTED |
|
||||
wimp_ICON_BORDER | wimp_ICON_FILLED |
|
||||
(wimp_COLOUR_LIGHT_GREY << wimp_ICON_BG_COLOUR_SHIFT) |
|
||||
(wimp_BUTTON_CLICK_DRAG << wimp_ICON_BUTTON_TYPE_SHIFT);
|
||||
empty_icon.icon.extent.x1 = 0;
|
||||
empty_icon.icon.data.indirected_text.text = null_text_string;
|
||||
empty_icon.icon.data.indirected_text.validation = resize_validation;
|
||||
empty_icon.icon.data.indirected_text.size = 1;
|
||||
if (xwimp_create_icon(&empty_icon, &icon_handle)) {
|
||||
ro_toolbar_destroy(toolbar);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Create the icons
|
||||
*/
|
||||
toolbar = ro_toolbar_create_icons(toolbar, sprite_area, url_buffer, throbber_buffer);
|
||||
|
||||
/* Return the toolbar
|
||||
*/
|
||||
return toolbar;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates a WIMP icons for the toolbar
|
||||
*
|
||||
* \param toolbar the toolbar to build from
|
||||
* \param sprite_area the sprite area to plot sprites from
|
||||
*/
|
||||
static struct toolbar *ro_toolbar_create_icons(struct toolbar *toolbar, osspriteop_area *sprite_area,
|
||||
char *url_buffer, char *throbber_buffer) {
|
||||
int index;
|
||||
struct toolbar_icon *cur_icon;
|
||||
wimp_i icon_handle;
|
||||
|
||||
/* Set the basic icon flags
|
||||
*/
|
||||
empty_icon.w = toolbar->toolbar_handle;
|
||||
empty_icon.icon.extent.x0 = 0;
|
||||
empty_icon.icon.extent.y0 = 0;
|
||||
empty_icon.icon.extent.x1 = 0;
|
||||
empty_icon.icon.extent.y1 = 0;
|
||||
empty_icon.icon.data.indirected_text.text = null_text_string;
|
||||
empty_icon.icon.data.indirected_text.size = 1;
|
||||
empty_icon.icon.flags = wimp_ICON_TEXT | wimp_ICON_SPRITE | wimp_ICON_INDIRECTED |
|
||||
wimp_ICON_HCENTRED | wimp_ICON_VCENTRED |
|
||||
(wimp_BUTTON_CLICK << wimp_ICON_BUTTON_TYPE_SHIFT);
|
||||
|
||||
/* Create all the required icons
|
||||
*/
|
||||
for (index = 0; index < ICON_TOOLBAR_URL; index++) {
|
||||
|
||||
/* Find an icon with the correct index and get the validation
|
||||
*/
|
||||
empty_icon.icon.data.indirected_text.validation = 0;
|
||||
cur_icon = toolbar->icon;
|
||||
while (cur_icon) {
|
||||
if (cur_icon->icon_number == index) {
|
||||
empty_icon.icon.data.indirected_text.validation = cur_icon->validation;
|
||||
cur_icon = NULL;
|
||||
} else {
|
||||
cur_icon = cur_icon->next_icon;
|
||||
}
|
||||
}
|
||||
|
||||
/* Create the icon and destroy the toolbar on failure
|
||||
*/
|
||||
if (xwimp_create_icon(&empty_icon, &icon_handle)) {
|
||||
ro_toolbar_destroy(toolbar);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* Now the URL icon
|
||||
*/
|
||||
empty_icon.icon.flags = wimp_ICON_TEXT | wimp_ICON_INDIRECTED | wimp_ICON_VCENTRED |
|
||||
wimp_ICON_BORDER | wimp_ICON_FILLED |
|
||||
(wimp_COLOUR_BLACK << wimp_ICON_FG_COLOUR_SHIFT) |
|
||||
(wimp_BUTTON_WRITE_CLICK_DRAG << wimp_ICON_BUTTON_TYPE_SHIFT);
|
||||
empty_icon.icon.data.indirected_text.text = url_buffer;
|
||||
empty_icon.icon.data.indirected_text.validation = url_validation;
|
||||
empty_icon.icon.data.indirected_text.size = 256;
|
||||
if (xwimp_create_icon(&empty_icon, &icon_handle)) {
|
||||
ro_toolbar_destroy(toolbar);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Now the throbber
|
||||
*/
|
||||
empty_icon.icon.flags = wimp_ICON_SPRITE | wimp_ICON_INDIRECTED | wimp_ICON_HCENTRED |
|
||||
wimp_ICON_VCENTRED;
|
||||
empty_icon.icon.data.indirected_sprite.id = (osspriteop_id)throbber_buffer;
|
||||
if (sprite_area) {
|
||||
empty_icon.icon.data.indirected_sprite.area = sprite_area;
|
||||
} else {
|
||||
empty_icon.icon.data.indirected_sprite.area = 1;
|
||||
}
|
||||
empty_icon.icon.data.indirected_sprite.size = 12;
|
||||
if (xwimp_create_icon(&empty_icon, &icon_handle)) {
|
||||
ro_toolbar_destroy(toolbar);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* And finally the status resize icon
|
||||
*/
|
||||
empty_icon.w = toolbar->status_handle;
|
||||
empty_icon.icon.flags = wimp_ICON_TEXT | wimp_ICON_INDIRECTED |
|
||||
wimp_ICON_BORDER | wimp_ICON_FILLED |
|
||||
(wimp_COLOUR_LIGHT_GREY << wimp_ICON_BG_COLOUR_SHIFT) |
|
||||
(wimp_BUTTON_CLICK_DRAG << wimp_ICON_BUTTON_TYPE_SHIFT);
|
||||
empty_icon.icon.data.indirected_text.text = null_text_string;
|
||||
empty_icon.icon.data.indirected_text.validation = resize_validation;
|
||||
empty_icon.icon.data.indirected_text.size = 1;
|
||||
if (xwimp_create_icon(&empty_icon, &icon_handle)) {
|
||||
ro_toolbar_destroy(toolbar);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Success - return what we had
|
||||
*/
|
||||
return toolbar;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Releases all icons and associated memory for a toolbar
|
||||
*
|
||||
* \param toolbar the toolbar to destroy
|
||||
*/
|
||||
void ro_toolbar_destroy(struct toolbar *toolbar) {
|
||||
struct toolbar_icon *cur_icon;
|
||||
struct toolbar_icon *next_icon;
|
||||
|
||||
/* Paranoia
|
||||
*/
|
||||
if (toolbar == NULL) return;
|
||||
|
||||
/* Free all our icons
|
||||
*/
|
||||
next_icon = toolbar->icon;
|
||||
while((cur_icon = next_icon) != NULL) {
|
||||
next_icon = cur_icon->next_icon;
|
||||
ro_toolbar_destroy_icon(cur_icon);
|
||||
}
|
||||
|
||||
/* Destroy our windows
|
||||
*/
|
||||
if (toolbar->status_handle) xwimp_delete_window(toolbar->status_handle);
|
||||
if (toolbar->toolbar_handle) xwimp_delete_window(toolbar->toolbar_handle);
|
||||
|
||||
/* Destroy ourself
|
||||
*/
|
||||
free(toolbar);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates a toolbar icon
|
||||
*
|
||||
* \param sprite_area the sprite area to read from
|
||||
* \param sprite the requested sprite
|
||||
* \param icon the icon number
|
||||
*/
|
||||
static struct toolbar_icon *ro_toolbar_create_icon(osspriteop_area *sprite_area, char *sprite, unsigned int icon) {
|
||||
struct toolbar_icon *current_icon;
|
||||
int i;
|
||||
int sprite_name_size = 0;
|
||||
os_coord dimensions;
|
||||
char name[16];
|
||||
osbool mask;
|
||||
os_mode mode;
|
||||
unsigned int validation_length;
|
||||
|
||||
/* Check if the sprite exists
|
||||
*/
|
||||
for (i = 1; i <= sprite_area->sprite_count; i++) {
|
||||
if (!xosspriteop_return_name(osspriteop_USER_AREA,
|
||||
sprite_area, name, 16, i, &sprite_name_size)) {
|
||||
name[sprite_name_size] = '\0';
|
||||
if (strncmp(name, sprite, sprite_name_size + 1) == 0) {
|
||||
|
||||
/* Yes, a while loop would be better...
|
||||
*/
|
||||
goto ro_toolbar_create_icon_found;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* No icon found
|
||||
*/
|
||||
return NULL;
|
||||
ro_toolbar_create_icon_found:
|
||||
|
||||
/* Get the sprite details
|
||||
*/
|
||||
xosspriteop_read_sprite_info(osspriteop_USER_AREA,
|
||||
sprite_area, (osspriteop_id)name,
|
||||
&dimensions.x, &dimensions.y, &mask, &mode);
|
||||
|
||||
/* Create an icon
|
||||
*/
|
||||
current_icon = (struct toolbar_icon *)calloc(1, sizeof(struct toolbar_icon));
|
||||
if (!current_icon) return NULL;
|
||||
|
||||
/* Get the validation buffer for 'R5;S<name>,p<name>\0'. We always assume
|
||||
there is a pushed variant as RISC OS happily ignores it if it doesn't
|
||||
exist.
|
||||
*/
|
||||
validation_length = sprite_name_size * 2 + 8;
|
||||
current_icon->validation = malloc(validation_length);
|
||||
if (!current_icon->validation) {
|
||||
free(current_icon);
|
||||
return NULL;
|
||||
}
|
||||
sprintf(current_icon->validation, "R5;S%s,p%s", name, name);
|
||||
|
||||
/* We want eig factors rather than pixels
|
||||
*/
|
||||
ro_convert_pixels_to_os_units(&dimensions, mode);
|
||||
current_icon->width = dimensions.x;
|
||||
current_icon->height = dimensions.y;
|
||||
current_icon->icon_number = icon;
|
||||
current_icon->available = true;
|
||||
|
||||
/* Return our structure
|
||||
*/
|
||||
return current_icon;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates a toolbar separator icon
|
||||
*
|
||||
*/
|
||||
static struct toolbar_icon *ro_toolbar_create_separator(void) {
|
||||
struct toolbar_icon *current_icon;
|
||||
|
||||
/* Create an icon
|
||||
*/
|
||||
current_icon = (struct toolbar_icon *)calloc(1, sizeof(struct toolbar_icon));
|
||||
if (!current_icon) return NULL;
|
||||
|
||||
/* Set it as a 8 OS unit separator
|
||||
*/
|
||||
current_icon->icon_number = -1;
|
||||
current_icon->available = true;
|
||||
current_icon->width = 16;
|
||||
|
||||
/* Return our structure
|
||||
*/
|
||||
return current_icon;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Removes all associated memory with a toolbar icon
|
||||
*
|
||||
* \param icon the icon to destroy
|
||||
*/
|
||||
static void ro_toolbar_destroy_icon(struct toolbar_icon *icon) {
|
||||
if (!icon->icon_number >= 0) free(icon->validation);
|
||||
free(icon);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Adds a toolbar icon to the toolbar
|
||||
*
|
||||
* \param toolbar the toolbar to add to
|
||||
* \param icon the icon to add
|
||||
*/
|
||||
static void ro_toolbar_add_icon(struct toolbar *toolbar, struct toolbar_icon *icon) {
|
||||
struct toolbar_icon *cur_icon;
|
||||
|
||||
/* If we've been given a NULL due to a failure to create a toolbar
|
||||
icon then we barf.
|
||||
*/
|
||||
if (icon == NULL) return;
|
||||
|
||||
/* Traverse to the end of our linked list.
|
||||
*/
|
||||
cur_icon = toolbar->icon;
|
||||
if (!cur_icon) {
|
||||
|
||||
/* First icon cannot be a separator. Well, it can, but it's very unlikely
|
||||
that this has arisen from anything other than the previous icons not
|
||||
being present
|
||||
*/
|
||||
if (icon->icon_number < 0) return;
|
||||
toolbar->icon = icon;
|
||||
} else {
|
||||
while (cur_icon->next_icon) cur_icon = cur_icon->next_icon;
|
||||
|
||||
/* Two separators should not follow each other.
|
||||
*/
|
||||
if ((cur_icon->icon_number < 0) && (icon->icon_number < 0)) return;
|
||||
cur_icon->next_icon = icon;
|
||||
}
|
||||
|
||||
/* Stop potential circular linking
|
||||
*/
|
||||
icon->next_icon = NULL;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Resizes the status bar height (toolsprites change)
|
||||
*
|
||||
* \param toolbar the toolbar to update
|
||||
* \param height the new status bar height
|
||||
*/
|
||||
void ro_toolbar_resize_status(struct toolbar *toolbar, int height) {
|
||||
os_box extent = { 0, 0, 0, 0 };
|
||||
|
||||
/* Paranoia
|
||||
*/
|
||||
if (toolbar == NULL) return;
|
||||
|
||||
/* Check if we need to update
|
||||
*/
|
||||
if (toolbar->status_height != height) {
|
||||
toolbar->status_height = height;
|
||||
xwimp_resize_icon(toolbar->status_handle, ICON_STATUS_TEXT,
|
||||
0, 0, 16384, height - 2);
|
||||
xwimp_force_redraw(toolbar->status_handle, 0, 0, 16384, height);
|
||||
extent.x1 = 16384;
|
||||
extent.y1 = height - 2;
|
||||
xwimp_set_extent(toolbar->status_handle, &extent);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Reformat the contents of the toolbar/status window
|
||||
*
|
||||
* \param toolbar the toolbar to update
|
||||
* \param width the new toolbar width
|
||||
* \return non-zero if the toolbar height has changed
|
||||
*/
|
||||
int ro_toolbar_reformat(struct toolbar *toolbar, int width) {
|
||||
wimp_caret caret;
|
||||
unsigned int right_margin = 8;
|
||||
int min_width = 0;
|
||||
int status_width = 0;
|
||||
int old_width;
|
||||
|
||||
/* Paranoia
|
||||
*/
|
||||
if (toolbar == NULL) return 0;
|
||||
|
||||
/* Check we aren't too small
|
||||
*/
|
||||
toolbar->width = width;
|
||||
if (toolbar->throbber) min_width = toolbar->throbber_width + 8;
|
||||
if (toolbar->standard_buttons) min_width += toolbar->icon_width;
|
||||
if (toolbar->url_bar) min_width += 64;
|
||||
if (width < min_width) width = min_width;
|
||||
|
||||
/* Check if we need to update the icons
|
||||
*/
|
||||
if (toolbar->update_pending) {
|
||||
toolbar->update_pending = 0;
|
||||
toolbar->width_internal = 0xffffffff;
|
||||
return ro_toolbar_update(toolbar);
|
||||
}
|
||||
|
||||
/* See if we need to move anything
|
||||
*/
|
||||
if (width != toolbar->width_internal) {
|
||||
toolbar->width_internal = width;
|
||||
|
||||
/* Move the throbber
|
||||
*/
|
||||
if ((toolbar->throbber) && (toolbar->throbber_width > 0)) {
|
||||
xwimp_resize_icon(toolbar->toolbar_handle, ICON_TOOLBAR_THROBBER,
|
||||
width - toolbar->throbber_width - 8,
|
||||
(toolbar->height - toolbar->throbber_height) / 2,
|
||||
width - 8,
|
||||
(toolbar->height + toolbar->throbber_height) / 2);
|
||||
right_margin += toolbar->throbber_width + 8;
|
||||
}
|
||||
|
||||
/* Resize the URL bar
|
||||
*/
|
||||
if (toolbar->url_bar) {
|
||||
xwimp_resize_icon(toolbar->toolbar_handle, ICON_TOOLBAR_URL,
|
||||
toolbar->icon_width,
|
||||
(toolbar->height - 52) / 2,
|
||||
width - right_margin,
|
||||
(toolbar->height + 52) / 2);
|
||||
|
||||
/* Handle the caret moving
|
||||
*/
|
||||
if (!xwimp_get_caret_position(&caret)) {
|
||||
if ((caret.w == toolbar->toolbar_handle) && (caret.i == ICON_TOOLBAR_URL)) {
|
||||
xwimp_set_caret_position(toolbar->toolbar_handle, ICON_TOOLBAR_URL,
|
||||
caret.pos.x, caret.pos.y, -1, caret.index);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Force a redraw
|
||||
*/
|
||||
xwimp_force_redraw(toolbar->toolbar_handle, toolbar->icon_width, 0, width, toolbar->height);
|
||||
}
|
||||
|
||||
/* Move the status resize icon
|
||||
*/
|
||||
if (toolbar->status_window) {
|
||||
status_width = toolbar->width - toolbar->status_width;
|
||||
if (status_width < 12) status_width = 12;
|
||||
old_width = toolbar->status_old_width;
|
||||
toolbar->status_old_width = status_width;
|
||||
if (old_width != status_width) {
|
||||
xwimp_resize_icon(toolbar->status_handle, ICON_STATUS_RESIZE,
|
||||
status_width - 12,
|
||||
0,
|
||||
status_width,
|
||||
toolbar->status_height - 2);
|
||||
xwimp_force_redraw(toolbar->status_handle,
|
||||
status_width - 12, 0, status_width, toolbar->status_height - 2);
|
||||
xwimp_force_redraw(toolbar->status_handle,
|
||||
old_width - 12, 0, old_width, toolbar->status_height - 2);
|
||||
}
|
||||
}
|
||||
|
||||
/* No change in height
|
||||
*/
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Updates the icon states and positions.
|
||||
*
|
||||
* Any necessary redrawing is performed for the client.
|
||||
* The client is responsible for resizing/opening/closing the window when necessary.
|
||||
*
|
||||
* \param toolbar the toolbar to update
|
||||
* \return non-zero if the toolbar height has changed
|
||||
*/
|
||||
int ro_toolbar_update(struct toolbar *toolbar) {
|
||||
wimp_caret caret;
|
||||
struct toolbar_icon *cur_icon;
|
||||
unsigned int toolbar_height = 0;
|
||||
unsigned int icon_left = 4;
|
||||
int return_status;
|
||||
|
||||
/* Paranoia
|
||||
*/
|
||||
if (toolbar == NULL) return 0;
|
||||
|
||||
/* Calculate the toolbar height (4 os unit border)
|
||||
*/
|
||||
if (toolbar->url_bar) toolbar_height = 52;
|
||||
if ((toolbar->throbber) && (toolbar_height < (toolbar->throbber_height + 4))) {
|
||||
toolbar_height = toolbar->throbber_height + 4;
|
||||
}
|
||||
|
||||
/* Calculate the maximum height of the icons
|
||||
*/
|
||||
if (toolbar->standard_buttons) {
|
||||
cur_icon = toolbar->icon;
|
||||
while (cur_icon) {
|
||||
if ((cur_icon->available) && (toolbar_height < (cur_icon->height + 4))) {
|
||||
toolbar_height = cur_icon->height + 4;
|
||||
}
|
||||
cur_icon = cur_icon->next_icon;
|
||||
}
|
||||
}
|
||||
|
||||
/* Set our return status
|
||||
*/
|
||||
if (toolbar_height != 0) toolbar_height += 8;
|
||||
return_status = (toolbar_height == toolbar->height);
|
||||
toolbar->height = toolbar_height;
|
||||
|
||||
/* Move our icons. Icons that are not avaiable are moved off the visible area.
|
||||
*/
|
||||
cur_icon = toolbar->icon;
|
||||
while (cur_icon) {
|
||||
if ((cur_icon->available) && (toolbar->standard_buttons)) {
|
||||
if (cur_icon->icon_number >= 0) {
|
||||
xwimp_resize_icon(toolbar->toolbar_handle, cur_icon->icon_number,
|
||||
icon_left,
|
||||
(toolbar_height - cur_icon->height) / 2,
|
||||
icon_left + cur_icon->width,
|
||||
(toolbar_height + cur_icon->height) / 2);
|
||||
}
|
||||
icon_left += cur_icon->width;
|
||||
|
||||
} else {
|
||||
if (cur_icon->icon_number >= 0) {
|
||||
xwimp_resize_icon(toolbar->toolbar_handle, cur_icon->icon_number,
|
||||
0,
|
||||
1024 + toolbar_height,
|
||||
cur_icon->width,
|
||||
1024 + toolbar_height + cur_icon->height);
|
||||
}
|
||||
}
|
||||
cur_icon = cur_icon->next_icon;
|
||||
}
|
||||
|
||||
/* Make a 8 OS unit spacer between icons and URL bar
|
||||
*/
|
||||
if (icon_left != 4) icon_left += 8;
|
||||
toolbar->icon_width = icon_left;
|
||||
|
||||
/* Hide the URL bar if we should (and shade it to stop caret issues)
|
||||
*/
|
||||
if (!toolbar->url_bar) {
|
||||
/* Handle losing the caret
|
||||
*/
|
||||
if (!xwimp_get_caret_position(&caret)) {
|
||||
if ((caret.w == toolbar->toolbar_handle) && (caret.i == ICON_TOOLBAR_URL)) {
|
||||
xwimp_set_caret_position(-1, 0, 0, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
xwimp_resize_icon(toolbar->toolbar_handle, ICON_TOOLBAR_URL,
|
||||
0,
|
||||
1024 + toolbar_height,
|
||||
64,
|
||||
1024 + toolbar_height + 52);
|
||||
ro_gui_set_icon_shaded_state(toolbar->toolbar_handle, ICON_TOOLBAR_URL, true);
|
||||
} else {
|
||||
ro_gui_set_icon_shaded_state(toolbar->toolbar_handle, ICON_TOOLBAR_URL, false);
|
||||
}
|
||||
|
||||
/* Hide the throbber if we should
|
||||
*/
|
||||
if (!toolbar->throbber) {
|
||||
xwimp_resize_icon(toolbar->toolbar_handle, ICON_TOOLBAR_THROBBER,
|
||||
0,
|
||||
1024 + toolbar_height,
|
||||
toolbar->throbber_width,
|
||||
1024 + toolbar_height + toolbar->throbber_height);
|
||||
}
|
||||
|
||||
/* Redraw the entire window
|
||||
*/
|
||||
ro_toolbar_reformat(toolbar, toolbar->width);
|
||||
xwimp_force_redraw(toolbar->toolbar_handle, 0, 0, toolbar->width, toolbar_height);
|
||||
|
||||
/* Update the toolbar height
|
||||
*/
|
||||
return return_status;
|
||||
}
|
84
riscos/toolbar.h
Normal file
84
riscos/toolbar.h
Normal file
@ -0,0 +1,84 @@
|
||||
/*
|
||||
* 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 Richard Wilson <not_ginger_matt@users.sourceforge.net>
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* Toolbar creation (interface).
|
||||
*/
|
||||
|
||||
#ifndef _NETSURF_RISCOS_TOOLBAR_H_
|
||||
#define _NETSURF_RISCOS_TOOLBAR_H_
|
||||
|
||||
#include "oslib/wimp.h"
|
||||
|
||||
|
||||
struct toolbar_icon {
|
||||
/* The desired WIMP icon number (-1 for separator)
|
||||
*/
|
||||
int icon_number;
|
||||
|
||||
/* Set to non-zero to display the icon
|
||||
*/
|
||||
unsigned int available;
|
||||
|
||||
/* Icon dimensions (OS units)
|
||||
*/
|
||||
unsigned int width;
|
||||
unsigned int height;
|
||||
|
||||
/* Icon validation, or NULL if this icon is unavailable
|
||||
*/
|
||||
unsigned char* validation;
|
||||
|
||||
/* The next icon (linked list)
|
||||
*/
|
||||
struct toolbar_icon *next_icon; // Next toolbar icon
|
||||
};
|
||||
|
||||
|
||||
struct toolbar {
|
||||
|
||||
/* Internal variables
|
||||
*/
|
||||
unsigned int resize_status; // Update status width on next reformat?
|
||||
unsigned int update_pending; // Update icons on next reformat?
|
||||
unsigned int icon_width; // Current width of icons
|
||||
int width_internal; // Width actually used on last reformat
|
||||
int status_height; // Status bar height
|
||||
int status_old_width; // Old status width
|
||||
int width; // Toolbar width on last reformat
|
||||
unsigned int height; // Toolbar height on last reformat
|
||||
|
||||
/* General options
|
||||
*/
|
||||
unsigned int throbber_width; // Throbber width (0 = unavaiable)
|
||||
unsigned int throbber_height; // Throbber height (0 = unavaiable)
|
||||
unsigned int status_window; // Show status window?
|
||||
unsigned int standard_buttons; // Show standard buttons?
|
||||
unsigned int url_bar; // Show URL bar?
|
||||
unsigned int throbber; // Show Throbber?
|
||||
unsigned int status_width; // Width of status window
|
||||
|
||||
/* The first toolbar icon
|
||||
*/
|
||||
struct toolbar_icon *icon;
|
||||
|
||||
/* Window handles
|
||||
*/
|
||||
wimp_w toolbar_handle;
|
||||
wimp_w status_handle;
|
||||
};
|
||||
|
||||
|
||||
struct toolbar *ro_toolbar_create(osspriteop_area *sprite_area, char *url_buffer,
|
||||
char *status_buffer, char *throbber_buffer);
|
||||
void ro_toolbar_destroy(struct toolbar *toolbar);
|
||||
void ro_toolbar_resize_status(struct toolbar *toolbar, int height);
|
||||
int ro_toolbar_reformat(struct toolbar *toolbar, int width);
|
||||
void ro_toolbar_status_reformat(struct toolbar *toolbar, int width);
|
||||
int ro_toolbar_update(struct toolbar *toolbar);
|
||||
|
||||
#endif
|
@ -54,7 +54,7 @@ void ro_uri_message_received(uri_full_message_process* uri_message)
|
||||
|
||||
xuri_request_uri(0, uri_requested, uri_length, uri_handle, NULL);
|
||||
|
||||
browser_window_create(uri_requested);
|
||||
browser_window_create(uri_requested, NULL);
|
||||
|
||||
xfree(uri_requested);
|
||||
}
|
||||
|
@ -99,7 +99,7 @@ void ro_url_message_received(wimp_message* message)
|
||||
message->sender);
|
||||
|
||||
/* create new browser window */
|
||||
browser_window_create(uri_requested);
|
||||
browser_window_create(uri_requested, NULL);
|
||||
|
||||
#if 0
|
||||
if (post) {
|
||||
|
193
riscos/wimp.c
Normal file
193
riscos/wimp.c
Normal file
@ -0,0 +1,193 @@
|
||||
/*
|
||||
* 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 Richard Wilson <not_ginger_matt@users.sourceforge.net>
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* General RISC OS WIMP/OS library functions (implementation).
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include "oslib/os.h"
|
||||
#include "oslib/wimp.h"
|
||||
#include "oslib/wimpextend.h"
|
||||
#include "netsurf/riscos/wimp.h"
|
||||
|
||||
|
||||
/* Wimp_Extend,11 block
|
||||
*/
|
||||
static wimpextend_furniture_sizes furniture_sizes;
|
||||
|
||||
/**
|
||||
* Gets the default horzontal scrollbar height
|
||||
*/
|
||||
int ro_get_hscroll_height(wimp_w w) {
|
||||
furniture_sizes.w = w;
|
||||
furniture_sizes.border_widths.y0 = 38;
|
||||
xwimpextend_get_furniture_sizes(&furniture_sizes);
|
||||
return furniture_sizes.border_widths.y0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a modes EIG factors.
|
||||
*
|
||||
* \param mode mode to read EIG factors for, or -1 for current
|
||||
*/
|
||||
struct eig_factors ro_read_eig_factors(os_mode mode) {
|
||||
bits psr;
|
||||
struct eig_factors factors;
|
||||
xos_read_mode_variable(mode, os_MODEVAR_XEIG_FACTOR, &factors.xeig, &psr);
|
||||
xos_read_mode_variable(mode, os_MODEVAR_YEIG_FACTOR, &factors.yeig, &psr);
|
||||
return factors;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Converts the supplied os_coord from OS units to pixels.
|
||||
*
|
||||
* \param os_units values to convert
|
||||
* \param mode mode to use EIG factors for, or -1 for current
|
||||
*/
|
||||
void ro_convert_os_units_to_pixels(os_coord *os_units, os_mode mode) {
|
||||
struct eig_factors factors = ro_read_eig_factors(mode);
|
||||
os_units->x = (os_units->x >> factors.xeig);
|
||||
os_units->y = (os_units->y >> factors.yeig);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Converts the supplied os_coord from pixels to OS units.
|
||||
*
|
||||
* \param pixels values to convert
|
||||
* \param mode mode to use EIG factors for, or -1 for current
|
||||
*/
|
||||
void ro_convert_pixels_to_os_units(os_coord *pixels, os_mode mode) {
|
||||
struct eig_factors factors = ro_read_eig_factors(mode);
|
||||
pixels->x = (pixels->x << factors.xeig);
|
||||
pixels->y = (pixels->y << factors.yeig);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Redraws an icon
|
||||
*
|
||||
* \param w window handle
|
||||
* \param i icon handle
|
||||
*/
|
||||
#define ro_gui_redraw_icon(w, i) xwimp_set_icon_state(w, i, 0, 0)
|
||||
|
||||
|
||||
/**
|
||||
* Read the contents of an icon.
|
||||
*
|
||||
* \param w window handle
|
||||
* \param i icon handle
|
||||
* \return string in icon
|
||||
*/
|
||||
char *ro_gui_get_icon_string(wimp_w w, wimp_i i) {
|
||||
wimp_icon_state ic;
|
||||
ic.w = w;
|
||||
ic.i = i;
|
||||
if (xwimp_get_icon_state(&ic)) return NULL;
|
||||
return ic.icon.data.indirected_text.text;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the contents of an icon to a string.
|
||||
*
|
||||
* \param w window handle
|
||||
* \param i icon handle
|
||||
* \param text string (copied)
|
||||
*/
|
||||
void ro_gui_set_icon_string(wimp_w w, wimp_i i, const char *text) {
|
||||
wimp_caret caret;
|
||||
wimp_icon_state ic;
|
||||
int old_len, len;
|
||||
|
||||
/* Get the icon data
|
||||
*/
|
||||
ic.w = w;
|
||||
ic.i = i;
|
||||
if (xwimp_get_icon_state(&ic)) return;
|
||||
|
||||
/* Check that the existing text is not the same as the updated text
|
||||
to stop flicker
|
||||
*/
|
||||
if (!strncmp(ic.icon.data.indirected_text.text, text,
|
||||
(unsigned int)ic.icon.data.indirected_text.size)) return;
|
||||
|
||||
/* Copy the text across
|
||||
*/
|
||||
old_len = strlen(ic.icon.data.indirected_text.text);
|
||||
strncpy(ic.icon.data.indirected_text.text, text,
|
||||
(unsigned int)ic.icon.data.indirected_text.size);
|
||||
|
||||
/* Handle the caret being in the icon
|
||||
*/
|
||||
if (!xwimp_get_caret_position(&caret)) {
|
||||
if ((caret.w == w) && (caret.i == i)) {
|
||||
len = strlen(text);
|
||||
if ((caret.index > len) || (caret.index == old_len)) caret.index = len;
|
||||
xwimp_set_caret_position(w, i, caret.pos.x, caret.pos.y, -1, caret.index);
|
||||
}
|
||||
}
|
||||
|
||||
/* Redraw the icon
|
||||
*/
|
||||
ro_gui_redraw_icon(w, i);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the contents of an icon to a number.
|
||||
*
|
||||
* \param w window handle
|
||||
* \param i icon handle
|
||||
* \param value value
|
||||
*/
|
||||
void ro_gui_set_icon_integer(wimp_w w, wimp_i i, int value) {
|
||||
char buffer[20]; // Big enough for 64-bit int
|
||||
sprintf(buffer, "%d", value);
|
||||
ro_gui_set_icon_string(w, i, buffer);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the selected state of an icon.
|
||||
*
|
||||
* \param w window handle
|
||||
* \param i icon handle
|
||||
* \param state selected state
|
||||
*/
|
||||
#define ro_gui_set_icon_selected_state(w, i, state) xwimp_set_icon_state(w, i, (state ? wimp_ICON_SELECTED : 0), wimp_ICON_SELECTED)
|
||||
|
||||
|
||||
/**
|
||||
* Gets the selected state of an icon.
|
||||
*
|
||||
* \param w window handle
|
||||
* \param i icon handle
|
||||
*/
|
||||
int ro_gui_get_icon_selected_state(wimp_w w, wimp_i i) {
|
||||
wimp_icon_state ic;
|
||||
ic.w = w;
|
||||
ic.i = i;
|
||||
xwimp_get_icon_state(&ic);
|
||||
return (ic.icon.flags & wimp_ICON_SELECTED) != 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the selected state of an icon.
|
||||
*
|
||||
* \param w window handle
|
||||
* \param i icon handle
|
||||
* \param state selected state
|
||||
*/
|
||||
#define ro_gui_set_icon_shaded_state(w, i, state) xwimp_set_icon_state(w, i, (state ? wimp_ICON_SHADED : 0), wimp_ICON_SHADED)
|
42
riscos/wimp.h
Normal file
42
riscos/wimp.h
Normal file
@ -0,0 +1,42 @@
|
||||
/*
|
||||
* 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 Richard Wilson <not_ginger_matt@users.sourceforge.net>
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* General RISC OS WIMP/OS library functions (interface).
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _NETSURF_RISCOS_WIMP_H_
|
||||
#define _NETSURF_RISCOS_WIMP_H_
|
||||
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include "oslib/os.h"
|
||||
#include "oslib/wimp.h"
|
||||
|
||||
struct eig_factors {
|
||||
int xeig;
|
||||
int yeig;
|
||||
};
|
||||
|
||||
|
||||
int ro_get_hscroll_height(wimp_w w);
|
||||
struct eig_factors ro_read_eig_factors(os_mode mode);
|
||||
void ro_convert_os_units_to_pixels(os_coord *os_units, os_mode mode);
|
||||
void ro_convert_pixels_to_os_units(os_coord *pixels, os_mode mode);
|
||||
|
||||
#define ro_gui_redraw_icon(w, i) xwimp_set_icon_state(w, i, 0, 0)
|
||||
char *ro_gui_get_icon_string(wimp_w w, wimp_i i);
|
||||
void ro_gui_set_icon_string(wimp_w w, wimp_i i, const char *text);
|
||||
void ro_gui_set_icon_integer(wimp_w w, wimp_i i, int value);
|
||||
#define ro_gui_set_icon_selected_state(w, i, state) xwimp_set_icon_state(w, i, (state ? wimp_ICON_SELECTED : 0), wimp_ICON_SELECTED)
|
||||
int ro_gui_get_icon_selected_state(wimp_w w, wimp_i i);
|
||||
#define ro_gui_set_icon_shaded_state(w, i, state) xwimp_set_icon_state(w, i, (state ? wimp_ICON_SHADED : 0), wimp_ICON_SHADED)
|
||||
|
||||
#endif
|
477
riscos/window.c
477
riscos/window.c
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is part of NetSurf, http://netsurf.sourceforge.net/
|
||||
* 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 2004 James Bursa <bursa@users.sourceforge.net>
|
||||
* Copyright 2003 John M Bell <jmb202@ecs.soton.ac.uk>
|
||||
@ -27,6 +27,7 @@
|
||||
#include "netsurf/riscos/save_draw.h"
|
||||
#include "netsurf/riscos/theme.h"
|
||||
#include "netsurf/riscos/thumbnail.h"
|
||||
#include "netsurf/riscos/wimp.h"
|
||||
#include "netsurf/render/form.h"
|
||||
#include "netsurf/utils/log.h"
|
||||
#include "netsurf/utils/url.h"
|
||||
@ -53,16 +54,15 @@ bool gui_window_in_list(gui_window *g) {
|
||||
|
||||
/**
|
||||
* Create and open a new browser window.
|
||||
*
|
||||
* \param clone the browser window to clone options from, or NULL for default
|
||||
*/
|
||||
|
||||
gui_window *gui_create_browser_window(struct browser_window *bw)
|
||||
gui_window *gui_create_browser_window(struct browser_window *bw, struct browser_window *clone)
|
||||
{
|
||||
int screen_width, screen_height, win_width, win_height;
|
||||
int toolbar_height = 0;
|
||||
wimp_window window;
|
||||
wimp_window_state state;
|
||||
wimp_outline outline;
|
||||
os_error *error;
|
||||
|
||||
gui_window* g = (gui_window*) xcalloc(1, sizeof(gui_window));
|
||||
g->type = GUI_BROWSER_WINDOW;
|
||||
@ -70,9 +70,6 @@ gui_window *gui_create_browser_window(struct browser_window *bw)
|
||||
|
||||
ro_gui_screen_size(&screen_width, &screen_height);
|
||||
|
||||
if (option_show_toolbar)
|
||||
toolbar_height = ro_theme_toolbar_height();
|
||||
|
||||
win_width = screen_width * 3 / 4;
|
||||
if (1600 < win_width)
|
||||
win_width = 1600;
|
||||
@ -102,7 +99,7 @@ gui_window *gui_create_browser_window(struct browser_window *bw)
|
||||
window.extent.x0 = 0;
|
||||
window.extent.y0 = win_height;
|
||||
window.extent.x1 = win_width;
|
||||
window.extent.y1 = toolbar_height;
|
||||
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;
|
||||
@ -115,66 +112,36 @@ gui_window *gui_create_browser_window(struct browser_window *bw)
|
||||
g->window = wimp_create_window(&window);
|
||||
|
||||
strcpy(g->title, "NetSurf");
|
||||
strcpy(g->throb_buf, "throbber0");
|
||||
|
||||
g->data.browser.toolbar = 0;
|
||||
if (option_show_toolbar)
|
||||
{
|
||||
g->data.browser.toolbar = ro_theme_create_toolbar(g->url, g->status,
|
||||
g->throb_buf);
|
||||
g->data.browser.toolbar_width = -1;
|
||||
sprintf(g->throb_buf, "throbber0");
|
||||
}
|
||||
ro_theme_create_toolbar(g);
|
||||
|
||||
g->data.browser.reformat_pending = false;
|
||||
g->data.browser.old_width = 0;
|
||||
g->scale = 1;
|
||||
g->data.browser.reformat_pending = false;
|
||||
g->data.browser.old_width = 0;
|
||||
|
||||
g->next = window_list;
|
||||
window_list = g;
|
||||
window_count++;
|
||||
g->next = window_list;
|
||||
window_list = g;
|
||||
window_count++;
|
||||
|
||||
/* Set the window options
|
||||
*/
|
||||
bw->window = g;
|
||||
gui_window_clone_options(bw, clone);
|
||||
|
||||
state.w = g->window;
|
||||
wimp_get_window_state(&state);
|
||||
state.next = wimp_TOP;
|
||||
ro_gui_window_open(g, (wimp_open*)&state);
|
||||
|
||||
outline.w = g->window;
|
||||
wimp_get_window_outline(&outline);
|
||||
|
||||
state.w = g->data.browser.toolbar;
|
||||
state.visible.x1 = outline.outline.x1 - 2;
|
||||
state.visible.y0 = state.visible.y1 - toolbar_height;
|
||||
state.xscroll = 0;
|
||||
state.yscroll = 0;
|
||||
state.next = wimp_TOP;
|
||||
|
||||
g->data.browser.toolbar_width = state.visible.x1 - state.visible.x0;
|
||||
ro_theme_resize_toolbar(g->data.browser.toolbar,
|
||||
g->data.browser.toolbar_width,
|
||||
state.visible.y1 - state.visible.y0);
|
||||
|
||||
wimp_open_window_nested((wimp_open *) &state, 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_TOP_OR_RIGHT
|
||||
<< wimp_CHILD_RS_EDGE_SHIFT |
|
||||
wimp_CHILD_LINKS_PARENT_VISIBLE_TOP_OR_RIGHT
|
||||
<< wimp_CHILD_TS_EDGE_SHIFT);
|
||||
|
||||
error = xwimp_set_caret_position(g->data.browser.toolbar,
|
||||
ICON_TOOLBAR_URL, -1, -1, -1, 0);
|
||||
if (error)
|
||||
LOG(("xwimp_set_caret_position: 0x%x: %s",
|
||||
error->errnum, error->errmess));
|
||||
|
||||
/* Set the caret position to the URL bar
|
||||
*/
|
||||
xwimp_set_caret_position(g->data.browser.toolbar->toolbar_handle,
|
||||
ICON_TOOLBAR_URL, -1, -1, -1, 0);
|
||||
return g;
|
||||
}
|
||||
|
||||
|
||||
void gui_window_set_title(gui_window* g, char* title)
|
||||
{
|
||||
void gui_window_set_title(gui_window* g, char* title) {
|
||||
strncpy(g->title, title, 255);
|
||||
wimp_force_redraw_title(g->window);
|
||||
}
|
||||
@ -199,9 +166,8 @@ void gui_window_destroy(gui_window* g)
|
||||
|
||||
window_count--;
|
||||
|
||||
ro_toolbar_destroy(g->data.browser.toolbar);
|
||||
xwimp_delete_window(g->window);
|
||||
if (g->data.browser.toolbar)
|
||||
xwimp_delete_window(g->data.browser.toolbar);
|
||||
|
||||
xfree(g);
|
||||
}
|
||||
@ -243,9 +209,9 @@ void ro_gui_window_redraw(gui_window* g, wimp_draw* redraw)
|
||||
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,
|
||||
(int) redraw->box.x0 - (int) redraw->xscroll,
|
||||
(int) redraw->box.y1 - (int) redraw->yscroll,
|
||||
c->width * 2, c->height * 2,
|
||||
redraw->clip.x0, redraw->clip.y0,
|
||||
redraw->clip.x1 - 1, redraw->clip.y1 - 1,
|
||||
g->scale);
|
||||
@ -319,7 +285,6 @@ void gui_window_update_box(gui_window *g, const union content_msg_data *data)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void gui_window_set_scroll(gui_window* g, unsigned long sx, unsigned long sy)
|
||||
{
|
||||
wimp_window_state state;
|
||||
@ -329,13 +294,11 @@ void gui_window_set_scroll(gui_window* g, unsigned long sx, unsigned long sy)
|
||||
wimp_get_window_state(&state);
|
||||
state.xscroll = sx * 2;
|
||||
state.yscroll = -sy * 2;
|
||||
if (option_show_toolbar)
|
||||
state.yscroll += ro_theme_toolbar_height();
|
||||
state.yscroll += g->data.browser.toolbar->height;
|
||||
ro_gui_window_open(g, (wimp_open*)&state);
|
||||
}
|
||||
|
||||
unsigned long gui_window_get_width(gui_window* g)
|
||||
{
|
||||
unsigned long gui_window_get_width(gui_window* g) {
|
||||
wimp_window_state state;
|
||||
state.w = g->window;
|
||||
wimp_get_window_state(&state);
|
||||
@ -343,9 +306,7 @@ unsigned long gui_window_get_width(gui_window* g)
|
||||
}
|
||||
|
||||
|
||||
void gui_window_set_extent(gui_window *g, unsigned long width,
|
||||
unsigned long height)
|
||||
{
|
||||
void gui_window_set_extent(gui_window *g, unsigned long width, unsigned long height) {
|
||||
os_box extent = { 0, 0, 0, 0 };
|
||||
wimp_window_state state;
|
||||
int toolbar_height = 0;
|
||||
@ -357,8 +318,7 @@ void gui_window_set_extent(gui_window *g, unsigned long width,
|
||||
wimp_get_window_state(&state);
|
||||
|
||||
/* account for toolbar height, if present */
|
||||
if (option_show_toolbar)
|
||||
toolbar_height = ro_theme_toolbar_height();
|
||||
if (g->data.browser.toolbar) toolbar_height = g->data.browser.toolbar->height;
|
||||
|
||||
if (width < (unsigned int)(state.visible.x1 - state.visible.x0))
|
||||
width = state.visible.x1 - state.visible.x0;
|
||||
@ -373,35 +333,30 @@ void gui_window_set_extent(gui_window *g, unsigned long width,
|
||||
}
|
||||
|
||||
|
||||
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, ICON_TOOLBAR_STATUS, 0, 0);
|
||||
}
|
||||
void gui_window_set_status(gui_window* g, const char* text) {
|
||||
if (g->data.browser.toolbar) {
|
||||
ro_gui_set_icon_string(g->data.browser.toolbar->status_handle, ICON_STATUS_TEXT, text);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the contents of a window's address bar.
|
||||
*/
|
||||
|
||||
void gui_window_set_url(gui_window *g, char *url)
|
||||
{
|
||||
wimp_caret c;
|
||||
strncpy(g->url, url, 255);
|
||||
wimp_set_icon_state(g->data.browser.toolbar, ICON_TOOLBAR_URL, 0, 0);
|
||||
/* Move the caret to the url bar.
|
||||
* It's ok to do this as this only gets
|
||||
* called when fetching a new page .
|
||||
*/
|
||||
wimp_get_caret_position(&c);
|
||||
if (c.w == g->window || c.w == g->data.browser.toolbar) {
|
||||
wimp_set_caret_position(g->data.browser.toolbar,
|
||||
ICON_TOOLBAR_URL,
|
||||
0,0,-1, (int) strlen(g->url));
|
||||
}
|
||||
void gui_window_set_url(gui_window *g, char *url) {
|
||||
wimp_caret c;
|
||||
if (g->data.browser.toolbar) {
|
||||
ro_gui_set_icon_string(g->data.browser.toolbar->toolbar_handle, ICON_TOOLBAR_URL, url);
|
||||
|
||||
/* Move the caret to the URL bar
|
||||
*/
|
||||
if (!xwimp_get_caret_position(&c)) {
|
||||
if (c.w == g->window || c.w == g->data.browser.toolbar->toolbar_handle) {
|
||||
xwimp_set_caret_position(g->data.browser.toolbar->toolbar_handle,
|
||||
ICON_TOOLBAR_URL, 0, 0, -1, (int)strlen(g->url));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -409,8 +364,7 @@ void gui_window_set_url(gui_window *g, char *url)
|
||||
* Open a window using the given wimp_open, handling toolbars and resizing.
|
||||
*/
|
||||
|
||||
void ro_gui_window_open(gui_window *g, wimp_open *open)
|
||||
{
|
||||
void ro_gui_window_open(gui_window *g, wimp_open *open) {
|
||||
int width = open->visible.x1 - open->visible.x0;
|
||||
int height = open->visible.y1 - open->visible.y0;
|
||||
int toolbar_height = 0;
|
||||
@ -436,14 +390,14 @@ void ro_gui_window_open(gui_window *g, wimp_open *open)
|
||||
}
|
||||
|
||||
/* account for toolbar height, if present */
|
||||
if (option_show_toolbar) {
|
||||
toolbar_height = ro_theme_toolbar_height();
|
||||
height -= toolbar_height;
|
||||
}
|
||||
if (g->data.browser.toolbar) toolbar_height = g->data.browser.toolbar->height;
|
||||
height -= toolbar_height;
|
||||
|
||||
/* the height should be no less than the content height */
|
||||
if (content && (unsigned int)height < content->height * 2 * g->scale)
|
||||
/* The height should be no less than the content height
|
||||
*/
|
||||
if (content && (unsigned int)height < content->height * 2 * g->scale) {
|
||||
height = content->height * 2 * g->scale;
|
||||
}
|
||||
|
||||
/* change extent if necessary */
|
||||
if (g->data.browser.old_width != width ||
|
||||
@ -483,101 +437,75 @@ void ro_gui_window_open(gui_window *g, wimp_open *open)
|
||||
g->data.browser.old_height = height;
|
||||
}
|
||||
|
||||
/* open toolbar, if present */
|
||||
if (!toolbar_height)
|
||||
return;
|
||||
ro_theme_resize_toolbar(g);
|
||||
}
|
||||
|
||||
state.w = g->data.browser.toolbar;
|
||||
wimp_get_window_state(&state);
|
||||
if (state.visible.x1 - state.visible.x0 !=
|
||||
g->data.browser.toolbar_width) {
|
||||
g->data.browser.toolbar_width = state.visible.x1 -
|
||||
state.visible.x0;
|
||||
ro_theme_resize_toolbar(g->data.browser.toolbar,
|
||||
g->data.browser.toolbar_width,
|
||||
state.visible.y1 - state.visible.y0);
|
||||
|
||||
void ro_gui_throb(void) {
|
||||
gui_window* g;
|
||||
|
||||
/* Abort on no throbs
|
||||
*/
|
||||
if (theme_throbs == 0) return;
|
||||
|
||||
/* Animate
|
||||
*/
|
||||
float nowtime = (float) (clock() / (CLOCKS_PER_SEC/(15*23/theme_throbs)));
|
||||
for (g = window_list; g != NULL; g = g->next) {
|
||||
if ((g->type == GUI_BROWSER_WINDOW) && (g->data.browser.bw->throbbing)) {
|
||||
if (nowtime > g->throbtime + 0.2) {
|
||||
g->throbtime = nowtime;
|
||||
g->throbber++;
|
||||
if (g->throbber > theme_throbs) g->throbber = 0;
|
||||
sprintf(g->throb_buf, "throbber%i", g->throbber);
|
||||
ro_gui_redraw_icon(g->data.browser.toolbar->toolbar_handle, ICON_TOOLBAR_THROBBER);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ro_gui_throb(void)
|
||||
{
|
||||
gui_window* g;
|
||||
float nowtime = (float) (clock() / (CLOCKS_PER_SEC/(15*23/theme_throbs)));
|
||||
|
||||
for (g = window_list; g != NULL; g = g->next)
|
||||
{
|
||||
if (g->type == GUI_BROWSER_WINDOW)
|
||||
{
|
||||
if (option_show_toolbar)
|
||||
{
|
||||
if (g->data.browser.bw->throbbing != 0)
|
||||
{
|
||||
if (nowtime > g->throbtime + 0.2)
|
||||
{
|
||||
g->throbtime = nowtime;
|
||||
g->throbber++;
|
||||
if ((unsigned int)g->throbber > theme_throbs)
|
||||
g->throbber = 0;
|
||||
sprintf(g->throb_buf, "throbber%u", g->throbber);
|
||||
wimp_set_icon_state(g->data.browser.toolbar,
|
||||
ICON_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) && (g->window == window)) return g;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
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) && (g->data.browser.toolbar) &&
|
||||
(g->data.browser.toolbar->toolbar_handle == 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;
|
||||
gui_window *ro_lookup_gui_status_from_w(wimp_w window) {
|
||||
gui_window* g;
|
||||
for (g = window_list; g != NULL; g = g->next) {
|
||||
if ((g->type == GUI_BROWSER_WINDOW) && (g->data.browser.toolbar) &&
|
||||
(g->data.browser.toolbar->status_handle == window)) return g;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Convert a wimp window handle to the owning gui_window structure.
|
||||
*/
|
||||
gui_window *ro_gui_window_lookup(wimp_w w)
|
||||
{
|
||||
gui_window *ro_gui_window_lookup(wimp_w w) {
|
||||
gui_window *g;
|
||||
|
||||
for (g = window_list; g; g = g->next) {
|
||||
if (g->window == w)
|
||||
return g;
|
||||
else if (g->type == GUI_BROWSER_WINDOW &&
|
||||
g->data.browser.toolbar == w)
|
||||
if (g->window == w) {
|
||||
return g;
|
||||
} else if (g->type == GUI_BROWSER_WINDOW) {
|
||||
if ((g->data.browser.toolbar) &&
|
||||
((g->data.browser.toolbar->toolbar_handle == w) ||
|
||||
(g->data.browser.toolbar->status_handle == w))) return g;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
@ -588,8 +516,8 @@ void ro_gui_window_mouse_at(wimp_pointer* pointer)
|
||||
gui_window* g;
|
||||
|
||||
if (pointer->w == history_window) {
|
||||
ro_gui_history_mouse_at(pointer);
|
||||
return;
|
||||
ro_gui_history_mouse_at(pointer);
|
||||
return;
|
||||
}
|
||||
|
||||
g = ro_lookup_gui_from_w(pointer->w);
|
||||
@ -625,17 +553,18 @@ void ro_gui_window_mouse_at(wimp_pointer* pointer)
|
||||
}
|
||||
}
|
||||
|
||||
void ro_gui_toolbar_click(gui_window* g, wimp_pointer* pointer)
|
||||
{
|
||||
void ro_gui_toolbar_click(gui_window* g, wimp_pointer* pointer) {
|
||||
unsigned int history_move_back;
|
||||
switch (pointer->i) {
|
||||
case ICON_TOOLBAR_BACK:
|
||||
history_back(g->data.browser.bw,
|
||||
g->data.browser.bw->history);
|
||||
break;
|
||||
|
||||
case ICON_TOOLBAR_FORWARD:
|
||||
history_forward(g->data.browser.bw,
|
||||
g->data.browser.bw->history);
|
||||
history_move_back = (pointer->i == ICON_TOOLBAR_BACK);
|
||||
if (pointer->buttons == wimp_CLICK_ADJUST) history_move_back = !history_move_back;
|
||||
if (history_move_back) {
|
||||
history_back(g->data.browser.bw, g->data.browser.bw->history);
|
||||
} else {
|
||||
history_forward(g->data.browser.bw, g->data.browser.bw->history);
|
||||
}
|
||||
break;
|
||||
|
||||
case ICON_TOOLBAR_HISTORY:
|
||||
@ -653,105 +582,123 @@ void ro_gui_toolbar_click(gui_window* g, wimp_pointer* pointer)
|
||||
);*/
|
||||
break;
|
||||
|
||||
case ICON_TOOLBAR_SCALE:
|
||||
current_gui = g;
|
||||
ro_gui_menu_prepare_scale();
|
||||
/** \todo make scale window persistent */
|
||||
xwimp_create_menu((wimp_menu *) dialog_zoom,
|
||||
pointer->pos.x, pointer->pos.y);
|
||||
break;
|
||||
|
||||
case ICON_TOOLBAR_SAVE:
|
||||
current_gui = g;
|
||||
current_gui = g;
|
||||
gui_current_save_type = GUI_SAVE_SOURCE;
|
||||
ro_gui_menu_prepare_save(g->data.browser.bw->current_content);
|
||||
/** \todo make save window persistent */
|
||||
xwimp_create_menu((wimp_menu *) dialog_saveas,
|
||||
pointer->pos.x, pointer->pos.y);
|
||||
break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void ro_gui_status_click(gui_window* g, wimp_pointer* pointer) {
|
||||
wimp_drag drag;
|
||||
os_error *error;
|
||||
switch (pointer->i) {
|
||||
case ICON_STATUS_RESIZE:
|
||||
gui_current_drag_type = GUI_DRAG_STATUS_RESIZE;
|
||||
drag.w = g->data.browser.toolbar->status_handle;
|
||||
drag.type = wimp_DRAG_SYSTEM_SIZE;
|
||||
drag.initial.x0 = pointer->pos.x;
|
||||
drag.initial.x1 = pointer->pos.x;
|
||||
drag.initial.y0 = pointer->pos.y;
|
||||
drag.initial.y1 = pointer->pos.y;
|
||||
error = xwimp_drag_box(&drag);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ro_gui_window_click(gui_window* g, wimp_pointer* pointer)
|
||||
{
|
||||
struct browser_action msg;
|
||||
int x,y;
|
||||
wimp_window_state state;
|
||||
void ro_gui_window_click(gui_window* g, wimp_pointer* pointer) {
|
||||
struct browser_action msg;
|
||||
int x,y;
|
||||
wimp_window_state state;
|
||||
|
||||
state.w = pointer->w;
|
||||
wimp_get_window_state(&state);
|
||||
if (g->type != GUI_BROWSER_WINDOW) return;
|
||||
|
||||
if (g->type == GUI_BROWSER_WINDOW)
|
||||
{
|
||||
x = window_x_units(pointer->pos.x, &state) / 2 / g->scale;
|
||||
y = -window_y_units(pointer->pos.y, &state) / 2 / g->scale;
|
||||
state.w = pointer->w;
|
||||
wimp_get_window_state(&state);
|
||||
|
||||
if (pointer->buttons == wimp_CLICK_MENU)
|
||||
{
|
||||
x = window_x_units(pointer->pos.x, &state) / 2 / g->scale;
|
||||
y = -window_y_units(pointer->pos.y, &state) / 2 / g->scale;
|
||||
|
||||
if (pointer->buttons == wimp_CLICK_MENU) {
|
||||
ro_gui_create_menu(browser_menu, pointer->pos.x - 64, pointer->pos.y, g);
|
||||
}
|
||||
else if (g->data.browser.bw->current_content != NULL)
|
||||
{
|
||||
} 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)
|
||||
if (pointer->buttons == wimp_CLICK_SELECT)
|
||||
{
|
||||
msg.type = act_MOUSE_CLICK;
|
||||
msg.data.mouse.x = x;
|
||||
msg.data.mouse.x = x;
|
||||
msg.data.mouse.y = y;
|
||||
if (browser_window_action(g->data.browser.bw, &msg) == 1)
|
||||
return;
|
||||
msg.type = act_UNKNOWN;
|
||||
}
|
||||
if (pointer->buttons == wimp_CLICK_SELECT && g->data.browser.bw->current_content->data.html.text_selection.selected == 1)
|
||||
msg.type = act_CLEAR_SELECTION;
|
||||
else if (pointer->buttons == wimp_CLICK_ADJUST && g->data.browser.bw->current_content->data.html.text_selection.selected == 1)
|
||||
msg.type = act_ALTER_SELECTION;
|
||||
else if (pointer->buttons == wimp_DRAG_SELECT ||
|
||||
pointer->buttons == wimp_DRAG_ADJUST)
|
||||
{
|
||||
msg.type = act_START_NEW_SELECTION;
|
||||
if (pointer->buttons == wimp_DRAG_ADJUST && g->data.browser.bw->current_content->data.html.text_selection.selected == 1)
|
||||
msg.type = act_ALTER_SELECTION;
|
||||
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);
|
||||
ro_gui_start_selection(pointer, &state, g);
|
||||
g->drag_status = drag_BROWSER_TEXT_SELECTION;
|
||||
}
|
||||
msg.data.mouse.x = x;
|
||||
msg.data.mouse.y = y;
|
||||
if (msg.type != act_UNKNOWN)
|
||||
browser_window_action(g->data.browser.bw, &msg);
|
||||
|
||||
if (pointer->buttons == wimp_CLICK_ADJUST && g->data.browser.bw->current_content->data.html.text_selection.selected == 1)
|
||||
{
|
||||
current_gui->data.browser.bw->current_content->data.html.text_selection.altering = alter_UNKNOWN;
|
||||
}
|
||||
if (pointer->buttons == wimp_CLICK_ADJUST && g->data.browser.bw->current_content->data.html.text_selection.selected == 1)
|
||||
{
|
||||
current_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);
|
||||
}
|
||||
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_start_throbber(struct gui_window* g) {
|
||||
if (theme_throbs == 0) return;
|
||||
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;
|
||||
sprintf(g->throb_buf, "throbber%u", g->throbber);
|
||||
wimp_set_icon_state(g->data.browser.toolbar, ICON_TOOLBAR_THROBBER, 0, 0);
|
||||
void gui_window_stop_throbber(gui_window* g) {
|
||||
g->throbber = 0;
|
||||
sprintf(g->throb_buf, "throbber%u", g->throbber);
|
||||
ro_gui_redraw_icon(g->data.browser.toolbar->toolbar_handle, ICON_TOOLBAR_THROBBER);
|
||||
}
|
||||
|
||||
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) {
|
||||
wimp_set_caret_position(g->window, -1,
|
||||
x * 2, -(y + height) * 2, height * 2, -1);
|
||||
}
|
||||
@ -787,7 +734,7 @@ bool ro_gui_window_keypress(gui_window *g, int key, bool toolbar)
|
||||
/* We can't map on to any of: 3,8,10,13,21,22 or 24
|
||||
* That leaves 1,2,4-7,11,12,14-20,23,25-31 and 129-159
|
||||
*/
|
||||
if (c == 394) c = 9; /* Tab */
|
||||
if (c == 394) c = 9; /* Tab */
|
||||
else if (c == 410) c = 11; /* Shift+Tab */
|
||||
else if (c == 428) c = 26; /* Ctrl+Left */
|
||||
else if (c == 429) c = 27; /* Ctrl+Right*/
|
||||
@ -895,8 +842,7 @@ bool ro_gui_window_keypress(gui_window *g, int key, bool toolbar)
|
||||
state.w = g->window;
|
||||
wimp_get_window_state(&state);
|
||||
y = state.visible.y1 - state.visible.y0 - 32;
|
||||
if (option_show_toolbar)
|
||||
y -= ro_theme_toolbar_height();
|
||||
y -= g->data.browser.toolbar->height;
|
||||
|
||||
switch (key) {
|
||||
case wimp_KEY_UP:
|
||||
@ -917,7 +863,7 @@ bool ro_gui_window_keypress(gui_window *g, int key, bool toolbar)
|
||||
case wimp_KEY_CONTROL | wimp_KEY_DOWN:
|
||||
state.yscroll = -0x10000000;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
wimp_open_window((wimp_open *) &state);
|
||||
return true;
|
||||
@ -937,8 +883,7 @@ void ro_gui_scroll_request(wimp_scroll *scroll)
|
||||
|
||||
x = scroll->visible.x1 - scroll->visible.x0 - 32;
|
||||
y = scroll->visible.y1 - scroll->visible.y0 - 32;
|
||||
if (option_show_toolbar)
|
||||
y -= ro_theme_toolbar_height();
|
||||
y -= g->data.browser.toolbar->height;
|
||||
|
||||
switch (scroll->xmin) {
|
||||
case wimp_SCROLL_PAGE_LEFT:
|
||||
@ -981,13 +926,12 @@ void ro_gui_scroll_request(wimp_scroll *scroll)
|
||||
/**
|
||||
* Convert x from screen to window coordinates.
|
||||
*
|
||||
* \param x x coordinate / os units
|
||||
* \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)
|
||||
{
|
||||
//#define window_x_units(x, state) (x - (state->visible.x0 - state->xscroll))
|
||||
int window_x_units(int x, wimp_window_state *state) {
|
||||
return x - (state->visible.x0 - state->xscroll);
|
||||
}
|
||||
|
||||
@ -995,13 +939,12 @@ int window_x_units(int x, wimp_window_state *state)
|
||||
/**
|
||||
* Convert y from screen to window coordinates.
|
||||
*
|
||||
* \param y y coordinate / os units
|
||||
* \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)
|
||||
{
|
||||
//#define window_y_units(y, state) (y - (state->visible.y1 - state->yscroll))
|
||||
int window_y_units(int y, wimp_window_state *state) {
|
||||
return y - (state->visible.y1 - state->yscroll);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user