Fixed WM_GETTEXTLENGTH handling.
[wine/multimedia.git] / graphics / win16drv / graphics.c
bloba3f3a71071df90eb870494b3cbdcf72b2ce8cfaa
1 /*
2 * Windows 16 bit device driver graphics functions
4 * Copyright 1997 John Harvey
5 */
7 #include <stdio.h>
8 #include "heap.h"
9 #include "win16drv.h"
10 #include "debugtools.h"
12 DEFAULT_DEBUG_CHANNEL(win16drv);
14 /***********************************************************************
15 * WIN16DRV_LineTo
17 BOOL
18 WIN16DRV_LineTo( DC *dc, INT x, INT y )
20 BOOL bRet ;
21 WIN16DRV_PDEVICE *physDev = (WIN16DRV_PDEVICE *)dc->physDev;
22 POINT16 points[2];
23 points[0].x = dc->DCOrgX + XLPTODP( dc, dc->CursPosX );
24 points[0].y = dc->DCOrgY + YLPTODP( dc, dc->CursPosY );
25 points[1].x = dc->DCOrgX + XLPTODP( dc, x );
26 points[1].y = dc->DCOrgY + YLPTODP( dc, y );
27 bRet = PRTDRV_Output(physDev->segptrPDEVICE,
28 OS_POLYLINE, 2, points,
29 physDev->PenInfo,
30 NULL,
31 win16drv_SegPtr_DrawMode, dc->hClipRgn);
33 dc->CursPosX = x;
34 dc->CursPosY = y;
35 return TRUE;
39 /***********************************************************************
40 * WIN16DRV_Rectangle
42 BOOL
43 WIN16DRV_Rectangle(DC *dc, INT left, INT top, INT right, INT bottom)
45 WIN16DRV_PDEVICE *physDev = (WIN16DRV_PDEVICE *)dc->physDev;
46 BOOL bRet = 0;
47 POINT16 points[2];
49 TRACE("In WIN16DRV_Rectangle, x %d y %d DCOrgX %d y %d\n",
50 left, top, dc->DCOrgX, dc->DCOrgY);
51 TRACE("In WIN16DRV_Rectangle, VPortOrgX %d y %d\n",
52 dc->vportOrgX, dc->vportOrgY);
53 points[0].x = XLPTODP(dc, left);
54 points[0].y = YLPTODP(dc, top);
56 points[1].x = XLPTODP(dc, right);
57 points[1].y = YLPTODP(dc, bottom);
58 bRet = PRTDRV_Output(physDev->segptrPDEVICE,
59 OS_RECTANGLE, 2, points,
60 physDev->PenInfo,
61 physDev->BrushInfo,
62 win16drv_SegPtr_DrawMode, dc->hClipRgn);
63 return bRet;
69 /***********************************************************************
70 * WIN16DRV_Polygon
72 BOOL
73 WIN16DRV_Polygon(DC *dc, const POINT* pt, INT count )
75 WIN16DRV_PDEVICE *physDev = (WIN16DRV_PDEVICE *)dc->physDev;
76 BOOL bRet = 0;
77 LPPOINT16 points;
78 int i;
80 if(count < 2) return TRUE;
81 if(pt[0].x != pt[count-1].x || pt[0].y != pt[count-1].y)
82 count++; /* Ensure polygon is closed */
84 points = HeapAlloc( GetProcessHeap(), 0, count * sizeof(POINT16) );
85 if(points == NULL) return FALSE;
87 for (i = 0; i < count - 1; i++)
89 points[i].x = XLPTODP( dc, pt[i].x );
90 points[i].y = YLPTODP( dc, pt[i].y );
92 points[count-1].x = points[0].x;
93 points[count-1].y = points[0].y;
94 bRet = PRTDRV_Output(physDev->segptrPDEVICE,
95 OS_WINDPOLYGON, count, points,
96 physDev->PenInfo,
97 physDev->BrushInfo,
98 win16drv_SegPtr_DrawMode, dc->hClipRgn);
99 HeapFree( GetProcessHeap(), 0, points );
100 return bRet;
104 /***********************************************************************
105 * WIN16DRV_Polyline
107 BOOL
108 WIN16DRV_Polyline(DC *dc, const POINT* pt, INT count )
110 WIN16DRV_PDEVICE *physDev = (WIN16DRV_PDEVICE *)dc->physDev;
111 BOOL bRet = 0;
112 LPPOINT16 points;
113 int i;
115 if(count < 2) return TRUE;
117 points = HeapAlloc( GetProcessHeap(), 0, count * sizeof(POINT16) );
118 if(points == NULL) return FALSE;
120 for (i = 0; i < count; i++)
122 points[i].x = XLPTODP( dc, pt[i].x );
123 points[i].y = YLPTODP( dc, pt[i].y );
125 bRet = PRTDRV_Output(physDev->segptrPDEVICE,
126 OS_POLYLINE, count, points,
127 physDev->PenInfo,
128 NULL,
129 win16drv_SegPtr_DrawMode, dc->hClipRgn);
130 HeapFree( GetProcessHeap(), 0, points );
131 return bRet;
136 /***********************************************************************
137 * WIN16DRV_Ellipse
139 BOOL
140 WIN16DRV_Ellipse(DC *dc, INT left, INT top, INT right, INT bottom)
142 WIN16DRV_PDEVICE *physDev = (WIN16DRV_PDEVICE *)dc->physDev;
143 BOOL bRet = 0;
144 POINT16 points[2];
145 TRACE("In WIN16DRV_Ellipse, x %d y %d DCOrgX %d y %d\n",
146 left, top, dc->DCOrgX, dc->DCOrgY);
147 TRACE("In WIN16DRV_Ellipse, VPortOrgX %d y %d\n",
148 dc->vportOrgX, dc->vportOrgY);
149 points[0].x = XLPTODP(dc, left);
150 points[0].y = YLPTODP(dc, top);
152 points[1].x = XLPTODP(dc, right);
153 points[1].y = YLPTODP(dc, bottom);
155 bRet = PRTDRV_Output(physDev->segptrPDEVICE,
156 OS_ELLIPSE, 2, points,
157 physDev->PenInfo,
158 physDev->BrushInfo,
159 win16drv_SegPtr_DrawMode, dc->hClipRgn);
160 return bRet;