Release 971101
[wine] / graphics / win16drv / graphics.c
1 /*
2  * Windows 16 bit device driver graphics functions
3  *
4  * Copyright 1997 John Harvey
5  */
6
7 #include "heap.h"
8 #include "win16drv.h"
9
10 /**********************************************************************
11  *           WIN16DRV_MoveToEx
12  */
13 BOOL32
14 WIN16DRV_MoveToEx(DC *dc,INT32 x,INT32 y,LPPOINT32 pt) 
15 {
16     if (pt)
17     {
18         pt->x = dc->w.CursPosX;
19         pt->y = dc->w.CursPosY;
20     }
21     dc->w.CursPosX = x;
22     dc->w.CursPosY = y;
23     return TRUE;
24 }
25
26 /***********************************************************************
27  *           WIN16DRV_LineTo
28  */
29 BOOL32
30 WIN16DRV_LineTo( DC *dc, INT32 x, INT32 y )
31 {
32     BOOL32 bRet ;
33     WIN16DRV_PDEVICE *physDev = (WIN16DRV_PDEVICE *)dc->physDev;
34     POINT16 points[2];
35     points[0].x = dc->w.DCOrgX + XLPTODP( dc, dc->w.CursPosX );
36     points[0].y = dc->w.DCOrgY + YLPTODP( dc, dc->w.CursPosY );
37     points[1].x = dc->w.DCOrgX + XLPTODP( dc, x );
38     points[1].y = dc->w.DCOrgY + YLPTODP( dc, y );
39     bRet = PRTDRV_Output(physDev->segptrPDEVICE,
40                          OS_POLYLINE, 2, points, 
41                          physDev->segptrPenInfo,
42                          NULL,
43                          win16drv_SegPtr_DrawMode, NULL);
44
45     dc->w.CursPosX = x;
46     dc->w.CursPosY = y;
47     return TRUE;
48 }
49
50
51 /***********************************************************************
52  *           WIN16DRV_Rectangle
53  */
54 BOOL32
55 WIN16DRV_Rectangle(DC *dc, INT32 left, INT32 top, INT32 right, INT32 bottom)
56 {
57     WIN16DRV_PDEVICE *physDev = (WIN16DRV_PDEVICE *)dc->physDev;
58     BOOL32 bRet = 0;
59     POINT16 points[2];
60     printf("In WIN16drv_Rectangle, x %d y %d DCOrgX %d y %d\n",
61            left, top, dc->w.DCOrgX, dc->w.DCOrgY);
62     printf("In WIN16drv_Rectangle, VPortOrgX %d y %d\n",
63            dc->vportOrgX, dc->vportOrgY);
64     points[0].x = XLPTODP(dc, left);
65     points[0].y = YLPTODP(dc, top);
66
67     points[1].x = XLPTODP(dc, right);
68     points[1].y = YLPTODP(dc, bottom);
69     bRet = PRTDRV_Output(physDev->segptrPDEVICE,
70                          OS_RECTANGLE, 2, points, 
71                          physDev->segptrPenInfo,
72                          physDev->segptrBrushInfo,
73                          win16drv_SegPtr_DrawMode, NULL);
74     return bRet;
75 }
76
77
78
79
80 /***********************************************************************
81  *           WIN16DRV_Polygon
82  */
83 BOOL32
84 WIN16DRV_Polygon(DC *dc, LPPOINT32 pt, INT32 count )
85 {
86     WIN16DRV_PDEVICE *physDev = (WIN16DRV_PDEVICE *)dc->physDev;
87     BOOL32 bRet = 0;
88     LPPOINT16 points;
89     int i;
90     points = HEAP_xalloc( GetProcessHeap(), 0, count * sizeof(POINT16) );
91     for (i = 0; i<count ; i++)
92     {
93       points[i].x = ((pt[i].x - dc->wndOrgX) * dc->vportExtX/ dc->wndExtX) + dc->vportOrgX;
94       points[i].y = ((pt[i].y - dc->wndOrgY) * dc->vportExtY/ dc->wndExtY) + dc->vportOrgY;
95     }
96     bRet = PRTDRV_Output(physDev->segptrPDEVICE,
97                          OS_WINDPOLYGON, 2, points, 
98                          physDev->segptrPenInfo,
99                          physDev->segptrBrushInfo,
100                          win16drv_SegPtr_DrawMode, NULL);
101     HeapFree( GetProcessHeap(), 0, points );
102     return bRet;
103 }