Release 970112
[wine] / graphics / metafiledrv / graphics.c
1 /*
2  * Metafile driver graphics functions
3  *
4  * Copyright 1993, 1994 Alexandre Julliard
5  */
6
7 #include <stdlib.h>
8 #include "graphics.h"
9 #include "gdi.h"
10 #include "dc.h"
11 #include "metafile.h"
12 #include "region.h"
13 #include "xmalloc.h"
14 #include "metafiledrv.h"
15 #include "stddebug.h"
16 #include "debug.h"
17
18 /**********************************************************************
19  *           MFDRV_MoveToEx
20  */
21 BOOL32
22 MFDRV_MoveToEx(DC *dc,INT32 x,INT32 y,LPPOINT32 pt)
23 {
24     if (!MF_MetaParam2(dc,META_MOVETO,x,y))
25         return FALSE;
26
27     if (pt)
28     {
29         pt->x = dc->w.CursPosX;
30         pt->y = dc->w.CursPosY;
31     }
32     dc->w.CursPosX = x;
33     dc->w.CursPosY = y;
34     return TRUE;
35 }
36
37 /***********************************************************************
38  *           MFDRV_LineTo
39  */
40 BOOL32
41 MFDRV_LineTo( DC *dc, INT32 x, INT32 y )
42 {
43      return MF_MetaParam2(dc, META_LINETO, x, y);
44 }
45
46
47 /***********************************************************************
48  *           MFDRV_Arc
49  */
50 BOOL32 
51 MFDRV_Arc( DC *dc, INT32 left, INT32 top, INT32 right, INT32 bottom,
52            INT32 xstart, INT32 ystart, INT32 xend, INT32 yend )
53 {
54      return MF_MetaParam8(dc, META_ARC, left, top, right, bottom,
55                           xstart, ystart, xend, yend);
56 }
57
58
59 /***********************************************************************
60  *           MFDRV_Pie
61  */
62 BOOL32
63 MFDRV_Pie( DC *dc, INT32 left, INT32 top, INT32 right, INT32 bottom,
64            INT32 xstart, INT32 ystart, INT32 xend, INT32 yend )
65 {
66     return MF_MetaParam8(dc, META_PIE, left, top, right, bottom,
67                          xstart, ystart, xend, yend);
68 }
69
70
71 /***********************************************************************
72  *           MFDRV_Chord
73  */
74 BOOL32
75 MFDRV_Chord( DC *dc, INT32 left, INT32 top, INT32 right, INT32 bottom,
76              INT32 xstart, INT32 ystart, INT32 xend, INT32 yend )
77 {
78     return MF_MetaParam8(dc, META_CHORD, left, top, right, bottom,
79                          xstart, ystart, xend, yend);
80 }
81
82 /***********************************************************************
83  *           MFDRV_Ellipse
84  */
85 BOOL32
86 MFDRV_Ellipse( DC *dc, INT32 left, INT32 top, INT32 right, INT32 bottom )
87 {
88     return MF_MetaParam4(dc, META_ELLIPSE, left, top, right, bottom);
89 }
90
91 /***********************************************************************
92  *           MFDRV_Rectangle
93  */
94 BOOL32
95 MFDRV_Rectangle(DC *dc, INT32 left, INT32 top, INT32 right, INT32 bottom)
96 {
97     return MF_MetaParam4(dc, META_RECTANGLE, left, top, right, bottom);
98 }
99
100 /***********************************************************************
101  *           MFDRV_RoundRect
102  */
103 BOOL32 
104 MFDRV_RoundRect( DC *dc, INT32 left, INT32 top, INT32 right,
105                  INT32 bottom, INT32 ell_width, INT32 ell_height )
106 {
107     return MF_MetaParam6(dc, META_ROUNDRECT, left, top, right, bottom,
108                          ell_width, ell_height);
109 }
110
111 /***********************************************************************
112  *           MFDRV_SetPixel
113  */
114 COLORREF
115 MFDRV_SetPixel( DC *dc, INT32 x, INT32 y, COLORREF color )
116 {
117     return MF_MetaParam4(dc, META_SETPIXEL, x, y,HIWORD(color),LOWORD(color)); 
118 }
119
120
121 /**********************************************************************
122  *          MFDRV_Polyline
123  */
124 BOOL32
125 MFDRV_Polyline( DC *dc, const LPPOINT32 pt, INT32 count )
126 {
127     register int i;
128     LPPOINT16   pt16;
129     BOOL16      ret;
130
131     pt16 = (LPPOINT16)xmalloc(sizeof(POINT16)*count);
132     for (i=count;i--;) CONV_POINT32TO16(&(pt[i]),&(pt16[i]));
133     ret = MF_MetaPoly(dc, META_POLYLINE, pt16, count); 
134
135     free(pt16);
136     return ret;
137 }
138
139
140 /**********************************************************************
141  *          MFDRV_Polygon
142  */
143 BOOL32
144 MFDRV_Polygon( DC *dc, LPPOINT32 pt, INT32 count )
145 {
146     register int i;
147     LPPOINT16   pt16;
148     BOOL16      ret;
149
150     pt16 = (LPPOINT16)xmalloc(sizeof(POINT16)*count);
151     for (i=count;i--;) CONV_POINT32TO16(&(pt[i]),&(pt16[i]));
152     ret = MF_MetaPoly(dc, META_POLYGON, pt16, count); 
153
154     free(pt16);
155     return ret;
156 }
157
158
159 /**********************************************************************
160  *          PolyPolygon
161  */
162 BOOL32 
163 MFDRV_PolyPolygon( DC *dc, LPPOINT32 pt, LPINT32 counts, UINT32 polygons)
164 {
165     int         i,j;
166     LPPOINT16   pt16;
167     LPPOINT32   curpt=pt;
168     BOOL32      ret;
169
170     for (i=0;i<polygons;i++) {
171         pt16=(LPPOINT16)xmalloc(sizeof(POINT16)*counts[i]);
172         for (j=counts[i];j--;) CONV_POINT32TO16(&(curpt[j]),&(pt16[j]));
173         ret = MF_MetaPoly(dc, META_POLYGON, pt16, counts[i]);
174         free(pt16);
175         if (!ret)
176             return FALSE;
177         curpt+=counts[i];
178     }
179     return TRUE;
180 }
181
182
183 /**********************************************************************
184  *          MFDRV_ExtFloodFill
185  */
186 BOOL32 
187 MFDRV_ExtFloodFill( DC *dc, INT32 x, INT32 y, COLORREF color, UINT32 fillType )
188 {
189     return MF_MetaParam4(dc,META_FLOODFILL,x,y,HIWORD(color),LOWORD(color)); 
190 }