source: libcaca/trunk/cxx/caca++.h @ 4333

Last change on this file since 4333 was 4333, checked in by Sam Hocevar, 10 years ago

Large source code cleanup, getting rid of spaces, tabs, and svn keywords.

  • Property svn:keywords set to Id
File size: 5.7 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 *  This library is free software. It comes without any warranty, to
7 *  the extent permitted by applicable law. You can redistribute it
8 *  and/or modify it under the terms of the Do What The Fuck You Want
9 *  To Public License, Version 2, as published by Sam Hocevar. See
10 *  http://sam.zoy.org/wtfpl/COPYING for more details.
11 */
12
13/** \file caca++.h
14 *  \author Jean-Yves Lamoureux <jylam@lnxscene.org>
15 *  \brief The \e libcaca++ public header.
16 *
17 *  This header contains the public types and functions that applications
18 *  using \e libcaca++ may use.
19 */
20#ifndef _CACA_PP_H
21#define _CACA_PP_H
22
23#include <caca.h>
24
25#undef __class
26#if defined(_WIN32) && defined(__LIBCACA_PP__)
27#   define __class class __declspec(dllexport)
28#else
29#   define __class class
30#endif
31
32class Canvas;
33
34__class Charset
35{
36 public:
37    uint32_t utf8ToUtf32(char const *, size_t *);
38    size_t utf32ToUtf8(char *, uint32_t);
39    uint8_t utf32ToCp437(uint32_t);
40    uint32_t cp437ToUtf32(uint8_t);
41};
42
43/* Ugly, I know */
44__class Font
45{
46 public:
47    ~Font();
48    Font(void const *, unsigned int);
49    char const *const * getList(void);
50    unsigned int getWidth();
51    unsigned int getHeight();
52    void renderCanvas(Canvas *, uint8_t *, unsigned int,
53                               unsigned int, unsigned int);
54    uint32_t const *getBlocks();
55
56 private:
57    caca_font *font;
58};
59
60__class Dither
61{
62 public:
63    Dither(unsigned int, unsigned int, unsigned int, unsigned int,
64           unsigned int, unsigned int, unsigned int, unsigned int);
65    ~Dither();
66
67    void setPalette(uint32_t r[], uint32_t g[],
68                    uint32_t b[], uint32_t a[]);
69    void setBrightness(float);
70    void setGamma(float);
71    void setContrast(float);
72    void setAntialias(char const *);
73    char const *const * getAntialiasList();
74    void setColor(char const *);
75    char const *const * getColorList();
76    void setCharset(char const *);
77    char const *const * getCharsetList();
78    void setMode(char const *);
79    char const *const * getModeList();
80    void Bitmap(Canvas *, int, int, int, int, void *);
81
82 private:
83    caca_dither *dither;
84};
85
86__class Canvas
87{
88    friend class Caca;
89    friend class Dither;
90    friend class Font;
91 public:
92    Canvas();
93    Canvas(int width, int height);
94    ~Canvas();
95
96    void setSize(unsigned int w, unsigned int h);
97    unsigned int getWidth(void);
98    unsigned int getHeight(void);
99    uint32_t getAttr(int, int);
100    int setAttr(uint32_t);
101    int setColorANSI(uint8_t f, uint8_t b);
102    int setColorARGB(unsigned int f, unsigned int b);
103    void Printf(int x, int y , char const * format, ...);
104    void putChar(int x, int y, uint32_t ch);
105    uint32_t getChar(int, int);
106    void putStr(int x, int y, char *str);
107    void Clear(void);
108    void Blit(int, int, Canvas* c1, Canvas* c2);
109    void Invert();
110    void Flip();
111    void Flop();
112    void Rotate180();
113    void RotateLeft();
114    void RotateRight();
115    void drawLine(int, int, int, int, uint32_t);
116    void drawPolyline(int const x[], int const y[], int, uint32_t);
117    void drawThinLine(int, int, int, int);
118    void drawThinPolyline(int const x[], int const y[], int);
119    void drawCircle(int, int, int, uint32_t);
120    void drawEllipse(int, int, int, int, uint32_t);
121    void drawThinEllipse(int, int, int, int);
122    void fillEllipse(int, int, int, int, uint32_t);
123    void drawBox(int, int, int, int, uint32_t);
124    void drawThinBox(int, int, int, int);
125    void drawCP437Box(int, int, int, int);
126    void fillBox(int, int, int, int, uint32_t);
127    void drawTriangle(int, int, int, int, int, int, uint32_t);
128    void drawThinTriangle(int, int, int, int, int, int);
129    void fillTriangle(int, int, int, int, int, int, uint32_t);
130    void fillTriangleTextured(int coords[6], Canvas *tex, float uv[6]);
131    int setBoundaries(caca_canvas_t *, int, int, unsigned int, unsigned int);
132    unsigned int getFrameCount();
133    int setFrame(unsigned int);
134    int createFrame(unsigned int);
135    int freeFrame(unsigned int);
136
137    char const * const * getImportList(void);
138    long int importFromMemory(void const *, size_t, char const *);
139    long int importFromFile(char const *, char const *);
140    char const * const * getExportList(void);
141    void *exportToMemory(char const *, size_t *);
142
143    static int Rand(int, int);
144    static char const * getVersion();
145
146 protected:
147    caca_canvas_t *get_caca_canvas_t();
148
149 private:
150    caca_canvas_t *cv;
151};
152
153__class Event
154{
155    friend class Caca;
156 public:
157    enum caca_event_type
158        {
159            CACA_EVENT_NONE =          0x0000, /**< No event. */
160
161            CACA_EVENT_KEY_PRESS =     0x0001, /**< A key was pressed. */
162            CACA_EVENT_KEY_RELEASE =   0x0002, /**< A key was released. */
163            CACA_EVENT_MOUSE_PRESS =   0x0004, /**< A mouse button was pressed. */
164            CACA_EVENT_MOUSE_RELEASE = 0x0008, /**< A mouse button was released. */
165            CACA_EVENT_MOUSE_MOTION =  0x0010, /**< The mouse was moved. */
166            CACA_EVENT_RESIZE =        0x0020, /**< The window was resized. */
167
168            CACA_EVENT_ANY =           0xffff  /**< Bitmask for any event. */
169        } type;
170
171 protected:
172    caca_event_t e;
173};
174
175__class Caca
176{
177 public:
178    Caca();
179    Caca(Canvas *cv);
180    ~Caca();
181
182    void Attach(Canvas *cv);
183    void Detach();
184    void setDisplayTime(unsigned int);
185
186    void Display();
187    unsigned int getDisplayTime();
188    unsigned int getWidth();
189    unsigned int getHeight();
190    int setTitle(char const *);
191    int getEvent(unsigned int, Event*, int);
192    unsigned int getMouseX();
193    unsigned int getMouseY();
194    void setMouse(int);
195
196    static char const * getVersion();
197 private:
198    caca_display_t *dp;
199};
200
201#endif /* _CACA_PP_H */
Note: See TracBrowser for help on using the repository browser.