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 * Callbacks to achieve various core window functionality.
50 */
52 /**
53 * Invalidate an area of a window.
54 *
55 * The specified area of the window should now be considered
56 * out of date. If the area is NULL the entire window must be
57 * invalidated. It is expected that the windowing system will
58 * then subsequently cause redraw/expose operations as
59 * necessary.
60 *
61 * \note the frontend should not attempt to actually start the
62 * redraw operations as a result of this callback because the
63 * core redraw functions may already be threaded.
64 *
65 * \param[in] cw The core window to invalidate.
66 * \param[in] rect area to redraw or NULL for the entire window area
67 * \return NSERROR_OK on success or appropriate error code
68 */
69 nserror (*invalidate)(struct core_window *cw, const struct rect *rect);
70
71 /**
72 * Update the limits of the window
73 *
74 * \param[in] cw the core window object
75 * \param[in] width the width in px, or negative if don't care
76 * \param[in] height the height in px, or negative if don't care
77 * \return NSERROR_OK on success or appropriate error code
78 */
79 nserror (*update_size)(struct core_window *cw, int width, int height);
80
81 /**
82 * Scroll the window to given scroll offsets
83 *
84 * Note: Core callers of this may want to look at calling
85 * the `cw_helper_scroll_visible()`, rather than calling
86 * this directly.
87 *
88 * \param[in] cw the core window object
89 * \param[in] x x-scroll value to set
90 * \param[in] y y-scroll value to set
91 * \return NSERROR_OK on success or appropriate error code
92 */
93 nserror (*set_scroll)(struct core_window *cw, int x, int y);
94
95 /**
96 * Get the current scroll offsets
97 *
98 * \param[in] cw the core window object
99 * \param[out] returns horizontal scroll in px
100 * \param[out] returns vertical scroll in px
101 * \return NSERROR_OK on success or appropriate error code
102 */
103 nserror (*get_scroll)(const struct core_window *cw, int *x, int *y);
104
105 /**
106 * Get window viewport dimensions
107 *
108 * \param[in] cw the core window object
109 * \param[out] width to be set to viewport width in px
110 * \param[out] height to be set to viewport height in px
111 * \return NSERROR_OK on success or appropriate error code
112 */
113 nserror (*get_window_dimensions)(const struct core_window *cw,
114 int *width, int *height);
115
116 /**
117 * Inform corewindow owner of drag status
118 *
119 * \param[in] cw the core window object
120 * \param[in] ds the current drag status
121 * \return NSERROR_OK on success or appropriate error code
122 */
123 nserror (*drag_status)(struct core_window *cw,
125};
126
127
128#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:159
int height
Definition: gui.c:160
Callbacks to achieve various core window functionality.
Definition: core_window.h:51
nserror(* get_scroll)(const struct core_window *cw, int *x, int *y)
Get the current scroll offsets.
Definition: core_window.h:103
nserror(* get_window_dimensions)(const struct core_window *cw, int *width, int *height)
Get window viewport dimensions.
Definition: core_window.h:113
nserror(* drag_status)(struct core_window *cw, core_window_drag_status ds)
Inform corewindow owner of drag status.
Definition: core_window.h:123
nserror(* update_size)(struct core_window *cw, int width, int height)
Update the limits of the window.
Definition: core_window.h:79
nserror(* set_scroll)(struct core_window *cw, int x, int y)
Scroll the window to given scroll offsets.
Definition: core_window.h:93
nserror(* invalidate)(struct core_window *cw, const struct rect *rect)
Invalidate an area of a window.
Definition: core_window.h:69
Rectangle coordinates.
Definition: types.h:40
struct rect rect
Rectangle coordinates.