Use GetPartialTextExtents() in wxHTML under all platforms
Call wxDC::GetPartialTextExtents() once instead of calling GetTextExtent() for
each letter in a loop in wxHtmlWordCell code. This is more efficient and more
precise and was done for wxOSX since 89e94a4bff
10+ years ago, but for some reason wasn't done for the other platforms.
This commit is contained in:
@@ -349,8 +349,6 @@ void wxHtmlWordCell::Split(const wxDC& dc,
|
|||||||
|
|
||||||
// before selection:
|
// before selection:
|
||||||
// (include character under caret only if in first half of width)
|
// (include character under caret only if in first half of width)
|
||||||
#ifdef __WXMAC__
|
|
||||||
// implementation using PartialExtents to support fractional widths
|
|
||||||
wxArrayInt widths ;
|
wxArrayInt widths ;
|
||||||
dc.GetPartialTextExtents(m_Word,widths) ;
|
dc.GetPartialTextExtents(m_Word,widths) ;
|
||||||
while( i < len && pt1.x >= widths[i] )
|
while( i < len && pt1.x >= widths[i] )
|
||||||
@@ -361,24 +359,10 @@ void wxHtmlWordCell::Split(const wxDC& dc,
|
|||||||
if ( widths[i] - pt1.x < charW/2 )
|
if ( widths[i] - pt1.x < charW/2 )
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
#else // !__WXMAC__
|
|
||||||
wxCoord charW, charH;
|
|
||||||
while ( pt1.x > 0 && i < len )
|
|
||||||
{
|
|
||||||
dc.GetTextExtent(m_Word[i], &charW, &charH);
|
|
||||||
pt1.x -= charW;
|
|
||||||
if ( pt1.x >= -charW/2 )
|
|
||||||
{
|
|
||||||
pos1 += charW;
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif // __WXMAC__/!__WXMAC__
|
|
||||||
|
|
||||||
// in selection:
|
// in selection:
|
||||||
// (include character under caret only if in first half of width)
|
// (include character under caret only if in first half of width)
|
||||||
unsigned j = i;
|
unsigned j = i;
|
||||||
#ifdef __WXMAC__
|
|
||||||
while( j < len && pt2.x >= widths[j] )
|
while( j < len && pt2.x >= widths[j] )
|
||||||
j++ ;
|
j++ ;
|
||||||
if ( j < len )
|
if ( j < len )
|
||||||
@@ -387,20 +371,6 @@ void wxHtmlWordCell::Split(const wxDC& dc,
|
|||||||
if ( widths[j] - pt2.x < charW/2 )
|
if ( widths[j] - pt2.x < charW/2 )
|
||||||
j++;
|
j++;
|
||||||
}
|
}
|
||||||
#else // !__WXMAC__
|
|
||||||
pos2 = pos1;
|
|
||||||
pt2.x -= pos2;
|
|
||||||
while ( pt2.x > 0 && j < len )
|
|
||||||
{
|
|
||||||
dc.GetTextExtent(m_Word[j], &charW, &charH);
|
|
||||||
pt2.x -= charW;
|
|
||||||
if ( pt2.x >= -charW/2 )
|
|
||||||
{
|
|
||||||
pos2 += charW;
|
|
||||||
j++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif // __WXMAC__/!__WXMAC__
|
|
||||||
|
|
||||||
pos1 = i;
|
pos1 = i;
|
||||||
pos2 = j;
|
pos2 = j;
|
||||||
|
Reference in New Issue
Block a user