"Fossies" - the Fresh Open Source Software Archive

Member "libcaca-0.99.beta20/cxx/caca++.h" (22 May 2018, 6002 Bytes) of package /linux/privat/libcaca-0.99.beta20.tar.bz2:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    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 
   14 /** \file caca++.h
   15  *  \author Jean-Yves Lamoureux <jylam@lnxscene.org>
   16  *  \brief The \e libcaca++ public header.
   17  *
   18  *  This header contains the public types and functions that applications
   19  *  using \e libcaca++ may use.
   20  */
   21 #ifndef _CACA_PP_H
   22 #define _CACA_PP_H
   23 
   24 #include <caca.h>
   25 
   26 #undef __class
   27 #if defined(_WIN32) && defined(__LIBCACA_PP__)
   28 #   define __class class __declspec(dllexport)
   29 #elif defined CACA_ENABLE_VISIBILITY
   30 #   define __class class __attribute__((visibility("default")))
   31 #else
   32 #   define __class class
   33 #endif
   34 
   35 class Canvas;
   36 
   37 __class Charset
   38 {
   39  public:
   40     uint32_t utf8ToUtf32(char const *, size_t *);
   41     size_t utf32ToUtf8(char *, uint32_t);
   42     uint8_t utf32ToCp437(uint32_t);
   43     uint32_t cp437ToUtf32(uint8_t);
   44 };
   45 
   46 /* Ugly, I know */
   47 __class Font
   48 {
   49  public:
   50     ~Font();
   51     Font(void const *, unsigned int);
   52     char const *const * getList(void);
   53     unsigned int getWidth();
   54     unsigned int getHeight();
   55     void renderCanvas(Canvas *, uint8_t *, unsigned int,
   56                                unsigned int, unsigned int);
   57     uint32_t const *getBlocks();
   58 
   59  private:
   60     caca_font *font;
   61 };
   62 
   63 __class Dither
   64 {
   65  public:
   66     Dither(unsigned int, unsigned int, unsigned int, unsigned int,
   67            unsigned int, unsigned int, unsigned int, unsigned int);
   68     ~Dither();
   69 
   70     void setPalette(uint32_t r[], uint32_t g[],
   71                     uint32_t b[], uint32_t a[]);
   72     void setBrightness(float);
   73     void setGamma(float);
   74     void setContrast(float);
   75     void setAntialias(char const *);
   76     char const *const * getAntialiasList();
   77     void setColor(char const *);
   78     char const *const * getColorList();
   79     void setCharset(char const *);
   80     char const *const * getCharsetList();
   81     void setMode(char const *);
   82     char const *const * getModeList();
   83     void Bitmap(Canvas *, int, int, int, int, void *);
   84 
   85  private:
   86     caca_dither *dither;
   87 };
   88 
   89 __class Canvas
   90 {
   91     friend class Caca;
   92     friend class Dither;
   93     friend class Font;
   94  public:
   95     Canvas();
   96     Canvas(int width, int height);
   97     ~Canvas();
   98 
   99     void setSize(unsigned int w, unsigned int h);
  100     unsigned int getWidth(void);
  101     unsigned int getHeight(void);
  102     uint32_t getAttr(int, int);
  103     int setAttr(uint32_t);
  104     int setColorANSI(uint8_t f, uint8_t b);
  105     int setColorARGB(unsigned int f, unsigned int b);
  106     void Printf(int x, int y , char const * format, ...);
  107     void putChar(int x, int y, uint32_t ch);
  108     uint32_t getChar(int, int);
  109     void putStr(int x, int y, char *str);
  110     void Clear(void);
  111     void Blit(int, int, Canvas* c1, Canvas* c2);
  112     void Invert();
  113     void Flip();
  114     void Flop();
  115     void Rotate180();
  116     void RotateLeft();
  117     void RotateRight();
  118     void drawLine(int, int, int, int, uint32_t);
  119     void drawPolyline(int const x[], int const y[], int, uint32_t);
  120     void drawThinLine(int, int, int, int);
  121     void drawThinPolyline(int const x[], int const y[], int);
  122     void drawCircle(int, int, int, uint32_t);
  123     void drawEllipse(int, int, int, int, uint32_t);
  124     void drawThinEllipse(int, int, int, int);
  125     void fillEllipse(int, int, int, int, uint32_t);
  126     void drawBox(int, int, int, int, uint32_t);
  127     void drawThinBox(int, int, int, int);
  128     void drawCP437Box(int, int, int, int);
  129     void fillBox(int, int, int, int, uint32_t);
  130     void drawTriangle(int, int, int, int, int, int, uint32_t);
  131     void drawThinTriangle(int, int, int, int, int, int);
  132     void fillTriangle(int, int, int, int, int, int, uint32_t);
  133     void fillTriangleTextured(int coords[6], Canvas *tex, float uv[6]);
  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 importFromMemory(void const *, size_t, char const *);
  142     long int importFromFile(char const *, char const *);
  143     char const * const * getExportList(void);
  144     void *exportToMemory(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 __class Event
  157 {
  158     friend class Caca;
  159  public:
  160     enum caca_event_type
  161         {
  162             CACA_EVENT_NONE =          0x0000, /**< No event. */
  163 
  164             CACA_EVENT_KEY_PRESS =     0x0001, /**< A key was pressed. */
  165             CACA_EVENT_KEY_RELEASE =   0x0002, /**< A key was released. */
  166             CACA_EVENT_MOUSE_PRESS =   0x0004, /**< A mouse button was pressed. */
  167             CACA_EVENT_MOUSE_RELEASE = 0x0008, /**< A mouse button was released. */
  168             CACA_EVENT_MOUSE_MOTION =  0x0010, /**< The mouse was moved. */
  169             CACA_EVENT_RESIZE =        0x0020, /**< The window was resized. */
  170 
  171             CACA_EVENT_ANY =           0xffff  /**< Bitmask for any event. */
  172         } type;
  173 
  174  protected:
  175     caca_event_t e;
  176 };
  177 
  178 __class Caca
  179 {
  180  public:
  181     Caca();
  182     Caca(Canvas *cv);
  183     ~Caca();
  184 
  185     void Attach(Canvas *cv);
  186     void Detach();
  187     void setDisplayTime(unsigned int);
  188 
  189     void Display();
  190     unsigned int getDisplayTime();
  191     unsigned int getWidth();
  192     unsigned int getHeight();
  193     int setTitle(char const *);
  194     int getEvent(unsigned int, Event*, int);
  195     unsigned int getMouseX();
  196     unsigned int getMouseY();
  197     void setMouse(int);
  198 
  199     static char const * getVersion();
  200  private:
  201     caca_display_t *dp;
  202 };
  203 
  204 #endif /* _CACA_PP_H */