Framework for the doppler effect.
[wine] / graphics / escape.c
1 /*
2  * Escape() function.
3  *
4  * Copyright 1994  Bob Amstadt
5  * Copyright 2001  Alexandre Julliard
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20  */
21
22 #include <string.h>
23 #include "windef.h"
24 #include "wingdi.h"
25 #include "gdi.h"
26 #include "wine/debug.h"
27
28 WINE_DEFAULT_DEBUG_CHANNEL(driver);
29
30
31 /************************************************************************
32  *             Escape  [GDI32.@]
33  */
34 INT WINAPI Escape( HDC hdc, INT escape, INT in_count, LPCSTR in_data, LPVOID out_data )
35 {
36     INT ret;
37     POINT *pt;
38
39     switch (escape)
40     {
41     case ABORTDOC:
42         return AbortDoc( hdc );
43
44     case ENDDOC:
45         return EndDoc( hdc );
46
47     case GETPHYSPAGESIZE:
48         pt = out_data;
49         pt->x = GetDeviceCaps( hdc, PHYSICALWIDTH );
50         pt->y = GetDeviceCaps( hdc, PHYSICALHEIGHT );
51         return 1;
52
53     case GETPRINTINGOFFSET:
54         pt = out_data;
55         pt->x = GetDeviceCaps( hdc, PHYSICALOFFSETX );
56         pt->y = GetDeviceCaps( hdc, PHYSICALOFFSETY );
57         return 1;
58
59     case GETSCALINGFACTOR:
60         pt = out_data;
61         pt->x = GetDeviceCaps( hdc, SCALINGFACTORX );
62         pt->y = GetDeviceCaps( hdc, SCALINGFACTORY );
63         return 1;
64
65     case NEWFRAME:
66         return EndPage( hdc );
67
68     case SETABORTPROC:
69         return SetAbortProc( hdc, (ABORTPROC)in_data );
70
71     case STARTDOC:
72         {
73             DOCINFOA doc;
74             char *name = NULL;
75
76             /* in_data may not be 0 terminated so we must copy it */
77             if (in_data)
78             {
79                 name = HeapAlloc( GetProcessHeap(), 0, in_count+1 );
80                 memcpy( name, in_data, in_count );
81                 name[in_count] = 0;
82             }
83             /* out_data is actually a pointer to the DocInfo structure and used as
84              * a second input parameter */
85             if (out_data) doc = *(DOCINFOA *)out_data;
86             else
87             {
88                 doc.cbSize = sizeof(doc);
89                 doc.lpszOutput = NULL;
90                 doc.lpszDatatype = NULL;
91                 doc.fwType = 0;
92             }
93             doc.lpszDocName = name;
94             ret = StartDocA( hdc, &doc );
95             if (name) HeapFree( GetProcessHeap(), 0, name );
96             if (ret > 0) ret = StartPage( hdc );
97             return ret;
98         }
99
100     case QUERYESCSUPPORT:
101         {
102             INT *ptr = (INT *)in_data;
103             if (in_count < sizeof(INT)) return 0;
104             switch(*ptr)
105             {
106             case ABORTDOC:
107             case ENDDOC:
108             case GETPHYSPAGESIZE:
109             case GETPRINTINGOFFSET:
110             case GETSCALINGFACTOR:
111             case NEWFRAME:
112             case QUERYESCSUPPORT:
113             case SETABORTPROC:
114             case STARTDOC:
115                 return TRUE;
116             }
117             break;
118         }
119     }
120
121     /* if not handled internally, pass it to the driver */
122     return ExtEscape( hdc, escape, in_count, in_data, 0, out_data );
123 }
124
125
126 /******************************************************************************
127  *              ExtEscape       [GDI32.@]
128  *
129  * PARAMS
130  *    hdc         [I] Handle to device context
131  *    nEscape     [I] Escape function
132  *    cbInput     [I] Number of bytes in input structure
133  *    lpszInData  [I] Pointer to input structure
134  *    cbOutput    [I] Number of bytes in output structure
135  *    lpszOutData [O] Pointer to output structure
136  *
137  * RETURNS
138  *    Success: >0
139  *    Not implemented: 0
140  *    Failure: <0
141  */
142 INT WINAPI ExtEscape( HDC hdc, INT nEscape, INT cbInput, LPCSTR lpszInData,
143                       INT cbOutput, LPSTR lpszOutData )
144 {
145     INT ret = 0;
146     DC * dc = DC_GetDCPtr( hdc );
147     if (dc)
148     {
149         if (dc->funcs->pExtEscape)
150             ret = dc->funcs->pExtEscape( dc->physDev, nEscape, cbInput, lpszInData, cbOutput, lpszOutData );
151         GDI_ReleaseObj( hdc );
152     }
153     return ret;
154 }
155
156
157 /*******************************************************************
158  *      DrawEscape [GDI32.@]
159  *
160  *
161  */
162 INT WINAPI DrawEscape(HDC hdc, INT nEscape, INT cbInput, LPCSTR lpszInData)
163 {
164     FIXME("DrawEscape, stub\n");
165     return 0;
166 }