Added pBitmapBits and pCreateBitmap to the GDI function table and
[wine] / graphics / psdrv / text.c
1 /*
2  *      PostScript driver text functions
3  *
4  *      Copyright 1998  Huw D M Davies
5  *
6  */
7 #include <string.h>
8 #include "windows.h"
9 #include "psdrv.h"
10 #include "debug.h"
11 #include "print.h"
12
13 /***********************************************************************
14  *           PSDRV_ExtTextOut
15  */
16 BOOL32 PSDRV_ExtTextOut( DC *dc, INT32 x, INT32 y, UINT32 flags,
17                    const RECT32 *lprect, LPCSTR str, UINT32 count,
18                    const INT32 *lpDx )
19 {
20     PSDRV_PDEVICE *physDev = (PSDRV_PDEVICE *)dc->physDev;
21     char *strbuf;
22     SIZE32 sz;
23
24     TRACE(psdrv, "(x=%d, y=%d, flags=0x%08x, str='%s', count=%d)\n", x, y,
25           flags, str, count);
26
27     strbuf = (char *)HeapAlloc( PSDRV_Heap, 0, count + 1);
28     if(!strbuf) {
29         WARN(psdrv, "HeapAlloc failed\n");
30         return FALSE;
31     }
32
33     if(dc->w.textAlign & TA_UPDATECP) {
34         x = dc->w.CursPosX;
35         y = dc->w.CursPosY;
36     }
37
38     x = XLPTODP(dc, x);
39     y = YLPTODP(dc, y);
40
41     GetTextExtentPoint32A(dc->hSelf, str, count, &sz);
42     sz.cx = XLSTODS(dc, sz.cx);
43     sz.cy = YLSTODS(dc, sz.cy);
44
45     switch(dc->w.textAlign & (TA_LEFT | TA_CENTER | TA_RIGHT) ) {
46     case TA_LEFT:
47         if(dc->w.textAlign & TA_UPDATECP)
48             dc->w.CursPosX = XDPTOLP(dc, x + sz.cx);
49         break;
50
51     case TA_CENTER:
52         x -= sz.cx/2;
53         break;
54
55     case TA_RIGHT:
56         x -= sz.cx;
57         if(dc->w.textAlign & TA_UPDATECP)
58             dc->w.CursPosX = XDPTOLP(dc, x);
59         break;
60     }
61
62     switch(dc->w.textAlign & (TA_TOP | TA_BASELINE | TA_BOTTOM) ) {
63     case TA_TOP:
64         y += physDev->font.tm.tmAscent;
65         break;
66
67     case TA_BASELINE:
68         break;
69
70     case TA_BOTTOM:
71         y -= physDev->font.tm.tmDescent;
72         break;
73     }
74
75     memcpy(strbuf, str, count);
76     *(strbuf + count) = '\0';
77     
78     PSDRV_SetFont(dc);
79
80     PSDRV_WriteMoveTo(dc, x, y);
81     PSDRV_WriteShow(dc, strbuf, strlen(strbuf));
82
83     HeapFree(PSDRV_Heap, 0, strbuf);
84     return TRUE;
85 }