source: libcaca/trunk/cxx/cucul++.h @ 2821

Last change on this file since 2821 was 2821, checked in by Sam Hocevar, 11 years ago

Starting refactoring to get rid of libcucul. The initial reason for the
split is rendered moot by the plugin system: when enabled, binaries do
not link directly with libX11 or libGL. I hope this is a step towards
more consisteny and clarity.

  • Property svn:keywords set to Id
File size: 4.4 KB
Line 
1/*
2 *  libcaca++    C++ bindings for libcaca
3 *  Copyright (c) 2006 Jean-Yves Lamoureux <jylam@lnxscene.org>
4 *                All Rights Reserved
5 *
6 *  $Id: cucul++.h 2821 2008-09-27 13:12:46Z sam $
7 *
8 *  This library is free software. It comes without any warranty, to
9 *  the extent permitted by applicable law. You can redistribute it
10 *  and/or modify it under the terms of the Do What The Fuck You Want
11 *  To Public License, Version 2, as published by Sam Hocevar. See
12 *  http://sam.zoy.org/wtfpl/COPYING for more details.
13 */
14
15/** \file caca++.h
16 *  \version \$Id: cucul++.h 2821 2008-09-27 13:12:46Z sam $
17 *  \author Jean-Yves Lamoureux <jylam@lnxscene.org>
18 *  \brief The \e libcaca++ public header.
19 *
20 *  This header contains the public types and functions that applications
21 *  using \e libcaca++ may use.
22 */
23
24#ifndef _CUCUL_PP_H
25#define _CUCUL_PP_H
26
27#include <caca.h>
28
29#undef __class
30#if defined(_WIN32) && defined(__LIBCACA_PP__)
31#   define __class class __declspec(dllexport)
32#else
33#   define __class class
34#endif
35
36class Canvas;
37
38__class Charset
39{
40 public:
41    uint32_t utf8ToUtf32(char const *, size_t *);
42    size_t utf32ToUtf8(char *, uint32_t);
43    uint8_t utf32ToCp437(uint32_t);
44    uint32_t cp437ToUtf32(uint8_t);
45};
46
47/* Ugly, I know */
48__class Font
49{
50 public:
51    ~Font();
52    Font(void const *, unsigned int);
53    char const *const * getList(void);
54    unsigned int getWidth();
55    unsigned int getHeight();
56    void renderCanvas(Canvas *, uint8_t *, unsigned int,
57                               unsigned int, unsigned int);
58    uint32_t const *getBlocks();
59
60 private:
61    caca_font *font;
62};
63
64__class Dither
65{
66 public:
67    Dither(unsigned int, unsigned int, unsigned int, unsigned int,
68           unsigned int, unsigned int, unsigned int, unsigned int);
69    ~Dither();
70
71    void setPalette(uint32_t r[], uint32_t g[],
72                    uint32_t b[], uint32_t a[]);
73    void setBrightness(float);
74    void setGamma(float);
75    void setContrast(float);
76    void setAntialias(char const *);
77    char const *const * getAntialiasList();
78    void setColor(char const *);
79    char const *const * getColorList();
80    void setCharset(char const *);
81    char const *const * getCharsetList();
82    void setMode(char const *);
83    char const *const * getModeList();
84    void Bitmap(Canvas *, int, int, int, int, void *);
85
86 private:
87    caca_dither *dither;
88};
89
90__class Canvas
91{
92    friend class Caca;
93    friend class Dither;
94    friend class Font;
95 public:
96    Canvas();
97    Canvas(int width, int height);
98    ~Canvas();
99
100    void setSize(unsigned int w, unsigned int h);
101    unsigned int getWidth(void);
102    unsigned int getHeight(void);
103    uint32_t getAttr(int, int);
104    int setAttr(uint32_t);
105    int setColorANSI(uint8_t f, uint8_t b);
106    int setColorARGB(unsigned int f, unsigned int b);
107    void Printf(int x, int y , char const * format, ...);
108    void putChar(int x, int y, uint32_t ch);
109    uint32_t getChar(int, int);
110    void putStr(int x, int y, char *str);
111    void Clear(void);
112    void Blit(int, int, Canvas* c1, Canvas* c2);
113    void Invert();
114    void Flip();
115    void Flop();
116    void Rotate180();
117    void RotateLeft();
118    void RotateRight();
119    void drawLine(int, int, int, int, uint32_t);
120    void drawPolyline(int const x[], int const y[], int, uint32_t);
121    void drawThinLine(int, int, int, int);
122    void drawThinPolyline(int const x[], int const y[], int);
123    void drawCircle(int, int, int, uint32_t);
124    void drawEllipse(int, int, int, int, uint32_t);
125    void drawThinEllipse(int, int, int, int);
126    void fillEllipse(int, int, int, int, uint32_t);
127    void drawBox(int, int, int, int, uint32_t);
128    void drawThinBox(int, int, int, int);
129    void drawCP437Box(int, int, int, int);
130    void fillBox(int, int, int, int, uint32_t);
131    void drawTriangle(int, int, int, int, int, int, uint32_t);
132    void drawThinTriangle(int, int, int, int, int, int);
133    void fillTriangle(int, int, int, int, int, int, uint32_t);
134    int setBoundaries(caca_canvas_t *, int, int, unsigned int, unsigned int);
135    unsigned int getFrameCount();
136    int setFrame(unsigned int);
137    int createFrame(unsigned int);
138    int freeFrame(unsigned int);
139
140    char const * const * getImportList(void);
141    long int importMemory(void const *, size_t, char const *);
142    long int importFile(char const *, char const *);
143    char const * const * getExportList(void);
144    void *exportMemory(char const *, size_t *);
145
146    static int Rand(int, int);
147    static char const * getVersion();
148
149 protected:
150    caca_canvas_t *get_caca_canvas_t();
151
152 private:
153    caca_canvas_t *cv;
154};
155
156#endif /* _CUCUL_PP_H */
Note: See TracBrowser for help on using the repository browser.