From abaa8a90938024685d39a10192586d369e44a101 Mon Sep 17 00:00:00 2001 From: Richard Wilson Date: Fri, 16 Jul 2004 16:33:45 +0000 Subject: [project @ 2004-07-16 16:33:44 by rjw] Various fixes for the GUI. Persistant windows are closed when upon a change of content. Hotlist saves in the same format as !Browse. Neater login window. Support for interactive help from hotlist windows. svn path=/import/netsurf/; revision=1081 --- riscos/wimp.c | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) (limited to 'riscos/wimp.c') diff --git a/riscos/wimp.c b/riscos/wimp.c index e125a0419..03d78a2ff 100644 --- a/riscos/wimp.c +++ b/riscos/wimp.c @@ -21,6 +21,7 @@ #include "oslib/wimpreadsysinfo.h" #include "oslib/wimpspriteop.h" #include "netsurf/desktop/gui.h" +#include "netsurf/riscos/gui.h" #include "netsurf/riscos/wimp.h" #include "netsurf/utils/log.h" #include "netsurf/utils/utils.h" @@ -317,6 +318,62 @@ void ro_gui_set_caret_first(wimp_w w) { } +/** + * Opens a window at the centre of either another window or the screen + * + * /param parent the parent window (NULL for centre of screen) + * /param child the child window + */ +void ro_gui_open_window_centre(wimp_w parent, wimp_w child) { + os_error *error; + wimp_window_state state; + int mid_x, mid_y; + int dimension, scroll_width; + + /* Get the parent window state + */ + if (parent) { + state.w = parent; + error = xwimp_get_window_state(&state); + if (error) { + warn_user("WimpError", error->errmess); + return; + } + scroll_width = ro_get_vscroll_width(parent); + + /* Get the centre of the parent + */ + mid_x = (state.visible.x0 + state.visible.x1 + scroll_width) / 2; + mid_y = (state.visible.y0 + state.visible.y1) / 2; + } else { + ro_gui_screen_size(&mid_x, &mid_y); + mid_x /= 2; + mid_y /= 2; + } + + /* Get the child window state + */ + state.w = child; + error = xwimp_get_window_state(&state); + if (error) { + warn_user("WimpError", error->errmess); + return; + } + + /* Move to the centre of the parent at the top of the stack + */ + dimension = state.visible.x1 - state.visible.x0; + scroll_width = ro_get_vscroll_width(hotlist_window); + state.visible.x0 = mid_x - (dimension + scroll_width) / 2; + state.visible.x1 = state.visible.x0 + dimension; + dimension = state.visible.y1 - state.visible.y0; + state.visible.y0 = mid_y - dimension / 2; + state.visible.y1 = state.visible.y0 + dimension; + state.next = wimp_TOP; + wimp_open_window((wimp_open *) &state); +} + + /** * Load a sprite file into memory. * -- cgit v1.2.3