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 | |
---|
12 | #include <ruby.h> |
---|
13 | #include <caca.h> |
---|
14 | #include <errno.h> |
---|
15 | #include "common.h" |
---|
16 | |
---|
17 | VALUE cEvent; |
---|
18 | static VALUE cEventKey; |
---|
19 | VALUE cEventKeyPress; |
---|
20 | VALUE cEventKeyRelease; |
---|
21 | static VALUE cEventMouse; |
---|
22 | VALUE cEventMousePress; |
---|
23 | VALUE cEventMouseRelease; |
---|
24 | VALUE cEventMouseMotion; |
---|
25 | VALUE cEventResize; |
---|
26 | VALUE cEventQuit; |
---|
27 | |
---|
28 | void Init_caca_event(VALUE mCaca) |
---|
29 | { |
---|
30 | 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 | |
---|
72 | } |
---|