Remove double strlen call in wxSTCListBoxD2D
The length of a string in wxSTCListBoxD2D::OnDrawItemText was being calculated twice - first when measured and again when drawn. Instead store the length the first time it is calculated. Also, pass a copy of the string in wx2stclen to allow the calculation to work in ASCII builds.
This commit is contained in:
@@ -3175,8 +3175,8 @@ public:
|
||||
wxString ellipsizedLabel = label;
|
||||
|
||||
wxCharBuffer buffer = wx2stc(ellipsizedLabel);
|
||||
int curWidth = surface.WidthText(tempFont, buffer.data(),
|
||||
wx2stclen(wxString(), buffer));
|
||||
int ellipsizedLen = wx2stclen(ellipsizedLabel, buffer);
|
||||
int curWidth = surface.WidthText(tempFont, buffer.data(),ellipsizedLen);
|
||||
|
||||
for ( int i = label.length(); curWidth > rect.GetWidth() && i; --i )
|
||||
{
|
||||
@@ -3184,8 +3184,8 @@ public:
|
||||
ellipsizedLabel << "...";
|
||||
|
||||
buffer = wx2stc(ellipsizedLabel);
|
||||
curWidth = surface.WidthText(tempFont, buffer.data(),
|
||||
wx2stclen(wxString(), buffer));
|
||||
ellipsizedLen = wx2stclen(ellipsizedLabel, buffer);
|
||||
curWidth = surface.WidthText(tempFont, buffer.data(),ellipsizedLen);
|
||||
}
|
||||
|
||||
PRectangle prect = PRectangleFromwxRect(rect);
|
||||
@@ -3194,7 +3194,7 @@ public:
|
||||
XYPOSITION ybase = rect.GetTop() + m_surfaceFontData->GetAscent();
|
||||
|
||||
surface.DrawTextTransparent(prect, tempFont, ybase, buffer.data(),
|
||||
wx2stclen(wxString(), buffer), fore);
|
||||
ellipsizedLen, fore);
|
||||
tempFont.Release();
|
||||
surface.Release();
|
||||
}
|
||||
|
Reference in New Issue
Block a user