r2931 jmb - /trunk/netsurf/riscos/query.c
by netsurf@semichrome.net
Author: jmb
Date: Fri Sep 8 17:05:36 2006
New Revision: 2931
URL: http://svn.semichrome.net?rev=2931&view=rev
Log:
Squash warning
Modified:
trunk/netsurf/riscos/query.c
Modified: trunk/netsurf/riscos/query.c
URL: http://svn.semichrome.net/trunk/netsurf/riscos/query.c?rev=2931&r1=2930&r...
==============================================================================
--- trunk/netsurf/riscos/query.c (original)
+++ trunk/netsurf/riscos/query.c Fri Sep 8 17:05:36 2006
@@ -5,6 +5,7 @@
* Copyright 2005 Adrian Lees <adrianl(a)users.sourceforge.net>
*/
+#define _GNU_SOURCE /* for strnlen */
#include <stdlib.h>
#include <string.h>
@@ -274,7 +275,7 @@
{
struct gui_query_window *qw;
const query_callback *cb;
-
+
qw = (struct gui_query_window *)ro_gui_wimp_event_get_user_data(w);
cb = qw->cb;
cb->confirm(qw->id, QUERY_YES, qw->pw);
@@ -289,7 +290,7 @@
{
struct gui_query_window *qw;
const query_callback *cb;
-
+
qw = (struct gui_query_window *)ro_gui_wimp_event_get_user_data(pointer->w);
cb = qw->cb;
17 years
r2929 rjw - /trunk/netsurf/riscos/query.c
by netsurf@semichrome.net
Author: rjw
Date: Fri Sep 8 14:31:43 2006
New Revision: 2929
URL: http://svn.semichrome.net?rev=2929&view=rev
Log:
Fix icon sizing
Modified:
trunk/netsurf/riscos/query.c
Modified: trunk/netsurf/riscos/query.c
URL: http://svn.semichrome.net/trunk/netsurf/riscos/query.c?rev=2929&r1=2928&r...
==============================================================================
--- trunk/netsurf/riscos/query.c (original)
+++ trunk/netsurf/riscos/query.c Fri Sep 8 14:31:43 2006
@@ -133,10 +133,9 @@
width = len * 16;
}
if (!query_yes_width) query_yes_width = icn->extent.x1 - icn->extent.x0;
+ width += 44;
if (width < query_yes_width)
width = query_yes_width;
- else
- width += 44;
icn->extent.x0 = x = icn->extent.x1 - width;
/* set the text of the 'No' button and size accordingly */
@@ -153,10 +152,9 @@
error->errnum, error->errmess));
width = len * 16;
}
+ width += 28;
if (width < query_no_width)
width = query_no_width;
- else
- width += 28;
icn->extent.x0 = icn->extent.x1 - width;
error = xwimp_create_window(query_template, &qw->window);
17 years
r2928 jmb - /trunk/netsurf/riscos/window.c
by netsurf@semichrome.net
Author: jmb
Date: Thu Sep 7 21:39:37 2006
New Revision: 2928
URL: http://svn.semichrome.net?rev=2928&view=rev
Log:
Lose noisy logging
Modified:
trunk/netsurf/riscos/window.c
Modified: trunk/netsurf/riscos/window.c
URL: http://svn.semichrome.net/trunk/netsurf/riscos/window.c?rev=2928&r1=2927&...
==============================================================================
--- trunk/netsurf/riscos/window.c (original)
+++ trunk/netsurf/riscos/window.c Thu Sep 7 21:39:37 2006
@@ -1990,7 +1990,6 @@
browser_window_mouse_track(g->bw,
ro_gui_mouse_drag_state(pointer->buttons),
pos.x, pos.y);
- LOG(("(%i, %i) -> (%i, %i)", pointer->pos.x, pointer->pos.y, pos.x, pos.y));
}
17 years
r2927 jmb - /trunk/netsurf/gtk/gtk_window.c
by netsurf@semichrome.net
Author: jmb
Date: Thu Sep 7 21:27:59 2006
New Revision: 2927
URL: http://svn.semichrome.net?rev=2927&view=rev
Log:
Fix GTK build
Modified:
trunk/netsurf/gtk/gtk_window.c
Modified: trunk/netsurf/gtk/gtk_window.c
URL: http://svn.semichrome.net/trunk/netsurf/gtk/gtk_window.c?rev=2927&r1=2926...
==============================================================================
--- trunk/netsurf/gtk/gtk_window.c (original)
+++ trunk/netsurf/gtk/gtk_window.c Thu Sep 7 21:27:59 2006
@@ -965,16 +965,6 @@
}
-int gui_window_get_width(struct gui_window* g)
-{
- return GTK_WIDGET(g->drawing_area)->allocation.width;
-}
-
-int gui_window_get_height(struct gui_window* g)
-{
- return GTK_WIDGET(g->drawing_area)->allocation.height;
-}
-
void gui_window_update_extent(struct gui_window *g)
{
if (!g->bw->current_content)
@@ -1197,10 +1187,16 @@
}
-void gui_window_get_dimensions(struct gui_window *g, int *width, int *height)
-{
- *width = 1;
- *height = 1;
+void gui_window_get_dimensions(struct gui_window *g, int *width, int *height,
+ bool scaled)
+{
+ *width = GTK_WIDGET(g->drawing_area)->allocation.width;
+ *height = GTK_WIDGET(g->drawing_area)->allocation.height;
+
+ if (scaled) {
+ *width /= g->scale;
+ *height /= g->scale;
+ }
}
void gui_window_position_frame(struct gui_window *g, int x0, int y0, int x1, int y1)
17 years
r2925 jmb - in /trunk/netsurf/riscos: gui.c window.c
by netsurf@semichrome.net
Author: jmb
Date: Thu Sep 7 10:44:50 2006
New Revision: 2925
URL: http://svn.semichrome.net?rev=2925&view=rev
Log:
Fix dataload stupidities
Modified:
trunk/netsurf/riscos/gui.c
trunk/netsurf/riscos/window.c
Modified: trunk/netsurf/riscos/gui.c
URL: http://svn.semichrome.net/trunk/netsurf/riscos/gui.c?rev=2925&r1=2924&r2=...
==============================================================================
--- trunk/netsurf/riscos/gui.c (original)
+++ trunk/netsurf/riscos/gui.c Thu Sep 7 10:44:50 2006
@@ -1369,10 +1369,12 @@
g = ro_gui_window_lookup(message->data.data_xfer.w);
if (g) {
- while (g->bw->parent)
- g = g->bw->parent->window;
if (ro_gui_window_dataload(g, message))
return;
+
+ /* Get top-level window for loading into */
+ while (g->bw->parent)
+ g = g->bw->parent->window;
}
else {
g = ro_gui_toolbar_lookup(message->data.data_xfer.w);
Modified: trunk/netsurf/riscos/window.c
URL: http://svn.semichrome.net/trunk/netsurf/riscos/window.c?rev=2925&r1=2924&...
==============================================================================
--- trunk/netsurf/riscos/window.c (original)
+++ trunk/netsurf/riscos/window.c Thu Sep 7 10:44:50 2006
@@ -2719,7 +2719,7 @@
return false;
if (!ro_gui_window_to_window_pos(g, message->data.data_xfer.pos.x,
- message->data.data_xfer.pos.x, &pos))
+ message->data.data_xfer.pos.y, &pos))
return false;
content = bw->current_content;
17 years
r2924 rjw - in /trunk/netsurf: desktop/browser.c desktop/gui.h riscos/gui.h riscos/menus.c riscos/textselection.c riscos/theme.c riscos/theme.h riscos/treeview.c riscos/treeview.h riscos/window.c
by netsurf@semichrome.net
Author: rjw
Date: Wed Sep 6 23:15:58 2006
New Revision: 2924
URL: http://svn.semichrome.net?rev=2924&view=rev
Log:
Simplify and tidy up RISC OS gui_ functions. Fix toolbar height changing issues for framesets.
Modified:
trunk/netsurf/desktop/browser.c
trunk/netsurf/desktop/gui.h
trunk/netsurf/riscos/gui.h
trunk/netsurf/riscos/menus.c
trunk/netsurf/riscos/textselection.c
trunk/netsurf/riscos/theme.c
trunk/netsurf/riscos/theme.h
trunk/netsurf/riscos/treeview.c
trunk/netsurf/riscos/treeview.h
trunk/netsurf/riscos/window.c
Modified: trunk/netsurf/desktop/browser.c
URL: http://svn.semichrome.net/trunk/netsurf/desktop/browser.c?rev=2924&r1=292...
==============================================================================
--- trunk/netsurf/desktop/browser.c (original)
+++ trunk/netsurf/desktop/browser.c Wed Sep 6 23:15:58 2006
@@ -263,7 +263,7 @@
assert(bw);
/* update window dimensions */
- gui_window_get_dimensions(bw->window, &bw_width, &bw_height);
+ gui_window_get_dimensions(bw->window, &bw_width, &bw_height, false);
if (!bw->parent) {
bw->x0 = 0;
bw->y0 = 0;
@@ -383,7 +383,7 @@
/* window dimensions */
if (!bw->parent) {
- gui_window_get_dimensions(bw->window, &bw_width, &bw_height);
+ gui_window_get_dimensions(bw->window, &bw_width, &bw_height, false);
bw->x0 = 0;
bw->y0 = 0;
bw->x1 = bw_width;
@@ -751,6 +751,7 @@
char url_buf[256];
int depth = 0;
struct browser_window *cur;
+ int width, height;
LOG(("bw %p, url %s", bw, url));
assert(bw);
@@ -810,13 +811,13 @@
browser_window_remove_caret(bw);
browser_window_destroy_children(bw);
+ gui_window_get_dimensions(bw->window, &width, &height, true);
+
browser_window_set_status(bw, messages_get("Loading"));
bw->history_add = history_add;
bw->time0 = clock();
c = fetchcache(url2, browser_window_callback, (intptr_t) bw, 0,
- gui_window_get_width(bw->window),
- gui_window_get_height(bw->window),
- false,
+ width, height, false,
post_urlenc, post_multipart, true, download);
free(url2);
if (!c) {
@@ -835,9 +836,7 @@
bw->download = download;
fetchcache_go(c, option_send_referer ? referer : 0,
- browser_window_callback, (intptr_t) bw, 0,
- gui_window_get_width(bw->window),
- gui_window_get_height(bw->window),
+ browser_window_callback, (intptr_t) bw, 0, width, height,
post_urlenc, post_multipart, true);
}
Modified: trunk/netsurf/desktop/gui.h
URL: http://svn.semichrome.net/trunk/netsurf/desktop/gui.h?rev=2924&r1=2923&r2...
==============================================================================
--- trunk/netsurf/desktop/gui.h (original)
+++ trunk/netsurf/desktop/gui.h Wed Sep 6 23:15:58 2006
@@ -67,9 +67,8 @@
int x1, int y1);
void gui_window_position_frame(struct gui_window *g, int x0, int y0,
int x1, int y1);
-void gui_window_get_dimensions(struct gui_window *g, int *width, int *height);
-int gui_window_get_width(struct gui_window *g);
-int gui_window_get_height(struct gui_window *g);
+void gui_window_get_dimensions(struct gui_window *g, int *width, int *height,
+ bool scaled);
void gui_window_update_extent(struct gui_window *g);
void gui_window_set_status(struct gui_window *g, const char *text);
void gui_window_set_pointer(struct gui_window *g, gui_pointer_shape shape);
@@ -83,8 +82,8 @@
bool gui_window_scroll_start(struct gui_window *g);
bool gui_window_box_scroll_start(struct gui_window *g,
int x0, int y0, int x1, int y1);
+bool gui_window_frame_resize_start(struct gui_window *g);
void gui_window_save_as_link(struct gui_window *g, struct content *c);
-bool gui_window_frame_resize_start(struct gui_window *g);
struct gui_download_window *gui_download_window_create(const char *url,
const char *mime_type, struct fetch *fetch,
Modified: trunk/netsurf/riscos/gui.h
URL: http://svn.semichrome.net/trunk/netsurf/riscos/gui.h?rev=2924&r1=2923&r2=...
==============================================================================
--- trunk/netsurf/riscos/gui.h (original)
+++ trunk/netsurf/riscos/gui.h Wed Sep 6 23:15:58 2006
@@ -137,7 +137,6 @@
/* in window.c */
void ro_gui_window_quit(void);
void ro_gui_window_update_theme(void);
-void ro_gui_window_update_dimensions(struct gui_window *g, int yscroll);
void ro_gui_window_mouse_at(struct gui_window *g, wimp_pointer *pointer);
bool ro_gui_toolbar_click(wimp_pointer *pointer);
bool ro_gui_status_click(wimp_pointer *pointer);
@@ -146,9 +145,8 @@
struct gui_window *ro_gui_toolbar_lookup(wimp_w window);
struct gui_window *ro_gui_status_lookup(wimp_w window);
void ro_gui_scroll_request(wimp_scroll *scroll);
-int window_x_units(int x, wimp_window_state *state);
-int window_y_units(int y, wimp_window_state *state);
-bool window_screen_pos(struct gui_window *g, int x, int y, os_coord *pos);
+bool ro_gui_window_to_window_pos(struct gui_window *g, int x, int y, os_coord *pos);
+bool ro_gui_window_to_screen_pos(struct gui_window *g, int x, int y, os_coord *pos);
bool ro_gui_window_dataload(struct gui_window *g, wimp_message *message);
bool ro_gui_toolbar_dataload(struct gui_window *g, wimp_message *message);
void ro_gui_window_process_reformats(void);
Modified: trunk/netsurf/riscos/menus.c
URL: http://svn.semichrome.net/trunk/netsurf/riscos/menus.c?rev=2924&r1=2923&r...
==============================================================================
--- trunk/netsurf/riscos/menus.c (original)
+++ trunk/netsurf/riscos/menus.c Wed Sep 6 23:15:58 2006
@@ -447,10 +447,9 @@
* Display a menu.
*/
void ro_gui_menu_create(wimp_menu *menu, int x, int y, wimp_w w) {
- int doc_x, doc_y;
- wimp_window_state state;
struct gui_window *g;
os_error *error;
+ os_coord pos;
int i;
menu_action action;
struct menu_definition *definition;
@@ -467,26 +466,14 @@
/* read the object under the pointer for a new gui_window menu */
if ((!current_menu) && (menu == browser_menu)) {
- state.w = w;
- error = xwimp_get_window_state(&state);
- if (error) {
- LOG(("xwimp_get_window_state: 0x%x: %s",
- error->errnum, error->errmess));
- warn_user("WimpError", error->errmess);
+ g = ro_gui_window_lookup(w);
+
+ if (!ro_gui_window_to_window_pos(g, x, y, &pos))
return;
- }
-
- g = ro_gui_window_lookup(w);
- assert(g);
-
- doc_x = window_x_units(x, &state) / 2 / g->option.scale;
- doc_y = -window_y_units(y, &state) / 2 / g->option.scale;
-
current_menu_object_box = NULL;
if (g->bw->current_content &&
g->bw->current_content->type == CONTENT_HTML)
- current_menu_object_box = box_object_at_point(
- g->bw->current_content, doc_x, doc_y);
+ current_menu_object_box = box_object_at_point(g->bw->current_content, pos.x, pos.y);
}
/* store the menu characteristics */
@@ -776,17 +763,13 @@
* \param toolbar the toolbar to update
*/
void ro_gui_menu_refresh_toolbar(struct toolbar *toolbar) {
- int height;
assert(toolbar);
toolbar->reformat_buttons = true;
- height = toolbar->height;
ro_gui_theme_process_toolbar(toolbar, -1);
if (toolbar->type == THEME_BROWSER_TOOLBAR) {
- ro_gui_window_update_dimensions(
- ro_gui_window_lookup(current_menu_window),
- height - toolbar->height);
+ gui_window_update_extent(ro_gui_window_lookup(current_menu_window));
} else if (toolbar->type == THEME_HOTLIST_TOOLBAR) {
tree_resized(hotlist_tree);
xwimp_force_redraw((wimp_w)hotlist_tree->handle,
@@ -794,6 +777,10 @@
} else if (toolbar->type == THEME_HISTORY_TOOLBAR) {
tree_resized(global_history_tree);
xwimp_force_redraw((wimp_w)global_history_tree->handle,
+ 0,-16384, 16384, 16384);
+ } else if (toolbar->type == THEME_COOKIES_TOOLBAR) {
+ tree_resized(cookies_tree);
+ xwimp_force_redraw((wimp_w)cookies_tree->handle,
0,-16384, 16384, 16384);
}
}
Modified: trunk/netsurf/riscos/textselection.c
URL: http://svn.semichrome.net/trunk/netsurf/riscos/textselection.c?rev=2924&r...
==============================================================================
--- trunk/netsurf/riscos/textselection.c (original)
+++ trunk/netsurf/riscos/textselection.c Wed Sep 6 23:15:58 2006
@@ -137,10 +137,9 @@
void ro_gui_selection_drag_end(struct gui_window *g, wimp_dragged *drag)
{
wimp_auto_scroll_info scroll;
- wimp_window_state state;
wimp_pointer pointer;
os_error *error;
- int x, y;
+ os_coord pos;
LOG(("ending text selection drag"));
@@ -167,20 +166,10 @@
return;
}
- 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;
- }
-
- x = window_x_units(drag->final.x0, &state) / 2 / g->option.scale;
- y = -window_y_units(drag->final.y0, &state) / 2 / g->option.scale;
-
- browser_window_mouse_drag_end(g->bw,
- ro_gui_mouse_click_state(pointer.buttons), x, y);
+ 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);
}
@@ -369,7 +358,7 @@
os_error *error;
os_coord pos;
- if (!window_screen_pos(g, x, y, &pos))
+ if (!ro_gui_window_to_screen_pos(g, x, y, &pos))
return;
msg.size = sizeof(msg);
@@ -510,15 +499,13 @@
struct box *textarea = NULL;
struct box *text_box = NULL;
struct browser_window *bw;
- wimp_window_state state;
struct content *content;
int gadget_box_x = 0;
int gadget_box_y = 0;
struct gui_window *g;
- os_error *error;
+ os_coord pos;
int box_x = 0;
int box_y = 0;
- int x, y;
/* with autoscrolling, we will probably need to remember the gui_window and
override the drag->w window handle which could be any window on the desktop */
@@ -535,20 +522,8 @@
return;
}
- state.w = drag->w;
- error = xwimp_get_window_state(&state);
- if (error) {
- LOG(("xwimp_get_window_state: 0x%x: %s\n",
- error->errnum, error->errmess));
- warn_user("WimpError", error->errmess);
- drag_claimed = false;
+ if (!ro_gui_window_to_window_pos(g, drag->pos.x, drag->pos.y, &pos))
return;
- }
-
- x = window_x_units(drag->pos.x, &state) / 2 /
- g->option.scale;
- y = -window_y_units(drag->pos.y, &state) / 2 /
- g->option.scale;
bw = g->bw;
content = bw->current_content;
@@ -557,7 +532,7 @@
struct box *box = content->data.html.layout;
- while ((box = box_at_point(box, x, y, &box_x, &box_y, &content))) {
+ while ((box = box_at_point(box, pos.x, pos.y, &box_x, &box_y, &content))) {
if (box->style &&
box->style->visibility == CSS_VISIBILITY_HIDDEN)
continue;
@@ -591,8 +566,8 @@
else
gui_window_set_pointer(g, GUI_POINTER_CARET);
- text_box = textarea_get_position(textarea, x - gadget_box_x,
- y - gadget_box_y, &char_offset, &pixel_offset);
+ text_box = textarea_get_position(textarea, pos.x - gadget_box_x,
+ pos.y - gadget_box_y, &char_offset, &pixel_offset);
caret_set_position(&ghost_caret, bw, text_box, char_offset, pixel_offset);
drag_claimed = true;
Modified: trunk/netsurf/riscos/theme.c
URL: http://svn.semichrome.net/trunk/netsurf/riscos/theme.c?rev=2924&r1=2923&r...
==============================================================================
--- trunk/netsurf/riscos/theme.c (original)
+++ trunk/netsurf/riscos/theme.c Wed Sep 6 23:15:58 2006
@@ -568,6 +568,9 @@
/* apply the theme to all the current windows */
ro_gui_window_update_theme();
+ ro_gui_tree_update_theme(hotlist_tree);
+ ro_gui_tree_update_theme(global_history_tree);
+ ro_gui_tree_update_theme(cookies_tree);
ro_gui_theme_close(theme_previous, false);
return true;
}
@@ -833,6 +836,7 @@
ro_gui_theme_destroy_toolbar(toolbar);
return NULL;
}
+ toolbar->old_height = ro_gui_theme_toolbar_full_height(toolbar);
return toolbar;
}
@@ -1751,7 +1755,6 @@
* \param toolbar the toolbar to toggle editing for
*/
void ro_gui_theme_toggle_edit(struct toolbar *toolbar) {
- int height;
int icons = 0;
struct toolbar_icon *icon;
struct gui_window *g = NULL;
@@ -1812,14 +1815,13 @@
}
/* turn off editing */
- height = toolbar->editor->height;
ro_gui_theme_destroy_toolbar(toolbar->editor);
toolbar->editor = NULL;
ro_gui_theme_update_toolbar(toolbar->descriptor, toolbar);
switch (toolbar->type) {
case THEME_BROWSER_TOOLBAR:
if (g)
- ro_gui_window_update_dimensions(g, height);
+ gui_window_update_extent(g);
break;
default:
if (toolbar->parent_handle)
@@ -1863,8 +1865,7 @@
switch (toolbar->type) {
case THEME_BROWSER_TOOLBAR:
if (g)
- ro_gui_window_update_dimensions(g,
- -toolbar->editor->height);
+ gui_window_update_extent(g);
break;
default:
if (toolbar->parent_handle) {
@@ -2426,3 +2427,12 @@
if (toolbar->status_width > 10000) toolbar->status_width = 10000;
ro_gui_theme_process_toolbar(toolbar, -1);
}
+
+int ro_gui_theme_height_change(struct toolbar *toolbar) {
+ int height, cur_height;
+
+ cur_height = ro_gui_theme_toolbar_full_height(toolbar);
+ height = toolbar->old_height - cur_height;
+ toolbar->old_height = cur_height;
+ return height;
+}
Modified: trunk/netsurf/riscos/theme.h
URL: http://svn.semichrome.net/trunk/netsurf/riscos/theme.h?rev=2924&r1=2923&r...
==============================================================================
--- trunk/netsurf/riscos/theme.h (original)
+++ trunk/netsurf/riscos/theme.h Wed Sep 6 23:15:58 2006
@@ -108,6 +108,7 @@
int toolbar_current; /**< the size of the toolbar window in OS units */
int height; /**< vertical extent of the toolbar (read only) */
int max_height; /**< allowed vertical extent (read only) */
+ int old_height; /**< height on last test (read only) */
wimp_w toolbar_handle; /**< toolbar window handle */
wimp_w status_handle; /**< status window handle (if applicable) */
wimp_w parent_handle; /**< parent window handle (read only) */
@@ -162,6 +163,8 @@
void ro_gui_theme_toolbar_editor_click(struct toolbar *toolbar, wimp_pointer *pointer);
void ro_gui_theme_toolbar_editor_drag_end(wimp_dragged *drag);
+int ro_gui_theme_height_change(struct toolbar *toolbar);
+
struct toolbar_icon *ro_gui_theme_toolbar_get_icon(struct toolbar *toolbar, int x, int y);
#define ro_gui_theme_toolbar_height(toolbar) toolbar->height + \
Modified: trunk/netsurf/riscos/treeview.c
URL: http://svn.semichrome.net/trunk/netsurf/riscos/treeview.c?rev=2924&r1=292...
==============================================================================
--- trunk/netsurf/riscos/treeview.c (original)
+++ trunk/netsurf/riscos/treeview.c Wed Sep 6 23:15:58 2006
@@ -1490,3 +1490,20 @@
int ro_gui_tree_help(int x, int y) {
return -1;
}
+
+
+void ro_gui_tree_update_theme(struct tree *tree) {
+ if ((tree) && (tree->toolbar)) {
+ if (tree->toolbar->editor)
+ if (!ro_gui_theme_update_toolbar(NULL, tree->toolbar->editor))
+ tree->toolbar->editor = NULL;
+ if (!ro_gui_theme_update_toolbar(NULL, tree->toolbar)) {
+ ro_gui_theme_destroy_toolbar(tree->toolbar);
+ tree->toolbar = NULL;
+ }
+ ro_gui_theme_toolbar_editor_sync(tree->toolbar);
+ ro_gui_theme_attach_toolbar(tree->toolbar, (wimp_w)tree->handle);
+ tree_resized(tree);
+ xwimp_force_redraw((wimp_w)tree->handle, 0, -16384, 16384, 16384);
+ }
+}
Modified: trunk/netsurf/riscos/treeview.h
URL: http://svn.semichrome.net/trunk/netsurf/riscos/treeview.h?rev=2924&r1=292...
==============================================================================
--- trunk/netsurf/riscos/treeview.h (original)
+++ trunk/netsurf/riscos/treeview.h Wed Sep 6 23:15:58 2006
@@ -45,5 +45,6 @@
void ro_gui_tree_get_tree_coordinates(struct tree *tree, int x, int y,
int *tree_x, int *tree_y);
int ro_gui_tree_help(int x, int y);
+void ro_gui_tree_update_theme(struct tree *tree);
#endif
Modified: trunk/netsurf/riscos/window.c
URL: http://svn.semichrome.net/trunk/netsurf/riscos/window.c?rev=2924&r1=2923&...
==============================================================================
--- trunk/netsurf/riscos/window.c (original)
+++ trunk/netsurf/riscos/window.c Wed Sep 6 23:15:58 2006
@@ -79,6 +79,41 @@
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))
+
+
+/** An entry in ro_gui_pointer_table. */
+struct ro_gui_pointer_entry {
+ bool wimp_area; /** The pointer is in the Wimp's sprite area. */
+ char sprite_name[12];
+ 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 },
+};
+
+
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);
@@ -104,6 +139,7 @@
struct update_box *pending_updates;
#define MARGIN 4
+
/**
* Create and open a new browser window.
@@ -194,7 +230,7 @@
} else {
/* Base how we define the window height/width
- on the compile time options set */
+ on the compile time options set */
win_width = screen_width * 3 / 4;
if (1600 < win_width)
win_width = 1600;
@@ -264,7 +300,7 @@
unsigned int col;
col = bw->border_colour & 0xffffff;
sprintf(g->validation, "C%.6x", col);
- window.extra_flags |= wimp_WINDOW_USE_TITLE_VALIDATION_STRING;
+ window.extra_flags |= wimp_WINDOW_USE_TITLE_VALIDATION_STRING;
window.title_data.indirected_text.validation = g->validation;
}
break;
@@ -273,7 +309,7 @@
wimp_WINDOW_BACK_ICON |
wimp_WINDOW_CLOSE_ICON |
wimp_WINDOW_TITLE_ICON |
- wimp_WINDOW_TOGGLE_ICON;
+ wimp_WINDOW_TOGGLE_ICON;
break;
}
@@ -334,7 +370,7 @@
}
state.next = wimp_TOP;
if (bw->parent) {
- top = browser_window_owner(bw);
+ top = browser_window_owner(bw);
error = xwimp_open_window_nested((wimp_open *)&state, top->window->window,
wimp_CHILD_LINKS_PARENT_WORK_AREA
<< wimp_CHILD_XORIGIN_SHIFT |
@@ -388,40 +424,21 @@
if (g->next)
g->next->prev = g->prev;
+ /* destroy toolbar */
if (g->toolbar)
ro_gui_theme_destroy_toolbar(g->toolbar);
-
- /* remove our wimp event bindings */
+
+ /* delete window */
+ ro_gui_dialog_close(g->window);
+ error = xwimp_delete_window(g->window);
+ if (error) {
+ LOG(("xwimp_delete_window: 0x%x: %s",
+ error->errnum, error->errmess));
+ warn_user("WimpError", error->errmess);
+ }
ro_gui_wimp_event_finalise(g->window);
- /* delete window */
- error = xwimp_delete_window(g->window);
- if (error) {
- LOG(("xwimp_delete_window: 0x%x: %s",
- error->errnum, error->errmess));
- warn_user("WimpError", error->errmess);
- }
-
free(g);
-}
-
-
-/**
- * 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);
- }
}
@@ -457,22 +474,6 @@
/**
- * 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);
-}
-
-
-/**
* Force a redraw of part of the contents of a browser window.
*
* \param g gui_window to redraw
@@ -498,6 +499,857 @@
/**
+ * 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)
+{
+ wimp_window_info info;
+ os_error *error;
+
+ assert(g);
+
+ info.w = g->window;
+ 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;
+ }
+
+ 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);
+ }
+}
+
+
+/**
+ * Redraw an area of a window.
+ *
+ * \param g gui_window
+ * \param data content_msg_data union with filled in redraw data
+ */
+
+void gui_window_update_box(struct gui_window *g,
+ const union content_msg_data *data)
+{
+ struct content *c = g->bw->current_content;
+ bool use_buffer;
+ int x0, y0, x1, y1;
+ struct update_box *cur;
+
+ if (!c)
+ return;
+
+ x0 = floorf(data->redraw.x * 2 * g->option.scale);
+ y0 = -ceilf((data->redraw.y + data->redraw.height) * 2 * g->option.scale);
+ x1 = ceilf((data->redraw.x + data->redraw.width) * 2 * g->option.scale) + 1;
+ y1 = -floorf(data->redraw.y * 2 * g->option.scale) + 1;
+ use_buffer = (data->redraw.full_redraw) &&
+ (g->option.buffer_everything || g->option.buffer_animations);
+
+ /* 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;
+ }
+
+ }
+ }
+ cur = malloc(sizeof(struct update_box));
+ if (!cur) {
+ LOG(("No memory for malloc."));
+ warn_user("NoMemory", 0);
+ return;
+ }
+ 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;
+}
+
+
+/**
+ * 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
+ */
+
+bool gui_window_get_scroll(struct gui_window *g, int *sx, int *sy)
+{
+ wimp_window_state state;
+ os_error *error;
+ int toolbar_height = 0;
+
+ 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;
+ }
+
+ if (g->toolbar)
+ toolbar_height = ro_gui_theme_toolbar_full_height(g->toolbar);
+ *sx = state.xscroll / (2 * g->option.scale);
+ *sy = -(state.yscroll - toolbar_height) / (2 * g->option.scale);
+ return true;
+}
+
+
+/**
+ * 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
+ */
+
+void gui_window_set_scroll(struct gui_window *g, int sx, int sy)
+{
+ wimp_window_state state;
+ os_error *error;
+
+ 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;
+ }
+
+ state.xscroll = sx * 2 * g->option.scale;
+ state.yscroll = -sy * 2 * g->option.scale;
+ if (g->toolbar)
+ state.yscroll += ro_gui_theme_toolbar_full_height(g->toolbar);
+ ro_gui_window_open((wimp_open *) &state);
+}
+
+
+/**
+ * Scrolls the specified area of a browser window into view.
+ *
+ * \param g gui_window to scroll
+ * \param x0 left point to ensure visible
+ * \param y0 bottom point to ensure visible
+ * \param x1 right point to ensure visible
+ * \param y1 top point to ensure visible
+ */
+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)
+ toolbar_height = ro_gui_theme_toolbar_full_height(g->toolbar);
+
+ x0 = x0 * 2 * g->option.scale;
+ y0 = y0 * 2 * g->option.scale;
+ x1 = x1 * 2 * g->option.scale;
+ y1 = y1 * 2 * g->option.scale;
+
+ cx0 = state.xscroll;
+ cy0 = -state.yscroll + toolbar_height;
+ width = state.visible.x1 - state.visible.x0;
+ height = state.visible.y1 - state.visible.y0 - toolbar_height;
+
+ /* 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) {
+ 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;
+ }
+ padding_available = (height - y1 + y0) / 2;
+ if (padding_available > 0) {
+ 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;
+ }
+
+ state.xscroll = cx0;
+ state.yscroll = -cy0 + toolbar_height;
+ ro_gui_window_open((wimp_open *)&state);
+}
+
+
+/**
+ * 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;
+ int toolbar_height = 0;
+ struct browser_window *bw;
+ struct browser_window *parent;
+ struct browser_window *top;
+
+ assert(g);
+ bw = g->bw;
+ assert(bw);
+ parent = bw->parent;
+ assert(parent);
+ top = browser_window_owner(bw);
+
+ /* store position for children */
+ if (parent->browser_window_type == BROWSER_WINDOW_IFRAME) {
+ bw->x0 = x0;
+ bw->y0 = y0;
+ bw->x1 = x1;
+ bw->y1 = y1;
+ } else {
+ bw->x0 = x0 = parent->x0 + x0;
+ bw->y0 = y0 = parent->y0 + y0;
+ bw->x1 = x1 = parent->x0 + x1;
+ bw->y1 = y1 = parent->y0 + y1;
+ }
+
+ /* 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;
+ }
+ if (top->window->toolbar)
+ toolbar_height = ro_gui_theme_toolbar_full_height(top->window->toolbar);
+ px0 = state.visible.x0;
+ py1 = state.visible.y1 - toolbar_height;
+
+ /* 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;
+ }
+
+ x1 *= 2;
+ y1 *= 2;
+
+ /* 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;
+ }
+ state.visible.x0 = px0 + x0 * 2;
+ state.visible.y0 = py1 - y1;
+ state.visible.x1 = px0 + x1;
+ state.visible.y1 = py1 - y0 * 2;
+ ro_gui_window_open((wimp_open *)&state);
+}
+
+
+/**
+ * Find the current dimensions of a browser window's content area.
+ *
+ * \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
+ */
+
+void gui_window_get_dimensions(struct gui_window *g, int *width, int *height, bool scaled)
+{
+ wimp_window_state state;
+ os_error *error;
+
+ /* get the dimensions */
+ 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);
+ *width = 0;
+ *height = 0;
+ return;
+ }
+
+ *width = (state.visible.x1 - state.visible.x0) / 2;
+ *height = ((state.visible.y1 - state.visible.y0) -
+ (g->toolbar ? ro_gui_theme_toolbar_full_height(g->toolbar) : 0)) / 2;
+ if (scaled) {
+ *width /= g->option.scale;
+ *height /= g->option.scale;
+ }
+}
+
+
+/**
+ * Update the extent of the inside of a browser window to that of the current content.
+ *
+ * \param g gui_window to update the extent of
+ */
+
+void gui_window_update_extent(struct gui_window *g)
+{
+ os_error *error;
+ wimp_window_state state;
+ bool update;
+ unsigned int flags;
+ int scroll = 0;
+
+ 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;
+ }
+ g->old_height = -1;
+
+ /* scroll on toolbar height change */
+ if (g->toolbar) {
+ scroll = ro_gui_theme_height_change(g->toolbar);
+ state.yscroll -= scroll;
+ if (state.yscroll < 0)
+ state.yscroll = 0;
+ }
+
+ /* only allow a further reformat if we've gained/lost scrollbars */
+ flags = state.flags & (wimp_WINDOW_HSCROLL | wimp_WINDOW_VSCROLL);
+ update = g->reformat_pending;
+ ro_gui_window_open((wimp_open *)&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 (flags == (state.flags & (wimp_WINDOW_HSCROLL | wimp_WINDOW_VSCROLL)))
+ g->reformat_pending = update;
+
+ if ((scroll != 0) && (g->bw->children))
+ browser_window_recalculate_frameset(g->bw);
+}
+
+
+/**
+ * Set the status bar of a browser window.
+ *
+ * \param g gui_window to update
+ * \param text new status text
+ */
+
+void gui_window_set_status(struct gui_window *g, const char *text)
+{
+ if ((!g->toolbar) || (!g->toolbar->status_handle))
+ return;
+
+ ro_gui_set_icon_string(g->toolbar->status_handle,
+ ICON_STATUS_TEXT, text);
+}
+
+
+/**
+ * Change mouse pointer shape
+ */
+
+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;
+ os_error *error;
+
+ 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);
+ if (error) {
+ 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;
+ char *toolbar_url;
+
+ if (!g->toolbar)
+ return;
+
+ ro_gui_set_icon_string(g->toolbar->toolbar_handle,
+ ICON_TOOLBAR_URL, url);
+ 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",
+ error->errnum, error->errmess));
+ warn_user("WimpError", error->errmess);
+ return;
+ }
+
+ 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,
+ ICON_TOOLBAR_THROBBER, throb_buf);
+ 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,
+ x * 2 * g->option.scale,
+ -(y + height) * 2 * g->option.scale,
+ height * 2 * g->option.scale, -1);
+ 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;
+ }
+
+ 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;
+ drag.bbox.x0 = pointer.pos.x + (int)(x0 * 2 * g->option.scale);
+ drag.bbox.y0 = pointer.pos.y + (int)(y0 * 2 * g->option.scale);
+ drag.bbox.x1 = pointer.pos.x + (int)(x1 * 2 * g->option.scale);
+ drag.bbox.y1 = pointer.pos.y + (int)(y1 * 2 * g->option.scale);
+
+ 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;
+ int row = -1, col = -1, i;
+ struct browser_window *top, *bw;
+ wimp_window_state state;
+
+ /* get the maximum drag box (collapse all surrounding frames */
+ bw = g->bw;
+ x0 = bw->x0;
+ y0 = bw->y0;
+ x1 = bw->x1;
+ y1 = bw->y1;
+ for (i = 0; i < (bw->parent->cols * bw->parent->rows); i++) {
+ if (&bw->parent->children[i] == bw) {
+ col = i % bw->parent->cols;
+ row = i / bw->parent->cols;
+ }
+ }
+ assert((row >= 0) && (col >= 0));
+
+ if (g->bw->drag_resize_left)
+ x0 = bw->parent->children[row * bw->parent->cols + (col - 1)].x0;
+ if (g->bw->drag_resize_right)
+ x1 = bw->parent->children[row * bw->parent->cols + (col + 1)].x1;
+ if (g->bw->drag_resize_up)
+ y0 = bw->parent->children[(row - 1) * bw->parent->cols + col].y0;
+ if (g->bw->drag_resize_down)
+ y1 = bw->parent->children[(row + 1) * bw->parent->cols + col].y1;
+
+ /* convert to screen co-ordinates */
+ top = browser_window_owner(bw);
+ 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 false;
+ }
+ x0 = state.visible.x0 + x0 * 2;
+ y0 = state.visible.y0 + y0 * 2;
+ x1 = state.visible.x0 + x1 * 2 - 1;
+ y1 = state.visible.y0 + y1 * 2 - 1;
+
+ /* 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 */
+ if (!(g->bw->drag_resize_left || g->bw->drag_resize_right)) {
+ x0 = pointer.pos.x;
+ x1 = pointer.pos.x;
+ }
+ if (!(g->bw->drag_resize_up || g->bw->drag_resize_down)) {
+ y0 = pointer.pos.y;
+ y1 = pointer.pos.y;
+ }
+
+ /* start the drag */
+ drag.type = wimp_DRAG_USER_POINT;
+ drag.bbox.x0 = x0;
+ drag.bbox.y0 = y0;
+ drag.bbox.x1 = x1;
+ drag.bbox.y1 = y1;
+
+ 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;
+}
+
+
+/**
* Redraws the content for all windows.
*/
@@ -507,39 +1359,6 @@
for (g = window_list; g; g = g->next)
gui_window_redraw_window(g);
}
-
-
-/**
- * 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)
-{
- wimp_window_info info;
- os_error *error;
-
- assert(g);
-
- info.w = g->window;
- 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;
- }
-
- 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);
- }
-}
-
/**
* Handle a Redraw_Window_Request for a browser window.
@@ -761,504 +1580,6 @@
}
}
-/**
- * Redraw an area of a window.
- *
- * \param g gui_window
- * \param data content_msg_data union with filled in redraw data
- */
-
-void gui_window_update_box(struct gui_window *g,
- const union content_msg_data *data)
-{
- struct content *c = g->bw->current_content;
- bool use_buffer;
- int x0, y0, x1, y1;
- struct update_box *cur;
-
- if (!c)
- return;
-
- x0 = floorf(data->redraw.x * 2 * g->option.scale);
- y0 = -ceilf((data->redraw.y + data->redraw.height) * 2 * g->option.scale);
- x1 = ceilf((data->redraw.x + data->redraw.width) * 2 * g->option.scale) + 1;
- y1 = -floorf(data->redraw.y * 2 * g->option.scale) + 1;
- use_buffer = (data->redraw.full_redraw) &&
- (g->option.buffer_everything || g->option.buffer_animations);
-
- /* 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;
- }
-
- }
- }
- cur = malloc(sizeof(struct update_box));
- if (!cur) {
- LOG(("No memory for malloc."));
- warn_user("NoMemory", 0);
- return;
- }
- 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;
-}
-
-
-/**
- * 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
- */
-
-bool gui_window_get_scroll(struct gui_window *g, int *sx, int *sy)
-{
- wimp_window_state state;
- os_error *error;
-
- 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;
- }
- else {
- int toolbar_height = 0;
-
- if (g->toolbar)
- toolbar_height = ro_gui_theme_toolbar_full_height(g->toolbar);
-
- *sx = state.xscroll / (2 * g->option.scale);
- *sy = -(state.yscroll - toolbar_height) / (2 * g->option.scale);
- return true;
- }
-}
-
-
-/**
- * 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
- */
-
-void gui_window_set_scroll(struct gui_window *g, int sx, int sy)
-{
- wimp_window_state state;
- os_error *error;
-
- 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;
- }
-
- state.xscroll = sx * 2 * g->option.scale;
- state.yscroll = -sy * 2 * g->option.scale;
- if (g->toolbar)
- state.yscroll += ro_gui_theme_toolbar_full_height(g->toolbar);
- ro_gui_window_open((wimp_open *) &state);
-}
-
-
-/**
- * Scrolls the specified area of a browser window into view.
- *
- * \param g gui_window to scroll
- * \param x0 left point to ensure visible
- * \param y0 bottom point to ensure visible
- * \param x1 right point to ensure visible
- * \param y1 top point to ensure visible
- */
-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)
- toolbar_height = ro_gui_theme_toolbar_full_height(g->toolbar);
-
- x0 = x0 * 2 * g->option.scale;
- y0 = y0 * 2 * g->option.scale;
- x1 = x1 * 2 * g->option.scale;
- y1 = y1 * 2 * g->option.scale;
-
- cx0 = state.xscroll;
- cy0 = -state.yscroll + toolbar_height;
- width = state.visible.x1 - state.visible.x0;
- height = state.visible.y1 - state.visible.y0 - toolbar_height;
-
- /* 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) {
- 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;
- }
- padding_available = (height - y1 + y0) / 2;
- if (padding_available > 0) {
- 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;
- }
-
- state.xscroll = cx0;
- state.yscroll = -cy0 + toolbar_height;
- ro_gui_window_open((wimp_open *)&state);
-}
-
-
-/**
- * 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;
- int toolbar_height = 0;
- struct browser_window *bw;
- struct browser_window *parent;
- struct browser_window *top;
-
- assert(g);
- bw = g->bw;
- assert(bw);
- parent = bw->parent;
- assert(parent);
- top = browser_window_owner(bw);
-
- /* store position for children */
- if (parent->browser_window_type == BROWSER_WINDOW_IFRAME) {
- bw->x0 = x0;
- bw->y0 = y0;
- bw->x1 = x1;
- bw->y1 = y1;
- } else {
- bw->x0 = x0 = parent->x0 + x0;
- bw->y0 = y0 = parent->y0 + y0;
- bw->x1 = x1 = parent->x0 + x1;
- bw->y1 = y1 = parent->y0 + y1;
- }
-
- /* 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;
- }
- if (top->window->toolbar)
- toolbar_height = ro_gui_theme_toolbar_full_height(top->window->toolbar);
- px0 = state.visible.x0;
- py1 = state.visible.y1 - toolbar_height;
-
- /* 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;
- }
-
- x1 *= 2;
- y1 *= 2;
-
- /* 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;
- }
- state.visible.x0 = px0 + x0 * 2;
- state.visible.y0 = py1 - y1;
- state.visible.x1 = px0 + x1;
- state.visible.y1 = py1 - y0 * 2;
- ro_gui_window_open((wimp_open *)&state);
-}
-
-
-/**
- * Find the current unscaled dimensions of a browser window's content area.
- *
- * \param g gui_window to measure
- */
-
-void gui_window_get_dimensions(struct gui_window *g, int *width, int *height)
-{
- wimp_window_state state;
- os_error *error;
-
- /* get the dimensions */
- 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);
- *width = 0;
- *height = 0;
- return;
- }
-
- *width = (state.visible.x1 - state.visible.x0) / 2;
- *height = (state.visible.y1 - state.visible.y0 - (g->toolbar ?
- ro_gui_theme_toolbar_full_height(g->toolbar) : 0)) / 2;
-}
-
-
-/**
- * Find the current scaled width of a browser window.
- *
- * \param g gui_window to measure
- * \return width of window
- */
-
-int gui_window_get_width(struct gui_window *g)
-{
- wimp_window_state state;
- os_error *error;
-
- 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 800;
- }
- return (state.visible.x1 - state.visible.x0) / 2 / g->option.scale;
-}
-
-
-/**
- * Find the current scaled height of a browser window.
- *
- * \param g gui_window to measure
- * \return height of window
- */
-
-int gui_window_get_height(struct gui_window *g)
-{
- wimp_window_state state;
- os_error *error;
-
- 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 800;
- }
- return (state.visible.y1 - state.visible.y0 - (g->toolbar ?
- ro_gui_theme_toolbar_full_height(g->toolbar) : 0)) /
- 2 / g->option.scale;
-}
-
-
-/**
- * Update the extent of the inside of a browser window to that of the current content.
- *
- * \param g gui_window to resize
- */
-
-void gui_window_update_extent(struct gui_window *g)
-{
- ro_gui_window_update_dimensions(g, 0);
-}
-
-
-/**
- * Forces the windows extent to be updated
- *
- * /param g the gui window to update
- * /param yscroll an amount to scroll the vertical scroll bar by
- */
-void ro_gui_window_update_dimensions(struct gui_window *g, int yscroll) {
- os_error *error;
- wimp_window_state state;
- bool update;
- unsigned int flags;
-
- if (!g) return;
- 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;
- }
- state.yscroll -= yscroll;
- g->old_height = -1;
-
- /* only allow a further reformat if we've gained/lost scrollbars */
- flags = state.flags & (wimp_WINDOW_HSCROLL | wimp_WINDOW_VSCROLL);
- update = g->reformat_pending;
- ro_gui_window_open((wimp_open *)&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 (flags == (state.flags & (wimp_WINDOW_HSCROLL | wimp_WINDOW_VSCROLL)))
- g->reformat_pending = update;
-}
-
-
-/**
- * Set the status bar of a browser window.
- *
- * \param g gui_window to update
- * \param text new status text
- */
-
-void gui_window_set_status(struct gui_window *g, const char *text)
-{
- if ((!g->toolbar) || (!g->toolbar->status_handle))
- return;
-
- ro_gui_set_icon_string(g->toolbar->status_handle,
- ICON_STATUS_TEXT, text);
-}
-
-
-/**
- * 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;
- char *toolbar_url;
-
- if (!g->toolbar)
- return;
-
- ro_gui_set_icon_string(g->toolbar->toolbar_handle,
- ICON_TOOLBAR_URL, url);
- 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",
- error->errnum, error->errmess));
- warn_user("WimpError", error->errmess);
- return;
- }
-
- 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);
-}
/**
@@ -1286,59 +1607,21 @@
/**
* Forces all windows to be set to the current theme
- *
- * /param g the gui window to update
*/
void ro_gui_window_update_theme(void) {
- int height;
struct gui_window *g;
for (g = window_list; g; g = g->next) {
if (g->toolbar) {
- height = ro_gui_theme_toolbar_height(g->toolbar);
if (g->toolbar->editor)
if (!ro_gui_theme_update_toolbar(NULL, g->toolbar->editor))
g->toolbar->editor = NULL;
if (!ro_gui_theme_update_toolbar(NULL, g->toolbar)) {
ro_gui_theme_destroy_toolbar(g->toolbar);
g->toolbar = NULL;
- if (height != 0)
- ro_gui_window_update_dimensions(g, height);
- } else {
- if (height != (ro_gui_theme_toolbar_height(g->toolbar)))
- ro_gui_window_update_dimensions(g, height -
- ro_gui_theme_toolbar_height(g->toolbar));
}
ro_gui_theme_toolbar_editor_sync(g->toolbar);
+ gui_window_update_extent(g);
}
- }
- if ((hotlist_tree) && (hotlist_tree->toolbar)) {
- if (hotlist_tree->toolbar->editor)
- if (!ro_gui_theme_update_toolbar(NULL, hotlist_tree->toolbar->editor))
- hotlist_tree->toolbar->editor = NULL;
- if (!ro_gui_theme_update_toolbar(NULL, hotlist_tree->toolbar)) {
- ro_gui_theme_destroy_toolbar(hotlist_tree->toolbar);
- hotlist_tree->toolbar = NULL;
- }
- ro_gui_theme_toolbar_editor_sync(hotlist_tree->toolbar);
- ro_gui_theme_attach_toolbar(hotlist_tree->toolbar,
- (wimp_w)hotlist_tree->handle);
- xwimp_force_redraw((wimp_w)hotlist_tree->handle,
- 0, -16384, 16384, 16384);
- }
- if ((global_history_tree) && (global_history_tree->toolbar)) {
- if (global_history_tree->toolbar->editor)
- if (!ro_gui_theme_update_toolbar(NULL,
- global_history_tree->toolbar->editor))
- global_history_tree->toolbar->editor = NULL;
- if (!ro_gui_theme_update_toolbar(NULL, global_history_tree->toolbar)) {
- ro_gui_theme_destroy_toolbar(global_history_tree->toolbar);
- global_history_tree->toolbar = NULL;
- }
- ro_gui_theme_toolbar_editor_sync(global_history_tree->toolbar);
- ro_gui_theme_attach_toolbar(global_history_tree->toolbar,
- (wimp_w)global_history_tree->handle);
- xwimp_force_redraw((wimp_w)global_history_tree->handle,
- 0, -16384, 16384, 16384);
}
}
@@ -1385,7 +1668,7 @@
if (g->toolbar)
toolbar_height = ro_gui_theme_toolbar_full_height(g->toolbar);
height -= toolbar_height;
-
+
/* work with the state from now on so we can modify flags */
state.visible.x0 = open->visible.x0;
state.visible.y0 = open->visible.y0;
@@ -1394,7 +1677,7 @@
state.xscroll = open->xscroll;
state.yscroll = open->yscroll;
state.next = open->next;
-
+
/* frameset windows shouldn't be shown */
if ((g->bw->parent) && (g->bw->children))
state.next = wimp_HIDDEN;
@@ -1405,7 +1688,7 @@
no_hscroll = (g->bw->children &&
(g->bw->browser_window_type != BROWSER_WINDOW_NORMAL));
no_vscroll = g->bw->children;
-
+
/* hscroll */
size = ro_get_hscroll_height(NULL);
if (g->bw->border)
@@ -1438,7 +1721,7 @@
}
state.flags &= ~wimp_WINDOW_HSCROLL;
}
-
+
/* vscroll */
size = ro_get_vscroll_width(NULL);
if (g->bw->border)
@@ -1476,7 +1759,7 @@
/* change extent if necessary */
if (g->old_width != width || g->old_height != height) {
if (content) {
- if (g->old_width != width) {
+ if (g->old_width != width) {
xosbyte1(osbyte_SCAN_KEYBOARD, 1 ^ 0x80, 0, &key_down);
if (key_down)
g->option.scale = (g->option.scale * width) / g->old_width;
@@ -1487,7 +1770,7 @@
g->old_width = width;
g->old_height = height;
-
+
if (content && height < content->height * 2 * g->option.scale)
height = content->height * 2 * g->option.scale;
if (content && width < content->width * 2 * g->option.scale)
@@ -1567,9 +1850,9 @@
}
free(filename);
} else {
- /* 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);
+ /* 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);
}
}
if (ro_gui_shift_pressed())
@@ -1578,7 +1861,26 @@
ro_gui_dialog_close_persistent(w);
browser_window_destroy(g->bw);
return;
-
+
+}
+
+
+/**
+ * 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);
+ }
}
@@ -1682,29 +1984,13 @@
void ro_gui_window_mouse_at(struct gui_window *g, wimp_pointer *pointer)
{
- int x, y;
- wimp_window_state state;
- os_error *error;
-
- 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));
-/*
- * the WIMP sometimes fails to realise the pointer has left a NetSurf window
- * so we get an error -- there is no gain from telling the user about this
- *
- * warn_user("WimpError", error->errmess);
-*/ return;
- }
-
- x = window_x_units(pointer->pos.x, &state) / 2 / g->option.scale;
- y = -window_y_units(pointer->pos.y, &state) / 2 / g->option.scale;
-
- browser_window_mouse_track(g->bw, ro_gui_mouse_drag_state(pointer->buttons), x, y);
+ os_coord pos;
+
+ 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);
+ LOG(("(%i, %i) -> (%i, %i)", pointer->pos.x, pointer->pos.y, pos.x, pos.y));
}
@@ -1910,131 +2196,27 @@
bool ro_gui_window_click(wimp_pointer *pointer)
{
struct gui_window *g;
- wimp_window_state state;
- os_error *error;
- int x, y;
+ os_coord pos;
g = (struct gui_window *)ro_gui_wimp_event_get_user_data(pointer->w);
/* try to close url-completion */
ro_gui_url_complete_close(g, pointer->i);
-
- state.w = pointer->w;
- error = xwimp_get_window_state(&state);
- if (error) {
- LOG(("xwimp_get_window_state: 0x%x: %s", error->errnum,
- error->errmess));
- warn_user("WimpError", error->errmess);
- return false;
- }
-
- x = window_x_units(pointer->pos.x, &state) / 2 / g->option.scale;
- y = -window_y_units(pointer->pos.y, &state) / 2 / g->option.scale;
/* set input focus */
if (pointer->buttons == wimp_CLICK_SELECT ||
pointer->buttons == wimp_CLICK_ADJUST)
gui_window_place_caret(g, -100, -100, 0);
- if (pointer->buttons == wimp_CLICK_MENU)
- ro_gui_menu_create(browser_menu, pointer->pos.x,
- pointer->pos.y, pointer->w);
- else
- browser_window_mouse_click(g->bw,
- ro_gui_mouse_click_state(pointer->buttons), x, y);
-
+ 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);
+ }
return true;
-}
-
-
-/**
- * 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,
- ICON_TOOLBAR_THROBBER, throb_buf);
- 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,
- x * 2 * g->option.scale,
- -(y + height) * 2 * g->option.scale,
- height * 2 * g->option.scale, -1);
- 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);
}
@@ -2446,28 +2628,33 @@
/**
- * Convert x from screen to window coordinates.
- *
- * \param x x coordinate / os units
- * \param state window state
- * \return x coordinate in window / os units
- */
-//#define window_x_units(x, state) (x - (state->visible.x0 - state->xscroll))
-int window_x_units(int x, wimp_window_state *state) {
- return x - (state->visible.x0 - state->xscroll);
-}
-
-
-/**
- * Convert y from screen to window coordinates.
- *
- * \param y y coordinate / os units
- * \param state window state
- * \return y coordinate in window / os units
- */
-//#define window_y_units(y, state) (y - (state->visible.y1 - state->yscroll))
-int window_y_units(int y, wimp_window_state *state) {
- return y - (state->visible.y1 - state->yscroll);
+ * Convert x,y screen co-ordinates into window co-ordinates.
+ *
+ * \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
+ */
+
+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;
+
+ 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;
+ }
+ pos->x = (x - (state.visible.x0 - state.xscroll)) / 2 / g->option.scale;
+ pos->y = ((state.visible.y1 - state.yscroll) - y) / 2 / g->option.scale;
+ return true;
}
@@ -2481,11 +2668,13 @@
* \return true iff conversion successful
*/
-bool window_screen_pos(struct gui_window *g, int x, int y, os_coord *pos)
+bool ro_gui_window_to_screen_pos(struct gui_window *g, int x, int y, os_coord *pos)
{
wimp_window_state state;
os_error *error;
+ assert(g);
+
state.w = g->window;
error = xwimp_get_window_state(&state);
if (error) {
@@ -2494,8 +2683,8 @@
warn_user("WimpError", error->errmess);
return false;
}
- pos->x = state.visible.x0 + ((x * 2 * g->option.scale) - state.xscroll);
- pos->y = state.visible.y1 + ((-y * 2 * g->option.scale) - state.yscroll);
+ pos->x = (x * 2 * g->option.scale) + (state.visible.x0 - state.xscroll);
+ pos->y = (state.visible.y1 - state.yscroll) - (y * 2 * g->option.scale);
return true;
}
@@ -2513,14 +2702,13 @@
bool ro_gui_window_dataload(struct gui_window *g, wimp_message *message)
{
int box_x = 0, box_y = 0;
- int x, y;
struct box *box;
struct box *file_box = 0;
struct box *text_box = 0;
struct browser_window *bw = g->bw;
struct content *content;
- wimp_window_state state;
os_error *error;
+ os_coord pos;
/* HTML content only. */
if (!bw->current_content || bw->current_content->type != CONTENT_HTML)
@@ -2530,24 +2718,13 @@
if (0x1000 <= message->data.data_xfer.file_type)
return false;
- /* Search for a file input or text area at the drop point. */
- state.w = message->data.data_xfer.w;
- error = xwimp_get_window_state(&state);
- if (error) {
- LOG(("xwimp_get_window_state: 0x%x: %s\n",
- error->errnum, error->errmess));
- warn_user("WimpError", error->errmess);
+ if (!ro_gui_window_to_window_pos(g, message->data.data_xfer.pos.x,
+ message->data.data_xfer.pos.x, &pos))
return false;
- }
-
- x = window_x_units(message->data.data_xfer.pos.x, &state) / 2 /
- g->option.scale;
- y = -window_y_units(message->data.data_xfer.pos.y, &state) / 2 /
- g->option.scale;
content = bw->current_content;
box = content->data.html.layout;
- while ((box = box_at_point(box, x, y, &box_x, &box_y, &content))) {
+ while ((box = box_at_point(box, pos.x, pos.y, &box_x, &box_y, &content))) {
if (box->style &&
box->style->visibility == CSS_VISIBILITY_HIDDEN)
continue;
@@ -2593,15 +2770,15 @@
file_box->gadget->value = utf8_fn;
/* Redraw box. */
- box_coords(file_box, &x, &y);
- gui_window_redraw(bw->window, x, y,
- x + file_box->width,
- y + file_box->height);
+ 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);
} else {
const char *filename = message->data.data_xfer.file_name;
- browser_window_mouse_click(g->bw, BROWSER_MOUSE_CLICK_1, x, y);
+ browser_window_mouse_click(g->bw, BROWSER_MOUSE_CLICK_1, pos.x, pos.y);
if (!ro_gui_window_import_text(g, filename, false))
return true; /* it was for us, it just didn't work! */
@@ -2666,7 +2843,7 @@
g->reformat_pending = false;
content_reformat(g->bw->current_content,
g->old_width / 2 / g->option.scale,
- gui_window_get_height(g));
+ g->old_height / 2 / g->option.scale);
}
}
@@ -2759,111 +2936,6 @@
}
-/** An entry in ro_gui_pointer_table. */
-struct ro_gui_pointer_entry {
- bool wimp_area; /** The pointer is in the Wimp's sprite area. */
- char sprite_name[12];
- 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 },
-};
-
-/**
- * Change mouse pointer shape
- */
-
-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;
- os_error *error;
-
- 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);
- if (error) {
- LOG(("xwimpspriteop_set_pointer_shape: 0x%x: %s",
- error->errnum, error->errmess));
- warn_user("WimpError", error->errmess);
- }
-}
-
-
-/**
- * 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);
-}
/**
@@ -2947,121 +3019,16 @@
/**
- * 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)
+ * 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;
- 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;
- drag.bbox.x0 = pointer.pos.x + (int)(x0 * 2 * g->option.scale);
- drag.bbox.y0 = pointer.pos.y + (int)(y0 * 2 * g->option.scale);
- drag.bbox.x1 = pointer.pos.x + (int)(x1 * 2 * g->option.scale);
- drag.bbox.y1 = pointer.pos.y + (int)(y1 * 2 * g->option.scale);
-
- 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 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;
- }
-
- gui_current_drag_type = GUI_DRAG_SCROLL;
- return true;
-}
-
-
-/**
- * Completes scrolling of a browser window
- *
- * \param g gui window
- */
-
-void ro_gui_window_scroll_end(struct gui_window *g, wimp_dragged *drag)
-{
- wimp_window_state state;
- wimp_pointer pointer;
- os_error *error;
- int x, y;
+ os_coord pos;
gui_current_drag_type = GUI_DRAG_NONE;
if (!g)
@@ -3089,115 +3056,26 @@
warn_user("WimpError", error->errmess);
}
- 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);
+ 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);
+}
+
+
+/**
+ * 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;
- }
-
- x = window_x_units(drag->final.x0, &state) / 2 / g->option.scale;
- y = -window_y_units(drag->final.y0, &state) / 2 / g->option.scale;
-
- browser_window_mouse_drag_end(g->bw,
- ro_gui_mouse_click_state(pointer.buttons), x, y);
-}
-
-
-/**
- * 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;
- int row = -1, col = -1, i;
- struct browser_window *top, *bw;
- wimp_window_state state;
-
- /* get the maximum drag box (collapse all surrounding frames */
- bw = g->bw;
- x0 = bw->x0;
- y0 = bw->y0;
- x1 = bw->x1;
- y1 = bw->y1;
- for (i = 0; i < (bw->parent->cols * bw->parent->rows); i++) {
- if (&bw->parent->children[i] == bw) {
- col = i % bw->parent->cols;
- row = i / bw->parent->cols;
- }
- }
- assert((row >= 0) && (col >= 0));
-
- if (g->bw->drag_resize_left)
- x0 = bw->parent->children[row * bw->parent->cols + (col - 1)].x0;
- if (g->bw->drag_resize_right)
- x1 = bw->parent->children[row * bw->parent->cols + (col + 1)].x1;
- if (g->bw->drag_resize_up)
- y0 = bw->parent->children[(row - 1) * bw->parent->cols + col].y0;
- if (g->bw->drag_resize_down)
- y1 = bw->parent->children[(row + 1) * bw->parent->cols + col].y1;
-
- /* convert to screen co-ordinates */
- top = browser_window_owner(bw);
- 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 false;
- }
- x0 = state.visible.x0 + x0 * 2;
- y0 = state.visible.y0 + y0 * 2;
- x1 = state.visible.x0 + x1 * 2 - 1;
- y1 = state.visible.y0 + y1 * 2 - 1;
-
- /* 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 */
- if (!(g->bw->drag_resize_left || g->bw->drag_resize_right)) {
- x0 = pointer.pos.x;
- x1 = pointer.pos.x;
- }
- if (!(g->bw->drag_resize_up || g->bw->drag_resize_down)) {
- y0 = pointer.pos.y;
- y1 = pointer.pos.y;
- }
-
- /* start the drag */
- drag.type = wimp_DRAG_USER_POINT;
- drag.bbox.x0 = x0;
- drag.bbox.y0 = y0;
- drag.bbox.x1 = x1;
- drag.bbox.y1 = y1;
-
- 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;
+ ro_gui_save_prepare(GUI_SAVE_LINK_URL, c);
+ ro_gui_dialog_open_persistent(g->window, dialog_saveas, true);
}
@@ -3209,7 +3087,7 @@
void ro_gui_window_frame_resize_end(struct gui_window *g, wimp_dragged *drag)
{
- /* our clean-up is the same as for page scrolling */
+ /* our clean-up is the same as for page scrolling */
ro_gui_window_scroll_end(g, drag);
}
17 years
r2923 rjw - /trunk/netsurf/riscos/wimp_event.c
by netsurf@semichrome.net
Author: rjw
Date: Wed Sep 6 15:46:18 2006
New Revision: 2923
URL: http://svn.semichrome.net?rev=2923&view=rev
Log:
Finish event based GUI system transiton and begin code cleanup.
Modified:
trunk/netsurf/riscos/wimp_event.c
Modified: trunk/netsurf/riscos/wimp_event.c
URL: http://svn.semichrome.net/trunk/netsurf/riscos/wimp_event.c?rev=2923&r1=2...
==============================================================================
--- trunk/netsurf/riscos/wimp_event.c (original)
+++ trunk/netsurf/riscos/wimp_event.c Wed Sep 6 15:46:18 2006
@@ -641,6 +641,8 @@
static wchar_t wc = 0; /* buffer for UTF8 alphabet */
static int shift = 0;
struct event_window *window;
+ struct icon_event *event;
+ wimp_pointer pointer;
wimp_key k;
wchar_t c = (wchar_t)key->c;
int t_alphabet;
@@ -789,13 +791,21 @@
return true;
switch (key->c) {
- /* Escape closes a dialog with a registered OK button */
+ /* Escape performs the CANCEL action (simulated click) */
case wimp_KEY_ESCAPE:
- if (!window->ok_click)
- return false;
- ro_gui_dialog_close(key->w);
- ro_gui_menu_closed(true);
- return true;
+ for (event = window->first; event; event = event->next) {
+ switch (event->type) {
+ case EVENT_CANCEL:
+ pointer.w = key->w;
+ pointer.i = event->i;
+ pointer.buttons = wimp_CLICK_SELECT;
+ ro_gui_wimp_event_mouse_click(&pointer);
+ return true;
+ default:
+ break;
+ }
+ }
+ return false;
/* CTRL+F2 closes a window with a close icon */
case wimp_KEY_CONTROL + wimp_KEY_F2:
if (!ro_gui_wimp_check_window_furniture(key->w,
17 years
r2922 rjw - in /trunk/netsurf: !NetSurf/Resources/de/ !NetSurf/Resources/en/ !NetSurf/Resources/fr/ !NetSurf/Resources/nl/ riscos/ utils/
by netsurf@semichrome.net
Author: rjw
Date: Wed Sep 6 15:44:42 2006
New Revision: 2922
URL: http://svn.semichrome.net?rev=2922&view=rev
Log:
Finish event based GUI system transition and begin code cleanup.
Modified:
trunk/netsurf/!NetSurf/Resources/de/Templates,fec
trunk/netsurf/!NetSurf/Resources/en/Templates,fec
trunk/netsurf/!NetSurf/Resources/fr/Templates,fec
trunk/netsurf/!NetSurf/Resources/nl/Templates,fec
trunk/netsurf/riscos/401login.c
trunk/netsurf/riscos/configure.c
trunk/netsurf/riscos/dialog.c
trunk/netsurf/riscos/download.c
trunk/netsurf/riscos/gui.c
trunk/netsurf/riscos/gui.h
trunk/netsurf/riscos/query.c
trunk/netsurf/riscos/query.h
trunk/netsurf/riscos/sslcert.c
trunk/netsurf/riscos/theme.c
trunk/netsurf/riscos/theme.h
trunk/netsurf/riscos/window.c
trunk/netsurf/utils/utils.h
Modified: trunk/netsurf/!NetSurf/Resources/de/Templates,fec
URL: http://svn.semichrome.net/trunk/netsurf/%21NetSurf/Resources/de/Templates...
==============================================================================
Binary files - no diff available.
Modified: trunk/netsurf/!NetSurf/Resources/en/Templates,fec
URL: http://svn.semichrome.net/trunk/netsurf/%21NetSurf/Resources/en/Templates...
==============================================================================
Binary files - no diff available.
Modified: trunk/netsurf/!NetSurf/Resources/fr/Templates,fec
URL: http://svn.semichrome.net/trunk/netsurf/%21NetSurf/Resources/fr/Templates...
==============================================================================
Binary files - no diff available.
Modified: trunk/netsurf/!NetSurf/Resources/nl/Templates,fec
URL: http://svn.semichrome.net/trunk/netsurf/%21NetSurf/Resources/nl/Templates...
==============================================================================
Binary files - no diff available.
Modified: trunk/netsurf/riscos/401login.c
URL: http://svn.semichrome.net/trunk/netsurf/riscos/401login.c?rev=2922&r1=292...
==============================================================================
--- trunk/netsurf/riscos/401login.c (original)
+++ trunk/netsurf/riscos/401login.c Wed Sep 6 15:44:42 2006
@@ -26,6 +26,13 @@
#ifdef WITH_AUTH
+#define ICON_401LOGIN_LOGIN 0
+#define ICON_401LOGIN_CANCEL 1
+#define ICON_401LOGIN_HOST 2
+#define ICON_401LOGIN_REALM 3
+#define ICON_401LOGIN_USERNAME 4
+#define ICON_401LOGIN_PASSWORD 5
+
static void ro_gui_401login_close(wimp_w w);
static bool ro_gui_401login_apply(wimp_w w);
static void ro_gui_401login_open(struct browser_window *bw, const char *host,
@@ -157,12 +164,14 @@
free(session->url);
free(session);
+ ro_gui_dialog_close(w);
+ error = xwimp_delete_window(w);
+ if (error) {
+ LOG(("xwimp_delete_window: 0x%x:%s",
+ error->errnum, error->errmess));
+ warn_user("WimpError", error->errmess);
+ }
ro_gui_wimp_event_finalise(w);
-
- error = xwimp_delete_window(w);
- if (error)
- LOG(("xwimp_delete_window: 0x%x: %s",
- error->errnum, error->errmess));
}
Modified: trunk/netsurf/riscos/configure.c
URL: http://svn.semichrome.net/trunk/netsurf/riscos/configure.c?rev=2922&r1=29...
==============================================================================
--- trunk/netsurf/riscos/configure.c (original)
+++ trunk/netsurf/riscos/configure.c Wed Sep 6 15:44:42 2006
@@ -138,7 +138,6 @@
ro_gui_wimp_event_register_close_window(
tool->w,
ro_gui_configure_close);
-
} else {
ro_gui_dialog_open_top(tool->w, NULL, 0, 0);
}
@@ -157,6 +156,7 @@
tool->open = false;
if (tool->finalise)
tool->finalise(w);
+ ro_gui_dialog_close(w);
break;
}
}
Modified: trunk/netsurf/riscos/dialog.c
URL: http://svn.semichrome.net/trunk/netsurf/riscos/dialog.c?rev=2922&r1=2921&...
==============================================================================
--- trunk/netsurf/riscos/dialog.c (original)
+++ trunk/netsurf/riscos/dialog.c Wed Sep 6 15:44:42 2006
@@ -398,7 +398,6 @@
error->errnum, error->errmess));
warn_user("WimpError", error->errmess);
}
- ro_gui_wimp_event_close_window(close);
}
Modified: trunk/netsurf/riscos/download.c
URL: http://svn.semichrome.net/trunk/netsurf/riscos/download.c?rev=2922&r1=292...
==============================================================================
--- trunk/netsurf/riscos/download.c (original)
+++ trunk/netsurf/riscos/download.c Wed Sep 6 15:44:42 2006
@@ -38,12 +38,19 @@
#include "netsurf/riscos/save.h"
#include "netsurf/riscos/query.h"
#include "netsurf/riscos/wimp.h"
+#include "netsurf/riscos/wimp_event.h"
#include "netsurf/utils/log.h"
#include "netsurf/utils/messages.h"
#include "netsurf/utils/url.h"
#include "netsurf/utils/utf8.h"
#include "netsurf/utils/utils.h"
+#define ICON_DOWNLOAD_ICON 0
+#define ICON_DOWNLOAD_URL 1
+#define ICON_DOWNLOAD_PATH 2
+#define ICON_DOWNLOAD_DESTINATION 3
+#define ICON_DOWNLOAD_PROGRESS 5
+#define ICON_DOWNLOAD_STATUS 6
typedef enum
{
@@ -122,22 +129,25 @@
const char *file_name, bool force_overwrite);
static void ro_gui_download_send_dataload(struct gui_download_window *dw);
static void ro_gui_download_window_destroy_wrapper(void *p);
+static bool ro_gui_download_window_destroy(struct gui_download_window *dw, bool quit);
static void ro_gui_download_close_confirmed(query_id, enum query_response res, void *p);
static void ro_gui_download_close_cancelled(query_id, enum query_response res, void *p);
static void ro_gui_download_overwrite_confirmed(query_id, enum query_response res, void *p);
static void ro_gui_download_overwrite_cancelled(query_id, enum query_response res, void *p);
+static bool ro_gui_download_click(wimp_pointer *pointer);
+static bool ro_gui_download_keypress(wimp_key *key);
+static void ro_gui_download_close(wimp_w w);
+
static const query_callback close_funcs =
{
ro_gui_download_close_confirmed,
- ro_gui_download_close_cancelled,
ro_gui_download_close_cancelled
};
static const query_callback overwrite_funcs =
{
ro_gui_download_overwrite_confirmed,
- ro_gui_download_overwrite_cancelled,
ro_gui_download_overwrite_cancelled
};
@@ -327,6 +337,11 @@
ro_gui_download_update_status(dw);
ro_gui_dialog_open(dw->window);
+
+ ro_gui_wimp_event_set_user_data(dw->window, dw);
+ ro_gui_wimp_event_register_mouse_click(dw->window, ro_gui_download_click);
+ ro_gui_wimp_event_register_keypress(dw->window, ro_gui_download_keypress);
+ ro_gui_wimp_event_register_close_window(dw->window, ro_gui_download_close);
/* issue the warning now, so that it appears in front of the download
* window! */
@@ -687,36 +702,20 @@
/**
- * Convert a RISC OS window handle to a gui_download_window.
- *
- * \param w RISC OS window handle
- * \return pointer to a structure if found, 0 otherwise
- */
-
-struct gui_download_window * ro_gui_download_window_lookup(wimp_w w)
-{
- struct gui_download_window *dw;
- for (dw = download_window_list; dw; dw = dw->next)
- if (dw->window == w)
- return dw;
- return 0;
-}
-
-
-/**
* Handle Mouse_Click events in a download window.
*
* \param dw download window
* \param pointer block returned by Wimp_Poll
*/
-void ro_gui_download_window_click(struct gui_download_window *dw,
- wimp_pointer *pointer)
-{
+bool ro_gui_download_click(wimp_pointer *pointer)
+{
+ struct gui_download_window *dw;
char command[256] = "Filer_OpenDir ";
char *dot;
os_error *error;
+ dw = (struct gui_download_window *)ro_gui_wimp_event_get_user_data(pointer->w);
if (pointer->i == ICON_DOWNLOAD_ICON && !dw->error &&
!dw->saved) {
const char *sprite = ro_gui_get_icon_string(pointer->w, pointer->i);
@@ -738,6 +737,7 @@
}
}
}
+ return true;
}
@@ -749,8 +749,11 @@
* \return true iff key press handled
*/
-bool ro_gui_download_window_keypress(struct gui_download_window *dw, wimp_key *key)
-{
+bool ro_gui_download_keypress(wimp_key *key)
+{
+ struct gui_download_window *dw;
+
+ dw = (struct gui_download_window *)ro_gui_wimp_event_get_user_data(key->w);
switch (key->c)
{
case wimp_KEY_ESCAPE:
@@ -1262,11 +1265,23 @@
/**
+ * Handle closing of download window
+ */
+void ro_gui_download_close(wimp_w w)
+{
+ struct gui_download_window *dw;
+
+ dw = (struct gui_download_window *)ro_gui_wimp_event_get_user_data(w);
+ ro_gui_download_window_destroy(dw, false);
+}
+
+
+/**
* Close a download window and free any related resources.
*
* \param dw download window
* \param quit destroying because we're quitting the whole app
- * \return true iff window destroyed, not waiting for user confirmation
+ * \return true if window destroyed, not waiting for user confirmation
*/
bool ro_gui_download_window_destroy(struct gui_download_window *dw, bool quit)
@@ -1320,12 +1335,14 @@
dw->next->prev = dw->prev;
/* delete window */
+ ro_gui_dialog_close(dw->window);
error = xwimp_delete_window(dw->window);
if (error) {
LOG(("xwimp_delete_window: 0x%x: %s",
error->errnum, error->errmess));
warn_user("WimpError", error->errmess);
}
+ ro_gui_wimp_event_finalise(dw->window);
/* close download file */
if (dw->file) {
@@ -1447,7 +1464,7 @@
* Respond to PreQuit message, displaying a prompt message if we need
* the user to confirm the shutdown.
*
- * \return true iff we can shutdown straightaway
+ * \return true if we can shutdown straightaway
*/
bool ro_gui_download_prequit(void)
Modified: trunk/netsurf/riscos/gui.c
URL: http://svn.semichrome.net/trunk/netsurf/riscos/gui.c?rev=2922&r1=2921&r2=...
==============================================================================
--- trunk/netsurf/riscos/gui.c (original)
+++ trunk/netsurf/riscos/gui.c Wed Sep 6 15:44:42 2006
@@ -142,14 +142,8 @@
char *default_stylesheet_url;
char *adblock_stylesheet_url;
-#ifndef ncos
static const char *task_name = "NetSurf";
#define CHOICES_PREFIX "<Choices$Write>.WWW.NetSurf."
-#else
-static const char *task_name = "NCNetSurf";
-#define CHOICES_PREFIX "<User$Path>.Choices.NetSurf."
-#endif
-
/** The pointer is over a window which is tracking mouse movement. */
static bool gui_track = false;
@@ -238,17 +232,16 @@
} screen_info;
static void ro_gui_create_dirs(void);
+static void ro_gui_create_dir(char *path);
static void ro_gui_choose_language(void);
static void ro_gui_icon_bar_create(void);
static void ro_gui_signal(int sig);
static void ro_gui_cleanup(void);
static void ro_gui_handle_event(wimp_event_no event, wimp_block *block);
static void ro_gui_null_reason_code(void);
-static void ro_gui_redraw_window_request(wimp_draw *redraw);
static void ro_gui_close_window_request(wimp_close *close);
static void ro_gui_pointer_leaving_window(wimp_leaving *leaving);
static void ro_gui_pointer_entering_window(wimp_entering *entering);
-static void ro_gui_mouse_click(wimp_pointer *pointer);
static bool ro_gui_icon_bar_click(wimp_pointer *pointer);
static void ro_gui_check_resolvers(void);
static void ro_gui_drag_end(wimp_dragged *drag);
@@ -475,8 +468,8 @@
*/
void ro_gui_create_dirs(void)
{
+ char buf[256];
char *path;
- char buf[256];
/* Choices */
path = getenv("NetSurf$ChoicesSave");
@@ -484,57 +477,45 @@
die("Failed to find NetSurf Choices save path");
snprintf(buf, sizeof(buf), "%s", path);
- path = buf;
-
- /* Given a path x.y.z, this will try to create x, x.y */
- while ((path = strchr(path, '.'))) {
- *path = '\0';
- xosfile_create_dir(buf, 0);
- *path++ = '.';
- }
+ ro_gui_create_dir(buf);
/* URL */
snprintf(buf, sizeof(buf), "%s", option_url_save);
- path = buf;
-
- while ((path = strchr(path, '.'))) {
- *path = '\0';
- xosfile_create_dir(buf, 0);
- *path++ = '.';
- }
+ ro_gui_create_dir(buf);
/* Hotlist */
snprintf(buf, sizeof(buf), "%s", option_hotlist_save);
- path = buf;
-
- while ((path = strchr(path, '.'))) {
- *path = '\0';
- xosfile_create_dir(buf, 0);
- *path++ = '.';
- }
+ ro_gui_create_dir(buf);
/* Recent */
snprintf(buf, sizeof(buf), "%s", option_recent_save);
- path = buf;
-
- while ((path = strchr(path, '.'))) {
- *path = '\0';
- xosfile_create_dir(buf, 0);
- *path++ = '.';
- }
+ ro_gui_create_dir(buf);
/* Theme */
snprintf(buf, sizeof(buf), "%s", option_theme_save);
- path = buf;
-
- while ((path = strchr(path, '.'))) {
- *path = '\0';
- xosfile_create_dir(buf, 0);
- *path++ = '.';
- }
+ ro_gui_create_dir(buf);
/* and the final directory part (as theme_save is a directory) */
xosfile_create_dir(buf, 0);
}
+
+
+/**
+ * Create directory structure for a path
+ *
+ * Given a path of x.y.z directories x and x.y will be created
+ *
+ * \param path the directory path to create
+ */
+void ro_gui_create_dir(char *path)
+{
+ char *cur = path;
+ while ((cur = strchr(cur, '.'))) {
+ *cur = '\0';
+ xosfile_create_dir(path, 0);
+ *cur++ = '.';
+ }
+}
+
/**
* Choose the language to use.
@@ -618,7 +599,6 @@
void ro_gui_icon_bar_create(void)
{
-#ifndef ncos
os_error *error;
wimp_icon_create icon = {
@@ -635,7 +615,6 @@
}
ro_gui_wimp_event_register_mouse_click(wimp_ICON_BAR,
ro_gui_icon_bar_click);
-#endif
}
@@ -904,7 +883,7 @@
break;
case wimp_REDRAW_WINDOW_REQUEST:
- ro_gui_redraw_window_request(&block->redraw);
+ ro_gui_wimp_event_redraw_window(&block->redraw);
break;
case wimp_OPEN_WINDOW_REQUEST:
@@ -924,7 +903,7 @@
break;
case wimp_MOUSE_CLICK:
- ro_gui_mouse_click(&block->pointer);
+ ro_gui_wimp_event_mouse_click(&block->pointer);
break;
case wimp_USER_DRAG_BOX:
@@ -1026,49 +1005,22 @@
/**
- * Handle Redraw_Window_Request events.
- */
-
-void ro_gui_redraw_window_request(wimp_draw *redraw)
-{
- struct gui_window *g;
-
- if (ro_gui_wimp_event_redraw_window(redraw))
- return;
-
- g = ro_gui_window_lookup(redraw->w);
- if (g)
- ro_gui_window_redraw(g, redraw);
-}
-
-
-/**
* Handle Open_Window_Request events.
*/
void ro_gui_open_window_request(wimp_open *open)
{
- struct gui_window *g;
os_error *error;
if (ro_gui_wimp_event_open_window(open))
return;
- g = ro_gui_window_lookup(open->w);
- if (g) {
- ro_gui_window_open(g, open);
- } else {
- error = xwimp_open_window(open);
- if (error) {
- LOG(("xwimp_open_window: 0x%x: %s",
- error->errnum, error->errmess));
- warn_user("WimpError", error->errmess);
- return;
- }
-
- g = ro_gui_status_lookup(open->w);
- if (g && g->toolbar)
- ro_gui_theme_resize_toolbar_status(g->toolbar);
+ error = xwimp_open_window(open);
+ if (error) {
+ LOG(("xwimp_open_window: 0x%x: %s",
+ error->errnum, error->errmess));
+ warn_user("WimpError", error->errmess);
+ return;
}
}
@@ -1079,70 +1031,9 @@
void ro_gui_close_window_request(wimp_close *close)
{
- struct gui_window *g;
- struct gui_download_window *dw;
- wimp_pointer pointer;
- os_error *error;
- char *temp_name, *r;
- char *filename;
- struct content *content = NULL;
-
- if ((g = ro_gui_window_lookup(close->w)) != 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) {
- filename = url_to_path(content->url);
- 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 {
- /* this is pointless if we are about to close the window */
- if (ro_gui_shift_pressed())
- ro_gui_menu_handle_action(close->w, BROWSER_NAVIGATE_UP, true);
- }
- }
- if (ro_gui_shift_pressed())
- return;
- ro_gui_url_complete_close(NULL, 0);
-
- /* search must be closed before the main window so that
- the content still exists */
- ro_gui_dialog_close_persistent(close->w);
- browser_window_destroy(g->bw);
+ if (ro_gui_wimp_event_close_window(close->w))
return;
-
- } else if ((dw = ro_gui_download_window_lookup(close->w)) != NULL) {
- ro_gui_download_window_destroy(dw, false);
- } else {
- ro_gui_dialog_close(close->w);
- }
- ro_gui_dialog_close_persistent(close->w);
+ ro_gui_dialog_close(close->w);
}
@@ -1152,14 +1043,8 @@
void ro_gui_pointer_leaving_window(wimp_leaving *leaving)
{
- if (gui_track_wimp_w == history_window) {
- os_error *error = xwimp_close_window(dialog_tooltip);
- if (error) {
- LOG(("xwimp_close_window: 0x%x: %s",
- error->errnum, error->errmess));
- warn_user("WimpError", error->errmess);
- }
- }
+ if (gui_track_wimp_w == history_window)
+ ro_gui_dialog_close(dialog_tooltip);
switch (gui_current_drag_type) {
case GUI_DRAG_SELECTION:
@@ -1198,24 +1083,6 @@
gui_track_wimp_w == dialog_url_complete;
break;
}
-}
-
-
-/**
- * Handle Mouse_Click events.
- */
-
-void ro_gui_mouse_click(wimp_pointer *pointer)
-{
- struct gui_download_window *dw;
- struct gui_query_window *qw;
-
- if (ro_gui_wimp_event_mouse_click(pointer))
- return;
- else if ((dw = ro_gui_download_window_lookup(pointer->w)) != NULL)
- ro_gui_download_window_click(dw, pointer);
- else if ((qw = ro_gui_query_window_lookup(pointer->w)) != NULL)
- ro_gui_query_window_click(qw, pointer);
}
@@ -1309,19 +1176,9 @@
void ro_gui_keypress(wimp_key *key)
{
- struct gui_download_window *dw;
- struct gui_query_window *qw;
- bool handled = false;
os_error *error;
- if (ro_gui_wimp_event_keypress(key))
- handled = true;
- else if ((qw = ro_gui_query_window_lookup(key->w)) != NULL)
- handled = ro_gui_query_window_keypress(qw, key);
- else if ((dw = ro_gui_download_window_lookup(key->w)) != NULL)
- handled = ro_gui_download_window_keypress(dw, key);
-
- if (!handled) {
+ if (!ro_gui_wimp_event_keypress(key)) {
error = xwimp_process_key(key->c);
if (error) {
LOG(("xwimp_process_key: 0x%x: %s",
Modified: trunk/netsurf/riscos/gui.h
URL: http://svn.semichrome.net/trunk/netsurf/riscos/gui.h?rev=2922&r1=2921&r2=...
==============================================================================
--- trunk/netsurf/riscos/gui.h (original)
+++ trunk/netsurf/riscos/gui.h Wed Sep 6 15:44:42 2006
@@ -119,15 +119,9 @@
/* in download.c */
void ro_gui_download_init(void);
-struct gui_download_window * ro_gui_download_window_lookup(wimp_w w);
-void ro_gui_download_window_click(struct gui_download_window *dw,
- wimp_pointer *pointer);
void ro_gui_download_drag_end(wimp_dragged *drag);
void ro_gui_download_datasave_ack(wimp_message *message);
-bool ro_gui_download_window_destroy(struct gui_download_window *dw, bool quit);
bool ro_gui_download_prequit(void);
-bool ro_gui_download_window_keypress(struct gui_download_window *dw,
- wimp_key *key);
/* in 401login.c */
#ifdef WITH_AUTH
@@ -144,8 +138,6 @@
void ro_gui_window_quit(void);
void ro_gui_window_update_theme(void);
void ro_gui_window_update_dimensions(struct gui_window *g, int yscroll);
-void ro_gui_window_open(struct gui_window *g, wimp_open *open);
-void ro_gui_window_redraw(struct gui_window *g, wimp_draw *redraw);
void ro_gui_window_mouse_at(struct gui_window *g, wimp_pointer *pointer);
bool ro_gui_toolbar_click(wimp_pointer *pointer);
bool ro_gui_status_click(wimp_pointer *pointer);
@@ -232,20 +224,6 @@
#define ICON_STATUS_RESIZE 0
#define ICON_STATUS_TEXT 1
-#define ICON_DOWNLOAD_ICON 0
-#define ICON_DOWNLOAD_URL 1
-#define ICON_DOWNLOAD_PATH 2
-#define ICON_DOWNLOAD_DESTINATION 3
-#define ICON_DOWNLOAD_PROGRESS 5
-#define ICON_DOWNLOAD_STATUS 6
-
-#define ICON_401LOGIN_LOGIN 0
-#define ICON_401LOGIN_CANCEL 1
-#define ICON_401LOGIN_HOST 2
-#define ICON_401LOGIN_REALM 3
-#define ICON_401LOGIN_USERNAME 4
-#define ICON_401LOGIN_PASSWORD 5
-
#define ICON_ZOOM_VALUE 1
#define ICON_ZOOM_DEC 2
#define ICON_ZOOM_INC 3
@@ -276,11 +254,6 @@
#define ICON_WARNING_CONTINUE 1
#define ICON_WARNING_HELP 2
-#define ICON_QUERY_MESSAGE 0
-#define ICON_QUERY_YES 1
-#define ICON_QUERY_NO 2
-#define ICON_QUERY_HELP 3
-
#define ICON_SEARCH_TEXT 0
#define ICON_SEARCH_CASE_SENSITIVE 1
#define ICON_SEARCH_FIND_NEXT 2
Modified: trunk/netsurf/riscos/query.c
URL: http://svn.semichrome.net/trunk/netsurf/riscos/query.c?rev=2922&r1=2921&r...
==============================================================================
--- trunk/netsurf/riscos/query.c (original)
+++ trunk/netsurf/riscos/query.c Wed Sep 6 15:44:42 2006
@@ -11,10 +11,15 @@
#include "netsurf/riscos/dialog.h"
#include "netsurf/riscos/query.h"
#include "netsurf/riscos/wimp.h"
+#include "netsurf/riscos/wimp_event.h"
#include "netsurf/utils/log.h"
#include "netsurf/utils/messages.h"
#include "netsurf/utils/utils.h"
+#define ICON_QUERY_MESSAGE 0
+#define ICON_QUERY_YES 1
+#define ICON_QUERY_NO 2
+#define ICON_QUERY_HELP 3
/** Data for a query window */
struct gui_query_window
@@ -45,29 +50,16 @@
static int query_yes_width = 0;
static int query_no_width = 0;
-static void ro_gui_query_window_destroy(struct gui_query_window *qw);
static struct gui_query_window *ro_gui_query_window_lookup_id(query_id id);
+static bool ro_gui_query_click(wimp_pointer *pointer);
+static void ro_gui_query_close(wimp_w w);
+static bool ro_gui_query_apply(wimp_w w);
+
void ro_gui_query_init(void)
{
query_template = ro_gui_dialog_load_template("query");
-}
-
-
-/**
- * Lookup a query window using its RISC OS window handle
- *
- * \param w RISC OS window handle
- * \return pointer to query window or NULL
- */
-
-struct gui_query_window *ro_gui_query_window_lookup(wimp_w w)
-{
- struct gui_query_window *qw = gui_query_window_list;
- while (qw && qw->window != w)
- qw = qw->next;
- return qw;
}
@@ -128,42 +120,42 @@
if (!yes) yes = messages_get("Yes");
if (!no) no = messages_get("No");
+ /* set the text of the 'Yes' button and size accordingly */
+ icn = &query_template->icons[ICON_QUERY_YES];
+ len = strnlen(yes, icn->data.indirected_text.size - 1);
+ memcpy(icn->data.indirected_text.text, yes, len);
+ icn->data.indirected_text.text[len] = '\0';
+
+ error = xwimptextop_string_width(icn->data.indirected_text.text, len, &width);
+ if (error) {
+ LOG(("xwimptextop_string_width: 0x%x:%s",
+ error->errnum, error->errmess));
+ width = len * 16;
+ }
+ if (!query_yes_width) query_yes_width = icn->extent.x1 - icn->extent.x0;
+ if (width < query_yes_width)
+ width = query_yes_width;
+ else
+ width += 44;
+ icn->extent.x0 = x = icn->extent.x1 - width;
+
/* set the text of the 'No' button and size accordingly */
icn = &query_template->icons[ICON_QUERY_NO];
len = strnlen(no, icn->data.indirected_text.size - 1);
memcpy(icn->data.indirected_text.text, no, len);
icn->data.indirected_text.text[len] = '\0';
+ if (!query_no_width) query_no_width = icn->extent.x1 - icn->extent.x0;
+ icn->extent.x1 = x - 16;
error = xwimptextop_string_width(icn->data.indirected_text.text, len, &width);
if (error) {
LOG(("xwimptextop_string_width: 0x%x:%s",
error->errnum, error->errmess));
width = len * 16;
}
- if (!query_no_width) query_no_width = icn->extent.x1 - icn->extent.x0;
if (width < query_no_width)
width = query_no_width;
else
- width += 44;
- icn->extent.x0 = x = icn->extent.x1 - width;
-
- /* set the text of the 'Yes' button and size accordingly */
- icn = &query_template->icons[ICON_QUERY_YES];
- len = strnlen(yes, icn->data.indirected_text.size - 1);
- memcpy(icn->data.indirected_text.text, yes, len);
- icn->data.indirected_text.text[len] = '\0';
-
- if (!query_yes_width) query_yes_width = icn->extent.x1 - icn->extent.x0;
- icn->extent.x1 = x - 16;
- error = xwimptextop_string_width(icn->data.indirected_text.text, len, &width);
- if (error) {
- LOG(("xwimptextop_string_width: 0x%x:%s",
- error->errnum, error->errmess));
- width = len * 16;
- }
- if (width < query_yes_width)
- width = query_yes_width;
- else
width += 28;
icn->extent.x0 = icn->extent.x1 - width;
@@ -185,6 +177,12 @@
ro_gui_dialog_open(qw->window);
+ ro_gui_wimp_event_set_user_data(qw->window, qw);
+ ro_gui_wimp_event_register_mouse_click(qw->window, ro_gui_query_click);
+ ro_gui_wimp_event_register_cancel(qw->window, ICON_QUERY_NO);
+ ro_gui_wimp_event_register_ok(qw->window, ICON_QUERY_YES, ro_gui_query_apply);
+ ro_gui_wimp_event_register_close_window(qw->window, ro_gui_query_close);
+
error = xwimp_set_caret_position(qw->window, (wimp_i)-1, 0, 0, 1 << 25, -1);
if (error) {
LOG(("xwimp_get_caret_position: 0x%x : %s",
@@ -201,34 +199,6 @@
gui_query_window_list = qw;
return qw->id;
-}
-
-
-/**
- * Close and destroy a query window, releasing all resources
- *
- * \param qw query window
- */
-
-void ro_gui_query_window_destroy(struct gui_query_window *qw)
-{
- os_error *error = xwimp_delete_window(qw->window);
- if (error) {
- LOG(("xwimp_delete_window: 0x%x:%s",
- error->errnum, error->errmess));
- warn_user("WimpError", error->errmess);
- }
-
- /* remove from linked-list of query windows and release memory */
- if (qw->prev)
- qw->prev->next = qw->next;
- else
- gui_query_window_list = qw->next;
-
- if (qw->next)
- qw->next->prev = qw->prev;
-
- free(qw);
}
@@ -243,7 +213,10 @@
void query_close(query_id id)
{
struct gui_query_window *qw = ro_gui_query_window_lookup_id(id);
- if (qw) ro_gui_query_window_destroy(qw);
+ if (!qw)
+ return;
+ ro_gui_query_close(qw->window);
+
}
@@ -266,59 +239,68 @@
/**
- * Handle mouse clicks in a query window.
- *
- * \param qw query window
- * \param key key press info from the Wimp
- */
-
-void ro_gui_query_window_click(struct gui_query_window *qw, wimp_pointer *pointer)
-{
- const query_callback *cb = qw->cb;
+ * Handle closing of query dialog
+ */
+void ro_gui_query_close(wimp_w w)
+{
+ struct gui_query_window *qw;
+ os_error *error;
+
+ qw = (struct gui_query_window *)ro_gui_wimp_event_get_user_data(w);
+
+ ro_gui_dialog_close(w);
+ error = xwimp_delete_window(qw->window);
+ if (error) {
+ LOG(("xwimp_delete_window: 0x%x:%s",
+ error->errnum, error->errmess));
+ warn_user("WimpError", error->errmess);
+ }
+ ro_gui_wimp_event_finalise(w);
+
+ /* remove from linked-list of query windows and release memory */
+ if (qw->prev)
+ qw->prev->next = qw->next;
+ else
+ gui_query_window_list = qw->next;
+
+ if (qw->next)
+ qw->next->prev = qw->prev;
+ free(qw);
+}
+
+
+/**
+ * Handle acceptance of query dialog
+ */
+bool ro_gui_query_apply(wimp_w w)
+{
+ struct gui_query_window *qw;
+ const query_callback *cb;
+
+ qw = (struct gui_query_window *)ro_gui_wimp_event_get_user_data(w);
+ cb = qw->cb;
+ cb->confirm(qw->id, QUERY_YES, qw->pw);
+ return true;
+}
+
+
+/**
+ * Handle clicks in query dialog
+ */
+bool ro_gui_query_click(wimp_pointer *pointer)
+{
+ struct gui_query_window *qw;
+ const query_callback *cb;
+
+ qw = (struct gui_query_window *)ro_gui_wimp_event_get_user_data(pointer->w);
+ cb = qw->cb;
+
switch (pointer->i) {
- case ICON_QUERY_YES:
- cb->confirm(qw->id, QUERY_YES, qw->pw);
- ro_gui_query_window_destroy(qw);
- break;
-
case ICON_QUERY_NO:
cb->cancel(qw->id, QUERY_NO, qw->pw);
- ro_gui_query_window_destroy(qw);
break;
-
- case ICON_QUERY_HELP:
- /* \todo */
- break;
- }
-}
-
-
-/**
- * Handle keypresses in a query window.
- *
- * \param qw query window
- * \param pointer mouse pointer state from Wimp.
- * \return true iff the key press is the key press has been handled
- */
-
-bool ro_gui_query_window_keypress(struct gui_query_window *qw, wimp_key *key)
-{
- const query_callback *cb = qw->cb;
- switch (key->c) {
-
- case wimp_KEY_ESCAPE:
- cb->escape(qw->id, QUERY_ESCAPE, qw->pw);
- ro_gui_query_window_destroy(qw);
- return true;
-
- case wimp_KEY_RETURN:
- if (qw->default_confirm)
- cb->confirm(qw->id, QUERY_YES, qw->pw);
- else
- cb->cancel(qw->id, QUERY_NO, qw->pw);
- ro_gui_query_window_destroy(qw);
- return true;
- }
-
- return true;
-}
+ default:
+ return false;
+ }
+ return false;
+}
Modified: trunk/netsurf/riscos/query.h
URL: http://svn.semichrome.net/trunk/netsurf/riscos/query.h?rev=2922&r1=2921&r...
==============================================================================
--- trunk/netsurf/riscos/query.h (original)
+++ trunk/netsurf/riscos/query.h Wed Sep 6 15:44:42 2006
@@ -14,9 +14,6 @@
struct gui_query_window;
void ro_gui_query_init(void);
-struct gui_query_window *ro_gui_query_window_lookup(wimp_w w);
void ro_gui_query_window_bring_to_front(query_id id);
-void ro_gui_query_window_click(struct gui_query_window *qw, wimp_pointer *pointer);
-bool ro_gui_query_window_keypress(struct gui_query_window *qw, wimp_key *key);
#endif
Modified: trunk/netsurf/riscos/sslcert.c
URL: http://svn.semichrome.net/trunk/netsurf/riscos/sslcert.c?rev=2922&r1=2921...
==============================================================================
--- trunk/netsurf/riscos/sslcert.c (original)
+++ trunk/netsurf/riscos/sslcert.c Wed Sep 6 15:44:42 2006
@@ -373,6 +373,7 @@
void ro_gui_cert_close(wimp_w w)
{
struct session_data *data;
+ os_error *error;
unsigned long i;
data = (struct session_data *)ro_gui_wimp_event_get_user_data(w);
@@ -390,12 +391,24 @@
if (data->tree) {
tree_delete_node(data->tree, data->tree->root, false);
- xwimp_delete_window((wimp_w)data->tree->handle);
+ ro_gui_dialog_close((wimp_w)data->tree->handle);
+ error = xwimp_delete_window((wimp_w)data->tree->handle);
+ if (error) {
+ LOG(("xwimp_delete_window: 0x%x:%s",
+ error->errnum, error->errmess));
+ warn_user("WimpError", error->errmess);
+ }
+ ro_gui_wimp_event_finalise((wimp_w)data->tree->handle);
free(data->tree);
}
- xwimp_delete_window(w);
-
- ro_gui_wimp_event_finalise(w);
+
+ ro_gui_dialog_close(w);
+ error = xwimp_delete_window(w);
+ if (error) {
+ LOG(("xwimp_delete_window: 0x%x:%s",
+ error->errnum, error->errmess));
+ warn_user("WimpError", error->errmess);
+ }
}
Modified: trunk/netsurf/riscos/theme.c
URL: http://svn.semichrome.net/trunk/netsurf/riscos/theme.c?rev=2922&r1=2921&r...
==============================================================================
--- trunk/netsurf/riscos/theme.c (original)
+++ trunk/netsurf/riscos/theme.c Wed Sep 6 15:44:42 2006
@@ -78,6 +78,7 @@
const char* icons[], const char* ident);
static void ro_gui_theme_set_help_prefix(struct toolbar *toolbar);
+static void ro_gui_theme_status_open(wimp_open *open);
/* A basic window for the toolbar and status
*/
@@ -1119,8 +1120,11 @@
warn_user("WimpError", error->errmess);
return false;
}
+ ro_gui_wimp_event_set_user_data(toolbar->status_handle, toolbar);
ro_gui_wimp_event_register_mouse_click(toolbar->status_handle,
ro_gui_status_click);
+ ro_gui_wimp_event_register_open_window(toolbar->status_handle,
+ ro_gui_theme_status_open);
ro_gui_wimp_event_set_help_prefix(toolbar->status_handle, "HelpStatus");
/* Create the status resize icon
@@ -1298,55 +1302,6 @@
/**
- * Updates the toolbars status bar settings to reflect the current size
- *
- * \param toolbar the toolbar to update
- */
-void ro_gui_theme_resize_toolbar_status(struct toolbar *toolbar) {
- os_error *error;
- wimp_outline outline;
- wimp_window_state state;
- wimp_w parent = NULL;
- int parent_size, status_size;
- if ((!toolbar) || (!toolbar->parent_handle)) return;
-
- /* Get the width to scale to
- */
- parent = toolbar->parent_handle;
- outline.w = toolbar->parent_handle;
- error = xwimp_get_window_outline(&outline);
- if (error) {
- LOG(("xwimp_get_window_outline: 0x%x: %s",
- error->errnum, error->errmess));
- warn_user("WimpError", error->errmess);
- return;
- }
- parent_size = outline.outline.x1 - outline.outline.x0 -
- ro_get_vscroll_width(parent) - 2;
-
- /* Get the current size
- */
- state.w = toolbar->status_handle;
- 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;
- }
- status_size = state.visible.x1 - state.visible.x0;
- if (status_size <= 12)
- status_size = 0;
-
- /* Store the new size
- */
- toolbar->status_width = (10000 * status_size) / parent_size;
- if (toolbar->status_width > 10000) toolbar->status_width = 10000;
- ro_gui_theme_process_toolbar(toolbar, -1);
-}
-
-
-/**
* Updates the toolbar to reflect changes to the icon flags and any reformatting
* required due to the change in parent window size.
*
@@ -1375,7 +1330,7 @@
int xeig, yeig;
os_coord pixel = {1, 1};
int top, bottom, right;
- bool parent_hscroll;
+ bool parent_hscroll = false;
/* calculate 1px in OS units */
ro_convert_pixels_to_os_units(&pixel, (os_mode)-1);
@@ -2431,3 +2386,43 @@
break;
}
}
+
+void ro_gui_theme_status_open(wimp_open *open) {
+ struct toolbar *toolbar = (struct toolbar *)ro_gui_wimp_event_get_user_data(open->w);
+ os_error *error;
+ wimp_outline outline;
+ wimp_w parent = NULL;
+ int parent_size, status_size;
+
+ /* update the window size */
+ error = xwimp_open_window(open);
+ if (error) {
+ LOG(("xwimp_open_window: 0x%x: %s",
+ error->errnum, error->errmess));
+ warn_user("WimpError", error->errmess);
+ }
+
+ /* get the width to scale to */
+ parent = toolbar->parent_handle;
+ outline.w = toolbar->parent_handle;
+ error = xwimp_get_window_outline(&outline);
+ if (error) {
+ LOG(("xwimp_get_window_outline: 0x%x: %s",
+ error->errnum, error->errmess));
+ warn_user("WimpError", error->errmess);
+ return;
+ }
+ parent_size = outline.outline.x1 - outline.outline.x0 -
+ ro_get_vscroll_width(parent) - 2;
+
+ /* get the current size */
+ status_size = open->visible.x1 - open->visible.x0;
+ if (status_size <= 12)
+ status_size = 0;
+
+ /* Store the new size
+ */
+ toolbar->status_width = (10000 * status_size) / parent_size;
+ if (toolbar->status_width > 10000) toolbar->status_width = 10000;
+ ro_gui_theme_process_toolbar(toolbar, -1);
+}
Modified: trunk/netsurf/riscos/theme.h
URL: http://svn.semichrome.net/trunk/netsurf/riscos/theme.h?rev=2922&r1=2921&r...
==============================================================================
--- trunk/netsurf/riscos/theme.h (original)
+++ trunk/netsurf/riscos/theme.h Wed Sep 6 15:44:42 2006
@@ -154,7 +154,6 @@
struct toolbar *ro_gui_theme_create_toolbar(struct theme_descriptor *descriptor, toolbar_type type);
bool ro_gui_theme_update_toolbar(struct theme_descriptor *descriptor, struct toolbar *toolbar);
bool ro_gui_theme_attach_toolbar(struct toolbar *toolbar, wimp_w parent);
-void ro_gui_theme_resize_toolbar_status(struct toolbar *toolbar);
bool ro_gui_theme_process_toolbar(struct toolbar *toolbar, int width);
void ro_gui_theme_destroy_toolbar(struct toolbar *toolbar);
Modified: trunk/netsurf/riscos/window.c
URL: http://svn.semichrome.net/trunk/netsurf/riscos/window.c?rev=2922&r1=2921&...
==============================================================================
--- trunk/netsurf/riscos/window.c (original)
+++ trunk/netsurf/riscos/window.c Wed Sep 6 15:44:42 2006
@@ -79,6 +79,9 @@
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))
+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);
static bool ro_gui_window_click(wimp_pointer *mouse);
static bool ro_gui_window_keypress(wimp_key *key);
static void ro_gui_window_launch_url(struct gui_window *g, const char *url);
@@ -137,10 +140,9 @@
g->throbtime = 0;
g->iconise_icon = -1;
- /* Set the window position
- */
+ /* Set the window position */
if (bw->parent) {
- /* fill the parent window until it's reformatted */
+ /* Open as a small window until we are reformatted */
state.w = clone->window->window;
error = xwimp_get_window_state(&state);
if (error) {
@@ -169,8 +171,7 @@
} else {
ro_gui_screen_size(&screen_width, &screen_height);
- /* Check if we have a preferred position
- */
+ /* Check if we have a preferred position */
if ((option_window_screen_width != 0) &&
(option_window_screen_height != 0)) {
win_width = (option_window_width * screen_width) /
@@ -193,7 +194,7 @@
} else {
/* Base how we define the window height/width
- on the compile time options set */
+ on the compile time options set */
win_width = screen_width * 3 / 4;
if (1600 < win_width)
win_width = 1600;
@@ -207,13 +208,10 @@
window.visible.y1 = window.visible.y0 + win_height;
}
- /* Set the general window characteristics
- */
+ /* General flags for a non-movable, non-resizable, no-title bar window */
window.xscroll = 0;
window.yscroll = 0;
window.next = wimp_TOP;
-
- /* General flags for a non-movable, non-resizable, no-title bar window */
window.flags = wimp_WINDOW_MOVEABLE |
wimp_WINDOW_NEW_FORMAT |
wimp_WINDOW_VSCROLL |
@@ -293,6 +291,7 @@
return 0;
}
+ /* Link into window list */
g->prev = 0;
g->next = window_list;
if (window_list)
@@ -300,8 +299,7 @@
window_list = g;
window_count++;
- /* Add in a toolbar
- */
+ /* Add in a toolbar */
if (bw->browser_window_type == BROWSER_WINDOW_NORMAL) {
g->toolbar = ro_gui_theme_create_toolbar(NULL, THEME_BROWSER_TOOLBAR);
ro_gui_theme_attach_toolbar(g->toolbar, g->window);
@@ -309,14 +307,23 @@
g->toolbar = NULL;
}
- /* Set the window options
- */
+ /* Set the window options */
bw->window = g;
ro_gui_window_clone_options(bw, clone);
ro_gui_prepare_navigate(g);
- /* Open the window
- */
+ /* 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 */
state.w = g->window;
error = xwimp_get_window_state(&state);
if (error) {
@@ -325,9 +332,6 @@
warn_user("WimpError", error->errmess);
return g;
}
-
- /* Open the window at the top/back of the stack
- */
state.next = wimp_TOP;
if (bw->parent) {
top = browser_window_owner(bw);
@@ -337,18 +341,9 @@
wimp_CHILD_LINKS_PARENT_WORK_AREA
<< wimp_CHILD_YORIGIN_SHIFT);
}
- ro_gui_window_open(g, (wimp_open*)&state);
-
- /* Register event handlers */
- 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);
-
- /* Claim the caret position for top-level windows */
+ ro_gui_window_open((wimp_open*)&state);
+
+ /* Claim the caret for top-level windows */
if (bw->browser_window_type == BROWSER_WINDOW_NORMAL) {
if (g->toolbar && g->toolbar->display_url) {
error = xwimp_set_caret_position(
@@ -550,10 +545,11 @@
* Handle a Redraw_Window_Request for a browser window.
*/
-void ro_gui_window_redraw(struct gui_window *g, wimp_draw *redraw)
+void ro_gui_window_redraw(wimp_draw *redraw)
{
osbool more;
bool knockout = true;
+ struct gui_window *g = (struct gui_window *)ro_gui_wimp_event_get_user_data(redraw->w);
float scale = g->option.scale;
struct content *c = g->bw->current_content;
int clip_x0, clip_y0, clip_x1, clip_y1, clear_x1, clear_y1;
@@ -889,7 +885,7 @@
state.yscroll = -sy * 2 * g->option.scale;
if (g->toolbar)
state.yscroll += ro_gui_theme_toolbar_full_height(g->toolbar);
- ro_gui_window_open(g, (wimp_open *) &state);
+ ro_gui_window_open((wimp_open *) &state);
}
@@ -960,7 +956,6 @@
cx0 -= padding_available;
}
padding_available = (height - y1 + y0) / 2;
- LOG(("Padding available: %i", padding_available));
if (padding_available > 0) {
if (padding_available > SCROLL_VISIBLE_PADDING)
padding_available = SCROLL_VISIBLE_PADDING;
@@ -974,7 +969,7 @@
state.xscroll = cx0;
state.yscroll = -cy0 + toolbar_height;
- ro_gui_window_open(g, (wimp_open *)&state);
+ ro_gui_window_open((wimp_open *)&state);
}
@@ -1065,7 +1060,7 @@
state.visible.y0 = py1 - y1;
state.visible.x1 = px0 + x1;
state.visible.y1 = py1 - y0 * 2;
- ro_gui_window_open(g, (wimp_open *)&state);
+ ro_gui_window_open((wimp_open *)&state);
}
@@ -1187,7 +1182,7 @@
/* only allow a further reformat if we've gained/lost scrollbars */
flags = state.flags & (wimp_WINDOW_HSCROLL | wimp_WINDOW_VSCROLL);
update = g->reformat_pending;
- ro_gui_window_open(g, (wimp_open *)&state);
+ ro_gui_window_open((wimp_open *)&state);
state.w = g->window;
error = xwimp_get_window_state(&state);
@@ -1347,12 +1342,14 @@
}
}
+
/**
* Open a window using the given wimp_open, handling toolbars and resizing.
*/
-void ro_gui_window_open(struct gui_window *g, wimp_open *open)
-{
+void ro_gui_window_open(wimp_open *open)
+{
+ struct gui_window *g = (struct gui_window *)ro_gui_wimp_event_get_user_data(open->w);
int width = open->visible.x1 - open->visible.x0;
int height = open->visible.y1 - open->visible.y0;
int toolbar_height = 0;
@@ -1526,6 +1523,66 @@
/**
+ * 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) {
+ filename = url_to_path(content->url);
+ 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 {
+ /* 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);
+ }
+ }
+ if (ro_gui_shift_pressed())
+ return;
+ ro_gui_url_complete_close(NULL, 0);
+ ro_gui_dialog_close_persistent(w);
+ browser_window_destroy(g->bw);
+ return;
+
+}
+
+
+/**
* Animate the "throbbers" of all browser windows.
*/
@@ -1857,9 +1914,7 @@
os_error *error;
int x, y;
- g = ro_gui_window_lookup(pointer->w);
- if (!g)
- return false;
+ g = (struct gui_window *)ro_gui_wimp_event_get_user_data(pointer->w);
/* try to close url-completion */
ro_gui_url_complete_close(g, pointer->i);
Modified: trunk/netsurf/utils/utils.h
URL: http://svn.semichrome.net/trunk/netsurf/utils/utils.h?rev=2922&r1=2921&r2...
==============================================================================
--- trunk/netsurf/utils/utils.h (original)
+++ trunk/netsurf/utils/utils.h Wed Sep 6 15:44:42 2006
@@ -43,7 +43,6 @@
{
void (*confirm)(query_id id, enum query_response res, void *pw);
void (*cancel)(query_id, enum query_response res, void *pw);
- void (*escape)(query_id, enum query_response res, void *pw);
} query_callback;
17 years