@@ -20,81 +20,77 @@ | |||
#include "caca++.h" | |||
Caca::Caca(void) | |||
{ | |||
} | |||
Caca::Caca(Cucul *cv) | |||
Caca::Caca(Cucul *cv) | |||
{ | |||
dp = caca_create_display(cv->get_cucul_canvas_t()); | |||
if(!dp) | |||
throw -1; | |||
} | |||
Caca::~Caca() | |||
Caca::~Caca() | |||
{ | |||
caca_free_display(dp); | |||
} | |||
void Caca::attach(Cucul *cv) | |||
void Caca::Attach(Cucul *cv) | |||
{ | |||
dp = caca_create_display(cv->get_cucul_canvas_t()); | |||
if(!dp) | |||
throw -1; | |||
} | |||
void Caca::detach() | |||
void Caca::Detach() | |||
{ | |||
caca_free_display(dp); | |||
} | |||
void Caca::set_delay(unsigned int d) | |||
void Caca::setDelay(unsigned int d) | |||
{ | |||
caca_set_delay(dp, d); | |||
} | |||
void Caca::display() | |||
void Caca::Display() | |||
{ | |||
caca_refresh_display(dp); | |||
} | |||
unsigned int Caca::get_rendertime() | |||
unsigned int Caca::getRendertime() | |||
{ | |||
return caca_get_rendertime(dp); | |||
} | |||
unsigned int Caca::get_display_width() | |||
unsigned int Caca::getWidth() | |||
{ | |||
return caca_get_display_width(dp); | |||
} | |||
unsigned int Caca::get_display_height() | |||
unsigned int Caca::getHeight() | |||
{ | |||
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); | |||
} | |||
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); | |||
} | |||
unsigned int Caca::get_mouse_x() | |||
unsigned int Caca::getMouseX() | |||
{ | |||
return caca_get_mouse_x(dp); | |||
} | |||
unsigned int Caca::get_mouse_y() | |||
unsigned int Caca::getMouseY() | |||
{ | |||
return caca_get_mouse_x(dp); | |||
} | |||
void Caca::set_mouse(int v) | |||
void Caca::setMouse(int v) | |||
{ | |||
caca_set_mouse(dp, v); | |||
} | |||
@@ -56,18 +56,18 @@ class Caca | |||
Caca(Cucul *cv); | |||
~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: | |||
caca_display_t *dp; | |||
@@ -67,9 +67,9 @@ int main(int argc, char *argv[]) | |||
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 */ | |||
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); | |||
/* Blit */ | |||
kk->display(); | |||
kk->Display(); | |||
x+=ix; | |||
y+=iy; | |||
@@ -36,6 +36,12 @@ Cucul::Cucul(int width, int height) | |||
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() | |||
{ | |||
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 = cucul_load_font(s, v); | |||
if(!font) throw -1; | |||
} | |||
char const *const * Font::getList(void) | |||
@@ -317,6 +324,7 @@ Font::~Font() | |||
Buffer::Buffer(Cucul *cv, char const *buf) | |||
{ | |||
buffer = cucul_export_canvas(cv->get_cucul_canvas_t(), buf); | |||
if(!buffer) throw -1; | |||
} | |||
char const *const * Buffer::getExportList(void) | |||
@@ -91,6 +91,7 @@ class Cucul | |||
public: | |||
Cucul(); | |||
Cucul(int width, int height); | |||
Cucul(void const *, unsigned int, char const *); | |||
~Cucul(); | |||
void setSize(unsigned int w, unsigned int h); | |||