NetSurf
Macros | Functions | Variables
corewindow.c File Reference

RISC OS generic core window implementation. More...

#include <stdint.h>
#include <oslib/wimp.h>
#include "utils/log.h"
#include "netsurf/types.h"
#include "netsurf/mouse.h"
#include "netsurf/keypress.h"
#include "riscos/wimp_event.h"
#include "riscos/dialog.h"
#include "riscos/gui.h"
#include "riscos/window.h"
#include "riscos/toolbar.h"
#include "riscos/mouse.h"
#include "riscos/wimputils.h"
#include "riscos/corewindow.h"
Include dependency graph for corewindow.c:

Go to the source code of this file.

Macros

#define wimp_KEY_END   wimp_KEY_COPY
 

Functions

static void update_scrollbars (struct ro_corewindow *ro_cw, wimp_open *open)
 Update a windows scrollbars. More...
 
static void ro_cw_redraw (wimp_draw *redraw)
 wimp callback on redraw event More...
 
static void ro_cw_scroll (wimp_scroll *scroll)
 
static void ro_cw_mouse_at (wimp_pointer *pointer, void *data)
 Track the mouse under Null Polls from the wimp, to support dragging. More...
 
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(). More...
 
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. More...
 
static void ro_cw_pointer_leaving (wimp_leaving *leaving, void *data)
 Handle Pointer Leaving Window events. More...
 
static void ro_cw_pointer_entering (wimp_entering *entering)
 Wimp callback on pointer entering window. More...
 
static void ro_cw_open (wimp_open *open)
 Wimp callback on window open event. More...
 
static bool ro_cw_mouse_click (wimp_pointer *pointer)
 
static bool ro_cw_keypress (wimp_key *key)
 
static void cw_tb_size (void *ctx)
 Update a corewindow toolbar to a new size. More...
 
static void cw_tb_theme (void *ctx, bool exists)
 Update a corewindow toolbar to use a new theme. More...
 
static void cw_tb_update (void *ctx)
 Allow a corewindow toolbar button state to be updated. More...
 
static void cw_tb_click (void *ctx, toolbar_action_type action_type, union toolbar_action action)
 Respond to user actions (click) in a corewindow. More...
 
static void cw_tb_save (void *ctx, char *config)
 Save positions of core window toolbar buttons. More...
 
static nserror ro_cw_invalidate (struct core_window *cw, const struct rect *r)
 callback from core to request an invalidation of a window area. More...
 
static nserror ro_cw_update_size (struct core_window *cw, int width, int height)
 Callback from the core to update the content area size. More...
 
static nserror ro_cw_get_scroll (const struct core_window *cw, int *x, int *y)
 Callback from the core to scroll the visible content. More...
 
static nserror ro_cw_set_scroll (struct core_window *cw, int x, int y)
 Callback from the core to scroll the visible content. More...
 
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. More...
 
static nserror ro_cw_drag_status (struct core_window *cw, core_window_drag_status ds)
 Callback from the core to update the drag status. More...
 
static nserror dummy_toolbar_click (struct ro_corewindow *ro_cw, button_bar_action action)
 dummy toolbar click callback More...
 
static nserror dummy_toolbar_update (struct ro_corewindow *ro_cw)
 dummy toolbar update callback More...
 
static nserror dummy_toolbar_save (struct ro_corewindow *ro_cw, char *config)
 dummy toolbar save callback More...
 
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. More...
 
nserror ro_corewindow_fini (struct ro_corewindow *ro_cw)
 finalise elements of ro core window. More...
 

Variables

static struct ro_corewindowro_cw_drag_cw
 
static const struct toolbar_callbacks corewindow_toolbar_callbacks
 riscos core window toolbar callbacks More...
 
struct core_window_table ro_cw_cb_table
 
struct core_window_tableriscos_core_window_table = &ro_cw_cb_table
 

Detailed Description

RISC OS generic core window implementation.

Provides interface for core renderers to a risc os drawing area.

This module is an object that must be encapsulated. Client users should embed a struct ro_corewindow at the beginning of their context for this display surface, fill in relevant data and then call ro_corewindow_init()

The ro core window structure requires the callback for draw, key and mouse operations.

Definition in file corewindow.c.

Macro Definition Documentation

◆ wimp_KEY_END

#define wimp_KEY_END   wimp_KEY_COPY

Definition at line 52 of file corewindow.c.

Function Documentation

