Put the prefix-underline-drawing away into it's own function so we can
see what is happening.
This commit is contained in:
parent
c43985b275
commit
a4605ac000
|
@ -212,6 +212,42 @@ static const WCHAR *TEXT_NextLineW( HDC hdc, const WCHAR *str, int *count,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
* TEXT_DrawUnderscore
|
||||||
|
*
|
||||||
|
* Draw the underline under the prefixed character
|
||||||
|
*
|
||||||
|
* Parameters
|
||||||
|
* hdc [in] The handle of the DC for drawing
|
||||||
|
* x [in] The x location of the line segment (logical coordinates)
|
||||||
|
* y [in] The y location of where the underscore should appear
|
||||||
|
* (logical coordinates)
|
||||||
|
* str [in] The text of the line segment
|
||||||
|
* offset [in] The offset of the underscored character within str
|
||||||
|
*/
|
||||||
|
|
||||||
|
static void TEXT_DrawUnderscore (HDC hdc, int x, int y, const WCHAR *str, int offset)
|
||||||
|
{
|
||||||
|
int prefix_x;
|
||||||
|
int prefix_end;
|
||||||
|
SIZE size;
|
||||||
|
HPEN hpen;
|
||||||
|
HPEN oldPen;
|
||||||
|
|
||||||
|
GetTextExtentPointW (hdc, str, offset, &size);
|
||||||
|
prefix_x = x + size.cx;
|
||||||
|
GetTextExtentPointW (hdc, str, offset+1, &size);
|
||||||
|
prefix_end = x + size.cx - 1;
|
||||||
|
/* The above method may eventually be slightly wrong due to kerning etc. */
|
||||||
|
|
||||||
|
hpen = CreatePen (PS_SOLID, 1, GetTextColor (hdc));
|
||||||
|
oldPen = SelectObject (hdc, hpen);
|
||||||
|
MoveToEx (hdc, prefix_x, y, NULL);
|
||||||
|
LineTo (hdc, prefix_end, y);
|
||||||
|
SelectObject (hdc, oldPen);
|
||||||
|
DeleteObject (hpen);
|
||||||
|
}
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
* DrawTextExW (USER32.@)
|
* DrawTextExW (USER32.@)
|
||||||
*/
|
*/
|
||||||
|
@ -223,8 +259,6 @@ INT WINAPI DrawTextExW( HDC hdc, LPWSTR str, INT i_count,
|
||||||
const WCHAR *strPtr;
|
const WCHAR *strPtr;
|
||||||
static WCHAR line[MAX_STATIC_BUFFER];
|
static WCHAR line[MAX_STATIC_BUFFER];
|
||||||
int len, lh, count=i_count;
|
int len, lh, count=i_count;
|
||||||
int prefix_x = 0;
|
|
||||||
int prefix_end = 0;
|
|
||||||
TEXTMETRICW tm;
|
TEXTMETRICW tm;
|
||||||
int lmargin = 0, rmargin = 0;
|
int lmargin = 0, rmargin = 0;
|
||||||
int x = rect->left, y = rect->top;
|
int x = rect->left, y = rect->top;
|
||||||
|
@ -275,14 +309,6 @@ INT WINAPI DrawTextExW( HDC hdc, LPWSTR str, INT i_count,
|
||||||
len = MAX_STATIC_BUFFER;
|
len = MAX_STATIC_BUFFER;
|
||||||
strPtr = TEXT_NextLineW(hdc, strPtr, &count, line, &len, width, flags);
|
strPtr = TEXT_NextLineW(hdc, strPtr, &count, line, &len, width, flags);
|
||||||
|
|
||||||
if (prefix_offset != -1)
|
|
||||||
{
|
|
||||||
GetTextExtentPointW(hdc, line, prefix_offset, &size);
|
|
||||||
prefix_x = size.cx;
|
|
||||||
GetTextExtentPointW(hdc, line, prefix_offset + 1, &size);
|
|
||||||
prefix_end = size.cx - 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!GetTextExtentPointW(hdc, line, len, &size)) return 0;
|
if (!GetTextExtentPointW(hdc, line, len, &size)) return 0;
|
||||||
if (flags & DT_CENTER) x = (rect->left + rect->right -
|
if (flags & DT_CENTER) x = (rect->left + rect->right -
|
||||||
size.cx) / 2;
|
size.cx) / 2;
|
||||||
|
@ -302,6 +328,7 @@ INT WINAPI DrawTextExW( HDC hdc, LPWSTR str, INT i_count,
|
||||||
WCHAR* fnameDelim = NULL;
|
WCHAR* fnameDelim = NULL;
|
||||||
int totalLen = i_count >= 0 ? i_count : strlenW(str);
|
int totalLen = i_count >= 0 ? i_count : strlenW(str);
|
||||||
int fnameLen = totalLen;
|
int fnameLen = totalLen;
|
||||||
|
int old_prefix_offset = prefix_offset;
|
||||||
|
|
||||||
/* allow room for '...' */
|
/* allow room for '...' */
|
||||||
count = min(totalLen+3, countof(line)-3);
|
count = min(totalLen+3, countof(line)-3);
|
||||||
|
@ -338,6 +365,7 @@ INT WINAPI DrawTextExW( HDC hdc, LPWSTR str, INT i_count,
|
||||||
|
|
||||||
len = MAX_STATIC_BUFFER;
|
len = MAX_STATIC_BUFFER;
|
||||||
TEXT_NextLineW(hdc, swapStr, &count, line, &len, width, flags);
|
TEXT_NextLineW(hdc, swapStr, &count, line, &len, width, flags);
|
||||||
|
prefix_offset = old_prefix_offset;
|
||||||
|
|
||||||
/* if only the ELLIPSIS will fit, just let it be clipped */
|
/* if only the ELLIPSIS will fit, just let it be clipped */
|
||||||
len = max(3, len);
|
len = max(3, len);
|
||||||
|
@ -376,13 +404,15 @@ INT WINAPI DrawTextExW( HDC hdc, LPWSTR str, INT i_count,
|
||||||
line[len] = '\0';
|
line[len] = '\0';
|
||||||
strPtr = NULL;
|
strPtr = NULL;
|
||||||
|
|
||||||
if (flags & DT_MODIFYSTRING)
|
|
||||||
strcpyW(str, swapStr);
|
|
||||||
|
|
||||||
/* Note that really we ought to refigure the location of
|
/* Note that really we ought to refigure the location of
|
||||||
* the underline for the prefix; it might be currently set for
|
* the underline for the prefix; it might be currently set for
|
||||||
* something we have just ellipsified out.
|
* something we have just ellipsified out.
|
||||||
|
* NB We had better do it before modifying the string and
|
||||||
|
* loosing the ampersands
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
if (flags & DT_MODIFYSTRING)
|
||||||
|
strcpyW(str, swapStr);
|
||||||
}
|
}
|
||||||
if (!(flags & DT_CALCRECT))
|
if (!(flags & DT_CALCRECT))
|
||||||
{
|
{
|
||||||
|
@ -391,14 +421,7 @@ INT WINAPI DrawTextExW( HDC hdc, LPWSTR str, INT i_count,
|
||||||
((flags & DT_RTLREADING) ? ETO_RTLREADING : 0),
|
((flags & DT_RTLREADING) ? ETO_RTLREADING : 0),
|
||||||
rect, line, len, NULL )) return 0;
|
rect, line, len, NULL )) return 0;
|
||||||
if (prefix_offset != -1)
|
if (prefix_offset != -1)
|
||||||
{
|
TEXT_DrawUnderscore (hdc, x, y + tm.tmAscent + 1, line, prefix_offset);
|
||||||
HPEN hpen = CreatePen( PS_SOLID, 1, GetTextColor(hdc) );
|
|
||||||
HPEN oldPen = SelectObject( hdc, hpen );
|
|
||||||
MoveToEx(hdc, x + prefix_x, y + tm.tmAscent + 1, NULL );
|
|
||||||
LineTo(hdc, x + prefix_end + 1, y + tm.tmAscent + 1 );
|
|
||||||
SelectObject( hdc, oldPen );
|
|
||||||
DeleteObject( hpen );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (size.cx > max_width)
|
else if (size.cx > max_width)
|
||||||
max_width = size.cx;
|
max_width = size.cx;
|
||||||
|
|
Loading…
Reference in New Issue