// 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
/////////////////////////////////////////////////////////////////////////////
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))
// 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;
}
/* 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;
}
}
}
//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);
}
// 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"))
}
// 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);
}
// 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());
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
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();