Winspool DocumentProperties and DeviceCapabilities should now work on
[wine] / graphics / psdrv / clipping.c
1 /*
2  *      PostScript clipping functions
3  *
4  *      Copyright 1999  Luc Tourangau 
5  *
6  */
7
8 #include "gdi.h"
9 #include "psdrv.h"
10 #include "debugtools.h"
11 #include "winbase.h"
12
13 DEFAULT_DEBUG_CHANNEL(psdrv)
14
15 /***********************************************************************
16  *           PSDRV_SetDeviceClipping
17  */
18 VOID PSDRV_SetDeviceClipping( DC *dc )
19 {
20     CHAR szArrayName[] = "clippath";
21     DWORD size;
22     RGNDATA *rgndata;
23
24     TRACE("hdc=%04x\n", dc->hSelf);
25
26     if (dc->w.hGCClipRgn == 0) {
27         ERR("Rgn is 0. Please report this.\n");
28         return;
29     }
30
31     size = GetRegionData(dc->w.hGCClipRgn, 0, NULL);
32     if(!size) {
33         ERR("Invalid region\n");
34         return;
35     }
36
37     rgndata = HeapAlloc( GetProcessHeap(), 0, size );
38     if(!rgndata) {
39         ERR("Can't allocate buffer\n");
40         return;
41     }
42
43     GetRegionData(dc->w.hGCClipRgn, size, rgndata);
44
45     if (rgndata->rdh.nCount > 0)
46     {
47         INT i;
48         RECT *pRect = (RECT *)rgndata->Buffer;
49
50         PSDRV_WriteArrayDef(dc, szArrayName, rgndata->rdh.nCount * 4);
51
52         for (i = 0; i < rgndata->rdh.nCount; i++, pRect++)
53         {
54             PSDRV_WriteArrayPut(dc, szArrayName, i * 4,
55                                 pRect->left);
56             PSDRV_WriteArrayPut(dc, szArrayName, i * 4 + 1,
57                                 pRect->top);
58             PSDRV_WriteArrayPut(dc, szArrayName, i * 4 + 2, 
59                                 pRect->right - pRect->left);
60             PSDRV_WriteArrayPut(dc, szArrayName, i * 4 + 3, 
61                                 pRect->bottom - pRect->top);
62         }
63     }
64     
65     PSDRV_WriteRectClip(dc, szArrayName);
66     HeapFree( GetProcessHeap(), 0, rgndata );
67     return;
68 }