35#include <oslib/wimp.h>
52#define wimp_KEY_END wimp_KEY_COPY
69 NSLOG(netsurf, INFO,
"RO corewindow context %p", ro_cw);
72 extent_width = open->visible.x1 - open->visible.x0;
73 extent_height = open->visible.y0 - open->visible.y1;
75 "extent w:%d h:%d content w:%d h:%d origin h:%d", extent_width,
84 NSLOG(netsurf, INFO,
"extent w:%d h:%d", extent_width, extent_height);
86 extent.y0 = extent_height;
87 extent.x1 = extent_width;
90 error = xwimp_set_extent(ro_cw->
wh, &extent);
92 NSLOG(netsurf, INFO,
"xwimp_set_extent: 0x%x: %s",
93 error->errnum, error->errmess);
97 error = xwimp_open_window(open);
99 NSLOG(netsurf, INFO,
"xwimp_open_window: 0x%x: %s",
100 error->errnum, error->errmess);
119 error = xwimp_redraw_window(redraw, &more);
120 while ((error == NULL) && (more)) {
122 origin_x = redraw->box.x0 - redraw->xscroll;
138 error = xwimp_get_rectangle(redraw, &more);
141 NSLOG(netsurf, INFO,
"xwimp_redraw_window: 0x%x: %s",
142 error->errnum, error->errmess);
154 wimp_window_state state;
157 NSLOG(netsurf, INFO,
"RO corewindow context %p", ro_cw);
160 error = xwimp_get_window_state(&state);
162 NSLOG(netsurf, INFO,
"xwimp_get_window_state: 0x%x: %s",
163 error->errnum, error->errmess);
168 if (!(state.flags & wimp_WINDOW_OPEN)) {
172 page_x = scroll->visible.x1 - scroll->visible.x0 - 32;
173 page_y = scroll->visible.y1 - scroll->visible.y0 - 32;
178 open.visible = scroll->visible;
179 open.next = scroll->next;
181 switch (scroll->xmin) {
182 case wimp_SCROLL_PAGE_LEFT:
183 open.xscroll = scroll->xscroll - page_x;
186 case wimp_SCROLL_COLUMN_LEFT:
187 open.xscroll = scroll->xscroll - 32;
190 case wimp_SCROLL_COLUMN_RIGHT:
191 open.xscroll = scroll->xscroll + 32;
194 case wimp_SCROLL_PAGE_RIGHT:
195 open.xscroll = scroll->xscroll + page_x;
199 open.xscroll = scroll->xscroll + ((page_x * (scroll->xmin>>2)) >> 2);
203 switch (scroll->ymin) {
204 case wimp_SCROLL_PAGE_UP:
205 open.yscroll = scroll->yscroll + page_y;
208 case wimp_SCROLL_LINE_UP:
209 open.yscroll = scroll->yscroll + 32;
212 case wimp_SCROLL_LINE_DOWN:
213 open.yscroll = scroll->yscroll - 32;
216 case wimp_SCROLL_PAGE_DOWN:
217 open.yscroll = scroll->yscroll - page_y;
221 open.yscroll = scroll->yscroll + ((page_y * (scroll->ymin>>2)) >> 2);
225 error = xwimp_open_window(&open);
227 NSLOG(netsurf, INFO,
"xwimp_open_window: 0x%x: %s",
228 error->errnum, error->errmess);
245 wimp_window_state state;
250 if (pointer->buttons & (wimp_CLICK_MENU)) {
256 NSLOG(netsurf, INFO,
"no corewindow conext for window: 0x%x",
257 (
unsigned int)pointer->w);
261 NSLOG(netsurf, DEEPDEBUG,
"Called without drag window: %p",
265 NSLOG(netsurf, INFO,
"RO corewindow context %p", ro_cw);
268 state.w = pointer->w;
269 error = xwimp_get_window_state(&state);
271 NSLOG(netsurf, INFO,
"xwimp_get_window_state: 0x%x: %s",
272 error->errnum, error->errmess);
279 xpos = ((pointer->pos.x - state.visible.x0) + state.xscroll) / 2;
280 ypos = ((state.visible.y1 - pointer->pos.y) -
281 state.yscroll + ro_cw->
origin_y) / 2;
289 wimp_BUTTON_DOUBLE_CLICK_DRAG);
313 error = xwimp_drag_box((wimp_drag *) -1);
315 NSLOG(netsurf, INFO,
"xwimp_drag_box: 0x%x: %s",
316 error->errnum, error->errmess);
320 error = xwimp_auto_scroll(0, NULL, NULL);
322 NSLOG(netsurf, INFO,
"xwimp_auto_scroll: 0x%x: %s",
323 error->errnum, error->errmess);
339 wimp_pointer *pointer,
340 wimp_window_state *state)
344 wimp_auto_scroll_info auto_scroll;
347 drag.bbox.x0 = state->visible.x0;
348 drag.bbox.y0 = state->visible.y0;
349 drag.bbox.x1 = state->visible.x1;
354 drag.type = wimp_DRAG_USER_RUBBER;
356 drag.initial.x0 = pointer->pos.x;
357 drag.initial.y0 = pointer->pos.y;
358 drag.initial.x1 = pointer->pos.x;
359 drag.initial.y1 = pointer->pos.y;
363 drag.type = wimp_DRAG_USER_POINT;
365 drag.initial.x0 = pointer->pos.x - 4;
366 drag.initial.y0 = pointer->pos.y - 48;
367 drag.initial.x1 = pointer->pos.x + 48;
368 drag.initial.y1 = pointer->pos.y + 4;
376 NSLOG(netsurf, INFO,
"Drag start...");
378 error = xwimp_drag_box_with_flags(&drag,
379 wimp_DRAG_BOX_KEEP_IN_LINE | wimp_DRAG_BOX_CLIP);
381 NSLOG(netsurf, INFO,
"xwimp_drag_box: 0x%x: %s",
382 error->errnum, error->errmess);
385 auto_scroll.w = ro_cw->
wh;
386 auto_scroll.pause_zone_sizes.x0 = 80;
387 auto_scroll.pause_zone_sizes.y0 = 80;
388 auto_scroll.pause_zone_sizes.x1 = 80;
390 auto_scroll.pause_duration = 0;
391 auto_scroll.state_change = (
void *) 1;
393 error = xwimp_auto_scroll(wimp_AUTO_SCROLL_ENABLE_VERTICAL,
396 NSLOG(netsurf, INFO,
"xwimp_auto_scroll: 0x%x: %s",
397 error->errnum, error->errmess);
422 NSLOG(netsurf, INFO,
"no corewindow conext for window: 0x%x",
423 (
unsigned int)leaving->w);
466 wimp_window_state state;
469 bool handled =
false;
473 NSLOG(netsurf, INFO,
"RO corewindow context %p", ro_cw);
477 error = xwimp_get_window_state(&state);
479 NSLOG(netsurf, INFO,
"xwimp_get_window_state: 0x%x: %s",
480 error->errnum, error->errmess);
487 xpos = ((pointer->pos.x - state.visible.x0) + state.xscroll) / 2;
488 ypos = ((state.visible.y1 - pointer->pos.y) -
489 state.yscroll + ro_cw->
origin_y) / 2;
491 if (pointer->buttons != wimp_CLICK_MENU) {
493 wimp_BUTTON_DOUBLE_CLICK_DRAG);
499 xwimp_set_caret_position(ro_cw->
wh,
500 -1, -100, -100, 32, -1);
529 switch(pointer->buttons) {
530 case wimp_CLICK_ADJUST:
536 case wimp_CLICK_MENU:
551 NSLOG(netsurf, INFO,
"RO corewindow context %p", ro_cw);
553 c = (uint32_t)
key->c;
555 if ((
unsigned)c < 0x20 ||
556 (0x7f <= c && c <= 0x9f) ||
566 case wimp_KEY_SHIFT | wimp_KEY_TAB:
572 case wimp_KEY_CONTROL | wimp_KEY_LEFT:
583 case wimp_KEY_CONTROL | wimp_KEY_RIGHT:
587 case wimp_KEY_CONTROL | wimp_KEY_UP:
591 case wimp_KEY_CONTROL | wimp_KEY_DOWN:
595 case wimp_KEY_SHIFT | wimp_KEY_LEFT:
599 case wimp_KEY_SHIFT | wimp_KEY_RIGHT:
603 case wimp_KEY_SHIFT | wimp_KEY_UP:
607 case wimp_KEY_SHIFT | wimp_KEY_DOWN:
632 case wimp_KEY_DELETE:
645 res = ro_cw->
key(ro_cw, c);
664 wimp_window_state state;
672 error = xwimp_get_window_state(&state);
674 NSLOG(netsurf, INFO,
"xwimp_get_window_state: 0x%x: %s",
675 error->errnum, error->errmess);
679 error = xwimp_force_redraw(ro_cw->
wh,
680 0, state.visible.y0 - state.visible.y1,
681 state.visible.x1 - state.visible.x0, 0);
683 NSLOG(netsurf, INFO,
"xwimp_force_redraw: 0x%x: %s",
684 error->errnum, error->errmess);
787 wimp_window_info info;
791 error = xwimp_get_window_info_header_only(&info);
794 "xwimp_get_window_info_header_only: 0x%x: %s",
801 info.extent.x0 = 2 * r->
x0;
802 info.extent.y0 = (-2 * (r->
y0 + (r->
y1 - r->
y0))) + ro_cw->
origin_y;
803 info.extent.x1 = 2 * (r->
x0 + (r->
x1 - r->
x0));
804 info.extent.y1 = (-2 * r->
y0) + ro_cw->
origin_y;
807 error = xwimp_force_redraw(ro_cw->
wh,
808 info.extent.x0, info.extent.y0,
809 info.extent.x1, info.extent.y1);
811 NSLOG(netsurf, INFO,
"xwimp_force_redraw: 0x%x: %s",
812 error->errnum, error->errmess);
827 wimp_window_state state;
830 NSLOG(netsurf, INFO,
"content resize from w:%d h:%d to w:%d h:%d",
837 error = xwimp_get_window_state(&state);
839 NSLOG(netsurf, INFO,
"xwimp_get_window_state: 0x%x: %s",
840 error->errnum, error->errmess);
845 if (state.flags & wimp_WINDOW_OPEN) {
847 open.visible = state.visible;
848 open.xscroll = state.xscroll;
849 open.yscroll = state.yscroll;
850 open.next = state.next;
865 wimp_window_state state = {
870 error = xwimp_get_window_state(&state);
872 NSLOG(netsurf, ERROR,
"xwimp_get_window_state: 0x%x: %s",
873 error->errnum, error->errmess);
877 *x = state.xscroll / 2;
878 *y = -state.yscroll / 2;
890 wimp_window_state state = {
895 error = xwimp_get_window_state(&state);
897 NSLOG(netsurf, ERROR,
"xwimp_get_window_state: 0x%x: %s",
898 error->errnum, error->errmess);
902 state.xscroll = x * 2;
903 state.yscroll = -y * 2;
906 if (state.flags & wimp_WINDOW_OPEN) {
927 wimp_window_state state;
930 error = xwimp_get_window_state(&state);
932 NSLOG(netsurf, INFO,
"xwimp_get_window_state: 0x%x: %s",
933 error->errnum, error->errmess);
937 *
width = (state.visible.x1 - state.visible.x0) / 2;
938 *
height = (state.visible.y1 - state.visible.y0) / 2;
1007 const char *tb_help)
1056 NSLOG(netsurf, INFO,
"Setting corewindow %p for window handle %p",
core_window_drag_status
drag status passed to drag_status callback
@ CORE_WINDOW_DRAG_SELECTION
void ro_gui_dialog_close(wimp_w close)
Close a dialog box.
nserror
Enumeration of error codes.
@ NSERROR_INIT_FAILED
Initialisation failed.
@ NSERROR_INVALID
Invalid data.
void ro_mouse_drag_start(void(*drag_end)(wimp_dragged *dragged, void *data), void(*drag_track)(wimp_pointer *pointer, void *data), void(*drag_cancel)(void *data), void *data)
Start a drag, providing a function to be called when the Wimp_DragEnd event is received and optionall...
void ro_mouse_track_start(void(*poll_end)(wimp_leaving *leaving, void *data), void(*poll_track)(wimp_pointer *pointer, void *data), void *data)
Start tracking the mouse in a window, providing a function to be called on null polls and optionally ...
Mouse dragging and tracking support interface for RISC OS.
theme_style
Theme styles, collecting groups of attributes for different locations.
Browser window handling (interface).
Core mouse and pointer states.
browser_mouse_state
Mouse state: 1 is primary mouse button.
@ BROWSER_MOUSE_HOVER
No mouse buttons pressed, May be used to indicate hover or end of drag.
@ BROWSER_MOUSE_CLICK_1
button 1 clicked.
@ BROWSER_MOUSE_LEAVE
pointer leaving window
@ BROWSER_MOUSE_DRAG_ON
a drag operation was started and a mouse button is still pressed
Interface to key press operations.
@ NS_KEY_DELETE_LINE_START
#define NSLOG(catname, level, logmsg, args...)
static const struct toolbar_callbacks corewindow_toolbar_callbacks
riscos core window toolbar callbacks
static nserror ro_cw_get_scroll(const struct core_window *cw, int *x, int *y)
Callback from the core to scroll the visible content.
static void ro_cw_drag_start(struct ro_corewindow *ro_cw, wimp_pointer *pointer, wimp_window_state *state)
Start a RISC OS drag event to reflect on screen what is happening during the core tree drag.
static void ro_cw_drag_end(wimp_dragged *drag, void *data)
Process RISC OS User Drag Box events which relate to us: in effect, drags started by ro_cw_drag_start...
static void cw_tb_size(void *ctx)
Update a corewindow toolbar to a new size.
static void update_scrollbars(struct ro_corewindow *ro_cw, wimp_open *open)
Update a windows scrollbars.
static nserror ro_cw_drag_status(struct core_window *cw, core_window_drag_status ds)
Callback from the core to update the drag status.
static nserror dummy_toolbar_click(struct ro_corewindow *ro_cw, button_bar_action action)
dummy toolbar click callback
static void ro_cw_pointer_entering(wimp_entering *entering)
Wimp callback on pointer entering window.
static bool ro_cw_keypress(wimp_key *key)
static nserror ro_cw_update_size(struct core_window *cw, int width, int height)
Callback from the core to update the content area size.
static void ro_cw_pointer_leaving(wimp_leaving *leaving, void *data)
Handle Pointer Leaving Window events.
static void cw_tb_save(void *ctx, char *config)
Save positions of core window toolbar buttons.
struct core_window_table ro_cw_cb_table
static void cw_tb_update(void *ctx)
Allow a corewindow toolbar button state to be updated.
static bool ro_cw_mouse_click(wimp_pointer *pointer)
static nserror ro_cw_set_scroll(struct core_window *cw, int x, int y)
Callback from the core to scroll the visible content.
static void ro_cw_redraw(wimp_draw *redraw)
wimp callback on redraw event
nserror ro_corewindow_fini(struct ro_corewindow *ro_cw)
finalise elements of ro core window.
static nserror dummy_toolbar_save(struct ro_corewindow *ro_cw, char *config)
dummy toolbar save callback
nserror ro_corewindow_init(struct ro_corewindow *ro_cw, const struct button_bar_buttons *tb_buttons, char *tb_order, theme_style tb_style, const char *tb_help)
initialise elements of riscos core window.
static void cw_tb_theme(void *ctx, bool exists)
Update a corewindow toolbar to use a new theme.
static void ro_cw_scroll(wimp_scroll *scroll)
static nserror ro_cw_get_window_dimensions(const struct core_window *cw, int *width, int *height)
Callback from the core to obtain the window viewport dimensions.
static void cw_tb_click(void *ctx, toolbar_action_type action_type, union toolbar_action action)
Respond to user actions (click) in a corewindow.
static void ro_cw_mouse_at(wimp_pointer *pointer, void *data)
Track the mouse under Null Polls from the wimp, to support dragging.
static struct ro_corewindow * ro_cw_drag_cw
static nserror ro_cw_invalidate(struct core_window *cw, const struct rect *r)
callback from core to request an invalidation of a window area.
static void ro_cw_open(wimp_open *open)
Wimp callback on window open event.
static nserror dummy_toolbar_update(struct ro_corewindow *ro_cw)
dummy toolbar update callback
struct core_window_table * riscos_core_window_table
RISC OS core window interface.
nserror ro_warn_user(const char *warning, const char *detail)
Display a warning for a serious problem (eg memory exhaustion).
struct rect ro_plot_clip_rect
enum browser_mouse_state ro_gui_mouse_click_state(wimp_mouse_state buttons, wimp_icon_flags type)
Returns the state of the mouse buttons and modifiers keys for a mouse action, suitable for passing to...
browser_mouse_state ro_gui_mouse_drag_state(wimp_mouse_state buttons, wimp_icon_flags type)
Returns the state of the mouse buttons and modifiers keys whilst dragging, for passing to the OS-inde...
bool ro_gui_ctrl_pressed(void)
Returns true iff one or more Ctrl keys is held down.
Core user interface window function table.
nserror(* invalidate)(struct core_window *cw, const struct rect *rect)
Invalidate an area of a window.
int origin_y
content plot origin y relative to window
nserror(* toolbar_click)(struct ro_corewindow *ro_cw, button_bar_action action)
callback for clicks in ro core window toolbar.
nserror(* mouse)(struct ro_corewindow *ro_cw, browser_mouse_state mouse_state, int x, int y)
callback for mouse event on ro core window
nserror(* toolbar_save)(struct ro_corewindow *ro_cw, char *config)
callback for saving ro core window toolbar state.
nserror(* key)(struct ro_corewindow *ro_cw, uint32_t nskey)
callback for keypress on ro core window
nserror(* draw)(struct ro_corewindow *ro_cw, int originx, int originy, struct rect *r)
callback to draw on drawable area of ro core window
int content_width
content width
nserror(* toolbar_update)(struct ro_corewindow *ro_cw)
callback for updating state of buttons in ro core window toolbar.
int content_height
content height
struct toolbar * toolbar
toolbar
core_window_drag_status drag_status
drag status set by core
bool ro_gui_wimp_event_register_keypress(wimp_w w, bool(*callback)(wimp_key *key))
Register a function to be called for all keypresses within a particular window.
bool ro_gui_wimp_event_register_redraw_window(wimp_w w, void(*callback)(wimp_draw *redraw))
Register a function to be called for all window redraw operations.
void ro_gui_wimp_event_finalise(wimp_w w)
Free any resources associated with a window.
void * ro_gui_wimp_event_get_user_data(wimp_w w)
Gets the user data associated with a window.
bool ro_gui_wimp_event_register_mouse_click(wimp_w w, bool(*callback)(wimp_pointer *pointer))
Register a function to be called for all mouse-clicks to icons in a window that don't have registered...
bool ro_gui_wimp_event_set_user_data(wimp_w w, void *user)
Sets the user data associated with a window.
bool ro_gui_wimp_event_register_pointer_entering_window(wimp_w w, void(*callback)(wimp_entering *entering))
Register a function to be called for all pointer entering window requests.
bool ro_gui_wimp_event_register_scroll_window(wimp_w w, void(*callback)(wimp_scroll *scroll))
Register a function to be called for all window scroll requests.
bool ro_gui_wimp_event_register_open_window(wimp_w w, void(*callback)(wimp_open *open))
Register a function to be called for all window opening requests.
bool ro_gui_wimp_event_process_window_menu_click(wimp_pointer *pointer)
Process a Menu click in a window, by checking for a registered window menu and opening it if one is f...
Automated RISC OS WIMP event handling (interface).
A collection of grubby utilities for working with OSLib's wimp API.
#define PTR_WIMP_OPEN(pstate)