2003-08-27 02:37:32 +04:00
|
|
|
/*
|
|
|
|
* This file is part of NetSurf, http://netsurf.sourceforge.net/
|
|
|
|
* Licensed under the GNU General Public License,
|
2004-08-07 03:45:21 +04:00
|
|
|
* http://www.opensource.org/licenses/gpl-license
|
2003-08-27 02:37:32 +04:00
|
|
|
* Copyright 2003 Phil Mellor <monkeyson@users.sourceforge.net>
|
2005-02-25 01:00:41 +03:00
|
|
|
* Copyright 2005 James Bursa <bursa@users.sourceforge.net>
|
2003-08-27 02:37:32 +04:00
|
|
|
* Copyright 2003 John M Bell <jmb202@ecs.soton.ac.uk>
|
2005-12-31 07:40:49 +03:00
|
|
|
* Copyright 2005 Richard Wilson <info@tinct.net>
|
2004-07-25 23:25:26 +04:00
|
|
|
* Copyright 2004 Andrew Timmins <atimmins@blueyonder.co.uk>
|
2005-07-16 09:54:45 +04:00
|
|
|
* Copyright 2005 Adrian Lees <adrianl@users.sourceforge.net>
|
2003-08-27 02:37:32 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <assert.h>
|
2003-12-19 03:40:28 +03:00
|
|
|
#include <stddef.h>
|
2004-08-08 15:39:31 +04:00
|
|
|
#include <stdlib.h>
|
2003-08-27 02:37:32 +04:00
|
|
|
#include <string.h>
|
2003-08-28 00:09:57 +04:00
|
|
|
#include "oslib/colourtrans.h"
|
|
|
|
#include "oslib/osfile.h"
|
|
|
|
#include "oslib/osgbpb.h"
|
|
|
|
#include "oslib/osspriteop.h"
|
2003-08-27 02:37:32 +04:00
|
|
|
#include "oslib/wimp.h"
|
2005-02-25 01:00:41 +03:00
|
|
|
#include "rufl.h"
|
2004-01-05 05:10:59 +03:00
|
|
|
#include "netsurf/utils/config.h"
|
2003-12-19 20:11:07 +03:00
|
|
|
#include "netsurf/desktop/netsurf.h"
|
2004-09-14 03:56:18 +04:00
|
|
|
#include "netsurf/render/font.h"
|
2005-12-31 07:40:49 +03:00
|
|
|
#include "netsurf/riscos/configure.h"
|
|
|
|
#include "netsurf/riscos/dialog.h"
|
2006-01-07 00:25:34 +03:00
|
|
|
#include "netsurf/riscos/global_history.h"
|
2003-08-27 02:37:32 +04:00
|
|
|
#include "netsurf/riscos/gui.h"
|
2005-04-08 00:46:22 +04:00
|
|
|
#include "netsurf/riscos/menus.h"
|
2003-08-27 02:37:32 +04:00
|
|
|
#include "netsurf/riscos/options.h"
|
2004-05-23 03:04:44 +04:00
|
|
|
#include "netsurf/riscos/theme.h"
|
2005-12-31 07:40:49 +03:00
|
|
|
#include "netsurf/riscos/url_complete.h"
|
2004-05-05 02:23:44 +04:00
|
|
|
#include "netsurf/riscos/wimp.h"
|
2005-12-31 07:40:49 +03:00
|
|
|
#include "netsurf/riscos/wimp_event.h"
|
2003-08-28 00:09:57 +04:00
|
|
|
#include "netsurf/utils/log.h"
|
2003-11-09 00:47:10 +03:00
|
|
|
#include "netsurf/utils/messages.h"
|
2005-04-08 00:46:22 +04:00
|
|
|
#include "netsurf/utils/url.h"
|
2003-08-27 02:37:32 +04:00
|
|
|
#include "netsurf/utils/utils.h"
|
|
|
|
|
2005-07-16 09:54:45 +04:00
|
|
|
/* The maximum number of persistent dialogues
|
2004-07-08 21:28:56 +04:00
|
|
|
*/
|
2005-12-31 07:40:49 +03:00
|
|
|
#define MAX_PERSISTENT 16
|
2004-08-31 01:03:48 +04:00
|
|
|
|
|
|
|
|
2005-12-31 07:40:49 +03:00
|
|
|
wimp_w dialog_info, dialog_saveas,
|
2004-01-05 05:10:59 +03:00
|
|
|
#ifdef WITH_AUTH
|
2004-02-25 18:12:58 +03:00
|
|
|
dialog_401li,
|
2004-01-05 05:10:59 +03:00
|
|
|
#endif
|
2004-05-07 23:14:54 +04:00
|
|
|
dialog_zoom, dialog_pageinfo, dialog_objinfo, dialog_tooltip,
|
2005-12-31 07:40:49 +03:00
|
|
|
dialog_warning, dialog_debug,
|
2004-09-14 03:56:18 +04:00
|
|
|
dialog_folder, dialog_entry, dialog_search, dialog_print,
|
2005-12-31 07:40:49 +03:00
|
|
|
dialog_url_complete, dialog_openurl;
|
2004-08-31 01:03:48 +04:00
|
|
|
|
2005-04-08 00:46:22 +04:00
|
|
|
struct gui_window *ro_gui_current_zoom_gui;
|
|
|
|
|
2004-08-31 01:03:48 +04:00
|
|
|
|
2004-07-08 21:28:56 +04:00
|
|
|
/* A simple mapping of parent and child
|
|
|
|
*/
|
2004-07-27 19:49:28 +04:00
|
|
|
static struct {
|
|
|
|
wimp_w dialog;
|
|
|
|
wimp_w parent;
|
2005-07-16 09:54:45 +04:00
|
|
|
} persistent_dialog[MAX_PERSISTENT];
|
2003-08-27 02:37:32 +04:00
|
|
|
|
2004-08-31 01:03:48 +04:00
|
|
|
|
2005-12-31 07:40:49 +03:00
|
|
|
static bool ro_gui_dialog_openurl_apply(wimp_w w);
|
|
|
|
static bool ro_gui_dialog_zoom_click(wimp_pointer *pointer);
|
|
|
|
static bool ro_gui_dialog_zoom_apply(wimp_w w);
|
2003-08-27 02:37:32 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Load and create dialogs from template file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
void ro_gui_dialog_init(void)
|
|
|
|
{
|
2005-12-31 07:40:49 +03:00
|
|
|
/* warning dialog */
|
|
|
|
dialog_warning = ro_gui_dialog_create("warning");
|
|
|
|
ro_gui_wimp_event_register_ok(dialog_warning, ICON_WARNING_CONTINUE,
|
|
|
|
NULL);
|
|
|
|
ro_gui_wimp_event_set_help_prefix(dialog_debug, "HelpWarning");
|
|
|
|
|
2006-01-07 00:25:34 +03:00
|
|
|
/* tooltip for history */
|
|
|
|
dialog_tooltip = ro_gui_dialog_create("tooltip");
|
|
|
|
|
|
|
|
/* configure window */
|
|
|
|
ro_gui_configure_initialise();
|
|
|
|
|
|
|
|
/* 401 login window */
|
|
|
|
#ifdef WITH_AUTH
|
|
|
|
ro_gui_401login_init();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* hotlist window */
|
|
|
|
ro_gui_hotlist_initialise();
|
|
|
|
|
|
|
|
/* global history window */
|
|
|
|
ro_gui_global_history_initialise();
|
|
|
|
|
2005-12-31 07:40:49 +03:00
|
|
|
/* theme installation */
|
|
|
|
dialog_theme_install = ro_gui_dialog_create("theme_inst");
|
|
|
|
ro_gui_wimp_event_register_cancel(dialog_theme_install,
|
|
|
|
ICON_THEME_INSTALL_CANCEL);
|
|
|
|
ro_gui_wimp_event_register_ok(dialog_theme_install,
|
|
|
|
ICON_THEME_INSTALL_INSTALL,
|
|
|
|
ro_gui_theme_install_apply);
|
|
|
|
ro_gui_wimp_event_set_help_prefix(dialog_theme_install, "HelpThemeInst");
|
|
|
|
|
|
|
|
/* debug window */
|
|
|
|
dialog_debug = ro_gui_dialog_create("debug");
|
|
|
|
ro_gui_wimp_event_set_help_prefix(dialog_debug, "HelpDebug");
|
|
|
|
|
|
|
|
/* search */
|
|
|
|
#ifdef WITH_SEARCH
|
|
|
|
ro_gui_search_init();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* print */
|
|
|
|
#ifdef WITH_PRINT
|
|
|
|
ro_gui_print_init();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* about us */
|
2003-08-27 02:37:32 +04:00
|
|
|
dialog_info = ro_gui_dialog_create("info");
|
2004-02-26 03:44:42 +03:00
|
|
|
ro_gui_set_icon_string(dialog_info, 4, netsurf_version);
|
2005-12-31 07:40:49 +03:00
|
|
|
ro_gui_wimp_event_set_help_prefix(dialog_info, "HelpAppInfo");
|
2003-12-19 04:00:22 +03:00
|
|
|
|
2005-12-31 07:40:49 +03:00
|
|
|
/* page info */
|
2004-04-03 06:59:35 +04:00
|
|
|
dialog_pageinfo = ro_gui_dialog_create("pageinfo");
|
2005-12-31 07:40:49 +03:00
|
|
|
ro_gui_wimp_event_set_help_prefix(dialog_pageinfo, "HelpPageInfo");
|
|
|
|
|
|
|
|
/* object info */
|
2004-05-05 04:02:13 +04:00
|
|
|
dialog_objinfo = ro_gui_dialog_create("objectinfo");
|
2005-12-31 07:40:49 +03:00
|
|
|
ro_gui_wimp_event_set_help_prefix(dialog_objinfo, "HelpObjInfo");
|
|
|
|
|
|
|
|
/* hotlist folder editing */
|
2004-07-09 02:05:35 +04:00
|
|
|
dialog_folder = ro_gui_dialog_create("new_folder");
|
2005-12-31 07:40:49 +03:00
|
|
|
ro_gui_wimp_event_register_text_field(dialog_folder, ICON_FOLDER_NAME);
|
|
|
|
ro_gui_wimp_event_register_menu_gright(dialog_openurl, ICON_OPENURL_URL,
|
|
|
|
ICON_OPENURL_MENU, url_suggest_menu);
|
|
|
|
ro_gui_wimp_event_register_cancel(dialog_folder, ICON_FOLDER_CANCEL);
|
|
|
|
ro_gui_wimp_event_register_ok(dialog_folder, ICON_FOLDER_OK,
|
|
|
|
ro_gui_hotlist_dialog_apply);
|
|
|
|
ro_gui_wimp_event_set_help_prefix(dialog_folder, "HelpHotFolder");
|
|
|
|
|
|
|
|
/* hotlist entry editing */
|
2004-07-09 02:05:35 +04:00
|
|
|
dialog_entry = ro_gui_dialog_create("new_entry");
|
2005-12-31 07:40:49 +03:00
|
|
|
ro_gui_wimp_event_register_text_field(dialog_entry, ICON_ENTRY_NAME);
|
|
|
|
ro_gui_wimp_event_register_menu_gright(dialog_entry, ICON_ENTRY_URL,
|
|
|
|
ICON_ENTRY_RECENT, url_suggest_menu);
|
|
|
|
ro_gui_wimp_event_register_cancel(dialog_entry, ICON_ENTRY_CANCEL);
|
|
|
|
ro_gui_wimp_event_register_ok(dialog_entry, ICON_ENTRY_OK,
|
|
|
|
ro_gui_hotlist_dialog_apply);
|
|
|
|
ro_gui_wimp_event_set_help_prefix(dialog_entry, "HelpHotEntry");
|
|
|
|
|
|
|
|
/* save as */
|
|
|
|
dialog_saveas = ro_gui_saveas_create("saveas");
|
|
|
|
ro_gui_wimp_event_register_button(dialog_saveas, ICON_SAVE_ICON,
|
|
|
|
ro_gui_save_start_drag);
|
|
|
|
ro_gui_wimp_event_register_text_field(dialog_saveas, ICON_SAVE_PATH);
|
|
|
|
ro_gui_wimp_event_register_cancel(dialog_saveas, ICON_SAVE_CANCEL);
|
|
|
|
ro_gui_wimp_event_register_ok(dialog_saveas, ICON_SAVE_OK,
|
|
|
|
ro_gui_save_ok);
|
|
|
|
ro_gui_wimp_event_set_help_prefix(dialog_saveas, "HelpSaveAs");
|
|
|
|
|
|
|
|
/* url suggestion */
|
2005-02-03 16:18:22 +03:00
|
|
|
dialog_url_complete = ro_gui_dialog_create("url_suggest");
|
2006-01-01 16:58:31 +03:00
|
|
|
ro_gui_wimp_event_register_mouse_click(dialog_url_complete,
|
|
|
|
ro_gui_url_complete_click);
|
2005-12-31 07:40:49 +03:00
|
|
|
ro_gui_wimp_event_register_redraw_window(dialog_url_complete,
|
|
|
|
ro_gui_url_complete_redraw);
|
|
|
|
ro_gui_wimp_event_set_help_prefix(dialog_url_complete, "HelpAutoURL");
|
|
|
|
|
|
|
|
/* open URL */
|
2005-04-08 00:46:22 +04:00
|
|
|
dialog_openurl = ro_gui_dialog_create("open_url");
|
2005-12-31 07:40:49 +03:00
|
|
|
ro_gui_wimp_event_register_menu_gright(dialog_openurl, ICON_OPENURL_URL,
|
|
|
|
ICON_OPENURL_MENU, url_suggest_menu);
|
|
|
|
ro_gui_wimp_event_register_cancel(dialog_openurl, ICON_OPENURL_CANCEL);
|
|
|
|
ro_gui_wimp_event_register_ok(dialog_openurl, ICON_OPENURL_OPEN,
|
|
|
|
ro_gui_dialog_openurl_apply);
|
|
|
|
ro_gui_wimp_event_set_help_prefix(dialog_openurl, "HelpOpenURL");
|
|
|
|
|
|
|
|
/* scale view */
|
|
|
|
dialog_zoom = ro_gui_dialog_create("zoom");
|
|
|
|
ro_gui_wimp_event_register_numeric_field(dialog_zoom, ICON_ZOOM_VALUE,
|
|
|
|
ICON_ZOOM_INC, ICON_ZOOM_DEC, 10, 1600, 10, 0);
|
|
|
|
ro_gui_wimp_event_register_mouse_click(dialog_zoom,
|
|
|
|
ro_gui_dialog_zoom_click);
|
|
|
|
ro_gui_wimp_event_register_cancel(dialog_zoom, ICON_ZOOM_CANCEL);
|
|
|
|
ro_gui_wimp_event_register_ok(dialog_zoom, ICON_ZOOM_OK,
|
|
|
|
ro_gui_dialog_zoom_apply);
|
|
|
|
ro_gui_wimp_event_set_help_prefix(dialog_zoom, "HelpScaleView");
|
2003-08-27 02:37:32 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a window from a template.
|
2004-05-09 00:44:00 +04:00
|
|
|
*
|
|
|
|
* \param template_name name of template to load
|
|
|
|
* \return window handle
|
|
|
|
*
|
|
|
|
* Exits through die() on error.
|
2003-08-27 02:37:32 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
wimp_w ro_gui_dialog_create(const char *template_name)
|
|
|
|
{
|
|
|
|
wimp_window *window;
|
|
|
|
wimp_w w;
|
2004-05-09 00:44:00 +04:00
|
|
|
os_error *error;
|
2003-08-27 02:37:32 +04:00
|
|
|
|
2004-05-09 00:44:00 +04:00
|
|
|
window = ro_gui_dialog_load_template(template_name);
|
2003-08-27 02:37:32 +04:00
|
|
|
|
2004-05-09 00:44:00 +04:00
|
|
|
/* create window */
|
2005-12-31 07:40:49 +03:00
|
|
|
window->sprite_area = gui_sprites;
|
2004-05-09 00:44:00 +04:00
|
|
|
error = xwimp_create_window(window, &w);
|
|
|
|
if (error) {
|
|
|
|
LOG(("xwimp_create_window: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess));
|
|
|
|
xwimp_close_template();
|
|
|
|
die(error->errmess);
|
|
|
|
}
|
2003-08-27 02:37:32 +04:00
|
|
|
|
|
|
|
/* the window definition is copied by the wimp and may be freed */
|
2004-05-09 00:44:00 +04:00
|
|
|
free(window);
|
2003-08-27 02:37:32 +04:00
|
|
|
|
|
|
|
return w;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-05-09 00:44:00 +04:00
|
|
|
/**
|
|
|
|
* Load a template without creating a window.
|
|
|
|
*
|
|
|
|
* \param template_name name of template to load
|
|
|
|
* \return window block
|
|
|
|
*
|
|
|
|
* Exits through die() on error.
|
|
|
|
*/
|
|
|
|
|
|
|
|
wimp_window * ro_gui_dialog_load_template(const char *template_name)
|
|
|
|
{
|
|
|
|
char name[20];
|
|
|
|
int context, window_size, data_size;
|
|
|
|
char *data;
|
|
|
|
wimp_window *window;
|
|
|
|
os_error *error;
|
|
|
|
|
|
|
|
/* wimp_load_template won't accept a const char * */
|
|
|
|
strncpy(name, template_name, sizeof name);
|
|
|
|
|
|
|
|
/* find required buffer sizes */
|
|
|
|
error = xwimp_load_template(wimp_GET_SIZE, 0, 0, wimp_NO_FONTS,
|
|
|
|
name, 0, &window_size, &data_size, &context);
|
|
|
|
if (error) {
|
|
|
|
LOG(("xwimp_load_template: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess));
|
|
|
|
xwimp_close_template();
|
|
|
|
die(error->errmess);
|
|
|
|
}
|
|
|
|
if (!context) {
|
|
|
|
LOG(("template '%s' missing", template_name));
|
|
|
|
xwimp_close_template();
|
|
|
|
die("Template");
|
|
|
|
}
|
|
|
|
|
|
|
|
/* allocate space for indirected data and temporary window buffer */
|
|
|
|
data = malloc(data_size);
|
|
|
|
window = malloc(window_size);
|
|
|
|
if (!data || !window) {
|
|
|
|
xwimp_close_template();
|
|
|
|
die("NoMemory");
|
|
|
|
}
|
|
|
|
|
|
|
|
/* load template */
|
|
|
|
error = xwimp_load_template(window, data, data + data_size,
|
|
|
|
wimp_NO_FONTS, name, 0, 0, 0, 0);
|
|
|
|
if (error) {
|
|
|
|
LOG(("xwimp_load_template: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess));
|
|
|
|
xwimp_close_template();
|
|
|
|
die(error->errmess);
|
|
|
|
}
|
|
|
|
|
|
|
|
return window;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-08-28 00:09:57 +04:00
|
|
|
/**
|
|
|
|
* Open a dialog box, centered on the screen.
|
|
|
|
*/
|
2004-07-27 19:49:28 +04:00
|
|
|
|
2003-08-28 00:09:57 +04:00
|
|
|
void ro_gui_dialog_open(wimp_w w)
|
|
|
|
{
|
2003-11-08 02:51:13 +03:00
|
|
|
int screen_x, screen_y, dx, dy;
|
2004-05-23 03:04:44 +04:00
|
|
|
wimp_window_state open;
|
2004-07-27 19:49:28 +04:00
|
|
|
os_error *error;
|
2003-08-28 00:09:57 +04:00
|
|
|
|
2003-10-23 04:09:17 +04:00
|
|
|
/* find screen centre in os units */
|
2003-11-08 02:51:13 +03:00
|
|
|
ro_gui_screen_size(&screen_x, &screen_y);
|
|
|
|
screen_x /= 2;
|
|
|
|
screen_y /= 2;
|
2003-08-28 00:09:57 +04:00
|
|
|
|
|
|
|
/* centre and open */
|
|
|
|
open.w = w;
|
2004-07-27 19:49:28 +04:00
|
|
|
error = xwimp_get_window_state(&open);
|
|
|
|
if (error) {
|
|
|
|
LOG(("xwimp_get_window_state: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess));
|
|
|
|
warn_user("WimpError", error->errmess);
|
|
|
|
return;
|
|
|
|
}
|
2003-08-28 00:09:57 +04:00
|
|
|
dx = (open.visible.x1 - open.visible.x0) / 2;
|
|
|
|
dy = (open.visible.y1 - open.visible.y0) / 2;
|
|
|
|
open.visible.x0 = screen_x - dx;
|
|
|
|
open.visible.x1 = screen_x + dx;
|
|
|
|
open.visible.y0 = screen_y - dy;
|
|
|
|
open.visible.y1 = screen_y + dy;
|
|
|
|
open.next = wimp_TOP;
|
2004-07-27 19:49:28 +04:00
|
|
|
error = xwimp_open_window((wimp_open *) &open);
|
|
|
|
if (error) {
|
|
|
|
LOG(("xwimp_open_window: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess));
|
|
|
|
warn_user("WimpError", error->errmess);
|
|
|
|
return;
|
|
|
|
}
|
2004-07-17 17:00:38 +04:00
|
|
|
|
2004-07-12 01:45:51 +04:00
|
|
|
/* Set the caret position
|
|
|
|
*/
|
|
|
|
ro_gui_set_caret_first(w);
|
2003-08-28 00:09:57 +04:00
|
|
|
}
|
|
|
|
|
2004-07-08 21:28:56 +04:00
|
|
|
|
|
|
|
/**
|
2005-12-31 07:40:49 +03:00
|
|
|
* Close a dialog box.
|
2004-07-08 21:28:56 +04:00
|
|
|
*/
|
2004-07-27 19:49:28 +04:00
|
|
|
|
2005-12-31 07:40:49 +03:00
|
|
|
void ro_gui_dialog_close(wimp_w close)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
wimp_caret caret;
|
2004-07-08 21:28:56 +04:00
|
|
|
os_error *error;
|
2004-07-17 17:00:38 +04:00
|
|
|
|
2005-12-31 07:40:49 +03:00
|
|
|
/* Give the caret back to the parent window. This code relies on
|
|
|
|
the fact that only tree windows and browser windows open
|
|
|
|
persistent dialogues, as the caret gets placed to no icon.
|
2004-07-08 21:28:56 +04:00
|
|
|
*/
|
2005-12-31 07:40:49 +03:00
|
|
|
error = xwimp_get_caret_position(&caret);
|
|
|
|
if (error) {
|
|
|
|
LOG(("xwimp_get_caret_position: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess));
|
|
|
|
warn_user("WimpError", error->errmess);
|
|
|
|
} else if (caret.w == close) {
|
|
|
|
/* Check if we are a persistent window
|
2005-04-15 09:54:44 +04:00
|
|
|
*/
|
2005-12-31 07:40:49 +03:00
|
|
|
for (i = 0; i < MAX_PERSISTENT; i++) {
|
|
|
|
if (persistent_dialog[i].dialog == close) {
|
|
|
|
persistent_dialog[i].dialog = NULL;
|
|
|
|
error = xwimp_set_caret_position(
|
|
|
|
persistent_dialog[i].parent,
|
|
|
|
wimp_ICON_WINDOW, -100, -100,
|
|
|
|
32, -1);
|
|
|
|
if (error) {
|
|
|
|
LOG(("xwimp_set_caret_position: "
|
|
|
|
"0x%x: %s",
|
|
|
|
error->errnum,
|
|
|
|
error->errmess));
|
|
|
|
warn_user("WimpError", error->errmess);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2005-04-15 09:54:44 +04:00
|
|
|
}
|
2005-12-31 07:40:49 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
error = xwimp_close_window(close);
|
|
|
|
if (error) {
|
|
|
|
LOG(("xwimp_close_window: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess));
|
|
|
|
warn_user("WimpError", error->errmess);
|
|
|
|
}
|
|
|
|
ro_gui_wimp_event_close_window(close);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Moves a window to the top of the stack.
|
|
|
|
*
|
|
|
|
* If the window is currently closed then:
|
|
|
|
*
|
|
|
|
* * The window is opened in the centre of the screen (at the supplied size)
|
|
|
|
* * Any toolbar editing session is stopped
|
|
|
|
* * The scroll position is set to the top of the window
|
|
|
|
*
|
|
|
|
* If the window is currently open then:
|
|
|
|
*
|
|
|
|
* * The window is brought to the top of the stack
|
|
|
|
*
|
|
|
|
* \param w the window to show
|
|
|
|
* \param toolbar the toolbar to consider
|
|
|
|
* \param width the window width if it is currently closed (or 0 to retain)
|
|
|
|
* \param height the window height if it is currently closed (or 0 to retain)
|
|
|
|
* \return true if the window was previously open
|
|
|
|
*/
|
|
|
|
bool ro_gui_dialog_open_top(wimp_w w, struct toolbar *toolbar,
|
|
|
|
int width, int height) {
|
|
|
|
os_error *error;
|
|
|
|
int screen_width, screen_height;
|
|
|
|
wimp_window_state state;
|
|
|
|
int dimension;
|
|
|
|
int scroll_width;
|
|
|
|
bool open;
|
|
|
|
|
|
|
|
state.w = w;
|
|
|
|
error = xwimp_get_window_state(&state);
|
|
|
|
if (error) {
|
|
|
|
warn_user("WimpError", error->errmess);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* if we're open we jump to the top of the stack, if not then we
|
|
|
|
* open in the centre of the screen. */
|
|
|
|
open = state.flags & wimp_WINDOW_OPEN;
|
|
|
|
if (!open) {
|
|
|
|
/* cancel any editing */
|
|
|
|
if ((toolbar) && (toolbar->editor))
|
|
|
|
ro_gui_theme_toggle_edit(toolbar);
|
|
|
|
|
|
|
|
/* move to the centre */
|
|
|
|
ro_gui_screen_size(&screen_width, &screen_height);
|
|
|
|
dimension = ((width == 0) ?
|
|
|
|
(state.visible.x1 - state.visible.x0) : width);
|
|
|
|
scroll_width = ro_get_vscroll_width(w);
|
|
|
|
state.visible.x0 = (screen_width - (dimension + scroll_width)) / 2;
|
|
|
|
state.visible.x1 = state.visible.x0 + dimension;
|
|
|
|
dimension = ((height == 0) ?
|
|
|
|
(state.visible.y1 - state.visible.y0) : height);
|
|
|
|
state.visible.y0 = (screen_height - dimension) / 2;
|
|
|
|
state.visible.y1 = state.visible.y0 + dimension;
|
|
|
|
state.xscroll = 0;
|
|
|
|
state.yscroll = 0;
|
|
|
|
if (toolbar)
|
|
|
|
state.yscroll = ro_gui_theme_toolbar_height(toolbar);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* open the window at the top of the stack */
|
|
|
|
state.next = wimp_TOP;
|
|
|
|
ro_gui_open_window_request((wimp_open*)&state);
|
|
|
|
return open;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Open window at the location of the pointer.
|
|
|
|
*/
|
|
|
|
|
|
|
|
void ro_gui_dialog_open_at_pointer(wimp_w w)
|
|
|
|
{
|
|
|
|
int dx, dy;
|
|
|
|
wimp_window_state state;
|
|
|
|
wimp_pointer ptr;
|
|
|
|
os_error *error;
|
|
|
|
|
|
|
|
/* get the pointer position */
|
|
|
|
error = xwimp_get_pointer_info(&ptr);
|
|
|
|
if (error) {
|
|
|
|
LOG(("xwimp_get_pointer_info: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess));
|
|
|
|
warn_user("WimpError", error->errmess);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* move the window */
|
|
|
|
state.w = w;
|
|
|
|
error = xwimp_get_window_state(&state);
|
|
|
|
if (error) {
|
|
|
|
LOG(("xwimp_get_window_state: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess));
|
|
|
|
warn_user("WimpError", error->errmess);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
dx = (state.visible.x1 - state.visible.x0);
|
|
|
|
dy = (state.visible.y1 - state.visible.y0);
|
|
|
|
state.visible.x0 = ptr.pos.x - 64;
|
|
|
|
state.visible.x1 = ptr.pos.x - 64 + dx;
|
|
|
|
state.visible.y0 = ptr.pos.y - dy;
|
|
|
|
state.visible.y1 = ptr.pos.y;
|
|
|
|
|
|
|
|
/* open the window at the top of the stack */
|
|
|
|
state.next = wimp_TOP;
|
|
|
|
ro_gui_open_window_request((wimp_open*)&state);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Opens a window at the centre of either another window or the screen
|
|
|
|
*
|
|
|
|
* /param parent the parent window (NULL for centre of screen)
|
|
|
|
* /param child the child window
|
|
|
|
*/
|
|
|
|
void ro_gui_dialog_open_centre_parent(wimp_w parent, wimp_w child) {
|
|
|
|
os_error *error;
|
|
|
|
wimp_window_state state;
|
|
|
|
int mid_x, mid_y;
|
|
|
|
int dimension, scroll_width;
|
2005-04-15 09:54:44 +04:00
|
|
|
|
2005-12-31 07:40:49 +03:00
|
|
|
/* get the parent window state */
|
|
|
|
if (parent) {
|
|
|
|
state.w = parent;
|
|
|
|
error = xwimp_get_window_state(&state);
|
2004-07-27 19:49:28 +04:00
|
|
|
if (error) {
|
|
|
|
LOG(("xwimp_get_window_state: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess));
|
|
|
|
warn_user("WimpError", error->errmess);
|
|
|
|
return;
|
|
|
|
}
|
2005-12-31 07:40:49 +03:00
|
|
|
scroll_width = ro_get_vscroll_width(parent);
|
|
|
|
mid_x = (state.visible.x0 + state.visible.x1 + scroll_width);
|
|
|
|
mid_y = (state.visible.y0 + state.visible.y1);
|
2004-07-16 20:33:45 +04:00
|
|
|
} else {
|
2005-12-31 07:40:49 +03:00
|
|
|
ro_gui_screen_size(&mid_x, &mid_y);
|
2004-07-16 20:33:45 +04:00
|
|
|
}
|
2005-12-31 07:40:49 +03:00
|
|
|
mid_x /= 2;
|
|
|
|
mid_y /= 2;
|
2004-07-17 17:00:38 +04:00
|
|
|
|
2005-12-31 07:40:49 +03:00
|
|
|
/* get the child window state */
|
|
|
|
state.w = child;
|
|
|
|
error = xwimp_get_window_state(&state);
|
|
|
|
if (error) {
|
|
|
|
LOG(("xwimp_get_window_state: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess));
|
|
|
|
warn_user("WimpError", error->errmess);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* move to the centre of the parent at the top of the stack */
|
|
|
|
dimension = state.visible.x1 - state.visible.x0;
|
|
|
|
scroll_width = ro_get_vscroll_width(history_window);
|
|
|
|
state.visible.x0 = mid_x - (dimension + scroll_width) / 2;
|
|
|
|
state.visible.x1 = state.visible.x0 + dimension;
|
|
|
|
dimension = state.visible.y1 - state.visible.y0;
|
|
|
|
state.visible.y0 = mid_y - dimension / 2;
|
|
|
|
state.visible.y1 = state.visible.y0 + dimension;
|
|
|
|
state.next = wimp_TOP;
|
|
|
|
ro_gui_open_window_request((wimp_open*)&state);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Open a persistent dialog box relative to the pointer.
|
|
|
|
*
|
|
|
|
* \param parent the owning window (NULL for no owner)
|
|
|
|
* \param w the dialog window
|
|
|
|
* \param pointer open the window at the pointer (centre of the parent
|
|
|
|
* otherwise)
|
|
|
|
*/
|
|
|
|
|
|
|
|
void ro_gui_dialog_open_persistent(wimp_w parent, wimp_w w, bool pointer) {
|
|
|
|
|
|
|
|
if (pointer)
|
|
|
|
ro_gui_dialog_open_at_pointer(w);
|
|
|
|
else
|
|
|
|
ro_gui_dialog_open_centre_parent(parent, w);
|
|
|
|
|
|
|
|
/* todo: use wimp_event definitions rather than special cases */
|
2005-04-08 00:46:22 +04:00
|
|
|
if ((w == dialog_pageinfo) || (w == dialog_objinfo))
|
|
|
|
ro_gui_wimp_update_window_furniture(w, wimp_WINDOW_CLOSE_ICON,
|
|
|
|
wimp_WINDOW_CLOSE_ICON);
|
2005-12-31 07:40:49 +03:00
|
|
|
ro_gui_dialog_add_persistent(parent, w);
|
|
|
|
ro_gui_set_caret_first(w);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ro_gui_dialog_add_persistent(wimp_w parent, wimp_w w) {
|
|
|
|
int i;
|
|
|
|
|
|
|
|
/* all persistant windows have a back icon */
|
2005-04-08 00:46:22 +04:00
|
|
|
ro_gui_wimp_update_window_furniture(w, wimp_WINDOW_BACK_ICON,
|
|
|
|
wimp_WINDOW_BACK_ICON);
|
2004-07-17 17:00:38 +04:00
|
|
|
|
2004-07-08 21:28:56 +04:00
|
|
|
/* Add a mapping
|
|
|
|
*/
|
2005-12-31 07:40:49 +03:00
|
|
|
if ((parent == NULL) || (parent == wimp_ICON_BAR))
|
2004-07-27 19:49:28 +04:00
|
|
|
return;
|
2005-07-16 09:54:45 +04:00
|
|
|
for (i = 0; i < MAX_PERSISTENT; i++) {
|
|
|
|
if (persistent_dialog[i].dialog == NULL ||
|
|
|
|
persistent_dialog[i].dialog == w) {
|
|
|
|
persistent_dialog[i].dialog = w;
|
|
|
|
persistent_dialog[i].parent = parent;
|
2004-07-08 21:28:56 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2005-07-16 09:54:45 +04:00
|
|
|
LOG(("Unable to map persistent dialog to parent."));
|
2005-12-31 07:40:49 +03:00
|
|
|
return;
|
2004-07-08 21:28:56 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2004-07-27 19:49:28 +04:00
|
|
|
* Close persistent dialogs associated with a window.
|
2004-07-08 21:28:56 +04:00
|
|
|
*
|
2004-07-27 19:49:28 +04:00
|
|
|
* \param parent the window to close children of
|
2004-07-08 21:28:56 +04:00
|
|
|
*/
|
2004-07-27 19:49:28 +04:00
|
|
|
|
2005-07-16 09:54:45 +04:00
|
|
|
void ro_gui_dialog_close_persistent(wimp_w parent) {
|
2004-07-27 19:49:28 +04:00
|
|
|
int i;
|
2004-07-17 17:00:38 +04:00
|
|
|
|
2004-07-08 21:28:56 +04:00
|
|
|
/* Check our mappings
|
|
|
|
*/
|
2005-07-16 09:54:45 +04:00
|
|
|
for (i = 0; i < MAX_PERSISTENT; i++) {
|
|
|
|
if (persistent_dialog[i].parent == parent &&
|
|
|
|
persistent_dialog[i].dialog != NULL) {
|
|
|
|
ro_gui_dialog_close(persistent_dialog[i].dialog);
|
|
|
|
persistent_dialog[i].dialog = NULL;
|
2004-07-08 21:28:56 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-12-26 21:18:17 +03:00
|
|
|
/**
|
2005-12-31 07:40:49 +03:00
|
|
|
* Save the current options.
|
2003-08-27 02:37:32 +04:00
|
|
|
*/
|
|
|
|
|
2005-12-31 07:40:49 +03:00
|
|
|
void ro_gui_save_options(void)
|
2003-08-27 02:37:32 +04:00
|
|
|
{
|
2005-12-31 07:40:49 +03:00
|
|
|
/* NCOS doesnt have the fancy Universal Boot vars; so select
|
|
|
|
* the path to the choices file based on the build options */
|
|
|
|
#ifndef NCOS
|
|
|
|
options_write("<Choices$Write>.WWW.NetSurf.Choices");
|
|
|
|
#else
|
|
|
|
options_write("<User$Path>.Choices.NetSurf.Choices");
|
2004-08-09 10:28:57 +04:00
|
|
|
#endif
|
2004-11-04 04:19:46 +03:00
|
|
|
}
|
2003-08-27 02:37:32 +04:00
|
|
|
|
2005-02-23 02:36:14 +03:00
|
|
|
|
2004-07-27 19:49:28 +04:00
|
|
|
/**
|
2005-12-31 07:40:49 +03:00
|
|
|
* Handle clicks in the Scale view dialog.
|
2004-07-27 19:49:28 +04:00
|
|
|
*/
|
|
|
|
|
2005-12-31 07:40:49 +03:00
|
|
|
bool ro_gui_dialog_zoom_click(wimp_pointer *pointer)
|
2004-07-27 19:49:28 +04:00
|
|
|
{
|
2005-12-31 07:40:49 +03:00
|
|
|
switch (pointer->i) {
|
|
|
|
case ICON_ZOOM_75:
|
|
|
|
ro_gui_set_icon_integer(dialog_zoom,
|
|
|
|
ICON_ZOOM_VALUE, 75);
|
|
|
|
return true;
|
|
|
|
case ICON_ZOOM_100:
|
|
|
|
ro_gui_set_icon_integer(dialog_zoom,
|
|
|
|
ICON_ZOOM_VALUE, 100);
|
|
|
|
return true;
|
|
|
|
case ICON_ZOOM_150:
|
|
|
|
ro_gui_set_icon_integer(dialog_zoom,
|
|
|
|
ICON_ZOOM_VALUE, 150);
|
|
|
|
return true;
|
|
|
|
case ICON_ZOOM_200:
|
|
|
|
ro_gui_set_icon_integer(dialog_zoom,
|
|
|
|
ICON_ZOOM_VALUE, 200);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
2004-07-27 19:49:28 +04:00
|
|
|
}
|
|
|
|
|
2005-12-31 07:40:49 +03:00
|
|
|
bool ro_gui_dialog_zoom_apply(wimp_w w) {
|
|
|
|
unsigned int scale;
|
2004-07-27 19:49:28 +04:00
|
|
|
|
2005-12-31 07:40:49 +03:00
|
|
|
scale = atoi(ro_gui_get_icon_string(w, ICON_ZOOM_VALUE));
|
|
|
|
ro_gui_window_set_scale(ro_gui_current_zoom_gui, scale * 0.01);
|
|
|
|
return true;
|
2004-07-27 19:49:28 +04:00
|
|
|
}
|
|
|
|
|
2005-02-23 02:36:14 +03:00
|
|
|
|
|
|
|
/**
|
2005-12-31 07:40:49 +03:00
|
|
|
* Prepares the Scale view dialog.
|
2005-02-23 02:36:14 +03:00
|
|
|
*/
|
|
|
|
|
2005-12-31 07:40:49 +03:00
|
|
|
void ro_gui_dialog_prepare_zoom(struct gui_window *g)
|
2005-02-23 02:36:14 +03:00
|
|
|
{
|
2005-12-31 07:40:49 +03:00
|
|
|
char scale_buffer[8];
|
|
|
|
sprintf(scale_buffer, "%.0f", g->option.scale * 100);
|
|
|
|
ro_gui_set_icon_string(dialog_zoom, ICON_ZOOM_VALUE, scale_buffer);
|
2005-02-20 16:19:19 +03:00
|
|
|
|
2005-12-31 07:40:49 +03:00
|
|
|
ro_gui_current_zoom_gui = g;
|
|
|
|
ro_gui_wimp_event_memorise(dialog_zoom);
|
2004-11-03 02:23:07 +03:00
|
|
|
}
|
2004-07-27 19:49:28 +04:00
|
|
|
|
2005-02-23 02:36:14 +03:00
|
|
|
|
2005-12-31 07:40:49 +03:00
|
|
|
bool ro_gui_dialog_openurl_apply(wimp_w w) {
|
|
|
|
url_func_result res;
|
|
|
|
const char *url;
|
|
|
|
char *url2;
|
2004-09-14 03:56:18 +04:00
|
|
|
|
2005-12-31 07:40:49 +03:00
|
|
|
url = ro_gui_get_icon_string(w, ICON_OPENURL_URL);
|
|
|
|
res = url_normalize(url, &url2);
|
|
|
|
if (res == URL_FUNC_OK) {
|
|
|
|
browser_window_create(url2, 0, 0);
|
|
|
|
global_history_add_recent(url2);
|
|
|
|
free(url2);
|
|
|
|
return true;
|
2004-11-03 02:23:07 +03:00
|
|
|
}
|
2005-12-31 07:40:49 +03:00
|
|
|
return false;
|
2004-07-27 19:49:28 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-08-27 02:37:32 +04:00
|
|
|
/**
|
2005-12-31 07:40:49 +03:00
|
|
|
* Prepares the Open URL dialog.
|
2003-08-27 02:37:32 +04:00
|
|
|
*/
|
|
|
|
|
2005-12-31 07:40:49 +03:00
|
|
|
void ro_gui_dialog_prepare_open_url(void)
|
2005-04-08 00:46:22 +04:00
|
|
|
{
|
2005-05-11 02:49:41 +04:00
|
|
|
int suggestions;
|
|
|
|
ro_gui_set_icon_string(dialog_openurl, ICON_OPENURL_URL, "");
|
|
|
|
global_history_get_recent(&suggestions);
|
|
|
|
ro_gui_set_icon_shaded_state(dialog_openurl,
|
|
|
|
ICON_OPENURL_MENU, (suggestions <= 0));
|
2005-12-31 07:40:49 +03:00
|
|
|
ro_gui_wimp_event_memorise(dialog_openurl);
|
2004-08-31 01:03:48 +04:00
|
|
|
}
|