Ignore:
Timestamp:
May 13, 2011, 9:13:53 AM (11 years ago)
Author:
Sam Hocevar
Message:

imlib: refactor Event and EventHandler?.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • abuse/trunk/src/imlib/event.h

    r555 r643  
    3232class Jwindow;
    3333
    34 class event : public linked_node
     34class Event : public linked_node
    3535{
    36 public :
    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;
    43        void *start; }         redraw;
    44   Jwindow                        *window;      // NULL is root
    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 } ;
     36public:
     37    Event()
     38    {
     39        type = EV_SPURIOUS;
     40    }
    5041
    51 class event_handler
     42    Event(int id, char *data)
     43    {
     44        type = EV_MESSAGE;
     45        message.id = id;
     46        message.data = data;
     47    }
     48
     49    int type;
     50    vec2i mouse_move;
     51    int mouse_button, key;
     52
     53    struct { char alt, ctrl, shift; } key_special;
     54    struct { int x1, y1, x2, y2; void *start; } redraw;
     55
     56    Jwindow *window;      // NULL is root
     57    vec2i window_position;
     58    struct { int id; char *data; } message;
     59};
     60
     61class EventHandler
    5262{
    53   sprite_controller sc;
    54   int mhere,ewaiting,last_keystat,last_key;
    55   int get_key_flags();
    56   linked_list events;
    57 public :
     63public:
     64    EventHandler(image *screen, palette *pal);
     65    ~EventHandler();
     66
     67    void Push(Event *ev)
     68    {
     69        m_events.add_end(ev);
     70    }
     71
    5872  JCMouse *mouse;
    5973  sprite *mouse_sprite() { return mouse->mouse_sprite(); }
    60   event_handler(image *screen, palette *pal);
    6174  int event_waiting();
    62   void get_event(event &ev);
     75  void Get(Event &ev);
    6376  void add_redraw(int X1, int Y1, int X2, int Y2, void *Start);
    6477  void mouse_status(int &x, int &y, int &button)
    65   { if (mouse)
     78  {
     79    if (mouse)
    6680    {
    67       x=mouse->x(); y=mouse->y(); button=mouse->button();
    68     } else x=y=button=0;
     81      x = mouse->x();
     82      y = mouse->y();
     83      button = mouse->button();
     84    } else x = y = button = 0;
    6985  }
    70   void push_event(event *ev) { events.add_end(ev); }
    7186  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 } ;
     87  int has_mouse() { return mouse->exists(); }
     88  void set_mouse_shape(image *im, int centerx, int centery) { mouse->set_shape(im, -centerx, -centery); }
     89  void set_mouse_position(int mx, int my) { if (mouse) mouse->set_position(mx, my); }
     90
     91private:
     92    int get_key_flags();
     93
     94    linked_list m_events;
     95    int mhere, ewaiting, last_keystat, last_key;
     96    sprite_controller sc;
     97};
     98
    7799#endif
    78100
Note: See TracChangeset for help on using the changeset viewer.