◆ cw_tb_click()

static void cw_tb_click ( void *  ctx,
toolbar_action_type  action_type,
union toolbar_action  action 
)
static

Respond to user actions (click) in a corewindow.

Parameters
ctxContext as passed to toolbar creation.
action_typetype of action on toolbar
actiondata for action.

Definition at line 727 of file corewindow.c.

References toolbar_action::button, TOOLBAR_ACTION_BUTTON, ro_corewindow::toolbar_click, and ro_corewindow::toolbar_update.

◆ cw_tb_save()

static void cw_tb_save ( void *  ctx,
char *  config 
)
static

Save positions of core window toolbar buttons.

Parameters
ctxContext as passed to toolbar creation.
configThe new button config string.

Definition at line 748 of file corewindow.c.

References ro_corewindow::toolbar_save.

◆ cw_tb_size()

static void cw_tb_size ( void *  ctx)
static

Update a corewindow toolbar to a new size.

Parameters
ctxContext as passed to toolbar creation.

Definition at line 661 of file corewindow.c.

References NSLOG, ro_corewindow::origin_y, ro_toolbar_height(), ro_corewindow::toolbar, and ro_corewindow::wh.

Referenced by cw_tb_theme().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cw_tb_theme()

static void cw_tb_theme ( void *  ctx,
bool  exists 
)
static

Update a corewindow toolbar to use a new theme.

Parameters
ctxContext as passed to toolbar creation.
existstrue if the bar still exists; else false.

Definition at line 696 of file corewindow.c.

References cw_tb_size().

Here is the call graph for this function:

◆ cw_tb_update()

static void cw_tb_update ( void *  ctx)
static

Allow a corewindow toolbar button state to be updated.

Parameters
ctxContext as passed to toolbar creation.

Definition at line 709 of file corewindow.c.

References ro_corewindow::toolbar_update.

◆ dummy_toolbar_click()

static nserror dummy_toolbar_click ( struct ro_corewindow ro_cw,
button_bar_action  action 
)
static

dummy toolbar click callback

Definition at line 980 of file corewindow.c.

References NSERROR_OK.

Referenced by ro_corewindow_init().

Here is the caller graph for this function:

◆ dummy_toolbar_save()

static nserror dummy_toolbar_save ( struct ro_corewindow ro_cw,
char *  config 
)
static

dummy toolbar save callback

Definition at line 996 of file corewindow.c.

References NSERROR_OK.

Referenced by ro_corewindow_init().

Here is the caller graph for this function:

◆ dummy_toolbar_update()

static nserror dummy_toolbar_update ( struct ro_corewindow ro_cw)
static

dummy toolbar update callback

Definition at line 988 of file corewindow.c.

References NSERROR_OK.

Referenced by ro_corewindow_init().

Here is the caller graph for this function:

◆ ro_corewindow_fini()

nserror ro_corewindow_fini ( struct ro_corewindow ro_cw)

finalise elements of ro core window.

Parameters
ro_cwA riscos core window structure to initialise
Returns
NSERROR_OK on successful finalisation otherwise error code.
Todo:
need to consider freeing of toolbar

Definition at line 1078 of file corewindow.c.

References NSERROR_OK, ro_gui_wimp_event_finalise(), and ro_corewindow::wh.

Referenced by ro_gui_cookies_finalise(), ro_gui_global_history_finalise(), ro_gui_hotlist_finalise(), ro_gui_local_history_finalise(), and ro_gui_pageinfo_finalise().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ro_corewindow_init()

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.

As a pre-requisite the draw, key and mouse callbacks must be defined

Parameters
ro_cwA riscos core window structure to initialise
tb_buttonstoolbar button bar context
tb_orderThe order of toolbar buttons
tb_styleThe style of toolbar buttons
tb_helpThh toolbar help text
Returns
NSERROR_OK on successful initialisation otherwise error code.

Definition at line 1003 of file corewindow.c.

