2003-11-08 02:51:13 +03:00
|
|
|
/*
|
|
|
|
* Copyright 2003 Phil Mellor <monkeyson@users.sourceforge.net>
|
2004-02-25 18:12:58 +03:00
|
|
|
* Copyright 2004 James Bursa <bursa@users.sourceforge.net>
|
2003-11-08 02:51:13 +03:00
|
|
|
* Copyright 2003 John M Bell <jmb202@ecs.soton.ac.uk>
|
2004-07-19 02:21:32 +04:00
|
|
|
* Copyright 2004 Andrew Timmins <atimmins@blueyonder.co.uk>
|
2005-04-21 03:22:49 +04:00
|
|
|
* Copyright 2005 Richard Wilson <info@tinct.net>
|
2005-04-22 01:36:23 +04:00
|
|
|
* Copyright 2005 Adrian Lees <adrianl@users.sourceforge.net>
|
2007-08-08 20:16:03 +04:00
|
|
|
*
|
|
|
|
* This file is part of NetSurf, http://www.netsurf-browser.org/
|
|
|
|
*
|
|
|
|
* NetSurf is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; version 2 of the License.
|
|
|
|
*
|
|
|
|
* NetSurf is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2003-11-08 02:51:13 +03:00
|
|
|
*/
|
|
|
|
|
2003-12-12 04:33:38 +03:00
|
|
|
/** \file
|
|
|
|
* Browser window handling (implementation).
|
|
|
|
*/
|
|
|
|
|
2003-12-15 15:58:58 +03:00
|
|
|
#include <assert.h>
|
2005-04-22 01:36:23 +04:00
|
|
|
#include <ctype.h>
|
2008-05-16 13:37:22 +04:00
|
|
|
#include <inttypes.h>
|
2004-06-03 01:27:07 +04:00
|
|
|
#include <math.h>
|
2006-03-24 06:44:37 +03:00
|
|
|
#include <stdio.h>
|
2003-12-28 19:17:31 +03:00
|
|
|
#include <stdbool.h>
|
2004-12-09 13:30:44 +03:00
|
|
|
#include <time.h>
|
2003-11-08 02:51:13 +03:00
|
|
|
#include <string.h>
|
2004-05-07 02:24:37 +04:00
|
|
|
#include "oslib/colourtrans.h"
|
2005-01-03 05:09:20 +03:00
|
|
|
#include "oslib/osbyte.h"
|
2005-04-20 16:24:41 +04:00
|
|
|
#include "oslib/osfile.h"
|
2008-07-27 02:29:15 +04:00
|
|
|
#include "oslib/osspriteop.h"
|
2003-11-08 02:51:13 +03:00
|
|
|
#include "oslib/wimp.h"
|
|
|
|
#include "oslib/wimpspriteop.h"
|
2007-05-31 02:39:54 +04:00
|
|
|
#include "utils/config.h"
|
|
|
|
#include "content/content.h"
|
|
|
|
#include "content/urldb.h"
|
|
|
|
#include "css/css.h"
|
|
|
|
#include "desktop/browser.h"
|
|
|
|
#include "desktop/frames.h"
|
|
|
|
#include "desktop/plotters.h"
|
|
|
|
#include "desktop/textinput.h"
|
|
|
|
#include "desktop/tree.h"
|
|
|
|
#include "desktop/gui.h"
|
|
|
|
#include "render/box.h"
|
|
|
|
#include "render/form.h"
|
|
|
|
#include "riscos/bitmap.h"
|
|
|
|
#include "riscos/buffer.h"
|
|
|
|
#include "riscos/dialog.h"
|
|
|
|
#include "riscos/global_history.h"
|
|
|
|
#include "riscos/gui.h"
|
|
|
|
#include "riscos/gui/status_bar.h"
|
|
|
|
#include "riscos/menus.h"
|
|
|
|
#include "riscos/options.h"
|
2008-03-10 03:51:51 +03:00
|
|
|
#include "riscos/oslib_pre7.h"
|
2007-05-31 02:39:54 +04:00
|
|
|
#include "riscos/save.h"
|
|
|
|
#include "riscos/theme.h"
|
|
|
|
#include "riscos/thumbnail.h"
|
|
|
|
#include "riscos/url_complete.h"
|
|
|
|
#include "riscos/wimp.h"
|
|
|
|
#include "riscos/wimp_event.h"
|
|
|
|
#include "utils/log.h"
|
|
|
|
#include "utils/talloc.h"
|
|
|
|
#include "utils/url.h"
|
|
|
|
#include "utils/utf8.h"
|
|
|
|
#include "utils/utils.h"
|
|
|
|
#include "utils/messages.h"
|
2003-11-08 02:51:13 +03:00
|
|
|
|
2005-04-20 16:24:41 +04:00
|
|
|
#ifndef wimp_KEY_END
|
|
|
|
#define wimp_KEY_END wimp_KEY_COPY
|
|
|
|
#endif
|
|
|
|
|
2006-01-25 20:28:29 +03:00
|
|
|
#define SCROLL_VISIBLE_PADDING 32
|
2004-07-17 17:00:38 +04:00
|
|
|
|
2006-03-24 06:44:37 +03:00
|
|
|
/** Remembers which iconised sprite numbers are in use */
|
|
|
|
static bool iconise_used[64];
|
|
|
|
static int iconise_next = 0;
|
|
|
|
|
2008-06-06 17:58:56 +04:00
|
|
|
/** Whether a pressed mouse button has become a drag */
|
|
|
|
static bool mouse_drag;
|
|
|
|
|
2004-07-17 17:00:38 +04:00
|
|
|
/** List of all browser windows. */
|
|
|
|
static struct gui_window *window_list = 0;
|
2004-08-07 03:45:21 +04:00
|
|
|
/** GUI window which is being redrawn. Valid only during redraw. */
|
2004-07-17 17:00:38 +04:00
|
|
|
struct gui_window *ro_gui_current_redraw_gui;
|
|
|
|
|
2005-03-13 04:23:10 +03:00
|
|
|
static float scale_snap_to[] = {0.10, 0.125, 0.25, 0.333, 0.5, 0.75,
|
|
|
|
1.0,
|
|
|
|
1.5, 2.0, 3.0, 4.0, 6.0, 8.0, 12.0, 16.0};
|
|
|
|
#define SCALE_SNAP_TO_SIZE (sizeof scale_snap_to) / (sizeof(float))
|
2004-07-17 17:00:38 +04:00
|
|
|
|
2006-09-07 02:15:58 +04:00
|
|
|
|
|
|
|
|
|
|
|
/** An entry in ro_gui_pointer_table. */
|
|
|
|
struct ro_gui_pointer_entry {
|
|
|
|
bool wimp_area; /** The pointer is in the Wimp's sprite area. */
|
2007-12-11 05:42:11 +03:00
|
|
|
char sprite_name[16];
|
2006-09-07 02:15:58 +04:00
|
|
|
int xactive;
|
|
|
|
int yactive;
|
|
|
|
};
|
|
|
|
|
|
|
|
/** Map from gui_pointer_shape to pointer sprite data. Must be ordered as
|
|
|
|
* enum gui_pointer_shape. */
|
|
|
|
struct ro_gui_pointer_entry ro_gui_pointer_table[] = {
|
|
|
|
{ true, "ptr_default", 0, 0 },
|
|
|
|
{ false, "ptr_point", 6, 0 },
|
|
|
|
{ false, "ptr_caret", 4, 9 },
|
|
|
|
{ false, "ptr_menu", 6, 4 },
|
|
|
|
{ false, "ptr_ud", 6, 7 },
|
|
|
|
{ false, "ptr_ud", 6, 7 },
|
|
|
|
{ false, "ptr_lr", 7, 6 },
|
|
|
|
{ false, "ptr_lr", 7, 6 },
|
|
|
|
{ false, "ptr_ld", 7, 7 },
|
|
|
|
{ false, "ptr_ld", 7, 7 },
|
|
|
|
{ false, "ptr_rd", 7, 7 },
|
|
|
|
{ false, "ptr_rd", 6, 7 },
|
|
|
|
{ false, "ptr_cross", 7, 7 },
|
|
|
|
{ false, "ptr_move", 8, 0 },
|
|
|
|
{ false, "ptr_wait", 7, 10 },
|
|
|
|
{ false, "ptr_help", 0, 0 },
|
|
|
|
{ false, "ptr_nodrop", 0, 0 },
|
|
|
|
{ false, "ptr_nt_allwd", 10, 10 },
|
|
|
|
{ false, "ptr_progress", 0, 0 },
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2006-12-03 14:38:14 +03:00
|
|
|
static void ro_gui_window_remove_update_boxes(struct gui_window *g);
|
2006-12-30 05:10:46 +03:00
|
|
|
static void gui_window_set_extent(struct gui_window *g, int width, int height);
|
2006-09-06 18:44:42 +04:00
|
|
|
static void ro_gui_window_open(wimp_open *open);
|
|
|
|
static void ro_gui_window_close(wimp_w w);
|
|
|
|
static void ro_gui_window_redraw(wimp_draw *redraw);
|
2006-07-14 01:57:35 +04:00
|
|
|
static bool ro_gui_window_click(wimp_pointer *mouse);
|
|
|
|
static bool ro_gui_window_keypress(wimp_key *key);
|
2005-04-22 01:36:23 +04:00
|
|
|
static void ro_gui_window_launch_url(struct gui_window *g, const char *url);
|
2004-07-17 17:00:38 +04:00
|
|
|
static void ro_gui_window_clone_options(struct browser_window *new_bw,
|
|
|
|
struct browser_window *old_bw);
|
2005-04-15 09:54:44 +04:00
|
|
|
static browser_mouse_state ro_gui_mouse_drag_state(wimp_mouse_state buttons);
|
2008-06-06 17:58:56 +04:00
|
|
|
static bool ro_gui_window_import_text(struct gui_window *g,
|
|
|
|
const char *filename, bool toolbar);
|
2004-07-17 17:00:38 +04:00
|
|
|
|
2006-07-09 21:38:34 +04:00
|
|
|
struct update_box {
|
2006-07-14 01:57:35 +04:00
|
|
|
int x0;
|
|
|
|
int y0;
|
|
|
|
int x1;
|
|
|
|
int y1;
|
|
|
|
bool use_buffer;
|
|
|
|
struct gui_window *g;
|
|
|
|
union content_msg_data data;
|
|
|
|
struct update_box *next;
|
2006-07-09 21:38:34 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
struct update_box *pending_updates;
|
|
|
|
#define MARGIN 4
|
2003-12-12 04:33:38 +03:00
|
|
|
|
2006-09-07 02:15:58 +04:00
|
|
|
|
2003-12-12 04:33:38 +03:00
|
|
|
/**
|
|
|
|
* Create and open a new browser window.
|
2004-05-05 02:23:44 +04:00
|
|
|
*
|
2004-08-07 03:45:21 +04:00
|
|
|
* \param bw browser_window structure to update
|
2004-05-25 14:42:28 +04:00
|
|
|
* \param clone the browser window to clone options from, or NULL for default
|
|
|
|
* \return gui_window, or 0 on error and error reported
|
2003-12-12 04:33:38 +03:00
|
|
|
*/
|
|
|
|
|
2004-07-17 17:00:38 +04:00
|
|
|
struct gui_window *gui_create_browser_window(struct browser_window *bw,
|
2008-08-24 14:31:38 +04:00
|
|
|
struct browser_window *clone, bool new_tab)
|
2003-11-08 02:51:13 +03:00
|
|
|
{
|
2004-05-25 14:42:28 +04:00
|
|
|
int screen_width, screen_height, win_width, win_height, scroll_width;
|
|
|
|
static int window_count = 2;
|
|
|
|
wimp_window window;
|
|
|
|
wimp_window_state state;
|
|
|
|
os_error *error;
|
2004-06-27 18:41:14 +04:00
|
|
|
bool open_centred = true;
|
2004-07-17 17:00:38 +04:00
|
|
|
struct gui_window *g;
|
2006-09-02 19:52:41 +04:00
|
|
|
struct browser_window *top;
|
2003-11-08 02:51:13 +03:00
|
|
|
|
2004-07-17 17:00:38 +04:00
|
|
|
g = malloc(sizeof *g);
|
2004-05-25 14:42:28 +04:00
|
|
|
if (!g) {
|
|
|
|
warn_user("NoMemory", 0);
|
|
|
|
return 0;
|
|
|
|
}
|
2004-07-17 17:00:38 +04:00
|
|
|
g->bw = bw;
|
|
|
|
g->toolbar = 0;
|
2006-11-30 18:30:54 +03:00
|
|
|
g->status_bar = 0;
|
2004-07-17 17:00:38 +04:00
|
|
|
g->old_width = 0;
|
|
|
|
g->old_height = 0;
|
2007-01-03 18:15:54 +03:00
|
|
|
g->update_extent = true;
|
2004-05-25 14:42:28 +04:00
|
|
|
strcpy(g->title, "NetSurf");
|
|
|
|
g->throbber = 0;
|
|
|
|
g->throbtime = 0;
|
2006-03-24 06:44:37 +03:00
|
|
|
g->iconise_icon = -1;
|
2004-05-25 14:42:28 +04:00
|
|
|
|
2006-09-06 18:44:42 +04:00
|
|
|
/* Set the window position */
|
2006-09-02 19:52:41 +04:00
|
|
|
if (bw->parent) {
|
|
|
|
window.visible.x0 = 0;
|
|
|
|
window.visible.x1 = 64;
|
|
|
|
window.visible.y0 = 0;
|
|
|
|
window.visible.y1 = 64;
|
|
|
|
open_centred = false;
|
|
|
|
} else if (clone && clone->window && option_window_size_clone) {
|
2006-11-30 18:30:54 +03:00
|
|
|
for (top = clone; top->parent; top = top->parent);
|
|
|
|
state.w = top->window->window;
|
2004-06-27 18:41:14 +04:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
window.visible.x0 = state.visible.x0;
|
|
|
|
window.visible.x1 = state.visible.x1;
|
|
|
|
window.visible.y0 = state.visible.y0 - 48;
|
|
|
|
window.visible.y1 = state.visible.y1 - 48;
|
|
|
|
open_centred = false;
|
|
|
|
} else {
|
|
|
|
ro_gui_screen_size(&screen_width, &screen_height);
|
2004-06-29 23:08:19 +04:00
|
|
|
|
2006-09-06 18:44:42 +04:00
|
|
|
/* Check if we have a preferred position */
|
2004-07-17 17:00:38 +04:00
|
|
|
if ((option_window_screen_width != 0) &&
|
|
|
|
(option_window_screen_height != 0)) {
|
|
|
|
win_width = (option_window_width * screen_width) /
|
|
|
|
option_window_screen_width;
|
|
|
|
win_height = (option_window_height * screen_height) /
|
|
|
|
option_window_screen_height;
|
|
|
|
window.visible.x0 = (option_window_x * screen_width) /
|
|
|
|
option_window_screen_width;
|
|
|
|
window.visible.y0 = (option_window_y * screen_height) /
|
|
|
|
option_window_screen_height;
|
2004-06-27 18:41:14 +04:00
|
|
|
if (option_window_stagger) {
|
2004-07-17 17:00:38 +04:00
|
|
|
window.visible.y0 += 96 -
|
|
|
|
(48 * (window_count % 5));
|
2004-06-27 18:41:14 +04:00
|
|
|
}
|
|
|
|
open_centred = false;
|
2004-07-17 17:00:38 +04:00
|
|
|
if (win_width < 100)
|
|
|
|
win_width = 100;
|
|
|
|
if (win_height < 100)
|
|
|
|
win_height = 100;
|
2004-06-27 18:41:14 +04:00
|
|
|
} else {
|
2004-07-19 02:21:32 +04:00
|
|
|
|
2004-08-07 03:45:21 +04:00
|
|
|
/* Base how we define the window height/width
|
2006-09-07 02:15:58 +04:00
|
|
|
on the compile time options set */
|
2004-06-27 18:41:14 +04:00
|
|
|
win_width = screen_width * 3 / 4;
|
|
|
|
if (1600 < win_width)
|
|
|
|
win_width = 1600;
|
|
|
|
win_height = win_width * 3 / 4;
|
|
|
|
|
|
|
|
window.visible.x0 = (screen_width - win_width) / 2;
|
2004-07-17 17:00:38 +04:00
|
|
|
window.visible.y0 = ((screen_height - win_height) / 2) +
|
|
|
|
96 - (48 * (window_count % 5));
|
2004-06-27 18:41:14 +04:00
|
|
|
}
|
|
|
|
window.visible.x1 = window.visible.x0 + win_width;
|
|
|
|
window.visible.y1 = window.visible.y0 + win_height;
|
|
|
|
}
|
2004-06-29 23:08:19 +04:00
|
|
|
|
2006-09-06 18:44:42 +04:00
|
|
|
/* General flags for a non-movable, non-resizable, no-title bar window */
|
2004-05-25 14:42:28 +04:00
|
|
|
window.xscroll = 0;
|
|
|
|
window.yscroll = 0;
|
|
|
|
window.next = wimp_TOP;
|
2006-09-02 19:52:41 +04:00
|
|
|
window.flags = wimp_WINDOW_MOVEABLE |
|
2004-05-25 14:42:28 +04:00
|
|
|
wimp_WINDOW_NEW_FORMAT |
|
|
|
|
wimp_WINDOW_VSCROLL |
|
|
|
|
wimp_WINDOW_HSCROLL |
|
|
|
|
wimp_WINDOW_IGNORE_XEXTENT |
|
|
|
|
wimp_WINDOW_IGNORE_YEXTENT |
|
|
|
|
wimp_WINDOW_SCROLL_REPEAT;
|
|
|
|
window.title_fg = wimp_COLOUR_BLACK;
|
|
|
|
window.title_bg = wimp_COLOUR_LIGHT_GREY;
|
|
|
|
window.work_fg = wimp_COLOUR_LIGHT_GREY;
|
|
|
|
window.work_bg = wimp_COLOUR_TRANSPARENT;
|
|
|
|
window.scroll_outer = wimp_COLOUR_DARK_GREY;
|
|
|
|
window.scroll_inner = wimp_COLOUR_MID_LIGHT_GREY;
|
|
|
|
window.highlight_bg = wimp_COLOUR_CREAM;
|
2008-06-08 03:39:09 +04:00
|
|
|
window.extra_flags = wimp_WINDOW_USE_EXTENDED_SCROLL_REQUEST;
|
2004-05-25 14:42:28 +04:00
|
|
|
window.extent.x0 = 0;
|
2007-01-03 18:15:54 +03:00
|
|
|
window.extent.y0 = -(window.visible.y1 - window.visible.y0);
|
2004-06-27 18:41:14 +04:00
|
|
|
window.extent.x1 = window.visible.x1 - window.visible.x0;
|
2004-05-25 14:42:28 +04:00
|
|
|
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;
|
2005-03-19 02:52:38 +03:00
|
|
|
window.xmin = 1;
|
|
|
|
window.ymin = 1;
|
2004-05-25 14:42:28 +04:00
|
|
|
window.title_data.indirected_text.text = g->title;
|
|
|
|
window.title_data.indirected_text.validation = (char *) -1;
|
|
|
|
window.title_data.indirected_text.size = 255;
|
|
|
|
window.icon_count = 0;
|
2006-09-02 19:52:41 +04:00
|
|
|
|
|
|
|
/* Add in flags for our window type */
|
|
|
|
switch (bw->browser_window_type) {
|
|
|
|
case BROWSER_WINDOW_FRAMESET:
|
|
|
|
window.flags &= ~(wimp_WINDOW_VSCROLL |
|
|
|
|
wimp_WINDOW_HSCROLL);
|
|
|
|
window.title_fg = 0xff;
|
|
|
|
break;
|
|
|
|
case BROWSER_WINDOW_IFRAME:
|
2006-09-05 04:24:17 +04:00
|
|
|
window.flags |= wimp_WINDOW_NO_BOUNDS;
|
|
|
|
case BROWSER_WINDOW_FRAME:
|
2006-09-02 19:52:41 +04:00
|
|
|
if (bw->scrolling == SCROLLING_NO)
|
|
|
|
window.flags &= ~(wimp_WINDOW_VSCROLL |
|
|
|
|
wimp_WINDOW_HSCROLL);
|
2007-01-03 18:15:54 +03:00
|
|
|
if (bw->scrolling == SCROLLING_AUTO)
|
|
|
|
window.flags &= ~wimp_WINDOW_HSCROLL;
|
2006-09-02 19:52:41 +04:00
|
|
|
if (!bw->border)
|
|
|
|
window.title_fg = 0xff;
|
|
|
|
else {
|
|
|
|
/* set the correct border colour */
|
|
|
|
unsigned int col;
|
|
|
|
col = bw->border_colour & 0xffffff;
|
|
|
|
sprintf(g->validation, "C%.6x", col);
|
2006-09-07 02:15:58 +04:00
|
|
|
window.extra_flags |= wimp_WINDOW_USE_TITLE_VALIDATION_STRING;
|
2006-09-02 19:52:41 +04:00
|
|
|
window.title_data.indirected_text.validation = g->validation;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case BROWSER_WINDOW_NORMAL:
|
|
|
|
window.flags |= wimp_WINDOW_SIZE_ICON |
|
|
|
|
wimp_WINDOW_BACK_ICON |
|
|
|
|
wimp_WINDOW_CLOSE_ICON |
|
|
|
|
wimp_WINDOW_TITLE_ICON |
|
2006-09-07 02:15:58 +04:00
|
|
|
wimp_WINDOW_TOGGLE_ICON;
|
2006-09-02 19:52:41 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2004-08-31 01:03:48 +04:00
|
|
|
if (open_centred) {
|
2005-04-08 00:46:22 +04:00
|
|
|
scroll_width = ro_get_vscroll_width(NULL);
|
2004-08-31 01:03:48 +04:00
|
|
|
window.visible.x0 -= scroll_width;
|
|
|
|
}
|
2004-05-25 14:42:28 +04:00
|
|
|
|
|
|
|
error = xwimp_create_window(&window, &g->window);
|
|
|
|
if (error) {
|
|
|
|
LOG(("xwimp_create_window: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess));
|
|
|
|
warn_user("WimpError", error->errmess);
|
|
|
|
free(g);
|
|
|
|
return 0;
|
|
|
|
}
|
2004-06-29 23:08:19 +04:00
|
|
|
|
2006-09-06 18:44:42 +04:00
|
|
|
/* Link into window list */
|
2004-07-17 17:00:38 +04:00
|
|
|
g->prev = 0;
|
2004-05-05 02:23:44 +04:00
|
|
|
g->next = window_list;
|
2004-07-18 21:38:01 +04:00
|
|
|
if (window_list)
|
|
|
|
window_list->prev = g;
|
2004-05-05 02:23:44 +04:00
|
|
|
window_list = g;
|
2004-05-25 14:42:28 +04:00
|
|
|
window_count++;
|
2004-05-05 02:23:44 +04:00
|
|
|
|
2006-11-30 18:30:54 +03:00
|
|
|
/* Add in a toolbar and status bar */
|
2006-09-02 19:52:41 +04:00
|
|
|
if (bw->browser_window_type == BROWSER_WINDOW_NORMAL) {
|
2006-11-30 18:30:54 +03:00
|
|
|
g->status_bar = ro_gui_status_bar_create(g->window, option_toolbar_status_width);
|
2006-09-02 19:52:41 +04:00
|
|
|
g->toolbar = ro_gui_theme_create_toolbar(NULL, THEME_BROWSER_TOOLBAR);
|
|
|
|
ro_gui_theme_attach_toolbar(g->toolbar, g->window);
|
|
|
|
} else {
|
|
|
|
g->toolbar = NULL;
|
|
|
|
}
|
2004-08-31 01:03:48 +04:00
|
|
|
|
2006-09-06 18:44:42 +04:00
|
|
|
/* Set the window options */
|
2004-05-25 14:42:28 +04:00
|
|
|
bw->window = g;
|
2004-07-17 17:00:38 +04:00
|
|
|
ro_gui_window_clone_options(bw, clone);
|
2004-08-31 01:03:48 +04:00
|
|
|
ro_gui_prepare_navigate(g);
|
2003-12-12 04:33:38 +03:00
|
|
|
|
2006-09-06 18:44:42 +04:00
|
|
|
/* Register event handlers */
|
|
|
|
ro_gui_wimp_event_set_user_data(g->window, g);
|
|
|
|
ro_gui_wimp_event_register_open_window(g->window, ro_gui_window_open);
|
|
|
|
ro_gui_wimp_event_register_close_window(g->window, ro_gui_window_close);
|
|
|
|
ro_gui_wimp_event_register_redraw_window(g->window, ro_gui_window_redraw);
|
|
|
|
ro_gui_wimp_event_register_keypress(g->window, ro_gui_window_keypress);
|
|
|
|
if (g->toolbar)
|
|
|
|
ro_gui_wimp_event_register_keypress(g->toolbar->toolbar_handle,
|
|
|
|
ro_gui_window_keypress);
|
|
|
|
ro_gui_wimp_event_register_mouse_click(g->window, ro_gui_window_click);
|
|
|
|
|
|
|
|
/* Open the window at the top of the stack */
|
2004-05-23 16:22:05 +04:00
|
|
|
state.w = g->window;
|
2004-05-25 14:42:28 +04:00
|
|
|
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 g;
|
|
|
|
}
|
2007-01-03 18:15:54 +03:00
|
|
|
|
2006-09-05 05:09:05 +04:00
|
|
|
state.next = wimp_TOP;
|
2006-09-02 19:52:41 +04:00
|
|
|
if (bw->parent) {
|
2006-09-07 02:15:58 +04:00
|
|
|
top = browser_window_owner(bw);
|
2006-09-02 19:52:41 +04:00
|
|
|
error = xwimp_open_window_nested((wimp_open *)&state, top->window->window,
|
|
|
|
wimp_CHILD_LINKS_PARENT_WORK_AREA
|
|
|
|
<< wimp_CHILD_XORIGIN_SHIFT |
|
|
|
|
wimp_CHILD_LINKS_PARENT_WORK_AREA
|
|
|
|
<< wimp_CHILD_YORIGIN_SHIFT);
|
|
|
|
}
|
2007-01-03 18:15:54 +03:00
|
|
|
|
2006-09-06 18:44:42 +04:00
|
|
|
ro_gui_window_open((wimp_open*)&state);
|
2004-08-31 01:03:48 +04:00
|
|
|
|
2006-09-06 18:44:42 +04:00
|
|
|
/* Claim the caret for top-level windows */
|
2006-09-05 21:34:30 +04:00
|
|
|
if (bw->browser_window_type == BROWSER_WINDOW_NORMAL) {
|
|
|
|
if (g->toolbar && g->toolbar->display_url) {
|
|
|
|
error = xwimp_set_caret_position(
|
|
|
|
g->toolbar->toolbar_handle,
|
|
|
|
ICON_TOOLBAR_URL, -1, -1, -1, 0);
|
|
|
|
ro_gui_url_complete_start(g);
|
|
|
|
if (error) {
|
|
|
|
LOG(("xwimp_set_caret_position: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess));
|
|
|
|
warn_user("WimpError", error->errmess);
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
gui_window_place_caret(g, -100, -100, 0);
|
|
|
|
}
|
2004-05-25 14:42:28 +04:00
|
|
|
return g;
|
2003-11-08 02:51:13 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-07-17 17:00:38 +04:00
|
|
|
/**
|
|
|
|
* Close a browser window and free any related resources.
|
|
|
|
*
|
|
|
|
* \param g gui_window to destroy
|
|
|
|
*/
|
|
|
|
|
|
|
|
void gui_window_destroy(struct gui_window *g)
|
|
|
|
{
|
|
|
|
os_error *error;
|
2006-12-03 14:38:14 +03:00
|
|
|
wimp_w w;
|
2004-07-17 17:00:38 +04:00
|
|
|
|
|
|
|
assert(g);
|
|
|
|
|
2006-09-05 04:53:17 +04:00
|
|
|
/* stop any tracking */
|
|
|
|
if (gui_track_gui_window == g) {
|
|
|
|
gui_track_gui_window = NULL;
|
|
|
|
gui_current_drag_type = GUI_DRAG_NONE;
|
|
|
|
}
|
|
|
|
|
2004-07-17 17:00:38 +04:00
|
|
|
/* remove from list */
|
|
|
|
if (g->prev)
|
|
|
|
g->prev->next = g->next;
|
|
|
|
else
|
|
|
|
window_list = g->next;
|
|
|
|
if (g->next)
|
|
|
|
g->next->prev = g->prev;
|
|
|
|
|
2006-09-07 02:15:58 +04:00
|
|
|
/* destroy toolbar */
|
2006-09-02 19:52:41 +04:00
|
|
|
if (g->toolbar)
|
|
|
|
ro_gui_theme_destroy_toolbar(g->toolbar);
|
2006-12-03 14:38:14 +03:00
|
|
|
if (g->status_bar)
|
|
|
|
ro_gui_status_bar_destroy(g->status_bar);
|
|
|
|
|
|
|
|
w = g->window;
|
|
|
|
ro_gui_url_complete_close(NULL, 0);
|
|
|
|
ro_gui_dialog_close_persistent(w);
|
|
|
|
if (current_menu_window == w)
|
|
|
|
ro_gui_menu_closed(true);
|
|
|
|
ro_gui_window_remove_update_boxes(g);
|
2004-07-17 17:00:38 +04:00
|
|
|
|
|
|
|
/* delete window */
|
2006-12-03 14:38:14 +03:00
|
|
|
error = xwimp_delete_window(w);
|
2004-07-17 17:00:38 +04:00
|
|
|
if (error) {
|
|
|
|
LOG(("xwimp_delete_window: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess));
|
|
|
|
warn_user("WimpError", error->errmess);
|
|
|
|
}
|
2006-12-03 14:38:14 +03:00
|
|
|
ro_gui_wimp_event_finalise(w);
|
2004-07-17 17:00:38 +04:00
|
|
|
|
|
|
|
free(g);
|
2003-11-08 02:51:13 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-07-17 17:00:38 +04:00
|
|
|
/**
|
|
|
|
* Set the title of a browser window.
|
|
|
|
*
|
2004-08-07 03:45:21 +04:00
|
|
|
* \param g gui_window to update
|
2004-07-17 17:00:38 +04:00
|
|
|
* \param title new window title, copied
|
|
|
|
*/
|
|
|
|
|
|
|
|
void gui_window_set_title(struct gui_window *g, const char *title)
|
2003-11-08 02:51:13 +03:00
|
|
|
{
|
2005-03-13 04:23:10 +03:00
|
|
|
int scale_disp;
|
2004-07-17 17:00:38 +04:00
|
|
|
|
|
|
|
assert(g);
|
|
|
|
assert(title);
|
2005-04-15 22:00:21 +04:00
|
|
|
|
2007-08-07 07:55:18 +04:00
|
|
|
if (g->bw->scale != 1.0) {
|
|
|
|
scale_disp = g->bw->scale * 100;
|
|
|
|
if (ABS((float)scale_disp - g->bw->scale * 100) >= 0.05)
|
|
|
|
snprintf(g->title, sizeof g->title, "%s (%.1f%%)",
|
|
|
|
title, g->bw->scale * 100);
|
2005-03-13 04:23:10 +03:00
|
|
|
else
|
2007-08-07 07:55:18 +04:00
|
|
|
snprintf(g->title, sizeof g->title, "%s (%i%%)",
|
|
|
|
title, scale_disp);
|
2005-03-13 04:23:10 +03:00
|
|
|
} else {
|
|
|
|
strncpy(g->title, title, sizeof g->title);
|
|
|
|
}
|
2005-07-24 07:13:51 +04:00
|
|
|
|
2006-09-02 19:52:41 +04:00
|
|
|
/* only top-level parents have titlebars */
|
|
|
|
if (!g->bw->parent)
|
|
|
|
ro_gui_set_window_title(g->window, g->title);
|
2003-11-08 02:51:13 +03:00
|
|
|
}
|
|
|
|
|
2004-07-17 17:00:38 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Force a redraw of part of the contents of a browser window.
|
|
|
|
*
|
|
|
|
* \param g gui_window to redraw
|
|
|
|
* \param x0 rectangle to redraw
|
|
|
|
* \param y0 rectangle to redraw
|
|
|
|
* \param x1 rectangle to redraw
|
|
|
|
* \param y1 rectangle to redraw
|
|
|
|
*/
|
|
|
|
|
|
|
|
void gui_window_redraw(struct gui_window *g, int x0, int y0, int x1, int y1)
|
2003-11-08 02:51:13 +03:00
|
|
|
{
|
2004-07-17 17:00:38 +04:00
|
|
|
os_error *error;
|
2003-11-08 02:51:13 +03:00
|
|
|
|
2004-07-17 17:00:38 +04:00
|
|
|
assert(g);
|
|
|
|
|
|
|
|
error = xwimp_force_redraw(g->window, x0 * 2, -y1 * 2, x1 * 2, -y0 * 2);
|
|
|
|
if (error) {
|
|
|
|
LOG(("xwimp_force_redraw: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess));
|
|
|
|
warn_user("WimpError", error->errmess);
|
|
|
|
}
|
2003-11-08 02:51:13 +03:00
|
|
|
}
|
|
|
|
|
2004-07-17 17:00:38 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Force a redraw of the entire contents of a browser window.
|
|
|
|
*
|
|
|
|
* \param g gui_window to redraw
|
|
|
|
*/
|
|
|
|
void gui_window_redraw_window(struct gui_window *g)
|
2003-11-08 02:51:13 +03:00
|
|
|
{
|
2007-03-27 01:09:25 +04:00
|
|
|
wimp_window_info info;
|
|
|
|
os_error *error;
|
2007-03-04 00:57:24 +03:00
|
|
|
|
|
|
|
assert(g);
|
|
|
|
info.w = g->window;
|
2007-03-27 01:09:25 +04:00
|
|
|
error = xwimp_get_window_info_header_only(&info);
|
|
|
|
if (error) {
|
|
|
|
LOG(("xwimp_get_window_info_header_only: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess));
|
|
|
|
warn_user("WimpError", error->errmess);
|
|
|
|
return;
|
|
|
|
}
|
2007-03-04 00:57:24 +03:00
|
|
|
error = xwimp_force_redraw(g->window, info.extent.x0, info.extent.y0,
|
|
|
|
info.extent.x1, info.extent.y1);
|
|
|
|
if (error) {
|
|
|
|
LOG(("xwimp_force_redraw: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess));
|
|
|
|
warn_user("WimpError", error->errmess);
|
|
|
|
}
|
2003-11-08 02:51:13 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-07-17 17:00:38 +04:00
|
|
|
/**
|
2006-09-07 02:15:58 +04:00
|
|
|
* Redraw an area of a window.
|
|
|
|
*
|
|
|
|
* \param g gui_window
|
|
|
|
* \param data content_msg_data union with filled in redraw data
|
2004-07-17 17:00:38 +04:00
|
|
|
*/
|
|
|
|
|
2006-09-07 02:15:58 +04:00
|
|
|
void gui_window_update_box(struct gui_window *g,
|
|
|
|
const union content_msg_data *data)
|
2004-07-17 17:00:38 +04:00
|
|
|
{
|
|
|
|
struct content *c = g->bw->current_content;
|
2006-09-07 02:15:58 +04:00
|
|
|
bool use_buffer;
|
|
|
|
int x0, y0, x1, y1;
|
|
|
|
struct update_box *cur;
|
2005-03-14 16:58:43 +03:00
|
|
|
|
2006-09-07 02:15:58 +04:00
|
|
|
if (!c)
|
2006-09-02 19:52:41 +04:00
|
|
|
return;
|
2004-07-21 18:19:21 +04:00
|
|
|
|
2007-08-07 07:55:18 +04:00
|
|
|
x0 = floorf(data->redraw.x * 2 * g->bw->scale);
|
|
|
|
y0 = -ceilf((data->redraw.y + data->redraw.height) * 2 * g->bw->scale);
|
|
|
|
x1 = ceilf((data->redraw.x + data->redraw.width) * 2 * g->bw->scale) + 1;
|
|
|
|
y1 = -floorf(data->redraw.y * 2 * g->bw->scale) + 1;
|
2006-09-07 02:15:58 +04:00
|
|
|
use_buffer = (data->redraw.full_redraw) &&
|
|
|
|
(g->option.buffer_everything || g->option.buffer_animations);
|
2006-07-14 01:57:35 +04:00
|
|
|
|
2006-09-07 02:15:58 +04:00
|
|
|
/* try to optimise buffered redraws */
|
|
|
|
if (use_buffer) {
|
|
|
|
for (cur = pending_updates; cur != NULL; cur = cur->next) {
|
|
|
|
if ((cur->g != g) || (!cur->use_buffer))
|
|
|
|
continue;
|
|
|
|
if ((((cur->x0 - x1) < MARGIN) || ((cur->x1 - x0) < MARGIN)) &&
|
|
|
|
(((cur->y0 - y1) < MARGIN) || ((cur->y1 - y0) < MARGIN))) {
|
|
|
|
cur->x0 = min(cur->x0, x0);
|
|
|
|
cur->y0 = min(cur->y0, y0);
|
|
|
|
cur->x1 = max(cur->x1, x1);
|
|
|
|
cur->y1 = max(cur->y1, y1);
|
|
|
|
return;
|
|
|
|
}
|
2004-05-07 04:06:26 +04:00
|
|
|
|
2006-09-07 02:15:58 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
cur = malloc(sizeof(struct update_box));
|
|
|
|
if (!cur) {
|
|
|
|
LOG(("No memory for malloc."));
|
|
|
|
warn_user("NoMemory", 0);
|
2004-07-17 17:00:38 +04:00
|
|
|
return;
|
|
|
|
}
|
2006-09-07 02:15:58 +04:00
|
|
|
cur->x0 = x0;
|
|
|
|
cur->y0 = y0;
|
|
|
|
cur->x1 = x1;
|
|
|
|
cur->y1 = y1;
|
|
|
|
cur->next = pending_updates;
|
|
|
|
pending_updates = cur;
|
|
|
|
cur->g = g;
|
|
|
|
cur->use_buffer = use_buffer;
|
|
|
|
cur->data = *data;
|
|
|
|
}
|
2005-03-14 16:58:43 +03:00
|
|
|
|
|
|
|
|
2006-09-07 02:15:58 +04:00
|
|
|
/**
|
|
|
|
* Get the scroll position of a browser window.
|
|
|
|
*
|
|
|
|
* \param g gui_window
|
|
|
|
* \param sx receives x ordinate of point at top-left of window
|
|
|
|
* \param sy receives y ordinate of point at top-left of window
|
|
|
|
* \return true iff successful
|
|
|
|
*/
|
2004-05-07 04:06:26 +04:00
|
|
|
|
2006-09-07 02:15:58 +04:00
|
|
|
bool gui_window_get_scroll(struct gui_window *g, int *sx, int *sy)
|
|
|
|
{
|
|
|
|
wimp_window_state state;
|
|
|
|
os_error *error;
|
|
|
|
int toolbar_height = 0;
|
2005-03-14 16:58:43 +03:00
|
|
|
|
2006-09-07 02:15:58 +04:00
|
|
|
assert(g);
|
|
|
|
|
|
|
|
state.w = g->window;
|
|
|
|
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 false;
|
2004-07-17 17:00:38 +04:00
|
|
|
}
|
2006-09-07 02:15:58 +04:00
|
|
|
|
|
|
|
if (g->toolbar)
|
|
|
|
toolbar_height = ro_gui_theme_toolbar_full_height(g->toolbar);
|
2007-08-07 07:55:18 +04:00
|
|
|
*sx = state.xscroll / (2 * g->bw->scale);
|
|
|
|
*sy = -(state.yscroll - toolbar_height) / (2 * g->bw->scale);
|
2006-09-07 02:15:58 +04:00
|
|
|
return true;
|
2003-11-08 02:51:13 +03:00
|
|
|
}
|
|
|
|
|
2004-03-21 16:55:51 +03:00
|
|
|
|
|
|
|
/**
|
2006-09-07 02:15:58 +04:00
|
|
|
* Set the scroll position of a browser window.
|
|
|
|
*
|
|
|
|
* \param g gui_window to scroll
|
|
|
|
* \param sx point to place at top-left of window
|
|
|
|
* \param sy point to place at top-left of window
|
2004-03-21 16:55:51 +03:00
|
|
|
*/
|
2006-09-07 02:15:58 +04:00
|
|
|
|
|
|
|
void gui_window_set_scroll(struct gui_window *g, int sx, int sy)
|
|
|
|
{
|
|
|
|
wimp_window_state state;
|
2004-07-17 17:00:38 +04:00
|
|
|
os_error *error;
|
2006-07-14 01:57:35 +04:00
|
|
|
|
2006-09-07 02:15:58 +04:00
|
|
|
assert(g);
|
2004-07-17 17:00:38 +04:00
|
|
|
|
|
|
|
state.w = g->window;
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2007-08-07 07:55:18 +04:00
|
|
|
state.xscroll = sx * 2 * g->bw->scale;
|
|
|
|
state.yscroll = -sy * 2 * g->bw->scale;
|
2004-07-17 17:00:38 +04:00
|
|
|
if (g->toolbar)
|
2005-03-20 17:57:19 +03:00
|
|
|
state.yscroll += ro_gui_theme_toolbar_full_height(g->toolbar);
|
2007-01-03 18:15:54 +03:00
|
|
|
ro_gui_window_open((wimp_open *)&state);
|
2003-11-08 02:51:13 +03:00
|
|
|
}
|
|
|
|
|
2004-07-17 17:00:38 +04:00
|
|
|
|
2006-01-25 20:28:29 +03:00
|
|
|
/**
|
|
|
|
* Scrolls the specified area of a browser window into view.
|
|
|
|
*
|
|
|
|
* \param g gui_window to scroll
|
|
|
|
* \param x0 left point to ensure visible
|
2006-09-02 19:52:41 +04:00
|
|
|
* \param y0 bottom point to ensure visible
|
|
|
|
* \param x1 right point to ensure visible
|
|
|
|
* \param y1 top point to ensure visible
|
2006-01-25 20:28:29 +03:00
|
|
|
*/
|
|
|
|
void gui_window_scroll_visible(struct gui_window *g, int x0, int y0, int x1, int y1)
|
|
|
|
{
|
|
|
|
wimp_window_state state;
|
|
|
|
os_error *error;
|
|
|
|
int cx0, cy0, width, height;
|
|
|
|
int padding_available;
|
|
|
|
int toolbar_height = 0;
|
|
|
|
int correction;
|
|
|
|
|
|
|
|
assert(g);
|
|
|
|
|
|
|
|
state.w = g->window;
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (g->toolbar)
|
2006-09-02 19:52:41 +04:00
|
|
|
toolbar_height = ro_gui_theme_toolbar_full_height(g->toolbar);
|
2006-03-10 14:28:16 +03:00
|
|
|
|
2007-08-07 07:55:18 +04:00
|
|
|
x0 = x0 * 2 * g->bw->scale;
|
|
|
|
y0 = y0 * 2 * g->bw->scale;
|
|
|
|
x1 = x1 * 2 * g->bw->scale;
|
|
|
|
y1 = y1 * 2 * g->bw->scale;
|
2006-01-25 20:28:29 +03:00
|
|
|
|
|
|
|
cx0 = state.xscroll;
|
|
|
|
cy0 = -state.yscroll + toolbar_height;
|
|
|
|
width = state.visible.x1 - state.visible.x0;
|
|
|
|
height = state.visible.y1 - state.visible.y0 - toolbar_height;
|
2006-03-10 14:28:16 +03:00
|
|
|
|
2006-01-25 20:28:29 +03:00
|
|
|
/* make sure we're visible */
|
|
|
|
correction = (x1 - cx0 - width);
|
|
|
|
if (correction > 0)
|
|
|
|
cx0 += correction;
|
|
|
|
correction = (y1 - cy0 - height);
|
|
|
|
if (correction > 0)
|
|
|
|
cy0 += correction;
|
|
|
|
if (x0 < cx0)
|
|
|
|
cx0 = x0;
|
|
|
|
if (y0 < cy0)
|
|
|
|
cy0 = y0;
|
|
|
|
|
|
|
|
/* try to give a SCROLL_VISIBLE_PADDING border of space around us */
|
|
|
|
padding_available = (width - x1 + x0) / 2;
|
|
|
|
if (padding_available > 0) {
|
2006-09-02 19:52:41 +04:00
|
|
|
if (padding_available > SCROLL_VISIBLE_PADDING)
|
|
|
|
padding_available = SCROLL_VISIBLE_PADDING;
|
|
|
|
correction = (cx0 + width - x1);
|
|
|
|
if (correction < padding_available)
|
|
|
|
cx0 += padding_available;
|
|
|
|
correction = (x0 - cx0);
|
|
|
|
if (correction < padding_available)
|
|
|
|
cx0 -= padding_available;
|
2006-01-25 20:28:29 +03:00
|
|
|
}
|
|
|
|
padding_available = (height - y1 + y0) / 2;
|
|
|
|
if (padding_available > 0) {
|
2006-09-02 19:52:41 +04:00
|
|
|
if (padding_available > SCROLL_VISIBLE_PADDING)
|
|
|
|
padding_available = SCROLL_VISIBLE_PADDING;
|
|
|
|
correction = (cy0 + height - y1);
|
|
|
|
if (correction < padding_available)
|
|
|
|
cy0 += padding_available;
|
|
|
|
correction = (y0 - cy0);
|
|
|
|
if (correction < padding_available)
|
|
|
|
cy0 -= padding_available;
|
2006-01-25 20:28:29 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
state.xscroll = cx0;
|
|
|
|
state.yscroll = -cy0 + toolbar_height;
|
2006-09-06 18:44:42 +04:00
|
|
|
ro_gui_window_open((wimp_open *)&state);
|
2006-01-25 20:28:29 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-07-17 17:00:38 +04:00
|
|
|
/**
|
2006-09-02 19:52:41 +04:00
|
|
|
* Opens a frame at a specified position.
|
|
|
|
*
|
|
|
|
* \param g child gui_window to open
|
|
|
|
* \param x0 left point to open at
|
|
|
|
* \param y0 bottom point to open at
|
|
|
|
* \param x1 right point to open at
|
|
|
|
* \param y1 top point to open at
|
|
|
|
*/
|
|
|
|
void gui_window_position_frame(struct gui_window *g, int x0, int y0, int x1, int y1)
|
|
|
|
{
|
|
|
|
wimp_window_state state;
|
|
|
|
os_error *error;
|
|
|
|
int px0, py1;
|
|
|
|
struct browser_window *bw;
|
|
|
|
struct browser_window *parent;
|
|
|
|
struct browser_window *top;
|
2007-01-03 18:15:54 +03:00
|
|
|
float scale = 1.0;
|
2006-09-02 19:52:41 +04:00
|
|
|
|
|
|
|
assert(g);
|
|
|
|
bw = g->bw;
|
|
|
|
assert(bw);
|
|
|
|
parent = bw->parent;
|
|
|
|
assert(parent);
|
|
|
|
top = browser_window_owner(bw);
|
2006-09-07 02:15:58 +04:00
|
|
|
|
2006-09-02 19:52:41 +04:00
|
|
|
/* store position for children */
|
|
|
|
if (parent->browser_window_type == BROWSER_WINDOW_IFRAME) {
|
2006-09-05 04:24:17 +04:00
|
|
|
bw->x0 = x0;
|
|
|
|
bw->y0 = y0;
|
|
|
|
bw->x1 = x1;
|
|
|
|
bw->y1 = y1;
|
2006-09-02 19:52:41 +04:00
|
|
|
} else {
|
2006-09-05 04:24:17 +04:00
|
|
|
bw->x0 = x0 = parent->x0 + x0;
|
|
|
|
bw->y0 = y0 = parent->y0 + y0;
|
|
|
|
bw->x1 = x1 = parent->x0 + x1;
|
|
|
|
bw->y1 = y1 = parent->y0 + y1;
|
2006-09-02 19:52:41 +04:00
|
|
|
}
|
2007-03-27 01:09:25 +04:00
|
|
|
|
2007-01-03 18:15:54 +03:00
|
|
|
/* only scale iframe locations */
|
|
|
|
if (bw->browser_window_type == BROWSER_WINDOW_IFRAME)
|
2007-08-07 07:55:18 +04:00
|
|
|
scale = g->bw->scale;
|
2006-09-02 19:52:41 +04:00
|
|
|
|
|
|
|
/* get the position of the top level window */
|
|
|
|
state.w = top->window->window;
|
|
|
|
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;
|
|
|
|
}
|
2006-09-09 00:50:07 +04:00
|
|
|
px0 = state.visible.x0 - state.xscroll;
|
2006-09-09 02:36:09 +04:00
|
|
|
py1 = state.visible.y1 - state.yscroll;
|
2006-09-02 19:52:41 +04:00
|
|
|
|
|
|
|
/* get our current window state */
|
|
|
|
state.w = g->window;
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
if (!g->bw->border) {
|
|
|
|
x0 -= 1;
|
|
|
|
y0 -= 1;
|
|
|
|
x1 += 1;
|
|
|
|
y1 += 1;
|
|
|
|
}
|
|
|
|
|
2007-01-03 18:15:54 +03:00
|
|
|
x1 = x1 * 2 * scale;
|
|
|
|
y1 = y1 * 2 * scale;
|
2006-09-02 19:52:41 +04:00
|
|
|
|
|
|
|
/* scrollbars must go inside */
|
|
|
|
if (state.flags & wimp_WINDOW_HSCROLL) {
|
|
|
|
y1 -= ro_get_hscroll_height(NULL);
|
|
|
|
if (g->bw->border)
|
|
|
|
y1 += 2;
|
|
|
|
}
|
|
|
|
if (state.flags & wimp_WINDOW_VSCROLL) {
|
|
|
|
x1 -= ro_get_vscroll_width(NULL);
|
|
|
|
if (g->bw->border)
|
|
|
|
x1 += 2;
|
|
|
|
}
|
2007-01-03 18:15:54 +03:00
|
|
|
state.visible.x0 = px0 + x0 * 2 * scale;
|
2006-09-02 19:52:41 +04:00
|
|
|
state.visible.y0 = py1 - y1;
|
|
|
|
state.visible.x1 = px0 + x1;
|
2007-01-03 18:15:54 +03:00
|
|
|
state.visible.y1 = py1 - y0 * 2 * scale;
|
|
|
|
g->update_extent = true;
|
2006-09-06 18:44:42 +04:00
|
|
|
ro_gui_window_open((wimp_open *)&state);
|
2006-09-02 19:52:41 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2006-09-07 02:15:58 +04:00
|
|
|
* Find the current dimensions of a browser window's content area.
|
2006-09-02 19:52:41 +04:00
|
|
|
*
|
2006-09-07 02:15:58 +04:00
|
|
|
* \param g gui_window to measure
|
|
|
|
* \param width receives width of window
|
|
|
|
* \param height receives height of window
|
|
|
|
* \param scaled whether to return scaled values
|
2006-09-02 19:52:41 +04:00
|
|
|
*/
|
|
|
|
|
2006-09-07 02:15:58 +04:00
|
|
|
void gui_window_get_dimensions(struct gui_window *g, int *width, int *height, bool scaled)
|
2006-09-02 19:52:41 +04:00
|
|
|
{
|
2007-01-03 18:15:54 +03:00
|
|
|
/* use the cached window sizes */
|
|
|
|
*width = g->old_width / 2;
|
|
|
|
*height = g->old_height / 2;
|
2006-09-07 02:15:58 +04:00
|
|
|
if (scaled) {
|
2007-08-07 07:55:18 +04:00
|
|
|
*width /= g->bw->scale;
|
|
|
|
*height /= g->bw->scale;
|
2006-09-07 02:15:58 +04:00
|
|
|
}
|
2006-09-02 19:52:41 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2006-09-07 02:15:58 +04:00
|
|
|
* Update the extent of the inside of a browser window to that of the current content.
|
2004-07-17 17:00:38 +04:00
|
|
|
*
|
2006-09-07 02:15:58 +04:00
|
|
|
* \param g gui_window to update the extent of
|
2004-07-17 17:00:38 +04:00
|
|
|
*/
|
|
|
|
|
2006-09-07 02:15:58 +04:00
|
|
|
void gui_window_update_extent(struct gui_window *g)
|
2004-07-17 17:00:38 +04:00
|
|
|
{
|
|
|
|
os_error *error;
|
2006-09-07 02:15:58 +04:00
|
|
|
wimp_window_state state;
|
|
|
|
bool update;
|
|
|
|
unsigned int flags;
|
|
|
|
int scroll = 0;
|
|
|
|
|
|
|
|
assert(g);
|
2004-07-17 17:00:38 +04:00
|
|
|
|
|
|
|
state.w = g->window;
|
|
|
|
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);
|
2006-09-07 02:15:58 +04:00
|
|
|
return;
|
2004-07-17 17:00:38 +04:00
|
|
|
}
|
2003-11-08 02:51:13 +03:00
|
|
|
|
2006-09-07 02:15:58 +04:00
|
|
|
/* scroll on toolbar height change */
|
2007-01-03 18:15:54 +03:00
|
|
|
if (g->toolbar) {
|
|
|
|
scroll = ro_gui_theme_height_change(g->toolbar);
|
|
|
|
state.yscroll -= scroll;
|
|
|
|
}
|
2005-07-02 22:17:51 +04:00
|
|
|
|
2006-09-07 02:15:58 +04:00
|
|
|
/* only allow a further reformat if we've gained/lost scrollbars */
|
|
|
|
flags = state.flags & (wimp_WINDOW_HSCROLL | wimp_WINDOW_VSCROLL);
|
2007-08-07 07:55:18 +04:00
|
|
|
update = g->bw->reformat_pending;
|
2007-01-03 18:15:54 +03:00
|
|
|
g->update_extent = true;
|
2006-09-07 02:15:58 +04:00
|
|
|
ro_gui_window_open((wimp_open *)&state);
|
2005-07-02 22:17:51 +04:00
|
|
|
|
|
|
|
state.w = g->window;
|
|
|
|
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);
|
2006-09-07 02:15:58 +04:00
|
|
|
return;
|
2005-07-02 22:17:51 +04:00
|
|
|
}
|
2006-09-07 02:15:58 +04:00
|
|
|
if (flags == (state.flags & (wimp_WINDOW_HSCROLL | wimp_WINDOW_VSCROLL)))
|
2007-08-07 07:55:18 +04:00
|
|
|
g->bw->reformat_pending = update;
|
2006-09-07 02:15:58 +04:00
|
|
|
if ((scroll != 0) && (g->bw->children))
|
|
|
|
browser_window_recalculate_frameset(g->bw);
|
2005-07-02 22:17:51 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-07-17 17:00:38 +04:00
|
|
|
/**
|
2006-09-07 02:15:58 +04:00
|
|
|
* Set the status bar of a browser window.
|
2004-07-17 17:00:38 +04:00
|
|
|
*
|
2006-09-07 02:15:58 +04:00
|
|
|
* \param g gui_window to update
|
|
|
|
* \param text new status text
|
2004-07-17 17:00:38 +04:00
|
|
|
*/
|
|
|
|
|
2006-09-07 02:15:58 +04:00
|
|
|
void gui_window_set_status(struct gui_window *g, const char *text)
|
2004-07-17 17:00:38 +04:00
|
|
|
{
|
2006-11-30 18:30:54 +03:00
|
|
|
if (g->status_bar)
|
|
|
|
ro_gui_status_bar_set_text(g->status_bar, text);
|
2006-09-02 19:52:41 +04:00
|
|
|
}
|
2003-12-12 04:33:38 +03:00
|
|
|
|
|
|
|
|
2006-09-02 19:52:41 +04:00
|
|
|
/**
|
2006-09-07 02:15:58 +04:00
|
|
|
* Change mouse pointer shape
|
2006-09-02 19:52:41 +04:00
|
|
|
*/
|
2006-09-07 02:15:58 +04:00
|
|
|
|
|
|
|
void gui_window_set_pointer(struct gui_window *g, gui_pointer_shape shape)
|
|
|
|
{
|
|
|
|
static gui_pointer_shape curr_pointer = GUI_POINTER_DEFAULT;
|
|
|
|
struct ro_gui_pointer_entry *entry;
|
2006-09-02 19:52:41 +04:00
|
|
|
os_error *error;
|
2006-09-07 02:15:58 +04:00
|
|
|
|
|
|
|
if (shape == curr_pointer)
|
|
|
|
return;
|
|
|
|
|
|
|
|
assert(shape < sizeof ro_gui_pointer_table /
|
|
|
|
sizeof ro_gui_pointer_table[0]);
|
|
|
|
|
|
|
|
entry = &ro_gui_pointer_table[shape];
|
|
|
|
|
|
|
|
if (entry->wimp_area) {
|
|
|
|
/* pointer in the Wimp's sprite area */
|
|
|
|
error = xwimpspriteop_set_pointer_shape(entry->sprite_name,
|
|
|
|
1, entry->xactive, entry->yactive, 0, 0);
|
|
|
|
if (error) {
|
|
|
|
LOG(("xwimpspriteop_set_pointer_shape: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess));
|
|
|
|
warn_user("WimpError", error->errmess);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/* pointer in our own sprite area */
|
|
|
|
error = xosspriteop_set_pointer_shape(osspriteop_USER_AREA,
|
|
|
|
gui_sprites,
|
|
|
|
(osspriteop_id) entry->sprite_name,
|
|
|
|
1, entry->xactive, entry->yactive, 0, 0);
|
|
|
|
if (error) {
|
|
|
|
LOG(("xosspriteop_set_pointer_shape: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess));
|
|
|
|
warn_user("WimpError", error->errmess);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
curr_pointer = shape;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Remove the mouse pointer from the screen
|
|
|
|
*/
|
|
|
|
|
|
|
|
void gui_window_hide_pointer(struct gui_window *g)
|
|
|
|
{
|
|
|
|
os_error *error;
|
|
|
|
|
|
|
|
error = xwimpspriteop_set_pointer_shape(NULL, 0x30, 0, 0, 0, 0);
|
2004-07-17 17:00:38 +04:00
|
|
|
if (error) {
|
2006-09-07 02:15:58 +04:00
|
|
|
LOG(("xwimpspriteop_set_pointer_shape: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess));
|
|
|
|
warn_user("WimpError", error->errmess);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the contents of a window's address bar.
|
|
|
|
*
|
|
|
|
* \param g gui_window to update
|
|
|
|
* \param url new url for address bar
|
|
|
|
*/
|
|
|
|
|
|
|
|
void gui_window_set_url(struct gui_window *g, const char *url)
|
|
|
|
{
|
|
|
|
wimp_caret caret;
|
|
|
|
os_error *error;
|
2008-08-05 05:23:04 +04:00
|
|
|
const char *toolbar_url;
|
2006-09-07 02:15:58 +04:00
|
|
|
|
|
|
|
if (!g->toolbar)
|
|
|
|
return;
|
|
|
|
|
|
|
|
ro_gui_set_icon_string(g->toolbar->toolbar_handle,
|
2008-08-05 05:23:04 +04:00
|
|
|
ICON_TOOLBAR_URL, url, true);
|
2006-09-07 02:15:58 +04:00
|
|
|
ro_gui_force_redraw_icon(g->toolbar->toolbar_handle,
|
|
|
|
ICON_TOOLBAR_FAVICON);
|
|
|
|
|
|
|
|
/* if the caret is in the address bar, move it to the end */
|
|
|
|
error = xwimp_get_caret_position(&caret);
|
|
|
|
if (error) {
|
|
|
|
LOG(("xwimp_get_caret_position: 0x%x: %s",
|
2004-07-17 17:00:38 +04:00
|
|
|
error->errnum, error->errmess));
|
|
|
|
warn_user("WimpError", error->errmess);
|
|
|
|
return;
|
|
|
|
}
|
2006-09-07 02:15:58 +04:00
|
|
|
|
|
|
|
if (!(caret.w == g->toolbar->toolbar_handle &&
|
|
|
|
caret.i == ICON_TOOLBAR_URL))
|
|
|
|
return;
|
|
|
|
|
|
|
|
toolbar_url = ro_gui_get_icon_string(g->toolbar->toolbar_handle,
|
|
|
|
ICON_TOOLBAR_URL);
|
|
|
|
error = xwimp_set_caret_position(g->toolbar->toolbar_handle,
|
|
|
|
ICON_TOOLBAR_URL, 0, 0, -1, (int)strlen(toolbar_url));
|
|
|
|
if (error) {
|
|
|
|
LOG(("xwimp_set_caret_position: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess));
|
|
|
|
warn_user("WimpError", error->errmess);
|
|
|
|
}
|
|
|
|
ro_gui_url_complete_start(g);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Update the interface to reflect start of page loading.
|
|
|
|
*
|
|
|
|
* \param g window with start of load
|
|
|
|
*/
|
|
|
|
|
|
|
|
void gui_window_start_throbber(struct gui_window *g)
|
|
|
|
{
|
|
|
|
ro_gui_menu_objects_moved();
|
|
|
|
ro_gui_prepare_navigate(g);
|
|
|
|
xos_read_monotonic_time(&g->throbtime);
|
|
|
|
g->throbber = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Update the interface to reflect page loading stopped.
|
|
|
|
*
|
|
|
|
* \param g window with start of load
|
|
|
|
*/
|
|
|
|
|
|
|
|
void gui_window_stop_throbber(struct gui_window *g)
|
|
|
|
{
|
|
|
|
char throb_buf[12];
|
|
|
|
ro_gui_prepare_navigate(g);
|
|
|
|
g->throbber = 0;
|
|
|
|
if (g->toolbar) {
|
|
|
|
strcpy(throb_buf, "throbber0");
|
|
|
|
ro_gui_set_icon_string(g->toolbar->toolbar_handle,
|
2008-08-05 05:23:04 +04:00
|
|
|
ICON_TOOLBAR_THROBBER, throb_buf, true);
|
2006-09-07 02:15:58 +04:00
|
|
|
if ((g->toolbar->descriptor) && (g->toolbar->descriptor->throbber_redraw))
|
|
|
|
ro_gui_force_redraw_icon(g->toolbar->toolbar_handle,
|
|
|
|
ICON_TOOLBAR_THROBBER);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Place the caret in a browser window.
|
|
|
|
*
|
|
|
|
* \param g window with caret
|
|
|
|
* \param x coordinates of caret
|
|
|
|
* \param y coordinates of caret
|
|
|
|
* \param height height of caret
|
|
|
|
*/
|
|
|
|
|
|
|
|
void gui_window_place_caret(struct gui_window *g, int x, int y, int height)
|
|
|
|
{
|
|
|
|
os_error *error;
|
|
|
|
|
|
|
|
error = xwimp_set_caret_position(g->window, -1,
|
2007-08-07 07:55:18 +04:00
|
|
|
x * 2 * g->bw->scale,
|
|
|
|
-(y + height) * 2 * g->bw->scale,
|
|
|
|
height * 2 * g->bw->scale, -1);
|
2006-09-07 02:15:58 +04:00
|
|
|
if (error) {
|
|
|
|
LOG(("xwimp_set_caret_position: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess));
|
|
|
|
warn_user("WimpError", error->errmess);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Remove the caret, if present.
|
|
|
|
*
|
|
|
|
* \param g window with caret
|
|
|
|
*/
|
|
|
|
|
|
|
|
void gui_window_remove_caret(struct gui_window *g)
|
|
|
|
{
|
|
|
|
wimp_caret caret;
|
|
|
|
os_error *error;
|
|
|
|
|
|
|
|
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);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (caret.w != g->window)
|
|
|
|
/* we don't have the caret: do nothing */
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* hide caret, but keep input focus */
|
|
|
|
gui_window_place_caret(g, -100, -100, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Called when the gui_window has new content.
|
|
|
|
*
|
|
|
|
* \param g the gui_window that has new content
|
|
|
|
*/
|
|
|
|
|
|
|
|
void gui_window_new_content(struct gui_window *g)
|
|
|
|
{
|
|
|
|
ro_gui_menu_objects_moved();
|
|
|
|
ro_gui_prepare_navigate(g);
|
|
|
|
ro_gui_dialog_close_persistent(g->window);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Starts drag scrolling of a browser window
|
|
|
|
*
|
|
|
|
* \param gw gui window
|
|
|
|
*/
|
|
|
|
|
|
|
|
bool gui_window_scroll_start(struct gui_window *g)
|
|
|
|
{
|
|
|
|
wimp_window_info_base info;
|
|
|
|
wimp_pointer pointer;
|
|
|
|
os_error *error;
|
|
|
|
wimp_drag drag;
|
|
|
|
int height;
|
|
|
|
int width;
|
|
|
|
|
|
|
|
error = xwimp_get_pointer_info(&pointer);
|
|
|
|
if (error) {
|
|
|
|
LOG(("xwimp_get_pointer_info 0x%x : %s",
|
|
|
|
error->errnum, error->errmess));
|
|
|
|
warn_user("WimpError", error->errmess);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
info.w = g->window;
|
|
|
|
error = xwimp_get_window_info_header_only((wimp_window_info*)&info);
|
|
|
|
if (error) {
|
|
|
|
LOG(("xwimp_get_window_state: 0x%x : %s",
|
|
|
|
error->errnum, error->errmess));
|
|
|
|
warn_user("WimpError", error->errmess);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
width = info.extent.x1 - info.extent.x0;
|
|
|
|
height = info.extent.y1 - info.extent.y0;
|
|
|
|
|
|
|
|
drag.type = wimp_DRAG_USER_POINT;
|
|
|
|
drag.bbox.x1 = pointer.pos.x + info.xscroll;
|
|
|
|
drag.bbox.y0 = pointer.pos.y + info.yscroll;
|
|
|
|
drag.bbox.x0 = drag.bbox.x1 - (width - (info.visible.x1 - info.visible.x0));
|
|
|
|
drag.bbox.y1 = drag.bbox.y0 + (height - (info.visible.y1 - info.visible.y0));
|
|
|
|
|
|
|
|
if (g->toolbar) {
|
|
|
|
int tbar_height = ro_gui_theme_toolbar_full_height(g->toolbar);
|
|
|
|
drag.bbox.y0 -= tbar_height;
|
|
|
|
drag.bbox.y1 -= tbar_height;
|
|
|
|
}
|
|
|
|
|
|
|
|
error = xwimp_drag_box(&drag);
|
|
|
|
if (error) {
|
|
|
|
LOG(("xwimp_drag_box: 0x%x : %s",
|
|
|
|
error->errnum, error->errmess));
|
|
|
|
warn_user("WimpError", error->errmess);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2007-06-05 09:14:54 +04:00
|
|
|
gui_track_gui_window = g;
|
2006-09-07 02:15:58 +04:00
|
|
|
gui_current_drag_type = GUI_DRAG_SCROLL;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Platform-dependent part of starting a box scrolling operation,
|
|
|
|
* for frames and textareas.
|
|
|
|
*
|
|
|
|
* \param x0 minimum x ordinate of box relative to mouse pointer
|
|
|
|
* \param y0 minimum y ordinate
|
|
|
|
* \param x1 maximum x ordinate
|
|
|
|
* \param y1 maximum y ordinate
|
|
|
|
* \return true iff succesful
|
|
|
|
*/
|
|
|
|
|
|
|
|
bool gui_window_box_scroll_start(struct gui_window *g, int x0, int y0, int x1, int y1)
|
|
|
|
{
|
|
|
|
wimp_pointer pointer;
|
|
|
|
os_error *error;
|
|
|
|
wimp_drag drag;
|
|
|
|
|
|
|
|
error = xwimp_get_pointer_info(&pointer);
|
|
|
|
if (error) {
|
|
|
|
LOG(("xwimp_get_pointer_info 0x%x : %s",
|
|
|
|
error->errnum, error->errmess));
|
|
|
|
warn_user("WimpError", error->errmess);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
drag.type = wimp_DRAG_USER_POINT;
|
2007-08-07 07:55:18 +04:00
|
|
|
drag.bbox.x0 = pointer.pos.x + (int)(x0 * 2 * g->bw->scale);
|
|
|
|
drag.bbox.y0 = pointer.pos.y + (int)(y0 * 2 * g->bw->scale);
|
|
|
|
drag.bbox.x1 = pointer.pos.x + (int)(x1 * 2 * g->bw->scale);
|
|
|
|
drag.bbox.y1 = pointer.pos.y + (int)(y1 * 2 * g->bw->scale);
|
2006-09-07 02:15:58 +04:00
|
|
|
|
|
|
|
error = xwimp_drag_box(&drag);
|
|
|
|
if (error) {
|
|
|
|
LOG(("xwimp_drag_box: 0x%x : %s",
|
|
|
|
error->errnum, error->errmess));
|
|
|
|
warn_user("WimpError", error->errmess);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
gui_current_drag_type = GUI_DRAG_SCROLL;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Starts drag resizing of a browser frame
|
|
|
|
*
|
|
|
|
* \param gw gui window
|
|
|
|
*/
|
|
|
|
|
|
|
|
bool gui_window_frame_resize_start(struct gui_window *g)
|
|
|
|
{
|
|
|
|
wimp_pointer pointer;
|
|
|
|
os_error *error;
|
|
|
|
wimp_drag drag;
|
|
|
|
int x0, y0, x1, y1;
|
2006-12-04 00:11:34 +03:00
|
|
|
int row = -1, col = -1, i, toolbar_height = 0;
|
|
|
|
struct browser_window *top, *bw, *parent;
|
2006-09-07 02:15:58 +04:00
|
|
|
wimp_window_state state;
|
|
|
|
|
|
|
|
/* get the maximum drag box (collapse all surrounding frames */
|
|
|
|
bw = g->bw;
|
2006-12-04 00:11:34 +03:00
|
|
|
parent = bw->parent;
|
2006-09-07 02:15:58 +04:00
|
|
|
x0 = bw->x0;
|
|
|
|
y0 = bw->y0;
|
|
|
|
x1 = bw->x1;
|
|
|
|
y1 = bw->y1;
|
2006-12-04 00:11:34 +03:00
|
|
|
for (i = 0; i < (parent->cols * parent->rows); i++) {
|
|
|
|
if (&parent->children[i] == bw) {
|
|
|
|
col = i % parent->cols;
|
|
|
|
row = i / parent->cols;
|
2006-09-07 02:15:58 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
assert((row >= 0) && (col >= 0));
|
|
|
|
|
2006-12-04 00:11:34 +03:00
|
|
|
if (bw->drag_resize_left)
|
|
|
|
x0 = parent->children[row * parent->cols + (col - 1)].x0;
|
|
|
|
if (bw->drag_resize_right)
|
|
|
|
x1 = parent->children[row * parent->cols + (col + 1)].x1;
|
|
|
|
if (bw->drag_resize_up)
|
|
|
|
y0 = parent->children[(row - 1) * parent->cols + col].y0;
|
|
|
|
if (bw->drag_resize_down)
|
|
|
|
y1 = parent->children[(row + 1) * parent->cols + col].y1;
|
2006-09-07 02:15:58 +04:00
|
|
|
|
|
|
|
/* convert to screen co-ordinates */
|
|
|
|
top = browser_window_owner(bw);
|
2006-12-04 00:11:34 +03:00
|
|
|
if (top->window->toolbar)
|
|
|
|
toolbar_height = ro_gui_theme_toolbar_full_height(top->window->toolbar);
|
2006-09-07 02:15:58 +04:00
|
|
|
state.w = top->window->window;
|
2006-09-02 19:52:41 +04:00
|
|
|
error = xwimp_get_window_state(&state);
|
2004-07-17 17:00:38 +04:00
|
|
|
if (error) {
|
2006-09-02 19:52:41 +04:00
|
|
|
LOG(("xwimp_get_window_state: 0x%x: %s",
|
2004-07-17 17:00:38 +04:00
|
|
|
error->errnum, error->errmess));
|
|
|
|
warn_user("WimpError", error->errmess);
|
2006-09-07 02:15:58 +04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
x0 = state.visible.x0 + x0 * 2;
|
2006-12-04 00:11:34 +03:00
|
|
|
y0 = state.visible.y1 - y0 * 2 - toolbar_height;
|
2006-09-07 02:15:58 +04:00
|
|
|
x1 = state.visible.x0 + x1 * 2 - 1;
|
2006-12-04 00:11:34 +03:00
|
|
|
y1 = state.visible.y1 - y1 * 2 - toolbar_height - 1;
|
2006-09-07 02:15:58 +04:00
|
|
|
|
|
|
|
/* get the pointer position */
|
|
|
|
error = xwimp_get_pointer_info(&pointer);
|
|
|
|
if (error) {
|
|
|
|
LOG(("xwimp_get_pointer_info 0x%x : %s",
|
|
|
|
error->errnum, error->errmess));
|
|
|
|
warn_user("WimpError", error->errmess);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* stop dragging in directions we can't extend */
|
2006-12-04 00:11:34 +03:00
|
|
|
if (!(bw->drag_resize_left || bw->drag_resize_right)) {
|
2006-09-07 02:15:58 +04:00
|
|
|
x0 = pointer.pos.x;
|
|
|
|
x1 = pointer.pos.x;
|
|
|
|
}
|
2006-12-04 00:11:34 +03:00
|
|
|
if (!(bw->drag_resize_up || bw->drag_resize_down)) {
|
2006-09-07 02:15:58 +04:00
|
|
|
y0 = pointer.pos.y;
|
|
|
|
y1 = pointer.pos.y;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* start the drag */
|
|
|
|
drag.type = wimp_DRAG_USER_POINT;
|
|
|
|
drag.bbox.x0 = x0;
|
2006-12-04 00:11:34 +03:00
|
|
|
drag.bbox.y0 = y1;
|
2006-09-07 02:15:58 +04:00
|
|
|
drag.bbox.x1 = x1;
|
2006-12-04 00:11:34 +03:00
|
|
|
drag.bbox.y1 = y0;
|
2006-09-07 02:15:58 +04:00
|
|
|
|
|
|
|
error = xwimp_drag_box(&drag);
|
|
|
|
if (error) {
|
|
|
|
LOG(("xwimp_drag_box: 0x%x : %s",
|
|
|
|
error->errnum, error->errmess));
|
|
|
|
warn_user("WimpError", error->errmess);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* we may not be the window the pointer is currently over */
|
|
|
|
gui_track_gui_window = bw->window;
|
|
|
|
gui_current_drag_type = GUI_DRAG_FRAME;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-09-08 20:57:26 +04:00
|
|
|
/**
|
|
|
|
* Save the specified content as a link.
|
|
|
|
*
|
|
|
|
* \param g gui_window containing the content
|
|
|
|
* \param c the content to save
|
|
|
|
*/
|
|
|
|
|
|
|
|
void gui_window_save_as_link(struct gui_window *g, struct content *c)
|
|
|
|
{
|
|
|
|
if (!c)
|
|
|
|
return;
|
|
|
|
ro_gui_save_prepare(GUI_SAVE_LINK_URL, c);
|
|
|
|
ro_gui_dialog_open_persistent(g->window, dialog_saveas, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the scale setting of a window
|
|
|
|
*
|
|
|
|
* \param g gui window
|
|
|
|
* \param scale scale value (1.0 == normal scale)
|
|
|
|
*/
|
|
|
|
|
|
|
|
void gui_window_set_scale(struct gui_window *g, float scale)
|
|
|
|
{
|
2007-08-07 07:55:18 +04:00
|
|
|
ro_gui_dialog_update_zoom(g);
|
2006-09-08 20:57:26 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-09-07 02:15:58 +04:00
|
|
|
/**
|
|
|
|
* Redraws the content for all windows.
|
|
|
|
*/
|
|
|
|
|
|
|
|
void ro_gui_window_redraw_all(void)
|
|
|
|
{
|
|
|
|
struct gui_window *g;
|
|
|
|
for (g = window_list; g; g = g->next)
|
|
|
|
gui_window_redraw_window(g);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handle a Redraw_Window_Request for a browser window.
|
|
|
|
*/
|
|
|
|
|
|
|
|
void ro_gui_window_redraw(wimp_draw *redraw)
|
|
|
|
{
|
|
|
|
osbool more;
|
|
|
|
struct gui_window *g = (struct gui_window *)ro_gui_wimp_event_get_user_data(redraw->w);
|
2007-08-07 07:55:18 +04:00
|
|
|
float scale = g->bw->scale;
|
2006-09-07 02:15:58 +04:00
|
|
|
struct content *c = g->bw->current_content;
|
|
|
|
os_error *error;
|
|
|
|
|
|
|
|
/* Handle no content quickly
|
|
|
|
*/
|
|
|
|
if (!c) {
|
|
|
|
ro_gui_user_redraw(redraw, true, os_COLOUR_WHITE);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-03-10 03:19:11 +03:00
|
|
|
/* We can't render locked content as it is being in the process of
|
|
|
|
being transformed. We won't update anything (i.e. leaving
|
|
|
|
window area as is) instead of showing random data in case of
|
|
|
|
buffered redraw. */
|
|
|
|
if (c->locked)
|
|
|
|
return;
|
|
|
|
|
2006-09-07 02:15:58 +04:00
|
|
|
plot = ro_plotters;
|
|
|
|
ro_plot_set_scale(scale);
|
|
|
|
ro_gui_current_redraw_gui = g;
|
|
|
|
current_redraw_browser = g->bw;
|
|
|
|
|
|
|
|
/* HTML rendering handles scale itself */
|
|
|
|
if (c->type == CONTENT_HTML)
|
|
|
|
scale = 1;
|
|
|
|
|
|
|
|
error = xwimp_redraw_window(redraw, &more);
|
|
|
|
if (error) {
|
|
|
|
LOG(("xwimp_redraw_window: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess));
|
|
|
|
warn_user("WimpError", error->errmess);
|
2004-07-17 17:00:38 +04:00
|
|
|
return;
|
|
|
|
}
|
2006-09-07 02:15:58 +04:00
|
|
|
while (more) {
|
2008-07-30 23:17:27 +04:00
|
|
|
int clip_x0, clip_y0, clip_x1, clip_y1, clear_x1, clear_y1;
|
|
|
|
|
2006-09-07 02:15:58 +04:00
|
|
|
ro_plot_origin_x = redraw->box.x0 - redraw->xscroll;
|
|
|
|
ro_plot_origin_y = redraw->box.y1 - redraw->yscroll;
|
|
|
|
clip_x0 = (redraw->clip.x0 - ro_plot_origin_x) / 2;
|
|
|
|
clip_y0 = (ro_plot_origin_y - redraw->clip.y1) / 2;
|
|
|
|
clip_x1 = (redraw->clip.x1 - ro_plot_origin_x) / 2;
|
|
|
|
clip_y1 = (ro_plot_origin_y - redraw->clip.y0) / 2;
|
|
|
|
clear_x1 = redraw->clip.x1 - ro_plot_origin_x;
|
|
|
|
clear_y1 = redraw->clip.y0 - ro_plot_origin_y;
|
2003-11-08 02:51:13 +03:00
|
|
|
|
2006-09-07 02:15:58 +04:00
|
|
|
if (ro_gui_current_redraw_gui->option.buffer_everything)
|
|
|
|
ro_gui_buffer_open(redraw);
|
2003-12-12 04:33:38 +03:00
|
|
|
|
2008-07-30 23:17:27 +04:00
|
|
|
plot.clip(clip_x0, clip_y0, clip_x1, clip_y1);
|
2004-07-17 17:00:38 +04:00
|
|
|
|
2007-12-11 05:42:11 +03:00
|
|
|
if (c->type != CONTENT_HTML)
|
|
|
|
plot.clg(0x00ffffff);
|
|
|
|
|
2006-09-07 02:15:58 +04:00
|
|
|
content_redraw(c, 0, 0,
|
|
|
|
c->width * scale, c->height * scale,
|
|
|
|
clip_x0, clip_y0, clip_x1, clip_y1,
|
2007-08-07 07:55:18 +04:00
|
|
|
g->bw->scale,
|
2006-09-07 02:15:58 +04:00
|
|
|
0xFFFFFF);
|
2008-07-30 23:17:27 +04:00
|
|
|
|
2006-09-07 02:15:58 +04:00
|
|
|
if (ro_gui_current_redraw_gui->option.buffer_everything)
|
|
|
|
ro_gui_buffer_close();
|
2005-06-07 20:35:13 +04:00
|
|
|
|
2006-09-07 02:15:58 +04:00
|
|
|
error = xwimp_get_rectangle(redraw, &more);
|
|
|
|
/* RISC OS 3.7 returns an error here if enough buffer was
|
|
|
|
claimed to cause a new dynamic area to be created. It
|
|
|
|
doesn't actually stop anything working, so we mask it out
|
|
|
|
for now until a better fix is found. This appears to be a
|
|
|
|
bug in RISC OS. */
|
|
|
|
if (error && !(ro_gui_current_redraw_gui->
|
|
|
|
option.buffer_everything &&
|
|
|
|
error->errnum == error_WIMP_GET_RECT)) {
|
|
|
|
LOG(("xwimp_get_rectangle: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess));
|
|
|
|
warn_user("WimpError", error->errmess);
|
|
|
|
ro_gui_current_redraw_gui = NULL;
|
|
|
|
current_redraw_browser = NULL;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ro_gui_current_redraw_gui = NULL;
|
|
|
|
current_redraw_browser = NULL;
|
2003-11-08 02:51:13 +03:00
|
|
|
}
|
|
|
|
|
2004-07-17 17:00:38 +04:00
|
|
|
|
2006-12-03 14:38:14 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Remove all pending update boxes for a window
|
|
|
|
*
|
|
|
|
* \param g gui_window
|
|
|
|
*/
|
|
|
|
void ro_gui_window_remove_update_boxes(struct gui_window *g) {
|
|
|
|
struct update_box *cur;
|
|
|
|
|
|
|
|
for (cur = pending_updates; cur != NULL; cur = cur->next) {
|
|
|
|
if (cur->g == g)
|
|
|
|
cur->g = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-12-26 03:17:55 +03:00
|
|
|
/**
|
2006-09-07 02:15:58 +04:00
|
|
|
* Redraw any pending update boxes.
|
2003-12-26 03:17:55 +03:00
|
|
|
*/
|
2006-09-07 02:15:58 +04:00
|
|
|
void ro_gui_window_update_boxes(void) {
|
|
|
|
struct content *c;
|
|
|
|
osbool more;
|
|
|
|
bool clear_background = false;
|
|
|
|
bool use_buffer;
|
|
|
|
wimp_draw update;
|
|
|
|
int clip_x0, clip_y0, clip_x1, clip_y1;
|
2004-07-17 17:00:38 +04:00
|
|
|
os_error *error;
|
2006-09-07 02:15:58 +04:00
|
|
|
struct update_box *cur;
|
|
|
|
struct gui_window *g;
|
|
|
|
const union content_msg_data *data;
|
2004-07-17 17:00:38 +04:00
|
|
|
|
2006-09-07 02:15:58 +04:00
|
|
|
for (cur = pending_updates; cur != NULL; cur = cur->next) {
|
|
|
|
g = cur->g;
|
2006-12-03 14:38:14 +03:00
|
|
|
if (!g)
|
|
|
|
continue;
|
2006-09-07 02:15:58 +04:00
|
|
|
c = g->bw->current_content;
|
|
|
|
data = &cur->data;
|
|
|
|
use_buffer = cur->use_buffer;
|
|
|
|
if (!c)
|
|
|
|
continue;
|
2004-05-05 02:23:44 +04:00
|
|
|
|
2006-09-07 02:15:58 +04:00
|
|
|
update.w = g->window;
|
|
|
|
update.box.x0 = cur->x0;
|
|
|
|
update.box.y0 = cur->y0;
|
|
|
|
update.box.x1 = cur->x1;
|
|
|
|
update.box.y1 = cur->y1;
|
2004-07-17 17:00:38 +04:00
|
|
|
|
2006-09-07 02:15:58 +04:00
|
|
|
error = xwimp_update_window(&update, &more);
|
|
|
|
if (error) {
|
|
|
|
LOG(("xwimp_update_window: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess));
|
|
|
|
warn_user("WimpError", error->errmess);
|
|
|
|
continue;
|
|
|
|
}
|
2004-07-17 17:00:38 +04:00
|
|
|
|
2006-09-07 02:15:58 +04:00
|
|
|
/* Set the current redraw gui_window to get options from
|
|
|
|
*/
|
|
|
|
ro_gui_current_redraw_gui = g;
|
|
|
|
current_redraw_browser = g->bw;
|
2004-07-17 17:00:38 +04:00
|
|
|
|
2006-09-07 02:15:58 +04:00
|
|
|
plot = ro_plotters;
|
|
|
|
ro_plot_origin_x = update.box.x0 - update.xscroll;
|
|
|
|
ro_plot_origin_y = update.box.y1 - update.yscroll;
|
2007-08-07 07:55:18 +04:00
|
|
|
ro_plot_set_scale(g->bw->scale);
|
2006-09-07 02:15:58 +04:00
|
|
|
|
|
|
|
/* We should clear the background, except for HTML.
|
|
|
|
*/
|
|
|
|
if (c->type != CONTENT_HTML)
|
|
|
|
clear_background = true;
|
|
|
|
|
|
|
|
while (more) {
|
|
|
|
clip_x0 = (update.clip.x0 - ro_plot_origin_x) / 2;
|
|
|
|
clip_y0 = (ro_plot_origin_y - update.clip.y1) / 2;
|
|
|
|
clip_x1 = (update.clip.x1 - ro_plot_origin_x) / 2;
|
|
|
|
clip_y1 = (ro_plot_origin_y - update.clip.y0) / 2;
|
|
|
|
|
|
|
|
if (use_buffer)
|
|
|
|
ro_gui_buffer_open(&update);
|
|
|
|
if (data->redraw.full_redraw) {
|
|
|
|
if (clear_background) {
|
|
|
|
error = xcolourtrans_set_gcol(os_COLOUR_WHITE,
|
2008-03-10 03:51:51 +03:00
|
|
|
colourtrans_SET_BG_GCOL,
|
2006-09-07 02:15:58 +04:00
|
|
|
os_ACTION_OVERWRITE, 0, 0);
|
|
|
|
if (error) {
|
|
|
|
LOG(("xcolourtrans_set_gcol: 0x%x: %s",
|
|
|
|
error->errnum,
|
|
|
|
error->errmess));
|
|
|
|
warn_user("MiscError", error->errmess);
|
|
|
|
}
|
|
|
|
os_clg();
|
|
|
|
}
|
|
|
|
|
|
|
|
content_redraw(c, 0, 0,
|
|
|
|
c->width, c->height,
|
|
|
|
clip_x0, clip_y0, clip_x1, clip_y1,
|
2007-08-07 07:55:18 +04:00
|
|
|
g->bw->scale,
|
2006-09-07 02:15:58 +04:00
|
|
|
0xFFFFFF);
|
|
|
|
} else {
|
|
|
|
assert(data->redraw.object);
|
|
|
|
content_redraw(data->redraw.object,
|
|
|
|
floorf(data->redraw.object_x *
|
2007-08-07 07:55:18 +04:00
|
|
|
g->bw->scale),
|
2006-09-07 02:15:58 +04:00
|
|
|
ceilf(data->redraw.object_y *
|
2007-08-07 07:55:18 +04:00
|
|
|
g->bw->scale),
|
2006-09-07 02:15:58 +04:00
|
|
|
data->redraw.object_width *
|
2007-08-07 07:55:18 +04:00
|
|
|
g->bw->scale,
|
2006-09-07 02:15:58 +04:00
|
|
|
data->redraw.object_height *
|
2007-08-07 07:55:18 +04:00
|
|
|
g->bw->scale,
|
2006-09-07 02:15:58 +04:00
|
|
|
clip_x0, clip_y0, clip_x1, clip_y1,
|
2007-08-07 07:55:18 +04:00
|
|
|
g->bw->scale,
|
2006-09-07 02:15:58 +04:00
|
|
|
0xFFFFFF);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (use_buffer)
|
|
|
|
ro_gui_buffer_close();
|
|
|
|
error = xwimp_get_rectangle(&update, &more);
|
|
|
|
/* RISC OS 3.7 returns an error here if enough buffer was
|
|
|
|
claimed to cause a new dynamic area to be created. It
|
|
|
|
doesn't actually stop anything working, so we mask it out
|
|
|
|
for now until a better fix is found. This appears to be a
|
|
|
|
bug in RISC OS. */
|
|
|
|
if (error && !(use_buffer &&
|
|
|
|
error->errnum == error_WIMP_GET_RECT)) {
|
|
|
|
LOG(("xwimp_get_rectangle: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess));
|
|
|
|
warn_user("WimpError", error->errmess);
|
|
|
|
ro_gui_current_redraw_gui = NULL;
|
|
|
|
current_redraw_browser = NULL;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Reset the current redraw gui_window to prevent thumbnails from
|
|
|
|
retaining options
|
|
|
|
*/
|
|
|
|
ro_gui_current_redraw_gui = NULL;
|
|
|
|
current_redraw_browser = NULL;
|
2004-05-05 02:23:44 +04:00
|
|
|
}
|
2006-09-07 02:15:58 +04:00
|
|
|
while (pending_updates) {
|
|
|
|
cur = pending_updates;
|
|
|
|
pending_updates = pending_updates->next;
|
|
|
|
free(cur);
|
|
|
|
}
|
|
|
|
|
2003-11-08 02:51:13 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-04-22 01:36:23 +04:00
|
|
|
/**
|
|
|
|
* Launch a new url in the given window.
|
|
|
|
*
|
2006-09-02 19:52:41 +04:00
|
|
|
* \param g gui_window to update
|
2005-04-22 01:36:23 +04:00
|
|
|
* \param url url to be launched
|
|
|
|
*/
|
|
|
|
|
|
|
|
void ro_gui_window_launch_url(struct gui_window *g, const char *url)
|
|
|
|
{
|
|
|
|
url_func_result res;
|
|
|
|
char *url_norm;
|
|
|
|
|
|
|
|
ro_gui_url_complete_close(NULL, 0);
|
|
|
|
res = url_normalize(url, &url_norm);
|
|
|
|
if (res == URL_FUNC_OK) {
|
|
|
|
gui_window_set_url(g, url_norm);
|
2006-04-22 22:24:18 +04:00
|
|
|
browser_window_go(g->bw, url_norm, 0, true);
|
2005-04-22 01:36:23 +04:00
|
|
|
global_history_add_recent(url_norm);
|
|
|
|
free(url_norm);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-08-31 01:03:48 +04:00
|
|
|
/**
|
|
|
|
* Forces all windows to be set to the current theme
|
|
|
|
*/
|
|
|
|
void ro_gui_window_update_theme(void) {
|
|
|
|
struct gui_window *g;
|
|
|
|
for (g = window_list; g; g = g->next) {
|
|
|
|
if (g->toolbar) {
|
2005-03-20 23:39:43 +03:00
|
|
|
if (g->toolbar->editor)
|
|
|
|
if (!ro_gui_theme_update_toolbar(NULL, g->toolbar->editor))
|
|
|
|
g->toolbar->editor = NULL;
|
2004-08-31 01:03:48 +04:00
|
|
|
if (!ro_gui_theme_update_toolbar(NULL, g->toolbar)) {
|
|
|
|
ro_gui_theme_destroy_toolbar(g->toolbar);
|
|
|
|
g->toolbar = NULL;
|
|
|
|
}
|
2005-03-20 23:39:43 +03:00
|
|
|
ro_gui_theme_toolbar_editor_sync(g->toolbar);
|
2006-09-07 02:15:58 +04:00
|
|
|
gui_window_update_extent(g);
|
2004-08-31 01:03:48 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-09-06 18:44:42 +04:00
|
|
|
|
2006-12-30 05:10:46 +03:00
|
|
|
/**
|
|
|
|
* Updates a windows extent.
|
|
|
|
*
|
|
|
|
* \param g the gui_window to update
|
|
|
|
* \param width the minimum width, or -1 to use window width
|
|
|
|
* \param height the minimum height, or -1 to use window height
|
|
|
|
*/
|
|
|
|
|
|
|
|
void gui_window_set_extent(struct gui_window *g, int width, int height)
|
|
|
|
{
|
2007-03-03 23:49:49 +03:00
|
|
|
int screen_width;
|
2006-12-30 05:10:46 +03:00
|
|
|
int toolbar_height = 0;
|
|
|
|
struct content *content;
|
|
|
|
wimp_window_state state;
|
|
|
|
os_error *error;
|
|
|
|
|
|
|
|
content = g->bw->current_content;
|
|
|
|
if (g->toolbar)
|
|
|
|
toolbar_height = ro_gui_theme_toolbar_full_height(g->toolbar);
|
|
|
|
|
|
|
|
/* get the current state */
|
2007-01-03 18:15:54 +03:00
|
|
|
if ((height == -1) || (width == -1)) {
|
2006-12-30 05:10:46 +03:00
|
|
|
state.w = g->window;
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
if (width == -1)
|
|
|
|
width = state.visible.x1 - state.visible.x0;
|
|
|
|
if (height == -1) {
|
|
|
|
height = state.visible.y1 - state.visible.y0;
|
|
|
|
height -= toolbar_height;
|
|
|
|
}
|
|
|
|
}
|
2007-03-27 01:09:25 +04:00
|
|
|
|
2006-12-30 05:10:46 +03:00
|
|
|
/* the top-level framed window is a total pain. to get it to maximise to the
|
|
|
|
* top of the screen we need to fake it having a suitably large extent */
|
2007-03-03 23:49:49 +03:00
|
|
|
if (g->bw->children && (g->bw->browser_window_type == BROWSER_WINDOW_NORMAL)) {
|
|
|
|
ro_gui_screen_size(&screen_width, &height);
|
|
|
|
if (g->toolbar)
|
|
|
|
height -= ro_gui_theme_toolbar_full_height(g->toolbar);
|
|
|
|
height -= ro_get_hscroll_height(g->window);
|
|
|
|
height -= ro_get_title_height(g->window);
|
|
|
|
}
|
2006-12-30 05:10:46 +03:00
|
|
|
if (content) {
|
2007-08-07 07:55:18 +04:00
|
|
|
width = max(width, content->width * 2 * g->bw->scale);
|
|
|
|
height = max(height, content->height * 2 * g->bw->scale);
|
2006-12-30 05:10:46 +03:00
|
|
|
}
|
|
|
|
os_box extent = { 0, -height, width, toolbar_height };
|
|
|
|
error = xwimp_set_extent(g->window, &extent);
|
|
|
|
if (error) {
|
|
|
|
LOG(("xwimp_set_extent: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess));
|
|
|
|
warn_user("WimpError", error->errmess);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-12-12 04:33:38 +03:00
|
|
|
/**
|
|
|
|
* Open a window using the given wimp_open, handling toolbars and resizing.
|
|
|
|
*/
|
2003-11-08 02:51:13 +03:00
|
|
|
|
2006-09-06 18:44:42 +04:00
|
|
|
void ro_gui_window_open(wimp_open *open)
|
2004-07-17 17:00:38 +04:00
|
|
|
{
|
2006-09-06 18:44:42 +04:00
|
|
|
struct gui_window *g = (struct gui_window *)ro_gui_wimp_event_get_user_data(open->w);
|
2003-12-12 04:33:38 +03:00
|
|
|
int width = open->visible.x1 - open->visible.x0;
|
|
|
|
int height = open->visible.y1 - open->visible.y0;
|
2006-09-08 20:57:26 +04:00
|
|
|
int size, fheight, fwidth, toolbar_height = 0;
|
|
|
|
bool no_vscroll, no_hscroll;
|
|
|
|
float new_scale = 0;
|
2003-12-12 04:33:38 +03:00
|
|
|
struct content *content;
|
|
|
|
wimp_window_state state;
|
2004-07-17 17:00:38 +04:00
|
|
|
os_error *error;
|
2006-09-02 19:52:41 +04:00
|
|
|
wimp_w parent;
|
|
|
|
bits linkage;
|
2003-12-12 04:33:38 +03:00
|
|
|
|
2006-03-24 06:44:37 +03:00
|
|
|
if (open->next == wimp_TOP && g->iconise_icon >= 0) {
|
|
|
|
/* window is no longer iconised, release its sprite number */
|
|
|
|
iconise_used[g->iconise_icon] = false;
|
|
|
|
g->iconise_icon = -1;
|
|
|
|
}
|
|
|
|
|
2004-07-17 17:00:38 +04:00
|
|
|
content = g->bw->current_content;
|
2003-12-12 04:33:38 +03:00
|
|
|
|
2006-09-02 19:52:41 +04:00
|
|
|
/* get the current flags/nesting state */
|
2003-12-12 04:33:38 +03:00
|
|
|
state.w = g->window;
|
2006-09-02 19:52:41 +04:00
|
|
|
error = xwimp_get_window_state_and_nesting(&state, &parent, &linkage);
|
2004-07-17 17:00:38 +04:00
|
|
|
if (error) {
|
|
|
|
LOG(("xwimp_get_window_state: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess));
|
|
|
|
warn_user("WimpError", error->errmess);
|
|
|
|
return;
|
|
|
|
}
|
2003-12-12 04:33:38 +03:00
|
|
|
|
|
|
|
/* account for toolbar height, if present */
|
2004-07-17 17:00:38 +04:00
|
|
|
if (g->toolbar)
|
2005-03-20 17:57:19 +03:00
|
|
|
toolbar_height = ro_gui_theme_toolbar_full_height(g->toolbar);
|
2004-05-05 02:23:44 +04:00
|
|
|
height -= toolbar_height;
|
2006-09-07 02:15:58 +04:00
|
|
|
|
2006-09-02 19:52:41 +04:00
|
|
|
/* work with the state from now on so we can modify flags */
|
2007-01-03 18:15:54 +03:00
|
|
|
state.visible = open->visible;
|
2006-09-02 19:52:41 +04:00
|
|
|
state.xscroll = open->xscroll;
|
|
|
|
state.yscroll = open->yscroll;
|
|
|
|
state.next = open->next;
|
2006-09-07 02:15:58 +04:00
|
|
|
|
2006-09-02 19:52:41 +04:00
|
|
|
/* handle 'auto' scroll bars' and non-fitting scrollbar removal */
|
|
|
|
if ((g->bw->scrolling == SCROLLING_AUTO) || (g->bw->scrolling == SCROLLING_YES)) {
|
|
|
|
/* windows lose scrollbars when containing a frameset */
|
|
|
|
no_hscroll = (g->bw->children &&
|
|
|
|
(g->bw->browser_window_type != BROWSER_WINDOW_NORMAL));
|
|
|
|
no_vscroll = g->bw->children;
|
2006-09-07 02:15:58 +04:00
|
|
|
|
2006-09-02 19:52:41 +04:00
|
|
|
/* hscroll */
|
|
|
|
size = ro_get_hscroll_height(NULL);
|
|
|
|
if (g->bw->border)
|
|
|
|
size -= 2;
|
|
|
|
fheight = height;
|
|
|
|
if (state.flags & wimp_WINDOW_HSCROLL)
|
|
|
|
fheight += size;
|
|
|
|
if ((!no_hscroll) &&
|
2006-09-04 14:13:56 +04:00
|
|
|
((fheight > size) ||
|
|
|
|
(g->bw->browser_window_type == BROWSER_WINDOW_NORMAL)) &&
|
2007-08-07 07:55:18 +04:00
|
|
|
((content && width < content->width * 2 * g->bw->scale) ||
|
2006-09-09 00:50:07 +04:00
|
|
|
(g->bw->browser_window_type == BROWSER_WINDOW_NORMAL))) {
|
2006-09-02 19:52:41 +04:00
|
|
|
if (!(state.flags & wimp_WINDOW_HSCROLL)) {
|
|
|
|
height -= size;
|
|
|
|
state.visible.y0 += size;
|
|
|
|
if (content) {
|
2007-08-07 07:55:18 +04:00
|
|
|
g->bw->reformat_pending = true;
|
|
|
|
browser_reformat_pending = true;
|
2006-09-02 19:52:41 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
state.flags |= wimp_WINDOW_HSCROLL;
|
|
|
|
} else {
|
|
|
|
if (state.flags & wimp_WINDOW_HSCROLL) {
|
|
|
|
height += size;
|
|
|
|
state.visible.y0 -= size;
|
|
|
|
if (content) {
|
2007-08-07 07:55:18 +04:00
|
|
|
g->bw->reformat_pending = true;
|
|
|
|
browser_reformat_pending = true;
|
2006-09-02 19:52:41 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
state.flags &= ~wimp_WINDOW_HSCROLL;
|
|
|
|
}
|
2006-09-07 02:15:58 +04:00
|
|
|
|
2006-09-02 19:52:41 +04:00
|
|
|
/* vscroll */
|
|
|
|
size = ro_get_vscroll_width(NULL);
|
|
|
|
if (g->bw->border)
|
|
|
|
size -= 2;
|
|
|
|
fwidth = width;
|
|
|
|
if (state.flags & wimp_WINDOW_VSCROLL)
|
|
|
|
fwidth += size;
|
|
|
|
if ((!no_vscroll) &&
|
2006-09-04 14:13:56 +04:00
|
|
|
((fwidth > size) ||
|
|
|
|
(g->bw->browser_window_type == BROWSER_WINDOW_NORMAL)) &&
|
2007-08-07 07:55:18 +04:00
|
|
|
((content && height < content->height * 2 * g->bw->scale) ||
|
2006-09-04 14:13:56 +04:00
|
|
|
(g->bw->scrolling == SCROLLING_YES))) {
|
2006-09-02 19:52:41 +04:00
|
|
|
if (!(state.flags & wimp_WINDOW_VSCROLL)) {
|
|
|
|
width -= size;
|
|
|
|
state.visible.x1 -= size;
|
|
|
|
if (content) {
|
2007-08-07 07:55:18 +04:00
|
|
|
g->bw->reformat_pending = true;
|
|
|
|
browser_reformat_pending = true;
|
2006-09-02 19:52:41 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
state.flags |= wimp_WINDOW_VSCROLL;
|
|
|
|
} else {
|
|
|
|
if (state.flags & wimp_WINDOW_VSCROLL) {
|
|
|
|
width += size;
|
|
|
|
state.visible.x1 += size;
|
|
|
|
if (content) {
|
2007-08-07 07:55:18 +04:00
|
|
|
g->bw->reformat_pending = true;
|
|
|
|
browser_reformat_pending = true;
|
2006-09-02 19:52:41 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
state.flags &= ~wimp_WINDOW_VSCROLL;
|
|
|
|
}
|
|
|
|
}
|
2003-12-12 04:33:38 +03:00
|
|
|
|
2007-01-03 18:15:54 +03:00
|
|
|
/* reformat or change extent if necessary */
|
|
|
|
if ((content) && (g->old_width != width || g->old_height != height)) {
|
|
|
|
/* Ctrl-resize of a top-level window scales the content size */
|
|
|
|
if ((g->old_width > 0) && (g->old_width != width) && (!g->bw->parent) &&
|
|
|
|
(ro_gui_ctrl_pressed()))
|
2007-08-07 07:55:18 +04:00
|
|
|
new_scale = (g->bw->scale * width) / g->old_width;
|
|
|
|
g->bw->reformat_pending = true;
|
|
|
|
browser_reformat_pending = true;
|
2007-01-03 18:15:54 +03:00
|
|
|
}
|
|
|
|
if (g->update_extent || g->old_width != width || g->old_height != height) {
|
2004-07-17 17:00:38 +04:00
|
|
|
g->old_width = width;
|
|
|
|
g->old_height = height;
|
2007-01-03 18:15:54 +03:00
|
|
|
g->update_extent = false;
|
2006-12-30 05:10:46 +03:00
|
|
|
gui_window_set_extent(g, width, height);
|
2003-12-12 04:33:38 +03:00
|
|
|
}
|
|
|
|
|
2005-02-03 16:18:22 +03:00
|
|
|
/* first resize stops any flickering by making the URL window on top */
|
2006-09-02 19:52:41 +04:00
|
|
|
ro_gui_url_complete_resize(g, (wimp_open *)&state);
|
2005-04-15 22:00:21 +04:00
|
|
|
|
2006-09-02 19:52:41 +04:00
|
|
|
error = xwimp_open_window_nested_with_flags(&state, parent, linkage);
|
2004-07-17 17:00:38 +04:00
|
|
|
if (error) {
|
|
|
|
LOG(("xwimp_open_window: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess));
|
|
|
|
warn_user("WimpError", error->errmess);
|
|
|
|
return;
|
|
|
|
}
|
2003-12-12 04:33:38 +03:00
|
|
|
|
2006-09-08 20:57:26 +04:00
|
|
|
/* update the toolbar */
|
2006-11-30 18:30:54 +03:00
|
|
|
if (g->status_bar)
|
|
|
|
ro_gui_status_bar_resize(g->status_bar);
|
2005-02-03 16:18:22 +03:00
|
|
|
if (g->toolbar) {
|
2004-08-31 01:03:48 +04:00
|
|
|
ro_gui_theme_process_toolbar(g->toolbar, -1);
|
2005-02-03 16:18:22 +03:00
|
|
|
/* second resize updates to the new URL bar width */
|
|
|
|
ro_gui_url_complete_resize(g, open);
|
|
|
|
}
|
2006-09-10 02:07:08 +04:00
|
|
|
|
2006-09-08 20:57:26 +04:00
|
|
|
/* set the new scale from a ctrl-resize. this must be done at the end as
|
|
|
|
* it may cause a frameset recalculation based on the new window size. */
|
|
|
|
if (new_scale > 0)
|
|
|
|
browser_window_set_scale(g->bw, new_scale, true);
|
2003-11-08 02:51:13 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-09-06 18:44:42 +04:00
|
|
|
/**
|
|
|
|
* Handle wimp closing event
|
|
|
|
*/
|
|
|
|
void ro_gui_window_close(wimp_w w) {
|
|
|
|
struct gui_window *g = (struct gui_window *)ro_gui_wimp_event_get_user_data(w);
|
|
|
|
wimp_pointer pointer;
|
|
|
|
os_error *error;
|
|
|
|
char *temp_name, *r;
|
|
|
|
char *filename;
|
|
|
|
struct content *content = NULL;
|
|
|
|
|
|
|
|
error = xwimp_get_pointer_info(&pointer);
|
|
|
|
if (error) {
|
|
|
|
LOG(("xwimp_get_pointer_info: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess));
|
|
|
|
warn_user("WimpError", error->errmess);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (g->bw)
|
|
|
|
content = g->bw->current_content;
|
|
|
|
if (pointer.buttons & wimp_CLICK_ADJUST) {
|
2007-06-24 22:00:46 +04:00
|
|
|
filename = (content && content->url) ? url_to_path(content->url) : NULL;
|
2006-09-06 18:44:42 +04:00
|
|
|
if (filename) {
|
|
|
|
temp_name = malloc(strlen(filename) + 32);
|
|
|
|
if (temp_name) {
|
|
|
|
sprintf(temp_name, "Filer_OpenDir %s", filename);
|
|
|
|
r = temp_name + strlen(temp_name);
|
|
|
|
while (r > temp_name) {
|
|
|
|
if (*r == '.') {
|
|
|
|
*r = '\0';
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
*r--;
|
|
|
|
}
|
|
|
|
error = xos_cli(temp_name);
|
|
|
|
if (error) {
|
|
|
|
LOG(("xos_cli: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess));
|
|
|
|
warn_user("MiscError", error->errmess);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
free(temp_name);
|
|
|
|
}
|
|
|
|
free(filename);
|
|
|
|
} else {
|
2006-09-07 02:15:58 +04:00
|
|
|
/* this is pointless if we are about to close the window */
|
|
|
|
if (ro_gui_shift_pressed())
|
|
|
|
ro_gui_menu_handle_action(w, BROWSER_NAVIGATE_UP, true);
|
2006-09-06 18:44:42 +04:00
|
|
|
}
|
|
|
|
}
|
2006-12-03 14:38:14 +03:00
|
|
|
if (!ro_gui_shift_pressed())
|
|
|
|
browser_window_destroy(g->bw);
|
2006-09-07 02:15:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Destroy all browser windows.
|
|
|
|
*/
|
|
|
|
|
|
|
|
void ro_gui_window_quit(void)
|
|
|
|
{
|
|
|
|
struct gui_window *cur;
|
|
|
|
|
|
|
|
while (window_list) {
|
|
|
|
cur = window_list;
|
|
|
|
window_list = window_list->next;
|
|
|
|
|
|
|
|
/* framesets and iframes are destroyed by their parents */
|
|
|
|
if (!cur->bw->parent)
|
|
|
|
browser_window_destroy(cur->bw);
|
|
|
|
}
|
2006-09-06 18:44:42 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-07-17 17:00:38 +04:00
|
|
|
/**
|
|
|
|
* Animate the "throbbers" of all browser windows.
|
|
|
|
*/
|
2004-05-05 02:23:44 +04:00
|
|
|
|
2004-07-17 17:00:38 +04:00
|
|
|
void ro_gui_throb(void)
|
|
|
|
{
|
|
|
|
os_t t;
|
2006-09-02 19:52:41 +04:00
|
|
|
struct gui_window *g, *top_g;
|
|
|
|
struct browser_window *top;
|
2004-08-31 01:03:48 +04:00
|
|
|
char throb_buf[12];
|
2004-05-05 02:23:44 +04:00
|
|
|
|
2004-07-17 17:00:38 +04:00
|
|
|
xos_read_monotonic_time(&t);
|
2003-11-08 02:51:13 +03:00
|
|
|
|
2004-07-17 17:00:38 +04:00
|
|
|
for (g = window_list; g; g = g->next) {
|
2006-09-02 19:52:41 +04:00
|
|
|
if (!g->bw->throbbing)
|
2004-07-17 17:00:38 +04:00
|
|
|
continue;
|
2006-09-02 19:52:41 +04:00
|
|
|
for (top = g->bw; top->parent; top = top->parent);
|
|
|
|
top_g = top->window;
|
|
|
|
if (!top_g->toolbar || !top_g->toolbar->display_throbber ||
|
|
|
|
!top_g->toolbar->descriptor ||
|
|
|
|
!top_g->toolbar->descriptor->theme ||
|
|
|
|
(t < top_g->throbtime + 10))
|
|
|
|
continue;
|
|
|
|
top_g->throbtime = t;
|
|
|
|
top_g->throbber++;
|
|
|
|
if (top_g->toolbar->descriptor->theme->throbber_frames < top_g->throbber)
|
|
|
|
top_g->throbber = 1;
|
|
|
|
sprintf(throb_buf, "throbber%i", top_g->throbber);
|
|
|
|
ro_gui_set_icon_string(top_g->toolbar->toolbar_handle,
|
2008-08-05 05:23:04 +04:00
|
|
|
ICON_TOOLBAR_THROBBER, throb_buf, true);
|
2006-09-02 19:52:41 +04:00
|
|
|
if (top_g->toolbar->descriptor->throbber_redraw)
|
|
|
|
ro_gui_force_redraw_icon(top_g->toolbar->toolbar_handle,
|
2005-01-23 19:09:05 +03:00
|
|
|
ICON_TOOLBAR_THROBBER);
|
2004-05-05 02:23:44 +04:00
|
|
|
}
|
2003-11-08 02:51:13 +03:00
|
|
|
}
|
|
|
|
|
2004-07-17 17:00:38 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Convert a RISC OS window handle to a gui_window.
|
|
|
|
*
|
|
|
|
* \param w RISC OS window handle
|
|
|
|
* \return pointer to a structure if found, 0 otherwise
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct gui_window *ro_gui_window_lookup(wimp_w window)
|
|
|
|
{
|
|
|
|
struct gui_window *g;
|
|
|
|
for (g = window_list; g; g = g->next)
|
|
|
|
if (g->window == window)
|
|
|
|
return g;
|
|
|
|
return 0;
|
2004-05-05 02:23:44 +04:00
|
|
|
}
|
2003-11-08 02:51:13 +03:00
|
|
|
|
2004-07-17 17:00:38 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Convert a toolbar RISC OS window handle to a gui_window.
|
|
|
|
*
|
|
|
|
* \param w RISC OS window handle of a toolbar
|
|
|
|
* \return pointer to a structure if found, 0 otherwise
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct gui_window *ro_gui_toolbar_lookup(wimp_w window)
|
|
|
|
{
|
|
|
|
struct gui_window *g;
|
2005-03-20 17:57:19 +03:00
|
|
|
for (g = window_list; g; g = g->next) {
|
|
|
|
if ((g->toolbar) && ((g->toolbar->toolbar_handle == window) ||
|
|
|
|
((g->toolbar->editor) &&
|
|
|
|
(g->toolbar->editor->toolbar_handle == window))))
|
2004-07-17 17:00:38 +04:00
|
|
|
return g;
|
2005-03-20 17:57:19 +03:00
|
|
|
}
|
2004-07-17 17:00:38 +04:00
|
|
|
return 0;
|
2003-11-08 02:51:13 +03:00
|
|
|
}
|
|
|
|
|
2003-12-11 04:23:57 +03:00
|
|
|
|
2004-07-17 17:00:38 +04:00
|
|
|
/**
|
|
|
|
* Handle pointer movements in a browser window.
|
|
|
|
*
|
2004-08-07 03:45:21 +04:00
|
|
|
* \param g browser window that the pointer is in
|
2004-07-17 17:00:38 +04:00
|
|
|
* \param pointer new mouse position
|
2006-09-07 02:15:58 +04:00
|
|
|
*/
|
2004-07-17 17:00:38 +04:00
|
|
|
|
2006-09-07 02:15:58 +04:00
|
|
|
void ro_gui_window_mouse_at(struct gui_window *g, wimp_pointer *pointer)
|
|
|
|
{
|
|
|
|
os_coord pos;
|
2004-07-17 17:00:38 +04:00
|
|
|
|
2006-09-07 02:15:58 +04:00
|
|
|
if (ro_gui_window_to_window_pos(g, pointer->pos.x, pointer->pos.y, &pos))
|
|
|
|
browser_window_mouse_track(g->bw,
|
|
|
|
ro_gui_mouse_drag_state(pointer->buttons),
|
|
|
|
pos.x, pos.y);
|
2003-11-08 02:51:13 +03:00
|
|
|
}
|
|
|
|
|
2004-06-21 03:10:50 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Process Mouse_Click events in a toolbar.
|
|
|
|
*/
|
|
|
|
|
2005-12-31 07:40:49 +03:00
|
|
|
bool ro_gui_toolbar_click(wimp_pointer *pointer)
|
2004-07-17 17:00:38 +04:00
|
|
|
{
|
2005-12-31 07:40:49 +03:00
|
|
|
struct gui_window *g = ro_gui_toolbar_lookup(pointer->w);
|
2006-07-05 20:50:35 +04:00
|
|
|
struct browser_window *new_bw;
|
2005-12-31 07:40:49 +03:00
|
|
|
|
2006-01-03 01:06:59 +03:00
|
|
|
/* toolbars in the options window have no gui_window */
|
|
|
|
if (!g)
|
|
|
|
return true;
|
2005-12-31 07:40:49 +03:00
|
|
|
|
2005-02-03 16:18:22 +03:00
|
|
|
/* try to close url-completion */
|
|
|
|
ro_gui_url_complete_close(g, pointer->i);
|
2004-10-18 01:16:00 +04:00
|
|
|
|
2004-10-05 03:54:42 +04:00
|
|
|
/* Handle Menu clicks
|
|
|
|
*/
|
|
|
|
if (pointer->buttons == wimp_CLICK_MENU) {
|
2005-04-08 00:46:22 +04:00
|
|
|
ro_gui_menu_create(browser_toolbar_menu, pointer->pos.x,
|
|
|
|
pointer->pos.y, g->window);
|
2005-12-31 07:40:49 +03:00
|
|
|
return true;
|
2004-10-05 03:54:42 +04:00
|
|
|
}
|
2005-04-15 22:00:21 +04:00
|
|
|
|
2005-03-20 17:57:19 +03:00
|
|
|
/* Handle toolbar edits
|
|
|
|
*/
|
2005-03-20 22:28:50 +03:00
|
|
|
if ((g->toolbar->editor) && (pointer->i < ICON_TOOLBAR_URL)) {
|
2005-03-20 17:57:19 +03:00
|
|
|
ro_gui_theme_toolbar_editor_click(g->toolbar, pointer);
|
2005-12-31 07:40:49 +03:00
|
|
|
return true;
|
2005-03-20 17:57:19 +03:00
|
|
|
}
|
2004-06-28 23:35:04 +04:00
|
|
|
|
|
|
|
/* Handle the buttons appropriately
|
|
|
|
*/
|
2003-11-20 03:16:31 +03:00
|
|
|
switch (pointer->i) {
|
2004-02-26 20:52:10 +03:00
|
|
|
case ICON_TOOLBAR_BACK:
|
2006-07-05 20:50:35 +04:00
|
|
|
if (pointer->buttons == wimp_CLICK_ADJUST) {
|
|
|
|
new_bw = browser_window_create(NULL,
|
2008-08-24 14:31:38 +04:00
|
|
|
g->bw, NULL, false, false);
|
2006-09-02 19:52:41 +04:00
|
|
|
ro_gui_menu_handle_action(new_bw->window->window,
|
|
|
|
BROWSER_NAVIGATE_BACK, true);
|
2006-07-05 20:50:35 +04:00
|
|
|
} else {
|
2006-09-02 19:52:41 +04:00
|
|
|
ro_gui_menu_handle_action(g->window,
|
|
|
|
BROWSER_NAVIGATE_BACK, true);
|
2006-07-05 20:50:35 +04:00
|
|
|
}
|
2004-06-28 23:35:04 +04:00
|
|
|
break;
|
2005-04-08 00:46:22 +04:00
|
|
|
|
2004-02-26 20:52:10 +03:00
|
|
|
case ICON_TOOLBAR_FORWARD:
|
2006-07-05 20:50:35 +04:00
|
|
|
if (pointer->buttons == wimp_CLICK_ADJUST) {
|
|
|
|
new_bw = browser_window_create(NULL,
|
2008-08-24 14:31:38 +04:00
|
|
|
g->bw, NULL, false, false);
|
2006-09-02 19:52:41 +04:00
|
|
|
ro_gui_menu_handle_action(new_bw->window->window,
|
|
|
|
BROWSER_NAVIGATE_FORWARD, true);
|
2006-07-05 20:50:35 +04:00
|
|
|
} else {
|
2006-09-02 19:52:41 +04:00
|
|
|
ro_gui_menu_handle_action(g->window,
|
|
|
|
BROWSER_NAVIGATE_FORWARD, true);
|
|
|
|
}
|
2004-06-21 03:10:50 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ICON_TOOLBAR_STOP:
|
2006-09-02 19:52:41 +04:00
|
|
|
ro_gui_menu_handle_action(g->window,
|
|
|
|
BROWSER_NAVIGATE_STOP, true);
|
2004-02-26 20:52:10 +03:00
|
|
|
break;
|
|
|
|
|
2004-06-23 00:39:16 +04:00
|
|
|
case ICON_TOOLBAR_RELOAD:
|
2004-06-29 23:08:19 +04:00
|
|
|
if (pointer->buttons == wimp_CLICK_SELECT)
|
2006-09-02 19:52:41 +04:00
|
|
|
ro_gui_menu_handle_action(g->window,
|
|
|
|
BROWSER_NAVIGATE_RELOAD, true);
|
2004-06-29 23:08:19 +04:00
|
|
|
else if (pointer->buttons == wimp_CLICK_ADJUST)
|
2006-09-02 19:52:41 +04:00
|
|
|
ro_gui_menu_handle_action(g->window,
|
|
|
|
BROWSER_NAVIGATE_RELOAD_ALL, true);
|
2004-06-23 00:39:16 +04:00
|
|
|
break;
|
|
|
|
|
2003-11-20 03:16:31 +03:00
|
|
|
case ICON_TOOLBAR_HISTORY:
|
2005-04-08 00:46:22 +04:00
|
|
|
if (pointer->buttons == wimp_CLICK_SELECT)
|
2006-09-02 19:52:41 +04:00
|
|
|
ro_gui_menu_handle_action(g->window,
|
|
|
|
HISTORY_SHOW_LOCAL, true);
|
2005-04-08 00:46:22 +04:00
|
|
|
else
|
2006-09-02 19:52:41 +04:00
|
|
|
ro_gui_menu_handle_action(g->window,
|
|
|
|
HISTORY_SHOW_GLOBAL, true);
|
2003-11-20 03:16:31 +03:00
|
|
|
break;
|
2004-08-06 03:10:24 +04:00
|
|
|
case ICON_TOOLBAR_HOME:
|
2006-09-02 19:52:41 +04:00
|
|
|
ro_gui_menu_handle_action(g->window,
|
|
|
|
BROWSER_NAVIGATE_HOME, true);
|
2004-08-06 03:10:24 +04:00
|
|
|
break;
|
2004-09-14 03:59:30 +04:00
|
|
|
#ifdef WITH_SEARCH
|
2004-08-06 03:10:24 +04:00
|
|
|
case ICON_TOOLBAR_SEARCH:
|
2005-04-08 00:46:22 +04:00
|
|
|
ro_gui_menu_handle_action(g->window,
|
|
|
|
BROWSER_FIND_TEXT, true);
|
2004-08-06 03:10:24 +04:00
|
|
|
break;
|
2004-09-14 03:59:30 +04:00
|
|
|
#endif
|
2004-05-05 02:23:44 +04:00
|
|
|
case ICON_TOOLBAR_SCALE:
|
2005-04-08 00:46:22 +04:00
|
|
|
ro_gui_menu_handle_action(g->window,
|
|
|
|
BROWSER_SCALE_VIEW, true);
|
2004-05-05 02:23:44 +04:00
|
|
|
break;
|
2004-07-17 17:00:38 +04:00
|
|
|
|
2004-06-30 03:13:40 +04:00
|
|
|
case ICON_TOOLBAR_BOOKMARK:
|
2005-04-08 00:46:22 +04:00
|
|
|
if (pointer->buttons == wimp_CLICK_ADJUST)
|
|
|
|
ro_gui_menu_handle_action(g->window,
|
|
|
|
HOTLIST_ADD_URL, true);
|
|
|
|
else
|
|
|
|
ro_gui_menu_handle_action(g->window,
|
|
|
|
HOTLIST_SHOW, true);
|
2004-06-30 03:13:40 +04:00
|
|
|
break;
|
2004-05-05 02:23:44 +04:00
|
|
|
|
2004-03-31 00:24:00 +04:00
|
|
|
case ICON_TOOLBAR_SAVE:
|
2005-04-08 00:46:22 +04:00
|
|
|
if (pointer->buttons == wimp_CLICK_ADJUST)
|
|
|
|
ro_gui_menu_handle_action(g->window,
|
|
|
|
BROWSER_SAVE_COMPLETE, true);
|
|
|
|
else
|
|
|
|
ro_gui_menu_handle_action(g->window,
|
|
|
|
BROWSER_SAVE, true);
|
2004-05-05 02:23:44 +04:00
|
|
|
break;
|
2004-08-31 22:01:22 +04:00
|
|
|
case ICON_TOOLBAR_PRINT:
|
2006-09-02 19:52:41 +04:00
|
|
|
ro_gui_menu_handle_action(g->window,
|
|
|
|
BROWSER_PRINT, true);
|
2004-08-31 22:01:22 +04:00
|
|
|
break;
|
2006-07-04 01:07:02 +04:00
|
|
|
case ICON_TOOLBAR_UP:
|
2006-07-05 20:50:35 +04:00
|
|
|
if (pointer->buttons == wimp_CLICK_ADJUST) {
|
2006-09-02 19:52:41 +04:00
|
|
|
if (g->bw && g->bw->current_content) {
|
2006-07-05 20:50:35 +04:00
|
|
|
new_bw = browser_window_create(NULL,
|
2008-08-24 14:31:38 +04:00
|
|
|
g->bw, NULL, false,
|
|
|
|
false);
|
2006-09-02 19:52:41 +04:00
|
|
|
/* do it without loading the content into the new window */
|
|
|
|
ro_gui_window_navigate_up(new_bw->window,
|
|
|
|
g->bw->current_content->url);
|
|
|
|
}
|
2006-07-05 20:50:35 +04:00
|
|
|
} else {
|
2006-09-02 19:52:41 +04:00
|
|
|
ro_gui_menu_handle_action(g->window,
|
|
|
|
BROWSER_NAVIGATE_UP, true);
|
|
|
|
}
|
2006-07-04 01:07:02 +04:00
|
|
|
break;
|
2005-02-04 06:02:15 +03:00
|
|
|
case ICON_TOOLBAR_URL:
|
2005-09-29 19:24:48 +04:00
|
|
|
if (pointer->buttons & (wimp_DRAG_SELECT | wimp_DRAG_ADJUST)) {
|
|
|
|
if (g->bw->current_content) {
|
|
|
|
gui_save_type save_type;
|
|
|
|
|
|
|
|
if (ro_gui_shift_pressed())
|
|
|
|
save_type = GUI_SAVE_LINK_URL;
|
|
|
|
else
|
|
|
|
save_type = GUI_SAVE_LINK_TEXT;
|
|
|
|
|
|
|
|
gui_drag_save_object(save_type, g->bw->current_content, g);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ro_gui_url_complete_start(g);
|
2005-02-07 17:28:43 +03:00
|
|
|
break;
|
|
|
|
case ICON_TOOLBAR_SUGGEST:
|
|
|
|
ro_gui_popup_menu(url_suggest_menu,
|
2005-04-08 00:46:22 +04:00
|
|
|
g->toolbar->toolbar_handle,
|
2005-02-07 17:28:43 +03:00
|
|
|
ICON_TOOLBAR_SUGGEST);
|
|
|
|
break;
|
2003-11-20 03:16:31 +03:00
|
|
|
}
|
2005-12-31 07:40:49 +03:00
|
|
|
return true;
|
2003-11-08 02:51:13 +03:00
|
|
|
}
|
|
|
|
|
2004-06-21 03:10:50 +04:00
|
|
|
|
2004-07-17 17:00:38 +04:00
|
|
|
/**
|
|
|
|
* Handle Mouse_Click events in a browser window.
|
|
|
|
*
|
|
|
|
* \param pointer details of mouse click
|
2006-07-14 01:57:35 +04:00
|
|
|
* \return true if click handled, false otherwise
|
2004-07-17 17:00:38 +04:00
|
|
|
*/
|
|
|
|
|
2006-07-14 01:57:35 +04:00
|
|
|
bool ro_gui_window_click(wimp_pointer *pointer)
|
2004-07-17 17:00:38 +04:00
|
|
|
{
|
2006-07-14 01:57:35 +04:00
|
|
|
struct gui_window *g;
|
2006-09-07 02:15:58 +04:00
|
|
|
os_coord pos;
|
2004-06-25 21:38:39 +04:00
|
|
|
|
2006-09-06 18:44:42 +04:00
|
|
|
g = (struct gui_window *)ro_gui_wimp_event_get_user_data(pointer->w);
|
2003-11-08 02:51:13 +03:00
|
|
|
|
2005-02-03 16:18:22 +03:00
|
|
|
/* try to close url-completion */
|
|
|
|
ro_gui_url_complete_close(g, pointer->i);
|
|
|
|
|
2004-06-25 21:38:39 +04:00
|
|
|
/* set input focus */
|
2004-07-17 17:00:38 +04:00
|
|
|
if (pointer->buttons == wimp_CLICK_SELECT ||
|
2006-09-05 21:34:30 +04:00
|
|
|
pointer->buttons == wimp_CLICK_ADJUST)
|
|
|
|
gui_window_place_caret(g, -100, -100, 0);
|
2004-06-25 21:38:39 +04:00
|
|
|
|
2006-09-07 02:15:58 +04:00
|
|
|
if (pointer->buttons == wimp_CLICK_MENU) {
|
|
|
|
ro_gui_menu_create(browser_menu, pointer->pos.x, pointer->pos.y, pointer->w);
|
|
|
|
} else {
|
|
|
|
if (ro_gui_window_to_window_pos(g, pointer->pos.x, pointer->pos.y, &pos))
|
|
|
|
browser_window_mouse_click(g->bw,
|
|
|
|
ro_gui_mouse_click_state(pointer->buttons),
|
|
|
|
pos.x, pos.y);
|
2005-01-24 23:59:15 +03:00
|
|
|
}
|
2006-09-07 02:15:58 +04:00
|
|
|
return true;
|
2003-11-08 02:51:13 +03:00
|
|
|
}
|
2003-12-11 04:23:57 +03:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Process Key_Pressed events in a browser window.
|
|
|
|
*/
|
2004-03-27 21:46:08 +03:00
|
|
|
|
2006-07-14 01:57:35 +04:00
|
|
|
bool ro_gui_window_keypress(wimp_key *key)
|
2003-12-11 04:23:57 +03:00
|
|
|
{
|
2006-07-14 01:57:35 +04:00
|
|
|
struct gui_window *g;
|
|
|
|
bool toolbar;
|
|
|
|
struct content *content;
|
2003-12-11 04:23:57 +03:00
|
|
|
wimp_window_state state;
|
2006-07-14 01:57:35 +04:00
|
|
|
int y;
|
2008-08-05 05:23:04 +04:00
|
|
|
const char *toolbar_url;
|
2004-03-27 21:46:08 +03:00
|
|
|
os_error *error;
|
|
|
|
wimp_pointer pointer;
|
2006-09-10 02:07:08 +04:00
|
|
|
float scale;
|
2008-05-16 13:37:22 +04:00
|
|
|
uint32_t c = (uint32_t) key->c;
|
2006-07-14 01:57:35 +04:00
|
|
|
|
|
|
|
/* Find gui window */
|
|
|
|
if ((g = ro_gui_window_lookup(key->w)) != NULL) {
|
|
|
|
toolbar = false;
|
|
|
|
} else if ((g = ro_gui_toolbar_lookup(key->w)) != NULL) {
|
|
|
|
toolbar = true;
|
|
|
|
} else {
|
|
|
|
/* nothing to do with us */
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
content = g->bw->current_content;
|
2004-03-27 21:46:08 +03:00
|
|
|
|
|
|
|
error = xwimp_get_pointer_info(&pointer);
|
|
|
|
if (error) {
|
|
|
|
LOG(("xwimp_get_pointer_info: 0x%x: %s\n",
|
|
|
|
error->errnum, error->errmess));
|
2004-05-07 23:14:54 +04:00
|
|
|
warn_user("WimpError", error->errmess);
|
2004-03-27 21:46:08 +03:00
|
|
|
return false;
|
|
|
|
}
|
2003-12-11 04:23:57 +03:00
|
|
|
|
|
|
|
/* First send the key to the browser window, eg. form fields. */
|
|
|
|
if (!toolbar) {
|
2006-07-14 01:57:35 +04:00
|
|
|
if ((unsigned)c < 0x20 || (0x7f <= c && c <= 0x9f) ||
|
|
|
|
(c & IS_WIMP_KEY)) {
|
|
|
|
/* Munge control keys into unused control chars */
|
2005-04-15 09:54:44 +04:00
|
|
|
/* We can't map onto 1->26 (reserved for ctrl+<qwerty>
|
|
|
|
That leaves 27->31 and 128->159 */
|
2006-07-14 01:57:35 +04:00
|
|
|
switch (c & ~IS_WIMP_KEY) {
|
2005-04-20 16:24:41 +04:00
|
|
|
case wimp_KEY_TAB: c = 9; break;
|
|
|
|
case wimp_KEY_SHIFT | wimp_KEY_TAB: c = 11; break;
|
|
|
|
|
|
|
|
/* cursor movement keys */
|
2005-05-03 02:12:53 +04:00
|
|
|
case wimp_KEY_HOME:
|
|
|
|
case wimp_KEY_CONTROL | wimp_KEY_LEFT:
|
2006-07-14 01:57:35 +04:00
|
|
|
c = KEY_LINE_START;
|
2005-05-03 02:12:53 +04:00
|
|
|
break;
|
2005-04-20 16:24:41 +04:00
|
|
|
case wimp_KEY_END:
|
2005-04-22 01:36:23 +04:00
|
|
|
if (os_version >= RISCOS5)
|
|
|
|
c = KEY_LINE_END;
|
|
|
|
else
|
|
|
|
c = KEY_DELETE_RIGHT;
|
|
|
|
break;
|
2005-04-20 16:24:41 +04:00
|
|
|
case wimp_KEY_CONTROL | wimp_KEY_RIGHT: c = KEY_LINE_END; break;
|
2006-09-02 19:52:41 +04:00
|
|
|
case wimp_KEY_CONTROL | wimp_KEY_UP: c = KEY_TEXT_START; break;
|
2005-04-20 16:24:41 +04:00
|
|
|
case wimp_KEY_CONTROL | wimp_KEY_DOWN: c = KEY_TEXT_END; break;
|
2006-09-02 19:52:41 +04:00
|
|
|
case wimp_KEY_SHIFT | wimp_KEY_LEFT: c = KEY_WORD_LEFT ; break;
|
|
|
|
case wimp_KEY_SHIFT | wimp_KEY_RIGHT: c = KEY_WORD_RIGHT; break;
|
|
|
|
case wimp_KEY_SHIFT | wimp_KEY_UP: c = KEY_PAGE_UP; break;
|
|
|
|
case wimp_KEY_SHIFT | wimp_KEY_DOWN: c = KEY_PAGE_DOWN; break;
|
2005-04-20 16:24:41 +04:00
|
|
|
case wimp_KEY_LEFT: c = KEY_LEFT; break;
|
|
|
|
case wimp_KEY_RIGHT: c = KEY_RIGHT; break;
|
|
|
|
case wimp_KEY_UP: c = KEY_UP; break;
|
|
|
|
case wimp_KEY_DOWN: c = KEY_DOWN; break;
|
|
|
|
|
|
|
|
/* editing */
|
2005-04-22 01:36:23 +04:00
|
|
|
case wimp_KEY_CONTROL | wimp_KEY_END:
|
|
|
|
c = KEY_DELETE_LINE_END;
|
|
|
|
break;
|
|
|
|
case wimp_KEY_DELETE:
|
|
|
|
if (ro_gui_ctrl_pressed())
|
|
|
|
c = KEY_DELETE_LINE_START;
|
|
|
|
else if (os_version < RISCOS5)
|
|
|
|
c = KEY_DELETE_LEFT;
|
|
|
|
break;
|
2005-05-03 02:12:53 +04:00
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2006-07-14 01:57:35 +04:00
|
|
|
}
|
2005-06-07 20:35:13 +04:00
|
|
|
|
2006-07-14 01:57:35 +04:00
|
|
|
if (!(c & IS_WIMP_KEY)) {
|
2004-07-20 15:30:03 +04:00
|
|
|
if (browser_window_key_press(g->bw, c))
|
2003-12-11 04:23:57 +03:00
|
|
|
return true;
|
2005-04-15 22:00:21 +04:00
|
|
|
}
|
2003-12-11 04:23:57 +03:00
|
|
|
|
2006-07-14 02:35:46 +04:00
|
|
|
/* Reset c to incoming character / key code
|
|
|
|
* as we may have corrupted it above */
|
2008-05-16 13:37:22 +04:00
|
|
|
c = (uint32_t) key->c;
|
2006-07-14 02:35:46 +04:00
|
|
|
}
|
2006-07-14 01:57:35 +04:00
|
|
|
|
|
|
|
switch (c) {
|
2006-07-14 02:35:46 +04:00
|
|
|
case IS_WIMP_KEY + wimp_KEY_F1: /* Help. */
|
2005-04-08 00:46:22 +04:00
|
|
|
return ro_gui_menu_handle_action(g->window,
|
|
|
|
HELP_OPEN_CONTENTS, false);
|
2005-01-03 04:18:17 +03:00
|
|
|
|
2006-07-14 02:35:46 +04:00
|
|
|
case IS_WIMP_KEY + wimp_KEY_CONTROL + wimp_KEY_F1:
|
2005-04-08 00:46:22 +04:00
|
|
|
return ro_gui_menu_handle_action(g->window,
|
|
|
|
BROWSER_PAGE_INFO, false);
|
2005-01-03 04:18:17 +03:00
|
|
|
|
2006-07-14 02:35:46 +04:00
|
|
|
case IS_WIMP_KEY + wimp_KEY_F2:
|
2005-01-03 04:18:17 +03:00
|
|
|
if (!g->toolbar)
|
|
|
|
return false;
|
2005-02-05 04:08:00 +03:00
|
|
|
ro_gui_url_complete_close(NULL, 0);
|
2005-01-03 04:18:17 +03:00
|
|
|
ro_gui_set_icon_string(g->toolbar->toolbar_handle,
|
2008-08-05 05:23:04 +04:00
|
|
|
ICON_TOOLBAR_URL, "www.", true);
|
2005-01-03 04:18:17 +03:00
|
|
|
xwimp_set_caret_position(g->toolbar->toolbar_handle,
|
|
|
|
ICON_TOOLBAR_URL, 0, 0, -1, 4);
|
2005-02-04 06:02:15 +03:00
|
|
|
ro_gui_url_complete_start(g);
|
2005-02-05 04:08:00 +03:00
|
|
|
ro_gui_url_complete_keypress(g, wimp_KEY_DOWN);
|
2005-01-03 04:18:17 +03:00
|
|
|
return true;
|
|
|
|
|
2006-07-14 02:35:46 +04:00
|
|
|
case IS_WIMP_KEY + wimp_KEY_CONTROL + wimp_KEY_F2:
|
|
|
|
/* Close window. */
|
2005-03-19 02:52:38 +03:00
|
|
|
ro_gui_url_complete_close(NULL, 0);
|
2005-01-03 04:18:17 +03:00
|
|
|
browser_window_destroy(g->bw);
|
|
|
|
return true;
|
|
|
|
|
2006-08-18 09:39:53 +04:00
|
|
|
case 19: /* Ctrl + S */
|
2006-07-14 02:35:46 +04:00
|
|
|
case IS_WIMP_KEY + wimp_KEY_F3:
|
2005-04-08 00:46:22 +04:00
|
|
|
return ro_gui_menu_handle_action(g->window,
|
|
|
|
BROWSER_SAVE, false);
|
2005-01-03 04:18:17 +03:00
|
|
|
|
2006-07-14 02:35:46 +04:00
|
|
|
case IS_WIMP_KEY + wimp_KEY_CONTROL + wimp_KEY_F3:
|
2005-04-08 00:46:22 +04:00
|
|
|
return ro_gui_menu_handle_action(g->window,
|
|
|
|
BROWSER_EXPORT_TEXT, false);
|
2005-01-03 04:18:17 +03:00
|
|
|
|
2006-07-14 02:35:46 +04:00
|
|
|
case IS_WIMP_KEY + wimp_KEY_SHIFT + wimp_KEY_F3:
|
2005-04-08 00:46:22 +04:00
|
|
|
return ro_gui_menu_handle_action(g->window,
|
|
|
|
BROWSER_SAVE_COMPLETE, false);
|
2005-01-03 04:18:17 +03:00
|
|
|
|
2006-07-14 02:35:46 +04:00
|
|
|
case IS_WIMP_KEY + wimp_KEY_CONTROL + wimp_KEY_SHIFT + wimp_KEY_F3:
|
2005-04-08 00:46:22 +04:00
|
|
|
return ro_gui_menu_handle_action(g->window,
|
|
|
|
BROWSER_EXPORT_DRAW, false);
|
2004-05-14 23:59:09 +04:00
|
|
|
|
2004-09-14 03:59:30 +04:00
|
|
|
#ifdef WITH_SEARCH
|
2006-08-18 09:39:53 +04:00
|
|
|
case 6: /* Ctrl + F */
|
2006-07-14 02:35:46 +04:00
|
|
|
case IS_WIMP_KEY + wimp_KEY_F4: /* Search */
|
2005-04-08 00:46:22 +04:00
|
|
|
return ro_gui_menu_handle_action(g->window,
|
|
|
|
BROWSER_FIND_TEXT, false);
|
2004-09-14 03:59:30 +04:00
|
|
|
#endif
|
2004-08-06 00:32:00 +04:00
|
|
|
|
2006-07-14 02:35:46 +04:00
|
|
|
case IS_WIMP_KEY + wimp_KEY_F5: /* Reload */
|
2005-04-08 00:46:22 +04:00
|
|
|
return ro_gui_menu_handle_action(g->window,
|
|
|
|
BROWSER_NAVIGATE_RELOAD, false);
|
2004-07-27 00:13:45 +04:00
|
|
|
|
2006-05-02 14:13:36 +04:00
|
|
|
case 18: /* Ctrl+R (Full reload) */
|
2006-07-14 02:35:46 +04:00
|
|
|
case IS_WIMP_KEY + wimp_KEY_CONTROL + wimp_KEY_F5: /* Full reload */
|
2005-04-08 00:46:22 +04:00
|
|
|
return ro_gui_menu_handle_action(g->window,
|
|
|
|
BROWSER_NAVIGATE_RELOAD_ALL, false);
|
2004-06-30 03:13:40 +04:00
|
|
|
|
2006-07-14 02:35:46 +04:00
|
|
|
case IS_WIMP_KEY + wimp_KEY_F6: /* Hotlist */
|
2005-04-08 00:46:22 +04:00
|
|
|
return ro_gui_menu_handle_action(g->window,
|
|
|
|
HOTLIST_SHOW, false);
|
2004-07-27 00:13:45 +04:00
|
|
|
|
2006-07-14 02:35:46 +04:00
|
|
|
case IS_WIMP_KEY + wimp_KEY_F7: /* Show local history */
|
2005-04-08 00:46:22 +04:00
|
|
|
return ro_gui_menu_handle_action(g->window,
|
|
|
|
HISTORY_SHOW_LOCAL, false);
|
2004-07-27 00:13:45 +04:00
|
|
|
|
2006-07-14 02:35:46 +04:00
|
|
|
case IS_WIMP_KEY + wimp_KEY_CONTROL + wimp_KEY_F7:
|
|
|
|
/* Show global history */
|
2005-04-08 00:46:22 +04:00
|
|
|
return ro_gui_menu_handle_action(g->window,
|
|
|
|
HISTORY_SHOW_GLOBAL, false);
|
2003-12-11 04:23:57 +03:00
|
|
|
|
2006-07-14 02:35:46 +04:00
|
|
|
case IS_WIMP_KEY + wimp_KEY_F8: /* View source */
|
2005-04-08 00:46:22 +04:00
|
|
|
ro_gui_view_source(content);
|
2005-02-03 16:18:22 +03:00
|
|
|
return true;
|
|
|
|
|
2006-07-14 02:35:46 +04:00
|
|
|
case IS_WIMP_KEY + wimp_KEY_F9:
|
|
|
|
/* Dump content for debugging. */
|
2007-08-20 06:39:49 +04:00
|
|
|
ro_gui_dump_content(content);
|
2003-12-11 04:23:57 +03:00
|
|
|
return true;
|
|
|
|
|
2006-07-14 02:35:46 +04:00
|
|
|
case IS_WIMP_KEY + wimp_KEY_CONTROL + wimp_KEY_F9:
|
2006-04-10 03:21:13 +04:00
|
|
|
urldb_dump();
|
|
|
|
return true;
|
|
|
|
|
2006-07-14 02:35:46 +04:00
|
|
|
case IS_WIMP_KEY + wimp_KEY_CONTROL + wimp_KEY_SHIFT + wimp_KEY_F9:
|
2005-07-16 18:35:25 +04:00
|
|
|
talloc_report_full(0, stderr);
|
|
|
|
return true;
|
|
|
|
|
2006-07-14 02:35:46 +04:00
|
|
|
case IS_WIMP_KEY + wimp_KEY_F11: /* Zoom */
|
2005-04-08 00:46:22 +04:00
|
|
|
return ro_gui_menu_handle_action(g->window,
|
|
|
|
BROWSER_SCALE_VIEW, false);
|
|
|
|
|
2006-07-14 02:35:46 +04:00
|
|
|
case IS_WIMP_KEY + wimp_KEY_SHIFT + wimp_KEY_F11:
|
|
|
|
/* Toggle display of box outlines. */
|
2004-10-18 01:16:00 +04:00
|
|
|
html_redraw_debug = !html_redraw_debug;
|
2004-02-02 03:22:59 +03:00
|
|
|
gui_window_redraw_window(g);
|
|
|
|
return true;
|
|
|
|
|
2003-12-11 04:23:57 +03:00
|
|
|
case wimp_KEY_RETURN:
|
|
|
|
if (!toolbar)
|
|
|
|
break;
|
2004-08-31 01:03:48 +04:00
|
|
|
toolbar_url = ro_gui_get_icon_string(g->toolbar->toolbar_handle,
|
|
|
|
ICON_TOOLBAR_URL);
|
2005-04-22 01:36:23 +04:00
|
|
|
ro_gui_window_launch_url(g, toolbar_url);
|
2003-12-11 04:23:57 +03:00
|
|
|
return true;
|
|
|
|
|
2004-06-21 03:10:50 +04:00
|
|
|
case wimp_KEY_ESCAPE:
|
2005-03-19 02:52:38 +03:00
|
|
|
if (ro_gui_url_complete_close(NULL, 0)) {
|
2006-09-02 19:52:41 +04:00
|
|
|
ro_gui_url_complete_start(g);
|
2005-02-03 16:18:22 +03:00
|
|
|
return true;
|
2005-02-04 06:02:15 +03:00
|
|
|
}
|
2005-04-08 00:46:22 +04:00
|
|
|
return ro_gui_menu_handle_action(g->window,
|
|
|
|
BROWSER_NAVIGATE_STOP, false);
|
2004-06-21 03:10:50 +04:00
|
|
|
|
2006-06-02 03:54:55 +04:00
|
|
|
case 8: /* CTRL+H / Backspace */
|
2006-12-08 01:34:46 +03:00
|
|
|
if (toolbar)
|
|
|
|
return ro_gui_url_complete_keypress(g, c);
|
2006-12-08 01:39:00 +03:00
|
|
|
break;
|
2006-06-02 03:54:55 +04:00
|
|
|
|
2004-06-28 23:35:04 +04:00
|
|
|
case 14: /* CTRL+N */
|
2005-04-08 00:46:22 +04:00
|
|
|
return ro_gui_menu_handle_action(g->window,
|
|
|
|
BROWSER_NEW_WINDOW, false);
|
2004-06-23 00:39:16 +04:00
|
|
|
|
2004-06-11 04:08:53 +04:00
|
|
|
case 17: /* CTRL+Q (Zoom out) */
|
|
|
|
case 23: /* CTRL+W (Zoom in) */
|
2005-04-08 01:47:17 +04:00
|
|
|
if (!content)
|
|
|
|
break;
|
2007-08-07 07:55:18 +04:00
|
|
|
scale = g->bw->scale;
|
2006-07-14 01:57:35 +04:00
|
|
|
if (ro_gui_shift_pressed() && c == 17)
|
2007-08-07 07:55:18 +04:00
|
|
|
scale = g->bw->scale - 0.1;
|
2006-07-14 01:57:35 +04:00
|
|
|
else if (ro_gui_shift_pressed() && c == 23)
|
2007-08-07 07:55:18 +04:00
|
|
|
scale = g->bw->scale + 0.1;
|
2006-07-14 01:57:35 +04:00
|
|
|
else if (c == 17) {
|
2006-09-10 02:07:08 +04:00
|
|
|
for (int i = SCALE_SNAP_TO_SIZE - 1;
|
|
|
|
i >= 0; i--)
|
|
|
|
if (scale_snap_to[i] <
|
2007-08-07 07:55:18 +04:00
|
|
|
g->bw->scale) {
|
2006-09-10 02:07:08 +04:00
|
|
|
scale = scale_snap_to[i];
|
2005-03-13 04:23:10 +03:00
|
|
|
break;
|
2005-04-15 22:00:21 +04:00
|
|
|
}
|
2005-03-13 04:23:10 +03:00
|
|
|
} else {
|
2006-09-10 02:07:08 +04:00
|
|
|
for (unsigned int i = 0;
|
|
|
|
i < SCALE_SNAP_TO_SIZE; i++)
|
|
|
|
if (scale_snap_to[i] >
|
2007-08-07 07:55:18 +04:00
|
|
|
g->bw->scale) {
|
2006-09-10 02:07:08 +04:00
|
|
|
scale = scale_snap_to[i];
|
2005-03-13 04:23:10 +03:00
|
|
|
break;
|
2005-04-15 22:00:21 +04:00
|
|
|
}
|
2006-09-02 19:52:41 +04:00
|
|
|
}
|
2006-09-10 02:07:08 +04:00
|
|
|
if (scale < scale_snap_to[0])
|
|
|
|
scale = scale_snap_to[0];
|
|
|
|
if (scale > scale_snap_to[SCALE_SNAP_TO_SIZE - 1])
|
|
|
|
scale = scale_snap_to[SCALE_SNAP_TO_SIZE - 1];
|
2007-08-07 07:55:18 +04:00
|
|
|
if (g->bw->scale != scale) {
|
2006-09-10 02:07:08 +04:00
|
|
|
browser_window_set_scale(g->bw, scale, true);
|
|
|
|
// g->reformat_pending = true;
|
|
|
|
// if ((content) && (content->type != CONTENT_HTML))
|
|
|
|
// browser_window_update(g->bw, false);
|
2007-08-07 07:55:18 +04:00
|
|
|
// browser_reformat_pending = true;
|
2004-08-07 03:45:21 +04:00
|
|
|
}
|
|
|
|
return true;
|
2004-06-11 04:08:53 +04:00
|
|
|
|
2004-09-14 03:59:30 +04:00
|
|
|
#ifdef WITH_PRINT
|
2006-07-14 02:35:46 +04:00
|
|
|
case IS_WIMP_KEY + wimp_KEY_PRINT:
|
2006-07-14 01:57:35 +04:00
|
|
|
return ro_gui_menu_handle_action(g->window,
|
|
|
|
BROWSER_PRINT, false);
|
2004-09-14 03:59:30 +04:00
|
|
|
#endif
|
2004-08-09 10:28:57 +04:00
|
|
|
|
2006-12-03 15:45:35 +03:00
|
|
|
case IS_WIMP_KEY | wimp_KEY_LEFT:
|
|
|
|
case IS_WIMP_KEY | wimp_KEY_RIGHT:
|
|
|
|
case IS_WIMP_KEY | wimp_KEY_CONTROL | wimp_KEY_LEFT:
|
|
|
|
case IS_WIMP_KEY | wimp_KEY_CONTROL | wimp_KEY_RIGHT:
|
|
|
|
if (toolbar)
|
|
|
|
return false;
|
|
|
|
break;
|
2006-07-14 02:35:46 +04:00
|
|
|
case IS_WIMP_KEY + wimp_KEY_UP:
|
|
|
|
case IS_WIMP_KEY + wimp_KEY_DOWN:
|
|
|
|
case IS_WIMP_KEY + wimp_KEY_PAGE_UP:
|
|
|
|
case IS_WIMP_KEY + wimp_KEY_PAGE_DOWN:
|
2006-08-11 06:36:12 +04:00
|
|
|
case wimp_KEY_HOME:
|
2006-07-14 02:35:46 +04:00
|
|
|
case IS_WIMP_KEY | wimp_KEY_CONTROL | wimp_KEY_UP:
|
2006-08-11 06:36:12 +04:00
|
|
|
case IS_WIMP_KEY + wimp_KEY_END:
|
2006-07-14 02:35:46 +04:00
|
|
|
case IS_WIMP_KEY | wimp_KEY_CONTROL | wimp_KEY_DOWN:
|
2005-02-03 16:18:22 +03:00
|
|
|
if (toolbar)
|
2006-07-14 01:57:35 +04:00
|
|
|
return ro_gui_url_complete_keypress(g, c);
|
2003-12-21 05:27:22 +03:00
|
|
|
break;
|
|
|
|
default:
|
2005-02-03 16:18:22 +03:00
|
|
|
if (toolbar)
|
2006-07-14 01:57:35 +04:00
|
|
|
return ro_gui_url_complete_keypress(g, c);
|
2003-12-21 05:27:22 +03:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
state.w = g->window;
|
2006-07-14 02:35:46 +04:00
|
|
|
error = xwimp_get_window_state(&state);
|
|
|
|
if (error) {
|
|
|
|
LOG(("xwimp_get_window_state: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess));
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2003-12-21 05:27:22 +03:00
|
|
|
y = state.visible.y1 - state.visible.y0 - 32;
|
2005-03-19 02:52:38 +03:00
|
|
|
if (g->toolbar)
|
2005-03-20 17:57:19 +03:00
|
|
|
y -= ro_gui_theme_toolbar_full_height(g->toolbar);
|
2003-12-21 05:27:22 +03:00
|
|
|
|
2006-07-14 01:57:35 +04:00
|
|
|
switch (c) {
|
2006-12-03 15:45:35 +03:00
|
|
|
case IS_WIMP_KEY | wimp_KEY_LEFT:
|
|
|
|
state.xscroll -= 32;
|
|
|
|
break;
|
|
|
|
case IS_WIMP_KEY | wimp_KEY_RIGHT:
|
|
|
|
state.xscroll += 32;
|
|
|
|
break;
|
|
|
|
case IS_WIMP_KEY | wimp_KEY_CONTROL | wimp_KEY_LEFT:
|
|
|
|
state.xscroll = -0x10000000;
|
|
|
|
break;
|
|
|
|
case IS_WIMP_KEY | wimp_KEY_CONTROL | wimp_KEY_RIGHT:
|
|
|
|
state.xscroll = 0x10000000;
|
|
|
|
break;
|
2006-07-14 02:35:46 +04:00
|
|
|
case IS_WIMP_KEY | wimp_KEY_UP:
|
2003-12-21 05:27:22 +03:00
|
|
|
state.yscroll += 32;
|
|
|
|
break;
|
2006-07-14 02:35:46 +04:00
|
|
|
case IS_WIMP_KEY | wimp_KEY_DOWN:
|
2003-12-21 05:27:22 +03:00
|
|
|
state.yscroll -= 32;
|
|
|
|
break;
|
2006-07-14 02:35:46 +04:00
|
|
|
case IS_WIMP_KEY | wimp_KEY_PAGE_UP:
|
2003-12-21 05:27:22 +03:00
|
|
|
state.yscroll += y;
|
|
|
|
break;
|
2006-07-14 02:35:46 +04:00
|
|
|
case IS_WIMP_KEY | wimp_KEY_PAGE_DOWN:
|
2003-12-21 05:27:22 +03:00
|
|
|
state.yscroll -= y;
|
|
|
|
break;
|
2006-08-11 06:36:12 +04:00
|
|
|
case wimp_KEY_HOME:
|
2006-07-14 02:35:46 +04:00
|
|
|
case IS_WIMP_KEY | wimp_KEY_CONTROL | wimp_KEY_UP:
|
2006-12-03 15:45:35 +03:00
|
|
|
state.yscroll = 0x10000000;
|
2003-12-21 05:27:22 +03:00
|
|
|
break;
|
2006-08-11 06:36:12 +04:00
|
|
|
case IS_WIMP_KEY | wimp_KEY_END:
|
2006-07-14 02:35:46 +04:00
|
|
|
case IS_WIMP_KEY | wimp_KEY_CONTROL | wimp_KEY_DOWN:
|
2003-12-21 05:27:22 +03:00
|
|
|
state.yscroll = -0x10000000;
|
|
|
|
break;
|
2004-05-05 02:23:44 +04:00
|
|
|
}
|
2003-12-21 05:27:22 +03:00
|
|
|
|
2006-07-14 02:35:46 +04:00
|
|
|
error = xwimp_open_window((wimp_open *) &state);
|
|
|
|
if (error) {
|
|
|
|
LOG(("xwimp_open_window: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess));
|
|
|
|
}
|
|
|
|
|
2003-12-21 05:27:22 +03:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Process Scroll_Request events.
|
|
|
|
*/
|
|
|
|
void ro_gui_scroll_request(wimp_scroll *scroll)
|
|
|
|
{
|
2004-07-17 17:00:38 +04:00
|
|
|
struct gui_window *g = ro_gui_window_lookup(scroll->w);
|
2003-12-21 05:27:22 +03:00
|
|
|
|
2008-06-08 03:39:09 +04:00
|
|
|
if (g && g->bw->current_content && ro_gui_shift_pressed()) {
|
|
|
|
/* extended scroll request with shift held down; change zoom */
|
|
|
|
float scale, inc;
|
|
|
|
|
|
|
|
if (scroll->ymin & 3)
|
|
|
|
inc = 0.02; /* RO5 sends the msg 5 times; don't ask my why */
|
|
|
|
else
|
|
|
|
inc = (1 << (ABS(scroll->ymin)>>2)) / 20.0F;
|
|
|
|
|
2008-06-07 04:50:15 +04:00
|
|
|
if (scroll->ymin > 0) {
|
2008-06-08 03:39:09 +04:00
|
|
|
scale = g->bw->scale + inc;
|
2008-06-07 04:50:15 +04:00
|
|
|
if (scale > scale_snap_to[SCALE_SNAP_TO_SIZE - 1])
|
|
|
|
scale = scale_snap_to[SCALE_SNAP_TO_SIZE - 1];
|
|
|
|
} else {
|
2008-06-08 03:39:09 +04:00
|
|
|
scale = g->bw->scale - inc;
|
2008-06-07 04:50:15 +04:00
|
|
|
if (scale < scale_snap_to[0])
|
|
|
|
scale = scale_snap_to[0];
|
|
|
|
}
|
|
|
|
if (g->bw->scale != scale)
|
|
|
|
browser_window_set_scale(g->bw, scale, true);
|
|
|
|
} else {
|
|
|
|
int x = scroll->visible.x1 - scroll->visible.x0 - 32;
|
|
|
|
int y = scroll->visible.y1 - scroll->visible.y0 - 32;
|
|
|
|
os_error *error;
|
|
|
|
|
|
|
|
if (g && g->toolbar)
|
|
|
|
y -= ro_gui_theme_toolbar_full_height(g->toolbar);
|
2008-06-08 03:39:09 +04:00
|
|
|
|
2008-06-07 04:50:15 +04:00
|
|
|
switch (scroll->xmin) {
|
|
|
|
case wimp_SCROLL_PAGE_LEFT:
|
|
|
|
scroll->xscroll -= x;
|
|
|
|
break;
|
|
|
|
case wimp_SCROLL_COLUMN_LEFT:
|
|
|
|
scroll->xscroll -= 32;
|
|
|
|
break;
|
|
|
|
case wimp_SCROLL_COLUMN_RIGHT:
|
|
|
|
scroll->xscroll += 32;
|
|
|
|
break;
|
|
|
|
case wimp_SCROLL_PAGE_RIGHT:
|
|
|
|
scroll->xscroll += x;
|
|
|
|
break;
|
|
|
|
default:
|
2008-06-08 03:39:09 +04:00
|
|
|
scroll->xscroll += (x * (scroll->xmin>>2)) >> 2;
|
2008-06-07 04:50:15 +04:00
|
|
|
break;
|
|
|
|
}
|
2008-06-08 03:39:09 +04:00
|
|
|
|
2008-06-07 04:50:15 +04:00
|
|
|
switch (scroll->ymin) {
|
|
|
|
case wimp_SCROLL_PAGE_UP:
|
|
|
|
scroll->yscroll += y;
|
|
|
|
break;
|
|
|
|
case wimp_SCROLL_LINE_UP:
|
|
|
|
scroll->yscroll += 32;
|
|
|
|
break;
|
|
|
|
case wimp_SCROLL_LINE_DOWN:
|
|
|
|
scroll->yscroll -= 32;
|
|
|
|
break;
|
|
|
|
case wimp_SCROLL_PAGE_DOWN:
|
|
|
|
scroll->yscroll -= y;
|
|
|
|
break;
|
|
|
|
default:
|
2008-06-08 03:39:09 +04:00
|
|
|
scroll->yscroll += (y * (scroll->ymin>>2)) >> 2;
|
2008-06-07 04:50:15 +04:00
|
|
|
break;
|
|
|
|
}
|
2003-12-11 04:23:57 +03:00
|
|
|
|
2008-06-07 04:50:15 +04:00
|
|
|
error = xwimp_open_window((wimp_open *) scroll);
|
|
|
|
if (error) {
|
|
|
|
LOG(("xwimp_open_window: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess));
|
|
|
|
}
|
2003-12-11 04:23:57 +03:00
|
|
|
}
|
|
|
|
}
|
2004-02-25 18:12:58 +03:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
2006-09-07 02:15:58 +04:00
|
|
|
* Convert x,y screen co-ordinates into window co-ordinates.
|
2004-02-25 18:12:58 +03:00
|
|
|
*
|
2006-09-07 02:15:58 +04:00
|
|
|
* \param g gui window
|
|
|
|
* \param x x ordinate
|
|
|
|
* \param y y ordinate
|
|
|
|
* \param pos receives position in window co-ordinatates
|
|
|
|
* \return true iff conversion successful
|
2004-02-25 18:12:58 +03:00
|
|
|
*/
|
|
|
|
|
2006-09-07 02:15:58 +04:00
|
|
|
bool ro_gui_window_to_window_pos(struct gui_window *g, int x, int y, os_coord *pos)
|
|
|
|
{
|
|
|
|
wimp_window_state state;
|
|
|
|
os_error *error;
|
2004-02-25 18:12:58 +03:00
|
|
|
|
2006-09-07 02:15:58 +04:00
|
|
|
assert(g);
|
|
|
|
|
|
|
|
state.w = g->window;
|
|
|
|
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 false;
|
|
|
|
}
|
2007-08-07 07:55:18 +04:00
|
|
|
pos->x = (x - (state.visible.x0 - state.xscroll)) / 2 / g->bw->scale;
|
|
|
|
pos->y = ((state.visible.y1 - state.yscroll) - y) / 2 / g->bw->scale;
|
2006-09-07 02:15:58 +04:00
|
|
|
return true;
|
2004-02-25 18:12:58 +03:00
|
|
|
}
|
2004-05-04 02:05:40 +04:00
|
|
|
|
|
|
|
|
2005-04-20 16:24:41 +04:00
|
|
|
/**
|
|
|
|
* Convert x,y window co-ordinates into screen co-ordinates.
|
|
|
|
*
|
2006-09-02 19:52:41 +04:00
|
|
|
* \param g gui window
|
|
|
|
* \param x x ordinate
|
|
|
|
* \param y y ordinate
|
2005-04-20 16:24:41 +04:00
|
|
|
* \param pos receives position in screen co-ordinatates
|
|
|
|
* \return true iff conversion successful
|
|
|
|
*/
|
|
|
|
|
2006-09-07 02:15:58 +04:00
|
|
|
bool ro_gui_window_to_screen_pos(struct gui_window *g, int x, int y, os_coord *pos)
|
2005-04-20 16:24:41 +04:00
|
|
|
{
|
|
|
|
wimp_window_state state;
|
|
|
|
os_error *error;
|
|
|
|
|
2006-09-07 02:15:58 +04:00
|
|
|
assert(g);
|
|
|
|
|
2005-04-20 16:24:41 +04:00
|
|
|
state.w = g->window;
|
|
|
|
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 false;
|
|
|
|
}
|
2007-08-07 07:55:18 +04:00
|
|
|
pos->x = (x * 2 * g->bw->scale) + (state.visible.x0 - state.xscroll);
|
|
|
|
pos->y = (state.visible.y1 - state.yscroll) - (y * 2 * g->bw->scale);
|
2005-04-20 16:24:41 +04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-05-04 02:05:40 +04:00
|
|
|
/**
|
|
|
|
* Handle Message_DataLoad (file dragged in) for a window.
|
|
|
|
*
|
2004-08-07 03:45:21 +04:00
|
|
|
* \param g window
|
2004-05-04 02:05:40 +04:00
|
|
|
* \param message Message_DataLoad block
|
|
|
|
* \return true if the load was processed
|
|
|
|
*
|
|
|
|
* If the file was dragged into a form file input, it is used as the value.
|
|
|
|
*/
|
|
|
|
|
2004-07-17 17:00:38 +04:00
|
|
|
bool ro_gui_window_dataload(struct gui_window *g, wimp_message *message)
|
2004-05-04 02:05:40 +04:00
|
|
|
{
|
2004-07-18 21:38:01 +04:00
|
|
|
int box_x = 0, box_y = 0;
|
|
|
|
struct box *box;
|
|
|
|
struct box *file_box = 0;
|
2005-04-20 16:24:41 +04:00
|
|
|
struct box *text_box = 0;
|
2004-07-18 21:38:01 +04:00
|
|
|
struct browser_window *bw = g->bw;
|
|
|
|
struct content *content;
|
|
|
|
os_error *error;
|
2006-09-07 02:15:58 +04:00
|
|
|
os_coord pos;
|
2004-05-04 02:05:40 +04:00
|
|
|
|
|
|
|
/* HTML content only. */
|
|
|
|
if (!bw->current_content || bw->current_content->type != CONTENT_HTML)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
/* Ignore directories etc. */
|
|
|
|
if (0x1000 <= message->data.data_xfer.file_type)
|
|
|
|
return false;
|
|
|
|
|
2006-09-07 02:15:58 +04:00
|
|
|
if (!ro_gui_window_to_window_pos(g, message->data.data_xfer.pos.x,
|
2006-09-07 13:44:50 +04:00
|
|
|
message->data.data_xfer.pos.y, &pos))
|
2004-05-04 02:05:40 +04:00
|
|
|
return false;
|
2004-07-18 21:38:01 +04:00
|
|
|
|
|
|
|
content = bw->current_content;
|
|
|
|
box = content->data.html.layout;
|
2006-09-07 02:15:58 +04:00
|
|
|
while ((box = box_at_point(box, pos.x, pos.y, &box_x, &box_y, &content))) {
|
2004-07-18 21:38:01 +04:00
|
|
|
if (box->style &&
|
|
|
|
box->style->visibility == CSS_VISIBILITY_HIDDEN)
|
|
|
|
continue;
|
|
|
|
|
2005-04-20 16:24:41 +04:00
|
|
|
if (box->gadget) {
|
|
|
|
switch (box->gadget->type) {
|
|
|
|
case GADGET_FILE:
|
|
|
|
file_box = box;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GADGET_TEXTBOX:
|
|
|
|
case GADGET_TEXTAREA:
|
|
|
|
case GADGET_PASSWORD:
|
|
|
|
text_box = box;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default: /* appease compiler */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2004-05-04 02:05:40 +04:00
|
|
|
}
|
|
|
|
|
2005-04-20 16:24:41 +04:00
|
|
|
if (!file_box && !text_box)
|
2004-07-18 21:38:01 +04:00
|
|
|
return false;
|
|
|
|
|
2005-04-20 16:24:41 +04:00
|
|
|
if (file_box) {
|
2006-01-22 20:25:30 +03:00
|
|
|
utf8_convert_ret ret;
|
|
|
|
char *utf8_fn;
|
|
|
|
|
|
|
|
ret = utf8_from_local_encoding(
|
|
|
|
message->data.data_xfer.file_name, 0,
|
|
|
|
&utf8_fn);
|
|
|
|
if (ret != UTF8_CONVERT_OK) {
|
|
|
|
/* A bad encoding should never happen */
|
|
|
|
assert(ret != UTF8_CONVERT_BADENC);
|
|
|
|
LOG(("utf8_from_local_encoding failed"));
|
|
|
|
/* Load was for us - just no memory */
|
|
|
|
return true;
|
|
|
|
}
|
2004-05-04 02:05:40 +04:00
|
|
|
|
2005-04-20 16:24:41 +04:00
|
|
|
/* Found: update form input. */
|
|
|
|
free(file_box->gadget->value);
|
2006-01-22 20:25:30 +03:00
|
|
|
file_box->gadget->value = utf8_fn;
|
2005-04-20 16:24:41 +04:00
|
|
|
|
|
|
|
/* Redraw box. */
|
2006-09-07 02:15:58 +04:00
|
|
|
box_coords(file_box, &pos.x, &pos.y);
|
|
|
|
gui_window_redraw(bw->window, pos.x, pos.y,
|
|
|
|
pos.x + file_box->width,
|
|
|
|
pos.y + file_box->height);
|
2006-07-03 05:38:13 +04:00
|
|
|
} else {
|
2005-04-20 16:24:41 +04:00
|
|
|
|
|
|
|
const char *filename = message->data.data_xfer.file_name;
|
|
|
|
|
Merged revisions 4282-4285,4288-4293,4297-4298,4307,4309-4313,4322,4324-4680 via svnmerge from
svn://svn.netsurf-browser.org/branches/mikeL/netsurf
........
r4432 | mikeL | 2008-06-24 04:00:36 +0100 (Tue, 24 Jun 2008) | 1 line
Drag events are now emited from where the press originated, instead of from where they became a drag
........
r4433 | mikeL | 2008-06-24 04:25:33 +0100 (Tue, 24 Jun 2008) | 1 line
Added accelerator to 'Select All'
........
r4495 | mikeL | 2008-07-02 21:36:32 +0100 (Wed, 02 Jul 2008) | 1 line
Selections are now deleted and replaced when a key is typed in a text area or text box. All input box behavior while a selection is active is now implemented (ex: pressing the right arrow key moves the caret to the end of the selection). Cut now works properly in both versions. Fixed discrepancy between where the caret was placed and selection began when starting a drag-select. Fixed bug with calculation of a selections end box.
........
r4496 | mikeL | 2008-07-02 22:11:24 +0100 (Wed, 02 Jul 2008) | 1 line
Added support for cut in input boxes
........
r4497 | mikeL | 2008-07-02 22:21:35 +0100 (Wed, 02 Jul 2008) | 1 line
Removed unused variables (Thanks tlsa)
........
r4498 | mikeL | 2008-07-02 23:30:30 +0100 (Wed, 02 Jul 2008) | 1 line
Modified selection clearing behavior to allow for drag-saves
........
r4499 | mikeL | 2008-07-03 00:51:50 +0100 (Thu, 03 Jul 2008) | 1 line
Fixed regression where it would take two clicks to place caret in an input (Thanks tlsa)
........
r4509 | mikeL | 2008-07-06 07:55:09 +0100 (Sun, 06 Jul 2008) | 1 line
Basic download support implemented. Only downloading of text files works
........
r4510 | mikeL | 2008-07-06 18:55:31 +0100 (Sun, 06 Jul 2008) | 1 line
Downloading of non-text files is now possible. Progress bar and size downloaded are now updated
........
r4511 | mikeL | 2008-07-06 20:46:00 +0100 (Sun, 06 Jul 2008) | 1 line
Added downloads glade file
........
r4512 | mikeL | 2008-07-06 20:47:39 +0100 (Sun, 06 Jul 2008) | 1 line
Downloads window now spawns in the center of the parent browser window
........
r4513 | mikeL | 2008-07-06 20:56:12 +0100 (Sun, 06 Jul 2008) | 1 line
Fixed bug where backspace would be ignored if the selection began at the beginning on an input
........
r4514 | mikeL | 2008-07-06 21:26:45 +0100 (Sun, 06 Jul 2008) | 1 line
Fixed compiler warnings by adding casts
........
r4516 | mikeL | 2008-07-06 21:32:41 +0100 (Sun, 06 Jul 2008) | 1 line
Fixed initialization of size string, added initialization of progress
........
r4518 | mikeL | 2008-07-06 21:51:08 +0100 (Sun, 06 Jul 2008) | 1 line
Added an option for short units (with space) to human_friendly_bytesize
........
r4519 | mikeL | 2008-07-06 21:52:05 +0100 (Sun, 06 Jul 2008) | 1 line
Removed function size_to_string
........
r4520 | mikeL | 2008-07-06 22:03:11 +0100 (Sun, 06 Jul 2008) | 1 line
Fixed pedantic error (kB instead of KB). Added missing necessary parameters to human_friendly_bytesize. Fixed incorrect bool types
........
r4521 | mikeL | 2008-07-06 22:08:15 +0100 (Sun, 06 Jul 2008) | 1 line
Removed unnecessary parameter and units list from human_friendly_bytesize
........
r4522 | mikeL | 2008-07-06 22:57:03 +0100 (Sun, 06 Jul 2008) | 1 line
Removed unnused variable
........
r4523 | mikeL | 2008-07-06 23:03:46 +0100 (Sun, 06 Jul 2008) | 1 line
Fixed url parsing by replacing url_parse_filename with url_nice. Total size and size downloaded are now in human readable form. Speed is now calculated (roughly)
........
r4524 | mikeL | 2008-07-07 01:19:01 +0100 (Mon, 07 Jul 2008) | 1 line
Added file overwrite confirmation. Changed speed to a double
........
r4546 | mikeL | 2008-07-09 17:21:43 +0100 (Wed, 09 Jul 2008) | 1 line
Changed parameter of selection_get_end/start to a size_t instead of int and changed all offset variables to size_t as well
........
r4547 | mikeL | 2008-07-09 17:30:47 +0100 (Wed, 09 Jul 2008) | 1 line
Added action buttons to the bottom toolbar. Added ability to clear selected (and completed) downloads with a framework for other actions.
........
r4556 | jmb | 2008-07-10 00:17:24 +0100 (Thu, 10 Jul 2008) | 3 lines
A large bunch of tidying and general fixes to text input handling.
Make selection code treat password fields as inputs, too.
........
r4557 | mikeL | 2008-07-10 00:24:46 +0100 (Thu, 10 Jul 2008) | 1 line
Added functionality to gui_empty_clipboard and gui_start_selection (Thanks jmb)
........
r4573 | mikeL | 2008-07-10 16:33:27 +0100 (Thu, 10 Jul 2008) | 1 line
Removed example download. Made the list store row aware of its download and vise versa. Added new way of handling actions from the dialog (e.g. buttons) which handles all rows in the selection. Added a few memory management function calls to clean up better
........
r4577 | mikeL | 2008-07-10 21:11:51 +0100 (Thu, 10 Jul 2008) | 1 line
Download write channels now close properly. Added status column to the tree store which will change the progress bar text if a download is canceled or completed. Implemented cancel button functionality.
........
r4578 | mikeL | 2008-07-10 21:17:51 +0100 (Thu, 10 Jul 2008) | 1 line
Speed is now displayed as '-' when 0 or download has stopped
........
r4580 | mikeL | 2008-07-11 02:10:57 +0100 (Fri, 11 Jul 2008) | 1 line
Added two download related options (Download directory & Clear completed downloads) and a Downloads tab to the preferences dialog. Also moved the option to ask when overwriting files to Downloads tab. Added another option to the pre-download dialog, Save, which downloads the file immediately to your 'Download directory'
........
r4581 | mikeL | 2008-07-11 02:26:00 +0100 (Fri, 11 Jul 2008) | 1 line
Rearranged pre-download dialog buttons to conform to the HIG
........
r4616 | mikeL | 2008-07-11 19:54:12 +0100 (Fri, 11 Jul 2008) | 1 line
Limited download window updates to a user-defined variable that can be set in options (default is .5). Updates are now only done if the download window is visible. This greatly reduces the cpu usage.
........
r4617 | mikeL | 2008-07-11 20:07:48 +0100 (Fri, 11 Jul 2008) | 1 line
Removed unnecessary update limit option (it is now fixed at .5)
........
r4629 | mikeL | 2008-07-13 04:21:07 +0100 (Sun, 13 Jul 2008) | 1 line
Reorganized button sensitivity functions. Sensitivities are now updated when the selection changes as well as when a selected download's state changes.
........
r4635 | mikeL | 2008-07-13 17:00:05 +0100 (Sun, 13 Jul 2008) | 1 line
Added error handling. Added word-wrap to the "info" cell renderer so that to keep everything under control. Fixed bug where downloads would always go to you default folder (missing breaks).
........
r4642 | mikeL | 2008-07-13 21:46:09 +0100 (Sun, 13 Jul 2008) | 1 line
Added time remaining column. Fixed regression where the download info would be erased upon completion/cancelation.
........
r4655 | mikeL | 2008-07-14 23:20:33 +0100 (Mon, 14 Jul 2008) | 1 line
Downloads dialog is now initialized in gtk_gui.c with no parent window. The parent windows are now set when a download is created (through an extra parameter in gui_download_window_create) and when nsgtk_download_show is called. When it is closed (when NS shuts down) all incomplete downloads are canceled (and the files deleted). Added a warning dialog when netsurf tries to close with incomplete downloads. Fixed bug where default save directory would initialize to NULL.
........
r4676 | mikeL | 2008-07-15 21:01:17 +0100 (Tue, 15 Jul 2008) | 1 line
Downloads dialog is now initialized in gtk_gui.c with no parent window. The parent windows are now set when a download is created (through an extra parameter in gui_download_window_create) and when nsgtk_download_show is called. (This is the second half of the patch, last commit was only partial for some reason)
........
r4678 | mikeL | 2008-07-16 01:18:52 +0100 (Wed, 16 Jul 2008) | 1 line
Addresses almost all of rjek and jmb's concerns, fixes most of the sloppiness that was present earlier. Downloads without a total_size are now handled correctly (thanks tlsa). Changes to the default download directly are now saved correctly. Billions of other small bugs fixed
........
svn path=/trunk/netsurf/; revision=4681
2008-07-16 14:19:30 +04:00
|
|
|
browser_window_mouse_click(g->bw, BROWSER_MOUSE_PRESS_1, pos.x, pos.y);
|
2005-04-20 16:24:41 +04:00
|
|
|
|
2005-04-22 01:36:23 +04:00
|
|
|
if (!ro_gui_window_import_text(g, filename, false))
|
2005-04-20 16:24:41 +04:00
|
|
|
return true; /* it was for us, it just didn't work! */
|
|
|
|
}
|
2004-05-04 02:05:40 +04:00
|
|
|
|
|
|
|
/* send DataLoadAck */
|
|
|
|
message->action = message_DATA_LOAD_ACK;
|
|
|
|
message->your_ref = message->my_ref;
|
2004-07-18 21:38:01 +04:00
|
|
|
error = xwimp_send_message(wimp_USER_MESSAGE, message, message->sender);
|
|
|
|
if (error) {
|
|
|
|
LOG(("xwimp_send_message: 0x%x: %s\n",
|
|
|
|
error->errnum, error->errmess));
|
|
|
|
warn_user("WimpError", error->errmess);
|
|
|
|
}
|
2004-05-04 02:05:40 +04:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2004-05-08 22:12:36 +04:00
|
|
|
|
|
|
|
|
2005-04-22 01:36:23 +04:00
|
|
|
/**
|
|
|
|
* Handle Message_DataLoad (file dragged in) for a toolbar
|
|
|
|
*
|
2006-09-02 19:52:41 +04:00
|
|
|
* \param g window
|
2005-04-22 01:36:23 +04:00
|
|
|
* \param message Message_DataLoad block
|
|
|
|
* \return true if the load was processed
|
|
|
|
*/
|
|
|
|
|
|
|
|
bool ro_gui_toolbar_dataload(struct gui_window *g, wimp_message *message)
|
|
|
|
{
|
|
|
|
if (message->data.data_xfer.file_type == osfile_TYPE_TEXT &&
|
|
|
|
ro_gui_window_import_text(g, message->data.data_xfer.file_name, true)) {
|
|
|
|
|
|
|
|
os_error *error;
|
|
|
|
|
|
|
|
/* send DataLoadAck */
|
|
|
|
message->action = message_DATA_LOAD_ACK;
|
|
|
|
message->your_ref = message->my_ref;
|
|
|
|
error = xwimp_send_message(wimp_USER_MESSAGE, message, message->sender);
|
|
|
|
if (error) {
|
|
|
|
LOG(("xwimp_send_message: 0x%x: %s\n",
|
|
|
|
error->errnum, error->errmess));
|
|
|
|
warn_user("WimpError", error->errmess);
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-07-17 17:00:38 +04:00
|
|
|
/**
|
|
|
|
* Process pending reformats
|
|
|
|
*/
|
|
|
|
|
|
|
|
void ro_gui_window_process_reformats(void)
|
|
|
|
{
|
|
|
|
struct gui_window *g;
|
|
|
|
|
2007-08-07 07:55:18 +04:00
|
|
|
browser_reformat_pending = false;
|
2004-07-17 17:00:38 +04:00
|
|
|
for (g = window_list; g; g = g->next) {
|
2007-08-07 07:55:18 +04:00
|
|
|
if (!g->bw->reformat_pending)
|
2004-07-17 17:00:38 +04:00
|
|
|
continue;
|
2007-08-07 07:55:18 +04:00
|
|
|
g->bw->reformat_pending = false;
|
2006-11-27 00:04:42 +03:00
|
|
|
browser_window_reformat(g->bw,
|
2007-08-07 07:55:18 +04:00
|
|
|
g->old_width / 2,
|
|
|
|
g->old_height / 2);
|
2004-07-17 17:00:38 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-05-08 22:12:36 +04:00
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
2004-07-17 17:00:38 +04:00
|
|
|
void ro_gui_window_clone_options(struct browser_window *new_bw,
|
2004-05-08 22:12:36 +04:00
|
|
|
struct browser_window *old_bw) {
|
2004-07-17 17:00:38 +04:00
|
|
|
struct gui_window *old_gui = NULL;
|
|
|
|
struct gui_window *new_gui;
|
2004-05-08 22:12:36 +04:00
|
|
|
|
2004-07-17 17:00:38 +04:00
|
|
|
assert(new_bw);
|
2004-05-08 22:12:36 +04:00
|
|
|
|
|
|
|
/* Get our GUIs
|
|
|
|
*/
|
|
|
|
new_gui = new_bw->window;
|
|
|
|
|
2004-07-17 17:00:38 +04:00
|
|
|
if (old_bw)
|
|
|
|
old_gui = old_bw->window;
|
2004-05-08 22:12:36 +04:00
|
|
|
|
|
|
|
/* Clone the basic options
|
|
|
|
*/
|
|
|
|
if (!old_gui) {
|
2007-08-07 07:55:18 +04:00
|
|
|
new_bw->scale = ((float)option_scale) / 100;
|
2004-07-17 17:00:38 +04:00
|
|
|
new_gui->option.background_images = option_background_images;
|
2004-07-21 00:02:59 +04:00
|
|
|
new_gui->option.buffer_animations = option_buffer_animations;
|
|
|
|
new_gui->option.buffer_everything = option_buffer_everything;
|
2004-05-08 22:12:36 +04:00
|
|
|
} else {
|
2004-07-17 17:00:38 +04:00
|
|
|
new_gui->option = old_gui->option;
|
2004-05-08 22:12:36 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Set up the toolbar
|
|
|
|
*/
|
2004-07-17 17:00:38 +04:00
|
|
|
if (new_gui->toolbar) {
|
2006-11-30 18:30:54 +03:00
|
|
|
new_gui->toolbar->display_buttons = option_toolbar_show_buttons;
|
|
|
|
new_gui->toolbar->display_url = option_toolbar_show_address;
|
|
|
|
new_gui->toolbar->display_throbber = option_toolbar_show_throbber;
|
2004-08-07 03:45:21 +04:00
|
|
|
if ((old_gui) && (old_gui->toolbar)) {
|
2004-08-31 01:03:48 +04:00
|
|
|
new_gui->toolbar->display_buttons = old_gui->toolbar->display_buttons;
|
|
|
|
new_gui->toolbar->display_url = old_gui->toolbar->display_url;
|
|
|
|
new_gui->toolbar->display_throbber = old_gui->toolbar->display_throbber;
|
2006-11-30 18:30:54 +03:00
|
|
|
new_gui->toolbar->reformat_buttons = true;
|
|
|
|
ro_gui_theme_process_toolbar(new_gui->toolbar, -1);
|
2004-05-08 22:12:36 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2004-07-17 17:00:38 +04:00
|
|
|
|
|
|
|
|
2005-07-21 03:27:28 +04:00
|
|
|
/**
|
2006-09-07 02:15:58 +04:00
|
|
|
* Makes a browser window's options the default.
|
|
|
|
*
|
|
|
|
* \param bw the browser window to read options from
|
2005-07-21 03:27:28 +04:00
|
|
|
*/
|
|
|
|
|
2006-09-07 02:15:58 +04:00
|
|
|
void ro_gui_window_default_options(struct browser_window *bw) {
|
|
|
|
struct gui_window *gui;
|
2005-07-21 03:27:28 +04:00
|
|
|
|
2006-09-07 02:15:58 +04:00
|
|
|
assert(bw);
|
2005-07-21 03:27:28 +04:00
|
|
|
|
2006-09-07 02:15:58 +04:00
|
|
|
/* Get our GUI
|
|
|
|
*/
|
|
|
|
gui = bw->window;
|
|
|
|
if (!gui) return;
|
2005-07-21 03:27:28 +04:00
|
|
|
|
2006-09-07 02:15:58 +04:00
|
|
|
/* Save the basic options
|
|
|
|
*/
|
2007-08-07 07:55:18 +04:00
|
|
|
option_scale = bw->scale * 100;
|
2006-09-07 02:15:58 +04:00
|
|
|
option_buffer_animations = gui->option.buffer_animations;
|
|
|
|
option_buffer_everything = gui->option.buffer_everything;
|
2004-07-17 17:00:38 +04:00
|
|
|
|
2006-09-07 02:15:58 +04:00
|
|
|
/* Set up the toolbar
|
|
|
|
*/
|
|
|
|
if (gui->toolbar) {
|
|
|
|
option_toolbar_show_buttons = gui->toolbar->display_buttons;
|
|
|
|
option_toolbar_show_address = gui->toolbar->display_url;
|
|
|
|
option_toolbar_show_throbber = gui->toolbar->display_throbber;
|
|
|
|
}
|
2006-11-30 18:30:54 +03:00
|
|
|
if (gui->status_bar)
|
2006-12-07 23:28:19 +03:00
|
|
|
option_toolbar_status_width = ro_gui_status_bar_get_width(gui->status_bar);
|
2004-07-17 17:00:38 +04:00
|
|
|
}
|
2005-02-07 17:28:43 +03:00
|
|
|
|
|
|
|
|
2006-09-07 02:15:58 +04:00
|
|
|
|
|
|
|
|
2005-02-07 17:28:43 +03:00
|
|
|
/**
|
|
|
|
* Updates the navigation controls for all toolbars;
|
|
|
|
*
|
2006-09-02 19:52:41 +04:00
|
|
|
* \param g the gui_window to launch the URL into
|
2005-02-07 17:28:43 +03:00
|
|
|
* \param url the URL to launch, or NULL to simply update the suggestion icon
|
|
|
|
*/
|
|
|
|
void ro_gui_window_prepare_navigate_all(void) {
|
2006-09-02 19:52:41 +04:00
|
|
|
struct gui_window *g;
|
2005-02-07 17:28:43 +03:00
|
|
|
|
|
|
|
for (g = window_list; g; g = g->next)
|
|
|
|
ro_gui_prepare_navigate(g);
|
|
|
|
}
|
2005-04-15 09:54:44 +04:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the state of the mouse buttons and modifiers keys for a
|
|
|
|
* click/release action, suitable for passing to the OS-independent
|
|
|
|
* browser window code
|
|
|
|
*/
|
|
|
|
|
|
|
|
browser_mouse_state ro_gui_mouse_click_state(wimp_mouse_state buttons)
|
|
|
|
{
|
|
|
|
browser_mouse_state state = 0;
|
|
|
|
|
2008-06-06 17:58:56 +04:00
|
|
|
if (buttons & (wimp_CLICK_SELECT))
|
|
|
|
state |= BROWSER_MOUSE_PRESS_1 | BROWSER_MOUSE_CLICK_1;
|
|
|
|
if (buttons & (wimp_CLICK_ADJUST))
|
|
|
|
state |= BROWSER_MOUSE_PRESS_2 | BROWSER_MOUSE_CLICK_2;
|
2005-04-15 09:54:44 +04:00
|
|
|
|
2008-06-06 17:58:56 +04:00
|
|
|
if (buttons & (wimp_DRAG_SELECT)) {
|
|
|
|
state |= BROWSER_MOUSE_DRAG_1;
|
|
|
|
mouse_drag = true;
|
|
|
|
}
|
|
|
|
if (buttons & (wimp_DRAG_ADJUST)) {
|
|
|
|
state |= BROWSER_MOUSE_DRAG_2;
|
|
|
|
mouse_drag = true;
|
|
|
|
}
|
2005-04-15 09:54:44 +04:00
|
|
|
|
|
|
|
if (ro_gui_shift_pressed()) state |= BROWSER_MOUSE_MOD_1;
|
|
|
|
if (ro_gui_ctrl_pressed()) state |= BROWSER_MOUSE_MOD_2;
|
|
|
|
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the state of the mouse buttons and modifiers keys whilst
|
|
|
|
* dragging, for passing to the OS-independent browser window code
|
|
|
|
*/
|
|
|
|
|
|
|
|
browser_mouse_state ro_gui_mouse_drag_state(wimp_mouse_state buttons)
|
|
|
|
{
|
|
|
|
browser_mouse_state state = 0;
|
|
|
|
|
2008-06-06 17:58:56 +04:00
|
|
|
|
2005-04-15 09:54:44 +04:00
|
|
|
if (buttons & (wimp_CLICK_SELECT)) state |= BROWSER_MOUSE_HOLDING_1;
|
|
|
|
if (buttons & (wimp_CLICK_ADJUST)) state |= BROWSER_MOUSE_HOLDING_2;
|
|
|
|
|
2008-06-06 17:58:56 +04:00
|
|
|
if (!(buttons & (wimp_CLICK_SELECT) || buttons & (wimp_CLICK_ADJUST)))
|
|
|
|
mouse_drag = false;
|
|
|
|
if (mouse_drag) state |= BROWSER_MOUSE_DRAG_ON;
|
|
|
|
|
2005-04-15 09:54:44 +04:00
|
|
|
if (ro_gui_shift_pressed()) state |= BROWSER_MOUSE_MOD_1;
|
|
|
|
if (ro_gui_ctrl_pressed()) state |= BROWSER_MOUSE_MOD_2;
|
|
|
|
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns true iff one or more Shift keys is held down
|
|
|
|
*/
|
|
|
|
|
|
|
|
bool ro_gui_shift_pressed(void)
|
|
|
|
{
|
|
|
|
int shift = 0;
|
|
|
|
xosbyte1(osbyte_SCAN_KEYBOARD, 0 ^ 0x80, 0, &shift);
|
|
|
|
return (shift == 0xff);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns true iff one or more Ctrl keys is held down
|
|
|
|
*/
|
|
|
|
|
|
|
|
bool ro_gui_ctrl_pressed(void)
|
|
|
|
{
|
|
|
|
int ctrl = 0;
|
|
|
|
xosbyte1(osbyte_SCAN_KEYBOARD, 1 ^ 0x80, 0, &ctrl);
|
|
|
|
return (ctrl == 0xff);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Completes scrolling of a browser window
|
|
|
|
*
|
|
|
|
* \param g gui window
|
|
|
|
*/
|
|
|
|
|
|
|
|
void ro_gui_window_scroll_end(struct gui_window *g, wimp_dragged *drag)
|
|
|
|
{
|
|
|
|
wimp_pointer pointer;
|
|
|
|
os_error *error;
|
2006-09-07 02:15:58 +04:00
|
|
|
os_coord pos;
|
2005-04-15 09:54:44 +04:00
|
|
|
|
|
|
|
gui_current_drag_type = GUI_DRAG_NONE;
|
2006-09-02 19:52:41 +04:00
|
|
|
if (!g)
|
|
|
|
return;
|
2005-04-15 09:54:44 +04:00
|
|
|
|
|
|
|
error = xwimp_drag_box((wimp_drag*)-1);
|
|
|
|
if (error) {
|
|
|
|
LOG(("xwimp_drag_box: 0x%x : %s",
|
|
|
|
error->errnum, error->errmess));
|
|
|
|
warn_user("WimpError", error->errmess);
|
|
|
|
}
|
|
|
|
|
|
|
|
error = xwimp_get_pointer_info(&pointer);
|
|
|
|
if (error) {
|
|
|
|
LOG(("xwimp_get_pointer_info 0x%x : %s",
|
|
|
|
error->errnum, error->errmess));
|
|
|
|
warn_user("WimpError", error->errmess);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-05-28 20:49:39 +04:00
|
|
|
error = xwimpspriteop_set_pointer_shape("ptr_default", 0x31, 0, 0, 0, 0);
|
2005-07-16 09:54:45 +04:00
|
|
|
if (error) {
|
|
|
|
LOG(("xwimpspriteop_set_pointer_shape: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess));
|
|
|
|
warn_user("WimpError", error->errmess);
|
|
|
|
}
|
|
|
|
|
2006-09-07 02:15:58 +04:00
|
|
|
if (ro_gui_window_to_window_pos(g, drag->final.x0, drag->final.y0, &pos))
|
|
|
|
browser_window_mouse_drag_end(g->bw,
|
|
|
|
ro_gui_mouse_click_state(pointer.buttons),
|
|
|
|
pos.x, pos.y);
|
2005-04-15 09:54:44 +04:00
|
|
|
}
|
|
|
|
|
2005-04-18 03:32:09 +04:00
|
|
|
|
2006-09-02 19:52:41 +04:00
|
|
|
/**
|
|
|
|
* Completes resizing of a browser frame
|
|
|
|
*
|
|
|
|
* \param g gui window
|
|
|
|
*/
|
|
|
|
|
|
|
|
void ro_gui_window_frame_resize_end(struct gui_window *g, wimp_dragged *drag)
|
|
|
|
{
|
2006-09-07 02:15:58 +04:00
|
|
|
/* our clean-up is the same as for page scrolling */
|
2006-09-02 19:52:41 +04:00
|
|
|
ro_gui_window_scroll_end(g, drag);
|
|
|
|
}
|
|
|
|
|
2005-04-20 16:24:41 +04:00
|
|
|
/**
|
2005-04-22 01:36:23 +04:00
|
|
|
* Import text file into window or its toolbar
|
2005-04-20 16:24:41 +04:00
|
|
|
*
|
2006-09-02 19:52:41 +04:00
|
|
|
* \param g gui window containing textarea
|
2005-04-20 16:24:41 +04:00
|
|
|
* \param filename pathname of file to be imported
|
2005-04-22 01:36:23 +04:00
|
|
|
* \param toolbar true iff imported to toolbar rather than main window
|
2005-04-20 16:24:41 +04:00
|
|
|
* \return true iff successful
|
|
|
|
*/
|
|
|
|
|
2005-04-22 01:36:23 +04:00
|
|
|
bool ro_gui_window_import_text(struct gui_window *g, const char *filename,
|
|
|
|
bool toolbar)
|
2005-04-20 16:24:41 +04:00
|
|
|
{
|
|
|
|
fileswitch_object_type obj_type;
|
|
|
|
os_error *error;
|
2006-01-22 20:25:30 +03:00
|
|
|
char *buf, *utf8_buf;
|
2005-04-20 16:24:41 +04:00
|
|
|
int size;
|
2006-01-22 20:25:30 +03:00
|
|
|
utf8_convert_ret ret;
|
2005-04-20 16:24:41 +04:00
|
|
|
|
|
|
|
error = xosfile_read_stamped(filename, &obj_type, NULL, NULL,
|
|
|
|
&size, NULL, NULL);
|
|
|
|
if (error) {
|
|
|
|
LOG(("xosfile_read_stamped: 0x%x:%s",
|
|
|
|
error->errnum, error->errmess));
|
|
|
|
warn_user("FileError", error->errmess);
|
|
|
|
return true; /* was for us, but it didn't work! */
|
|
|
|
}
|
|
|
|
|
2006-02-02 01:31:27 +03:00
|
|
|
buf = malloc(size);
|
2005-04-20 16:24:41 +04:00
|
|
|
if (!buf) {
|
|
|
|
warn_user("NoMemory", NULL);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
error = xosfile_load_stamped(filename, (byte*)buf,
|
|
|
|
NULL, NULL, NULL, NULL, NULL);
|
|
|
|
if (error) {
|
|
|
|
LOG(("xosfile_load_stamped: 0x%x:%s",
|
|
|
|
error->errnum, error->errmess));
|
|
|
|
warn_user("LoadError", error->errmess);
|
|
|
|
free(buf);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2006-02-02 01:31:27 +03:00
|
|
|
ret = utf8_from_local_encoding(buf, size, &utf8_buf);
|
2006-01-22 20:25:30 +03:00
|
|
|
if (ret != UTF8_CONVERT_OK) {
|
|
|
|
/* bad encoding shouldn't happen */
|
|
|
|
assert(ret != UTF8_CONVERT_BADENC);
|
|
|
|
LOG(("utf8_from_local_encoding failed"));
|
|
|
|
free(buf);
|
|
|
|
warn_user("NoMemory", NULL);
|
|
|
|
return true;
|
|
|
|
}
|
2006-02-11 22:10:42 +03:00
|
|
|
size = strlen(utf8_buf);
|
2006-01-22 20:25:30 +03:00
|
|
|
|
2005-04-22 01:36:23 +04:00
|
|
|
if (toolbar) {
|
2006-02-11 22:10:42 +03:00
|
|
|
const char *ep = utf8_buf + size;
|
2005-04-22 01:36:23 +04:00
|
|
|
const char *sp;
|
2006-01-22 20:25:30 +03:00
|
|
|
char *p = utf8_buf;
|
2005-04-22 01:36:23 +04:00
|
|
|
|
|
|
|
/* skip leading whitespace */
|
2006-02-11 22:10:42 +03:00
|
|
|
while (isspace(*p)) p++;
|
2005-04-22 01:36:23 +04:00
|
|
|
|
|
|
|
sp = p;
|
2006-02-11 22:10:42 +03:00
|
|
|
while (*p && *p != '\r' && *p != '\n')
|
2005-04-22 01:36:23 +04:00
|
|
|
p += utf8_next(p, ep - p, 0);
|
|
|
|
*p = '\0';
|
|
|
|
|
|
|
|
if (p > sp)
|
|
|
|
ro_gui_window_launch_url(g, sp);
|
|
|
|
}
|
|
|
|
else
|
2006-02-11 22:10:42 +03:00
|
|
|
browser_window_paste_text(g->bw, utf8_buf, size, true);
|
2005-04-20 16:24:41 +04:00
|
|
|
|
|
|
|
free(buf);
|
2006-01-22 20:25:30 +03:00
|
|
|
free(utf8_buf);
|
2005-04-20 16:24:41 +04:00
|
|
|
return true;
|
|
|
|
}
|
2006-03-24 06:44:37 +03:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Window is being iconised. Create a suitable thumbnail sprite
|
|
|
|
* (which, sadly, must be in the Wimp sprite pool), and return
|
|
|
|
* the sprite name and truncated title to the iconiser
|
|
|
|
*
|
|
|
|
* \param g the gui window being iconised
|
|
|
|
* \param wi the WindowInfo message from the iconiser
|
|
|
|
*/
|
|
|
|
|
|
|
|
void ro_gui_window_iconise(struct gui_window *g, wimp_full_message_window_info *wi)
|
|
|
|
{
|
|
|
|
/* sadly there is no 'legal' way to get the sprite into
|
|
|
|
the Wimp sprite pool other than via a filing system */
|
|
|
|
const char *temp_fname = "Pipe:$._tmpfile";
|
|
|
|
struct browser_window *bw = g->bw;
|
|
|
|
osspriteop_header *overlay = NULL;
|
|
|
|
osspriteop_header *sprite_header;
|
|
|
|
struct bitmap *bitmap;
|
|
|
|
osspriteop_area *area;
|
|
|
|
int w = 34, h = 34;
|
|
|
|
struct content *c;
|
|
|
|
os_error *error;
|
|
|
|
int len, id;
|
|
|
|
|
|
|
|
assert(bw);
|
|
|
|
|
|
|
|
c = bw->current_content;
|
|
|
|
if (!c) return;
|
|
|
|
|
|
|
|
/* if an overlay sprite is defined, locate it and gets its dimensions
|
|
|
|
so that we can produce a thumbnail with the same dimensions */
|
|
|
|
if (!ro_gui_wimp_get_sprite("ic_netsfxx", &overlay)) {
|
|
|
|
error = xosspriteop_read_sprite_info(osspriteop_PTR,
|
|
|
|
(osspriteop_area *)0x100,
|
|
|
|
(osspriteop_id)overlay, &w, &h, NULL, NULL);
|
|
|
|
if (error) {
|
|
|
|
LOG(("xosspriteop_read_sprite_info: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess));
|
|
|
|
warn_user("MiscError", error->errmess);
|
|
|
|
overlay = NULL;
|
|
|
|
}
|
|
|
|
else if (sprite_bpp(overlay) != 8) {
|
|
|
|
LOG(("overlay sprite is not 8bpp"));
|
|
|
|
overlay = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* create the thumbnail sprite */
|
|
|
|
bitmap = bitmap_create(w, h, BITMAP_NEW | BITMAP_OPAQUE | BITMAP_CLEAR_MEMORY);
|
|
|
|
if (!bitmap) {
|
|
|
|
LOG(("Thumbnail initialisation failed."));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
thumbnail_create(c, bitmap, NULL);
|
2006-09-02 19:52:41 +04:00
|
|
|
if (overlay)
|
|
|
|
bitmap_overlay_sprite(bitmap, overlay);
|
2006-03-24 06:44:37 +03:00
|
|
|
area = thumbnail_convert_8bpp(bitmap);
|
|
|
|
bitmap_destroy(bitmap);
|
|
|
|
if (!area) {
|
|
|
|
LOG(("Thumbnail conversion failed."));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* choose a suitable sprite name */
|
|
|
|
id = 0;
|
|
|
|
while (iconise_used[id])
|
2006-06-25 17:12:07 +04:00
|
|
|
if ((unsigned)++id >= NOF_ELEMENTS(iconise_used)) {
|
2006-03-24 06:44:37 +03:00
|
|
|
id = iconise_next;
|
2006-06-25 17:12:07 +04:00
|
|
|
if ((unsigned)++iconise_next >=
|
|
|
|
NOF_ELEMENTS(iconise_used))
|
2006-03-24 06:44:37 +03:00
|
|
|
iconise_next = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
sprite_header = (osspriteop_header *)(area + 1);
|
|
|
|
len = sprintf(sprite_header->name, "ic_netsf%.2d", id);
|
|
|
|
|
|
|
|
error = xosspriteop_save_sprite_file(osspriteop_USER_AREA,
|
|
|
|
area, temp_fname);
|
|
|
|
if (error) {
|
|
|
|
LOG(("xosspriteop_save_sprite_file: 0x%x:%s",
|
|
|
|
error->errnum, error->errmess));
|
|
|
|
warn_user("MiscError", error->errmess);
|
|
|
|
free(area);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
error = xwimpspriteop_merge_sprite_file(temp_fname);
|
|
|
|
if (error) {
|
|
|
|
LOG(("xwimpspriteop_merge_sprite_file: 0x%x:%s",
|
|
|
|
error->errnum, error->errmess));
|
|
|
|
warn_user("WimpError", error->errmess);
|
|
|
|
remove(temp_fname);
|
|
|
|
free(area);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
memcpy(wi->sprite_name, sprite_header->name + 3, len - 2); /* inc NUL */
|
|
|
|
strncpy(wi->title, g->title, sizeof(wi->title));
|
|
|
|
wi->title[sizeof(wi->title) - 1] = '\0';
|
|
|
|
|
2006-06-24 20:56:56 +04:00
|
|
|
if (wimptextop_string_width(wi->title, 0) > 182) {
|
2006-06-24 02:42:31 +04:00
|
|
|
/* work around bug in Pinboard where it will fail to display
|
|
|
|
* the icon if the text is very wide */
|
|
|
|
if (strlen(wi->title) > 10)
|
|
|
|
wi->title[10] = '\0'; /* pinboard does this anyway */
|
|
|
|
while (wimptextop_string_width(wi->title, 0) > 182)
|
|
|
|
wi->title[strlen(wi->title) - 1] = '\0';
|
|
|
|
}
|
|
|
|
|
2006-03-24 06:44:37 +03:00
|
|
|
wi->size = sizeof(wimp_full_message_window_info);
|
|
|
|
wi->your_ref = wi->my_ref;
|
|
|
|
error = xwimp_send_message(wimp_USER_MESSAGE, (wimp_message*)wi, wi->sender);
|
|
|
|
if (error) {
|
|
|
|
LOG(("xwimp_send_message: 0x%x:%s",
|
|
|
|
error->errnum, error->errmess));
|
|
|
|
warn_user("WimpError", error->errmess);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
g->iconise_icon = id;
|
|
|
|
iconise_used[id] = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
free(area);
|
|
|
|
}
|
2006-07-05 20:50:35 +04:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Navigate up one level
|
|
|
|
*
|
2006-09-02 19:52:41 +04:00
|
|
|
* \param g the gui_window to open the parent link in
|
2006-07-05 20:50:35 +04:00
|
|
|
* \param url the URL to open the parent of
|
|
|
|
*/
|
|
|
|
bool ro_gui_window_navigate_up(struct gui_window *g, const char *url) {
|
|
|
|
char *parent;
|
|
|
|
url_func_result res;
|
|
|
|
bool compare;
|
2006-07-14 01:57:35 +04:00
|
|
|
|
2006-07-05 20:50:35 +04:00
|
|
|
if (!g || (!g->bw))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
res = url_parent(url, &parent);
|
|
|
|
if (res == URL_FUNC_OK) {
|
2008-02-03 15:04:48 +03:00
|
|
|
res = url_compare(url, parent, false, &compare);
|
|
|
|
if ((res == URL_FUNC_OK) && !compare)
|
2006-09-02 19:52:41 +04:00
|
|
|
browser_window_go(g->bw, parent, 0, true);
|
|
|
|
free(parent);
|
|
|
|
}
|
2006-07-05 20:50:35 +04:00
|
|
|
return true;
|
|
|
|
}
|