Browse Source

* Updated libcaca c++ bindings

tags/v0.99.beta14
Jean-Yves Lamoureux jylam 18 years ago
parent
commit
f57af45c76
5 changed files with 38 additions and 33 deletions
  1. +14
    -18
      cpp/caca++.cpp
  2. +12
    -12
      cpp/caca++.h
  3. +3
    -3
      cpp/cpptest.cpp
  4. +8
    -0
      cpp/cucul++.cpp
  5. +1
    -0
      cpp/cucul++.h

+ 14
- 18
cpp/caca++.cpp View File

@@ -20,81 +20,77 @@


#include "caca++.h" #include "caca++.h"


Caca::Caca(void)
{

}


Caca::Caca(Cucul *cv)
Caca::Caca(Cucul *cv)
{ {
dp = caca_create_display(cv->get_cucul_canvas_t()); dp = caca_create_display(cv->get_cucul_canvas_t());
if(!dp) if(!dp)
throw -1; throw -1;
} }


Caca::~Caca()
Caca::~Caca()
{ {
caca_free_display(dp); caca_free_display(dp);
} }


void Caca::attach(Cucul *cv)
void Caca::Attach(Cucul *cv)
{ {
dp = caca_create_display(cv->get_cucul_canvas_t()); dp = caca_create_display(cv->get_cucul_canvas_t());
if(!dp) if(!dp)
throw -1; throw -1;
} }


void Caca::detach()
void Caca::Detach()
{ {
caca_free_display(dp); caca_free_display(dp);
} }


void Caca::set_delay(unsigned int d)
void Caca::setDelay(unsigned int d)
{ {
caca_set_delay(dp, d); caca_set_delay(dp, d);
} }


void Caca::display()
void Caca::Display()
{ {
caca_refresh_display(dp); caca_refresh_display(dp);
} }


unsigned int Caca::get_rendertime()
unsigned int Caca::getRendertime()
{ {
return caca_get_rendertime(dp); return caca_get_rendertime(dp);
} }


unsigned int Caca::get_display_width()
unsigned int Caca::getWidth()
{ {
return caca_get_display_width(dp); return caca_get_display_width(dp);
} }


unsigned int Caca::get_display_height()
unsigned int Caca::getHeight()
{ {
return caca_get_display_height(dp); return caca_get_display_height(dp);
} }


int Caca::set_display_title(char const *s)
int Caca::setTitle(char const *s)
{ {
return caca_set_display_title(dp, s); return caca_set_display_title(dp, s);
} }


int Caca::get_event(unsigned int g, Event *n, int aa)
int Caca::getEvent(unsigned int g, Event *n, int aa)
{ {
return caca_get_event(dp, g, &n->e, aa); return caca_get_event(dp, g, &n->e, aa);
} }


unsigned int Caca::get_mouse_x()
unsigned int Caca::getMouseX()
{ {
return caca_get_mouse_x(dp); return caca_get_mouse_x(dp);
} }


unsigned int Caca::get_mouse_y()
unsigned int Caca::getMouseY()
{ {
return caca_get_mouse_x(dp); return caca_get_mouse_x(dp);
} }


void Caca::set_mouse(int v)
void Caca::setMouse(int v)
{ {
caca_set_mouse(dp, v); caca_set_mouse(dp, v);
} }


+ 12
- 12
cpp/caca++.h View File

@@ -56,18 +56,18 @@ class Caca
Caca(Cucul *cv); Caca(Cucul *cv);
~Caca(); ~Caca();


void attach(Cucul *cv);
void detach();
void set_delay(unsigned int);
void display();
unsigned int get_rendertime();
unsigned int get_display_width();
unsigned int get_display_height();
int set_display_title(char const *);
int get_event(unsigned int, Event*, int);
unsigned int get_mouse_x();
unsigned int get_mouse_y();
void set_mouse(int);
void Attach(Cucul *cv);
void Detach();
void setDelay(unsigned int);
void Display();
unsigned int getRendertime();
unsigned int getWidth();
unsigned int getHeight();
int setTitle(char const *);
int getEvent(unsigned int, Event*, int);
unsigned int getMouseX();
unsigned int getMouseY();
void setMouse(int);


private: private:
caca_display_t *dp; caca_display_t *dp;


+ 3
- 3
cpp/cpptest.cpp View File

@@ -67,9 +67,9 @@ int main(int argc, char *argv[])
return -1; return -1;
} }


kk->set_delay(20000);
kk->setDelay(20000);


while(!kk->get_event(ev.CACA_EVENT_KEY_PRESS, &ev, 0)) {
while(!kk->getEvent(ev.CACA_EVENT_KEY_PRESS, &ev, 0)) {


/* Draw pig */ /* Draw pig */
qq->setColor(CUCUL_COLOR_LIGHTMAGENTA, CUCUL_COLOR_BLACK); qq->setColor(CUCUL_COLOR_LIGHTMAGENTA, CUCUL_COLOR_BLACK);
@@ -82,7 +82,7 @@ int main(int argc, char *argv[])
qq->Printf(30,15, "Powered by libcaca %s", VERSION); qq->Printf(30,15, "Powered by libcaca %s", VERSION);


/* Blit */ /* Blit */
kk->display();
kk->Display();


x+=ix; x+=ix;
y+=iy; y+=iy;


+ 8
- 0
cpp/cucul++.cpp View File

@@ -36,6 +36,12 @@ Cucul::Cucul(int width, int height)
if(!cv) throw -1; if(!cv) throw -1;
} }


Cucul::Cucul(void const *data, unsigned int size, char const *format)
{
cv = cucul_import_canvas(data, size, format);
if(!cv) throw -1;
}

Cucul::~Cucul() Cucul::~Cucul()
{ {
if(cv) if(cv)
@@ -287,6 +293,7 @@ void Dither::Bitmap(Cucul *cv, int x, int y, int w, int h, void *v)
Font::Font(void const *s, unsigned int v) Font::Font(void const *s, unsigned int v)
{ {
font = cucul_load_font(s, v); font = cucul_load_font(s, v);
if(!font) throw -1;
} }


char const *const * Font::getList(void) char const *const * Font::getList(void)
@@ -317,6 +324,7 @@ Font::~Font()
Buffer::Buffer(Cucul *cv, char const *buf) Buffer::Buffer(Cucul *cv, char const *buf)
{ {
buffer = cucul_export_canvas(cv->get_cucul_canvas_t(), buf); buffer = cucul_export_canvas(cv->get_cucul_canvas_t(), buf);
if(!buffer) throw -1;
} }


char const *const * Buffer::getExportList(void) char const *const * Buffer::getExportList(void)


+ 1
- 0
cpp/cucul++.h View File

@@ -91,6 +91,7 @@ class Cucul
public: public:
Cucul(); Cucul();
Cucul(int width, int height); Cucul(int width, int height);
Cucul(void const *, unsigned int, char const *);
~Cucul(); ~Cucul();


void setSize(unsigned int w, unsigned int h); void setSize(unsigned int w, unsigned int h);


Loading…
Cancel
Save