chiark / gitweb /
Initial revision
[ssr] / StraySrc / Libraries / Steel / h / event
1 /*
2  * event.h
3  *
4  * Handling and dispatching events
5  *
6  * © 1994-1998 Straylight
7  */
8
9 /*----- Licensing note ----------------------------------------------------*
10  *
11  * This file is part of Straylight's Steel library.
12  *
13  * Steel is free software; you can redistribute it and/or modify
14  * it under the terms of the GNU General Public License as published by
15  * the Free Software Foundation; either version 2, or (at your option)
16  * any later version.
17  *
18  * Steel is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with Steel.  If not, write to the Free Software Foundation,
25  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
26  */
27
28 #ifndef __event_h
29 #define __event_h
30
31 /*----- Required headers --------------------------------------------------*/
32
33 #ifndef __wimp_h
34   #include "wimp.h"
35 #endif
36
37 #ifndef __menu_h
38   typedef struct menu__menustr *menu;
39   typedef menu (*event_menu_maker)(void *handle);
40   typedef void (*event_menu_proc)(void *handle,char* hit);
41   #include "menu.h"
42 #endif
43
44 /*----- Type definitions --------------------------------------------------*/
45
46 typedef enum
47 {
48   event_MENUSELECT,
49   event_MENUSUBMENU,
50   event_MENUDELETE,
51   event_MENUHELP
52 }
53 event_menuPurpose;
54
55 typedef void (*event_midbhandler)(wimp_w w,
56                                   int gadget,
57                                   void *handlea,
58                                   void *handleb,
59                                   void *handlec);
60
61 /*----- Exported functions ------------------------------------------------*/
62
63 void event__process(void);
64 void event_process(void);
65 #define event_process(x) dbox__eventProcess()
66
67 event_menuPurpose event_whyMenuEvent(void);
68 void event_returnMenuHelp(BOOL doit);
69
70 /*
71  * BOOL event_attachMidbHandler(wimp_w w,
72  *                              event_midbhandler proc,
73  *                              int gadget,
74  *                              void *handlea,
75  *                              void *handleb,
76  *                              void *handlec)
77  *
78  * Use
79  *  Registers a function to be called by event when a menu button event is
80  *  received by a particular window.  Typically, this handler will display a
81  *  menu at the mouse coordinates, although you can do anything you want.
82  *
83  *  You shouldn't need to call this function very much.  It's really for
84  *  allowing other systems to supply menu attachment functions like event_-
85  *  attachmenu etc.
86  *
87  * Parameters
88  *  wimp_w == the window to which to attach the function
89  *  event_midbhandler proc == the function to call when a menu button event
90  *    is received for the window
91  *  others == arguments to be passed (unprocessed) to proc when it's called.
92  *
93  * Returns
94  *  TRUE if the attachment succeeded.
95  */
96
97 BOOL event_attachMidbHandler(wimp_w w,
98                              event_midbhandler proc,
99                              int gadget,
100                              void *handlea,
101                              void *handleb,
102                              void *handlec);
103
104 void event_attachedMenu(wimp_w w,
105                         menu *m,
106                         event_menu_maker *mk,
107                         event_menu_proc *proc,
108                         void **handle);
109
110 /*
111  * void event_openMenu(menu it,event_menu_proc proc,void *handle)
112  * void event_makeMenu(event_menu_maker it,event_menu_proc proc,void *handle)
113  * void event_openIconbarMenu(...)
114  * void event_makeIconbarMenu(...)
115  *
116  * Use
117  *  Opens a menu onto the screen and tells your routine when it's finished.
118  *
119  * Parameters
120  *  menu it == the menu or menu maker procedure
121  *  event_menu_proc proc == the menu handler function
122  *  void *handle == it's jolly old handle
123  */
124
125 void event_openMenu(menu it,event_menu_proc proc,void *handle);
126 void event_makeMenu(event_menu_maker maker,
127                     event_menu_proc proc,
128                     void *handle);
129 void event_openIconbarMenu(menu it,event_menu_proc proc,void *handle);
130 void event_makeIconbarMenu(event_menu_maker maker,
131                            event_menu_proc proc,
132                            void *handle);
133
134 /*
135  * void event_attachmenu(wimp_w w,menu m,event_menu_proc p,void *handle)
136  *
137  * Use
138  *  Attaches a menu to a window so that it opens when you click menu on it.
139  *
140  * Parameters
141  *  wimp_w w == the window to attach to
142  *  menu m == the menu to attach to it
143  *  event_menu_proc p == what to do when a menu item is chosen
144  *  void *handle == something else to send to p
145  */
146
147 BOOL event_attachmenu(wimp_w w,menu m,event_menu_proc p,void *handle);
148
149 /*
150  * void event_attachmenumaker(wimp_w w,
151  *                            event_menu_maker m,
152  *                            event_menu_proc p,
153  *                            void *handle)
154  *
155  * Use
156  *  Attaches a menu to a window so that it opens when you click menu on it.
157  *
158  * Parameters
159  *  wimp_w w == the window to attach to
160  *  event_menu_maker m == how to create the menu
161  *  event_menu_proc p == what to do when a menu item is chosen
162  *  void *handle == something else to send to p
163  */
164
165 BOOL event_attachmenumaker(wimp_w w,
166                            event_menu_maker m,
167                            event_menu_proc p,
168                            void *handle);
169
170 BOOL event_anywindows(void);
171
172 BOOL event_is_menu_being_recreated(void);
173
174 void event_clear_current_menu(void);
175
176 void event_setmask (wimp_emask mask);
177
178 wimp_emask event_getmask (void);
179
180 #endif