Further optimizations
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@53336 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -4914,6 +4914,7 @@ bool wxRichTextPlainText::GetRangeSize(const wxRichTextRange& range, wxSize& siz
|
|||||||
#if wxRICHTEXT_USE_PARTIAL_TEXT_EXTENTS
|
#if wxRICHTEXT_USE_PARTIAL_TEXT_EXTENTS
|
||||||
wxArrayInt textExtents;
|
wxArrayInt textExtents;
|
||||||
#endif
|
#endif
|
||||||
|
bool haveDescent = false;
|
||||||
|
|
||||||
wxString str(m_text);
|
wxString str(m_text);
|
||||||
wxString toReplace = wxRichTextLineBreakChar;
|
wxString toReplace = wxRichTextLineBreakChar;
|
||||||
@@ -4948,28 +4949,42 @@ bool wxRichTextPlainText::GetRangeSize(const wxRichTextRange& range, wxSize& siz
|
|||||||
|
|
||||||
while (stringChunk.Find(wxT('\t')) >= 0)
|
while (stringChunk.Find(wxT('\t')) >= 0)
|
||||||
{
|
{
|
||||||
|
int absoluteWidth = 0;
|
||||||
|
|
||||||
// the string has a tab
|
// the string has a tab
|
||||||
// break up the string at the Tab
|
// break up the string at the Tab
|
||||||
wxString stringFragment = stringChunk.BeforeFirst(wxT('\t'));
|
wxString stringFragment = stringChunk.BeforeFirst(wxT('\t'));
|
||||||
stringChunk = stringChunk.AfterFirst(wxT('\t'));
|
stringChunk = stringChunk.AfterFirst(wxT('\t'));
|
||||||
dc.GetTextExtent(stringFragment, & w, & h);
|
|
||||||
#if wxRICHTEXT_USE_PARTIAL_TEXT_EXTENTS
|
|
||||||
int oldWidth = width;
|
|
||||||
#endif
|
|
||||||
width += w;
|
|
||||||
int absoluteWidth = width + position.x;
|
|
||||||
|
|
||||||
#if wxRICHTEXT_USE_PARTIAL_TEXT_EXTENTS
|
#if wxRICHTEXT_USE_PARTIAL_TEXT_EXTENTS
|
||||||
if (g_UseGlobalPartialTextExtents)
|
if (g_UseGlobalPartialTextExtents)
|
||||||
{
|
{
|
||||||
|
int oldWidth;
|
||||||
|
if (textExtents.GetCount() > 0)
|
||||||
|
oldWidth = textExtents[textExtents.GetCount()-1];
|
||||||
|
else
|
||||||
|
oldWidth = 0;
|
||||||
|
|
||||||
// Add these partial extents
|
// Add these partial extents
|
||||||
wxArrayInt p;
|
wxArrayInt p;
|
||||||
dc.GetPartialTextExtents(stringFragment, p);
|
dc.GetPartialTextExtents(stringFragment, p);
|
||||||
size_t j;
|
size_t j;
|
||||||
for (j = 0; j < p.GetCount(); j++)
|
for (j = 0; j < p.GetCount(); j++)
|
||||||
textExtents.Add(oldWidth + p[j]);
|
textExtents.Add(oldWidth + p[j]);
|
||||||
|
|
||||||
|
if (textExtents.GetCount() > 0)
|
||||||
|
absoluteWidth = textExtents[textExtents.GetCount()-1] + position.x;
|
||||||
|
else
|
||||||
|
absoluteWidth = position.x;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
#endif
|
#endif
|
||||||
|
{
|
||||||
|
dc.GetTextExtent(stringFragment, & w, & h, & descent);
|
||||||
|
width += w;
|
||||||
|
absoluteWidth = width + position.x;
|
||||||
|
haveDescent = true;
|
||||||
|
}
|
||||||
|
|
||||||
bool notFound = true;
|
bool notFound = true;
|
||||||
for (int i = 0; i < tabCount && notFound; ++i)
|
for (int i = 0; i < tabCount && notFound; ++i)
|
||||||
@@ -4988,6 +5003,7 @@ bool wxRichTextPlainText::GetRangeSize(const wxRichTextRange& range, wxSize& siz
|
|||||||
}
|
}
|
||||||
|
|
||||||
notFound = false;
|
notFound = false;
|
||||||
|
|
||||||
width = nextTabPos - position.x;
|
width = nextTabPos - position.x;
|
||||||
|
|
||||||
#if wxRICHTEXT_USE_PARTIAL_TEXT_EXTENTS
|
#if wxRICHTEXT_USE_PARTIAL_TEXT_EXTENTS
|
||||||
@@ -5001,15 +5017,15 @@ bool wxRichTextPlainText::GetRangeSize(const wxRichTextRange& range, wxSize& siz
|
|||||||
|
|
||||||
if (!stringChunk.IsEmpty())
|
if (!stringChunk.IsEmpty())
|
||||||
{
|
{
|
||||||
dc.GetTextExtent(stringChunk, & w, & h, & descent);
|
|
||||||
#if wxRICHTEXT_USE_PARTIAL_TEXT_EXTENTS
|
|
||||||
int oldWidth = width;
|
|
||||||
#endif
|
|
||||||
width += w;
|
|
||||||
|
|
||||||
#if wxRICHTEXT_USE_PARTIAL_TEXT_EXTENTS
|
#if wxRICHTEXT_USE_PARTIAL_TEXT_EXTENTS
|
||||||
if (g_UseGlobalPartialTextExtents)
|
if (g_UseGlobalPartialTextExtents)
|
||||||
{
|
{
|
||||||
|
int oldWidth;
|
||||||
|
if (textExtents.GetCount() > 0)
|
||||||
|
oldWidth = textExtents[textExtents.GetCount()-1];
|
||||||
|
else
|
||||||
|
oldWidth = 0;
|
||||||
|
|
||||||
// Add these partial extents
|
// Add these partial extents
|
||||||
wxArrayInt p;
|
wxArrayInt p;
|
||||||
dc.GetPartialTextExtents(stringChunk, p);
|
dc.GetPartialTextExtents(stringChunk, p);
|
||||||
@@ -5017,7 +5033,13 @@ bool wxRichTextPlainText::GetRangeSize(const wxRichTextRange& range, wxSize& siz
|
|||||||
for (j = 0; j < p.GetCount(); j++)
|
for (j = 0; j < p.GetCount(); j++)
|
||||||
textExtents.Add(oldWidth + p[j]);
|
textExtents.Add(oldWidth + p[j]);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
#endif
|
#endif
|
||||||
|
{
|
||||||
|
dc.GetTextExtent(stringChunk, & w, & h, & descent);
|
||||||
|
width += w;
|
||||||
|
haveDescent = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if wxRICHTEXT_USE_PARTIAL_TEXT_EXTENTS
|
#if wxRICHTEXT_USE_PARTIAL_TEXT_EXTENTS
|
||||||
@@ -5031,14 +5053,26 @@ bool wxRichTextPlainText::GetRangeSize(const wxRichTextRange& range, wxSize& siz
|
|||||||
size_t j;
|
size_t j;
|
||||||
for (j = 0; j < textExtents.GetCount(); j++)
|
for (j = 0; j < textExtents.GetCount(); j++)
|
||||||
g_GlobalPartialTextExtents.Add(lastExtent + textExtents[j]);
|
g_GlobalPartialTextExtents.Add(lastExtent + textExtents[j]);
|
||||||
|
|
||||||
|
int charHeight = dc.GetCharHeight();
|
||||||
|
if (textExtents.GetCount() > 0)
|
||||||
|
w = textExtents[textExtents.GetCount()-1];
|
||||||
|
else
|
||||||
|
w = 0;
|
||||||
|
size = wxSize(w, charHeight);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
#endif
|
#endif
|
||||||
|
{
|
||||||
|
size = wxSize(width, dc.GetCharHeight());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!haveDescent)
|
||||||
|
dc.GetTextExtent(wxT("X"), & w, & h, & descent);
|
||||||
|
|
||||||
if ( bScript )
|
if ( bScript )
|
||||||
dc.SetFont(font);
|
dc.SetFont(font);
|
||||||
|
|
||||||
size = wxSize(width, dc.GetCharHeight());
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -6797,7 +6831,6 @@ void wxRichTextAction::UpdateAppearance(long caretPosition, bool sendUpdateEvent
|
|||||||
if (!m_ctrl->IsFrozen())
|
if (!m_ctrl->IsFrozen())
|
||||||
{
|
{
|
||||||
m_ctrl->LayoutContent();
|
m_ctrl->LayoutContent();
|
||||||
m_ctrl->PositionCaret();
|
|
||||||
|
|
||||||
#if wxRICHTEXT_USE_OPTIMIZED_DRAWING
|
#if wxRICHTEXT_USE_OPTIMIZED_DRAWING
|
||||||
// Find refresh rectangle if we are in a position to optimise refresh
|
// Find refresh rectangle if we are in a position to optimise refresh
|
||||||
|
@@ -1126,6 +1126,8 @@ bool wxRichTextCtrl::ScrollIntoView(long position, int keyCode)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (scrolled)
|
||||||
PositionCaret();
|
PositionCaret();
|
||||||
|
|
||||||
return scrolled;
|
return scrolled;
|
||||||
|
Reference in New Issue
Block a user