summaryrefslogtreecommitdiff
path: root/frontends/riscos/window.h
blob: 0a5bd43c2b286370aedb7a1be27bdfe26f06aa4c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
/*
 * Copyright 2010, 2011 Stephen Fryatt <stevef@netsurf-browser.org>
 *
 * This file is part of NetSurf, http://www.netsurf-browser.org/
 *
 * NetSurf is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; version 2 of the License.
 *
 * NetSurf is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

/** \file
 * Browser window handling (interface).
 */

#include <stdbool.h>

#ifndef _NETSURF_RISCOS_WINDOW_H_
#define _NETSURF_RISCOS_WINDOW_H_

struct gui_window;
struct nsurl;

extern struct gui_window_table *riscos_window_table;

/**
 * Initialise the browser window module and its menus.
 */
void ro_gui_window_initialise(void);


/**
 * Check if a particular menu handle is a browser window menu
 *
 * \param menu The menu in question.
 * \return true if this menu is a browser window menu
 */
bool ro_gui_window_check_menu(wimp_menu *menu);


/**
 * Set the contents of a window's address bar.
 *
 * \param g gui_window to update
 * \param url new url for address bar
 */
nserror ro_gui_window_set_url(struct gui_window *g, struct nsurl *url);


/**
 * Cause an area of a window to be invalidated
 *
 * The specified area of the window should now be considered out of
 *  date. If the entire window is invalidated this simply calls
 *  wimp_force_redraw() otherwise the area is added to a queue of
 *  pending updates which will be processed from a wimp poll allowing
 *  multiple invalidation requests to be agregated.
 *
 * \param g The window to update
 * \param rect The area of the window to update or NULL to redraw entire contents.
 */
nserror ro_gui_window_invalidate_area(struct gui_window *g, const struct rect *rect);


/**
 * Set a gui_window's scale
 */
void ro_gui_window_set_scale(struct gui_window *g, float scale);


/**
 * Handle Message_DataLoad (file dragged in) for a window.
 *
 * If the file was dragged into a form file input, it is used as the value.
 *
 * \param g window
 * \param message Message_DataLoad block
 * \return true if the load was processed
 */
bool ro_gui_window_dataload(struct gui_window *g, wimp_message *message);


/**
 * Handle pointer movements in a browser window.
 *
 * \param pointer new mouse position
 * \param data browser window that the pointer is in
 */
void ro_gui_window_mouse_at(wimp_pointer *pointer, void *data);


/**
 * Window is being iconised.
 *
 * Create a suitable thumbnail sprite (which, sadly, must be in the
 * Wimp sprite pool), and return the sprite name and truncated title
 * to the iconiser
 *
 * \param g the gui window being iconised
 * \param wi the WindowInfo message from the iconiser
 */
void ro_gui_window_iconise(struct gui_window *g, wimp_full_message_window_info *wi);


/**
 * Handle Message_DataLoad (file dragged in) for a toolbar
 *
 * @todo This belongs in the toolbar module, and should be moved there
 * once the module is able to usefully handle its own events.
 *
 * \param g window
 * \param message  Message_DataLoad block
 * \return true if the load was processed
 */
bool ro_gui_toolbar_dataload(struct gui_window *g, wimp_message *message);


/**
 * Redraws the content for all windows.
 */
void ro_gui_window_redraw_all(void);


/**
 * Redraw any pending update boxes.
 */
void ro_gui_window_update_boxes(void);


/**
 * Destroy all browser windows.
 */
void ro_gui_window_quit(void);


/**
 * Close all browser windows
 *
 * no need for a separate fn same operation as quit
*/
#define ro_gui_window_close_all ro_gui_window_quit


/**
 * Animate the "throbbers" of all browser windows.
 */
void ro_gui_throb(void);

/**
 * Makes a browser window's options the default.
 *
 * \param gui The riscos gui window to set default options in.
 */
void ro_gui_window_default_options(struct gui_window *gui);


/**
 * Convert a RISC OS window handle to a gui_window.
 *
 * \param window RISC OS window handle.
 * \return A pointer to a riscos gui window if found or NULL.
 */
struct gui_window *ro_gui_window_lookup(wimp_w window);


/**
 * Convert a toolbar RISC OS window handle to a gui_window.
 *
 * \param  window RISC OS window handle of a toolbar
 * \return pointer to a structure if found, NULL otherwise
 */
struct gui_window *ro_gui_toolbar_lookup(wimp_w window);


/**
 * Convert x,y screen co-ordinates into window co-ordinates.
 *
 * \param g gui window
 * \param x x ordinate
 * \param y y ordinate
 * \param pos receives position in window co-ordinatates
 * \return true iff conversion successful
 */
bool ro_gui_window_to_window_pos(struct gui_window *g, int x, int y, os_coord *pos);


/**
 * Convert x,y window co-ordinates into screen co-ordinates.
 *
 * \param g gui window
 * \param x x ordinate
 * \param y y ordinate
 * \param pos receives position in screen co-ordinatates
 * \return true iff conversion successful
 */
bool ro_gui_window_to_screen_pos(struct gui_window *g, int x, int y, os_coord *pos);

/**
 * Returns the state of the mouse buttons and modifiers keys for a
 * mouse action, suitable for passing to the OS-independent
 * browser window/ treeview/ etc code.
 *
 * \param  buttons		Wimp button state.
 * \param  type			Wimp work-area/icon type for decoding.
 * \return			NetSurf core button state.
 */
enum browser_mouse_state ro_gui_mouse_click_state(wimp_mouse_state buttons, wimp_icon_flags type);


/**
 * Returns the state of the mouse buttons and modifiers keys whilst
 * dragging, for passing to the OS-independent browser window/ treeview/
 * etc code
 *
 * \param buttons Wimp button state.
 * \param type Wimp work-area/icon type for decoding.
 * \return NetSurf core button state.
 */
enum browser_mouse_state ro_gui_mouse_drag_state(wimp_mouse_state buttons, wimp_icon_flags type);


/**
 * Returns true iff one or more Shift keys is held down
 */
bool ro_gui_shift_pressed(void);


/**
 * Returns true iff one or more Ctrl keys is held down
 */
bool ro_gui_ctrl_pressed(void);


/**
 * Returns true iff one or more Alt keys is held down
 */
bool ro_gui_alt_pressed(void);


/**
 * Change mouse pointer shape
 */
void gui_window_set_pointer(struct gui_window *g, enum gui_pointer_shape shape);

#endif