References ro_corewindow::content_height, ro_corewindow::content_width, CORE_WINDOW_DRAG_NONE, corewindow_toolbar_callbacks, ro_corewindow::drag_status, dummy_toolbar_click(), dummy_toolbar_save(), dummy_toolbar_update(), NSERROR_INIT_FAILED, NSERROR_OK, NSLOG, ro_corewindow::origin_y, ro_cw_keypress(), ro_cw_mouse_click(), ro_cw_open(), ro_cw_pointer_entering(), ro_cw_redraw(), ro_cw_scroll(), ro_gui_wimp_event_register_keypress(), ro_gui_wimp_event_register_mouse_click(), ro_gui_wimp_event_register_open_window(), ro_gui_wimp_event_register_pointer_entering_window(), ro_gui_wimp_event_register_redraw_window(), ro_gui_wimp_event_register_scroll_window(), ro_gui_wimp_event_set_user_data(), ro_toolbar_add_buttons(), ro_toolbar_create(), ro_toolbar_height(), ro_toolbar_rebuild(), tb_buttons, ro_corewindow::toolbar, ro_corewindow::toolbar_click, TOOLBAR_FLAGS_NONE, ro_corewindow::toolbar_save, ro_corewindow::toolbar_update, and ro_corewindow::wh.

Referenced by ro_cookie_init(), ro_global_history_init(), ro_hotlist_init(), ro_local_history_init(), and ro_pageinfo_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ro_cw_drag_end()

static void ro_cw_drag_end ( wimp_dragged *  drag,
void *  data 
)
static

Process RISC OS User Drag Box events which relate to us: in effect, drags started by ro_cw_drag_start().

Parameters
dragPointer to the User Drag Box Event block.
dataNULL to allow use as a ro_mouse callback.

Definition at line 309 of file corewindow.c.

References NSLOG, and ro_warn_user().

Referenced by ro_cw_drag_start().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ro_cw_drag_start()

static void ro_cw_drag_start ( struct ro_corewindow ro_cw,
wimp_pointer *  pointer,
wimp_window_state *  state 
)
static

Start a RISC OS drag event to reflect on screen what is happening during the core tree drag.

Parameters
ro_cwThe RO corewindow to which the drag is attached.
pointerThe RO pointer event data block starting the drag.
stateThe RO window state block for the treeview window.

Definition at line 338 of file corewindow.c.

References CORE_WINDOW_DRAG_MOVE, CORE_WINDOW_DRAG_SELECTION, ro_corewindow::drag_status, NSLOG, ro_cw_drag_cw, ro_cw_drag_end(), ro_cw_mouse_at(), ro_mouse_drag_start(), ro_toolbar_height(), ro_warn_user(), ro_corewindow::toolbar, and ro_corewindow::wh.

Referenced by ro_cw_mouse_click().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ro_cw_drag_status()

static nserror ro_cw_drag_status ( struct core_window *  cw,
core_window_drag_status  ds 
)
static

Callback from the core to update the drag status.

Definition at line 956 of file corewindow.c.

References ro_corewindow::drag_status, and NSERROR_OK.

◆ ro_cw_get_scroll()

static nserror ro_cw_get_scroll ( const struct core_window *  cw,
int *  x,
int *  y 
)
static

Callback from the core to scroll the visible content.

Definition at line 862 of file corewindow.c.

References NSERROR_INVALID, NSERROR_OK, NSLOG, and ro_corewindow::wh.

◆ ro_cw_get_window_dimensions()

static nserror ro_cw_get_window_dimensions ( const struct core_window *  cw,
int *  width,
int *  height 
)
static

Callback from the core to obtain the window viewport dimensions.

Parameters
[in]cwthe core window object
[out]widthto be set to viewport width in px
[out]heightto be set to viewport height in px

Definition at line 922 of file corewindow.c.

References height, NSERROR_INVALID, NSERROR_OK, NSLOG, ro_toolbar_full_height(), ro_corewindow::toolbar, ro_corewindow::wh, and width.

Here is the call graph for this function:

◆ ro_cw_invalidate()

static nserror ro_cw_invalidate ( struct core_window *  cw,
const struct rect r 
)
static

callback from core to request an invalidation of a window area.

The specified area of the window should now be considered out of date. If the area is NULL the entire window must be invalidated.

Parameters
[in]cwThe core window to invalidate.
[in]rarea to redraw or NULL for the entire window area.
Returns
NSERROR_OK on success or appropriate error code.

Definition at line 783 of file corewindow.c.

References NSERROR_INVALID, NSERROR_OK, NSLOG, ro_corewindow::origin_y, ro_corewindow::wh, rect::x0, rect::x1, rect::y0, and rect::y1.

◆ ro_cw_keypress()

static bool ro_cw_keypress ( wimp_key *  key)
static

Definition at line 544 of file corewindow.c.

