Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. /*
  2. * libcaca++ C++ bindings for libcaca
  3. * Copyright (c) 2006 Jean-Yves Lamoureux <jylam@lnxscene.org>
  4. * All Rights Reserved
  5. *
  6. * $Id$
  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. /** \file caca++.h
  15. * \version \$Id$
  16. * \author Jean-Yves Lamoureux <jylam@lnxscene.org>
  17. * \brief The \e libcaca++ public header.
  18. *
  19. * This header contains the public types and functions that applications
  20. * using \e libcaca++ may use.
  21. */
  22. #ifndef _CACA_PP_H
  23. #define _CACA_PP_H
  24. #include <caca.h>
  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. class Canvas;
  32. __class Charset
  33. {
  34. public:
  35. uint32_t utf8ToUtf32(char const *, size_t *);
  36. size_t utf32ToUtf8(char *, uint32_t);
  37. uint8_t utf32ToCp437(uint32_t);
  38. uint32_t cp437ToUtf32(uint8_t);
  39. };
  40. /* Ugly, I know */
  41. __class Font
  42. {
  43. public:
  44. ~Font();
  45. Font(void const *, unsigned int);
  46. char const *const * getList(void);
  47. unsigned int getWidth();
  48. unsigned int getHeight();
  49. void renderCanvas(Canvas *, uint8_t *, unsigned int,
  50. unsigned int, unsigned int);
  51. uint32_t const *getBlocks();
  52. private:
  53. caca_font *font;
  54. };
  55. __class Dither
  56. {
  57. public:
  58. Dither(unsigned int, unsigned int, unsigned int, unsigned int,
  59. unsigned int, unsigned int, unsigned int, unsigned int);
  60. ~Dither();
  61. void setPalette(uint32_t r[], uint32_t g[],
  62. uint32_t b[], uint32_t a[]);
  63. void setBrightness(float);
  64. void setGamma(float);
  65. void setContrast(float);
  66. void setAntialias(char const *);
  67. char const *const * getAntialiasList();
  68. void setColor(char const *);
  69. char const *const * getColorList();
  70. void setCharset(char const *);
  71. char const *const * getCharsetList();
  72. void setMode(char const *);
  73. char const *const * getModeList();
  74. void Bitmap(Canvas *, int, int, int, int, void *);
  75. private:
  76. caca_dither *dither;
  77. };
  78. __class Canvas
  79. {
  80. friend class Caca;
  81. friend class Dither;
  82. friend class Font;
  83. public:
  84. Canvas();
  85. Canvas(int width, int height);
  86. ~Canvas();
  87. void setSize(unsigned int w, unsigned int h);
  88. unsigned int getWidth(void);
  89. unsigned int getHeight(void);
  90. uint32_t getAttr(int, int);
  91. int setAttr(uint32_t);
  92. int setColorANSI(uint8_t f, uint8_t b);
  93. int setColorARGB(unsigned int f, unsigned int b);
  94. void Printf(int x, int y , char const * format, ...);
  95. void putChar(int x, int y, uint32_t ch);
  96. uint32_t getChar(int, int);
  97. void putStr(int x, int y, char *str);
  98. void Clear(void);
  99. void Blit(int, int, Canvas* c1, Canvas* c2);
  100. void Invert();
  101. void Flip();
  102. void Flop();
  103. void Rotate180();
  104. void RotateLeft();
  105. void RotateRight();
  106. void drawLine(int, int, int, int, uint32_t);
  107. void drawPolyline(int const x[], int const y[], int, uint32_t);
  108. void drawThinLine(int, int, int, int);
  109. void drawThinPolyline(int const x[], int const y[], int);
  110. void drawCircle(int, int, int, uint32_t);
  111. void drawEllipse(int, int, int, int, uint32_t);
  112. void drawThinEllipse(int, int, int, int);
  113. void fillEllipse(int, int, int, int, uint32_t);
  114. void drawBox(int, int, int, int, uint32_t);
  115. void drawThinBox(int, int, int, int);
  116. void drawCP437Box(int, int, int, int);
  117. void fillBox(int, int, int, int, uint32_t);
  118. void drawTriangle(int, int, int, int, int, int, uint32_t);
  119. void drawThinTriangle(int, int, int, int, int, int);
  120. void fillTriangle(int, int, int, int, int, int, uint32_t);
  121. int setBoundaries(caca_canvas_t *, int, int, unsigned int, unsigned int);
  122. unsigned int getFrameCount();
  123. int setFrame(unsigned int);
  124. int createFrame(unsigned int);
  125. int freeFrame(unsigned int);
  126. char const * const * getImportList(void);
  127. long int importMemory(void const *, size_t, char const *);
  128. long int importFile(char const *, char const *);
  129. char const * const * getExportList(void);
  130. void *exportMemory(char const *, size_t *);
  131. static int Rand(int, int);
  132. static char const * getVersion();
  133. protected:
  134. caca_canvas_t *get_caca_canvas_t();
  135. private:
  136. caca_canvas_t *cv;
  137. };
  138. __class Event
  139. {
  140. friend class Caca;
  141. public:
  142. enum caca_event_type
  143. {
  144. CACA_EVENT_NONE = 0x0000, /**< No event. */
  145. CACA_EVENT_KEY_PRESS = 0x0001, /**< A key was pressed. */
  146. CACA_EVENT_KEY_RELEASE = 0x0002, /**< A key was released. */
  147. CACA_EVENT_MOUSE_PRESS = 0x0004, /**< A mouse button was pressed. */
  148. CACA_EVENT_MOUSE_RELEASE = 0x0008, /**< A mouse button was released. */
  149. CACA_EVENT_MOUSE_MOTION = 0x0010, /**< The mouse was moved. */
  150. CACA_EVENT_RESIZE = 0x0020, /**< The window was resized. */
  151. CACA_EVENT_ANY = 0xffff /**< Bitmask for any event. */
  152. } type;
  153. protected:
  154. caca_event_t e;
  155. };
  156. __class Caca
  157. {
  158. public:
  159. Caca();
  160. Caca(Canvas *cv);
  161. ~Caca();
  162. void Attach(Canvas *cv);
  163. void Detach();
  164. void setDisplayTime(unsigned int);
  165. void Display();
  166. unsigned int getDisplayTime();
  167. unsigned int getWidth();
  168. unsigned int getHeight();
  169. int setTitle(char const *);
  170. int getEvent(unsigned int, Event*, int);
  171. unsigned int getMouseX();
  172. unsigned int getMouseY();
  173. void setMouse(int);
  174. static char const * getVersion();
  175. private:
  176. caca_display_t *dp;
  177. };
  178. #endif /* _CACA_PP_H */