1 
2 /******************************************************************************
3 * MODULE     : basic_event.hpp
4 * DESCRIPTION: The most common events
5 * COPYRIGHT  : (C) 1999  Joris van der Hoeven
6 *******************************************************************************
7 * This software falls under the GNU general public license version 3 or later.
8 * It comes WITHOUT ANY WARRANTY WHATSOEVER. For details, see the file LICENSE
9 * in the root directory or <http://www.gnu.org/licenses/gpl-3.0.html>.
10 ******************************************************************************/
11 
12 #ifndef BASIC_EVENT_H
13 #define BASIC_EVENT_H
14 #include "Widkit/event.hpp"
15 #include "Widkit/wk_widget.hpp"
16 #include "Widkit/Event/event_codes.hpp"
17 #include "renderer.hpp"
18 
19 /******************************************************************************
20 * Attribute events
21 ******************************************************************************/
22 
23 struct get_size_event_rep: public event_rep {
24   SI& w; SI& h; int mode;
25   get_size_event_rep (SI& w, SI& h, int mode);
26   operator tree ();
27 };
28 EVENT(get_size_event);
29 
30 struct get_widget_event_rep: public event_rep {
31   string which; wk_widget& w;
32   get_widget_event_rep (string which, wk_widget& w);
33   operator tree ();
34 };
35 EVENT(get_widget_event);
36 
37 struct set_widget_event_rep: public event_rep {
38   string which; wk_widget w;
39   set_widget_event_rep (string which, wk_widget w);
40   operator tree ();
41 };
42 EVENT(set_widget_event);
43 
44 /******************************************************************************
45 * Structure events
46 ******************************************************************************/
47 
48 struct attach_window_event_rep: public event_rep {
49   window win;
50   attach_window_event_rep (window win);
51   operator tree ();
52 };
53 EVENT(attach_window_event);
54 
55 struct position_event_rep: public event_rep {
56   bool flag; SI ox, oy, w, h; gravity grav;
57   position_event_rep ();
58   position_event_rep (SI ox, SI oy, SI w, SI h, gravity grav);
59   operator tree ();
60 };
61 tree as_tree (gravity grav);
62 tm_ostream& operator << (tm_ostream& out, gravity grav);
63 EVENT(position_event);
64 
65 struct move_event_rep: public event_rep {
66   move_event_rep ();
67   operator tree ();
68 };
69 EVENT(move_event);
70 
71 struct resize_event_rep: public event_rep {
72   resize_event_rep ();
73   operator tree ();
74 };
75 EVENT(resize_event);
76 
77 struct destroy_event_rep: public event_rep {
78   destroy_event_rep ();
79   operator tree ();
80 };
81 EVENT(destroy_event);
82 
83 /******************************************************************************
84 * Input events
85 ******************************************************************************/
86 
87 struct keypress_event_rep: public event_rep {
88   string key; time_t t;
89   keypress_event_rep (string key, time_t t);
90   operator tree ();
91 };
92 EVENT(keypress_event);
93 
94 struct keyboard_focus_event_rep: public event_rep {
95   bool flag; time_t t;
96   keyboard_focus_event_rep (bool in_out_flag, time_t t);
97   operator tree ();
98 };
99 EVENT(keyboard_focus_event);
100 
101 struct keyboard_focus_on_event_rep: public event_rep {
102   string field; bool& done;
103   keyboard_focus_on_event_rep (string field, bool& done);
104   operator tree ();
105 };
106 EVENT(keyboard_focus_on_event);
107 
108 struct mouse_event_rep: public event_rep {
109   string type; SI x, y; int mods; time_t t;
110   mouse_event_rep (string type, SI x, SI y, int mods, time_t t);
111   bool pressed (string which);
112   operator tree ();
113 };
114 EVENT(mouse_event);
115 
116 struct alarm_event_rep: public event_rep {
117   string message; time_t t;
118   alarm_event_rep (string message, time_t t);
119   operator tree ();
120 };
121 EVENT(alarm_event);
122 
123 /******************************************************************************
124 * Output events
125 ******************************************************************************/
126 
127 struct clear_event_rep: public event_rep {
128   renderer win;
129   SI x1, y1, x2, y2;
130   clear_event_rep (renderer win, SI x1, SI y1, SI x2, SI y2);
131   operator tree ();
132 };
133 EVENT(clear_event);
134 
135 struct repaint_event_rep: public event_rep {
136   renderer win;
137   SI x1, y1, x2, y2; bool& stop;
138   repaint_event_rep (renderer win, SI x1, SI y1, SI x2, SI y2, bool& stop);
139   operator tree ();
140 };
141 EVENT(repaint_event);
142 
143 /******************************************************************************
144 * Request some action
145 ******************************************************************************/
146 
147 struct update_event_rep: public event_rep {
148   update_event_rep ();
149   operator tree ();
150 };
151 EVENT(update_event);
152 
153 struct refresh_event_rep: public event_rep {
154   string kind;
155   refresh_event_rep (string kind);
156   operator tree ();
157 };
158 EVENT(refresh_event);
159 
160 struct invalidate_event_rep: public event_rep {
161   bool all_flag;
162   SI x1, y1, x2, y2;
163   invalidate_event_rep ();
164   invalidate_event_rep (SI x1, SI y1, SI x2, SI y2);
165   operator tree ();
166 };
167 EVENT(invalidate_event);
168 
169 struct keyboard_grab_event_rep: public event_rep {
170   bool flag; time_t t;
171   keyboard_grab_event_rep (bool in_out_flag, time_t t);
172   operator tree ();
173 };
174 EVENT(keyboard_grab_event);
175 
176 struct mouse_grab_event_rep: public event_rep {
177   bool flag; time_t t;
178   mouse_grab_event_rep (bool in_out_flag, time_t t);
179   operator tree ();
180 };
181 EVENT(mouse_grab_event);
182 
183 struct request_alarm_event_rep: public event_rep {
184   event ev; time_t delay;
185   request_alarm_event_rep (event ev, time_t delay);
186   operator tree ();
187 };
188 EVENT(request_alarm_event);
189 
190 /******************************************************************************
191 * Miscellaneous events
192 ******************************************************************************/
193 
194 struct find_child_event_rep: public event_rep {
195   SI x, y; int& which;
196   find_child_event_rep (SI x, SI y, int& which);
197   operator tree ();
198 };
199 EVENT(find_child_event);
200 
201 /******************************************************************************
202 * Modification of events
203 ******************************************************************************/
204 
205 event emit_keypress (keypress_event ev, string key);
206 event emit_mouse (mouse_event ev, string type, SI x, SI y);
207 
208 #endif // defined BASIC_EVENT_H
209