1 /** \file 2 * \brief Old User API 3 * 4 * See Copyright Notice in cd.h 5 */ 6 7 module cd.old; 8 9 import cd.cd; 10 11 extern (C) @safe nothrow: 12 13 /* canvas control */ 14 int cdActivate(cdCanvas* canvas); 15 cdCanvas* cdActiveCanvas(); 16 int cdSimulate(int mode); 17 void cdFlush(); 18 void cdClear(); 19 cdState* cdSaveState(); 20 void cdRestoreState(cdState* state); 21 void cdSetAttribute(const(char) * name, char* data); 22 void cdSetfAttribute(const(char) * name, const(char) * format, ...); 23 char* cdGetAttribute(const(char) * name); 24 cdContext* cdGetContext(cdCanvas* canvas); 25 26 /* interpretation */ 27 int cdRegisterCallback(cdContext *context, int cb, cdCallback func); 28 int cdPlay(cdContext *context, int xmin, int xmax, int ymin, int ymax, void *data); 29 30 /* coordinate transformation */ 31 void cdGetCanvasSize(int *width, int *height, double *width_mm, double *height_mm); 32 int cdUpdateYAxis(int *y); 33 void cdMM2Pixel(double mm_dx, double mm_dy, int *dx, int *dy); 34 void cdPixel2MM(int dx, int dy, double *mm_dx, double *mm_dy); 35 void cdOrigin(int x, int y); 36 37 /* clipping */ 38 int cdClip(int mode); 39 int * cdGetClipPoly(int *n); 40 void cdClipArea(int xmin, int xmax, int ymin, int ymax); 41 int cdGetClipArea(int *xmin, int *xmax, int *ymin, int *ymax); 42 43 /* clipping region */ 44 int cdPointInRegion(int x, int y); 45 void cdOffsetRegion(int x, int y); 46 void cdRegionBox(int *xmin, int *xmax, int *ymin, int *ymax); 47 int cdRegionCombineMode(int mode); 48 49 /* primitives */ 50 void cdPixel(int x, int y, long color); 51 void cdMark(int x, int y); 52 void cdLine(int x1, int y1, int x2, int y2); 53 void cdBegin(int mode); 54 void cdVertex(int x, int y); 55 void cdEnd(); 56 void cdRect(int xmin, int xmax, int ymin, int ymax); 57 void cdBox(int xmin, int xmax, int ymin, int ymax); 58 void cdArc(int xc, int yc, int w, int h, double angle1, double angle2); 59 void cdSector(int xc, int yc, int w, int h, double angle1, double angle2); 60 void cdChord(int xc, int yc, int w, int h, double angle1, double angle2); 61 void cdText(int x, int y, const(char) * s); 62 63 /* attributes */ 64 long cdBackground(long color); 65 long cdForeground(long color); 66 int cdBackOpacity(int opacity); 67 int cdWriteMode(int mode); 68 int cdLineStyle(int style); 69 void cdLineStyleDashes(const(int) * dashes, int count); 70 int cdLineWidth(int width); 71 int cdLineJoin(int join); 72 int cdLineCap(int cap); 73 int cdInteriorStyle(int style); 74 int cdHatch(int style); 75 void cdStipple(int w, int h, const(ubyte) * stipple); 76 ubyte* cdGetStipple(int *n, int *m); 77 void cdPattern(int w, int h, const(long) *pattern); 78 long* cdGetPattern(int* n, int* m); 79 int cdFillMode(int mode); 80 void cdFont(int type_face, int style, int size); 81 void cdGetFont(int *type_face, int *style, int *size); 82 char* cdNativeFont(const(char) * font); 83 int cdTextAlignment(int alignment); 84 double cdTextOrientation(double angle); 85 int cdMarkType(int type); 86 int cdMarkSize(int size); 87 88 /* vector text */ 89 void cdVectorText(int x, int y, const(char) * s); 90 void cdMultiLineVectorText(int x, int y, const(char) * s); 91 92 /* vector text attributes */ 93 char *cdVectorFont(const(char) *filename); 94 void cdVectorTextDirection(int x1, int y1, int x2, int y2); 95 double* cdVectorTextTransform(const(double) * matrix); 96 void cdVectorTextSize(int size_x, int size_y, const(char) * s); 97 int cdVectorCharSize(int size); 98 99 /* vector text properties */ 100 void cdGetVectorTextSize(const(char) * s, int *x, int *y); 101 void cdGetVectorTextBounds(const(char) * s, int x, int y, int *rect); 102 103 /* properties */ 104 void cdFontDim(int *max_width, int *height, int *ascent, int *descent); 105 void cdTextSize(const(char) * s, int *width, int *height); 106 void cdTextBox(int x, int y, const(char) * s, int *xmin, int *xmax, int *ymin, int *ymax); 107 void cdTextBounds(int x, int y, const(char) * s, int *rect); 108 int cdGetColorPlanes(); 109 110 /* color */ 111 void cdPalette(int n, const(long) * palette, int mode); 112 113 /* client images */ 114 void cdGetImageRGB(ubyte* r, ubyte* g, ubyte* b, int x, int y, int w, int h); 115 void cdPutImageRectRGB(int iw, int ih, const(ubyte) * r, const(ubyte) * g, const(ubyte) * b, int x, int y, int w, int h, int xmin, int xmax, int ymin, int ymax); 116 void cdPutImageRectRGBA(int iw, int ih, const(ubyte) * r, const(ubyte) * g, const(ubyte) * b, const(ubyte) * a, int x, int y, int w, int h, int xmin, int xmax, int ymin, int ymax); 117 void cdPutImageRectMap(int iw, int ih, const(ubyte) * index, const(long) * colors, int x, int y, int w, int h, int xmin, int xmax, int ymin, int ymax); 118 119 /* defined for backward compatibility */ 120 pragma(inline, true) { 121 122 void cdPutImageRGB(int iw, int ih, const(ubyte) * r, const(ubyte) * g, const(ubyte) * b, int x, int y, int w, int h) { 123 cdPutImageRectRGB((iw), (ih), (r), (g), (b), (x), (y), (w), (h), 0, 0, 0, 0); 124 } 125 126 void cdPutImageRGBA(int iw, int ih, const(ubyte) * r, const(ubyte) * g, const(ubyte) * b, const(ubyte) * a, int x, int y, int w, int h) { 127 cdPutImageRectRGBA((iw), (ih), (r), (g), (b), (a), (x), (y), (w), (h), 0, 0, 0, 0); 128 } 129 130 void cdPutImageMap(int iw, int ih, const(ubyte) * index, const(long) * colors, int x, int y, int w, int h) { 131 cdPutImageRectMap((iw), (ih), (index), (colors), (x), (y), (w), (h), 0, 0, 0, 0); 132 } 133 134 void cdPutImage(cdImage* image, int x, int y) { 135 cdPutImageRect((image), (x), (y), 0, 0, 0, 0); 136 } 137 138 } 139 140 /* server images */ 141 cdImage* cdCreateImage(int w, int h); 142 void cdGetImage(cdImage* image, int x, int y); 143 void cdPutImageRect(cdImage* image, int x, int y, int xmin, int xmax, int ymin, int ymax); 144 void cdScrollArea(int xmin, int xmax, int ymin, int ymax, int dx, int dy); 145 146 /* bitmap */ 147 void cdPutBitmap(cdBitmap* bitmap, int x, int y, int w, int h); 148 void cdGetBitmap(cdBitmap* bitmap, int x, int y); 149 150 enum { /* OLD type face -> new names */ 151 CD_SYSTEM, /* "System" */ 152 CD_COURIER, /* "Courier" */ 153 CD_TIMES_ROMAN, /* "Times" */ 154 CD_HELVETICA, /* "Helvetica" */ 155 CD_NATIVE 156 }; 157 158 /* OLD definitions, defined for backward compatibility */ 159 enum CD_CLIPON = CD_CLIPAREA; 160 enum CD_CENTER_BASE = CD_BASE_CENTER; 161 enum CD_LEFT_BASE = CD_BASE_LEFT; 162 enum CD_RIGHT_BASE = CD_BASE_RIGHT; 163 enum CD_ITALIC_BOLD = CD_BOLD_ITALIC; 164 alias cdScrollImage = cdScrollArea; 165 166 pragma(inline, true) 167 void cdCanvas2Raster(T)(T x, int *y) { 168 cdUpdateYAxis(y); 169 } 170