Implemented toolbar multirow button layout.
[wine/testsucceed.git] / graphics / win16drv / text.c
blob580a152e0c866be75a8acac4a57dda141351897e
1 /*
2 * win16 driver text functions
4 * Copyright 1996 John Harvey
5 * 1998 Huw Davies
6 */
8 #include <stdlib.h>
9 #include "win16drv.h"
10 #include "dc.h"
11 #include "gdi.h"
12 #include "debug.h"
14 DEFAULT_DEBUG_CHANNEL(win16drv)
16 /***********************************************************************
17 * WIN16DRV_ExtTextOut
19 BOOL WIN16DRV_ExtTextOut( DC *dc, INT x, INT y, UINT flags,
20 const RECT *lprect, LPCSTR str, UINT count,
21 const INT *lpDx )
23 WIN16DRV_PDEVICE *physDev = (WIN16DRV_PDEVICE *)dc->physDev;
24 BOOL bRet = 1;
25 RECT16 clipRect;
26 RECT16 opaqueRect;
27 RECT16 *lpOpaqueRect = NULL;
28 WORD wOptions = 0;
29 WORD wCount = count;
30 INT16 width;
32 if (count == 0)
33 return FALSE;
35 TRACE(win16drv, "%04x %d %d %x %p %*s %p\n",
36 dc->hSelf, x, y, flags, lprect, count > 0 ? count : 8, str, lpDx);
39 if (dc != NULL)
41 DWORD dwRet;
43 clipRect.left = 0;
44 clipRect.top = 0;
46 clipRect.right = dc->w.devCaps->horzRes;
47 clipRect.bottom = dc->w.devCaps->vertRes;
48 if (lprect)
50 opaqueRect.left = lprect->left;
51 opaqueRect.top = lprect->top;
52 opaqueRect.right = lprect->right;
53 opaqueRect.bottom = lprect->bottom;
54 lpOpaqueRect = &opaqueRect;
58 TRACE(win16drv, "textalign = %d\n", dc->w.textAlign);
60 if (dc->w.textAlign & TA_UPDATECP)
62 x = dc->w.CursPosX;
63 y = dc->w.CursPosY;
66 x = XLPTODP( dc, x );
67 y = YLPTODP( dc, y );
69 dwRet = PRTDRV_ExtTextOut(physDev->segptrPDEVICE, 0, 0,
70 NULL, str, -count, physDev->FontInfo,
71 win16drv_SegPtr_DrawMode, win16drv_SegPtr_TextXForm,
72 NULL, NULL, 0);
74 width = LOWORD(dwRet);
76 switch( dc->w.textAlign & (TA_LEFT | TA_RIGHT | TA_CENTER) )
78 case TA_LEFT:
79 if (dc->w.textAlign & TA_UPDATECP)
80 dc->w.CursPosX = XDPTOLP( dc, x + width );
81 break;
82 case TA_RIGHT:
83 x -= width;
84 if (dc->w.textAlign & TA_UPDATECP)
85 dc->w.CursPosX = XDPTOLP( dc, x );
86 break;
87 case TA_CENTER:
88 x -= width / 2;
89 break;
92 switch( dc->w.textAlign & (TA_TOP | TA_BOTTOM | TA_BASELINE) )
94 case TA_TOP:
95 break;
96 case TA_BOTTOM:
97 y -= physDev->FontInfo->dfPixHeight;
98 break;
99 case TA_BASELINE:
100 y -= physDev->FontInfo->dfAscent;
101 break;
104 dwRet = PRTDRV_ExtTextOut(physDev->segptrPDEVICE,
105 x, y, &clipRect, str, wCount,
106 physDev->FontInfo, win16drv_SegPtr_DrawMode,
107 win16drv_SegPtr_TextXForm, NULL, lpOpaqueRect, wOptions);
109 return bRet;