Release 980315
[wine/multimedia.git] / graphics / win16drv / text.c
blob609ecaf0a282879e196a5b75326fe37ac00a236d
1 /*
2 * win16 driver text functions
4 * Copyright 1996 John Harvey
5 * 1998 Huw Davies
6 */
8 #include <stdlib.h>
9 #include "windows.h"
10 #include "win16drv.h"
11 #include "dc.h"
12 #include "gdi.h"
13 #include "debug.h"
15 /***********************************************************************
16 * WIN16DRV_ExtTextOut
18 BOOL32 WIN16DRV_ExtTextOut( DC *dc, INT32 x, INT32 y, UINT32 flags,
19 const RECT32 *lprect, LPCSTR str, UINT32 count,
20 const INT32 *lpDx )
22 WIN16DRV_PDEVICE *physDev = (WIN16DRV_PDEVICE *)dc->physDev;
23 BOOL32 bRet = 1;
24 RECT16 clipRect;
25 RECT16 opaqueRect;
26 RECT16 *lpOpaqueRect = NULL;
27 WORD wOptions = 0;
28 WORD wCount = count;
29 INT16 width;
31 if (count == 0)
32 return FALSE;
34 TRACE(win16drv, "%04x %d %d %x %p %*s %p\n",
35 dc->hSelf, x, y, flags, lprect, count > 0 ? count : 8, str, lpDx);
38 if (dc != NULL)
40 DWORD dwRet;
42 clipRect.left = 0;
43 clipRect.top = 0;
45 clipRect.right = dc->w.devCaps->horzRes;
46 clipRect.bottom = dc->w.devCaps->vertRes;
47 if (lprect)
49 opaqueRect.left = lprect->left;
50 opaqueRect.top = lprect->top;
51 opaqueRect.right = lprect->right;
52 opaqueRect.bottom = lprect->bottom;
53 lpOpaqueRect = &opaqueRect;
57 TRACE(win16drv, "textalign = %d\n", dc->w.textAlign);
59 if (dc->w.textAlign & TA_UPDATECP)
61 x = dc->w.CursPosX;
62 y = dc->w.CursPosY;
65 x = XLPTODP( dc, x );
66 y = YLPTODP( dc, y );
68 dwRet = PRTDRV_ExtTextOut(physDev->segptrPDEVICE, 0, 0,
69 NULL, str, -count, physDev->FontInfo,
70 win16drv_SegPtr_DrawMode, win16drv_SegPtr_TextXForm,
71 NULL, NULL, 0);
73 width = LOWORD(dwRet);
75 switch( dc->w.textAlign & (TA_LEFT | TA_RIGHT | TA_CENTER) )
77 case TA_LEFT:
78 if (dc->w.textAlign & TA_UPDATECP)
79 dc->w.CursPosX = XDPTOLP( dc, x + width );
80 break;
81 case TA_RIGHT:
82 x -= width;
83 if (dc->w.textAlign & TA_UPDATECP)
84 dc->w.CursPosX = XDPTOLP( dc, x );
85 break;
86 case TA_CENTER:
87 x -= width / 2;
88 break;
91 switch( dc->w.textAlign & (TA_TOP | TA_BOTTOM | TA_BASELINE) )
93 case TA_TOP:
94 break;
95 case TA_BOTTOM:
96 y -= physDev->FontInfo->dfPixHeight;
97 break;
98 case TA_BASELINE:
99 y -= physDev->FontInfo->dfAscent;
100 break;
103 dwRet = PRTDRV_ExtTextOut(physDev->segptrPDEVICE,
104 x, y, &clipRect, str, wCount,
105 physDev->FontInfo, win16drv_SegPtr_DrawMode,
106 win16drv_SegPtr_TextXForm, NULL, lpOpaqueRect, wOptions);
108 return bRet;