1 | /********************************************************************** <BR>
|
---|
2 | This file is part of Crack dot Com's free source code release of
|
---|
3 | Golgotha. <a href="http://www.crack.com/golgotha_release"> <BR> for
|
---|
4 | information about compiling & licensing issues visit this URL</a>
|
---|
5 | <PRE> If that doesn't help, contact Jonathan Clark at
|
---|
6 | golgotha_source@usa.net (Subject should have "GOLG" in it)
|
---|
7 | ***********************************************************************/
|
---|
8 |
|
---|
9 | #ifndef __WIN_EVT_HH
|
---|
10 | #define __WIN_EVT_HH
|
---|
11 |
|
---|
12 | #include "device/event.hh"
|
---|
13 | #include "arch.hh"
|
---|
14 |
|
---|
15 | class i4_cursor_class;
|
---|
16 | class i4_window_class;
|
---|
17 |
|
---|
18 | class i4_window_message_class : public i4_event
|
---|
19 | {
|
---|
20 | public :
|
---|
21 | enum win_sub_type {
|
---|
22 | GOT_MOUSE_FOCUS, // \/ \/ \/ sent by parent to children events \/ \/ \/
|
---|
23 |
|
---|
24 | LOST_MOUSE_FOCUS,
|
---|
25 | GOT_KEYBOARD_FOCUS,
|
---|
26 | LOST_KEYBOARD_FOCUS,
|
---|
27 |
|
---|
28 | DRAG_DROP_MOVE, // when mouse moves in drag drop mode
|
---|
29 |
|
---|
30 | GOT_DROP_FOCUS,
|
---|
31 | LOST_DROP_FOCUS,
|
---|
32 | GOT_DROP,
|
---|
33 |
|
---|
34 | REQUEST_KEY_GRAB, // \/ \/ \/ sent by children to parent events \/ \/ \/
|
---|
35 | REQUEST_NEXT_KEY_FOCUS,
|
---|
36 |
|
---|
37 | REQUEST_LEFT_KEY_FOCUS,
|
---|
38 | REQUEST_RIGHT_KEY_FOCUS,
|
---|
39 | REQUEST_UP_KEY_FOCUS,
|
---|
40 | REQUEST_DOWN_KEY_FOCUS,
|
---|
41 |
|
---|
42 | REQUEST_MOUSE_GRAB,
|
---|
43 | REQUEST_MOUSE_UNGRAB,
|
---|
44 |
|
---|
45 | REQUEST_DRAG_DROP_START,
|
---|
46 | REQUEST_DRAG_DROP_END,
|
---|
47 |
|
---|
48 | REQUEST_DRAG_START,
|
---|
49 | REQUEST_DRAG_END,
|
---|
50 |
|
---|
51 | REQUEST_DELETE,
|
---|
52 |
|
---|
53 | NOTIFY_MOVE,
|
---|
54 | NOTIFY_RESIZE,
|
---|
55 |
|
---|
56 | CHANGE_CURSOR
|
---|
57 | } ;
|
---|
58 |
|
---|
59 |
|
---|
60 |
|
---|
61 | win_sub_type sub_type;
|
---|
62 | i4_window_class *from_window;
|
---|
63 |
|
---|
64 | i4_window_class *from() { return from_window; }
|
---|
65 | i4_window_message_class(win_sub_type win_message, i4_window_class *From)
|
---|
66 | {
|
---|
67 | from_window=From;
|
---|
68 | sub_type=win_message;
|
---|
69 | }
|
---|
70 |
|
---|
71 | virtual dispatch_time when() { return NOW; }
|
---|
72 | virtual event_type type() { return WINDOW_MESSAGE; }
|
---|
73 | virtual i4_event *copy() { return new i4_window_message_class(sub_type,from_window); }
|
---|
74 | char *name() { return "window_message"; }
|
---|
75 | } ;
|
---|
76 |
|
---|
77 | class i4_window_got_mouse_focus_class : public i4_window_message_class
|
---|
78 | {
|
---|
79 | public:
|
---|
80 | // location of mouse when you got focus, because got_focus may come before mouse_move
|
---|
81 | int x, y;
|
---|
82 |
|
---|
83 | virtual void move(int xoff, int yoff) { x+=xoff; y+=yoff; }
|
---|
84 |
|
---|
85 | i4_window_got_mouse_focus_class(i4_window_class *from, int x, int y)
|
---|
86 | : i4_window_message_class(GOT_MOUSE_FOCUS, from), x(x), y(y) {}
|
---|
87 | char *name() { return "got_mouse_focus"; }
|
---|
88 | virtual dispatch_time when() { return NOW; }
|
---|
89 | virtual i4_event *copy() { return new i4_window_got_mouse_focus_class(from_window,x,y); }
|
---|
90 | };
|
---|
91 |
|
---|
92 |
|
---|
93 | class i4_window_lost_mouse_focus_class : public i4_window_message_class
|
---|
94 | {
|
---|
95 | public:
|
---|
96 | i4_window_class *lost_to;
|
---|
97 |
|
---|
98 | i4_window_lost_mouse_focus_class(i4_window_class *from,
|
---|
99 | i4_window_class *lost_to)
|
---|
100 | : i4_window_message_class(LOST_MOUSE_FOCUS, from), lost_to(lost_to) {}
|
---|
101 | char *name() { return "lost_mouse_focus"; }
|
---|
102 | virtual dispatch_time when() { return NOW; }
|
---|
103 | virtual i4_event *copy() { return new i4_window_lost_mouse_focus_class(from_window, lost_to); }
|
---|
104 | };
|
---|
105 |
|
---|
106 | class i4_window_request_drag_drop_end_class : public i4_window_message_class
|
---|
107 | {
|
---|
108 | public:
|
---|
109 | i4_window_request_drag_drop_end_class(i4_window_class *from)
|
---|
110 | : i4_window_message_class(REQUEST_DRAG_DROP_END, from)
|
---|
111 | {}
|
---|
112 | char *name() { return "request_drag_drop_end"; }
|
---|
113 | };
|
---|
114 |
|
---|
115 |
|
---|
116 | class i4_window_drag_drop_move_class : public i4_window_message_class
|
---|
117 | {
|
---|
118 | public:
|
---|
119 | i4_coord x,y;
|
---|
120 | w32 reference_id;
|
---|
121 | void *further_info;
|
---|
122 |
|
---|
123 | virtual void move(int xoff, int yoff) { x+=xoff; y+=yoff; }
|
---|
124 |
|
---|
125 | i4_window_drag_drop_move_class(i4_window_class *from,
|
---|
126 | i4_coord x,
|
---|
127 | i4_coord y,
|
---|
128 | w32 reference_id,
|
---|
129 | void *further_info)
|
---|
130 | : i4_window_message_class(DRAG_DROP_MOVE, from),
|
---|
131 | x(x), y(y), reference_id(reference_id), further_info(further_info)
|
---|
132 | {}
|
---|
133 |
|
---|
134 | virtual i4_event *copy()
|
---|
135 | { return new i4_window_drag_drop_move_class(from_window, x,y, reference_id, further_info); }
|
---|
136 | char *name() { return "drag_drop_move"; }
|
---|
137 |
|
---|
138 | };
|
---|
139 |
|
---|
140 | // return_result is set to i4_T if the parent was able to give you mouse grabbing
|
---|
141 | class i4_window_request_drag_drop_start_class : public i4_window_message_class
|
---|
142 | {
|
---|
143 | public :
|
---|
144 | i4_bool return_result;
|
---|
145 | i4_cursor_class *drag_cursor;
|
---|
146 | w32 reference_id;
|
---|
147 | i4_event *drop_event;
|
---|
148 | void *further_info;
|
---|
149 | i4_window_request_drag_drop_start_class(i4_window_class *from,
|
---|
150 | i4_cursor_class *drag_cursor, // this will be destoryed
|
---|
151 | w32 reference_id, // a unique number
|
---|
152 | void *further_info=0)
|
---|
153 |
|
---|
154 | : i4_window_message_class(REQUEST_DRAG_DROP_START,from),
|
---|
155 | drag_cursor(drag_cursor),
|
---|
156 | reference_id(reference_id),
|
---|
157 | further_info(further_info)
|
---|
158 | { return_result=i4_F; }
|
---|
159 |
|
---|
160 | virtual i4_event *copy()
|
---|
161 | { return new i4_window_request_drag_drop_start_class(from_window,
|
---|
162 | drag_cursor, reference_id, further_info); }
|
---|
163 |
|
---|
164 | virtual dispatch_time when() { return NOW; } // send now because a result is expected
|
---|
165 | char *name() { return "request_drag_drop_start"; }
|
---|
166 | } ;
|
---|
167 |
|
---|
168 | class i4_str;
|
---|
169 | struct i4_drag_info_struct
|
---|
170 | {
|
---|
171 | enum {
|
---|
172 | FILENAMES
|
---|
173 | } drag_object_type;
|
---|
174 |
|
---|
175 | i4_coord x,y;
|
---|
176 |
|
---|
177 |
|
---|
178 | int t_filenames;
|
---|
179 | i4_str **filenames;
|
---|
180 | void copy_to(i4_drag_info_struct &drag_struct);
|
---|
181 | i4_drag_info_struct() { t_filenames=0; filenames=0; }
|
---|
182 | ~i4_drag_info_struct();
|
---|
183 | };
|
---|
184 |
|
---|
185 | class i4_window_got_drag_drop_focus_class : public i4_window_message_class
|
---|
186 | {
|
---|
187 | public:
|
---|
188 | i4_drag_info_struct drag_info;
|
---|
189 |
|
---|
190 | virtual void move(int xoff, int yoff) { drag_info.x+=xoff; drag_info.y+=yoff; }
|
---|
191 |
|
---|
192 | i4_window_got_drag_drop_focus_class(i4_window_class *from)
|
---|
193 | : i4_window_message_class(DRAG_DROP_MOVE, from) {}
|
---|
194 |
|
---|
195 | virtual i4_event *copy()
|
---|
196 | {
|
---|
197 | i4_window_got_drag_drop_focus_class *dg=new i4_window_got_drag_drop_focus_class(from());
|
---|
198 | drag_info.copy_to(dg->drag_info);
|
---|
199 | return dg;
|
---|
200 | }
|
---|
201 |
|
---|
202 | char *name() { return "got_drag_drop_focus"; }
|
---|
203 | };
|
---|
204 |
|
---|
205 | class i4_window_got_drop_class : public i4_window_message_class
|
---|
206 | {
|
---|
207 | public:
|
---|
208 | i4_drag_info_struct drag_info;
|
---|
209 |
|
---|
210 | virtual void move(int xoff, int yoff) { drag_info.x+=xoff; drag_info.y+=yoff; }
|
---|
211 |
|
---|
212 | i4_window_got_drop_class(i4_window_class *from)
|
---|
213 | : i4_window_message_class(GOT_DROP, from) {}
|
---|
214 |
|
---|
215 | virtual i4_event *copy()
|
---|
216 | {
|
---|
217 | i4_window_got_drop_class *dg=new i4_window_got_drop_class(from());
|
---|
218 | drag_info.copy_to(dg->drag_info);
|
---|
219 | return dg;
|
---|
220 | }
|
---|
221 |
|
---|
222 | char *name() { return "got_drop"; }
|
---|
223 | };
|
---|
224 |
|
---|
225 |
|
---|
226 | class i4_window_lost_drag_drop_focus_class : public i4_window_message_class
|
---|
227 | {
|
---|
228 | public:
|
---|
229 | i4_window_lost_drag_drop_focus_class(i4_window_class *from)
|
---|
230 | : i4_window_message_class(LOST_DROP_FOCUS, from)
|
---|
231 | {}
|
---|
232 | char *name() { return "lost_drag_drop_focus"; }
|
---|
233 | };
|
---|
234 |
|
---|
235 |
|
---|
236 | // return_result is set to i4_T if the parent was able to give you mouse grabbing
|
---|
237 | class i4_window_request_key_grab_class : public i4_window_message_class
|
---|
238 | {
|
---|
239 | public :
|
---|
240 | i4_bool return_result;
|
---|
241 | i4_window_request_key_grab_class(i4_window_class *from)
|
---|
242 | : i4_window_message_class(REQUEST_KEY_GRAB,from)
|
---|
243 | { return_result=i4_F; }
|
---|
244 |
|
---|
245 | virtual i4_event *copy() { return new i4_window_request_key_grab_class(from_window); }
|
---|
246 | virtual dispatch_time when() { return NOW; } // send now because a result is expected
|
---|
247 | char *name() { return "request_key_grab"; }
|
---|
248 | } ;
|
---|
249 |
|
---|
250 |
|
---|
251 | // return_result is set to i4_T if the parent was able to give you mouse grabbing
|
---|
252 | class i4_window_request_mouse_grab_class : public i4_window_message_class
|
---|
253 | {
|
---|
254 | public :
|
---|
255 | i4_bool return_result;
|
---|
256 |
|
---|
257 | i4_window_request_mouse_grab_class(i4_window_class *from)
|
---|
258 | : i4_window_message_class(REQUEST_MOUSE_GRAB,from)
|
---|
259 | { return_result=i4_F; }
|
---|
260 |
|
---|
261 | virtual i4_event *copy()
|
---|
262 | {
|
---|
263 | return new i4_window_request_mouse_grab_class(from_window);
|
---|
264 | }
|
---|
265 |
|
---|
266 | virtual dispatch_time when() { return NOW; } // send now because a result is expected
|
---|
267 | char *name() { return "request_mouse_grab"; }
|
---|
268 | } ;
|
---|
269 |
|
---|
270 |
|
---|
271 | // return_result is set to i4_T if the parent was able to give you mouse grabbing
|
---|
272 | class i4_window_request_mouse_ungrab_class : public i4_window_message_class
|
---|
273 | {
|
---|
274 | public :
|
---|
275 | i4_bool return_result;
|
---|
276 | i4_window_request_mouse_ungrab_class(i4_window_class *from)
|
---|
277 | : i4_window_message_class(REQUEST_MOUSE_UNGRAB,from)
|
---|
278 | { return_result=i4_F; }
|
---|
279 |
|
---|
280 | virtual i4_event *copy() { return new i4_window_request_mouse_ungrab_class(from_window); }
|
---|
281 | virtual dispatch_time when() { return NOW; } // send now because a result is expected
|
---|
282 | char *name() { return "request_mouse_ungrab"; }
|
---|
283 | } ;
|
---|
284 |
|
---|
285 | // return_result is set to i4_T if the parent was able to start dragging
|
---|
286 | class i4_window_request_drag_start_class : public i4_window_message_class
|
---|
287 | {
|
---|
288 | public :
|
---|
289 | i4_bool return_result;
|
---|
290 | i4_window_request_drag_start_class(i4_window_class *from) :
|
---|
291 | i4_window_message_class(REQUEST_DRAG_START,from)
|
---|
292 | { return_result=i4_F; }
|
---|
293 |
|
---|
294 | virtual i4_event *copy()
|
---|
295 | { return new i4_window_request_drag_start_class(from_window); }
|
---|
296 |
|
---|
297 | virtual dispatch_time when()
|
---|
298 | { return NOW; } // send now because a result is expected
|
---|
299 | char *name() { return "request_drag_start"; }
|
---|
300 | } ;
|
---|
301 |
|
---|
302 |
|
---|
303 | // return_result is set to i4_T if the parent was able to start dragging
|
---|
304 | class i4_window_request_drag_end_class : public i4_window_message_class
|
---|
305 | {
|
---|
306 | public :
|
---|
307 | i4_window_request_drag_end_class(i4_window_class *from) :
|
---|
308 | i4_window_message_class(REQUEST_DRAG_END,from) {}
|
---|
309 |
|
---|
310 | virtual i4_event *copy()
|
---|
311 | { return new i4_window_request_drag_end_class(from_window); }
|
---|
312 |
|
---|
313 | virtual dispatch_time when()
|
---|
314 | { return NOW; } // send now because a result is expected
|
---|
315 |
|
---|
316 | char *name() { return "request_drag_end"; }
|
---|
317 | } ;
|
---|
318 |
|
---|
319 |
|
---|
320 | // this event is sent automatically by set_cursor
|
---|
321 | class i4_window_change_cursor_class : public i4_window_message_class
|
---|
322 | {
|
---|
323 | public :
|
---|
324 | i4_cursor_class *cursor; // if cursor is 0, then default cursor is used
|
---|
325 | i4_bool only_if_active; // if window is not active (mouse focus) then cursor will not loaded
|
---|
326 | i4_window_change_cursor_class(i4_window_class *From,
|
---|
327 | i4_cursor_class *cursor,
|
---|
328 | i4_bool only_if_active=i4_F) :
|
---|
329 | i4_window_message_class(CHANGE_CURSOR,From),
|
---|
330 | cursor(cursor),
|
---|
331 | only_if_active(only_if_active)
|
---|
332 | {}
|
---|
333 |
|
---|
334 |
|
---|
335 | virtual i4_event *copy()
|
---|
336 | { return new i4_window_change_cursor_class(from_window,cursor,only_if_active); }
|
---|
337 |
|
---|
338 | // send now in case the cursor gets destoryed before delivery
|
---|
339 | virtual dispatch_time when() { return NOW; }
|
---|
340 | char *name() { return "change_cursor"; }
|
---|
341 | } ;
|
---|
342 |
|
---|
343 |
|
---|
344 | // this event is sent to your parent and children automatically by resize()
|
---|
345 | class i4_window_notify_resize_class : public i4_window_message_class
|
---|
346 | {
|
---|
347 | public :
|
---|
348 | w16 new_width,new_height;
|
---|
349 | i4_bool draw_covered;
|
---|
350 | i4_window_notify_resize_class(i4_window_class *from, w16 new_width, w16 new_height) :
|
---|
351 | i4_window_message_class(NOTIFY_RESIZE,from),
|
---|
352 | new_width(new_width),
|
---|
353 | new_height(new_height)
|
---|
354 | { draw_covered=i4_T; }
|
---|
355 |
|
---|
356 | virtual i4_event *copy()
|
---|
357 | { return new i4_window_notify_resize_class(from_window,new_width,new_height); }
|
---|
358 |
|
---|
359 | // send now so recepient doesn't draw incorrect before event is delivered
|
---|
360 | virtual dispatch_time when() { return NOW; }
|
---|
361 | char *name() { return "notify_resize"; }
|
---|
362 | } ;
|
---|
363 |
|
---|
364 |
|
---|
365 |
|
---|
366 | // the request move_notify is automatically sent to parent during move()
|
---|
367 | class i4_window_notify_move_class : public i4_window_message_class
|
---|
368 | {
|
---|
369 | public :
|
---|
370 | i4_coord x_offset,y_offset;
|
---|
371 | i4_bool draw_covered;
|
---|
372 | i4_window_notify_move_class(i4_window_class *from,
|
---|
373 | i4_coord x_offset, i4_coord y_offset,
|
---|
374 | i4_bool draw_covered=i4_T) :
|
---|
375 | i4_window_message_class(NOTIFY_MOVE,from),
|
---|
376 | x_offset(x_offset),
|
---|
377 | y_offset(y_offset),
|
---|
378 | draw_covered(draw_covered) {};
|
---|
379 |
|
---|
380 | virtual i4_event *copy()
|
---|
381 | { return new i4_window_notify_move_class(from_window,x_offset,y_offset,draw_covered); }
|
---|
382 |
|
---|
383 | virtual dispatch_time when()
|
---|
384 | { return NOW; } // send now so reciever doesn't draw incorrectly before it arrives
|
---|
385 | char *name() { return "notify_move"; }
|
---|
386 | } ;
|
---|
387 |
|
---|
388 |
|
---|
389 |
|
---|
390 | #endif
|
---|
391 |
|
---|