source: abuse/tags/pd/macabuse/imlib/include/event.hpp @ 49

Last change on this file since 49 was 49, checked in by Sam Hocevar, 12 years ago
  • Imported original public domain release, for future reference.
File size: 2.0 KB
RevLine 
[49]1#ifndef __EVENT_HPP_
2#define __EVENT_HPP_
3#define EV_MOUSE_MOVE     1
4#define EV_MOUSE_BUTTON   2
5#define EV_KEY            4
6#define EV_KEY_SPECIAL    8
7#define EV_REDRAW        16
8#define EV_SPURIOUS      32
9#define EV_RESIZE        64
10#define EV_KEYRELEASE   128
11#define EV_CLOSE_WINDOW 256
12#define EV_DRAG_WINDOW  512
13#define EV_MESSAGE     1024
14
15#define LEFT_BUTTON    1
16#define RIGHT_BUTTON   2
17#define MIDDLE_BUTTON  4
18#include "keys.hpp"
19#include "sprite.hpp"
20#include "mouse.hpp"
21
22class jwindow;
23
24class event : public linked_node
25{
26public :
27  int                             type;
28  struct { int x,y; }             mouse_move;
29  int                             mouse_button;
30  int                             key;
31  struct { char alt,ctrl,shift; } key_special;
32  struct { int x1,y1,x2,y2;
33           void *start; }         redraw;
34  jwindow                        *window;      // NULL is root
35  struct { int x,y; }             window_position;
36  struct { int id; char *data; }  message;
37  event(int id, char *data) { type=EV_MESSAGE; message.id=id; message.data=data; }
38  event() { type=EV_SPURIOUS; }
39} ;
40
41class event_handler
42{
43  sprite_controller sc;
44  int mhere,ewaiting,last_keystat,last_key;
45  int get_key_flags();
46  linked_list events;
47public :
48  JCMouse *mouse;
49  sprite *mouse_sprite() { return mouse->mouse_sprite(); }
50  event_handler(image *screen, palette *pal);
51  int event_waiting();
52  void get_event(event &ev);
53  void add_redraw(int X1, int Y1, int X2, int Y2, void *Start);
54  void mouse_status(int &x, int &y, int &button)
55  { if (mouse)
56    {
57      x=mouse->x(); y=mouse->y(); button=mouse->button();
58    } else x=y=button=0;
59  }
60  void push_event(event *ev)
61  {
62    events.add_end((linked_node *)ev);
63    ewaiting=1;
64  }
65  void flush_screen();
66  int has_mouse() { return mouse->exsist(); }
67  void set_mouse_shape(image *im, int centerx, int centery) { mouse->set_shape(im,-centerx,-centery); }
68  void set_mouse_position(int mx, int my) { if (mouse) mouse->set_position(mx,my); }
69  ~event_handler();
70} ;
71#endif
72
Note: See TracBrowser for help on using the repository browser.