-Fixed MESSAGE functions that were thunking down to 16 bits implementation.
[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 "gdi.h"
9 #include "dc.h"
10 #include "metafile.h"
11 #include "region.h"
12 #include "xmalloc.h"
13 #include "metafiledrv.h"
14 #include "debug.h"
15
16 /**********************************************************************
17  *           MFDRV_MoveToEx
18  */
19 BOOL32
20 MFDRV_MoveToEx(DC *dc,INT32 x,INT32 y,LPPOINT32 pt)
21 {
22     if (!MF_MetaParam2(dc,META_MOVETO,x,y))
23         return FALSE;
24
25     if (pt)
26     {
27         pt->x = dc->w.CursPosX;
28         pt->y = dc->w.CursPosY;
29     }
30     dc->w.CursPosX = x;
31     dc->w.CursPosY = y;
32     return TRUE;
33 }
34
35 /***********************************************************************
36  *           MFDRV_LineTo
37  */
38 BOOL32
39 MFDRV_LineTo( DC *dc, INT32 x, INT32 y )
40 {
41      return MF_MetaParam2(dc, META_LINETO, x, y);
42 }
43
44
45 /***********************************************************************
46  *           MFDRV_Arc
47  */
48 BOOL32 
49 MFDRV_Arc( DC *dc, INT32 left, INT32 top, INT32 right, INT32 bottom,
50            INT32 xstart, INT32 ystart, INT32 xend, INT32 yend )
51 {
52      return MF_MetaParam8(dc, META_ARC, left, top, right, bottom,
53                           xstart, ystart, xend, yend);
54 }
55
56
57 /***********************************************************************
58  *           MFDRV_Pie
59  */
60 BOOL32
61 MFDRV_Pie( DC *dc, INT32 left, INT32 top, INT32 right, INT32 bottom,
62            INT32 xstart, INT32 ystart, INT32 xend, INT32 yend )
63 {
64     return MF_MetaParam8(dc, META_PIE, left, top, right, bottom,
65                          xstart, ystart, xend, yend);
66 }
67
68
69 /***********************************************************************
70  *           MFDRV_Chord
71  */
72 BOOL32
73 MFDRV_Chord( DC *dc, INT32 left, INT32 top, INT32 right, INT32 bottom,
74              INT32 xstart, INT32 ystart, INT32 xend, INT32 yend )
75 {
76     return MF_MetaParam8(dc, META_CHORD, left, top, right, bottom,
77                          xstart, ystart, xend, yend);
78 }
79
80 /***********************************************************************
81  *           MFDRV_Ellipse
82  */
83 BOOL32
84 MFDRV_Ellipse( DC *dc, INT32 left, INT32 top, INT32 right, INT32 bottom )
85 {
86     return MF_MetaParam4(dc, META_ELLIPSE, left, top, right, bottom);
87 }
88
89 /***********************************************************************
90  *           MFDRV_Rectangle
91  */
92 BOOL32
93 MFDRV_Rectangle(DC *dc, INT32 left, INT32 top, INT32 right, INT32 bottom)
94 {
95     return MF_MetaParam4(dc, META_RECTANGLE, left, top, right, bottom);
96 }
97
98 /***********************************************************************
99  *           MFDRV_RoundRect
100  */
101 BOOL32 
102 MFDRV_RoundRect( DC *dc, INT32 left, INT32 top, INT32 right,
103                  INT32 bottom, INT32 ell_width, INT32 ell_height )
104 {
105     return MF_MetaParam6(dc, META_ROUNDRECT, left, top, right, bottom,
106                          ell_width, ell_height);
107 }
108
109 /***********************************************************************
110  *           MFDRV_SetPixel
111  */
112 COLORREF
113 MFDRV_SetPixel( DC *dc, INT32 x, INT32 y, COLORREF color )
114 {
115     return MF_MetaParam4(dc, META_SETPIXEL, x, y,HIWORD(color),LOWORD(color)); 
116 }
117
118
119 /**********************************************************************
120  *          MFDRV_Polyline
121  */
122 BOOL32
123 MFDRV_Polyline( DC *dc, const POINT32* pt, INT32 count )
124 {
125     register int i;
126     LPPOINT16   pt16;
127     BOOL16      ret;
128
129     pt16 = (LPPOINT16)xmalloc(sizeof(POINT16)*count);
130     for (i=count;i--;) CONV_POINT32TO16(&(pt[i]),&(pt16[i]));
131     ret = MF_MetaPoly(dc, META_POLYLINE, pt16, count); 
132
133     free(pt16);
134     return ret;
135 }
136
137
138 /**********************************************************************
139  *          MFDRV_Polygon
140  */
141 BOOL32
142 MFDRV_Polygon( DC *dc, const POINT32* pt, INT32 count )
143 {
144     register int i;
145     LPPOINT16   pt16;
146     BOOL16      ret;
147
148     pt16 = (LPPOINT16)xmalloc(sizeof(POINT16)*count);
149     for (i=count;i--;) CONV_POINT32TO16(&(pt[i]),&(pt16[i]));
150     ret = MF_MetaPoly(dc, META_POLYGON, pt16, count); 
151
152     free(pt16);
153     return ret;
154 }
155
156
157 /**********************************************************************
158  *          PolyPolygon
159  */
160 BOOL32 
161 MFDRV_PolyPolygon( DC *dc, const POINT32* pt, const INT32* counts, UINT32 polygons)
162 {
163     int         i,j;
164     LPPOINT16   pt16;
165     const POINT32* curpt=pt;
166     BOOL32      ret;
167
168     for (i=0;i<polygons;i++) {
169         pt16=(LPPOINT16)xmalloc(sizeof(POINT16)*counts[i]);
170         for (j=counts[i];j--;) CONV_POINT32TO16(&(curpt[j]),&(pt16[j]));
171         ret = MF_MetaPoly(dc, META_POLYGON, pt16, counts[i]);
172         free(pt16);
173         if (!ret)
174             return FALSE;
175         curpt+=counts[i];
176     }
177     return TRUE;
178 }
179
180
181 /**********************************************************************
182  *          MFDRV_ExtFloodFill
183  */
184 BOOL32 
185 MFDRV_ExtFloodFill( DC *dc, INT32 x, INT32 y, COLORREF color, UINT32 fillType )
186 {
187     return MF_MetaParam4(dc,META_FLOODFILL,x,y,HIWORD(color),LOWORD(color)); 
188 }
189
190
191 /**********************************************************************
192  *          MFDRV_PaintRgn
193  */
194 BOOL32
195 MFDRV_PaintRgn( DC *dc, HRGN32 hrgn )
196 {
197     INT16 index;
198     index = MF_CreateRegion( dc, hrgn );
199     if(index == -1)
200         return FALSE;
201     return MF_MetaParam1( dc, META_PAINTREGION, index );
202 }
203
204
205 /**********************************************************************
206  *          MFDRV_SetBkColor
207  */
208 COLORREF
209 MFDRV_SetBkColor( DC *dc, COLORREF color )
210 {
211     return MF_MetaParam2(dc, META_SETBKCOLOR, HIWORD(color), LOWORD(color));
212 }
213
214
215 /**********************************************************************
216  *          MFDRV_SetTextColor
217  */
218 COLORREF
219 MFDRV_SetTextColor( DC *dc, COLORREF color )
220 {
221     return MF_MetaParam2(dc, META_SETTEXTCOLOR, HIWORD(color), LOWORD(color));
222 }
223