NetSurf
core_window.h
Go to the documentation of this file.
1/*
2 * Copyright 2012 Michael Drake <tlsa@netsurf-browser.org>
3 *
4 * This file is part of NetSurf, http://www.netsurf-browser.org/
5 *
6 * NetSurf is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
9 *
10 * NetSurf is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19/**
20 * \file
21 * Interface to core window handling.
22 *
23 * This provides a generalised API for frontends to implement which
24 * allows them to provide a single implementation for general window
25 * operations on their platform.
26 *
27 * General core implementations (cookie manager, global history,
28 * hotlist and ssl certificate viewer) use this API to perform
29 * operations like drawing and user input in a portable way.
30 */
31
32#ifndef _NETSURF_CORE_WINDOW_H_
33#define _NETSURF_CORE_WINDOW_H_
34
35struct core_window;
36struct rect;
37
38/**
39 * drag status passed to drag_status callback
40 */
41typedef enum {
47
48/**
49 * Core user interface window function table.
50 *
51 * function table implementing core window operations
52 */
54 /**
55 * Invalidate an area of a window.
56 *
57 * The specified area of the window should now be considered
58 * out of date. If the area is NULL the entire window must be
59 * invalidated. It is expected that the windowing system will
60 * then subsequently cause redraw/expose operations as
61 * necessary.
62 *
63 * \note the frontend should not attempt to actually start the
64 * redraw operations as a result of this callback because the
65 * core redraw functions may already be threaded.
66 *
67 * \param[in] cw The core window to invalidate.
68 * \param[in] rect area to redraw or NULL for the entire window area
69 * \return NSERROR_OK on success or appropriate error code
70 */
71 nserror (*invalidate)(struct core_window *cw, const struct rect *rect);
72
73 /**
74 * Update the logical extent of the window
75 *
76 * \param[in] cw the core window object
77 * \param[in] width the width in px, or negative if don't care
78 * \param[in] height the height in px, or negative if don't care
79 * \return NSERROR_OK on success or appropriate error code
80 */
81 nserror (*set_extent)(struct core_window *cw, int width, int height);
82
83 /**
84 * Scroll the window to given scroll offsets
85 *
86 * Note: Core callers of this may want to look at calling
87 * the `cw_helper_scroll_visible()`, rather than calling
88 * this directly.
89 *
90 * \param[in] cw the core window object
91 * \param[in] x x-scroll value to set
92 * \param[in] y y-scroll value to set
93 * \return NSERROR_OK on success or appropriate error code
94 */
95 nserror (*set_scroll)(struct core_window *cw, int x, int y);
96
97 /**
98 * Get the current scroll offsets
99 *
100 * \param[in] cw the core window object
101 * \param[out] returns horizontal scroll in px
102 * \param[out] returns vertical scroll in px
103 * \return NSERROR_OK on success or appropriate error code
104 */
105 nserror (*get_scroll)(const struct core_window *cw, int *x, int *y);
106
107 /**
108 * Get window viewport dimensions
109 *
110 * \param[in] cw the core window object
111 * \param[out] width to be set to viewport width in px
112 * \param[out] height to be set to viewport height in px
113 * \return NSERROR_OK on success or appropriate error code
114 */
115 nserror (*get_dimensions)(const struct core_window *cw,
116 int *width, int *height);
117
118 /**
119 * Inform corewindow owner of drag status
120 *
121 * \param[in] cw the core window object
122 * \param[in] ds the current drag status
123 * \return NSERROR_OK on success or appropriate error code
124 */
125 nserror (*drag_status)(struct core_window *cw,
127};
128
129
130#endif
core_window_drag_status
drag status passed to drag_status callback
Definition: core_window.h:41
@ CORE_WINDOW_DRAG_NONE
Definition: core_window.h:42
@ CORE_WINDOW_DRAG_MOVE
Definition: core_window.h:45
@ CORE_WINDOW_DRAG_TEXT_SELECTION
Definition: core_window.h:44
@ CORE_WINDOW_DRAG_SELECTION
Definition: core_window.h:43
nserror
Enumeration of error codes.
Definition: errors.h:29
int width
Definition: gui.c:160
int height
Definition: gui.c:161
Core user interface window function table.
Definition: core_window.h:53
nserror(* set_extent)(struct core_window *cw, int width, int height)
Update the logical extent of the window.
Definition: core_window.h:81
nserror(* get_dimensions)(const struct core_window *cw, int *width, int *height)
Get window viewport dimensions.
Definition: core_window.h:115
nserror(* drag_status)(struct core_window *cw, core_window_drag_status ds)
Inform corewindow owner of drag status.
Definition: core_window.h:125
nserror(* invalidate)(struct core_window *cw, const struct rect *rect)
Invalidate an area of a window.
Definition: core_window.h:71
nserror(* get_scroll)(const struct core_window *cw, int *x, int *y)
Get the current scroll offsets.
Definition: core_window.h:105
nserror(* set_scroll)(struct core_window *cw, int x, int y)
Scroll the window to given scroll offsets.
Definition: core_window.h:95
Rectangle coordinates.
Definition: types.h:40
struct rect rect
Rectangle coordinates.