X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e0e4b2b0e95c737ac7de5d10cf701ad74e34a124..12bb29f5432174ecbd65549bda832d70d34a98ae:/src/html/m_tables.cpp diff --git a/src/html/m_tables.cpp b/src/html/m_tables.cpp index 1b96963be3..07f7b61658 100644 --- a/src/html/m_tables.cpp +++ b/src/html/m_tables.cpp @@ -17,6 +17,7 @@ #ifndef WX_PRECOMP #include "wx/wxcrtvararg.h" + #include "wx/brush.h" #endif #include "wx/html/forcelnk.h" @@ -106,6 +107,8 @@ public: void AddRow(const wxHtmlTag& tag); void AddCell(wxHtmlContainerCell *cell, const wxHtmlTag& tag); + const wxColour& GetRowDefaultBackgroundColour() const { return m_rBkg; } + private: // Reallocates memory to given number of cols/rows // and changes m_NumCols/m_NumRows value to reflect this change @@ -676,6 +679,37 @@ TAG_HANDLER_BEGIN(TABLE, "TABLE,TR,TD,TH") wxString m_tAlign, m_rAlign; wxHtmlContainerCell *m_enclosingContainer; + // Call ParseInner() preserving background colour and mode after any + // changes done by it. + void CallParseInnerWithBg(const wxHtmlTag& tag, const wxColour& colBg) + { + const wxColour oldbackclr = m_WParser->GetActualBackgroundColor(); + const int oldbackmode = m_WParser->GetActualBackgroundMode(); + if ( colBg.IsOk() ) + { + m_WParser->SetActualBackgroundColor(colBg); + m_WParser->SetActualBackgroundMode(wxBRUSHSTYLE_SOLID); + m_WParser->GetContainer()->InsertCell( + new wxHtmlColourCell(colBg, wxHTML_CLR_BACKGROUND) + ); + } + + ParseInner(tag); + + if ( oldbackmode != m_WParser->GetActualBackgroundMode() || + oldbackclr != m_WParser->GetActualBackgroundColor() ) + { + m_WParser->SetActualBackgroundMode(oldbackmode); + m_WParser->SetActualBackgroundColor(oldbackclr); + m_WParser->GetContainer()->InsertCell( + new wxHtmlColourCell(oldbackclr, + oldbackmode == wxBRUSHSTYLE_TRANSPARENT + ? wxHTML_CLR_TRANSPARENT_BACKGROUND + : wxHTML_CLR_BACKGROUND) + ); + } + } + TAG_HANDLER_CONSTR(TABLE) { m_Table = NULL; @@ -724,7 +758,7 @@ TAG_HANDLER_BEGIN(TABLE, "TABLE,TR,TD,TH") if (tag.HasParam(wxT("ALIGN"))) m_tAlign = tag.GetParam(wxT("ALIGN")); - ParseInner(tag); + CallParseInnerWithBg(tag, m_Table->GetBackgroundColour()); m_WParser->SetAlign(oldAlign); m_WParser->SetContainer(m_enclosingContainer); @@ -787,7 +821,11 @@ TAG_HANDLER_BEGIN(TABLE, "TABLE,TR,TD,TH") new wxHtmlFontCell(m_WParser->CreateCurrentFont())); } - ParseInner(tag); + wxColour bgCol; + if ( !tag.GetParamAsColour(wxT("BGCOLOR"), &bgCol) ) + bgCol = m_Table->GetRowDefaultBackgroundColour(); + + CallParseInnerWithBg(tag, bgCol); if ( isHeader ) {