mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 01:35:47 +00:00
- Update TEXT_TabbedTextOut from Wine's trunk. Reduces number of failures in "user32_winetest.exe text" from 64 to 4.
svn path=/trunk/; revision=21981
This commit is contained in:
parent
612e2ff4df
commit
96f2c584d0
1 changed files with 59 additions and 37 deletions
|
@ -79,16 +79,13 @@ static LONG TEXT_TabbedTextOut( HDC hdc, INT x, INT y, LPCWSTR lpstr,
|
||||||
{
|
{
|
||||||
INT defWidth;
|
INT defWidth;
|
||||||
SIZE extent;
|
SIZE extent;
|
||||||
int i, tabPos = x;
|
int i, j;
|
||||||
int start = x;
|
int start = x;
|
||||||
|
|
||||||
extent.cx = 0;
|
|
||||||
extent.cy = 0;
|
|
||||||
|
|
||||||
if (!lpTabPos)
|
if (!lpTabPos)
|
||||||
cTabStops=0;
|
cTabStops=0;
|
||||||
|
|
||||||
if (cTabStops == 1 && *lpTabPos >= /* sic */ 0)
|
if (cTabStops == 1)
|
||||||
{
|
{
|
||||||
defWidth = *lpTabPos;
|
defWidth = *lpTabPos;
|
||||||
cTabStops = 0;
|
cTabStops = 0;
|
||||||
|
@ -96,51 +93,76 @@ static LONG TEXT_TabbedTextOut( HDC hdc, INT x, INT y, LPCWSTR lpstr,
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
TEXTMETRICA tm;
|
TEXTMETRICA tm;
|
||||||
if (GetTextMetricsA( hdc, &tm ))
|
GetTextMetricsA( hdc, &tm );
|
||||||
defWidth = 8 * tm.tmAveCharWidth;
|
defWidth = 8 * tm.tmAveCharWidth;
|
||||||
else
|
|
||||||
defWidth = 0;
|
|
||||||
if (cTabStops == 1)
|
|
||||||
cTabStops = 0; /* on negative *lpTabPos */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
while (count > 0)
|
while (count > 0)
|
||||||
{
|
{
|
||||||
|
RECT r;
|
||||||
|
INT x0;
|
||||||
|
x0 = x;
|
||||||
|
r.left = x0;
|
||||||
|
/* chop the string into substrings of 0 or more <tabs>
|
||||||
|
* possibly followed by 1 or more normal characters */
|
||||||
for (i = 0; i < count; i++)
|
for (i = 0; i < count; i++)
|
||||||
if (lpstr[i] == '\t') break;
|
if (lpstr[i] != '\t') break;
|
||||||
GetTextExtentPointW( hdc, lpstr, i, &extent );
|
for (j = i; j < count; j++)
|
||||||
while ((cTabStops > 0) &&
|
if (lpstr[j] == '\t') break;
|
||||||
(nTabOrg + *lpTabPos <= x + extent.cx))
|
/* get the extent of the normal character part */
|
||||||
{
|
GetTextExtentPointW( hdc, lpstr + i, j - i , &extent );
|
||||||
lpTabPos++;
|
/* and if there is a <tab>, calculate its position */
|
||||||
cTabStops--;
|
if( i) {
|
||||||
}
|
/* get x coordinate for the drawing of this string */
|
||||||
if (i == count)
|
for (; cTabStops > i; lpTabPos++, cTabStops--)
|
||||||
tabPos = x + extent.cx;
|
{
|
||||||
else if (cTabStops > 0)
|
if( nTabOrg + abs( *lpTabPos) > x) {
|
||||||
tabPos = nTabOrg + *lpTabPos;
|
if( lpTabPos[ i - 1] >= 0) {
|
||||||
else if (defWidth <= 0)
|
/* a left aligned tab */
|
||||||
tabPos = x + extent.cx;
|
x = nTabOrg + lpTabPos[ i-1] + extent.cx;
|
||||||
else
|
break;
|
||||||
tabPos = nTabOrg + ((x + extent.cx - nTabOrg) / defWidth + 1) * defWidth;
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* if tab pos is negative then text is right-aligned
|
||||||
|
* to tab stop meaning that the string extends to the
|
||||||
|
* left, so we must subtract the width of the string */
|
||||||
|
if (nTabOrg - lpTabPos[ i - 1] - extent.cx > x)
|
||||||
|
{
|
||||||
|
x = nTabOrg - lpTabPos[ i - 1];
|
||||||
|
x0 = x - extent.cx;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* if we have run out of tab stops and we have a valid default tab
|
||||||
|
* stop width then round x up to that width */
|
||||||
|
if ((cTabStops <= i) && (defWidth > 0)) {
|
||||||
|
x0 = nTabOrg + ((x - nTabOrg) / defWidth + i) * defWidth;
|
||||||
|
x = x0 + extent.cx;
|
||||||
|
} else if ((cTabStops <= i) && (defWidth < 0)) {
|
||||||
|
x = nTabOrg + ((x - nTabOrg + extent.cx) / -defWidth + i)
|
||||||
|
* -defWidth;
|
||||||
|
x0 = x - extent.cx;
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
x += extent.cx;
|
||||||
|
|
||||||
if (fDisplayText)
|
if (fDisplayText)
|
||||||
{
|
{
|
||||||
RECT r;
|
|
||||||
r.left = x;
|
|
||||||
r.top = y;
|
r.top = y;
|
||||||
r.right = tabPos;
|
r.right = x;
|
||||||
r.bottom = y + extent.cy;
|
r.bottom = y + extent.cy;
|
||||||
ExtTextOutW( hdc, x, y, GetBkMode(hdc) == OPAQUE ? ETO_OPAQUE : 0,
|
ExtTextOutW( hdc, x0, y, GetBkMode(hdc) == OPAQUE ? ETO_OPAQUE : 0,
|
||||||
&r, lpstr, i, NULL );
|
&r, lpstr + i, j - i, NULL );
|
||||||
}
|
}
|
||||||
x = tabPos;
|
count -= j;
|
||||||
count -= i+1;
|
lpstr += j;
|
||||||
lpstr += i+1;
|
|
||||||
}
|
}
|
||||||
return MAKELONG(tabPos - start, extent.cy);
|
return MAKELONG(x - start, extent.cy);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @implemented
|
* @implemented
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue