Close the right window when clicking on a non active window close
[wine/dcerpc.git] / graphics / win16drv / graphics.c
blob9bf8b065f66da1e42be63aad99ad12edf3af1559
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_MoveToEx
17 BOOL
18 WIN16DRV_MoveToEx(DC *dc,INT x,INT y,LPPOINT pt)
20 if (pt)
22 pt->x = dc->w.CursPosX;
23 pt->y = dc->w.CursPosY;
25 dc->w.CursPosX = x;
26 dc->w.CursPosY = y;
27 return TRUE;
30 /***********************************************************************
31 * WIN16DRV_LineTo
33 BOOL
34 WIN16DRV_LineTo( DC *dc, INT x, INT y )
36 BOOL bRet ;
37 WIN16DRV_PDEVICE *physDev = (WIN16DRV_PDEVICE *)dc->physDev;
38 POINT16 points[2];
39 points[0].x = dc->w.DCOrgX + XLPTODP( dc, dc->w.CursPosX );
40 points[0].y = dc->w.DCOrgY + YLPTODP( dc, dc->w.CursPosY );
41 points[1].x = dc->w.DCOrgX + XLPTODP( dc, x );
42 points[1].y = dc->w.DCOrgY + YLPTODP( dc, y );
43 bRet = PRTDRV_Output(physDev->segptrPDEVICE,
44 OS_POLYLINE, 2, points,
45 physDev->PenInfo,
46 NULL,
47 win16drv_SegPtr_DrawMode, dc->w.hClipRgn);
49 dc->w.CursPosX = x;
50 dc->w.CursPosY = y;
51 return TRUE;
55 /***********************************************************************
56 * WIN16DRV_Rectangle
58 BOOL
59 WIN16DRV_Rectangle(DC *dc, INT left, INT top, INT right, INT bottom)
61 WIN16DRV_PDEVICE *physDev = (WIN16DRV_PDEVICE *)dc->physDev;
62 BOOL bRet = 0;
63 POINT16 points[2];
65 TRACE("In WIN16DRV_Rectangle, x %d y %d DCOrgX %d y %d\n",
66 left, top, dc->w.DCOrgX, dc->w.DCOrgY);
67 TRACE("In WIN16DRV_Rectangle, VPortOrgX %d y %d\n",
68 dc->vportOrgX, dc->vportOrgY);
69 points[0].x = XLPTODP(dc, left);
70 points[0].y = YLPTODP(dc, top);
72 points[1].x = XLPTODP(dc, right);
73 points[1].y = YLPTODP(dc, bottom);
74 bRet = PRTDRV_Output(physDev->segptrPDEVICE,
75 OS_RECTANGLE, 2, points,
76 physDev->PenInfo,
77 physDev->BrushInfo,
78 win16drv_SegPtr_DrawMode, dc->w.hClipRgn);
79 return bRet;
85 /***********************************************************************
86 * WIN16DRV_Polygon
88 BOOL
89 WIN16DRV_Polygon(DC *dc, const POINT* pt, INT count )
91 WIN16DRV_PDEVICE *physDev = (WIN16DRV_PDEVICE *)dc->physDev;
92 BOOL bRet = 0;
93 LPPOINT16 points;
94 int i;
96 if(count < 2) return TRUE;
97 if(pt[0].x != pt[count-1].x || pt[0].y != pt[count-1].y)
98 count++; /* Ensure polygon is closed */
100 points = HEAP_xalloc( GetProcessHeap(), 0, count * sizeof(POINT16) );
101 for (i = 0; i < count - 1; i++)
103 points[i].x = XLPTODP( dc, pt[i].x );
104 points[i].y = YLPTODP( dc, pt[i].y );
106 points[count-1].x = points[0].x;
107 points[count-1].y = points[0].y;
108 bRet = PRTDRV_Output(physDev->segptrPDEVICE,
109 OS_WINDPOLYGON, count, points,
110 physDev->PenInfo,
111 physDev->BrushInfo,
112 win16drv_SegPtr_DrawMode, dc->w.hClipRgn);
113 HeapFree( GetProcessHeap(), 0, points );
114 return bRet;
118 /***********************************************************************
119 * WIN16DRV_Polyline
121 BOOL
122 WIN16DRV_Polyline(DC *dc, const POINT* pt, INT count )
124 WIN16DRV_PDEVICE *physDev = (WIN16DRV_PDEVICE *)dc->physDev;
125 BOOL bRet = 0;
126 LPPOINT16 points;
127 int i;
129 if(count < 2) return TRUE;
131 points = HEAP_xalloc( GetProcessHeap(), 0, count * sizeof(POINT16) );
132 for (i = 0; i < count; i++)
134 points[i].x = XLPTODP( dc, pt[i].x );
135 points[i].y = YLPTODP( dc, pt[i].y );
137 bRet = PRTDRV_Output(physDev->segptrPDEVICE,
138 OS_POLYLINE, count, points,
139 physDev->PenInfo,
140 NULL,
141 win16drv_SegPtr_DrawMode, dc->w.hClipRgn);
142 HeapFree( GetProcessHeap(), 0, points );
143 return bRet;
148 /***********************************************************************
149 * WIN16DRV_Ellipse
151 BOOL
152 WIN16DRV_Ellipse(DC *dc, INT left, INT top, INT right, INT bottom)
154 WIN16DRV_PDEVICE *physDev = (WIN16DRV_PDEVICE *)dc->physDev;
155 BOOL bRet = 0;
156 POINT16 points[2];
157 TRACE("In WIN16DRV_Ellipse, x %d y %d DCOrgX %d y %d\n",
158 left, top, dc->w.DCOrgX, dc->w.DCOrgY);
159 TRACE("In WIN16DRV_Ellipse, VPortOrgX %d y %d\n",
160 dc->vportOrgX, dc->vportOrgY);
161 points[0].x = XLPTODP(dc, left);
162 points[0].y = YLPTODP(dc, top);
164 points[1].x = XLPTODP(dc, right);
165 points[1].y = YLPTODP(dc, bottom);
167 bRet = PRTDRV_Output(physDev->segptrPDEVICE,
168 OS_ELLIPSE, 2, points,
169 physDev->PenInfo,
170 physDev->BrushInfo,
171 win16drv_SegPtr_DrawMode, dc->w.hClipRgn);
172 return bRet;