25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

74 lines
2.6 KiB

  1. /*
  2. * libcaca Ruby bindings
  3. * Copyright (c) 2007-2010 Pascal Terjan <pterjan@linuxfr.org>
  4. * 2012 Sam Hocevar <sam@hocevar.net>
  5. *
  6. * This library is free software. It comes without any warranty, to
  7. * the extent permitted by applicable law. You can redistribute it
  8. * and/or modify it under the terms of the Do What the Fuck You Want
  9. * to Public License, Version 2, as published by Sam Hocevar. See
  10. * http://www.wtfpl.net/ for more details.
  11. */
  12. #include <ruby.h>
  13. #include <caca.h>
  14. #include <errno.h>
  15. #include "common.h"
  16. VALUE cEvent;
  17. static VALUE cEventKey;
  18. VALUE cEventKeyPress;
  19. VALUE cEventKeyRelease;
  20. static VALUE cEventMouse;
  21. VALUE cEventMousePress;
  22. VALUE cEventMouseRelease;
  23. VALUE cEventMouseMotion;
  24. VALUE cEventResize;
  25. VALUE cEventQuit;
  26. void Init_caca_event(VALUE mCaca)
  27. {
  28. cEvent = rb_define_class_under(mCaca, "Event", rb_cObject);
  29. rb_define_const(cEvent, "TYPE", INT2FIX(CACA_EVENT_ANY));
  30. cEventKey = rb_define_class_under(cEvent, "Key", cEvent);
  31. rb_define_const(cEventKey, "TYPE",
  32. INT2FIX(CACA_EVENT_KEY_PRESS|
  33. CACA_EVENT_KEY_RELEASE));
  34. cEventKeyPress = rb_define_class_under(cEventKey, "Press", cEventKey);
  35. rb_define_const(cEventKeyPress, "TYPE",
  36. INT2FIX(CACA_EVENT_KEY_PRESS));
  37. cEventKeyRelease = rb_define_class_under(cEventKey, "Release", cEventKey);
  38. rb_define_const(cEventKeyRelease, "TYPE",
  39. INT2FIX(CACA_EVENT_KEY_RELEASE));
  40. cEventMouse = rb_define_class_under(cEvent, "Mouse", cEvent);
  41. rb_define_const(cEventMouse, "TYPE",
  42. INT2FIX(CACA_EVENT_MOUSE_PRESS|
  43. CACA_EVENT_MOUSE_RELEASE|
  44. CACA_EVENT_MOUSE_MOTION));
  45. cEventMousePress = rb_define_class_under(cEventMouse, "Press", cEventMouse);
  46. rb_define_const(cEventMousePress, "TYPE",
  47. INT2FIX(CACA_EVENT_MOUSE_PRESS));
  48. cEventMouseRelease = rb_define_class_under(cEventMouse, "Release", cEventMouse);
  49. rb_define_const(cEventMouseRelease, "TYPE",
  50. INT2FIX(CACA_EVENT_MOUSE_RELEASE));
  51. cEventMouseMotion = rb_define_class_under(cEventMouse, "Motion", cEventMouse);
  52. rb_define_const(cEventMouseMotion, "TYPE",
  53. INT2FIX(CACA_EVENT_MOUSE_MOTION));
  54. cEventResize = rb_define_class_under(cEvent, "Resize", cEvent);
  55. rb_define_const(cEventResize, "TYPE",
  56. INT2FIX(CACA_EVENT_RESIZE));
  57. cEventQuit = rb_define_class_under(cEvent, "Quit", cEvent);
  58. rb_define_const(cEventQuit, "TYPE",
  59. INT2FIX(CACA_EVENT_QUIT));
  60. }