From 12b35d02e8dc2970471df21dd1e9ea120677b3d5 Mon Sep 17 00:00:00 2001 From: Jean-Yves Lamoureux Date: Mon, 17 Apr 2006 13:23:28 +0000 Subject: [PATCH] * Fixed compile problem, put Event outside Caca class --- cpp/caca++.cpp | 2 +- cpp/caca++.h | 32 ++++++++++++++++++++++---------- cpp/cpptest.cpp | 5 +++-- 3 files changed, 26 insertions(+), 13 deletions(-) diff --git a/cpp/caca++.cpp b/cpp/caca++.cpp index 655aa07..4029ad1 100644 --- a/cpp/caca++.cpp +++ b/cpp/caca++.cpp @@ -67,7 +67,7 @@ int Caca::set_window_title (char const *s) { return caca_set_window_title(kk, s); } -int Caca::get_event (unsigned int g, Caca::Event *n, int aa) +int Caca::get_event (unsigned int g, Event *n, int aa) { return caca_get_event(kk, g, n->e, aa); } diff --git a/cpp/caca++.h b/cpp/caca++.h index dd438d5..844b9ea 100644 --- a/cpp/caca++.h +++ b/cpp/caca++.h @@ -29,19 +29,33 @@ #include "cucul++.h" +class Event { + friend class Caca; + public: + enum caca_event_type + { + CACA_EVENT_NONE = 0x0000, /**< No event. */ + + CACA_EVENT_KEY_PRESS = 0x0001, /**< A key was pressed. */ + CACA_EVENT_KEY_RELEASE = 0x0002, /**< A key was released. */ + CACA_EVENT_MOUSE_PRESS = 0x0004, /**< A mouse button was pressed. */ + CACA_EVENT_MOUSE_RELEASE = 0x0008, /**< A mouse button was released. */ + CACA_EVENT_MOUSE_MOTION = 0x0010, /**< The mouse was moved. */ + CACA_EVENT_RESIZE = 0x0020, /**< The window was resized. */ + + CACA_EVENT_ANY = 0xffff /**< Bitmask for any event. */ + } type; + + protected: + caca_event *e; +}; + class Caca { public: Caca(); Caca(Cucul *qq); ~Caca(); - class Event { - friend class Caca; - protected: - caca_event *e; - }; - - void attach (Cucul *qq); void detach (); void set_delay (unsigned int); @@ -50,7 +64,7 @@ class Caca { unsigned int get_window_width (); unsigned int get_window_height (); int set_window_title (char const *); - int get_event (unsigned int, Caca::Event*, int); + int get_event (unsigned int, Event*, int); unsigned int get_mouse_x (); unsigned int get_mouse_y (); void set_mouse (int); @@ -59,8 +73,6 @@ class Caca { private: caca_t *kk; - - }; diff --git a/cpp/cpptest.cpp b/cpp/cpptest.cpp index 6b65c21..64bc9e6 100644 --- a/cpp/cpptest.cpp +++ b/cpp/cpptest.cpp @@ -43,7 +43,8 @@ int main(int argc, char *argv[]) { Cucul *qq; Caca *kk; - Caca::Event ev; + Event ev; + int x = 0, y = 0, ix = 1, iy = 1; @@ -66,7 +67,7 @@ int main(int argc, char *argv[]) kk->set_delay(20000); - while(!kk->get_event(CACA_EVENT_KEY_PRESS, &ev, 0)) { + while(!kk->get_event(ev.CACA_EVENT_KEY_PRESS, &ev, 0)) { /* Draw pig */ qq->set_color(CUCUL_COLOR_LIGHTMAGENTA, CUCUL_COLOR_BLACK);