Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

text.c

Go to the documentation of this file.
00001 /****************************** Module Header ******************************\ 00002 * Module Name: text.c 00003 * 00004 * Copyright (c) 1985 - 1999, Microsoft Corporation 00005 * 00006 * This module contains the MessageBox API and related functions. 00007 * 00008 * History: 00009 * 10-01-90 EricK Created. 00010 * 11-20-90 DarrinM Merged in User text APIs. 00011 * 02-07-91 DarrinM Removed TextOut, ExtTextOut, and GetTextExtentPoint stubs. 00012 \***************************************************************************/ 00013 00014 #include "precomp.h" 00015 #pragma hdrstop 00016 00017 BOOL _TextOutW( 00018 HDC hdc, 00019 int x, 00020 int y, 00021 LPCWSTR lp, 00022 UINT cc); 00023 00024 /***************************************************************************\ 00025 * xxxPSMTextOut 00026 * 00027 * Outputs the text and puts and _ below the character with an & 00028 * before it. Note that this routine isn't used for menus since menus 00029 * have their own special one so that it is specialized and faster... 00030 * 00031 * NOTE: A very similar routine (UserLpkPSMTextOut) exists on the client 00032 * side in drawtext.c. Any non-kernel specific changes to this 00033 * routine most likely need to be made in UserLpkPSMTextOut as well. 00034 * 00035 * History: 00036 * 11-13-90 JimA Ported to NT. 00037 * 30-Nov-1992 mikeke Client side version 00038 * 8-Apr-1998 MCostea Added dwFlags 00039 \***************************************************************************/ 00040 00041 void xxxPSMTextOut( 00042 HDC hdc, 00043 int xLeft, 00044 int yTop, 00045 LPWSTR lpsz, 00046 int cch, 00047 DWORD dwFlags) 00048 { 00049 int cx; 00050 LONG textsize, result; 00051 /* 00052 * In the kernel we have a limited amount of stack. So it should be a stack 00053 * variable in user mode and static in kernel mode where it is thread safe 00054 * since we are in the crit section. 00055 */ 00056 static WCHAR achWorkBuffer[255]; 00057 WCHAR *pchOut = achWorkBuffer; 00058 TEXTMETRICW textMetric; 00059 SIZE size; 00060 RECT rc; 00061 COLORREF color; 00062 PTHREADINFO ptiCurrent = PtiCurrentShared(); 00063 00064 if (CALL_LPK(ptiCurrent)) { 00065 /* 00066 * A user mode LPK is installed for layout and shaping. 00067 * Perform callback and return. 00068 */ 00069 UNICODE_STRING ustrStr; 00070 00071 RtlInitUnicodeString(&ustrStr, lpsz); 00072 xxxClientPSMTextOut(hdc, xLeft, yTop, &ustrStr, cch, dwFlags); 00073 return; 00074 } 00075 00076 if (cch > sizeof(achWorkBuffer)/sizeof(WCHAR)) { 00077 pchOut = (WCHAR*)UserAllocPool((cch+1) * sizeof(WCHAR), TAG_RTL); 00078 if (pchOut == NULL) 00079 return; 00080 } 00081 00082 result = GetPrefixCount(lpsz, cch, pchOut, cch); 00083 00084 if (!(dwFlags & DT_PREFIXONLY)) { 00085 _TextOutW(hdc, xLeft, yTop, pchOut, cch - HIWORD(result)); 00086 } 00087 00088 /* 00089 * Any true prefix characters to underline? 00090 */ 00091 if (LOWORD(result) == 0xFFFF || dwFlags & DT_HIDEPREFIX) { 00092 if (pchOut != achWorkBuffer) 00093 UserFreePool(pchOut); 00094 return; 00095 } 00096 00097 if (!_GetTextMetricsW(hdc, &textMetric)) { 00098 textMetric.tmOverhang = 0; 00099 textMetric.tmAscent = 0; 00100 } 00101 00102 /* 00103 * For proportional fonts, find starting point of underline. 00104 */ 00105 if (LOWORD(result) != 0) { 00106 00107 /* 00108 * How far in does underline start (if not at 0th byte.). 00109 */ 00110 GreGetTextExtentW(hdc, (LPWSTR)pchOut, LOWORD(result), &size, GGTE_WIN3_EXTENT); 00111 xLeft += size.cx; 00112 00113 /* 00114 * Adjust starting point of underline if not at first char and there is 00115 * an overhang. (Italics or bold fonts.) 00116 */ 00117 xLeft = xLeft - textMetric.tmOverhang; 00118 } 00119 00120 /* 00121 * Adjust for proportional font when setting the length of the underline and 00122 * height of text. 00123 */ 00124 GreGetTextExtentW(hdc, (LPWSTR)(pchOut + LOWORD(result)), 1, &size, GGTE_WIN3_EXTENT); 00125 textsize = size.cx; 00126 00127 /* 00128 * Find the width of the underline character. Just subtract out the overhang 00129 * divided by two so that we look better with italic fonts. This is not 00130 * going to effect embolded fonts since their overhang is 1. 00131 */ 00132 cx = LOWORD(textsize) - textMetric.tmOverhang / 2; 00133 00134 /* 00135 * Get height of text so that underline is at bottom. 00136 */ 00137 yTop += textMetric.tmAscent + 1; 00138 00139 /* 00140 * Draw the underline using the foreground color. 00141 */ 00142 SetRect(&rc, xLeft, yTop, xLeft+cx, yTop+1); 00143 color = GreSetBkColor(hdc, GreGetTextColor(hdc)); 00144 GreExtTextOutW(hdc, xLeft, yTop, ETO_OPAQUE, &rc, TEXT(""), 0, NULL); 00145 GreSetBkColor(hdc, color); 00146 00147 if (pchOut != achWorkBuffer) { 00148 UserFreePool(pchOut); 00149 } 00150 } 00151

Generated on Sat May 15 19:41:57 2004 for test by doxygen 1.3.7