X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/4bfa6c94c8c2eec77d6bdf7251c0a2dd515e5019..4b263e5ef358411a345dee9ffef3ba69c19be40e:/src/html/m_tables.cpp diff --git a/src/html/m_tables.cpp b/src/html/m_tables.cpp index 07f7b61658..25f3f96b7c 100644 --- a/src/html/m_tables.cpp +++ b/src/html/m_tables.cpp @@ -2,7 +2,6 @@ // Name: src/html/m_tables.cpp // Purpose: wxHtml module for tables // Author: Vaclav Slavik -// RCS-ID: $Id$ // Copyright: (c) 1999 Vaclav Slavik // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -135,16 +134,9 @@ wxHtmlTableCell::wxHtmlTableCell(wxHtmlContainerCell *parent, const wxHtmlTag& t m_ActualCol = m_ActualRow = -1; /* scan params: */ - if (tag.HasParam(wxT("BGCOLOR"))) - { - tag.GetParamAsColour(wxT("BGCOLOR"), &m_tBkg); - if (m_tBkg.IsOk()) - SetBackgroundColour(m_tBkg); - } - if (tag.HasParam(wxT("VALIGN"))) - m_tValign = tag.GetParam(wxT("VALIGN")); - else - m_tValign = wxEmptyString; + if (tag.GetParamAsColour(wxT("BGCOLOR"), &m_tBkg)) + SetBackgroundColour(m_tBkg); + m_tValign = tag.GetParam(wxT("VALIGN")); if (!tag.GetParamAsInt(wxT("CELLSPACING"), &m_Spacing)) m_Spacing = 2; if (!tag.GetParamAsInt(wxT("CELLPADDING"), &m_Padding)) @@ -243,11 +235,8 @@ void wxHtmlTableCell::AddRow(const wxHtmlTag& tag) // scan params: m_rBkg = m_tBkg; - if (tag.HasParam(wxT("BGCOLOR"))) - tag.GetParamAsColour(wxT("BGCOLOR"), &m_rBkg); - if (tag.HasParam(wxT("VALIGN"))) - m_rValign = tag.GetParam(wxT("VALIGN")); - else + tag.GetParamAsColour(wxT("BGCOLOR"), &m_rBkg); + if (!tag.GetParamAsString(wxT("VALIGN"), &m_rValign)) m_rValign = m_tValign; } @@ -285,27 +274,28 @@ void wxHtmlTableCell::AddCell(wxHtmlContainerCell *cell, const wxHtmlTag& tag) /* scan for parameters: */ + // id: + wxString idvalue; + if (tag.GetParamAsString(wxT("ID"), &idvalue)) + { + cell->SetId(idvalue); + } + // width: { - if (tag.HasParam(wxT("WIDTH"))) + int width = 0; + bool wpercent = false; + if (tag.GetParamAsIntOrPercent(wxT("WIDTH"), &width, wpercent)) { - wxString wd = tag.GetParam(wxT("WIDTH")); - - if (!wd.empty() && wd[wd.length()-1] == wxT('%')) + if (wpercent) { - if ( wxSscanf(wd.c_str(), wxT("%i%%"), &m_ColsInfo[c].width) == 1 ) - { - m_ColsInfo[c].units = wxHTML_UNITS_PERCENT; - } + m_ColsInfo[c].width = width; + m_ColsInfo[c].units = wxHTML_UNITS_PERCENT; } else { - long width; - if ( wd.ToLong(&width) ) - { - m_ColsInfo[c].width = (int)(m_PixelScale * (double)width); - m_ColsInfo[c].units = wxHTML_UNITS_PIXELS; - } + m_ColsInfo[c].width = (int)(m_PixelScale * (double)width); + m_ColsInfo[c].units = wxHTML_UNITS_PIXELS; } } } @@ -345,8 +335,7 @@ void wxHtmlTableCell::AddCell(wxHtmlContainerCell *cell, const wxHtmlTag& tag) //background color: { wxColour bk = m_rBkg; - if (tag.HasParam(wxT("BGCOLOR"))) - tag.GetParamAsColour(wxT("BGCOLOR"), &bk); + tag.GetParamAsColour(wxT("BGCOLOR"), &bk); if (bk.IsOk()) cell->SetBackgroundColour(bk); } @@ -356,9 +345,7 @@ void wxHtmlTableCell::AddCell(wxHtmlContainerCell *cell, const wxHtmlTag& tag) // vertical alignment: { wxString valign; - if (tag.HasParam(wxT("VALIGN"))) - valign = tag.GetParam(wxT("VALIGN")); - else + if (!tag.GetParamAsString(wxT("VALIGN"), &valign)) valign = m_tValign; valign.MakeUpper(); if (valign == wxT("TOP")) @@ -369,10 +356,7 @@ void wxHtmlTableCell::AddCell(wxHtmlContainerCell *cell, const wxHtmlTag& tag) } // nowrap - if (tag.HasParam(wxT("NOWRAP"))) - m_CellInfo[r][c].nowrap = true; - else - m_CellInfo[r][c].nowrap = false; + m_CellInfo[r][c].nowrap = tag.HasParam(wxT("NOWRAP")); cell->SetIndent(m_Padding, wxHTML_INDENT_ALL, wxHTML_UNITS_PIXELS); } @@ -734,29 +718,25 @@ TAG_HANDLER_BEGIN(TABLE, "TABLE,TR,TD,TH") // width: { - if (tag.HasParam(wxT("WIDTH"))) + int width = 0; + bool wpercent = false; + if (tag.GetParamAsIntOrPercent(wxT("WIDTH"), &width, wpercent)) { - int width = 0; - bool wpercent = false; - if (tag.GetParamAsIntOrPercent(wxT("WIDTH"), &width, wpercent)) + if (wpercent) { - if (wpercent) - { - m_Table->SetWidthFloat(width, wxHTML_UNITS_PERCENT); - } - else - { - m_Table->SetWidthFloat((int)(m_WParser->GetPixelScale() * width), wxHTML_UNITS_PIXELS); - } + m_Table->SetWidthFloat(width, wxHTML_UNITS_PERCENT); + } + else + { + m_Table->SetWidthFloat((int)(m_WParser->GetPixelScale() * width), wxHTML_UNITS_PIXELS); } } else m_Table->SetWidthFloat(0, wxHTML_UNITS_PIXELS); } int oldAlign = m_WParser->GetAlign(); - m_tAlign = wxEmptyString; - if (tag.HasParam(wxT("ALIGN"))) - m_tAlign = tag.GetParam(wxT("ALIGN")); + if (!tag.GetParamAsString(wxT("ALIGN"), &m_tAlign)) + m_tAlign.clear(); CallParseInnerWithBg(tag, m_Table->GetBackgroundColour()); @@ -777,9 +757,8 @@ TAG_HANDLER_BEGIN(TABLE, "TABLE,TR,TD,TH") if (tag.GetName() == wxT("TR")) { m_Table->AddRow(tag); - m_rAlign = m_tAlign; - if (tag.HasParam(wxT("ALIGN"))) - m_rAlign = tag.GetParam(wxT("ALIGN")); + if (!tag.GetParamAsString(wxT("ALIGN"), &m_rAlign)) + m_rAlign = m_tAlign; } // new cell @@ -793,9 +772,7 @@ TAG_HANDLER_BEGIN(TABLE, "TABLE,TR,TD,TH") const bool isHeader = tag.GetName() == wxT("TH"); wxString als; - if (tag.HasParam(wxT("ALIGN"))) - als = tag.GetParam(wxT("ALIGN")); - else + if (!tag.GetParamAsString(wxT("ALIGN"), &als)) als = m_rAlign; als.MakeUpper();