NetSurf
wimp_event.h
Go to the documentation of this file.
1/*
2 * Copyright 2005 Richard Wilson <info@tinct.net>
3 * Copyright 2010, 2011 Stephen Fryatt <stevef@netsurf-browser.org>
4 *
5 * This file is part of NetSurf, http://www.netsurf-browser.org/
6 *
7 * NetSurf is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 2 of the License.
10 *
11 * NetSurf is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20/** \file
21 * Automated RISC OS WIMP event handling (interface).
22 */
23
24
25#ifndef _NETSURF_RISCOS_WIMP_EVENT_H_
26#define _NETSURF_RISCOS_WIMP_EVENT_H_
27
28#include <assert.h>
29#include <stdbool.h>
30#include <stdlib.h>
31#include <stdio.h>
32#include <string.h>
33#include "oslib/os.h"
34#include "oslib/wimp.h"
35#include "riscos/menus.h"
36
37#define IS_WIMP_KEY (1u<<31)
38
39bool ro_gui_wimp_event_memorise(wimp_w w);
40bool ro_gui_wimp_event_restore(wimp_w w);
41bool ro_gui_wimp_event_validate(wimp_w w);
42bool ro_gui_wimp_event_transfer(wimp_w from, wimp_w to);
43void ro_gui_wimp_event_finalise(wimp_w w);
44void ro_gui_wimp_event_deregister(wimp_w w, wimp_i i);
45
46bool ro_gui_wimp_event_set_help_prefix(wimp_w w, const char *help_prefix);
47const char *ro_gui_wimp_event_get_help_prefix(wimp_w w);
49 const char *(*get_help_suffix)(wimp_w w, wimp_i i,
50 os_coord *pos, wimp_mouse_state buttons));
51const char *ro_gui_wimp_event_get_help_suffix(wimp_w w, wimp_i i,
52 os_coord *pos, wimp_mouse_state buttons);
53bool ro_gui_wimp_event_set_user_data(wimp_w w, void *user);
55
56bool ro_gui_wimp_event_menu_selection(wimp_w w, wimp_i i, wimp_menu *menu,
57 wimp_selection *selection, menu_action action);
58bool ro_gui_wimp_event_mouse_click(wimp_pointer *pointer);
59bool ro_gui_wimp_event_keypress(wimp_key *key);
60bool ro_gui_wimp_event_open_window(wimp_open *open);
62bool ro_gui_wimp_event_redraw_window(wimp_draw *redraw);
63bool ro_gui_wimp_event_scroll_window(wimp_scroll *scroll);
64bool ro_gui_wimp_event_pointer_entering_window(wimp_entering *entering);
65
66bool ro_gui_wimp_event_process_window_menu_click(wimp_pointer *pointer);
67bool ro_gui_wimp_event_prepare_menu(wimp_w w, wimp_i i, wimp_menu *menu);
68
69bool ro_gui_wimp_event_register_menu(wimp_w w, wimp_menu *m,
70 bool menu_auto, bool position_ibar);
71bool ro_gui_wimp_event_register_numeric_field(wimp_w w, wimp_i i, wimp_i up,
72 wimp_i down, int min, int max, int stepping,
73 int decimal_places);
74bool ro_gui_wimp_event_register_text_field(wimp_w w, wimp_i i);
75bool ro_gui_wimp_event_register_menu_gright(wimp_w w, wimp_i i,
76 wimp_i gright, wimp_menu *menu);
77bool ro_gui_wimp_event_register_checkbox(wimp_w w, wimp_i i);
78bool ro_gui_wimp_event_register_radio(wimp_w w, wimp_i *i);
79bool ro_gui_wimp_event_register_button(wimp_w w, wimp_i i,
80 void (*callback)(wimp_pointer *pointer));
81bool ro_gui_wimp_event_register_cancel(wimp_w w, wimp_i i);
82bool ro_gui_wimp_event_register_ok(wimp_w w, wimp_i i,
83 bool (*callback)(wimp_w w));
84
86 bool (*callback)(wimp_pointer *pointer));
88 bool (*callback)(wimp_key *key));
90 void (*callback)(wimp_open *open));
92 void (*callback)(wimp_w w));
94 void (*callback)(wimp_draw *redraw));
96 void (*callback)(wimp_scroll *scroll));
98 void (*callback)(wimp_entering *entering));
100 bool (*callback)(wimp_w w, wimp_i i, wimp_menu *m,
101 wimp_pointer *p));
103 bool (*callback)(wimp_w w, wimp_i i, wimp_menu *m,
104 wimp_selection *s, menu_action a));
106 void (*callback)(wimp_w w, wimp_i i, wimp_menu *m,
107 wimp_selection *s, menu_action a));
109 void (*callback)(wimp_w w, wimp_i i, wimp_menu *m));
110
111bool ro_gui_wimp_event_submenu_warning(wimp_w w, wimp_i i, wimp_menu *menu,
112 wimp_selection *selection, menu_action action);
113void ro_gui_wimp_event_menus_closed(wimp_w w, wimp_i i, wimp_menu *menu);
115
116#endif
menu_action
Definition: scaffolding.h:77
Interface to utility string handling.
char from[32]
Encoding name to convert from.
Definition: utf8.c:143
char to[32]
Encoding name to convert to.
Definition: utf8.c:144
#define min(x, y)
Definition: utils.h:46
#define max(x, y)
Definition: utils.h:50
bool ro_gui_wimp_event_register_text_field(wimp_w w, wimp_i i)
Register a text field to be automatically handled.
Definition: wimp_event.c:1318
bool ro_gui_wimp_event_register_keypress(wimp_w w, bool(*callback)(wimp_key *key))
Register a function to be called for all keypresses within a particular window.
Definition: wimp_event.c:1461
bool ro_gui_wimp_event_register_numeric_field(wimp_w w, wimp_i i, wimp_i up, wimp_i down, int min, int max, int stepping, int decimal_places)
Register a numeric field to be automatically handled.
Definition: wimp_event.c:1287
bool ro_gui_wimp_event_set_help_prefix(wimp_w w, const char *help_prefix)
Set the associated help prefix for a given window.
Definition: wimp_event.c:390
const char * ro_gui_wimp_event_get_help_prefix(wimp_w w)
Get the associated help prefix.
Definition: wimp_event.c:408
bool ro_gui_wimp_event_mouse_click(wimp_pointer *pointer)
Handles a mouse click event in a registered window.
Definition: wimp_event.c:639
bool ro_gui_wimp_event_register_redraw_window(wimp_w w, void(*callback)(wimp_draw *redraw))
Register a function to be called for all window redraw operations.
Definition: wimp_event.c:1507
bool ro_gui_wimp_event_register_menu_gright(wimp_w w, wimp_i i, wimp_i gright, wimp_menu *menu)
Register an icon menu to be automatically handled.
Definition: wimp_event.c:1331
void ro_gui_wimp_event_finalise(wimp_w w)
Free any resources associated with a window.
Definition: wimp_event.c:296
void * ro_gui_wimp_event_get_user_data(wimp_w w)
Gets the user data associated with a window.
Definition: wimp_event.c:486
bool ro_gui_wimp_event_transfer(wimp_w from, wimp_w to)
Transfer event data from one window to another.
Definition: wimp_event.c:267
bool ro_gui_wimp_event_register_cancel(wimp_w w, wimp_i i)
Register a function to be called for the Cancel action on a window.
Definition: wimp_event.c:1403
bool ro_gui_wimp_event_memorise(wimp_w w)
Memorises the current state of any registered components in a window.
Definition: wimp_event.c:139
bool ro_gui_wimp_event_register_menu_selection(wimp_w w, bool(*callback)(wimp_w w, wimp_i i, wimp_menu *m, wimp_selection *s, menu_action a))
Register a function to be called following a menu selection.
Definition: wimp_event.c:1581
bool ro_gui_wimp_event_redraw_window(wimp_draw *redraw)
Handle any redraw window requests.
Definition: wimp_event.c:1129
const char * ro_gui_wimp_event_get_help_suffix(wimp_w w, wimp_i i, os_coord *pos, wimp_mouse_state buttons)
Get the associated help suffix.
Definition: wimp_event.c:448
bool ro_gui_wimp_event_scroll_window(wimp_scroll *scroll)
Handle any scroll window requests.
Definition: wimp_event.c:1147
bool ro_gui_wimp_event_prepare_menu(wimp_w w, wimp_i i, wimp_menu *menu)
Trigger a window's Prepare Menu event.
Definition: wimp_event.c:1239
bool ro_gui_wimp_event_open_window(wimp_open *open)
Handle any open window requests.
Definition: wimp_event.c:1089
void ro_gui_wimp_event_deregister(wimp_w w, wimp_i i)
Free any resources associated with a specific icon in a window.
Definition: wimp_event.c:334
void ro_gui_wimp_event_register_submenu(wimp_w w)
Register a submenu as being opened.
Definition: wimp_event.c:1844
bool ro_gui_wimp_event_close_window(wimp_w w)
Service any close window handlers.
Definition: wimp_event.c:1107
bool ro_gui_wimp_event_register_mouse_click(wimp_w w, bool(*callback)(wimp_pointer *pointer))
Register a function to be called for all mouse-clicks to icons in a window that don't have registered...
Definition: wimp_event.c:1439
void ro_gui_wimp_event_menus_closed(wimp_w w, wimp_i i, wimp_menu *menu)
Handle menus being closed.
Definition: wimp_event.c:1807
bool ro_gui_wimp_event_register_checkbox(wimp_w w, wimp_i i)
Register a checkbox to be automatically handled.
Definition: wimp_event.c:1349
bool ro_gui_wimp_event_pointer_entering_window(wimp_entering *entering)
Handle any pointer entering window requests.
Definition: wimp_event.c:1165
bool ro_gui_wimp_event_submenu_warning(wimp_w w, wimp_i i, wimp_menu *menu, wimp_selection *selection, menu_action action)
Definition: wimp_event.c:1754
bool ro_gui_wimp_event_register_menu_prepare(wimp_w w, bool(*callback)(wimp_w w, wimp_i i, wimp_menu *m, wimp_pointer *p))
Register a function to be called before a menu is (re-)opened.
Definition: wimp_event.c:1559
bool ro_gui_wimp_event_restore(wimp_w w)
Restore the state of any registered components in a window to their memorised state.
Definition: wimp_event.c:186
bool ro_gui_wimp_event_validate(wimp_w w)
Ensures all values are within pre-determined boundaries.
Definition: wimp_event.c:225
bool ro_gui_wimp_event_set_user_data(wimp_w w, void *user)
Sets the user data associated with a window.
Definition: wimp_event.c:467
bool ro_gui_wimp_event_register_menu_close(wimp_w w, void(*callback)(wimp_w w, wimp_i i, wimp_menu *m))
Register a function to be called before a menu is finally closed.
Definition: wimp_event.c:1624
bool ro_gui_wimp_event_register_ok(wimp_w w, wimp_i i, bool(*callback)(wimp_w w))
Register a function to be called for the OK action on a window.
Definition: wimp_event.c:1417
bool ro_gui_wimp_event_register_pointer_entering_window(wimp_w w, void(*callback)(wimp_entering *entering))
Register a function to be called for all pointer entering window requests.
Definition: wimp_event.c:1539
bool ro_gui_wimp_event_register_close_window(wimp_w w, void(*callback)(wimp_w w))
Register a function to be called after the window has been closed.
Definition: wimp_event.c:1492
bool ro_gui_wimp_event_register_radio(wimp_w w, wimp_i *i)
Register a group of radio icons to be automatically handled.
Definition: wimp_event.c:1363
bool ro_gui_wimp_event_register_help_suffix(wimp_w w, const char *(*get_help_suffix)(wimp_w w, wimp_i i, os_coord *pos, wimp_mouse_state buttons))
Register a handler to decode help suffixes for a given window.
Definition: wimp_event.c:424
bool ro_gui_wimp_event_menu_selection(wimp_w w, wimp_i i, wimp_menu *menu, wimp_selection *selection, menu_action action)
Handles a menu selection event.
Definition: wimp_event.c:520
bool ro_gui_wimp_event_register_scroll_window(wimp_w w, void(*callback)(wimp_scroll *scroll))
Register a function to be called for all window scroll requests.
Definition: wimp_event.c:1523
bool ro_gui_wimp_event_keypress(wimp_key *key)
Handle any registered keypresses, and the standard RISC OS ones.
Definition: wimp_event.c:885
bool ro_gui_wimp_event_register_button(wimp_w w, wimp_i i, void(*callback)(wimp_pointer *pointer))
Register a function to be called when a particular button is pressed.
Definition: wimp_event.c:1387
bool ro_gui_wimp_event_register_open_window(wimp_w w, void(*callback)(wimp_open *open))
Register a function to be called for all window opening requests.
Definition: wimp_event.c:1477
bool ro_gui_wimp_event_register_menu_warning(wimp_w w, void(*callback)(wimp_w w, wimp_i i, wimp_menu *m, wimp_selection *s, menu_action a))
Register a function to be called when a sub-menu warning is received.
Definition: wimp_event.c:1603
bool ro_gui_wimp_event_register_menu(wimp_w w, wimp_menu *m, bool menu_auto, bool position_ibar)
Register a window menu to be (semi-)automatically handled.
Definition: wimp_event.c:1270
bool ro_gui_wimp_event_process_window_menu_click(wimp_pointer *pointer)
Process a Menu click in a window, by checking for a registered window menu and opening it if one is f...
Definition: wimp_event.c:1186