optimized wxHtmlContainerCell - now proceeds layouting only when neccessary (will speed-up window resizing of pages with many constant-width tables)
;; also added much larger (complete?) table of -like substitutions git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@5396 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -65,7 +65,7 @@ void wxHtmlCell::OnMouseClick(wxWindow *parent, int x, int y,
|
||||
|
||||
|
||||
|
||||
bool wxHtmlCell::AdjustPagebreak(int *pagebreak)
|
||||
bool wxHtmlCell::AdjustPagebreak(int *pagebreak) const
|
||||
{
|
||||
if ((!m_CanLiveOnPagebreak) &&
|
||||
m_PosY < *pagebreak && m_PosY + m_Height > *pagebreak) {
|
||||
@@ -100,15 +100,108 @@ wxHtmlWordCell::wxHtmlWordCell(const wxString& word, wxDC& dc) : wxHtmlCell()
|
||||
|
||||
if (m_Word.Find(wxT('&')) != -1)
|
||||
{
|
||||
#define ESCSEQ(escape, subst) \
|
||||
{ wxT("&"escape";"), wxT("&"escape" "), wxT(subst) }
|
||||
static wxChar* substitutions[][3] =
|
||||
{
|
||||
{ wxT(" "), wxT("  "), wxT(" ") },
|
||||
{ wxT("©"), wxT("© "), wxT("(c)") },
|
||||
{ wxT("""), wxT("" "), wxT("\"") },
|
||||
{ wxT("<"), wxT("< "), wxT("<") },
|
||||
{ wxT(">"), wxT("> "), wxT(">") },
|
||||
{ wxT("&"), wxT("& "), wxT("&") /*this one should be last one*/ },
|
||||
{ NULL, NULL, NULL }
|
||||
ESCSEQ("quot", "\""),
|
||||
ESCSEQ("lt", "<"),
|
||||
ESCSEQ("gt", ">"),
|
||||
|
||||
ESCSEQ("nbsp", " "),
|
||||
ESCSEQ("iexcl", "!"),
|
||||
ESCSEQ("cent", "<EFBFBD>"),
|
||||
|
||||
ESCSEQ("yen", " "),
|
||||
ESCSEQ("brkbar", " "),
|
||||
ESCSEQ("sect", " "),
|
||||
ESCSEQ("uml", " "),
|
||||
|
||||
ESCSEQ("copy", "(c)"),
|
||||
ESCSEQ("ordf", " "),
|
||||
ESCSEQ("laquo", " "),
|
||||
ESCSEQ("not", " "),
|
||||
|
||||
ESCSEQ("reg", "(r)"),
|
||||
|
||||
ESCSEQ("deg", " "),
|
||||
ESCSEQ("plusm", " "),
|
||||
|
||||
ESCSEQ("acute", " "),
|
||||
ESCSEQ("micro", " "),
|
||||
ESCSEQ("para", " "),
|
||||
|
||||
ESCSEQ("ordm", " "),
|
||||
ESCSEQ("raquo", " "),
|
||||
|
||||
ESCSEQ("iquest", " "),
|
||||
ESCSEQ("Agrave", "<EFBFBD>"),
|
||||
|
||||
ESCSEQ("Acirc", "<EFBFBD>"),
|
||||
ESCSEQ("Atilde", "<EFBFBD>"),
|
||||
ESCSEQ("Auml", "<EFBFBD>"),
|
||||
ESCSEQ("Aring", " "),
|
||||
ESCSEQ("AElig", " "),
|
||||
ESCSEQ("Ccedil", "<EFBFBD>"),
|
||||
ESCSEQ("Egrave", "<EFBFBD>"),
|
||||
ESCSEQ("Eacute", "<EFBFBD>"),
|
||||
ESCSEQ("Ecirc", "<EFBFBD>"),
|
||||
ESCSEQ("Euml", "<EFBFBD>"),
|
||||
ESCSEQ("Igrave", "<EFBFBD>"),
|
||||
|
||||
ESCSEQ("Icirc", "<EFBFBD>"),
|
||||
ESCSEQ("Iuml", "<EFBFBD>"),
|
||||
|
||||
ESCSEQ("Ntilde", "<EFBFBD>"),
|
||||
ESCSEQ("Ograve", "<EFBFBD>"),
|
||||
|
||||
ESCSEQ("Ocirc", "<EFBFBD>"),
|
||||
ESCSEQ("Otilde", "<EFBFBD>"),
|
||||
ESCSEQ("Ouml", "<EFBFBD>"),
|
||||
|
||||
ESCSEQ("Oslash", " "),
|
||||
ESCSEQ("Ugrave", "<EFBFBD>"),
|
||||
|
||||
ESCSEQ("Ucirc", " "),
|
||||
ESCSEQ("Uuml", "<EFBFBD>"),
|
||||
|
||||
ESCSEQ("szlig", "<EFBFBD>"),
|
||||
ESCSEQ("agrave;","<EFBFBD>"),
|
||||
ESCSEQ("aacute", "<EFBFBD>"),
|
||||
ESCSEQ("acirc", "<EFBFBD>"),
|
||||
ESCSEQ("atilde", "<EFBFBD>"),
|
||||
ESCSEQ("auml", "<EFBFBD>"),
|
||||
ESCSEQ("aring", "a"),
|
||||
ESCSEQ("aelig", "ae"),
|
||||
ESCSEQ("ccedil", "<EFBFBD>"),
|
||||
ESCSEQ("egrave", "<EFBFBD>"),
|
||||
ESCSEQ("eacute", "<EFBFBD>"),
|
||||
ESCSEQ("ecirc", "<EFBFBD>"),
|
||||
ESCSEQ("euml", "<EFBFBD>"),
|
||||
ESCSEQ("igrave", "<EFBFBD>"),
|
||||
ESCSEQ("iacute", "<EFBFBD>"),
|
||||
ESCSEQ("icirc", " "),
|
||||
ESCSEQ("iuml", "<EFBFBD>"),
|
||||
ESCSEQ("eth", " "),
|
||||
ESCSEQ("ntilde", "<EFBFBD>"),
|
||||
ESCSEQ("ograve", "<EFBFBD>"),
|
||||
ESCSEQ("oacute", "<EFBFBD>"),
|
||||
ESCSEQ("ocirc", "<EFBFBD>"),
|
||||
ESCSEQ("otilde", "<EFBFBD>"),
|
||||
ESCSEQ("ouml", "<EFBFBD>"),
|
||||
ESCSEQ("divide", " "),
|
||||
ESCSEQ("oslash", " "),
|
||||
ESCSEQ("ugrave", "<EFBFBD>"),
|
||||
ESCSEQ("uacute", "<EFBFBD>"),
|
||||
ESCSEQ("ucirc", "<EFBFBD>"),
|
||||
ESCSEQ("uuml", "<EFBFBD>"),
|
||||
|
||||
ESCSEQ("yuml", ""),
|
||||
|
||||
/* this one should ALWAYS stay the last one!!! */
|
||||
ESCSEQ("amp", "&"),
|
||||
|
||||
{ NULL, NULL, NULL }
|
||||
};
|
||||
|
||||
for (int i = 0; substitutions[i][0] != NULL; i++)
|
||||
@@ -150,6 +243,7 @@ wxHtmlContainerCell::wxHtmlContainerCell(wxHtmlContainerCell *parent) : wxHtmlCe
|
||||
m_UseBorder = FALSE;
|
||||
m_MinHeight = m_MaxLineWidth = 0;
|
||||
m_MinHeightAlign = wxHTML_ALIGN_TOP;
|
||||
m_LastLayout = -1;
|
||||
}
|
||||
|
||||
|
||||
@@ -161,6 +255,7 @@ void wxHtmlContainerCell::SetIndent(int i, int what, int units)
|
||||
if (what & wxHTML_INDENT_RIGHT) m_IndentRight = val;
|
||||
if (what & wxHTML_INDENT_TOP) m_IndentTop = val;
|
||||
if (what & wxHTML_INDENT_BOTTOM) m_IndentBottom = val;
|
||||
m_LastLayout = -1;
|
||||
}
|
||||
|
||||
|
||||
@@ -190,7 +285,7 @@ int wxHtmlContainerCell::GetIndentUnits(int ind) const
|
||||
|
||||
|
||||
|
||||
bool wxHtmlContainerCell::AdjustPagebreak(int *pagebreak)
|
||||
bool wxHtmlContainerCell::AdjustPagebreak(int *pagebreak) const
|
||||
{
|
||||
if (!m_CanLiveOnPagebreak)
|
||||
return wxHtmlCell::AdjustPagebreak(pagebreak);
|
||||
@@ -213,6 +308,11 @@ bool wxHtmlContainerCell::AdjustPagebreak(int *pagebreak)
|
||||
|
||||
void wxHtmlContainerCell::Layout(int w)
|
||||
{
|
||||
if (m_LastLayout == w) {
|
||||
wxHtmlCell::Layout(w);
|
||||
return;
|
||||
}
|
||||
|
||||
wxHtmlCell *cell = m_Cells, *line = m_Cells;
|
||||
long xpos = 0, ypos = m_IndentTop;
|
||||
int xdelta = 0, ybasicpos = 0, ydiff;
|
||||
@@ -313,6 +413,8 @@ void wxHtmlContainerCell::Layout(int w)
|
||||
m_MaxLineWidth += s_indent + ((m_IndentRight < 0) ? (-m_IndentRight * m_Width / 100) : m_IndentRight);
|
||||
if (m_Width < m_MaxLineWidth) m_Width = m_MaxLineWidth;
|
||||
|
||||
m_LastLayout = w;
|
||||
|
||||
wxHtmlCell::Layout(w);
|
||||
}
|
||||
|
||||
@@ -394,6 +496,7 @@ void wxHtmlContainerCell::InsertCell(wxHtmlCell *f)
|
||||
if (m_LastCell) while (m_LastCell -> GetNext()) m_LastCell = m_LastCell -> GetNext();
|
||||
}
|
||||
f -> SetParent(this);
|
||||
m_LastLayout = -1;
|
||||
}
|
||||
|
||||
|
||||
@@ -409,6 +512,7 @@ void wxHtmlContainerCell::SetAlign(const wxHtmlTag& tag)
|
||||
SetAlignHor(wxHTML_ALIGN_LEFT);
|
||||
else if (alg == wxT("RIGHT"))
|
||||
SetAlignHor(wxHTML_ALIGN_RIGHT);
|
||||
m_LastLayout = -1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -428,6 +532,7 @@ void wxHtmlContainerCell::SetWidthFloat(const wxHtmlTag& tag, double pixel_scale
|
||||
wxSscanf(wd.c_str(), wxT("%i"), &wdi);
|
||||
SetWidthFloat((int)(pixel_scale * (double)wdi), wxHTML_UNITS_PIXELS);
|
||||
}
|
||||
m_LastLayout = -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user