test: kernel/text.c File Reference

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

# text.c File Reference

`#include "precomp.h"`

Go to the source code of this file.

## Functions

BOOL | _TextOutW (HDC hdc, int x, int y, LPCWSTR lp, UINT cc)
void | xxxPSMTextOut (HDC hdc, int xLeft, int yTop, LPWSTR lpsz, int cch, DWORD dwFlags)

## Function Documentation

BOOL _TextOutW | ( | HDC | hdc,
|  | int | x,
|  | int | y,
|  | LPCWSTR | lp,
|  | UINT | cc
| ) |

Definition at line 1201 of file kernel/server.c.

References BOOL, and NULL.

Referenced by xxxPSMTextOut().

    01207 {
    01208     return GreExtTextOutW(hdc, x, y, 0, NULL, (LPWSTR)lp, cc, NULL);
    01209 }

void xxxPSMTextOut | ( | HDC | hdc,
|  | int | xLeft,
|  | int | yTop,
|  | LPWSTR | lpsz,
|  | int | cch,
|  | DWORD | dwFlags
| ) |

Definition at line 41 of file kernel/text.c.

References _GetTextMetricsW(), _TextOutW(), CALL_LPK, dwFlags, GetPrefixCount(), NULL, PtiCurrentShared, RtlInitUnicodeString(), SetRect(), and xxxClientPSMTextOut().

Referenced by DT_InitDrawTextInfo(), xxxDrawMenuBarUnderlines(), xxxDrawMenuItemText(), and xxxRealDrawMenuItem().

    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 }