gdi32: Pass the source/dest visible rectangles to the AlphaBlend driver entry point.
[wine/testsucceed.git] / dlls / wineps.drv / text.c
blobafd01cb00eabc73b5fa2501c31f85f93d1c8a143
1 /*
2 * PostScript driver text functions
4 * Copyright 1998 Huw D M Davies
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 #include <string.h>
21 #include <stdarg.h>
22 #include <stdlib.h>
23 #include <math.h>
25 #include "windef.h"
26 #include "wingdi.h"
27 #include "psdrv.h"
28 #include "wine/debug.h"
30 WINE_DEFAULT_DEBUG_CHANNEL(psdrv);
32 static BOOL PSDRV_Text(PHYSDEV dev, INT x, INT y, UINT flags,
33 LPCWSTR str, UINT count,
34 BOOL bDrawBackground, const INT *lpDx);
36 /***********************************************************************
37 * PSDRV_ExtTextOut
39 BOOL CDECL PSDRV_ExtTextOut( PHYSDEV dev, INT x, INT y, UINT flags,
40 const RECT *lprect, LPCWSTR str, UINT count,
41 const INT *lpDx )
43 PSDRV_PDEVICE *physDev = get_psdrv_dev( dev );
44 BOOL bResult = TRUE;
45 BOOL bClipped = FALSE;
46 BOOL bOpaque = FALSE;
48 TRACE("(x=%d, y=%d, flags=0x%08x, str=%s, count=%d, lpDx=%p)\n", x, y,
49 flags, debugstr_wn(str, count), count, lpDx);
51 if(physDev->job.id == 0) return FALSE;
53 /* write font if not already written */
54 PSDRV_SetFont(dev);
56 PSDRV_SetClip(dev);
58 /* set clipping and/or draw background */
59 if ((flags & (ETO_CLIPPED | ETO_OPAQUE)) && (lprect != NULL))
61 PSDRV_WriteGSave(dev);
62 PSDRV_WriteRectangle(dev, lprect->left, lprect->top, lprect->right - lprect->left,
63 lprect->bottom - lprect->top);
65 if (flags & ETO_OPAQUE)
67 bOpaque = TRUE;
68 PSDRV_WriteGSave(dev);
69 PSDRV_WriteSetColor(dev, &physDev->bkColor);
70 PSDRV_WriteFill(dev);
71 PSDRV_WriteGRestore(dev);
74 if (flags & ETO_CLIPPED)
76 bClipped = TRUE;
77 PSDRV_WriteClip(dev);
80 bResult = PSDRV_Text(dev, x, y, flags, str, count, !(bClipped && bOpaque), lpDx);
81 PSDRV_WriteGRestore(dev);
83 else
85 bResult = PSDRV_Text(dev, x, y, flags, str, count, TRUE, lpDx);
88 PSDRV_ResetClip(dev);
89 return bResult;
92 /***********************************************************************
93 * PSDRV_Text
95 static BOOL PSDRV_Text(PHYSDEV dev, INT x, INT y, UINT flags, LPCWSTR str,
96 UINT count, BOOL bDrawBackground, const INT *lpDx)
98 PSDRV_PDEVICE *physDev = get_psdrv_dev( dev );
99 WORD *glyphs = NULL;
101 if (!count)
102 return TRUE;
104 if(physDev->font.fontloc == Download)
105 glyphs = (LPWORD)str;
107 PSDRV_WriteMoveTo(dev, x, y);
109 if(!lpDx) {
110 if(physDev->font.fontloc == Download)
111 PSDRV_WriteDownloadGlyphShow(dev, glyphs, count);
112 else
113 PSDRV_WriteBuiltinGlyphShow(dev, str, count);
115 else {
116 UINT i;
117 POINT offset = {0, 0};
119 for(i = 0; i < count-1; i++) {
120 if(physDev->font.fontloc == Download)
121 PSDRV_WriteDownloadGlyphShow(dev, glyphs + i, 1);
122 else
123 PSDRV_WriteBuiltinGlyphShow(dev, str + i, 1);
124 if(flags & ETO_PDY)
126 offset.x += lpDx[i * 2];
127 offset.y += lpDx[i * 2 + 1];
129 else
130 offset.x += lpDx[i];
131 PSDRV_WriteMoveTo(dev, x + offset.x, y + offset.y);
133 if(physDev->font.fontloc == Download)
134 PSDRV_WriteDownloadGlyphShow(dev, glyphs + i, 1);
135 else
136 PSDRV_WriteBuiltinGlyphShow(dev, str + i, 1);
139 return TRUE;