NetSurf
corewindow.h
Go to the documentation of this file.
1/*
2 * Copyright 2017 Chris Young <chris@unsatisfactorysoftware.co.uk>
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#ifndef AMIGA_COREWINDOW_H
20#define AMIGA_COREWINDOW_H
21
22#include "netsurf/core_window.h"
23
24#include "amiga/gui.h" /* need to know the size of ami_generic_window :( */
25#include "amiga/plotters.h"
26
27/**
28 * BOOPSI objects
29 */
30
31enum {
32 GID_CW_WIN = 0, /* window object */
33 GID_CW_MAIN, /* root layout object */
34 GID_CW_DRAW, /* drawing area (space.gadget) */
35 GID_CW_HSCROLL, /* horizontal scroller */
36 GID_CW_VSCROLL, /* vertical scroller */
37 GID_CW_HSCROLLLAYOUT, /* horizontal scroller container*/
38 GID_CW_VSCROLLLAYOUT, /* vertical scroller container */
40};
41
42/**
43 * Amiga core window state
44 */
46 /*
47 * Any variables common to any frontend window would go here.
48 * e.g. drawing area handles, toolkit pointers or other state
49 */
51 struct Window *win;
53
54 struct Hook idcmp_hook;
55 struct timeval lastclick;
56
60
64
65 bool close_window; // set to true to close the window during event loop
66
68 struct MinList *deferred_rects;
69
70 /** keep track of the scrollbar type we're using */
74
75 /** window title, must be allocated wth ami_utf8 function */
76 char *wintitle;
77
78 /** stuff for our off-screen render bitmap */
79 struct gui_globals *gg;
80 struct MinList *shared_pens;
81
82 /** drag status set by core */
84
85 /** table of callbacks for core window operations */
87
88 /**
89 * callback to draw on drawable area of Amiga core window
90 *
91 * \param ami_cw The Amiga core window structure.
92 * \param x Plot origin (X)
93 * \param r Plot origin (Y)
94 * \param r The rectangle of the window that needs updating.
95 * \param ctx Redraw context
96 * \return NSERROR_OK on success otherwise apropriate error code
97 */
98 nserror (*draw)(struct ami_corewindow *ami_cw, int x, int y, struct rect *r,
99 struct redraw_context *ctx);
100
101 /**
102 * callback for keypress on Amiga core window
103 *
104 * \param ami_cw The Amiga core window structure.
105 * \param nskey The netsurf key code.
106 * \return NSERROR_OK if key processed,
107 * NSERROR_NOT_IMPLEMENTED if key not processed
108 * otherwise apropriate error code
109 */
110 nserror (*key)(struct ami_corewindow *ami_cw, uint32_t nskey);
111
112 /**
113 * callback for mouse event on Amiga core window
114 *
115 * \param ami_cw The Amiga core window structure.
116 * \param mouse_state mouse state
117 * \param x location of event
118 * \param y location of event
119 * \return NSERROR_OK on sucess otherwise apropriate error code.
120 */
121 nserror (*mouse)(struct ami_corewindow *ami_cw, browser_mouse_state mouse_state, int x, int y);
122
123 /**
124 * callback for unknown events on Amiga core window
125 * eg. buttons in the ssl cert window
126 * (result & WMHI_CLASSMASK) gives the class of event (eg. WMHI_GADGETUP)
127 * (result & WMHI_GADGETMASK) gives the gadget ID (eg. GID_SSLCERT_ACCEPT)
128 *
129 * \param ami_cw The Amiga core window structure.
130 * \param result event as returned by RA_HandleInput()
131 * \return TRUE if window closed during event processing
132 */
133 BOOL (*event)(struct ami_corewindow *ami_cw, ULONG result);
134
135 /**
136 * callback for drag end on Amiga core window
137 * ie. a drag *from* this window to a different window
138 *
139 * \param ami_cw The Amiga core window structure.
140 * \param x mouse x position **in screen co-ordinates**
141 * \param y mouse y position **in screen co-ordinates**
142 * \return NSERROR_OK on success otherwise apropriate error code
143 */
144 nserror (*drag_end)(struct ami_corewindow *ami_cw, int x, int y);
145
146 /**
147 * callback for icon drop on Amiga core window
148 * ie. a drag has ended *above* this window
149 * \todo this may not be very flexible but serves our current purposes
150 *
151 * \param ami_cw The Amiga core window structure.
152 * \param url url of dropped icon
153 * \param title title of dropped icon
154 * \param x mouse x position **in screen co-ordinates**
155 * \param y mouse y position **in screen co-ordinates**
156 * \return NSERROR_OK on success otherwise apropriate error code
157 */
158 nserror (*icon_drop)(struct ami_corewindow *ami_cw, struct nsurl *url, const char *title, int x, int y);
159
160 /**
161 * callback to close an Amiga core window
162 *
163 * \param ami_cw The Amiga core window structure.
164 */
165 void (*close)(struct ami_corewindow *ami_cw);
166
167};
168
169/**
170 * initialise elements of Amiga core window.
171 *
172 * As a pre-requisite the draw, key and mouse callbacks must be defined
173 *
174 * \param ami_cw An Amiga core window structure to initialise
175 * \return NSERROR_OK on successful initialisation otherwise error code.
176 */
178
179/**
180 * finalise elements of Amiga core window.
181 *
182 * \param ami_cw An Amiga core window structure to finialise
183 * \return NSERROR_OK on successful finalisation otherwise error code.
184 */
186
187#endif
188
nserror ami_corewindow_fini(struct ami_corewindow *ami_cw)
finalise elements of Amiga core window.
Definition: corewindow.c:986
nserror ami_corewindow_init(struct ami_corewindow *ami_cw)
initialise elements of Amiga core window.
Definition: corewindow.c:926
@ GID_CW_MAIN
Definition: corewindow.h:33
@ GID_CW_VSCROLLLAYOUT
Definition: corewindow.h:38
@ GID_CW_WIN
Definition: corewindow.h:32
@ GID_CW_VSCROLL
Definition: corewindow.h:36
@ GID_CW_LAST
Definition: corewindow.h:39
@ GID_CW_DRAW
Definition: corewindow.h:34
@ GID_CW_HSCROLL
Definition: corewindow.h:35
@ GID_CW_HSCROLLLAYOUT
Definition: corewindow.h:37
STATIC char result[100]
Definition: arexx.c:77
Interface to core window handling.
core_window_drag_status
drag status passed to drag_status callback
Definition: core_window.h:41
nserror
Enumeration of error codes.
Definition: errors.h:29
browser_mouse_state
Mouse state.
Definition: mouse.h:43
struct nsurl nsurl
NetSurf URL object.
Definition: nsurl.h:31
Amiga core window state.
Definition: corewindow.h:45
bool scroll_y_visible
Definition: corewindow.h:73
void(* close)(struct ami_corewindow *ami_cw)
callback to close an Amiga core window
Definition: corewindow.h:165
Object * objects[GID_CW_LAST]
Definition: corewindow.h:52
nserror(* icon_drop)(struct ami_corewindow *ami_cw, struct nsurl *url, const char *title, int x, int y)
callback for icon drop on Amiga core window ie.
Definition: corewindow.h:158
struct core_window_callback_table * cb_table
table of callbacks for core window operations
Definition: corewindow.h:86
bool close_window
Definition: corewindow.h:65
nserror(* mouse)(struct ami_corewindow *ami_cw, browser_mouse_state mouse_state, int x, int y)
callback for mouse event on Amiga core window
Definition: corewindow.h:121
nserror(* draw)(struct ami_corewindow *ami_cw, int x, int y, struct rect *r, struct redraw_context *ctx)
callback to draw on drawable area of Amiga core window
Definition: corewindow.h:98
struct ami_generic_window w
Definition: corewindow.h:50
APTR deferred_rects_pool
Definition: corewindow.h:67
struct timeval lastclick
Definition: corewindow.h:55
nserror(* key)(struct ami_corewindow *ami_cw, uint32_t nskey)
callback for keypress on Amiga core window
Definition: corewindow.h:110
struct MinList * deferred_rects
Definition: corewindow.h:68
bool in_border_scroll
keep track of the scrollbar type we're using
Definition: corewindow.h:71
struct Window * win
Definition: corewindow.h:51
BOOL(* event)(struct ami_corewindow *ami_cw, ULONG result)
callback for unknown events on Amiga core window eg.
Definition: corewindow.h:133
struct MinList * shared_pens
Definition: corewindow.h:80
core_window_drag_status drag_status
drag status set by core
Definition: corewindow.h:83
nserror(* drag_end)(struct ami_corewindow *ami_cw, int x, int y)
callback for drag end on Amiga core window ie.
Definition: corewindow.h:144
bool scroll_x_visible
Definition: corewindow.h:72
struct gui_globals * gg
stuff for our off-screen render bitmap
Definition: corewindow.h:79
struct Hook idcmp_hook
Definition: corewindow.h:54
char * wintitle
window title, must be allocated wth ami_utf8 function
Definition: corewindow.h:76
Callbacks to achieve various core window functionality.
Definition: core_window.h:51
Rectangle coordinates.
Definition: types.h:40
Redraw context.
Definition: plotters.h:51