浏览代码

* Fixed compile problem, put Event outside Caca class

tags/v0.99.beta14
Jean-Yves Lamoureux jylam 19 年前
父节点
当前提交
12b35d02e8
共有 3 个文件被更改,包括 26 次插入13 次删除
  1. +1
    -1
      cpp/caca++.cpp
  2. +22
    -10
      cpp/caca++.h
  3. +3
    -2
      cpp/cpptest.cpp

+ 1
- 1
cpp/caca++.cpp 查看文件

@@ -67,7 +67,7 @@ int Caca::set_window_title (char const *s)
{ {
return caca_set_window_title(kk, 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); return caca_get_event(kk, g, n->e, aa);
} }


+ 22
- 10
cpp/caca++.h 查看文件

@@ -29,19 +29,33 @@
#include "cucul++.h" #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 { class Caca {
public: public:
Caca(); Caca();
Caca(Cucul *qq); Caca(Cucul *qq);
~Caca(); ~Caca();


class Event {
friend class Caca;
protected:
caca_event *e;
};


void attach (Cucul *qq); void attach (Cucul *qq);
void detach (); void detach ();
void set_delay (unsigned int); void set_delay (unsigned int);
@@ -50,7 +64,7 @@ class Caca {
unsigned int get_window_width (); unsigned int get_window_width ();
unsigned int get_window_height (); unsigned int get_window_height ();
int set_window_title (char const *); 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_x ();
unsigned int get_mouse_y (); unsigned int get_mouse_y ();
void set_mouse (int); void set_mouse (int);
@@ -59,8 +73,6 @@ class Caca {
private: private:
caca_t *kk; caca_t *kk;


}; };






+ 3
- 2
cpp/cpptest.cpp 查看文件

@@ -43,7 +43,8 @@ int main(int argc, char *argv[])
{ {
Cucul *qq; Cucul *qq;
Caca *kk; Caca *kk;
Caca::Event ev;
Event ev;

int x = 0, y = 0, ix = 1, iy = 1; int x = 0, y = 0, ix = 1, iy = 1;




@@ -66,7 +67,7 @@ int main(int argc, char *argv[])


kk->set_delay(20000); 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 */ /* Draw pig */
qq->set_color(CUCUL_COLOR_LIGHTMAGENTA, CUCUL_COLOR_BLACK); qq->set_color(CUCUL_COLOR_LIGHTMAGENTA, CUCUL_COLOR_BLACK);


正在加载...
取消
保存