From 7b52cc13af4e85f1ca2deb6b6c77de9c95ea0dcf Mon Sep 17 00:00:00 2001 From: scuri Date: Fri, 17 Oct 2008 06:10:33 +0000 Subject: First commit - moving from LuaForge to SourceForge --- include/cd.h | 494 +++++++++++++++++++++++++++++++++++++++++++++++ include/cd_canvas.hpp | 358 ++++++++++++++++++++++++++++++++++ include/cd_old.h | 158 +++++++++++++++ include/cd_private.h | 362 ++++++++++++++++++++++++++++++++++ include/cdcgm.h | 34 ++++ include/cdclipbd.h | 22 +++ include/cddbuf.h | 23 +++ include/cddebug.h | 24 +++ include/cddgn.h | 23 +++ include/cddxf.h | 22 +++ include/cdemf.h | 22 +++ include/cdgdiplus.h | 29 +++ include/cdimage.h | 23 +++ include/cdirgb.h | 30 +++ include/cdiup.h | 22 +++ include/cdlua.h | 39 ++++ include/cdlua3_private.h | 120 ++++++++++++ include/cdlua5_private.h | 141 ++++++++++++++ include/cdluaim.h | 24 +++ include/cdluaiup.h | 27 +++ include/cdluapdf.h | 27 +++ include/cdmf.h | 24 +++ include/cdmf_private.h | 32 +++ include/cdnative.h | 26 +++ include/cdpdf.h | 38 ++++ include/cdpicture.h | 22 +++ include/cdprint.h | 23 +++ include/cdps.h | 37 ++++ include/cdwmf.h | 22 +++ include/wd.h | 78 ++++++++ include/wd_old.h | 85 ++++++++ 31 files changed, 2411 insertions(+) create mode 100644 include/cd.h create mode 100644 include/cd_canvas.hpp create mode 100644 include/cd_old.h create mode 100644 include/cd_private.h create mode 100644 include/cdcgm.h create mode 100644 include/cdclipbd.h create mode 100644 include/cddbuf.h create mode 100644 include/cddebug.h create mode 100644 include/cddgn.h create mode 100644 include/cddxf.h create mode 100644 include/cdemf.h create mode 100644 include/cdgdiplus.h create mode 100644 include/cdimage.h create mode 100644 include/cdirgb.h create mode 100644 include/cdiup.h create mode 100644 include/cdlua.h create mode 100644 include/cdlua3_private.h create mode 100644 include/cdlua5_private.h create mode 100644 include/cdluaim.h create mode 100644 include/cdluaiup.h create mode 100644 include/cdluapdf.h create mode 100644 include/cdmf.h create mode 100644 include/cdmf_private.h create mode 100644 include/cdnative.h create mode 100644 include/cdpdf.h create mode 100644 include/cdpicture.h create mode 100644 include/cdprint.h create mode 100644 include/cdps.h create mode 100644 include/cdwmf.h create mode 100644 include/wd.h create mode 100644 include/wd_old.h (limited to 'include') diff --git a/include/cd.h b/include/cd.h new file mode 100644 index 0000000..7a72d74 --- /dev/null +++ b/include/cd.h @@ -0,0 +1,494 @@ +/** \file + * \brief User API + * CD - Canvas Draw + * Tecgraf: Computer Graphics Technology Group, PUC-Rio, Brazil + * http://www.tecgraf.puc-rio.br/cd + * mailto:cd@tecgraf.puc-rio.br + * + * See Copyright Notice at the end of this file + */ + +#ifndef __CD_H +#define __CD_H + +#ifdef __cplusplus +extern "C" { +#endif + + +#define CD_NAME "CD - Canvas Draw" +#define CD_DESCRIPTION "A 2D Graphics Library" +#define CD_COPYRIGHT "Copyright (C) 1994-2008 Tecgraf, PUC-Rio." +#define CD_VERSION "5.1.0" +#define CD_VERSION_DATE "2008/10/14" +#define CD_VERSION_NUMBER 501000 + +typedef struct _cdContext cdContext; +typedef struct _cdCanvas cdCanvas; +typedef struct _cdCanvas cdState; +typedef struct _cdImage cdImage; + +/* client images using bitmap structure */ +typedef struct _cdBitmap { + int w; + int h; + int type; + void *data; +} cdBitmap; + + +/* library */ +char* cdVersion(void); +char* cdVersionDate(void); +int cdVersionNumber(void); + +/* canvas init */ +cdCanvas* cdCreateCanvas(cdContext *context, void *data); +cdCanvas* cdCreateCanvasf(cdContext *context, const char* format, ...); +void cdKillCanvas(cdCanvas* canvas); + +cdContext* cdCanvasGetContext(cdCanvas* canvas); +int cdCanvasActivate(cdCanvas* canvas); +void cdCanvasDeactivate(cdCanvas* canvas); +int cdUseContextPlus(int use); +void cdInitContextPlus(void); /* need an external library */ + +/* context */ +typedef int (*cdCallback)(cdCanvas* canvas, ...); +int cdContextRegisterCallback(cdContext *context, int cb, cdCallback func); +unsigned long cdContextCaps(cdContext *context); + +/* control */ +int cdCanvasSimulate(cdCanvas* canvas, int mode); +void cdCanvasFlush(cdCanvas* canvas); +void cdCanvasClear(cdCanvas* canvas); +cdState* cdCanvasSaveState(cdCanvas* canvas); +void cdCanvasRestoreState(cdCanvas* canvas, cdState* state); +void cdReleaseState(cdState* state); +void cdCanvasSetAttribute(cdCanvas* canvas, const char* name, char* data); +void cdCanvasSetfAttribute(cdCanvas* canvas, const char* name, const char* format, ...); +char* cdCanvasGetAttribute(cdCanvas* canvas, const char* name); + +/* interpretation */ +int cdCanvasPlay(cdCanvas* canvas, cdContext *context, int xmin, int xmax, int ymin, int ymax, void *data); + +/* coordinate transformation */ +void cdCanvasGetSize(cdCanvas* canvas, int *width, int *height, double *width_mm, double *height_mm); +int cdCanvasUpdateYAxis(cdCanvas* canvas, int* y); +double cdfCanvasUpdateYAxis(cdCanvas* canvas, double* y); +int cdCanvasInvertYAxis(cdCanvas* canvas, int y); +double cdfCanvasInvertYAxis(cdCanvas* canvas, double y); +void cdCanvasMM2Pixel(cdCanvas* canvas, double mm_dx, double mm_dy, int *dx, int *dy); +void cdCanvasPixel2MM(cdCanvas* canvas, int dx, int dy, double *mm_dx, double *mm_dy); +void cdfCanvasMM2Pixel(cdCanvas* canvas, double mm_dx, double mm_dy, double *dx, double *dy); +void cdfCanvasPixel2MM(cdCanvas* canvas, double dx, double dy, double *mm_dx, double *mm_dy); +void cdCanvasOrigin(cdCanvas* canvas, int x, int y); +void cdfCanvasOrigin(cdCanvas* canvas, double x, double y); +void cdCanvasGetOrigin(cdCanvas* canvas, int *x, int *y); +void cdfCanvasGetOrigin(cdCanvas* canvas, double *x, double *y); +void cdCanvasTransform(cdCanvas* canvas, const double* matrix); +double* cdCanvasGetTransform(cdCanvas* canvas); +void cdCanvasTransformMultiply(cdCanvas* canvas, const double* matrix); +void cdCanvasTransformRotate(cdCanvas* canvas, double angle); +void cdCanvasTransformScale(cdCanvas* canvas, double sx, double sy); +void cdCanvasTransformTranslate(cdCanvas* canvas, double dx, double dy); +void cdCanvasTransformPoint(cdCanvas* canvas, int x, int y, int *tx, int *ty); +void cdfCanvasTransformPoint(cdCanvas* canvas, double x, double y, double *tx, double *ty); + +/* clipping */ +int cdCanvasClip(cdCanvas* canvas, int mode); +void cdCanvasClipArea(cdCanvas* canvas, int xmin, int xmax, int ymin, int ymax); +int cdCanvasGetClipArea(cdCanvas* canvas, int *xmin, int *xmax, int *ymin, int *ymax); +void cdfCanvasClipArea(cdCanvas* canvas, double xmin, double xmax, double ymin, double ymax); +int cdfCanvasGetClipArea(cdCanvas* canvas, double *xmin, double *xmax, double *ymin, double *ymax); + +/* clipping region */ +int cdCanvasIsPointInRegion(cdCanvas* canvas, int x, int y); +void cdCanvasOffsetRegion(cdCanvas* canvas, int x, int y); +void cdCanvasGetRegionBox(cdCanvas* canvas, int *xmin, int *xmax, int *ymin, int *ymax); +int cdCanvasRegionCombineMode(cdCanvas* canvas, int mode); + +/* primitives */ +void cdCanvasPixel(cdCanvas* canvas, int x, int y, long color); +void cdCanvasMark(cdCanvas* canvas, int x, int y); + +void cdCanvasLine(cdCanvas* canvas, int x1, int y1, int x2, int y2); +void cdCanvasBegin(cdCanvas* canvas, int mode); +void cdCanvasVertex(cdCanvas* canvas, int x, int y); +void cdCanvasEnd(cdCanvas* canvas); +void cdCanvasRect(cdCanvas* canvas, int xmin, int xmax, int ymin, int ymax); +void cdCanvasBox(cdCanvas* canvas, int xmin, int xmax, int ymin, int ymax); +void cdCanvasArc(cdCanvas* canvas, int xc, int yc, int w, int h, double angle1, double angle2); +void cdCanvasSector(cdCanvas* canvas, int xc, int yc, int w, int h, double angle1, double angle2); +void cdCanvasChord(cdCanvas* canvas, int xc, int yc, int w, int h, double angle1, double angle2); +void cdCanvasText(cdCanvas* canvas, int x, int y, const char* s); + +void cdfCanvasLine(cdCanvas* canvas, double x1, double y1, double x2, double y2); +void cdfCanvasVertex(cdCanvas* canvas, double x, double y); +void cdfCanvasRect(cdCanvas* canvas, double xmin, double xmax, double ymin, double ymax); +void cdfCanvasBox(cdCanvas* canvas, double xmin, double xmax, double ymin, double ymax); +void cdfCanvasArc(cdCanvas* canvas, double xc, double yc, double w, double h, double angle1, double angle2); +void cdfCanvasSector(cdCanvas* canvas, double xc, double yc, double w, double h, double angle1, double angle2); +void cdfCanvasChord(cdCanvas* canvas, double xc, double yc, double w, double h, double angle1, double angle2); +void cdfCanvasText(cdCanvas* canvas, double x, double y, const char* s); + +/* attributes */ +void cdCanvasSetBackground(cdCanvas* canvas, long color); +void cdCanvasSetForeground(cdCanvas* canvas, long color); +long cdCanvasBackground(cdCanvas* canvas, long color); +long cdCanvasForeground(cdCanvas* canvas, long color); +int cdCanvasBackOpacity(cdCanvas* canvas, int opacity); +int cdCanvasWriteMode(cdCanvas* canvas, int mode); +int cdCanvasLineStyle(cdCanvas* canvas, int style); +void cdCanvasLineStyleDashes(cdCanvas* canvas, const int* dashes, int count); +int cdCanvasLineWidth(cdCanvas* canvas, int width); +int cdCanvasLineJoin(cdCanvas* canvas, int join); +int cdCanvasLineCap(cdCanvas* canvas, int cap); +int cdCanvasInteriorStyle(cdCanvas* canvas, int style); +int cdCanvasHatch(cdCanvas* canvas, int style); +void cdCanvasStipple(cdCanvas* canvas, int w, int h, const unsigned char* stipple); +unsigned char* cdCanvasGetStipple(cdCanvas* canvas, int *n, int *m); +void cdCanvasPattern(cdCanvas* canvas, int w, int h, long const int *pattern); +long* cdCanvasGetPattern(cdCanvas* canvas, int* n, int* m); +int cdCanvasFillMode(cdCanvas* canvas, int mode); +int cdCanvasFont(cdCanvas* canvas, const char* type_face, int style, int size); +void cdCanvasGetFont(cdCanvas* canvas, char *type_face, int *style, int *size); +char* cdCanvasNativeFont(cdCanvas* canvas, const char* font); +int cdCanvasTextAlignment(cdCanvas* canvas, int alignment); +double cdCanvasTextOrientation(cdCanvas* canvas, double angle); +int cdCanvasMarkType(cdCanvas* canvas, int type); +int cdCanvasMarkSize(cdCanvas* canvas, int size); + +/* vector text */ +void cdCanvasVectorText(cdCanvas* canvas, int x, int y, const char* s); +void cdCanvasMultiLineVectorText(cdCanvas* canvas, int x, int y, const char* s); + +/* vector text attributes */ +char *cdCanvasVectorFont(cdCanvas* canvas, const char *filename); +void cdCanvasVectorTextDirection(cdCanvas* canvas, int x1, int y1, int x2, int y2); +double* cdCanvasVectorTextTransform(cdCanvas* canvas, const double* matrix); +void cdCanvasVectorTextSize(cdCanvas* canvas, int size_x, int size_y, const char* s); +int cdCanvasVectorCharSize(cdCanvas* canvas, int size); + +/* vector text properties */ +void cdCanvasGetVectorTextSize(cdCanvas* canvas, const char* s, int *x, int *y); +void cdCanvasGetVectorTextBounds(cdCanvas* canvas, const char* s, int x, int y, int *rect); + +/* properties */ +void cdCanvasGetFontDim(cdCanvas* canvas, int *max_width, int *height, int *ascent, int *descent); +void cdCanvasGetTextSize(cdCanvas* canvas, const char* s, int *width, int *height); +void cdCanvasGetTextBox(cdCanvas* canvas, int x, int y, const char* s, int *xmin, int *xmax, int *ymin, int *ymax); +void cdCanvasGetTextBounds(cdCanvas* canvas, int x, int y, const char* s, int *rect); +int cdCanvasGetColorPlanes(cdCanvas* canvas); + +/* color */ +void cdCanvasPalette(cdCanvas* canvas, int n, const long *palette, int mode); + +/* client images */ +void cdCanvasGetImageRGB(cdCanvas* canvas, unsigned char* r, unsigned char* g, unsigned char* b, int x, int y, int w, int h); +void cdCanvasPutImageRectRGB(cdCanvas* canvas, int iw, int ih, const unsigned char* r, const unsigned char* g, const unsigned char* b, int x, int y, int w, int h, int xmin, int xmax, int ymin, int ymax); +void cdCanvasPutImageRectRGBA(cdCanvas* canvas, int iw, int ih, const unsigned char* r, const unsigned char* g, const unsigned char* b, const unsigned char* a, int x, int y, int w, int h, int xmin, int xmax, int ymin, int ymax); +void cdCanvasPutImageRectMap(cdCanvas* canvas, int iw, int ih, const unsigned char* index, const long* colors, int x, int y, int w, int h, int xmin, int xmax, int ymin, int ymax); + +/* server images */ +cdImage* cdCanvasCreateImage(cdCanvas* canvas, int w, int h); +void cdKillImage(cdImage* image); +void cdCanvasGetImage(cdCanvas* canvas, cdImage* image, int x, int y); +void cdCanvasPutImageRect(cdCanvas* canvas, cdImage* image, int x, int y, int xmin, int xmax, int ymin, int ymax); +void cdCanvasScrollArea(cdCanvas* canvas, int xmin, int xmax, int ymin, int ymax, int dx, int dy); + +/* bitmap */ +cdBitmap* cdCreateBitmap(int w, int h, int type); +cdBitmap* cdInitBitmap(int w, int h, int type, ...); +void cdKillBitmap(cdBitmap* bitmap); +unsigned char* cdBitmapGetData(cdBitmap* bitmap, int dataptr); +void cdBitmapSetRect(cdBitmap* bitmap, int xmin, int xmax, int ymin, int ymax); +void cdCanvasPutBitmap(cdCanvas* canvas, cdBitmap* bitmap, int x, int y, int w, int h); +void cdCanvasGetBitmap(cdCanvas* canvas, cdBitmap* bitmap, int x, int y); +void cdBitmapRGB2Map(cdBitmap* bitmap_rgb, cdBitmap* bitmap_map); + +/* color */ +long cdEncodeColor(unsigned char red, unsigned char green, unsigned char blue); +void cdDecodeColor(long color, unsigned char* red, unsigned char* green, unsigned char* blue); +unsigned char cdDecodeAlpha(long color); +long cdEncodeAlpha(long color, unsigned char alpha); + +#define cdAlpha(_) (unsigned char)(~(((_) >> 24) & 0xFF)) +#define cdReserved(_) (unsigned char)(((_) >> 24) & 0xFF) +#define cdRed(_) (unsigned char)(((_) >> 16) & 0xFF) +#define cdGreen(_) (unsigned char)(((_) >> 8) & 0xFF) +#define cdBlue(_) (unsigned char)(((_) >> 0) & 0xFF) + +/* client image color convertion */ +void cdRGB2Map(int width, int height, const unsigned char* red, const unsigned char* green, const unsigned char* blue, unsigned char* index, int pal_size, long *color); + + +/* CD Values */ + +#define CD_QUERY -1 /* query value */ + +enum { /* bitmap type */ + CD_RGB, /* these definitions are compatible with the IM library */ + CD_MAP, + CD_RGBA = 0x100 +}; + +enum { /* bitmap data */ + CD_IRED, + CD_IGREEN, + CD_IBLUE, + CD_IALPHA, + CD_INDEX, + CD_COLORS +}; + +enum { /* status report */ + CD_ERROR = -1, + CD_OK = 0 +}; + +enum { /* clip mode */ + CD_CLIPOFF, + CD_CLIPAREA, + CD_CLIPPOLYGON, + CD_CLIPREGION +}; + +enum { /* region combine mode */ + CD_UNION, + CD_INTERSECT, + CD_DIFFERENCE, + CD_NOTINTERSECT +}; + +enum { /* polygon mode (begin...end) */ + CD_FILL, + CD_OPEN_LINES, + CD_CLOSED_LINES, + CD_CLIP, + CD_BEZIER, + CD_REGION +}; + +#define CD_POLYCUSTOM 10 + +enum { /* fill mode */ + CD_EVENODD, + CD_WINDING +}; + +enum { /* line join */ + CD_MITER, + CD_BEVEL, + CD_ROUND +}; + +enum { /* line cap */ + CD_CAPFLAT, + CD_CAPSQUARE, + CD_CAPROUND +}; + +enum { /* background opacity mode */ + CD_OPAQUE, + CD_TRANSPARENT +}; + +enum { /* write mode */ + CD_REPLACE, + CD_XOR, + CD_NOT_XOR +}; + +enum { /* color allocation mode (palette) */ + CD_POLITE, + CD_FORCE +}; + +enum { /* line style */ + CD_CONTINUOUS, + CD_DASHED, + CD_DOTTED, + CD_DASH_DOT, + CD_DASH_DOT_DOT, + CD_CUSTOM +}; + +enum { /* marker type */ + CD_PLUS, + CD_STAR, + CD_CIRCLE, + CD_X, + CD_BOX, + CD_DIAMOND, + CD_HOLLOW_CIRCLE, + CD_HOLLOW_BOX, + CD_HOLLOW_DIAMOND +}; + +enum { /* hatch type */ + CD_HORIZONTAL, + CD_VERTICAL, + CD_FDIAGONAL, + CD_BDIAGONAL, + CD_CROSS, + CD_DIAGCROSS +}; + +enum { /* interior style */ + CD_SOLID, + CD_HATCH, + CD_STIPPLE, + CD_PATTERN, + CD_HOLLOW +}; + +enum { /* text alignment */ + CD_NORTH, + CD_SOUTH, + CD_EAST, + CD_WEST, + CD_NORTH_EAST, + CD_NORTH_WEST, + CD_SOUTH_EAST, + CD_SOUTH_WEST, + CD_CENTER, + CD_BASE_LEFT, + CD_BASE_CENTER, + CD_BASE_RIGHT +}; + +enum { /* style */ + CD_PLAIN = 0, + CD_BOLD = 1, + CD_ITALIC = 2, + CD_UNDERLINE = 4, + CD_STRIKEOUT = 8 +}; + +#define CD_BOLD_ITALIC (CD_BOLD|CD_ITALIC) /* compatibility name */ + +enum { /* some font sizes */ + CD_SMALL = 8, + CD_STANDARD = 12, + CD_LARGE = 18 +}; + +/* Canvas Capabilities */ +#define CD_CAP_NONE 0x00000000 +#define CD_CAP_FLUSH 0x00000001 +#define CD_CAP_CLEAR 0x00000002 +#define CD_CAP_PLAY 0x00000004 +#define CD_CAP_YAXIS 0x00000008 +#define CD_CAP_CLIPAREA 0x00000010 +#define CD_CAP_CLIPPOLY 0x00000020 +#define CD_CAP_REGION 0x00000040 +#define CD_CAP_RECT 0x00000080 +#define CD_CAP_CHORD 0x00000100 +#define CD_CAP_IMAGERGB 0x00000200 +#define CD_CAP_IMAGERGBA 0x00000400 +#define CD_CAP_IMAGEMAP 0x00000800 +#define CD_CAP_GETIMAGERGB 0x00001000 +#define CD_CAP_IMAGESRV 0x00002000 +#define CD_CAP_BACKGROUND 0x00004000 +#define CD_CAP_BACKOPACITY 0x00008000 +#define CD_CAP_WRITEMODE 0x00010000 +#define CD_CAP_LINESTYLE 0x00020000 +#define CD_CAP_LINEWITH 0x00040000 +#define CD_CAP_FPRIMTIVES 0x00080000 +#define CD_CAP_HATCH 0x00100000 +#define CD_CAP_STIPPLE 0x00200000 +#define CD_CAP_PATTERN 0x00400000 +#define CD_CAP_FONT 0x00800000 +#define CD_CAP_FONTDIM 0x01000000 +#define CD_CAP_TEXTSIZE 0x02000000 +#define CD_CAP_TEXTORIENTATION 0x04000000 +#define CD_CAP_PALETTE 0x08000000 +#define CD_CAP_LINECAP 0x10000000 +#define CD_CAP_LINEJOIN 0x20000000 +#define CD_CAP_ALL 0xFFFFFFFF + +/* cdPlay definitions */ +#define CD_SIZECB 0 /* size callback */ +typedef int(*cdSizeCB)(cdCanvas *canvas, int w, int h, double w_mm, double h_mm); +#define CD_ABORT 1 +#define CD_CONTINUE 0 + +/* simulation flags */ +#define CD_SIM_NONE 0x0000 +#define CD_SIM_LINE 0x0001 +#define CD_SIM_RECT 0x0002 +#define CD_SIM_BOX 0x0004 +#define CD_SIM_ARC 0x0008 +#define CD_SIM_SECTOR 0x0010 +#define CD_SIM_CHORD 0x0020 +#define CD_SIM_POLYLINE 0x0040 +#define CD_SIM_POLYGON 0x0080 +#define CD_SIM_TEXT 0x0100 +#define CD_SIM_ALL 0xFFFF + +#define CD_SIM_LINES (CD_SIM_LINE | CD_SIM_RECT | CD_SIM_ARC | CD_SIM_POLYLINE) +#define CD_SIM_FILLS (CD_SIM_BOX | CD_SIM_SECTOR | CD_SIM_CHORD | CD_SIM_POLYGON) + +/* some predefined colors for convenience */ +#define CD_RED 0xFF0000L /* 255, 0, 0 */ +#define CD_DARK_RED 0x800000L /* 128, 0, 0 */ +#define CD_GREEN 0x00FF00L /* 0,255, 0 */ +#define CD_DARK_GREEN 0x008000L /* 0,128, 0 */ +#define CD_BLUE 0x0000FFL /* 0, 0,255 */ +#define CD_DARK_BLUE 0x000080L /* 0, 0,128 */ + +#define CD_YELLOW 0xFFFF00L /* 255,255, 0 */ +#define CD_DARK_YELLOW 0x808000L /* 128,128, 0 */ +#define CD_MAGENTA 0xFF00FFL /* 255, 0,255 */ +#define CD_DARK_MAGENTA 0x800080L /* 128, 0,128 */ +#define CD_CYAN 0x00FFFFL /* 0,255,255 */ +#define CD_DARK_CYAN 0x008080L /* 0,128,128 */ + +#define CD_WHITE 0xFFFFFFL /* 255,255,255 */ +#define CD_BLACK 0x000000L /* 0, 0, 0 */ + +#define CD_DARK_GRAY 0x808080L /* 128,128,128 */ +#define CD_GRAY 0xC0C0C0L /* 192,192,192 */ + +/* some usefull conversion factors */ +#define CD_MM2PT 2.834645669 /* milimeters to points (pt = CD_MM2PT * mm) */ +#define CD_RAD2DEG 57.295779513 /* radians to degrees (deg = CD_RAD2DEG * rad) */ +#define CD_DEG2RAD 0.01745329252 /* degrees to radians (rad = CD_DEG2RAD * deg) */ + + +#ifdef __cplusplus +} +#endif + + +#ifndef CD_NO_OLD_INTERFACE +#include "cd_old.h" +#endif + + +/****************************************************************************** +Copyright (C) 1994-2008 Tecgraf, PUC-Rio. + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +******************************************************************************/ + +#endif /* ifndef CD_H */ + diff --git a/include/cd_canvas.hpp b/include/cd_canvas.hpp new file mode 100644 index 0000000..b31a683 --- /dev/null +++ b/include/cd_canvas.hpp @@ -0,0 +1,358 @@ +/** \file + * \brief Canvas Class + * + * See Copyright Notice in cd.h + */ + +#ifndef __CD_CANVAS_HPP +#define __CD_CANVAS_HPP + +#include "cd.h" +#include "wd.h" + +class cdCanvasC +{ + cdCanvas* canvas; + + cdCanvasC() {}; + +public: + +/* canvas init */ + cdCanvasC(cdCanvas* _canvas) + { this->canvas = _canvas; } + + ~cdCanvasC() + { cdKillCanvas(this->canvas); } + +cdContext* GetContext() + { return cdCanvasGetContext(canvas); } +int Activate() + { return cdCanvasActivate(canvas); } +void Deactivate() + { cdCanvasDeactivate(canvas); } + +/* control */ +int Simulate(int mode) + { return cdCanvasSimulate(canvas, mode); } +void Flush() + { cdCanvasFlush(canvas); } +void Clear() + { cdCanvasClear(canvas); } +cdState* SaveState() + { return cdCanvasSaveState(canvas); } +void RestoreState(cdState* state) + { cdCanvasRestoreState(canvas, state); } +void SetAttribute(const char* name, char* data) + { cdCanvasSetAttribute(canvas, name, data); } +char* GetAttribute(const char* name) + { return cdCanvasGetAttribute(canvas, name); } + +/* interpretation */ +int Play(cdContext *context, int xmin, int xmax, int ymin, int ymax, void *data) + { return cdCanvasPlay(canvas, context, xmin, xmax, ymin, ymax, data); } + +/* coordinate transformation */ +void GetSize(int *width, int *height, double *width_mm, double *height_mm) + { cdCanvasGetSize(canvas, width, height, width_mm, height_mm); } +int UpdateYAxis(int* y) + { return cdCanvasUpdateYAxis(canvas, y); } +void MM2Pixel(double mm_dx, double mm_dy, int *dx, int *dy) + { cdCanvasMM2Pixel(canvas, mm_dx, mm_dy, dx, dy); } +void Pixel2MM(int dx, int dy, double *mm_dx, double *mm_dy) + { cdCanvasPixel2MM(canvas, dx, dy, mm_dx, mm_dy); } +void MM2Pixel(double mm_dx, double mm_dy, double *dx, double *dy) + { cdfCanvasMM2Pixel(canvas, mm_dx, mm_dy, dx, dy); } +void Pixel2MM(double dx, double dy, double *mm_dx, double *mm_dy) + { cdfCanvasPixel2MM(canvas, dx, dy, mm_dx, mm_dy); } +void Origin(int x, int y) + { cdCanvasOrigin(canvas, x, y); } +void Origin(double x, double y) + { cdfCanvasOrigin(canvas, x, y); } +void GetOrigin(int *x, int *y) + { cdCanvasGetOrigin(canvas, x, y); } +void GetOrigin(double *x, double *y) + { cdfCanvasGetOrigin(canvas, x, y); } + +/* clipping */ +int Clip(int mode) + { return cdCanvasClip(canvas, mode); } +void ClipArea(int xmin, int xmax, int ymin, int ymax) + { cdCanvasClipArea(canvas, xmin, xmax, ymin, ymax); } +int GetClipArea(int *xmin, int *xmax, int *ymin, int *ymax) + { return cdCanvasGetClipArea(canvas, xmin, xmax, ymin, ymax); } +void ClipArea(double xmin, double xmax, double ymin, double ymax) + { cdfCanvasClipArea(canvas, xmin, xmax, ymin, ymax); } +int GetClipArea(double *xmin, double *xmax, double *ymin, double *ymax) + { return cdfCanvasGetClipArea(canvas, xmin, xmax, ymin, ymax); } + +/* clipping region */ +int IsPointInRegion(int x, int y) + { return cdCanvasIsPointInRegion(canvas, x, y); } +void OffsetRegion(int x, int y) + { cdCanvasOffsetRegion(canvas, x, y); } +void GetRegionBox(int *xmin, int *xmax, int *ymin, int *ymax) + { cdCanvasGetRegionBox(canvas, xmin, xmax, ymin, ymax); } +int RegionCombineMode(int mode) + { return cdCanvasRegionCombineMode(canvas, mode); } + +/* primitives */ +void Pixel(int x, int y, long color) + { cdCanvasPixel(canvas, x, y, color); } +void Mark(int x, int y) + { cdCanvasMark(canvas, x, y); } + +void Line(int x1, int y1, int x2, int y2) + { cdCanvasLine(canvas, x1, y1, x2, y2); } +void Begin(int mode) + { cdCanvasBegin(canvas, mode); } +void Vertex(int x, int y) + { cdCanvasVertex(canvas, x, y); } +void End() + { cdCanvasEnd(canvas); } +void Rect(int xmin, int xmax, int ymin, int ymax) + { cdCanvasRect(canvas, xmin, xmax, ymin, ymax); } +void Box(int xmin, int xmax, int ymin, int ymax) + { cdCanvasBox(canvas, xmin, xmax, ymin, ymax); } +void Arc(int xc, int yc, int w, int h, double angle1, double angle2) + { cdCanvasArc(canvas, xc, yc, w, h, angle1, angle2); } +void Sector(int xc, int yc, int w, int h, double angle1, double angle2) + { cdCanvasSector(canvas, xc, yc, w, h, angle1, angle2); } +void Chord(int xc, int yc, int w, int h, double angle1, double angle2) + { cdCanvasChord(canvas, xc, yc, w, h, angle1, angle2); } +void Text(int x, int y, const char* s) + { cdCanvasText(canvas, x, y, s); } + +void Line(double x1, double y1, double x2, double y2) + { cdfCanvasLine(canvas, x1, y1, x2, y2); } +void Vertex(double x, double y) + { cdfCanvasVertex(canvas, x, y); } +void Rect(double xmin, double xmax, double ymin, double ymax) + { cdfCanvasRect(canvas, xmin, xmax, ymin, ymax); } +void Box(double xmin, double xmax, double ymin, double ymax) + { cdfCanvasBox(canvas, xmin, xmax, ymin, ymax); } +void Arc(double xc, double yc, double w, double h, double angle1, double angle2) + { cdfCanvasArc(canvas, xc, yc, w, h, angle1, angle2); } +void Sector(double xc, double yc, double w, double h, double angle1, double angle2) + { cdfCanvasSector(canvas, xc, yc, w, h, angle1, angle2); } +void Chord(double xc, double yc, double w, double h, double angle1, double angle2) + { cdfCanvasChord(canvas, xc, yc, w, h, angle1, angle2); } +void Text(double x, double y, const char* s) + { cdfCanvasText(canvas, x, y, s); } + +/* attributes */ +long Background(long color) + { return cdCanvasBackground(canvas, color); } +long Foreground(long color) + { return cdCanvasForeground(canvas, color); } +int BackOpacity(int opacity) + { return cdCanvasBackOpacity(canvas, opacity); } +int WriteMode(int mode) + { return cdCanvasWriteMode(canvas, mode); } +int LineStyle(int style) + { return cdCanvasLineStyle(canvas, style); } +void LineStyleDashes(const int* dashes, int count) + { cdCanvasLineStyleDashes(canvas, dashes, count); } +int LineWidth(int width) + { return cdCanvasLineWidth(canvas, width); } +int LineJoin(int join) + { return cdCanvasLineJoin(canvas, join); } +int LineCap(int cap) + { return cdCanvasLineCap(canvas, cap); } +int InteriorStyle(int style) + { return cdCanvasInteriorStyle(canvas, style); } +int Hatch(int style) + { return cdCanvasHatch(canvas, style); } +void Stipple(int w, int h, const unsigned char* stipple) + { cdCanvasStipple(canvas, w, h, stipple); } +unsigned char* GetStipple(int *n, int *m) + { return cdCanvasGetStipple(canvas, n, m); } +void Pattern(int w, int h, long const int *pattern) + { cdCanvasPattern(canvas, w, h, pattern); } +long* GetPattern(int* n, int* m) + { return cdCanvasGetPattern(canvas, n, m); } +int FillMode(int mode) + { return cdCanvasFillMode(canvas, mode); } +int Font(const char* type_face, int style, int size) + { return cdCanvasFont(canvas, type_face, style, size); } +void GetFont(char *type_face, int *style, int *size) + { cdCanvasGetFont(canvas, type_face, style, size); } +char* NativeFont(const char* font) + { return cdCanvasNativeFont(canvas, font); } +int TextAlignment(int alignment) + { return cdCanvasTextAlignment(canvas, alignment); } +double TextOrientation(double angle) + { return cdCanvasTextOrientation(canvas, angle); } +int MarkType(int type) + { return cdCanvasMarkType(canvas, type); } +int MarkSize(int size) + { return cdCanvasMarkSize(canvas, size); } + +/* vector text */ +void VectorText(int x, int y, const char* s) + { cdCanvasVectorText(canvas, x, y, s); } +void MultiLineVectorText(int x, int y, const char* s) + { cdCanvasMultiLineVectorText(canvas, x, y, s); } + +/* vector text attributes */ +char *VectorFont(const char *filename) + { return cdCanvasVectorFont(canvas, filename); } +void VectorTextDirection(int x1, int y1, int x2, int y2) + { cdCanvasVectorTextDirection(canvas, x1, y1, x2, y2); } +double* VectorTextTransform(const double* matrix) + { return cdCanvasVectorTextTransform(canvas, matrix); } +void VectorTextSize(int size_x, int size_y, const char* s) + { cdCanvasVectorTextSize(canvas, size_x, size_y, s); } +int VectorCharSize(int size) + { return cdCanvasVectorCharSize(canvas, size); } + + +/* vector text properties */ +void GetVectorTextSize(const char* s, int *x, int *y) + { cdCanvasGetVectorTextSize(canvas, s, x, y); } +void GetVectorTextBounds(const char* s, int x, int y, int *rect) + { cdCanvasGetVectorTextBounds(canvas, s, x, y, rect); } + +/* properties */ +void GetFontDim(int *max_width, int *height, int *ascent, int *descent) + { cdCanvasGetFontDim(canvas, max_width, height, ascent, descent); } +void GetTextSize(const char* s, int *width, int *height) + { cdCanvasGetTextSize(canvas, s, width, height); } +void GetTextBox(int x, int y, const char* s, int *xmin, int *xmax, int *ymin, int *ymax) + { cdCanvasGetTextBox(canvas, x, y, s, xmin, xmax, ymin, ymax); } +void GetTextBounds(int x, int y, const char* s, int *rect) + { cdCanvasGetTextBounds(canvas, x, y, s, rect); } +int GetColorPlanes() + { return cdCanvasGetColorPlanes(canvas); } + +/* color */ +void Palette(int n, const long *palette, int mode) + { cdCanvasPalette(canvas, n, palette, mode); } + +/* client images */ +void GetImageRGB(unsigned char* r, unsigned char* g, unsigned char* b, int x, int y, int w, int h) + { cdCanvasGetImageRGB(canvas, r, g, b, x, y, w, h); } +void PutImageRectRGB(int iw, int ih, const unsigned char* r, const unsigned char* g, const unsigned char* b, int x, int y, int w, int h, int xmin, int xmax, int ymin, int ymax) + { cdCanvasPutImageRectRGB(canvas, iw, ih, r, g, b, x, y, w, h, xmin, xmax, ymin, ymax); } +void PutImageRectRGBA(int iw, int ih, const unsigned char* r, const unsigned char* g, const unsigned char* b, const unsigned char* a, int x, int y, int w, int h, int xmin, int xmax, int ymin, int ymax) + { cdCanvasPutImageRectRGBA(canvas, iw, ih, r, g, b, a, x, y, w, h, xmin, xmax, ymin, ymax); } +void PutImageRectMap(int iw, int ih, const unsigned char* index, const long* colors, int x, int y, int w, int h, int xmin, int xmax, int ymin, int ymax) + { cdCanvasPutImageRectMap(canvas, iw, ih, index, colors, x, y, w, h, xmin, xmax, ymin, ymax); } + +/* server images */ +cdImage* CreateImage(int w, int h) + { return cdCanvasCreateImage(canvas, w, h); } +void GetImage(cdImage* image, int x, int y) + { cdCanvasGetImage(canvas, image, x, y); } +void PutImageRect(cdImage* image, int x, int y, int xmin, int xmax, int ymin, int ymax) + { cdCanvasPutImageRect(canvas, image, x, y, xmin, xmax, ymin, ymax); } +void ScrollArea(int xmin, int xmax, int ymin, int ymax, int dx, int dy) + { cdCanvasScrollArea(canvas, xmin, xmax, ymin, ymax, dx, dy); } + +void PutBitmap(cdBitmap* bitmap, int x, int y, int w, int h) + { cdCanvasPutBitmap(canvas, bitmap, x, y, w, h); } +void GetBitmap(cdBitmap* bitmap, int x, int y) + { cdCanvasGetBitmap(canvas, bitmap, x, y); } + +/* coordinate transformation */ +void wWindow(double xmin, double xmax, double ymin, double ymax) + { wdCanvasWindow(canvas, xmin, xmax, ymin, ymax); } +void wGetWindow(double *xmin, double *xmax, double *ymin, double *ymax) + { wdCanvasGetWindow(canvas, xmin, xmax, ymin, ymax); } +void wViewport(int xmin, int xmax, int ymin, int ymax) + { wdCanvasViewport(canvas, xmin, xmax, ymin, ymax); } +void wGetViewport(int *xmin, int *xmax, int *ymin, int *ymax) + { wdCanvasGetViewport(canvas, xmin, xmax, ymin, ymax); } +void wWorld2Canvas(double xw, double yw, int *xv, int *yv) + { wdCanvasWorld2Canvas(canvas, xw, yw, xv, yv); } +void wWorld2CanvasSize(double hw, double vw, int *hv, int *vv) + { wdCanvasWorld2CanvasSize(canvas, hw, vw, hv, vv); } +void wCanvas2World(int xv, int yv, double *xw, double *yw) + { wdCanvasCanvas2World(canvas, xv, yv, xw, yw); } + +void wClipArea(double xmin, double xmax, double ymin, double ymax) + { wdCanvasClipArea(canvas, xmin, xmax, ymin, ymax); } +int wGetClipArea(double *xmin, double *xmax, double *ymin, double *ymax) + { return wdCanvasGetClipArea(canvas, xmin, xmax, ymin, ymax); } +int wIsPointInRegion(double x, double y) + { return wdCanvasIsPointInRegion(canvas, x, y); } +void wOffsetRegion(double x, double y) + { wdCanvasOffsetRegion(canvas, x, y); } +void wGetRegionBox(double *xmin, double *xmax, double *ymin, double *ymax) + { wdCanvasGetRegionBox(canvas, xmin, xmax, ymin, ymax); } + +/* primitives */ +void wPixel(double x, double y, long color) + { wdCanvasPixel(canvas, x, y, color); } +void wMark(double x, double y) + { wdCanvasMark(canvas, x, y); } +void wLine(double x1, double y1, double x2, double y2) + { wdCanvasLine(canvas, x1, y1, x2, y2); } +void wVertex(double x, double y) + { wdCanvasVertex(canvas, x, y); } +void wRect(double xmin, double xmax, double ymin, double ymax) + { wdCanvasRect(canvas, xmin, xmax, ymin, ymax); } +void wBox(double xmin, double xmax, double ymin, double ymax) + { wdCanvasBox(canvas, xmin, xmax, ymin, ymax); } +void wArc(double xc, double yc, double w, double h, double angle1, double angle2) + { wdCanvasArc(canvas, xc, yc, w, h, angle1, angle2); } +void wSector(double xc, double yc, double w, double h, double angle1, double angle2) + { wdCanvasSector(canvas, xc, yc, w, h, angle1, angle2); } +void wChord(double xc, double yc, double w, double h, double angle1, double angle2) + { wdCanvasChord(canvas, xc, yc, w, h, angle1, angle2); } +void wText(double x, double y, const char* s) + { wdCanvasText(canvas, x, y, s); } + +void wPutImageRect(cdImage* image, double x, double y, int xmin, int xmax, int ymin, int ymax) + { wdCanvasPutImageRect(canvas, image, x, y, xmin, xmax, ymin, ymax); } +void wPutImageRectRGB(int iw, int ih, const unsigned char* r, const unsigned char* g, const unsigned char* b, double x, double y, double w, double h, int xmin, int xmax, int ymin, int ymax) + { wdCanvasPutImageRectRGB(canvas, iw, ih, r, g, b, x, y, w, h, xmin, xmax, ymin, ymax); } +void wPutImageRectRGBA(int iw, int ih, const unsigned char* r, const unsigned char* g, const unsigned char* b, const unsigned char* a, double x, double y, double w, double h, int xmin, int xmax, int ymin, int ymax) + { wdCanvasPutImageRectRGBA(canvas, iw, ih, r, g, b, a, x, y, w, h, xmin, xmax, ymin, ymax); } +void wPutImageRectMap(int iw, int ih, const unsigned char* index, const long* colors, double x, double y, double w, double h, int xmin, int xmax, int ymin, int ymax) + { wdCanvasPutImageRectMap(canvas, iw, ih, index, colors, x, y, w, h, xmin, xmax, ymin, ymax); } +void wPutBitmap(cdBitmap* bitmap, double x, double y, double w, double h) + { wdCanvasPutBitmap(canvas, bitmap, x, y, w, h); } + +/* attributes */ +double wLineWidth(double width) + { return wdCanvasLineWidth(canvas, width); } +int wFont(const char* type_face, int style, double size) + { return wdCanvasFont(canvas, type_face, style, size); } +void wGetFont(char *type_face, int *style, double *size) + { wdCanvasGetFont(canvas, type_face, style, size); } +double wMarkSize(double size) + { return wdCanvasMarkSize(canvas, size); } +void wGetFontDim(double *max_width, double *height, double *ascent, double *descent) + { wdCanvasGetFontDim(canvas, max_width, height, ascent, descent); } +void wGetTextSize(const char* s, double *width, double *height) + { wdCanvasGetTextSize(canvas, s, width, height); } +void wGetTextBox(double x, double y, const char* s, double *xmin, double *xmax, double *ymin, double *ymax) + { wdCanvasGetTextBox(canvas, x, y, s, xmin, xmax, ymin, ymax); } +void wGetTextBounds(double x, double y, const char* s, double *rect) + { wdCanvasGetTextBounds(canvas, x, y, s, rect); } +void wStipple(int w, int h, const unsigned char*fgbg, double w_mm, double h_mm) + { wdCanvasStipple(canvas, w, h, fgbg, w_mm, h_mm); } +void wPattern(int w, int h, const long *color, double w_mm, double h_mm) + { wdCanvasPattern(canvas, w, h, color, w_mm, h_mm); } + +/* vector text */ +void wVectorTextDirection(double x1, double y1, double x2, double y2) + { wdCanvasVectorTextDirection(canvas, x1, y1, x2, y2); } +void wVectorTextSize(double size_x, double size_y, const char* s) + { wdCanvasVectorTextSize(canvas, size_x, size_y, s); } +void wGetVectorTextSize(const char* s, double *x, double *y) + { wdCanvasGetVectorTextSize(canvas, s, x, y); } +double wVectorCharSize(double size) + { return wdCanvasVectorCharSize(canvas, size); } +void wVectorText(double x, double y, const char* s) + { wdCanvasVectorText(canvas, x, y, s); } +void wMultiLineVectorText(double x, double y, const char* s) + { wdCanvasMultiLineVectorText(canvas, x, y, s); } +void wGetVectorTextBounds(const char* s, double x, double y, double *rect) + { wdCanvasGetVectorTextBounds(canvas, s, x, y, rect); } + +}; + +#endif + diff --git a/include/cd_old.h b/include/cd_old.h new file mode 100644 index 0000000..47d805c --- /dev/null +++ b/include/cd_old.h @@ -0,0 +1,158 @@ +/** \file + * \brief Old User API + * + * See Copyright Notice in cd.h + */ + +#ifndef __CD_OLD_H +#define __CD_OLD_H + +#ifdef __cplusplus +extern "C" { +#endif + + +/* canvas control */ +int cdActivate(cdCanvas* canvas); +cdCanvas* cdActiveCanvas(void); +int cdSimulate(int mode); +void cdFlush(void); +void cdClear(void); +cdState* cdSaveState(void); +void cdRestoreState(cdState* state); +void cdSetAttribute(const char* name, char* data); +void cdSetfAttribute(const char* name, const char* format, ...); +char* cdGetAttribute(const char* name); +cdContext* cdGetContext(cdCanvas* canvas); + +/* interpretation */ +int cdRegisterCallback(cdContext *context, int cb, cdCallback func); +int cdPlay(cdContext *context, int xmin, int xmax, int ymin, int ymax, void *data); + +/* coordinate transformation */ +void cdGetCanvasSize(int *width, int *height, double *width_mm, double *height_mm); +int cdUpdateYAxis(int *y); +void cdMM2Pixel(double mm_dx, double mm_dy, int *dx, int *dy); +void cdPixel2MM(int dx, int dy, double *mm_dx, double *mm_dy); +void cdOrigin(int x, int y); + +/* clipping */ +int cdClip(int mode); +int * cdGetClipPoly(int *n); +void cdClipArea(int xmin, int xmax, int ymin, int ymax); +int cdGetClipArea(int *xmin, int *xmax, int *ymin, int *ymax); + +/* clipping region */ +int cdPointInRegion(int x, int y); +void cdOffsetRegion(int x, int y); +void cdRegionBox(int *xmin, int *xmax, int *ymin, int *ymax); +int cdRegionCombineMode(int mode); + +/* primitives */ +void cdPixel(int x, int y, long color); +void cdMark(int x, int y); +void cdLine(int x1, int y1, int x2, int y2); +void cdBegin(int mode); +void cdVertex(int x, int y); +void cdEnd(void); +void cdRect(int xmin, int xmax, int ymin, int ymax); +void cdBox(int xmin, int xmax, int ymin, int ymax); +void cdArc(int xc, int yc, int w, int h, double angle1, double angle2); +void cdSector(int xc, int yc, int w, int h, double angle1, double angle2); +void cdChord(int xc, int yc, int w, int h, double angle1, double angle2); +void cdText(int x, int y, const char* s); + +/* attributes */ +long cdBackground(long color); +long cdForeground(long color); +int cdBackOpacity(int opacity); +int cdWriteMode(int mode); +int cdLineStyle(int style); +void cdLineStyleDashes(const int* dashes, int count); +int cdLineWidth(int width); +int cdLineJoin(int join); +int cdLineCap(int cap); +int cdInteriorStyle(int style); +int cdHatch(int style); +void cdStipple(int w, int h, const unsigned char* stipple); +unsigned char* cdGetStipple(int *n, int *m); +void cdPattern(int w, int h, const long *pattern); +long* cdGetPattern(int* n, int* m); +int cdFillMode(int mode); +void cdFont(int type_face, int style, int size); +void cdGetFont(int *type_face, int *style, int *size); +char* cdNativeFont(const char* font); +int cdTextAlignment(int alignment); +double cdTextOrientation(double angle); +int cdMarkType(int type); +int cdMarkSize(int size); + +/* vector text */ +void cdVectorText(int x, int y, const char* s); +void cdMultiLineVectorText(int x, int y, const char* s); + +/* vector text attributes */ +char *cdVectorFont(const char *filename); +void cdVectorTextDirection(int x1, int y1, int x2, int y2); +double* cdVectorTextTransform(const double* matrix); +void cdVectorTextSize(int size_x, int size_y, const char* s); +int cdVectorCharSize(int size); + +/* vector text properties */ +void cdGetVectorTextSize(const char* s, int *x, int *y); +void cdGetVectorTextBounds(const char* s, int x, int y, int *rect); + +/* properties */ +void cdFontDim(int *max_width, int *height, int *ascent, int *descent); +void cdTextSize(const char* s, int *width, int *height); +void cdTextBox(int x, int y, const char* s, int *xmin, int *xmax, int *ymin, int *ymax); +void cdTextBounds(int x, int y, const char* s, int *rect); +int cdGetColorPlanes(void); + +/* color */ +void cdPalette(int n, const long* palette, int mode); + +/* client images */ +void cdGetImageRGB(unsigned char* r, unsigned char* g, unsigned char* b, int x, int y, int w, int h); +void cdPutImageRectRGB(int iw, int ih, const unsigned char* r, const unsigned char* g, const unsigned char* b, int x, int y, int w, int h, int xmin, int xmax, int ymin, int ymax); +void cdPutImageRectRGBA(int iw, int ih, const unsigned char* r, const unsigned char* g, const unsigned char* b, const unsigned char* a, int x, int y, int w, int h, int xmin, int xmax, int ymin, int ymax); +void cdPutImageRectMap(int iw, int ih, const unsigned char* index, const long* colors, int x, int y, int w, int h, int xmin, int xmax, int ymin, int ymax); + +/* defined for backward compatibility */ +#define cdPutImageRGB(iw, ih, r, g, b, x, y, w, h) cdPutImageRectRGB((iw), (ih), (r), (g), (b), (x), (y), (w), (h), 0, 0, 0, 0) +#define cdPutImageRGBA(iw, ih, r, g, b, a, x, y, w, h) cdPutImageRectRGBA((iw), (ih), (r), (g), (b), (a), (x), (y), (w), (h), 0, 0, 0, 0) +#define cdPutImageMap(iw, ih, index, colors, x, y, w, h) cdPutImageRectMap((iw), (ih), (index), (colors), (x), (y), (w), (h), 0, 0, 0, 0) +#define cdPutImage(image, x, y) cdPutImageRect((image), (x), (y), 0, 0, 0, 0) + +/* server images */ +cdImage* cdCreateImage(int w, int h); +void cdGetImage(cdImage* image, int x, int y); +void cdPutImageRect(cdImage* image, int x, int y, int xmin, int xmax, int ymin, int ymax); +void cdScrollArea(int xmin, int xmax, int ymin, int ymax, int dx, int dy); + +/* bitmap */ +void cdPutBitmap(cdBitmap* bitmap, int x, int y, int w, int h); +void cdGetBitmap(cdBitmap* bitmap, int x, int y); + +enum { /* OLD type face -> new names */ + CD_SYSTEM, /* "System" */ + CD_COURIER, /* "Courier" */ + CD_TIMES_ROMAN, /* "Times" */ + CD_HELVETICA, /* "Helvetica" */ + CD_NATIVE +}; + +/* OLD definitions, defined for backward compatibility */ +#define CD_CLIPON CD_CLIPAREA +#define CD_CENTER_BASE CD_BASE_CENTER +#define CD_LEFT_BASE CD_BASE_LEFT +#define CD_RIGHT_BASE CD_BASE_RIGHT +#define CD_ITALIC_BOLD CD_BOLD_ITALIC +#define cdScrollImage cdScrollArea +#define cdCanvas2Raster(x, y) {(void)x; cdUpdateYAxis(y);} + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/include/cd_private.h b/include/cd_private.h new file mode 100644 index 0000000..9ca38ce --- /dev/null +++ b/include/cd_private.h @@ -0,0 +1,362 @@ +/** \file + * \brief Private CD declarations + * + * See Copyright Notice in cd.h + */ + +#ifndef __CD_PRIVATE_H +#define __CD_PRIVATE_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* All context canvas must have at least the base canvas pointer. */ +typedef struct _cdCtxCanvasBase +{ + cdCanvas* canvas; +} cdCtxCanvasBase; + +typedef struct _cdCtxCanvas cdCtxCanvas; +typedef struct _cdCtxImage cdCtxImage; + +typedef struct _cdVectorFont cdVectorFont; +typedef struct _cdSimulation cdSimulation; + +typedef struct _cdPoint +{ + int x, y; +} cdPoint; + +typedef struct _cdfPoint +{ + double x, y; +} cdfPoint; + +typedef struct _cdRect +{ + int xmin, xmax, ymin, ymax; +} cdRect; + +typedef struct _cdfRect +{ + double xmin, xmax, ymin, ymax; +} cdfRect; + +typedef struct _cdAttribute +{ + const char *name; + + /* can be NULL one of them */ + void (*set)(cdCtxCanvas* ctxcanvas, char* data); + char* (*get)(cdCtxCanvas* ctxcanvas); +} cdAttribute; + +struct _cdImage +{ + int w, h; + cdCtxImage* ctximage; + + /* can NOT be NULL */ + void (*cxGetImage)(cdCtxCanvas* ctxcanvas, cdCtxImage* ctximage, int x, int y); + void (*cxPutImageRect)(cdCtxCanvas* ctxcanvas, cdCtxImage* ctximage, int x, int y, int xmin, int xmax, int ymin, int ymax); + void (*cxKillImage)(cdCtxImage* ctximage); +}; + +struct _cdContext +{ + unsigned long caps; /* canvas capabilities, combination of CD_CAP_* */ + int plus; /* indicates if the canvas is context plus */ + + /* can NOT be NULL */ + void (*cxCreateCanvas)(cdCanvas* canvas, void *data); + void (*cxInitTable)(cdCanvas* canvas); + + /* can be NULL */ + int (*cxPlay)(cdCanvas* canvas, int xmin, int xmax, int ymin, int ymax, void *data); + int (*cxRegisterCallback)(int cb, cdCallback func); +}; + +struct _cdCanvas +{ + char signature[2]; /* must be "CD" */ + + /* can NOT be NULL */ + void (*cxPixel)(cdCtxCanvas* ctxcanvas, int x, int y, long color); + void (*cxLine)(cdCtxCanvas* ctxcanvas, int x1, int y1, int x2, int y2); + void (*cxPoly)(cdCtxCanvas* ctxcanvas, int mode, cdPoint* points, int n); + void (*cxRect)(cdCtxCanvas* ctxcanvas, int xmin, int xmax, int ymin, int ymax); + void (*cxBox)(cdCtxCanvas* ctxcanvas, int xmin, int xmax, int ymin, int ymax); + void (*cxArc)(cdCtxCanvas* ctxcanvas, int xc, int yc, int w, int h, double angle1, double angle2); + void (*cxSector)(cdCtxCanvas* ctxcanvas, int xc, int yc, int w, int h, double angle1, double angle2); + void (*cxChord)(cdCtxCanvas* ctxcanvas, int xc, int yc, int w, int h, double angle1, double angle2); + void (*cxText)(cdCtxCanvas* ctxcanvas, int x, int y, const char *s); + void (*cxKillCanvas)(cdCtxCanvas* ctxcanvas); + int (*cxFont)(cdCtxCanvas* ctxcanvas, const char *type_face, int style, int size); + void (*cxPutImageRectMap)(cdCtxCanvas* ctxcanvas, int iw, int ih, const unsigned char *index, const long *colors, int x, int y, int w, int h, int xmin, int xmax, int ymin, int ymax); + void (*cxPutImageRectRGB)(cdCtxCanvas* ctxcanvas, int iw, int ih, const unsigned char *r, const unsigned char *g, const unsigned char *b, int x, int y, int w, int h, int xmin, int xmax, int ymin, int ymax); + + /* default implementation uses the simulation driver */ + void (*cxGetFontDim)(cdCtxCanvas* ctxcanvas, int *max_width, int *height, int *ascent, int *descent); + void (*cxGetTextSize)(cdCtxCanvas* ctxcanvas, const char *s, int *width, int *height); + + /* all the following function pointers can be NULL */ + + void (*cxFlush)(cdCtxCanvas* ctxcanvas); + void (*cxClear)(cdCtxCanvas* ctxcanvas); + + void (*cxFLine)(cdCtxCanvas* ctxcanvas, double x1, double y1, double x2, double y2); + void (*cxFPoly)(cdCtxCanvas* ctxcanvas, int mode, cdfPoint* points, int n); + void (*cxFRect)(cdCtxCanvas* ctxcanvas, double xmin, double xmax, double ymin, double ymax); + void (*cxFBox)(cdCtxCanvas* ctxcanvas, double xmin, double xmax, double ymin, double ymax); + void (*cxFArc)(cdCtxCanvas* ctxcanvas, double xc, double yc, double w, double h, double angle1, double angle2); + void (*cxFSector)(cdCtxCanvas* ctxcanvas, double xc, double yc, double w, double h, double angle1, double angle2); + void (*cxFChord)(cdCtxCanvas* ctxcanvas, double xc, double yc, double w, double h, double angle1, double angle2); + void (*cxFText)(cdCtxCanvas* ctxcanvas, double x, double y, const char *s); + + int (*cxClip)(cdCtxCanvas* ctxcanvas, int mode); + void (*cxClipArea)(cdCtxCanvas* ctxcanvas, int xmin, int xmax, int ymin, int ymax); + void (*cxFClipArea)(cdCtxCanvas* ctxcanvas, double xmin, double xmax, double ymin, double ymax); + int (*cxBackOpacity)(cdCtxCanvas* ctxcanvas, int opacity); + int (*cxWriteMode)(cdCtxCanvas* ctxcanvas, int mode); + int (*cxLineStyle)(cdCtxCanvas* ctxcanvas, int style); + int (*cxLineWidth)(cdCtxCanvas* ctxcanvas, int width); + int (*cxLineJoin)(cdCtxCanvas* ctxcanvas, int join); + int (*cxLineCap)(cdCtxCanvas* ctxcanvas, int cap); + int (*cxInteriorStyle)(cdCtxCanvas* ctxcanvas, int style); + int (*cxHatch)(cdCtxCanvas* ctxcanvas, int style); + void (*cxStipple)(cdCtxCanvas* ctxcanvas, int w, int h, const unsigned char *stipple); + void (*cxPattern)(cdCtxCanvas* ctxcanvas, int w, int h, const long *pattern); + int (*cxNativeFont)(cdCtxCanvas* ctxcanvas, const char* font); + int (*cxTextAlignment)(cdCtxCanvas* ctxcanvas, int alignment); + double (*cxTextOrientation)(cdCtxCanvas* ctxcanvas, double angle); + void (*cxPalette)(cdCtxCanvas* ctxcanvas, int n, const long *palette, int mode); + long (*cxBackground)(cdCtxCanvas* ctxcanvas, long color); + long (*cxForeground)(cdCtxCanvas* ctxcanvas, long color); + void (*cxTransform)(cdCtxCanvas* ctxcanvas, const double* matrix); + + void (*cxPutImageRectRGBA)(cdCtxCanvas* ctxcanvas, int iw, int ih, const unsigned char *r, const unsigned char *g, const unsigned char *b, const unsigned char *a, int x, int y, int w, int h, int xmin, int xmax, int ymin, int ymax); + void (*cxGetImageRGB)(cdCtxCanvas* ctxcanvas, unsigned char *r, unsigned char *g, unsigned char *b, int x, int y, int w, int h); + void (*cxScrollArea)(cdCtxCanvas* ctxcanvas, int xmin, int xmax, int ymin, int ymax, int dx, int dy); + + cdCtxImage* (*cxCreateImage)(cdCtxCanvas* ctxcanvas, int w, int h); + void (*cxKillImage)(cdCtxImage* ctximage); + void (*cxGetImage)(cdCtxCanvas* ctxcanvas, cdCtxImage* ctximage, int x, int y); + void (*cxPutImageRect)(cdCtxCanvas* ctxcanvas, cdCtxImage* ctximage, int x, int y, int xmin, int xmax, int ymin, int ymax); + + void (*cxNewRegion)(cdCtxCanvas* ctxcanvas); + int (*cxIsPointInRegion)(cdCtxCanvas* ctxcanvas, int x, int y); + void (*cxOffsetRegion)(cdCtxCanvas* ctxcanvas, int x, int y); + void (*cxGetRegionBox)(cdCtxCanvas* ctxcanvas, int *xmin, int *xmax, int *ymin, int *ymax); + + int (*cxActivate)(cdCtxCanvas* ctxcanvas); + void (*cxDeactivate)(cdCtxCanvas* ctxcanvas); + + /* the driver must update these, when the canvas is created and + whenever the canvas change its size or bpp. */ + int w,h; /* size in pixels */ /**** pixel = mm * res ****/ + double w_mm, h_mm; /* size in mm */ /**** mm = pixel / res ****/ + double xres, yres; /* resolution in pixels/mm */ /**** res = pixel / mm ****/ + int bpp; /* number of bits per pixel */ + int invert_yaxis; /* the driver has the y axis from top to bottom */ + double matrix[6]; + int use_matrix; + + /* clipping attributes */ + int clip_mode; + cdRect clip_rect; + cdfRect clip_frect; + int clip_poly_n; + cdPoint* clip_poly; /* only defined if integer poligon created, if exist clip_fpoly is NULL, and ->Poly exists */ + cdfPoint* clip_fpoly; /* only defined if real poligon created, if exist clip_poly is NULL, and ->fPoly exists */ + + /* clipping region attributes */ + int new_region; + int combine_mode; + + /* color attributes */ + long foreground, background; + int back_opacity, write_mode; + + /* primitive attributes */ + int mark_type, mark_size; + + int line_style, line_width; + int line_cap, line_join; + int* line_dashes; + int line_dashes_count; + + int interior_style, hatch_style; + int fill_mode; + + char font_type_face[1024]; + int font_style, font_size; + int text_alignment; + double text_orientation; + char native_font[1024]; + + int pattern_w, pattern_h, pattern_size; + long* pattern; + int stipple_w, stipple_h, stipple_size; + unsigned char* stipple; + + /* origin */ + int use_origin; + cdPoint origin; /* both points contains the same coordinate always */ + cdfPoint forigin; + + /* last polygon */ + int poly_mode, + poly_n, /* current number of vertices */ + poly_size, fpoly_size; /* allocated number of vertices, only increases */ + cdPoint* poly; /* used during an integer poligon creation, only if ->Poly exists */ + cdfPoint* fpoly; /* used during an real poligon creation, only if ->fPoly exists */ + int use_fpoly; + + /* simulation flags */ + int sim_mode; + int sim_poly; + + /* WC */ + double s, sx, tx, sy, ty; /* Transformacao Window -> Viewport (scale+translation)*/ + cdfRect window; /* Window in WC */ + cdRect viewport; /* Viewport in pixels */ + + cdAttribute* attrib_list[50]; + int attrib_n; + + cdVectorFont* vector_font; + cdSimulation* simulation; + cdCtxCanvas* ctxcanvas; + cdContext* context; +}; + + +/***************/ +/* attributes */ +/***************/ +void cdRegisterAttribute(cdCanvas* canvas, cdAttribute* attrib); + +/***************/ +/* vector font */ +/***************/ +cdVectorFont* cdCreateVectorFont(cdCanvas* canvas); +void cdKillVectorFont(cdVectorFont* vector_font_data); + +/**********/ +/* WC */ +/**********/ +void wdSetDefaults(cdCanvas* canvas); + +/********************/ +/* Context Plus */ +/********************/ +void cdInitContextPlusList(cdContext* ctx_list[]); +cdContext* cdGetContextPlus(int ctx); +enum{CD_CTX_NATIVEWINDOW, CD_CTX_IMAGE, CD_CTX_DBUFFER, CD_CTX_PRINTER, CD_CTX_EMF, CD_CTX_CLIPBOARD}; +#define NUM_CONTEXTPLUS 6 + +/*************/ +/* utilities */ +/*************/ +int cdRound(double x); +void cdCanvasGetEllipseBox(int xc, int yc, int w, int h, double a1, double a2, int *xmin, int *xmax, int *ymin, int *ymax); +int cdCheckBoxSize(int *xmin, int *xmax, int *ymin, int *ymax); +int cdfCheckBoxSize(double *xmin, double *xmax, double *ymin, double *ymax); +void cdNormalizeLimits(int w, int h, int *xmin, int *xmax, int *ymin, int *ymax); +int cdGetFileName(const char* strdata, char* filename); +int cdStrEqualNoCase(const char* str1, const char* str2); + +#define _cdCheckCanvas(_canvas) (_canvas!=NULL && ((unsigned char*)_canvas)[0] == 'C' && ((unsigned char*)_canvas)[1] == 'D') +#define _cdInvertYAxis(_canvas, _y) (_canvas->h - (_y) - 1) +#define _cdSwapInt(_a,_b) {int _c=_a;_a=_b;_b=_c;} +#define _cdSwapDouble(_a,_b) {double _c=_a;_a=_b;_b=_c;} +#define _cdRound(_x) ((int)(_x < 0? (_x-0.5): (_x+0.5))) +#define _cdRotateHatch(_x) ((_x) = ((_x)<< 1) | ((_x)>>7)) + +/******************/ +/* Transformation */ +/******************/ +void cdMatrixTransformPoint(double* matrix, int x, int y, int *rx, int *ry); +void cdfMatrixTransformPoint(double* matrix, double x, double y, double *rx, double *ry); +void cdMatrixMultiply(const double* matrix, double* mul_matrix); +void cdMatrixInverse(const double* matrix, double* inv_matrix); +void cdRotatePoint(cdCanvas* canvas, int x, int y, int cx, int cy, int *rx, int *ry, double sin_teta, double cos_teta); +void cdRotatePointY(cdCanvas* canvas, int x, int y, int cx, int cy, int *ry, double sin_theta, double cos_theta); +void cdTextTranslatePoint(cdCanvas* canvas, int x, int y, int w, int h, int baseline, int *rx, int *ry); + +/*************/ +/* Fonts */ +/*************/ +int cdParsePangoFont(const char *nativefont, char *type_face, int *style, int *size); +int cdParseIupWinFont(const char *nativefont, char *type_face, int *style, int *size); +int cdParseXWinFont(const char *nativefont, char *type_face, int *style, int *size); +int cdGetFontSizePixels(cdCanvas* canvas, int size); +int cdGetFontSizePoints(cdCanvas* canvas, int size); + +/****************/ +/* For Images */ +/****************/ +unsigned char cdZeroOrderInterpolation(int width, int height, const unsigned char *map, float xl, float yl); +unsigned char cdBilinearInterpolation(int width, int height, const unsigned char *map, float xl, float yl); +void cdImageRGBInitInverseTransform(int w, int h, int xmin, int xmax, int ymin, int ymax, float *xfactor, float *yfactor, const double* matrix, double* inv_matrix); +void cdImageRGBInverseTransform(int t_x, int t_y, float *i_x, float *i_y, float xfactor, float yfactor, int xmin, int ymin, int x, int y, double *inv_matrix); +void cdImageRGBCalcDstLimits(cdCanvas* canvas, int x, int y, int w, int h, int *xmin, int *xmax, int *ymin, int *ymax, int* rect); +void cdRGB2Gray(int width, int height, const unsigned char* red, const unsigned char* green, const unsigned char* blue, unsigned char* index, long *color); + +#define CD_ALPHA_BLEND(_src,_dst,_alpha) (unsigned char)(((_src) * (_alpha) + (_dst) * (255 - (_alpha))) / 255) + +int* cdGetZoomTable(int w, int rw, int xmin); +int cdCalcZoom(int canvas_size, int cnv_rect_pos, int cnv_rect_size, + int *new_cnv_rect_pos, int *new_cnv_rect_size, + int img_rect_pos, int img_rect_size, + int *new_img_rect_pos, int *new_img_rect_size, int is_horizontal); + +/**************/ +/* simulation */ +/**************/ +cdSimulation* cdCreateSimulation(cdCanvas* canvas); +void cdKillSimulation(cdSimulation* simulation); +void cdSimInitText(cdSimulation* simulation); + +/* Replacements for cdCanvas function pointers */ +void cdrectSIM(cdCtxCanvas* ctxcanvas, int xmin, int xmax, int ymin, int ymax); +void cdboxSIM(cdCtxCanvas* ctxcanvas, int xmin, int xmax, int ymin, int ymax); +void cdlineSIM(cdCtxCanvas* ctxcanvas, int x1, int y1, int x2, int y2); +void cdarcSIM(cdCtxCanvas* ctxcanvas, int xc, int yc, int width, int height, double angle1, double angle2); +void cdsectorSIM(cdCtxCanvas* ctxcanvas, int xc, int yc, int width, int height, double angle1, double angle2); +void cdchordSIM(cdCtxCanvas* ctxcanvas, int xc, int yc, int width, int height, double angle1, double angle2); +void cdpolySIM(cdCtxCanvas* ctxcanvas, int mode, cdPoint* points, int n); + +/* Replacements for Text and Font using FreeType library */ +void cdtextSIM(cdCtxCanvas* ctxcanvas, int x, int y, const char *s); +int cdfontSIM(cdCtxCanvas* ctxcanvas, const char *type_face, int style, int size); +void cdgetfontdimSIM(cdCtxCanvas* ctxcanvas, int *max_width, int *height, int *ascent, int *descent); +void cdgettextsizeSIM(cdCtxCanvas* ctxcanvas, const char *s, int *width, int *height); + +/* Simulation functions that are independent of the simulation base driver */ +void cdSimMark(cdCanvas* canvas, int x, int y); +void cdSimPolyBezier(cdCanvas* canvas, const cdPoint* points, int n); +void cdSimPutImageRectRGBA(cdCanvas* canvas, int iw, int ih, const unsigned char *r, const unsigned char *g, const unsigned char *b, const unsigned char *a, int x, int y, int w, int h, int xmin, int xmax, int ymin, int ymax); + +/* Simulation functions that are independent of the simulation base driver, + and does not checks for axis and matrix. + All use the polygon method ->cxFPoly only. */ +void cdfSimPolyBezier(cdCanvas* canvas, const cdfPoint* points, int n); +void cdfSimRect(cdCtxCanvas *ctxcanvas, double xmin, double xmax, double ymin, double ymax); +void cdfSimBox(cdCtxCanvas *ctxcanvas, double xmin, double xmax, double ymin, double ymax); +void cdfSimElipse(cdCtxCanvas* ctxcanvas, double xc, double yc, double width, double height, double angle1, double angle2, int sector); +void cdfSimArc(cdCtxCanvas *ctxcanvas, double xc, double yc, double width, double height, double angle1, double angle2); + +/* Replacements for Font using estimation */ +void cdgetfontdimEX(cdCtxCanvas* ctxcanvas, int *max_width, int *height, int *ascent, int *descent); +void cdgettextsizeEX(cdCtxCanvas* ctxcanvas, const char *s, int *width, int *height); + + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/include/cdcgm.h b/include/cdcgm.h new file mode 100644 index 0000000..2e686a7 --- /dev/null +++ b/include/cdcgm.h @@ -0,0 +1,34 @@ +/** \file + * \brief CGM driver + * + * See Copyright Notice in cd.h + */ + +#ifndef __CD_CGM_H +#define __CD_CGM_H + +#ifdef __cplusplus +extern "C" { +#endif + +cdContext* cdContextCGM(void); +#define CD_CGM cdContextCGM() + +#define CD_CGMCOUNTERCB 1 +#define CD_CGMSCLMDECB 2 +#define CD_CGMVDCEXTCB 3 +#define CD_CGMBEGPICTCB 4 +#define CD_CGMBEGPICTBCB 5 +#define CD_CGMBEGMTFCB 6 + +/* OLD definitions, defined for backward compatibility */ +#define CDPLAY_ABORT CD_ABORT +#define CDPLAY_GO CD_CONTINUE + +#ifdef __cplusplus +} +#endif + +#endif /* ifndef __CD_CGM_ */ + + diff --git a/include/cdclipbd.h b/include/cdclipbd.h new file mode 100644 index 0000000..b1594bc --- /dev/null +++ b/include/cdclipbd.h @@ -0,0 +1,22 @@ +/** \file + * \brief Clipboard driver + * + * See Copyright Notice in cd.h + */ + +#ifndef __CD_CLIPBOARD_H +#define __CD_CLIPBOARD_H + +#ifdef __cplusplus +extern "C" { +#endif + +cdContext* cdContextClipboard(void); + +#define CD_CLIPBOARD cdContextClipboard() + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/include/cddbuf.h b/include/cddbuf.h new file mode 100644 index 0000000..4eae9a9 --- /dev/null +++ b/include/cddbuf.h @@ -0,0 +1,23 @@ +/** \file + * \brief Double Buffer driver + * + * See Copyright Notice in cd.h + */ + +#ifndef __CD_DBUF_H +#define __CD_DBUF_H + +#ifdef __cplusplus +extern "C" { +#endif + +cdContext* cdContextDBuffer(void); + +#define CD_DBUFFER cdContextDBuffer() + +#ifdef __cplusplus +} +#endif + +#endif /* ifndef __CD_DBUF_ */ + diff --git a/include/cddebug.h b/include/cddebug.h new file mode 100644 index 0000000..0d3c5c6 --- /dev/null +++ b/include/cddebug.h @@ -0,0 +1,24 @@ +/** \file + * \brief CD Debug driver + * + * See Copyright Notice in cd.h + */ + +#ifndef __CD_DEBUG_H +#define __CD_DEBUG_H + +#ifdef __cplusplus +extern "C" { +#endif + +cdContext* cdContextDebug(void); + +#define CD_DEBUG cdContextDebug() + +#ifdef __cplusplus +} +#endif + +#endif /* ifndef __CD_DEBUG_H */ + + diff --git a/include/cddgn.h b/include/cddgn.h new file mode 100644 index 0000000..ed90f40 --- /dev/null +++ b/include/cddgn.h @@ -0,0 +1,23 @@ +/** \file + * \brief DGN driver + * + * See Copyright Notice in cd.h + */ + +#ifndef __CD_DGN_H +#define __CD_DGN_H + +#ifdef __cplusplus +extern "C" { +#endif + +cdContext* cdContextDGN(void); + +#define CD_DGN cdContextDGN() + +#ifdef __cplusplus +} +#endif + +#endif /* ifndef __CD_DGN_ */ + diff --git a/include/cddxf.h b/include/cddxf.h new file mode 100644 index 0000000..402504e --- /dev/null +++ b/include/cddxf.h @@ -0,0 +1,22 @@ +/** \file + * \brief DXF driver + * + * See Copyright Notice in cd.h + */ + +#ifndef __CD_DXF_H +#define __CD_DXF_H + +#ifdef __cplusplus +extern "C" { +#endif + +cdContext* cdContextDXF(void); + +#define CD_DXF cdContextDXF() + +#ifdef __cplusplus +} +#endif + +#endif /* ifndef __CD_DXF_ */ diff --git a/include/cdemf.h b/include/cdemf.h new file mode 100644 index 0000000..20e15fe --- /dev/null +++ b/include/cdemf.h @@ -0,0 +1,22 @@ +/** \file + * \brief EMF driver + * + * See Copyright Notice in cd.h + */ + +#ifndef __CD_EMF_H +#define __CD_EMF_H + +#ifdef __cplusplus +extern "C" { +#endif + +cdContext* cdContextEMF(void); + +#define CD_EMF cdContextEMF() + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/include/cdgdiplus.h b/include/cdgdiplus.h new file mode 100644 index 0000000..75e24f3 --- /dev/null +++ b/include/cdgdiplus.h @@ -0,0 +1,29 @@ +/** \file + * \brief GDI+ Control + * + * See Copyright Notice in cd.h + */ + +#ifndef __CD_GDIPLUS_H +#define __CD_GDIPLUS_H + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef WIN32 +void cdInitGdiPlus(void); /* old function, replaced by cdInitContextPlus */ +#else +#define cdInitGdiPlus() (0) +#endif + +/* Windows GDI+ Adicional Polygons */ +#define CD_SPLINE (CD_POLYCUSTOM+0) +#define CD_FILLSPLINE (CD_POLYCUSTOM+1) +#define CD_FILLGRADIENT (CD_POLYCUSTOM+2) + +#ifdef __cplusplus +} +#endif + +#endif /* ifndef _CD_GDIPLUS_ */ diff --git a/include/cdimage.h b/include/cdimage.h new file mode 100644 index 0000000..3573ef2 --- /dev/null +++ b/include/cdimage.h @@ -0,0 +1,23 @@ +/** \file + * \brief Server Image driver + * + * See Copyright Notice in cd.h + */ + +#ifndef __CD_IMAGE_H +#define __CD_IMAGE_H + +#ifdef __cplusplus +extern "C" { +#endif + +cdContext* cdContextImage(void); + +#define CD_IMAGE cdContextImage() + +#ifdef __cplusplus +} +#endif + +#endif /* ifndef __CD_IMAGE_ */ + diff --git a/include/cdirgb.h b/include/cdirgb.h new file mode 100644 index 0000000..2e12997 --- /dev/null +++ b/include/cdirgb.h @@ -0,0 +1,30 @@ +/** \file + * \brief IMAGERGB driver + * + * See Copyright Notice in cd.h + */ + +#ifndef __CD_IRGB_H +#define __CD_IRGB_H + +#ifdef __cplusplus +extern "C" { +#endif + +cdContext* cdContextImageRGB(void); +cdContext* cdContextDBufferRGB(void); + +#define CD_IMAGERGB cdContextImageRGB() +#define CD_DBUFFERRGB cdContextDBufferRGB() + +unsigned char* cdRedImage(cdCanvas* cnv); +unsigned char* cdGreenImage(cdCanvas* cnv); +unsigned char* cdBlueImage(cdCanvas* cnv); +unsigned char* cdAlphaImage(cdCanvas* cnv); + + +#ifdef __cplusplus +} +#endif + +#endif /* ifndef __CD_IRGB_ */ diff --git a/include/cdiup.h b/include/cdiup.h new file mode 100644 index 0000000..f6f7eb1 --- /dev/null +++ b/include/cdiup.h @@ -0,0 +1,22 @@ +/** \file + * \brief IUP driver + * + * See Copyright Notice in cd.h + */ + +#ifndef __CD_IUP_H +#define __CD_IUP_H + +#ifdef __cplusplus +extern "C" { +#endif + +cdContext* cdContextIup(void); + +#define CD_IUP cdContextIup() + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/include/cdlua.h b/include/cdlua.h new file mode 100644 index 0000000..30d8174 --- /dev/null +++ b/include/cdlua.h @@ -0,0 +1,39 @@ +/** \file + * \brief Lua Binding Control + * + * See Copyright Notice in cd.h + */ + +#ifndef __CD_LUA_H +#define __CD_LUA_H + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef LUA_NOOBJECT /* Lua 3 */ +void cdlua_open(void); +void cdlua_close(void); + +/* utilities */ +cdCanvas* cdlua_getcanvas(void); /* pos=1, deprecated use cdlua_checkcanvas */ +cdCanvas* cdlua_checkcanvas(int pos); +void cdlua_pushcanvas(cdCanvas* canvas); +#endif + +#ifdef LUA_TNONE /* Lua 5 */ +int cdlua_open(lua_State *L); +int cdlua_close(lua_State *L); + +/* utilities */ +cdCanvas* cdlua_getcanvas(lua_State * L); /* pos=1, deprecated use cdlua_checkcanvas */ +cdCanvas* cdlua_checkcanvas(lua_State * L, int pos); +void cdlua_pushcanvas(lua_State * L, cdCanvas* canvas); +#endif + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/include/cdlua3_private.h b/include/cdlua3_private.h new file mode 100644 index 0000000..3c84c72 --- /dev/null +++ b/include/cdlua3_private.h @@ -0,0 +1,120 @@ +/** \file + * \brief Private Lua 3 Binding Functions + * + * See Copyright Notice in cd.h + */ + +#ifndef __CDLUA3_PRIVATE_H +#define __CDLUA3_PRIVATE_H + +#ifdef __cplusplus +extern "C" { +#endif + +#define COLOR_TAG "CDLUA_COLOR_TAG" +#define CANVAS_TAG "CDLUA_CANVAS_TAG" +#define STATE_TAG "CDLUA_STATE_TAG" +#define BITMAP_TAG "CDLUA_BITMAP_TAG" +#define IMAGE_TAG "CDLUA_IMAGE_TAG" +#define IMAGERGB_TAG "CDLUA_IMAGERGB_TAG" +#define IMAGERGBA_TAG "CDLUA_IMAGERGBA_TAG" +#define STIPPLE_TAG "CDLUA_STIPPLE_TAG" +#define PATTERN_TAG "CDLUA_PATTERN_TAG" +#define PALETTE_TAG "CDLUA_PALETTE_TAG" +#define IMAGEMAP_TAG "CDLUA_IMAGEMAP_TAG" +#define CHANNEL_TAG "CDLUA_CHANNEL_TAG" + +/* context management */ + +typedef struct _cdCallbackLUA { + int lock; + char *name; + cdCallback func; +} cdCallbackLUA; + +typedef struct _cdContextLUA { + int id; + char *name; + cdContext* (*ctx)(void); + void* (*checkdata)(int param); + cdCallbackLUA* cb_list; + int cb_n; +} cdContextLUA; + +void cdlua_addcontext(cdContextLUA* luactx); +void cdlua_register(char* name, lua_CFunction func); +void cdlua_pushnumber(double num, char* name); + +/* tag management */ + +typedef struct _canvas_t { + cdCanvas *cd_canvas; +} canvas_t; + +typedef struct _state_t { + cdState *state; +} state_t; + +typedef struct _stipple_t { + unsigned char *value; + int width; + int height; + long int size; +} stipple_t; + +typedef struct _pattern_t { + long int *color; + int width; + int height; + long int size; +} pattern_t; + +typedef struct _palette_t { + long int *color; + long int size; +} palette_t; + +typedef struct _image_t { + void *cd_image; +} image_t; + +typedef struct _imagergb_t { + unsigned char *red; + unsigned char *green; + unsigned char *blue; + int width; + int height; + long int size; +} imagergb_t; + +typedef struct _imagergba_t { + unsigned char *red; + unsigned char *green; + unsigned char *blue; + unsigned char *alpha; + int width; + int height; + long int size; +} imagergba_t; + +typedef struct _imagemap_t { + unsigned char *index; + int width; + int height; + long int size; +} imagemap_t; + +typedef struct _channel_t { + unsigned char *value; + long int size; +} channel_t; + +typedef struct _bitmap_t { + cdBitmap *image; +} bitmap_t; + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/include/cdlua5_private.h b/include/cdlua5_private.h new file mode 100644 index 0000000..974fb4e --- /dev/null +++ b/include/cdlua5_private.h @@ -0,0 +1,141 @@ +/** \file +* \brief Private Lua 5 Binding Functions +* +* See Copyright Notice in cd.h +*/ + +#ifndef __CDLUA5_PRIVATE_H +#define __CDLUA5_PRIVATE_H + +#ifdef __cplusplus +extern "C" { +#endif + + +/* context management */ + +typedef struct _cdluaCallback { + int lock; + const char* name; + cdCallback func; +} cdluaCallback; + +typedef struct _cdluaContext { + int id; + const char* name; + cdContext* (*ctx)(void); + void* (*checkdata)(lua_State* L,int param); + cdluaCallback* cb_list; + int cb_n; +} cdluaContext; + +typedef struct _cdluaLuaState { + cdCanvas* void_canvas; /* the VOID canvas to avoid a NULL active canvas */ + cdluaContext* drivers[50]; /* store the registered drivers, map integer values to cdContext */ + int numdrivers; +} cdluaLuaState; + +/* metatables */ + +typedef struct _cdluaStipple { + unsigned char* stipple; + int width; + int height; + long int size; +} cdluaStipple; + +typedef struct _cdluaPattern { + long* pattern; + int width; + int height; + long int size; +} cdluaPattern; + +/* this is the same declaration used in the IM toolkit for imPalette in Lua */ +typedef struct _cdluaPalette { + long* color; + int count; +} cdluaPalette; + +typedef struct _cdluaImageRGB { + unsigned char* red; + unsigned char* green; + unsigned char* blue; + int width; + int height; + long int size; + int free; +} cdluaImageRGB; + +typedef struct _cdluaImageRGBA { + unsigned char* red; + unsigned char* green; + unsigned char* blue; + unsigned char* alpha; + int width; + int height; + long int size; + int free; +} cdluaImageRGBA; + +typedef struct _cdluaImageMap { + unsigned char* index; + int width; + int height; + long int size; +} cdluaImageMap; + +typedef struct _cdluaImageChannel { + unsigned char* channel; + long int size; +} cdluaImageChannel; + + +cdluaLuaState* cdlua_getstate(lua_State* L); +cdluaContext* cdlua_getcontext(lua_State* L, int param); + +lua_State* cdlua_getplaystate(void); +void cdlua_setplaystate(lua_State* L); + +void cdlua_kill_active(lua_State* L, cdCanvas* canvas); +void cdlua_open_active(lua_State* L, cdluaLuaState* cdL); + +void cdlua_open_canvas(lua_State* L); + +void cdlua_addcontext(lua_State* L, cdluaLuaState* cdL, cdluaContext* luactx); +void cdlua_initdrivers(lua_State* L, cdluaLuaState* cdL); + +cdluaPalette* cdlua_checkpalette(lua_State* L, int param); +cdluaStipple* cdlua_checkstipple(lua_State* L, int param); +cdluaPattern* cdlua_checkpattern(lua_State* L, int param); +cdluaImageRGB* cdlua_checkimagergb(lua_State* L, int param); +cdluaImageRGBA* cdlua_checkimagergba(lua_State* L, int param); +cdluaImageMap* cdlua_checkimagemap(lua_State* L, int param); +cdluaImageChannel* cdlua_checkchannel(lua_State* L, int param); + +long cdlua_checkcolor(lua_State* L, int param); +cdImage* cdlua_checkimage(lua_State* L, int param); +cdState* cdlua_checkstate(lua_State* L, int param); +cdBitmap* cdlua_checkbitmap(lua_State* L, int param); + +void cdlua_pushpalette(lua_State* L, long* palette, int size); +void cdlua_pushstipple(lua_State* L, unsigned char* stipple, int width, int height); +void cdlua_pushpattern(lua_State* L, long int* pattern, int width, int height); +void cdlua_pushimagergb(lua_State* L, unsigned char* red, unsigned char* green, unsigned char* blue, int width, int height); +void cdlua_pushimagergba(lua_State* L, unsigned char* red, unsigned char* green, unsigned char* blue, unsigned char* alpha, int width, int height); +void cdlua_pushimagemap(lua_State* L, unsigned char* index, int width, int height); +void cdlua_pushchannel(lua_State* L, unsigned char* channel, int size); + +void cdlua_pushimage(lua_State* L, cdImage* image); +void cdlua_pushstate(lua_State* L, cdState* state); +void cdlua_pushbitmap(lua_State* L, cdBitmap* bitmap); + +void cdlua_pushimagergb_ex(lua_State* L, unsigned char* red, unsigned char* green, unsigned char* blue, int width, int height); +void cdlua_pushimagergba_ex(lua_State* L, unsigned char* red, unsigned char* green, unsigned char* blue, unsigned char* alpha, int width, int height); + + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/include/cdluaim.h b/include/cdluaim.h new file mode 100644 index 0000000..3cd765c --- /dev/null +++ b/include/cdluaim.h @@ -0,0 +1,24 @@ +/** \file + * \brief CD+IM Lua Binding + * + * See Copyright Notice in cd.h + */ + +#ifndef __CD_LUAIM_H +#define __CD_LUAIM_H + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef LUA_TNONE /* Lua 5 */ +int cdluaim_open(lua_State *L); +int luaopen_cdluaim(lua_State *L); +#endif + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/include/cdluaiup.h b/include/cdluaiup.h new file mode 100644 index 0000000..570d7f1 --- /dev/null +++ b/include/cdluaiup.h @@ -0,0 +1,27 @@ +/** \file + * \brief IUP Canvas Lua Binding + * + * See Copyright Notice in cd.h + */ + +#ifndef __CD_LUAIUP_H +#define __CD_LUAIUP_H + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef LUA_NOOBJECT /* Lua 3 */ +void cdluaiup_open(void); +#endif + +#ifdef LUA_TNONE /* Lua 5 */ +int cdluaiup_open(lua_State *L); +#endif + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/include/cdluapdf.h b/include/cdluapdf.h new file mode 100644 index 0000000..45b4d98 --- /dev/null +++ b/include/cdluapdf.h @@ -0,0 +1,27 @@ +/** \file + * \brief PDF Canvas Lua Binding + * + * See Copyright Notice in cd.h + */ + +#ifndef __CD_LUAPDF_H +#define __CD_LUAPDF_H + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef LUA_NOOBJECT /* Lua 3 */ +void cdluapdf_open(void); +#endif + +#ifdef LUA_TNONE /* Lua 5 */ +int cdluapdf_open(lua_State *L); +#endif + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/include/cdmf.h b/include/cdmf.h new file mode 100644 index 0000000..7cc2a93 --- /dev/null +++ b/include/cdmf.h @@ -0,0 +1,24 @@ +/** \file + * \brief CD Metafile driver + * + * See Copyright Notice in cd.h + */ + +#ifndef __CD_MF_H +#define __CD_MF_H + +#ifdef __cplusplus +extern "C" { +#endif + +cdContext* cdContextMetafile(void); + +#define CD_METAFILE cdContextMetafile() + +#ifdef __cplusplus +} +#endif + +#endif /* ifndef __CD_MF_ */ + + diff --git a/include/cdmf_private.h b/include/cdmf_private.h new file mode 100644 index 0000000..7da5b90 --- /dev/null +++ b/include/cdmf_private.h @@ -0,0 +1,32 @@ +/** \file + * \brief CD Metafile driver private declarations + * + * See Copyright Notice in cd.h + */ + +#ifndef __CDMF_PRIVATE_H +#define __CDMF_PRIVATE_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* public part of the internal cdCtxCanvas */ +typedef struct cdCanvasMF +{ + cdCanvas* canvas; + char* filename; + void* data; +} cdCanvasMF; + +void cdcreatecanvasMF(cdCanvas *canvas, void *data); +void cdinittableMF(cdCanvas* canvas); +void cdkillcanvasMF(cdCanvasMF *mfcanvas); + +#ifdef __cplusplus +} +#endif + +#endif + + diff --git a/include/cdnative.h b/include/cdnative.h new file mode 100644 index 0000000..66c9c75 --- /dev/null +++ b/include/cdnative.h @@ -0,0 +1,26 @@ +/** \file + * \brief NativeWindow driver + * + * See Copyright Notice in cd.h + */ + +#ifndef __CD_NATIVE_H +#define __CD_NATIVE_H + +#ifdef __cplusplus +extern "C" { +#endif + +cdContext* cdContextNativeWindow(void); + +#define CD_NATIVEWINDOW cdContextNativeWindow() + +void cdGetScreenSize(int *width, int *height, double *width_mm, double *height_mm); +int cdGetScreenColorPlanes(void); + +#ifdef __cplusplus +} +#endif + +#endif /* ifndef __CD_NATIVE_ */ + diff --git a/include/cdpdf.h b/include/cdpdf.h new file mode 100644 index 0000000..70d6df5 --- /dev/null +++ b/include/cdpdf.h @@ -0,0 +1,38 @@ +/** \file + * \brief PDF driver + * + * See Copyright Notice in cd.h + */ + +#ifndef __CD_PDF_H +#define __CD_PDF_H + +#ifdef __cplusplus +extern "C" { +#endif + +cdContext* cdContextPDF(void); + +#define CD_PDF cdContextPDF() + +#ifndef CD_PAPERSIZE +#define CD_PAPERSIZE +enum { /* paper sizes */ + CD_A0, + CD_A1, + CD_A2, + CD_A3, + CD_A4, + CD_A5, + CD_LETTER, + CD_LEGAL +}; +#endif + + +#ifdef __cplusplus +} +#endif + +#endif /* ifndef _CD_PDF_ */ + diff --git a/include/cdpicture.h b/include/cdpicture.h new file mode 100644 index 0000000..860ff97 --- /dev/null +++ b/include/cdpicture.h @@ -0,0 +1,22 @@ +/** \file + * \brief CD Picture driver + * + * See Copyright Notice in cd.h + */ + +#ifndef __CD_PICTURE_H +#define __CD_PICTURE_H + +#ifdef __cplusplus +extern "C" { +#endif + +cdContext* cdContextPicture(void); + +#define CD_PICTURE cdContextPicture() + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/include/cdprint.h b/include/cdprint.h new file mode 100644 index 0000000..fff824b --- /dev/null +++ b/include/cdprint.h @@ -0,0 +1,23 @@ +/** \file + * \brief Printer driver + * + * See Copyright Notice in cd.h + */ + +#ifndef __CD_PRINTER_H +#define __CD_PRINTER_H + +#ifdef __cplusplus +extern "C" { +#endif + +cdContext* cdContextPrinter(void); + +#define CD_PRINTER cdContextPrinter() + +#ifdef __cplusplus +} +#endif + +#endif /* ifndef __CD_PRINTER_ */ + diff --git a/include/cdps.h b/include/cdps.h new file mode 100644 index 0000000..180ebad --- /dev/null +++ b/include/cdps.h @@ -0,0 +1,37 @@ +/** \file + * \brief PS driver + * + * See Copyright Notice in cd.h + */ + +#ifndef __CD_PS_H +#define __CD_PS_H + +#ifdef __cplusplus +extern "C" { +#endif + +cdContext* cdContextPS(void); + +#define CD_PS cdContextPS() + +#ifndef CD_PAPERSIZE +#define CD_PAPERSIZE +enum { /* paper sizes */ + CD_A0, + CD_A1, + CD_A2, + CD_A3, + CD_A4, + CD_A5, + CD_LETTER, + CD_LEGAL +}; +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* ifndef __CD_PS_ */ + diff --git a/include/cdwmf.h b/include/cdwmf.h new file mode 100644 index 0000000..607af6c --- /dev/null +++ b/include/cdwmf.h @@ -0,0 +1,22 @@ +/** \file + * \brief WMF driver + * + * See Copyright Notice in cd.h + */ + +#ifndef __CD_WMF_H +#define __CD_WMF_H + +#ifdef __cplusplus +extern "C" { +#endif + +cdContext* cdContextWMF(void); + +#define CD_WMF cdContextWMF() + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/include/wd.h b/include/wd.h new file mode 100644 index 0000000..83ebe0f --- /dev/null +++ b/include/wd.h @@ -0,0 +1,78 @@ +/** \file + * \brief World Coordinate Functions + * + * See Copyright Notice in cd.h + */ + +#ifndef __WD_H +#define __WD_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* coordinate transformation */ +void wdCanvasWindow(cdCanvas* canvas, double xmin, double xmax, double ymin, double ymax); +void wdCanvasGetWindow(cdCanvas* canvas, double *xmin, double *xmax, double *ymin, double *ymax); +void wdCanvasViewport(cdCanvas* canvas, int xmin, int xmax, int ymin, int ymax); +void wdCanvasGetViewport(cdCanvas* canvas, int *xmin, int *xmax, int *ymin, int *ymax); +void wdCanvasWorld2Canvas(cdCanvas* canvas, double xw, double yw, int *xv, int *yv); +void wdCanvasWorld2CanvasSize(cdCanvas* canvas, double hw, double vw, int *hv, int *vv); +void wdCanvasCanvas2World(cdCanvas* canvas, int xv, int yv, double *xw, double *yw); + +void wdCanvasClipArea(cdCanvas* canvas, double xmin, double xmax, double ymin, double ymax); +int wdCanvasGetClipArea(cdCanvas* canvas, double *xmin, double *xmax, double *ymin, double *ymax); +int wdCanvasIsPointInRegion(cdCanvas* canvas, double x, double y); +void wdCanvasOffsetRegion(cdCanvas* canvas, double x, double y); +void wdCanvasGetRegionBox(cdCanvas* canvas, double *xmin, double *xmax, double *ymin, double *ymax); + +void wdCanvasHardcopy(cdCanvas* canvas, cdContext* ctx, void *data, void(*draw_func)(cdCanvas *canvas_copy)); + +/* primitives */ +void wdCanvasPixel(cdCanvas* canvas, double x, double y, long color); +void wdCanvasMark(cdCanvas* canvas, double x, double y); +void wdCanvasLine(cdCanvas* canvas, double x1, double y1, double x2, double y2); +void wdCanvasVertex(cdCanvas* canvas, double x, double y); +void wdCanvasRect(cdCanvas* canvas, double xmin, double xmax, double ymin, double ymax); +void wdCanvasBox(cdCanvas* canvas, double xmin, double xmax, double ymin, double ymax); +void wdCanvasArc(cdCanvas* canvas, double xc, double yc, double w, double h, double angle1, double angle2); +void wdCanvasSector(cdCanvas* canvas, double xc, double yc, double w, double h, double angle1, double angle2); +void wdCanvasChord(cdCanvas* canvas, double xc, double yc, double w, double h, double angle1, double angle2); +void wdCanvasText(cdCanvas* canvas, double x, double y, const char* s); + +void wdCanvasPutImageRect(cdCanvas* canvas, cdImage* image, double x, double y, int xmin, int xmax, int ymin, int ymax); +void wdCanvasPutImageRectRGB(cdCanvas* canvas, int iw, int ih, const unsigned char* r, const unsigned char* g, const unsigned char* b, double x, double y, double w, double h, int xmin, int xmax, int ymin, int ymax); +void wdCanvasPutImageRectRGBA(cdCanvas* canvas, int iw, int ih, const unsigned char* r, const unsigned char* g, const unsigned char* b, const unsigned char* a, double x, double y, double w, double h, int xmin, int xmax, int ymin, int ymax); +void wdCanvasPutImageRectMap(cdCanvas* canvas, int iw, int ih, const unsigned char* index, const long* colors, double x, double y, double w, double h, int xmin, int xmax, int ymin, int ymax); +void wdCanvasPutBitmap(cdCanvas* canvas, cdBitmap* bitmap, double x, double y, double w, double h); + +/* attributes */ +double wdCanvasLineWidth(cdCanvas* canvas, double width); +int wdCanvasFont(cdCanvas* canvas, const char* type_face, int style, double size); +void wdCanvasGetFont(cdCanvas* canvas, char *type_face, int *style, double *size); +double wdCanvasMarkSize(cdCanvas* canvas, double size); +void wdCanvasGetFontDim(cdCanvas* canvas, double *max_width, double *height, double *ascent, double *descent); +void wdCanvasGetTextSize(cdCanvas* canvas, const char* s, double *width, double *height); +void wdCanvasGetTextBox(cdCanvas* canvas, double x, double y, const char* s, double *xmin, double *xmax, double *ymin, double *ymax); +void wdCanvasGetTextBounds(cdCanvas* canvas, double x, double y, const char* s, double *rect); +void wdCanvasStipple(cdCanvas* canvas, int w, int h, const unsigned char*fgbg, double w_mm, double h_mm); +void wdCanvasPattern(cdCanvas* canvas, int w, int h, const long *color, double w_mm, double h_mm); + +/* vector text */ +void wdCanvasVectorTextDirection(cdCanvas* canvas, double x1, double y1, double x2, double y2); +void wdCanvasVectorTextSize(cdCanvas* canvas, double size_x, double size_y, const char* s); +void wdCanvasGetVectorTextSize(cdCanvas* canvas, const char* s, double *x, double *y); +double wdCanvasVectorCharSize(cdCanvas* canvas, double size); +void wdCanvasVectorText(cdCanvas* canvas, double x, double y, const char* s); +void wdCanvasMultiLineVectorText(cdCanvas* canvas, double x, double y, const char* s); +void wdCanvasGetVectorTextBounds(cdCanvas* canvas, const char* s, double x, double y, double *rect); + +#ifdef __cplusplus +} +#endif + +#ifndef CD_NO_OLD_INTERFACE +#include "wd_old.h" +#endif + +#endif diff --git a/include/wd_old.h b/include/wd_old.h new file mode 100644 index 0000000..683c589 --- /dev/null +++ b/include/wd_old.h @@ -0,0 +1,85 @@ +/** \file + * \brief Old WC API + * + * See Copyright Notice in cd.h + */ + +#ifndef WD_OLD_H +#define WD_OLD_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* coordinate transformation */ +void wdWindow(double xmin, double xmax, double ymin, double ymax); +void wdGetWindow(double *xmin, double *xmax, double *ymin, double *ymax); +void wdViewport(int xmin, int xmax, int ymin, int ymax); +void wdGetViewport(int *xmin, int *xmax, int *ymin, int *ymax); +void wdWorld2Canvas(double xw, double yw, int *xv, int *yv); +void wdWorld2CanvasSize(double hw, double vw, int *hv, int *vv); +void wdCanvas2World(int xv, int yv, double *xw, double *yw); + +void wdClipArea(double xmin, double xmax, double ymin, double ymax); +int wdGetClipArea(double *xmin, double *xmax, double *ymin, double *ymax); +double* wdGetClipPoly(int *n); +int wdPointInRegion(double x, double y); +void wdOffsetRegion(double x, double y); +void wdRegionBox(double *xmin, double *xmax, double *ymin, double *ymax); + +void wdHardcopy(cdContext* ctx, void *data, cdCanvas *cnv, void(*draw_func)(void)); + +/* primitives */ +void wdPixel(double x, double y, long color); +void wdMark(double x, double y); +void wdLine(double x1, double y1, double x2, double y2); +void wdVertex(double x, double y); +void wdRect(double xmin, double xmax, double ymin, double ymax); +void wdBox(double xmin, double xmax, double ymin, double ymax); +void wdArc(double xc, double yc, double w, double h, double angle1, double angle2); +void wdSector(double xc, double yc, double w, double h, double angle1, double angle2); +void wdChord(double xc, double yc, double w, double h, double angle1, double angle2); +void wdText(double x, double y, const char* s); + +void wdPutImageRect(cdImage* image, double x, double y, int xmin, int xmax, int ymin, int ymax); +void wdPutImageRectRGB(int iw, int ih, const unsigned char* r, const unsigned char* g, const unsigned char* b, double x, double y, double w, double h, int xmin, int xmax, int ymin, int ymax); +void wdPutImageRectRGBA(int iw, int ih, const unsigned char* r, const unsigned char* g, const unsigned char* b, const unsigned char* a, double x, double y, double w, double h, int xmin, int xmax, int ymin, int ymax); +void wdPutImageRectMap(int iw, int ih, const unsigned char* index, const long* colors, double x, double y, double w, double h, int xmin, int xmax, int ymin, int ymax); +void wdPutBitmap(cdBitmap* bitmap, double x, double y, double w, double h); + +/* attributes */ +double wdLineWidth(double width); +void wdFont(int type_face, int style, double size); +void wdGetFont(int *type_face, int *style, double *size); +double wdMarkSize(double size); +void wdFontDim(double *max_width, double *height, double *ascent, double *descent); +void wdTextSize(const char* s, double *width, double *height); +void wdTextBox(double x, double y, const char* s, double *xmin, double *xmax, double *ymin, double *ymax); +void wdTextBounds(double x, double y, const char* s, double *rect); +void wdStipple(int w, int h, const unsigned char* stipple, double w_mm, double h_mm); +void wdPattern(int w, int h, const long* pattern, double w_mm, double h_mm); + +/* vector text */ +void wdVectorTextDirection(double x1, double y1, double x2, double y2); +void wdVectorTextSize(double size_x, double size_y, const char* s); +void wdGetVectorTextSize(const char* s, double *x, double *y); +double wdVectorCharSize(double size); +void wdVectorText(double x, double y, const char* s); +void wdMultiLineVectorText(double x, double y, const char* s); +void wdGetVectorTextBounds(const char* s, double x, double y, double *rect); + +/* OLD definitions, defined for backward compatibility */ +#define wdVectorFont cdVectorFont +#define wdVectorTextTransform cdVectorTextTransform +#define wdActivate cdActivate +#define wdClip(mode) cdClip(mode) +#define wdBegin(mode) cdBegin(mode) +#define wdEnd() cdEnd(); +#define wdMM2Pixel(mm_dx, mm_dy, dx, dy) cdMM2Pixel(mm_dx, mm_dy, dx, dy) +#define wdPixel2MM(dx, dy, mm_dx, mm_dy) cdPixel2MM(dx, dy, mm_dx, mm_dy) + +#ifdef __cplusplus +} +#endif + +#endif -- cgit v1.2.3