Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
 
 
 
 
 
 

215 rindas
6.2 KiB

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