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