Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 
 
 
 

73 lignes
2.5 KiB

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