Parcourir la source

* Fixed compile problem, put Event outside Caca class

tags/v0.99.beta14
Jean-Yves Lamoureux jylam il y a 18 ans
Parent
révision
12b35d02e8
3 fichiers modifiés avec 26 ajouts et 13 suppressions
  1. +1
    -1
      cpp/caca++.cpp
  2. +22
    -10
      cpp/caca++.h
  3. +3
    -2
      cpp/cpptest.cpp

+ 1
- 1
cpp/caca++.cpp Voir le fichier

@@ -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);
}


+ 22
- 10
cpp/caca++.h Voir le fichier

@@ -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;


};




+ 3
- 2
cpp/cpptest.cpp Voir le fichier

@@ -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);


Chargement…
Annuler
Enregistrer