summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--riscos/gui.c10
-rw-r--r--riscos/gui.h1
-rw-r--r--riscos/window.c98
3 files changed, 102 insertions, 7 deletions
diff --git a/riscos/gui.c b/riscos/gui.c
index cc8668249..4e64bca2a 100644
--- a/riscos/gui.c
+++ b/riscos/gui.c
@@ -308,6 +308,10 @@ void gui_poll(bool active)
ro_gui_menu_selection(&(block.selection));
break;
+ case wimp_SCROLL_REQUEST:
+ ro_gui_scroll_request(&(block.scroll));
+ break;
+
case wimp_LOSE_CARET :
break;
case wimp_GAIN_CARET :
@@ -465,6 +469,12 @@ void gui_multitask(void)
ro_gui_drag_end(&(block.dragged));
break;
case wimp_MENU_SELECTION :
+ break;
+
+ case wimp_SCROLL_REQUEST:
+ ro_gui_scroll_request(&(block.scroll));
+ break;
+
case wimp_USER_MESSAGE :
case wimp_USER_MESSAGE_RECORDED :
case wimp_USER_MESSAGE_ACKNOWLEDGE:
diff --git a/riscos/gui.h b/riscos/gui.h
index ab99b5104..6def3bc2b 100644
--- a/riscos/gui.h
+++ b/riscos/gui.h
@@ -145,6 +145,7 @@ gui_window* ro_lookup_gui_from_w(wimp_w window);
gui_window* ro_lookup_gui_toolbar_from_w(wimp_w window);
gui_window *ro_gui_window_lookup(wimp_w w);
bool ro_gui_window_keypress(gui_window *g, int key, bool toolbar);
+void ro_gui_scroll_request(wimp_scroll *scroll);
/* in history.c */
void ro_gui_history_init(void);
diff --git a/riscos/window.c b/riscos/window.c
index 8af876d99..fdfebb1f5 100644
--- a/riscos/window.c
+++ b/riscos/window.c
@@ -61,7 +61,8 @@ gui_window *gui_create_browser_window(struct browser_window *bw)
wimp_WINDOW_MOVEABLE | wimp_WINDOW_NEW_FORMAT | wimp_WINDOW_BACK_ICON |
wimp_WINDOW_CLOSE_ICON | wimp_WINDOW_TITLE_ICON | wimp_WINDOW_VSCROLL |
wimp_WINDOW_HSCROLL | wimp_WINDOW_SIZE_ICON | wimp_WINDOW_TOGGLE_ICON |
- wimp_WINDOW_IGNORE_XEXTENT | wimp_WINDOW_IGNORE_YEXTENT;
+ wimp_WINDOW_IGNORE_XEXTENT | wimp_WINDOW_IGNORE_YEXTENT |
+ wimp_WINDOW_SCROLL_REPEAT;
window.title_fg = wimp_COLOUR_BLACK;
window.title_bg = wimp_COLOUR_LIGHT_GREY;
window.work_fg = wimp_COLOUR_LIGHT_GREY;
@@ -659,6 +660,7 @@ bool ro_gui_window_keypress(gui_window *g, int key, bool toolbar)
{
struct content *content = g->data.browser.bw->current_content;
wimp_window_state state;
+ int y;
assert(g->type == GUI_BROWSER_WINDOW);
@@ -716,15 +718,97 @@ bool ro_gui_window_keypress(gui_window *g, int key, bool toolbar)
case wimp_KEY_UP:
case wimp_KEY_DOWN:
- state.w = g->window;
- wimp_get_window_state(&state);
- state.yscroll += key == wimp_KEY_UP ? 32 : -32;
- wimp_open_window((wimp_open *) &state);
- return true;
+ case wimp_KEY_PAGE_UP:
+ case wimp_KEY_PAGE_DOWN:
+ case wimp_KEY_CONTROL | wimp_KEY_UP:
+ case wimp_KEY_CONTROL | wimp_KEY_DOWN:
+ break;
+
+ default:
+ return false;
+ }
+
+ state.w = g->window;
+ wimp_get_window_state(&state);
+ y = state.visible.y1 - state.visible.y0 - 32;
+ if (g->data.browser.bw->flags & browser_TOOLBAR)
+ y -= ro_theme_toolbar_height();
+
+ switch (key) {
+ case wimp_KEY_UP:
+ state.yscroll += 32;
+ break;
+ case wimp_KEY_DOWN:
+ state.yscroll -= 32;
+ break;
+ case wimp_KEY_PAGE_UP:
+ state.yscroll += y;
+ break;
+ case wimp_KEY_PAGE_DOWN:
+ state.yscroll -= y;
+ break;
+ case wimp_KEY_CONTROL | wimp_KEY_UP:
+ state.yscroll = 1000;
+ break;
+ case wimp_KEY_CONTROL | wimp_KEY_DOWN:
+ state.yscroll = -0x10000000;
+ break;
+ }
+
+ wimp_open_window((wimp_open *) &state);
+ return true;
+}
+
+
+/**
+ * Process Scroll_Request events.
+ */
+void ro_gui_scroll_request(wimp_scroll *scroll)
+{
+ int x, y;
+ gui_window *g = ro_gui_window_lookup(scroll->w);
+
+ if (!g || g->type != GUI_BROWSER_WINDOW)
+ return;
+
+ x = scroll->visible.x1 - scroll->visible.x0 - 32;
+ y = scroll->visible.y1 - scroll->visible.y0 - 32;
+ if (g->data.browser.bw->flags & browser_TOOLBAR)
+ y -= ro_theme_toolbar_height();
+
+ switch (scroll->xmin) {
+ case wimp_SCROLL_PAGE_LEFT:
+ scroll->xscroll -= x;
+ break;
+ case wimp_SCROLL_COLUMN_LEFT:
+ scroll->xscroll -= 32;
+ break;
+ case wimp_SCROLL_COLUMN_RIGHT:
+ scroll->xscroll += 32;
+ break;
+ case wimp_SCROLL_PAGE_RIGHT:
+ scroll->xscroll += x;
+ break;
+ default:
+ break;
+ }
+ switch (scroll->ymin) {
+ case wimp_SCROLL_PAGE_UP:
+ scroll->yscroll += y;
+ break;
+ case wimp_SCROLL_LINE_UP:
+ scroll->yscroll += 32;
+ break;
+ case wimp_SCROLL_LINE_DOWN:
+ scroll->yscroll -= 32;
+ break;
+ case wimp_SCROLL_PAGE_DOWN:
+ scroll->yscroll -= y;
+ break;
default:
break;
}
- return false;
+ wimp_open_window((wimp_open *) scroll);
}