References IS_WIMP_KEY, ro_corewindow::key, NS_KEY_DELETE_LEFT, NS_KEY_DELETE_LINE_END, NS_KEY_DELETE_LINE_START, NS_KEY_DELETE_RIGHT, NS_KEY_DOWN, NS_KEY_LEFT, NS_KEY_LINE_END, NS_KEY_LINE_START, NS_KEY_PAGE_DOWN, NS_KEY_PAGE_UP, NS_KEY_RIGHT, NS_KEY_TEXT_END, NS_KEY_TEXT_START, NS_KEY_UP, NS_KEY_WORD_LEFT, NS_KEY_WORD_RIGHT, NSERROR_OK, NSLOG, os_version, RISCOS5, ro_gui_ctrl_pressed(), ro_gui_wimp_event_get_user_data(), ro_corewindow::toolbar_update, and wimp_KEY_END.

Referenced by ro_corewindow_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ro_cw_mouse_at()

static void ro_cw_mouse_at ( wimp_pointer *  pointer,
void *  data 
)
static

Track the mouse under Null Polls from the wimp, to support dragging.

Parameters
pointerPointer to a Wimp Pointer block.
dataNULL to allow use as a ro_mouse callback.

Definition at line 241 of file corewindow.c.

References BROWSER_MOUSE_DRAG_ON, BROWSER_MOUSE_HOVER, CORE_WINDOW_DRAG_NONE, ro_corewindow::drag_status, ro_corewindow::mouse, NSLOG, ro_corewindow::origin_y, ro_cw_drag_cw, ro_gui_mouse_drag_state(), ro_gui_wimp_event_get_user_data(), and ro_corewindow::toolbar_update.

Referenced by ro_cw_drag_start(), and ro_cw_pointer_entering().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ro_cw_mouse_click()

static bool ro_cw_mouse_click ( wimp_pointer *  pointer)
static

Definition at line 463 of file corewindow.c.

References BROWSER_MOUSE_CLICK_1, CORE_WINDOW_DRAG_MOVE, CORE_WINDOW_DRAG_SELECTION, ro_corewindow::drag_status, ro_corewindow::mouse, NSLOG, ro_corewindow::origin_y, ro_cw_drag_start(), ro_gui_dialog_close(), ro_gui_mouse_click_state(), ro_gui_wimp_event_get_user_data(), ro_gui_wimp_event_process_window_menu_click(), ro_corewindow::toolbar_update, and ro_corewindow::wh.

Referenced by ro_corewindow_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ro_cw_open()

static void ro_cw_open ( wimp_open *  open)
static

Wimp callback on window open event.

The wimp has issued an event to the window because an attempt has been made to open or resize it. This requires the new dimensions to be calculated and set within the wimp.

Parameters
openThe open event to be processed

Definition at line 454 of file corewindow.c.

References ro_gui_wimp_event_get_user_data(), and update_scrollbars().

Referenced by ro_corewindow_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ro_cw_pointer_entering()

static void ro_cw_pointer_entering ( wimp_entering *  entering)
static

Wimp callback on pointer entering window.

The wimp has issued an event to the window because the pointer has entered it.

Parameters
enteringThe entering event to be processed

Definition at line 439 of file corewindow.c.

References ro_cw_mouse_at(), ro_cw_pointer_leaving(), and ro_mouse_track_start().

Referenced by ro_corewindow_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ro_cw_pointer_leaving()

static void ro_cw_pointer_leaving ( wimp_leaving *  leaving,
void *  data 
)
static

Handle Pointer Leaving Window events.

These events are delivered as the termination callback handler from ro_mouse's mouse tracking.

Parameters
leavingThe Wimp_PointerLeavingWindow block.
dataNULL data pointer.

Definition at line 416 of file corewindow.c.

References BROWSER_MOUSE_LEAVE, ro_corewindow::mouse, NSLOG, and ro_gui_wimp_event_get_user_data().

Referenced by ro_cw_pointer_entering().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ro_cw_redraw()

static void ro_cw_redraw ( wimp_draw *  redraw)
static

wimp callback on redraw event

Definition at line 108 of file corewindow.c.

References ro_corewindow::draw, NSLOG, ro_corewindow::origin_y, ro_gui_wimp_event_get_user_data(), ro_plot_clip_rect, rect::x0, rect::x1, rect::y0, and rect::y1.

Referenced by ro_corewindow_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ro_cw_scroll()

static void ro_cw_scroll ( wimp_scroll *  scroll)
static

