Ignore:
Timestamp:
Nov 18, 2007, 10:13:33 PM (12 years ago)
Author:
Pascal Terjan
Message:
  • Finish Caca::Event (a.k.a. J'ai fait caca aujourd'hui)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcaca/trunk/ruby/caca-event.c

    r2017 r2019  
    1616
    1717VALUE cEvent;
     18static VALUE cEventKey;
     19VALUE cEventKeyPress;
     20VALUE cEventKeyRelease;
     21static VALUE cEventMouse;
     22VALUE cEventMousePress;
     23VALUE cEventMouseRelease;
     24VALUE cEventMouseMotion;
     25VALUE cEventResize;
     26VALUE cEventQuit;
    1827
    1928void Init_caca_event(VALUE mCaca)
    2029{
    2130    cEvent = rb_define_class_under(mCaca, "Event", rb_cObject);
     31    rb_define_const(cEvent, "TYPE", INT2FIX(CACA_EVENT_ANY));
     32
     33    cEventKey = rb_define_class_under(cEvent, "Key", cEvent);
     34    rb_define_const(cEventKey, "TYPE",
     35                    INT2FIX(CACA_EVENT_KEY_PRESS|
     36                            CACA_EVENT_KEY_RELEASE));
     37
     38    cEventKeyPress = rb_define_class_under(cEventKey, "Press", cEventKey);
     39    rb_define_const(cEventKeyPress, "TYPE",
     40                    INT2FIX(CACA_EVENT_KEY_PRESS));
     41
     42    cEventKeyRelease = rb_define_class_under(cEventKey, "Release", cEventKey);
     43    rb_define_const(cEventKeyRelease, "TYPE",
     44                    INT2FIX(CACA_EVENT_KEY_RELEASE));
     45   
     46    cEventMouse = rb_define_class_under(cEvent, "Mouse", cEvent);
     47    rb_define_const(cEventMouse, "TYPE",
     48                    INT2FIX(CACA_EVENT_MOUSE_PRESS|
     49                            CACA_EVENT_MOUSE_RELEASE|
     50                            CACA_EVENT_MOUSE_MOTION));
     51
     52    cEventMousePress = rb_define_class_under(cEventMouse, "Press", cEventMouse);
     53    rb_define_const(cEventMousePress, "TYPE",
     54                    INT2FIX(CACA_EVENT_MOUSE_PRESS));
     55
     56    cEventMouseRelease = rb_define_class_under(cEventMouse, "Release", cEventMouse);
     57    rb_define_const(cEventMouseRelease, "TYPE",
     58                    INT2FIX(CACA_EVENT_MOUSE_RELEASE));
     59
     60    cEventMouseMotion = rb_define_class_under(cEventMouse, "Motion", cEventMouse);
     61    rb_define_const(cEventMouseMotion, "TYPE",
     62                    INT2FIX(CACA_EVENT_MOUSE_MOTION));
     63
     64    cEventResize = rb_define_class_under(cEvent, "Resize", cEvent);
     65    rb_define_const(cEventResize, "TYPE",
     66                    INT2FIX(CACA_EVENT_RESIZE));
     67
     68    cEventQuit = rb_define_class_under(cEvent, "Quit", cEvent);
     69    rb_define_const(cEventQuit, "TYPE",
     70                    INT2FIX(CACA_EVENT_QUIT));
     71
    2272}
Note: See TracChangeset for help on using the changeset viewer.