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

Last change on this file since 534 was 519, checked in by Sam Hocevar, 12 years ago

core: fix a few useless casts.

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