summaryrefslogtreecommitdiff
path: root/riscos
diff options
context:
space:
mode:
Diffstat (limited to 'riscos')
-rw-r--r--riscos/gui.c2
-rw-r--r--riscos/gui.h1
-rw-r--r--riscos/treeview.c62
-rw-r--r--riscos/wimp_event.c34
-rw-r--r--riscos/wimp_event.h3
-rw-r--r--riscos/window.c47
6 files changed, 125 insertions, 24 deletions
diff --git a/riscos/gui.c b/riscos/gui.c
index 0ecb2bd76..645dc4dfc 100644
--- a/riscos/gui.c
+++ b/riscos/gui.c
@@ -1033,7 +1033,7 @@ void ro_gui_handle_event(wimp_event_no event, wimp_block *block)
break;
case wimp_SCROLL_REQUEST:
- ro_gui_scroll_request(&(block->scroll));
+ ro_gui_wimp_event_scroll_window(&(block->scroll));
break;
case wimp_USER_MESSAGE:
diff --git a/riscos/gui.h b/riscos/gui.h
index 1ed58cb29..284ae2e44 100644
--- a/riscos/gui.h
+++ b/riscos/gui.h
@@ -133,7 +133,6 @@ bool ro_gui_download_prequit(void);
void ro_gui_401login_init(void);
/* in window.c */
-void ro_gui_scroll_request(wimp_scroll *scroll);
bool ro_gui_window_dataload(struct gui_window *g, wimp_message *message);
void ro_gui_window_mouse_at(struct gui_window *g, wimp_pointer *pointer);
void ro_gui_window_iconise(struct gui_window *g,
diff --git a/riscos/treeview.c b/riscos/treeview.c
index 91f0c19ab..cb184587d 100644
--- a/riscos/treeview.c
+++ b/riscos/treeview.c
@@ -99,6 +99,7 @@ static void ro_treeview_get_window_dimensions(int *width, int *height,
void *pw);
static void ro_treeview_redraw(wimp_draw *redraw);
+static void ro_treeview_scroll(wimp_scroll *scroll);
static void ro_treeview_redraw_loop(wimp_draw *redraw, ro_treeview *tv,
osbool more);
static void ro_treeview_open(wimp_open *open);
@@ -192,6 +193,7 @@ ro_treeview *ro_treeview_create(wimp_w window, struct toolbar *toolbar,
/* Register wimp events to handle the supplied window. */
ro_gui_wimp_event_register_redraw_window(tv->w, ro_treeview_redraw);
+ ro_gui_wimp_event_register_scroll_window(tv->w, ro_treeview_scroll);
ro_gui_wimp_event_register_open_window(tv->w, ro_treeview_open);
ro_gui_wimp_event_register_mouse_click(tv->w, ro_treeview_mouse_click);
ro_gui_wimp_event_register_keypress(tv->w, ro_treeview_keypress);
@@ -333,6 +335,7 @@ void ro_treeview_redraw_request(int x, int y, int width, int height,
ro_treeview_redraw_loop(&update, tv, more);
}
}
+
/**
* Pass RISC OS redraw events on to the treeview widget.
*
@@ -367,6 +370,65 @@ void ro_treeview_redraw(wimp_draw *redraw)
}
/**
+ * Handle scroll events in treeview windows.
+ *
+ * \param *scroll Pointer to Scroll Event block.
+ */
+
+void ro_treeview_scroll(wimp_scroll *scroll)
+{
+ os_error *error;
+ int x = scroll->visible.x1 - scroll->visible.x0 - 32;
+ int y = scroll->visible.y1 - scroll->visible.y0 - 32;
+ struct toolbar *toolbar = ro_toolbar_parent_window_lookup(scroll->w);
+
+ if (toolbar != NULL)
+ y -= ro_toolbar_full_height(toolbar);
+
+ 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:
+ scroll->xscroll += (x * (scroll->xmin>>2)) >> 2;
+ 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:
+ scroll->yscroll += (y * (scroll->ymin>>2)) >> 2;
+ break;
+ }
+
+ error = xwimp_open_window((wimp_open *) scroll);
+ if (error) {
+ LOG(("xwimp_open_window: 0x%x: %s",
+ error->errnum, error->errmess));
+ }
+}
+
+/**
* Redraw a treeview window, once the initial readraw block has been collected.
*
* /param *redraw Pointer to redraw block.
diff --git a/riscos/wimp_event.c b/riscos/wimp_event.c
index 384a5258e..7dea8ed12 100644
--- a/riscos/wimp_event.c
+++ b/riscos/wimp_event.c
@@ -95,6 +95,7 @@ struct event_window {
void (*open_window)(wimp_open *open);
void (*close_window)(wimp_w w);
void (*redraw_window)(wimp_draw *redraw);
+ void (*scroll_window)(wimp_scroll *scroll);
bool (*menu_prepare)(wimp_w w, wimp_i i, wimp_menu *m,
wimp_pointer *p);
bool (*menu_selection)(wimp_w w, wimp_i i, wimp_menu *m,
@@ -1115,6 +1116,24 @@ bool ro_gui_wimp_event_redraw_window(wimp_draw *redraw)
/**
+ * Handle any scroll window requests
+ *
+ * \param scroll the window scroll request
+ */
+bool ro_gui_wimp_event_scroll_window(wimp_scroll *scroll)
+{
+ struct event_window *window;
+
+ window = ro_gui_wimp_event_find_window(scroll->w);
+ if ((window) && (window->scroll_window)) {
+ window->scroll_window(scroll);
+ return true;
+ }
+ return false;
+}
+
+
+/**
* Process a Menu click in a window, by checking for a registered window
* menu and opening it if one is found.
*
@@ -1455,6 +1474,21 @@ bool ro_gui_wimp_event_register_redraw_window(wimp_w w,
return true;
}
+/**
+ * Register a function to be called for all window scroll requests.
+ */
+
+bool ro_gui_wimp_event_register_scroll_window(wimp_w w,
+ void (*callback)(wimp_scroll *scroll))
+{
+ struct event_window *window;
+
+ window = ro_gui_wimp_event_get_window(w);
+ if (!window)
+ return false;
+ window->scroll_window = callback;
+ return true;
+}
/**
* Register a function to be called before a menu is (re-)opened.
diff --git a/riscos/wimp_event.h b/riscos/wimp_event.h
index f232291d8..650f35c91 100644
--- a/riscos/wimp_event.h
+++ b/riscos/wimp_event.h
@@ -60,6 +60,7 @@ bool ro_gui_wimp_event_keypress(wimp_key *key);
bool ro_gui_wimp_event_open_window(wimp_open *open);
bool ro_gui_wimp_event_close_window(wimp_w w);
bool ro_gui_wimp_event_redraw_window(wimp_draw *redraw);
+bool ro_gui_wimp_event_scroll_window(wimp_scroll *scroll);
bool ro_gui_wimp_event_process_window_menu_click(wimp_pointer *pointer);
bool ro_gui_wimp_event_prepare_menu(wimp_w w, wimp_i i, wimp_menu *menu);
@@ -90,6 +91,8 @@ bool ro_gui_wimp_event_register_close_window(wimp_w w,
void (*callback)(wimp_w w));
bool ro_gui_wimp_event_register_redraw_window(wimp_w w,
void (*callback)(wimp_draw *redraw));
+bool ro_gui_wimp_event_register_scroll_window(wimp_w w,
+ void (*callback)(wimp_scroll *scroll));
bool ro_gui_wimp_event_register_menu_prepare(wimp_w w,
bool (*callback)(wimp_w w, wimp_i i, wimp_menu *m,
wimp_pointer *p));
diff --git a/riscos/window.c b/riscos/window.c
index 9dac13f56..8ad696d9a 100644
--- a/riscos/window.c
+++ b/riscos/window.c
@@ -91,6 +91,7 @@
static void gui_window_set_extent(struct gui_window *g, int width, int height);
static void ro_gui_window_redraw(wimp_draw *redraw);
+static void ro_gui_window_scroll(wimp_scroll *scroll);
static void ro_gui_window_open(wimp_open *open);
static void ro_gui_window_close(wimp_w w);
static bool ro_gui_window_click(wimp_pointer *mouse);
@@ -537,6 +538,7 @@ struct gui_window *gui_create_browser_window(struct browser_window *bw,
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_scroll_window(g->window, ro_gui_window_scroll);
ro_gui_wimp_event_register_keypress(g->window, ro_gui_window_keypress);
ro_gui_wimp_event_register_mouse_click(g->window, ro_gui_window_click);
ro_gui_wimp_event_register_menu(g->window, ro_gui_browser_window_menu,
@@ -2959,16 +2961,12 @@ void ro_gui_window_menu_close(wimp_w w, wimp_i i, wimp_menu *menu)
/**
- * Process Scroll_Request events.
+ * Process Scroll_Request events in a browser window.
*
- * \TODO -- This handles Scroll Events for all windows, not just browser
- * windows. Either it needs to move somewhere else, or the
- * code needs to be split and Scroll Events dispatched via the
- * Wimp_Event module. Currently it doesn't properly handle
- * events affecting treeview windows, anyway.
+ * \param *scroll The wimp scroll event data block.
*/
-void ro_gui_scroll_request(wimp_scroll *scroll)
+void ro_gui_window_scroll(wimp_scroll *scroll)
{
struct gui_window *g = ro_gui_window_lookup(scroll->w);
struct toolbar *toolbar;
@@ -2997,9 +2995,9 @@ void ro_gui_scroll_request(wimp_scroll *scroll)
} else {
int x = scroll->visible.x1 - scroll->visible.x0 - 32;
int y = scroll->visible.y1 - scroll->visible.y0 - 32;
+ int xstep = 0, ystep = 0;
os_error *error;
- /* This has to handle all windows, not just browser ones. */
toolbar = ro_toolbar_parent_window_lookup(scroll->w);
assert(g == NULL || g->toolbar == NULL ||
g->toolbar == toolbar);
@@ -3008,44 +3006,49 @@ void ro_gui_scroll_request(wimp_scroll *scroll)
switch (scroll->xmin) {
case wimp_SCROLL_PAGE_LEFT:
- scroll->xscroll -= x;
+ xstep = -x;
break;
case wimp_SCROLL_COLUMN_LEFT:
- scroll->xscroll -= 32;
+ xstep = -32;
break;
case wimp_SCROLL_COLUMN_RIGHT:
- scroll->xscroll += 32;
+ xstep = 32;
break;
case wimp_SCROLL_PAGE_RIGHT:
- scroll->xscroll += x;
+ xstep = x;
break;
default:
- scroll->xscroll += (x * (scroll->xmin>>2)) >> 2;
+ xstep = (x * (scroll->xmin>>2)) >> 2;
break;
}
switch (scroll->ymin) {
case wimp_SCROLL_PAGE_UP:
- scroll->yscroll += y;
+ ystep = y;
break;
case wimp_SCROLL_LINE_UP:
- scroll->yscroll += 32;
+ ystep = 32;
break;
case wimp_SCROLL_LINE_DOWN:
- scroll->yscroll -= 32;
+ ystep = -32;
break;
case wimp_SCROLL_PAGE_DOWN:
- scroll->yscroll -= y;
+ ystep = -y;
break;
default:
- scroll->yscroll += (y * (scroll->ymin>>2)) >> 2;
+ ystep = (y * (scroll->ymin>>2)) >> 2;
break;
}
- error = xwimp_open_window((wimp_open *) scroll);
- if (error) {
- LOG(("xwimp_open_window: 0x%x: %s",
- error->errnum, error->errmess));
+ if (xstep != 0 || ystep != 0) {
+ scroll->xscroll += xstep;
+ scroll->yscroll += ystep;
+
+ error = xwimp_open_window((wimp_open *) scroll);
+ if (error) {
+ LOG(("xwimp_open_window: 0x%x: %s",
+ error->errnum, error->errmess));
+ }
}
}
}