Ignore:
Timestamp:
Sep 30, 2006, 8:56:23 PM (13 years ago)
Author:
Jean-Yves Lamoureux
Message:
  • Updated C++ bindings to support every single cucul/caca functionnality. Renamed cpptest to cxxtext for consistency.


--This line, and those below, will be ignored--

M cxx/cucul++.cpp
A cxx/cxxtest.cpp
M cxx/cucul++.h
M cxx/Makefile.am

Location:
libcaca/trunk/cxx
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • libcaca/trunk/cxx/Makefile.am

    r977 r1156  
    1717
    1818if USE_CXX
    19 noinst_PROGRAMS = cpptest
     19noinst_PROGRAMS = cxxtest
    2020endif
    2121
    22 cpptest_SOURCES = cpptest.cpp
    23 cpptest_LDADD = libcaca++.la libcucul++.la ../caca/libcaca.la ../cucul/libcucul.la @CACA_LIBS@
     22cxxtest_SOURCES = cxxtest.cpp
     23cxxtest_LDADD = libcaca++.la libcucul++.la ../caca/libcaca.la ../cucul/libcucul.la @CACA_LIBS@
    2424
  • libcaca/trunk/cxx/cucul++.cpp

    r899 r1156  
    2424#include "cucul++.h"
    2525
     26
     27unsigned long int Charset::utf8ToUtf32(char const *s, unsigned int *read)
     28{
     29    return cucul_utf8_to_utf32(s, read);
     30}
     31unsigned int Charset::utf32ToUtf8(char *buf, unsigned long int ch)
     32{
     33    return cucul_utf32_to_utf8(buf, ch);
     34}
     35unsigned char Charset::utf32ToCp437(unsigned long int ch)
     36{
     37    return cucul_utf32_to_cp437(ch);
     38}
     39unsigned long int Charset::cp437ToUtf32(unsigned char ch)
     40{
     41    return cucul_cp437_to_utf32(ch);
     42}
     43
     44
    2645Cucul::Cucul()
    2746{
     
    3958Cucul::Cucul(Buffer *b, char const *format)
    4059{
    41     cv = cucul_import_canvas(b->get_buffer(), format);
     60    cv = cucul_import_canvas(b->getBuffer(), format);
    4261    if(!cv) throw -1;
    4362}
     
    7291{
    7392    cucul_set_color(cv, f, b);
     93}
     94
     95int  Cucul::setTruecolor(unsigned int f, unsigned int b)
     96{
     97    return cucul_set_truecolor(cv, f, b);
    7498}
    7599
     
    212236}
    213237
     238unsigned long int Cucul::getColor(int x, int y)
     239{
     240    return cucul_get_color(cv, x, y);
     241}
     242
     243int Cucul::setBoundaries(cucul_canvas_t *, int x, int y,
     244                         unsigned int w, unsigned int h)
     245{
     246    return cucul_set_canvas_boundaries(cv, x, y, h, w);
     247}
     248
     249unsigned int Cucul::getFrameCount()
     250{
     251    return cucul_get_canvas_frame_count(cv);
     252}
     253int Cucul::setFrame(unsigned int f)
     254{
     255    return cucul_set_canvas_frame(cv, f);
     256}
     257int Cucul::createFrame(unsigned int f)
     258{
     259    return cucul_create_canvas_frame(cv, f);
     260}
     261int Cucul::freeFrame(unsigned int f)
     262{
     263    return cucul_create_canvas_frame(cv, f);
     264}
     265
    214266Dither::Dither(unsigned int v1, unsigned int v2, unsigned int v3, unsigned int v4, unsigned int v5, unsigned int v6, unsigned int v7, unsigned int v8)
    215267{
     
    317369}
    318370
     371unsigned long int const *Font::getBlocks()
     372{
     373    return cucul_get_font_blocks(font);
     374}
     375
    319376Font::~Font()
    320377{
     
    322379}
    323380
    324 Buffer::Buffer(Cucul *cv, char const *buf)
    325 {
    326     buffer = cucul_export_canvas(cv->get_cucul_canvas_t(), buf);
    327     if(!buffer) throw -1;
     381Buffer::Buffer()
     382{
     383    buffer_ = NULL;
     384}
     385
     386Buffer::~Buffer()
     387{
     388    if(buffer_)
     389        cucul_free_buffer(buffer_);
    328390}
    329391
     
    333395}
    334396
    335 cucul_buffer *Buffer::get_buffer(void)
    336 {
    337     return buffer;
    338 }
     397void *Buffer::getData(void)
     398{
     399    return cucul_get_buffer_data(buffer_);
     400}
     401
     402void Buffer::loadMemory(void *buf, unsigned long int size)
     403{
     404    buffer_ = cucul_load_memory(buf, size);
     405    if(buffer_ == NULL)
     406        throw -1;
     407}
     408
     409void Buffer::loadFile(char const *filename)
     410{
     411    buffer_ = cucul_load_file(filename);
     412    if(buffer_ == NULL)
     413        throw -1;
     414}
     415
     416unsigned long int Buffer::getSize()
     417{
     418    return cucul_get_buffer_size(buffer_);
     419}
     420
     421cucul_buffer *Buffer::getBuffer()
     422{
     423    return buffer_;
     424}
  • libcaca/trunk/cxx/cucul++.h

    r917 r1156  
    2929class Cucul;
    3030
     31
     32class Charset
     33{
     34    unsigned long int utf8ToUtf32(char const *, unsigned int *);
     35    unsigned int utf32ToUtf8(char *, unsigned long int);
     36    unsigned char utf32ToCp437(unsigned long int);
     37    unsigned long int cp437ToUtf32(unsigned char);
     38};
     39
     40
     41
     42
     43
    3144/* Ugly, I know */
    3245class Font
     
    3952    unsigned int getHeight();
    4053    void renderCanvas(Cucul *, unsigned char *, unsigned int, unsigned int, unsigned int);
    41    
     54    unsigned long int const *getBlocks();
     55
    4256 private:
    4357    cucul_font *font;
    44    
     58
    4559};
    4660
     
    7589    friend class Cucul;
    7690 public:
    77     Buffer(Cucul *cv, char const *);
     91    Buffer();
    7892    ~Buffer();
    7993    char const *const * getExportList(void);
     94    void *Buffer::getData(void);
     95    void loadMemory(void *buf, unsigned long int size);
     96    void loadFile(char const *filename);
     97    unsigned long int getSize();
    8098
    8199 protected:
     
    83101
    84102 private:
    85     cucul_buffer *buffer;
     103    cucul_buffer *buffer_;
     104    cucul_buffer *getBuffer();
    86105};
    87106
     
    103122    unsigned int getHeight(void);
    104123    void setColor(unsigned int f, unsigned int b);
     124    int  setTruecolor(unsigned int f, unsigned int b);
     125    unsigned long int getColor(int, int);
    105126    char const * getColorName(unsigned int color);
    106127    void Printf(int x , int y , char const * format,...);
    107128    void putChar(int x, int y, char ch);
     129    unsigned long int getChar(cucul_canvas_t *, int, int);
    108130    void putStr(int x, int y, char *str);
    109131    void Clear(void);
     
    128150    void fillTriangle(int, int, int, int, int, int, char const *);
    129151    int Rand(int, int);
     152    int setBoundaries(cucul_canvas_t *, int, int,
     153                                unsigned int, unsigned int);
     154    unsigned int getFrameCount();
     155    int setFrame(unsigned int);
     156    int createFrame(unsigned int);
     157    int freeFrame(unsigned int);
    130158
    131159 protected:
Note: See TracChangeset for help on using the changeset viewer.