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