X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/79d6c01818cafa1d95973955c8c55519d9550cf1..6d9022fe3bb50a75b9b5eaf5cf32558e518ba310:/src/html/m_tables.cpp?ds=sidebyside diff --git a/src/html/m_tables.cpp b/src/html/m_tables.cpp index 4f9af45eeb..7d125edf1c 100644 --- a/src/html/m_tables.cpp +++ b/src/html/m_tables.cpp @@ -291,7 +291,19 @@ void wxHtmlTableCell::AddCell(wxHtmlContainerCell *cell, const wxHtmlTag& tag) { tag.GetParamAsInt(wxT("COLSPAN"), &m_CellInfo[r][c].colspan); tag.GetParamAsInt(wxT("ROWSPAN"), &m_CellInfo[r][c].rowspan); - if ((m_CellInfo[r][c].colspan != 1) || (m_CellInfo[r][c].rowspan != 1)) + + // VS: the standard says this about col/rowspan: + // "This attribute specifies the number of rows spanned by the + // current cell. The default value of this attribute is one ("1"). + // The value zero ("0") means that the cell spans all rows from the + // current row to the last row of the table." All mainstream + // browsers act as if 0==1, though, and so does wxHTML. + if (m_CellInfo[r][c].colspan < 1) + m_CellInfo[r][c].colspan = 1; + if (m_CellInfo[r][c].rowspan < 1) + m_CellInfo[r][c].rowspan = 1; + + if ((m_CellInfo[r][c].colspan > 1) || (m_CellInfo[r][c].rowspan > 1)) { int i, j; @@ -335,16 +347,12 @@ void wxHtmlTableCell::AddCell(wxHtmlContainerCell *cell, const wxHtmlTag& tag) cell->SetIndent(m_Padding, wxHTML_INDENT_ALL, wxHTML_UNITS_PIXELS); } - - void wxHtmlTableCell::ComputeMinMaxWidths() { if (m_NumCols == 0 || m_ColsInfo[0].minWidth != -1) return; int left, right, width; - m_ColsInfo[0].minWidth = 0; // avoid recursion - Layout(1); for (int c = 0; c < m_NumCols; c++) { for (int r = 0; r < m_NumRows; r++) @@ -352,12 +360,13 @@ void wxHtmlTableCell::ComputeMinMaxWidths() cellStruct& cell = m_CellInfo[r][c]; if (cell.flag == cellUsed) { + cell.cont->Layout(2*m_Padding + 1); cell.cont->GetHorizontalConstraints(&left, &right); - width = right - left + 1; + width = right - left; + width -= (cell.colspan-1) * m_Spacing; // HTML 4.0 says it is acceptable to distribute min/max // width of spanning cells evently width /= cell.colspan; - width += m_Spacing + 2*m_Padding; for (int j = 0; j < cell.colspan; j++) if (width > m_ColsInfo[c+j].minWidth) m_ColsInfo[c+j].minWidth = width; @@ -373,6 +382,8 @@ void wxHtmlTableCell::ComputeMinMaxWidths() void wxHtmlTableCell::Layout(int w) { ComputeMinMaxWidths(); + + wxHtmlCell::Layout(w); /* @@ -513,13 +524,11 @@ TAG_HANDLER_BEGIN(TABLE, "TABLE,TR,TD,TH") TAG_HANDLER_VARS wxHtmlTableCell* m_Table; wxString m_tAlign, m_rAlign; - int m_OldAlign; TAG_HANDLER_CONSTR(TABLE) { m_Table = NULL; m_tAlign = m_rAlign = wxEmptyString; - m_OldAlign = wxHTML_ALIGN_LEFT; } @@ -532,22 +541,22 @@ TAG_HANDLER_BEGIN(TABLE, "TABLE,TR,TD,TH") { wxHtmlTableCell *oldt = m_Table; wxHtmlContainerCell *oldcont; - int m_OldAlign; oldcont = c = m_WParser->OpenContainer(); c->SetWidthFloat(tag, m_WParser->GetPixelScale()); m_Table = new wxHtmlTableCell(c, tag, m_WParser->GetPixelScale()); - m_OldAlign = m_WParser->GetAlign(); + int oldAlign = m_WParser->GetAlign(); m_tAlign = wxEmptyString; if (tag.HasParam(wxT("ALIGN"))) m_tAlign = tag.GetParam(wxT("ALIGN")); ParseInner(tag); - m_WParser->SetAlign(m_OldAlign); + m_WParser->SetAlign(oldAlign); m_WParser->SetContainer(oldcont); m_WParser->CloseContainer(); + m_Table = oldt; return TRUE; } @@ -567,29 +576,29 @@ TAG_HANDLER_BEGIN(TABLE, "TABLE,TR,TD,TH") // new cell else { - m_WParser->SetAlign(m_OldAlign); c = m_WParser->SetContainer(new wxHtmlContainerCell(m_Table)); m_Table->AddCell(c, tag); m_WParser->OpenContainer(); if (tag.GetName() == wxT("TH")) /*header style*/ - { m_WParser->SetAlign(wxHTML_ALIGN_CENTER); - } - - { - wxString als; - - als = m_rAlign; - if (tag.HasParam(wxT("ALIGN"))) - als = tag.GetParam(wxT("ALIGN")); - als.MakeUpper(); - if (als == wxT("RIGHT")) - m_WParser->SetAlign(wxHTML_ALIGN_RIGHT); - else if (als == wxT("CENTER")) - m_WParser->SetAlign(wxHTML_ALIGN_CENTER); - } + else + m_WParser->SetAlign(wxHTML_ALIGN_LEFT); + + wxString als; + + als = m_rAlign; + if (tag.HasParam(wxT("ALIGN"))) + als = tag.GetParam(wxT("ALIGN")); + als.MakeUpper(); + if (als == wxT("RIGHT")) + m_WParser->SetAlign(wxHTML_ALIGN_RIGHT); + else if (als == wxT("LEFT")) + m_WParser->SetAlign(wxHTML_ALIGN_LEFT); + else if (als == wxT("CENTER")) + m_WParser->SetAlign(wxHTML_ALIGN_CENTER); + m_WParser->OpenContainer(); } }