Replaced all occurences of SYSMETRICS_xx and sysMetrics[SM_xx] by
[wine] / graphics / escape.c
1 /*
2  * Escape() function.
3  *
4  * Copyright 1994  Bob Amstadt
5  */
6
7 #include <string.h>
8 #include "wingdi.h"
9 #include "gdi.h"
10 #include "heap.h"
11 #include "ldt.h"
12 #include "dc.h"
13 #include "debugtools.h"
14
15 DEFAULT_DEBUG_CHANNEL(driver)
16
17
18 INT16 WINAPI Escape16( HDC16 hdc, INT16 nEscape, INT16 cbInput,
19                        SEGPTR lpszInData, SEGPTR lpvOutData )
20 {
21     DC * dc = DC_GetDCPtr( hdc );
22     if (!dc || !dc->funcs->pEscape) return 0;
23     return dc->funcs->pEscape( dc, nEscape, cbInput, lpszInData, lpvOutData );
24 }
25
26 INT WINAPI Escape( HDC hdc, INT nEscape, INT cbInput,
27                        LPCSTR lpszInData, LPVOID lpvOutData )
28 {
29     DC          *dc = DC_GetDCPtr( hdc );
30     SEGPTR      segin,segout;
31     INT ret;
32
33     if (!dc || !dc->funcs->pEscape) return 0;
34     segin       = (SEGPTR)lpszInData;
35     segout      = (SEGPTR)lpvOutData;
36     switch (nEscape) {
37         /* Escape(hdc,QUERYESCSUPPORT,LPINT,NULL) */
38         /* Escape(hdc,EXT_DEVICE_CAPS,LPINT,NULL) */
39     case QUERYESCSUPPORT:
40     case EXT_DEVICE_CAPS:
41       {
42         LPINT16 x = (LPINT16)SEGPTR_NEW(INT16);
43         *x = *(INT*)lpszInData;
44         segin = SEGPTR_GET(x);
45         break;
46       }
47
48         /* Escape(hdc,GETSCALINGFACTOR,NULL,LPPOINT32) */
49         /* Escape(hdc,GETPHYSPAGESIZE,NULL,LPPOINT32) */
50         /* Escape(hdc,GETPRINTINGOFFSET,NULL,LPPOINT32) */
51
52     case GETSCALINGFACTOR:
53     case GETPHYSPAGESIZE:
54     case GETPRINTINGOFFSET:
55         segout = SEGPTR_GET(SEGPTR_NEW(POINT16));
56         break;
57
58       /* Escape(hdc,GETTECHNOLOGY,NULL,LPSTR); */
59
60     case GETTECHNOLOGY: {
61         segout = SEGPTR_GET(SEGPTR_ALLOC(200)); /* enough I hope */
62         break;
63
64     }
65
66       /* Escape(hdc,ENABLEPAIRKERNING,LPINT16,LPINT16); */
67
68     case ENABLEPAIRKERNING: {
69         LPINT16 enab = SEGPTR_NEW(INT16);
70         segout = SEGPTR_GET(SEGPTR_NEW(INT16));
71         segin = SEGPTR_GET(enab);
72         *enab = *(INT*)lpszInData;
73         break;
74     }
75
76       /* Escape(hdc,GETFACENAME,NULL,LPSTR); */
77
78     case GETFACENAME: {
79         segout = SEGPTR_GET(SEGPTR_ALLOC(200));
80         break;
81     }
82
83       /* Escape(hdc,STARTDOC,LPSTR,NULL); */
84
85     case STARTDOC: /* string may not be \0 terminated */
86         if(lpszInData) {
87             char *cp = SEGPTR_ALLOC(cbInput);
88             memcpy(cp, lpszInData, cbInput);
89             segin = SEGPTR_GET(cp);
90         } else
91             segin = 0;
92         break;
93
94     default:
95         break;
96
97     }
98
99     ret = dc->funcs->pEscape( dc, nEscape, cbInput, segin, segout );
100
101     switch(nEscape) {
102     case QUERYESCSUPPORT:
103         if (ret)
104                 TRACE("target DC implements Escape %d\n",nEscape);
105         SEGPTR_FREE(PTR_SEG_TO_LIN(segin));
106         break;
107     case EXT_DEVICE_CAPS:
108         SEGPTR_FREE(PTR_SEG_TO_LIN(segin));
109         break;
110     case GETSCALINGFACTOR:
111     case GETPRINTINGOFFSET:
112     case GETPHYSPAGESIZE: {
113         LPPOINT16 x = (LPPOINT16)PTR_SEG_TO_LIN(segout);
114         CONV_POINT16TO32(x,(LPPOINT)lpvOutData);
115         SEGPTR_FREE(x);
116         break;
117     }
118     case GETTECHNOLOGY: {
119         LPSTR x=PTR_SEG_TO_LIN(segout);
120         lstrcpyA(lpvOutData,x);
121         SEGPTR_FREE(x);
122         break;
123     }
124     case ENABLEPAIRKERNING: {
125         LPINT16 enab = (LPINT16)PTR_SEG_TO_LIN(segout);
126
127         *(LPINT)lpvOutData = *enab;
128         SEGPTR_FREE(enab);
129         SEGPTR_FREE(PTR_SEG_TO_LIN(segin));
130         break;
131     }
132     case GETFACENAME: {
133         LPSTR x = (LPSTR)PTR_SEG_TO_LIN(segout);
134         lstrcpyA(lpvOutData,x);
135         SEGPTR_FREE(x);
136         break;
137     }
138     case STARTDOC:
139         SEGPTR_FREE(PTR_SEG_TO_LIN(segin));
140         break;
141
142     default:
143         break;
144     }
145     return ret;
146 }
147
148 /******************************************************************************
149  *              ExtEscape       [GDI32.95]
150  *
151  * PARAMS
152  *    hdc         [I] Handle to device context
153  *    nEscape     [I] Escape function
154  *    cbInput     [I] Number of bytes in input structure
155  *    lpszInData  [I] Pointer to input structure
156  *    cbOutput    [I] Number of bytes in output structure
157  *    lpszOutData [O] Pointer to output structure
158  *
159  * RETURNS
160  *    Success: >0
161  *    Not implemented: 0
162  *    Failure: <0
163  */
164 INT WINAPI ExtEscape( HDC hdc, INT nEscape, INT cbInput, 
165                         LPCSTR lpszInData, INT cbOutput, LPSTR lpszOutData )
166 {
167     FIXME("(0x%04x,0x%x,%d,%s,%d,%p):stub\n",
168           hdc,nEscape,cbInput,debugstr_a(lpszInData),cbOutput,lpszOutData);
169     return 0;
170 }
171
172 /*******************************************************************
173  *      DrawEscape [GDI32.74]
174  *
175  *
176  */
177 INT WINAPI DrawEscape(HDC hdc, INT nEscape, INT cbInput, LPCSTR lpszInData)
178 {
179     FIXME("DrawEscape, stub\n");
180     return 0;
181 }