source: abuse/trunk/src/imlib/event.h @ 481

Last change on this file since 481 was 481, checked in by Sam Hocevar, 11 years ago

Fuck the history, I'm renaming all .hpp files to .h for my own sanity.

  • Property svn:keywords set to Id
File size: 2.2 KB
Line 
1/*
2 *  Abuse - dark 2D side-scrolling platform game
3 *  Copyright (c) 1995 Crack dot Com
4 *
5 *  This software was released into the Public Domain. As with most public
6 *  domain software, no warranty is made or implied by Crack dot Com or
7 *  Jonathan Clark.
8 */
9
10#ifndef __EVENT_HPP_
11#define __EVENT_HPP_
12#define EV_MOUSE_MOVE     1
13#define EV_MOUSE_BUTTON   2
14#define EV_KEY            4
15#define EV_KEY_SPECIAL    8
16#define EV_REDRAW        16
17#define EV_SPURIOUS      32
18#define EV_RESIZE        64
19#define EV_KEYRELEASE   128
20#define EV_CLOSE_WINDOW 256
21#define EV_DRAG_WINDOW  512
22#define EV_MESSAGE     1024
23
24#define LEFT_BUTTON    1
25#define RIGHT_BUTTON   2
26#define MIDDLE_BUTTON  4
27#include "keys.h"
28#include "sprite.h"
29#include "mouse.h"
30
31class Jwindow;
32
33class event : public linked_node
34{
35public :
36  int                             type;
37  struct { int x,y; }             mouse_move;
38  int                             mouse_button;
39  int                             key;
40  struct { char alt,ctrl,shift; } key_special;
41  struct { int x1,y1,x2,y2;
42       void *start; }         redraw;
43  Jwindow                        *window;      // NULL is root
44  struct { int x,y; }             window_position;
45  struct { int id; char *data; }  message;
46  event(int id, char *data) { type=EV_MESSAGE; message.id=id; message.data=data; }
47  event() { type=EV_SPURIOUS; }
48} ;
49
50class event_handler
51{
52  sprite_controller sc;
53  int mhere,ewaiting,last_keystat,last_key;
54  int get_key_flags();
55  linked_list events;
56public :
57  JCMouse *mouse;
58  sprite *mouse_sprite() { return mouse->mouse_sprite(); }
59  event_handler(image *screen, palette *pal);
60  int event_waiting();
61  void get_event(event &ev);
62  void add_redraw(int X1, int Y1, int X2, int Y2, void *Start);
63  void mouse_status(int &x, int &y, int &button)
64  { if (mouse)
65    {
66      x=mouse->x(); y=mouse->y(); button=mouse->button();
67    } else x=y=button=0;
68  }
69  void push_event(event *ev) { events.add_end((linked_node *)ev); }
70  void flush_screen();
71  int has_mouse() { return mouse->exsist(); }
72  void set_mouse_shape(image *im, int centerx, int centery) { mouse->set_shape(im,-centerx,-centery); }
73  void set_mouse_position(int mx, int my) { if (mouse) mouse->set_position(mx,my); }
74  ~event_handler();
75} ;
76#endif
77
Note: See TracBrowser for help on using the repository browser.