NetSurf
gui.h
Go to the documentation of this file.
1/*
2 * Copyright 2008-2019 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_GUI_H
20#define AMIGA_GUI_H
21
22#include <stdbool.h>
23#include <graphics/rastport.h>
24#include <intuition/classusr.h>
25#include <dos/dos.h>
26#include <devices/inputevent.h>
27
28#include "netsurf/window.h"
29#include "netsurf/mouse.h"
30
31#include "amiga/gui_menu.h"
32#include "amiga/object.h"
33#include "amiga/os3support.h"
34
35#ifdef __amigaos4__
36#define HOOKF(ret,func,type,ptr,msgtype) static ret func(struct Hook *hook, type ptr, msgtype msg)
37#else
38#define HOOKF(ret,func,type,ptr,msgtype) static ASM ret func(REG(a0, struct Hook *hook),REG(a2, type ptr), REG(a1, msgtype msg))
39#endif
40
41/* valid options for ami_gui_get_object */
42enum {
48};
49
50struct find_window;
52struct ami_menu_data;
53struct gui_window;
54struct gui_window_2;
55struct IBox;
56
57#define AMI_GUI_TOOLBAR_MAX 20
58
60 /* callback to handle events when using a shared msgport
61 *
62 * @param pointer to our window structure (must start with ami_generic_window)
63 * @return TRUE if window was destroyed during event processing
64 */
65 BOOL (*event)(void *w);
66
67 /* callback for explicit window closure
68 * some windows are implicitly closed by the browser and should set this to NULL
69 */
70 void (*close)(void *w);
71};
72
74 struct nsObject *node;
75 const struct ami_win_event_table *tbl;
76};
77
78#define IS_CURRENT_GW(GWIN,GW) (ami_gui2_get_gui_window(GWIN) == GW)
79
80/* The return value for these functions must be deallocated using FreeVec() */
81STRPTR ami_locale_langs(int *codeset);
82char *ami_gui_get_cache_favicon_name(struct nsurl *url, bool only_if_avail);
83
84/* Functions lacking documentation */
85void ami_get_msg(void);
86void ami_try_quit(void);
87void ami_quit_netsurf(void);
88void ami_schedule_redraw(struct gui_window_2 *gwin, bool full_redraw);
89int ami_key_to_nskey(ULONG keycode, struct InputEvent *ie);
90bool ami_text_box_at_point(struct gui_window_2 *gwin, ULONG *restrict x, ULONG *restrict y);
91bool ami_mouse_to_ns_coords(struct gui_window_2 *gwin, int *restrict x, int *restrict y,
92 int mouse_x, int mouse_y);
93BOOL ami_gadget_hit(Object *obj, int x, int y);
94void ami_gui_history(struct gui_window_2 *gwin, bool back);
97bool ami_locate_resource(char *fullpath, const char *file);
100int ami_gui_count_windows(int window, int *tabs);
101void ami_gui_set_scale(struct gui_window *gw, float scale);
102void ami_set_pointer(struct gui_window_2 *gwin, gui_pointer_shape shape, bool update);
103void ami_reset_pointer(struct gui_window_2 *gwin);
104void *ami_window_at_pointer(int type);
105
106/**
107 * Beep
108 */
109void ami_gui_beep(void);
110
111/**
112 * Close a window and all tabs attached to it.
113 *
114 * @param w gui_window_2 to act upon.
115 */
116void ami_gui_close_window(void *w);
117
118/**
119 * Close all tabs in a window except the active one.
120 *
121 * @param gwin gui_window_2 to act upon.
122 */
124
125/**
126 * Compatibility function to get space.gadget render area.
127 *
128 * @param obj A space.gadget object.
129 * @param bbox A pointer to a struct IBox *.
130 * @return error status.
131 */
132nserror ami_gui_get_space_box(Object *obj, struct IBox **bbox);
133
134/**
135 * Free any data obtained via ami_gui_get_space_box().
136 *
137 * @param bbox A pointer to a struct IBox.
138 */
139void ami_gui_free_space_box(struct IBox *bbox);
140
141/**
142 * Get shared message port
143 *
144 * @return Pointer to an initialised MsgPort
145 */
146struct MsgPort *ami_gui_get_shared_msgport(void);
147
148/**
149 * Get the application.library ID NetSurf is registered as.
150 *
151 * @return App ID.
152 */
154
155/**
156 * Get a pointer to the screen NetSurf is running on.
157 *
158 * @return Pointer to struct Screen.
159 */
160struct Screen *ami_gui_get_screen(void);
161
162/**
163 * Get the string for NetSurf's screen titlebar.
164 *
165 * @return String to use as the screen's titlebar text.
166 */
167STRPTR ami_gui_get_screen_title(void);
168
169/**
170 * Switch to the most-recently-opened tab
171 */
172void ami_gui_switch_to_new_tab(struct gui_window_2 *gwin);
173
174/**
175 * Add a window to the NetSurf window list (to enable event processing)
176 */
177nserror ami_gui_win_list_add(void *win, int type, const struct ami_win_event_table *table);
178
179/**
180 * Remove a window from the NetSurf window list
181 */
182void ami_gui_win_list_remove(void *win);
183
184/**
185 * Get the window list.
186 *
187 *\TODO: Nothing should be poking around in this list, but we aren't
188 * assigning unique IDs to windows (ARexx interface needs this)
189 * ami_find_gwin_by_id() is close but not ARexx-friendly
190 */
191struct MinList *ami_gui_get_window_list(void);
192
193/**
194 * Get which qualifier keys are being pressed
195 */
196int ami_gui_get_quals(Object *win_obj);
197
198/**
199 * Check rect is not already queued for redraw
200 */
201bool ami_gui_window_update_box_deferred_check(struct MinList *deferred_rects,
202 const struct rect *restrict new_rect, APTR mempool);
203
204/**
205 * Adjust scale by specified amount
206 */
207void ami_gui_adjust_scale(struct gui_window *gw, float adjustment);
208
209/**
210 * Get a pointer to the gui_window which NetSurf considers
211 * to be the current/active one
212 */
214
215/**
216 * Get browser window from gui_window
217 */
219
220/**
221 * Get browser window from gui_window_2
222 */
224
225/**
226 * Get gui_window_2 from gui_window
227 */
229
230/**
231 * Get gui_window from gui_window_2
232 */
234
235/**
236 * Get download list from gui_window
237 */
238struct List *ami_gui_get_download_list(struct gui_window *gw);
239
240/**
241 * Get tab title from gui_window
242 */
243const char *ami_gui_get_tab_title(struct gui_window *gw);
244
245/**
246 * Get window title from gui_window
247 */
248const char *ami_gui_get_win_title(struct gui_window *gw);
249
250/**
251 * Get tab node from gui_window
252 */
253struct Node *ami_gui_get_tab_node(struct gui_window *gw);
254
255/**
256 * Get tabs from gui_window_2
257 */
258ULONG ami_gui2_get_tabs(struct gui_window_2 *gwin);
259
260/**
261 * Get tab list from gui_window_2
262 */
263struct List *ami_gui2_get_tab_list(struct gui_window_2 *gwin);
264
265/**
266 * Get favicon from gui_window
267 */
269
270/**
271 * Get local history window from gui_window
272 */
274
275/**
276 * Set local history window in gui_window
277 */
279
280/**
281 * Set search window in gui_window
282 */
283void ami_gui_set_find_window(struct gui_window *gw, struct find_window *fw);
284
285/**
286 * Get throbbing status from gui_window
287 */
289
290/**
291 * Get throbbing frame from gui_window
292 */
294
295/**
296 * Set throbbing frame in gui_window
297 */
298void ami_gui_set_throbber_frame(struct gui_window *gw, int frame);
299
300/**
301 * Set throbbing status in gui_window
302 */
303void ami_gui_set_throbbing(struct gui_window *gw, bool throbbing);
304
305/**
306 * Get object from gui_window
307 */
308Object *ami_gui2_get_object(struct gui_window_2 *gwin, int object_type);
309
310/**
311 * Get window from gui_window
312 */
313struct Window *ami_gui_get_window(struct gui_window *gw);
314
315/**
316 * Get window from gui_window_2
317 */
318struct Window *ami_gui2_get_window(struct gui_window_2 *gwin);
319
320/**
321 * Get imenu from gui_window
322 */
323struct Menu *ami_gui_get_menu(struct gui_window *gw);
324
325/**
326 * Set imenu to gui_window_2. A value of NULL will free the menu (and menu_data!)
327 */
328void ami_gui2_set_menu(struct gui_window_2 *gwin, struct Menu *menu);
329
330/**
331 * Get menu_data from gui_window_2
332 */
334
335/**
336 * Set ctxmenu history tmp in gui_window_2
337 */
338void ami_gui2_set_ctxmenu_history_tmp(struct gui_window_2 *gwin, int temp);
339
340/**
341 * Get ctxmenu history tmp from gui_window_2
342 */
344
345/**
346 * Get ctxmenu history from gui_window_2
347 */
348Object *ami_gui2_get_ctxmenu_history(struct gui_window_2 *gwin, ULONG direction);
349
350/**
351 * Set ctxmenu history in gui_window_2
352 */
353void ami_gui2_set_ctxmenu_history(struct gui_window_2 *gwin, ULONG direction, Object *ctx_hist);
354
355/**
356 * Set closed in gui_window_2
357 */
358void ami_gui2_set_closed(struct gui_window_2 *gwin, bool closed);
359
360/**
361 * Set new_content in gui_window_2
362 * Indicates the window needs redrawing
363 */
364void ami_gui2_set_new_content(struct gui_window_2 *gwin, bool new_content);
365
366#endif
367
void ami_try_quit(void)
Definition: gui.c:3915
bool ami_gui_window_update_box_deferred_check(struct MinList *deferred_rects, const struct rect *restrict new_rect, APTR mempool)
Check rect is not already queued for redraw.
Definition: gui.c:5696
struct ami_history_local_window * ami_gui_get_history_window(struct gui_window *gw)
Get local history window from gui_window.
Definition: gui.c:488
struct Window * ami_gui_get_window(struct gui_window *gw)
Get window from gui_window.
Definition: gui.c:578
int ami_key_to_nskey(ULONG keycode, struct InputEvent *ie)
Definition: gui.c:1706
void ami_gui_set_find_window(struct gui_window *gw, struct find_window *fw)
Set search window in gui_window.
Definition: gui.c:500
int ami_gui2_get_ctxmenu_history_tmp(struct gui_window_2 *gwin)
Get ctxmenu history tmp from gui_window_2.
Definition: gui.c:612
struct Screen * ami_gui_get_screen(void)
Get a pointer to the screen NetSurf is running on.
Definition: gui.c:405
struct Node * ami_gui_get_tab_node(struct gui_window *gw)
Get tab node from gui_window.
Definition: gui.c:464
void ami_gui_hotlist_update_all(void)
Update hotlist toolbar and recreate the menu for all windows.
Definition: gui.c:4216
void ami_gui_close_inactive_tabs(struct gui_window_2 *gwin)
Close all tabs in a window except the active one.
Definition: gui.c:5494
void ami_gui2_set_new_content(struct gui_window_2 *gwin, bool new_content)
Set new_content in gui_window_2 Indicates the window needs redrawing.
Definition: gui.c:636
void ami_gui2_set_ctxmenu_history_tmp(struct gui_window_2 *gwin, int temp)
Set ctxmenu history tmp in gui_window_2.
Definition: gui.c:606
nserror ami_gui_win_list_add(void *win, int type, const struct ami_win_event_table *table)
Add a window to the NetSurf window list (to enable event processing)
Definition: gui.c:4685
uint32 ami_gui_get_app_id(void)
Get the application.library ID NetSurf is registered as.
Definition: gui.c:6364
void ami_gui_switch_to_new_tab(struct gui_window_2 *gwin)
Switch to the most-recently-opened tab.
Definition: gui.c:4389
void ami_gui_history(struct gui_window_2 *gwin, bool back)
Definition: gui.c:1690
bool ami_text_box_at_point(struct gui_window_2 *gwin, ULONG *restrict x, ULONG *restrict y)
Definition: gui.c:6194
void * ami_window_at_pointer(int type)
undocumented, or internal, or documented elsewhere
Definition: gui.c:684
void ami_gui_close_window(void *w)
Close a window and all tabs attached to it.
Definition: gui.c:5488
struct Menu * ami_gui_get_menu(struct gui_window *gw)
Get imenu from gui_window.
Definition: gui.c:584
void ami_gui_set_throbbing(struct gui_window *gw, bool throbbing)
Set throbbing status in gui_window.
Definition: gui.c:516
void ami_set_pointer(struct gui_window_2 *gwin, gui_pointer_shape shape, bool update)
Definition: gui.c:690
void ami_gui_adjust_scale(struct gui_window *gw, float adjustment)
Adjust scale by specified amount.
Definition: gui.c:4383
bool ami_locate_resource(char *fullpath, const char *file)
Definition: gui.c:816
bool ami_gui_get_throbbing(struct gui_window *gw)
Get throbbing status from gui_window.
Definition: gui.c:510
struct gui_window * ami_gui_get_active_gw(void)
Get a pointer to the gui_window which NetSurf considers to be the current/active one.
Definition: gui.c:400
struct browser_window * ami_gui2_get_browser_window(struct gui_window_2 *gwin)
Get browser window from gui_window_2.
Definition: gui.c:427
void ami_reset_pointer(struct gui_window_2 *gwin)
Definition: gui.c:698
void ami_gui2_set_ctxmenu_history(struct gui_window_2 *gwin, ULONG direction, Object *ctx_hist)
Set ctxmenu history in gui_window_2.
Definition: gui.c:624
void ami_get_msg(void)
Definition: gui.c:3531
STRPTR ami_gui_get_screen_title(void)
Get the string for NetSurf's screen titlebar.
Definition: gui.c:976
struct ami_menu_data ** ami_gui2_get_menu_data(struct gui_window_2 *gwin)
Get menu_data from gui_window_2.
Definition: gui.c:600
nserror ami_gui_new_blank_tab(struct gui_window_2 *gwin)
Definition: gui.c:4402
void ami_gui2_set_menu(struct gui_window_2 *gwin, struct Menu *menu)
Set imenu to gui_window_2.
Definition: gui.c:591
void ami_gui2_set_closed(struct gui_window_2 *gwin, bool closed)
Set closed in gui_window_2.
Definition: gui.c:630
nserror ami_gui_get_space_box(Object *obj, struct IBox **bbox)
Compatibility function to get space.gadget render area.
Definition: gui.c:1859
Object * ami_gui2_get_object(struct gui_window_2 *gwin, int object_type)
Get object from gui_window.
Definition: gui.c:536
const char * ami_gui_get_win_title(struct gui_window *gw)
Get window title from gui_window.
Definition: gui.c:451
int ami_gui_get_throbber_frame(struct gui_window *gw)
Get throbbing frame from gui_window.
Definition: gui.c:522
struct MsgPort * ami_gui_get_shared_msgport(void)
Get shared message port.
const char * ami_gui_get_tab_title(struct gui_window *gw)
Get tab title from gui_window.
Definition: gui.c:458
void ami_gui_set_history_window(struct gui_window *gw, struct ami_history_local_window *hw)
Set local history window in gui_window.
Definition: gui.c:494
struct gui_window * ami_gui2_get_gui_window(struct gui_window_2 *gwin)
Get gui_window from gui_window_2.
Definition: gui.c:445
STRPTR ami_locale_langs(int *codeset)
Definition: gui.c:704
struct List * ami_gui_get_download_list(struct gui_window *gw)
Get download list from gui_window.
Definition: gui.c:433
Object * ami_gui2_get_ctxmenu_history(struct gui_window_2 *gwin, ULONG direction)
Get ctxmenu history from gui_window_2.
Definition: gui.c:618
ULONG ami_gui2_get_tabs(struct gui_window_2 *gwin)
Get tabs from gui_window_2.
Definition: gui.c:470
void ami_gui_beep(void)
Beep.
Definition: gui.c:416
void ami_gui_free_space_box(struct IBox *bbox)
Free any data obtained via ami_gui_get_space_box().
Definition: gui.c:1876
@ AMI_WIN_MAIN
Definition: gui.h:47
@ AMI_GAD_URL
Definition: gui.h:45
@ AMI_GAD_TABS
Definition: gui.h:44
@ AMI_GAD_SEARCH
Definition: gui.h:46
@ AMI_GAD_THROBBER
Definition: gui.h:43
bool ami_mouse_to_ns_coords(struct gui_window_2 *gwin, int *restrict x, int *restrict y, int mouse_x, int mouse_y)
Definition: gui.c:1900
struct hlcache_handle * ami_gui_get_favicon(struct gui_window *gw)
Get favicon from gui_window.
Definition: gui.c:482
void ami_gui_set_scale(struct gui_window *gw, float scale)
Set the scale of a gui window.
Definition: gui.c:4377
struct List * ami_gui2_get_tab_list(struct gui_window_2 *gwin)
Get tab list from gui_window_2.
Definition: gui.c:476
void ami_gui_win_list_remove(void *win)
Remove a window from the NetSurf window list.
Definition: gui.c:4699
int ami_gui_count_windows(int window, int *tabs)
Count windows, and optionally tabs.
Definition: gui.c:4349
char * ami_gui_get_cache_favicon_name(struct nsurl *url, bool only_if_avail)
Definition: gui.c:3971
int ami_gui_get_quals(Object *win_obj)
Get which qualifier keys are being pressed.
Definition: gui.c:1828
void ami_gui_update_hotlist_button(struct gui_window_2 *gwin)
Definition: gui.c:4001
void ami_schedule_redraw(struct gui_window_2 *gwin, bool full_redraw)
Schedule a redraw of the browser window - Amiga-specific function.
Definition: gui.c:5652
struct Window * ami_gui2_get_window(struct gui_window_2 *gwin)
Get window from gui_window_2.
Definition: gui.c:572
struct browser_window * ami_gui_get_browser_window(struct gui_window *gw)
Get browser window from gui_window.
Definition: gui.c:421
struct MinList * ami_gui_get_window_list(void)
Get the window list.
Definition: gui.c:410
struct gui_window_2 * ami_gui_get_gui_window_2(struct gui_window *gw)
Get gui_window_2 from gui_window.
Definition: gui.c:439
void ami_gui_tabs_toggle_all(void)
Definition: gui.c:4313
BOOL ami_gadget_hit(Object *obj, int x, int y)
Definition: gui.c:6221
void ami_gui_set_throbber_frame(struct gui_window *gw, int frame)
Set throbbing frame in gui_window.
Definition: gui.c:529
void ami_quit_netsurf(void)
Definition: gui.c:3818
nserror
Enumeration of error codes.
Definition: errors.h:29
const char * type
Definition: filetype.cpp:44
static CONST_STRPTR tabs[OPTS_MAX_TABS]
Definition: gui_options.c:254
Core mouse and pointer states.
gui_pointer_shape
Definition: mouse.h:112
Interface to platform-specific graphical user interface window operations.
struct nsurl nsurl
NetSurf URL object.
Definition: nsurl.h:31
Minimal compatibility header for AmigaOS 3.
uint32_t uint32
Definition: os3support.h:184
struct nsObject * node
Definition: gui.h:74
const struct ami_win_event_table * tbl
Definition: gui.h:75
Amiga local history viewing window context.
Definition: history_local.c:57
struct gui_window * gw
Amiga GUI stuff.
Definition: history_local.c:62
BOOL(* event)(void *w)
Definition: gui.h:65
void(* close)(void *w)
Definition: gui.h:70
Browser window data.
struct gui_window * gw
Definition: gui.c:250
first entry in window list
Definition: gui.c:298
High-level cache handle.
Definition: hlcache.c:66
Rectangle coordinates.
Definition: types.h:40
static int mouse_x
Definition: url_complete.c:66
static int mouse_y
Definition: url_complete.c:67