escape.c 4.64 KB
Newer Older
Alexandre Julliard's avatar
Alexandre Julliard committed
1 2 3 4
/*
 * Escape() function.
 *
 * Copyright 1994  Bob Amstadt
5
 * Copyright 2001  Alexandre Julliard
6 7 8 9 10 11 12 13 14 15 16 17 18 19
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
Alexandre Julliard's avatar
Alexandre Julliard committed
20
 */
Alexandre Julliard's avatar
Alexandre Julliard committed
21

22
#include <string.h>
23
#include "windef.h"
24
#include "wingdi.h"
Alexandre Julliard's avatar
Alexandre Julliard committed
25
#include "gdi.h"
26
#include "wine/debug.h"
Alexandre Julliard's avatar
Alexandre Julliard committed
27

28
WINE_DEFAULT_DEBUG_CHANNEL(driver);
29

30

31 32 33 34 35 36 37
/************************************************************************
 *             Escape  [GDI32.@]
 */
INT WINAPI Escape( HDC hdc, INT escape, INT in_count, LPCSTR in_data, LPVOID out_data )
{
    INT ret;
    POINT *pt;
38

39 40 41 42
    switch (escape)
    {
    case ABORTDOC:
        return AbortDoc( hdc );
43

44 45
    case ENDDOC:
        return EndDoc( hdc );
46

47 48 49 50 51
    case GETPHYSPAGESIZE:
        pt = out_data;
        pt->x = GetDeviceCaps( hdc, PHYSICALWIDTH );
        pt->y = GetDeviceCaps( hdc, PHYSICALHEIGHT );
        return 1;
52

53 54 55 56 57
    case GETPRINTINGOFFSET:
        pt = out_data;
        pt->x = GetDeviceCaps( hdc, PHYSICALOFFSETX );
        pt->y = GetDeviceCaps( hdc, PHYSICALOFFSETY );
        return 1;
58

Alexandre Julliard's avatar
Alexandre Julliard committed
59
    case GETSCALINGFACTOR:
60 61 62 63
        pt = out_data;
        pt->x = GetDeviceCaps( hdc, SCALINGFACTORX );
        pt->y = GetDeviceCaps( hdc, SCALINGFACTORY );
        return 1;
64

65 66
    case NEWFRAME:
        return EndPage( hdc );
Alexandre Julliard's avatar
Alexandre Julliard committed
67

68 69
    case SETABORTPROC:
        return SetAbortProc( hdc, (ABORTPROC)in_data );
70

71 72 73 74
    case STARTDOC:
        {
            DOCINFOA doc;
            char *name = NULL;
75

76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118
            /* in_data may not be 0 terminated so we must copy it */
            if (in_data)
            {
                name = HeapAlloc( GetProcessHeap(), 0, in_count+1 );
                memcpy( name, in_data, in_count );
                name[in_count] = 0;
            }
            /* out_data is actually a pointer to the DocInfo structure and used as
             * a second input parameter */
            if (out_data) doc = *(DOCINFOA *)out_data;
            else
            {
                doc.cbSize = sizeof(doc);
                doc.lpszOutput = NULL;
                doc.lpszDatatype = NULL;
                doc.fwType = 0;
            }
            doc.lpszDocName = name;
            ret = StartDocA( hdc, &doc );
            if (name) HeapFree( GetProcessHeap(), 0, name );
            if (ret > 0) ret = StartPage( hdc );
            return ret;
        }

    case QUERYESCSUPPORT:
        {
            INT *ptr = (INT *)in_data;
            if (in_count < sizeof(INT)) return 0;
            switch(*ptr)
            {
            case ABORTDOC:
            case ENDDOC:
            case GETPHYSPAGESIZE:
            case GETPRINTINGOFFSET:
            case GETSCALINGFACTOR:
            case NEWFRAME:
            case QUERYESCSUPPORT:
            case SETABORTPROC:
            case STARTDOC:
                return TRUE;
            }
            break;
        }
Alexandre Julliard's avatar
Alexandre Julliard committed
119
    }
120 121 122

    /* if not handled internally, pass it to the driver */
    return ExtEscape( hdc, escape, in_count, in_data, 0, out_data );
Alexandre Julliard's avatar
Alexandre Julliard committed
123 124
}

125

Alexandre Julliard's avatar
Alexandre Julliard committed
126
/******************************************************************************
127
 *		ExtEscape	[GDI32.@]
Alexandre Julliard's avatar
Alexandre Julliard committed
128 129 130 131 132 133 134 135 136 137 138 139 140 141
 *
 * PARAMS
 *    hdc         [I] Handle to device context
 *    nEscape     [I] Escape function
 *    cbInput     [I] Number of bytes in input structure
 *    lpszInData  [I] Pointer to input structure
 *    cbOutput    [I] Number of bytes in output structure
 *    lpszOutData [O] Pointer to output structure
 *
 * RETURNS
 *    Success: >0
 *    Not implemented: 0
 *    Failure: <0
 */
142 143
INT WINAPI ExtEscape( HDC hdc, INT nEscape, INT cbInput, LPCSTR lpszInData,
                      INT cbOutput, LPSTR lpszOutData )
Alexandre Julliard's avatar
Alexandre Julliard committed
144
{
145 146 147 148 149
    INT ret = 0;
    DC * dc = DC_GetDCPtr( hdc );
    if (dc)
    {
        if (dc->funcs->pExtEscape)
150
            ret = dc->funcs->pExtEscape( dc->physDev, nEscape, cbInput, lpszInData, cbOutput, lpszOutData );
151
        GDI_ReleaseObj( hdc );
Huw D M Davies's avatar
Huw D M Davies committed
152 153
    }
    return ret;
Alexandre Julliard's avatar
Alexandre Julliard committed
154
}
Alexandre Julliard's avatar
Alexandre Julliard committed
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 166
    return 0;
}