From f57af45c762c16ece3ca8fe02ddf2c27dc45fc18 Mon Sep 17 00:00:00 2001
From: Jean-Yves Lamoureux <jylam@lnxscene.org>
Date: Wed, 26 Apr 2006 11:57:30 +0000
Subject: [PATCH]  * Updated libcaca c++ bindings

---
 cpp/caca++.cpp  | 32 ++++++++++++++------------------
 cpp/caca++.h    | 24 ++++++++++++------------
 cpp/cpptest.cpp |  6 +++---
 cpp/cucul++.cpp |  8 ++++++++
 cpp/cucul++.h   |  1 +
 5 files changed, 38 insertions(+), 33 deletions(-)

diff --git a/cpp/caca++.cpp b/cpp/caca++.cpp
index f1c4237..bf3d168 100644
--- a/cpp/caca++.cpp
+++ b/cpp/caca++.cpp
@@ -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);
 }
diff --git a/cpp/caca++.h b/cpp/caca++.h
index b2f30ea..c089dbd 100644
--- a/cpp/caca++.h
+++ b/cpp/caca++.h
@@ -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;
diff --git a/cpp/cpptest.cpp b/cpp/cpptest.cpp
index adacd63..8292f4b 100644
--- a/cpp/cpptest.cpp
+++ b/cpp/cpptest.cpp
@@ -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;
diff --git a/cpp/cucul++.cpp b/cpp/cucul++.cpp
index 8211eaf..6d864a1 100644
--- a/cpp/cucul++.cpp
+++ b/cpp/cucul++.cpp
@@ -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)
diff --git a/cpp/cucul++.h b/cpp/cucul++.h
index 50514d1..df16f2e 100644
--- a/cpp/cucul++.h
+++ b/cpp/cucul++.h
@@ -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);