Definition at line 147 of file corewindow.c.

References NSLOG, ro_corewindow::origin_y, ro_gui_wimp_event_get_user_data(), and ro_corewindow::wh.

Referenced by ro_corewindow_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ro_cw_set_scroll()

static nserror ro_cw_set_scroll ( struct core_window *  cw,
int  x,
int  y 
)
static

Callback from the core to scroll the visible content.

Definition at line 887 of file corewindow.c.

References NSERROR_INVALID, NSERROR_OK, NSLOG, PTR_WIMP_OPEN, update_scrollbars(), and ro_corewindow::wh.

Here is the call graph for this function:

◆ ro_cw_update_size()

static nserror ro_cw_update_size ( struct core_window *  cw,
int  width,
int  height 
)
static

Callback from the core to update the content area size.

Definition at line 823 of file corewindow.c.

References ro_corewindow::content_height, ro_corewindow::content_width, height, NSERROR_INVALID, NSERROR_OK, NSLOG, update_scrollbars(), ro_corewindow::wh, and width.

Here is the call graph for this function:

◆ update_scrollbars()

static void update_scrollbars ( struct ro_corewindow ro_cw,
wimp_open *  open 
)
static

Update a windows scrollbars.

in the wimp this is done by setting the extent and calling window open

Definition at line 62 of file corewindow.c.

References ro_corewindow::content_height, ro_corewindow::content_width, NSLOG, ro_corewindow::origin_y, and ro_corewindow::wh.

Referenced by ro_cw_open(), ro_cw_set_scroll(), and ro_cw_update_size().

Here is the caller graph for this function:

Variable Documentation

◆ corewindow_toolbar_callbacks

const struct toolbar_callbacks corewindow_toolbar_callbacks
static
Initial value:
= {
.theme_update = cw_tb_theme,
.change_size = cw_tb_size,
.update_buttons = cw_tb_update,
.user_action = cw_tb_click,
.save_buttons = cw_tb_save,
}
static void cw_tb_size(void *ctx)
Update a corewindow toolbar to a new size.
Definition: corewindow.c:661
static void cw_tb_save(void *ctx, char *config)
Save positions of core window toolbar buttons.
Definition: corewindow.c:748
static void cw_tb_update(void *ctx)
Allow a corewindow toolbar button state to be updated.
Definition: corewindow.c:709
static void cw_tb_theme(void *ctx, bool exists)
Update a corewindow toolbar to use a new theme.
Definition: corewindow.c:696
static void cw_tb_click(void *ctx, toolbar_action_type action_type, union toolbar_action action)
Respond to user actions (click) in a corewindow.
Definition: corewindow.c:727

riscos core window toolbar callbacks

Definition at line 762 of file corewindow.c.

Referenced by ro_corewindow_init().

◆ riscos_core_window_table

struct core_window_table* riscos_core_window_table = &ro_cw_cb_table

Definition at line 974 of file corewindow.c.

Referenced by main().

◆ ro_cw_cb_table

struct core_window_table ro_cw_cb_table
Initial value:
= {
.invalidate = ro_cw_invalidate,
.set_extent = ro_cw_update_size,
.set_scroll = ro_cw_set_scroll,
.get_scroll = ro_cw_get_scroll,
.get_dimensions = ro_cw_get_window_dimensions,
.drag_status = ro_cw_drag_status
}
static nserror ro_cw_get_scroll(const struct core_window *cw, int *x, int *y)
Callback from the core to scroll the visible content.
Definition: corewindow.c:862
static nserror ro_cw_drag_status(struct core_window *cw, core_window_drag_status ds)
Callback from the core to update the drag status.
Definition: corewindow.c:956
static nserror ro_cw_update_size(struct core_window *cw, int width, int height)
Callback from the core to update the content area size.
Definition: corewindow.c:823
static nserror ro_cw_set_scroll(struct core_window *cw, int x, int y)
Callback from the core to scroll the visible content.
Definition: corewindow.c:887
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.
Definition: corewindow.c:922
static nserror ro_cw_invalidate(struct core_window *cw, const struct rect *r)
callback from core to request an invalidation of a window area.
Definition: corewindow.c:783

Definition at line 965 of file corewindow.c.

◆ ro_cw_drag_cw

struct ro_corewindow* ro_cw_drag_cw
static

Definition at line 55 of file corewindow.c.

Referenced by ro_cw_drag_start(), and ro_cw_mouse_at().