added convenience accessors to wxHtmlTag and modified wxHTML code to use them; improved colours parsing

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@10747 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Václav Slavík
2001-07-01 18:07:33 +00:00
parent fef8557d30
commit 8bd72d9065
8 changed files with 167 additions and 97 deletions

View File

@@ -18,6 +18,8 @@
#include "wx/defs.h" #include "wx/defs.h"
#if wxUSE_HTML #if wxUSE_HTML
class WXDLLEXPORT wxHtmlEntitiesParser;
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// wxHtmlTagsCache // wxHtmlTagsCache
// - internal wxHTML class, do not use! // - internal wxHTML class, do not use!
@@ -58,7 +60,9 @@ public:
// constructs wxHtmlTag object based on HTML tag. // constructs wxHtmlTag object based on HTML tag.
// The tag begins (with '<' character) at position pos in source // The tag begins (with '<' character) at position pos in source
// end_pos is position where parsing ends (usually end of document) // end_pos is position where parsing ends (usually end of document)
wxHtmlTag(const wxString& source, int pos, int end_pos, wxHtmlTagsCache* cache); wxHtmlTag(const wxString& source, int pos, int end_pos,
wxHtmlTagsCache *cache,
wxHtmlEntitiesParser *entParser = NULL);
// Returns tag's name in uppercase. // Returns tag's name in uppercase.
inline wxString GetName() const {return m_Name;} inline wxString GetName() const {return m_Name;}
@@ -75,7 +79,11 @@ public:
// (or ("WhaT.jpg") if with_commas == TRUE) // (or ("WhaT.jpg") if with_commas == TRUE)
wxString GetParam(const wxString& par, bool with_commas = FALSE) const; wxString GetParam(const wxString& par, bool with_commas = FALSE) const;
// Scans param like scanf() functions family do. // Convenience functions:
bool GetParamAsColour(const wxString& par, wxColour *clr) const;
bool GetParamAsInt(const wxString& par, int *clr) const;
// Scans param like scanf() functions family does.
// Example : ScanParam("COLOR", "\"#%X\"", &clr); // Example : ScanParam("COLOR", "\"#%X\"", &clr);
// This is always with with_commas=FALSE // This is always with with_commas=FALSE
// Returns number of scanned values // Returns number of scanned values
@@ -85,7 +93,7 @@ public:
int ScanParam(const wxString& par, wxChar *format, void *param) const; int ScanParam(const wxString& par, wxChar *format, void *param) const;
// Returns string containing all params. // Returns string containing all params.
inline const wxString& GetAllParams() const {return m_Params;} wxString GetAllParams() const;
// return TRUE if this is ending tag (</something>) or FALSE // return TRUE if this is ending tag (</something>) or FALSE
// if it isn't (<something>) // if it isn't (<something>)
@@ -107,9 +115,10 @@ public:
inline int GetEndPos2() const {return m_End2;} inline int GetEndPos2() const {return m_End2;}
private: private:
wxString m_Name, m_Params; wxString m_Name;
int m_Begin, m_End1, m_End2; int m_Begin, m_End1, m_End2;
bool m_Ending; bool m_Ending;
wxArrayString m_ParamNames, m_ParamValues;
}; };

View File

@@ -162,7 +162,7 @@ bool HP_TagHandler::HandleTag(const wxHtmlTag& tag)
if (tag.GetParam(wxT("NAME")) == wxT("Local")) if (tag.GetParam(wxT("NAME")) == wxT("Local"))
m_Page = tag.GetParam(wxT("VALUE")); m_Page = tag.GetParam(wxT("VALUE"));
if (tag.GetParam(wxT("NAME")) == wxT("ID")) if (tag.GetParam(wxT("NAME")) == wxT("ID"))
tag.ScanParam(wxT("VALUE"), wxT("%i"), &m_ID); tag.GetParamAsInt(wxT("VALUE"), &m_ID);
return FALSE; return FALSE;
} }
} }

View File

@@ -304,6 +304,57 @@ int wxHtmlTag::ScanParam(const wxString& par, wxChar *format, void *param) const
return wxSscanf(parval, format, param); return wxSscanf(parval, format, param);
} }
bool wxHtmlTag::GetParamAsColour(const wxString& par, wxColour *clr) const
{
wxString str = GetParam(par);
if (str.IsEmpty()) return FALSE;
if (str.GetChar(0) == wxT('#'))
{
unsigned long tmp;
if (ScanParam(par, wxT("#%lX"), &tmp) != 1)
return FALSE;
*clr = wxColour((unsigned char)((tmp & 0xFF0000) >> 16),
(unsigned char)((tmp & 0x00FF00) >> 8),
(unsigned char)(tmp & 0x0000FF));
return TRUE;
}
else
{
// Handle colours defined in HTML 4.0:
#define HTML_COLOUR(name,r,g,b) \
if (str.IsSameAs(wxT(name), FALSE)) \
{ *clr = wxColour(r,g,b); return TRUE; }
HTML_COLOUR("black", 0x00,0x00,0x00)
HTML_COLOUR("silver", 0xC0,0xC0,0xC0)
HTML_COLOUR("gray", 0x80,0x80,0x80)
HTML_COLOUR("white", 0xFF,0xFF,0xFF)
HTML_COLOUR("maroon", 0x80,0x00,0x00)
HTML_COLOUR("red", 0xFF,0x00,0x00)
HTML_COLOUR("purple", 0x80,0x00,0x80)
HTML_COLOUR("fuchsia", 0xFF,0x00,0xFF)
HTML_COLOUR("green", 0x00,0x80,0x00)
HTML_COLOUR("lime", 0x00,0xFF,0x00)
HTML_COLOUR("olive", 0x80,0x80,0x00)
HTML_COLOUR("yellow", 0xFF,0xFF,0x00)
HTML_COLOUR("navy", 0x00,0x00,0x80)
HTML_COLOUR("blue", 0x00,0x00,0xFF)
HTML_COLOUR("teal", 0x00,0x80,0x80)
HTML_COLOUR("aqua", 0x00,0xFF,0xFF)
#undef HTML_COLOUR
return FALSE;
}
}
bool wxHtmlTag::GetParamAsInt(const wxString& par, int *clr) const
{
if (!HasParam(par)) return FALSE;
long i;
bool succ = GetParam(par).ToLong(&i);
*clr = (int)i;
return succ;
}
wxString wxHtmlTag::GetAllParams() const wxString wxHtmlTag::GetAllParams() const
{ {
// VS: this function is for backward compatiblity only, // VS: this function is for backward compatiblity only,

View File

@@ -45,13 +45,9 @@ TAG_HANDLER_BEGIN(FONT, "FONT")
if (tag.HasParam(wxT("COLOR"))) if (tag.HasParam(wxT("COLOR")))
{ {
unsigned long tmp = 0;
wxColour clr; wxColour clr;
if (tag.ScanParam(wxT("COLOR"), wxT("#%lX"), &tmp) == 1) if (tag.GetParamAsColour(wxT("COLOR"), &clr))
{ {
clr = wxColour((unsigned char)((tmp & 0xFF0000) >> 16),
(unsigned char)((tmp & 0x00FF00) >> 8),
(unsigned char)(tmp & 0x0000FF));
m_WParser->SetActualColor(clr); m_WParser->SetActualColor(clr);
m_WParser->GetContainer()->InsertCell(new wxHtmlColourCell(clr)); m_WParser->GetContainer()->InsertCell(new wxHtmlColourCell(clr));
} }
@@ -59,15 +55,16 @@ TAG_HANDLER_BEGIN(FONT, "FONT")
if (tag.HasParam(wxT("SIZE"))) if (tag.HasParam(wxT("SIZE")))
{ {
long tmp = 0; int tmp = 0;
wxChar c = tag.GetParam(wxT("SIZE"))[(unsigned int) 0]; wxChar c = tag.GetParam(wxT("SIZE")).GetChar(0);
if (tag.ScanParam(wxT("SIZE"), wxT("%li"), &tmp) == 1) if (tag.GetParamAsInt(wxT("SIZE"), &tmp))
{ {
if (c == '+' || c == '-') if (c == wxT('+') || c == wxT('-'))
m_WParser->SetFontSize(oldsize+tmp); m_WParser->SetFontSize(oldsize+tmp);
else else
m_WParser->SetFontSize(tmp); m_WParser->SetFontSize(tmp);
m_WParser->GetContainer()->InsertCell(new wxHtmlFontCell(m_WParser->CreateCurrentFont())); m_WParser->GetContainer()->InsertCell(
new wxHtmlFontCell(m_WParser->CreateCurrentFont()));
} }
} }
@@ -79,7 +76,7 @@ TAG_HANDLER_BEGIN(FONT, "FONT")
enu.EnumerateFacenames(); enu.EnumerateFacenames();
m_Faces = *enu.GetFacenames(); m_Faces = *enu.GetFacenames();
} }
wxStringTokenizer tk(tag.GetParam(wxT("FACE")), ","); wxStringTokenizer tk(tag.GetParam(wxT("FACE")), wxT(","));
int index; int index;
while (tk.HasMoreTokens()) while (tk.HasMoreTokens())
@@ -123,12 +120,14 @@ TAG_HANDLER_BEGIN(FACES_U, "U,STRIKE")
int underlined = m_WParser->GetFontUnderlined(); int underlined = m_WParser->GetFontUnderlined();
m_WParser->SetFontUnderlined(TRUE); m_WParser->SetFontUnderlined(TRUE);
m_WParser->GetContainer()->InsertCell(new wxHtmlFontCell(m_WParser->CreateCurrentFont())); m_WParser->GetContainer()->InsertCell(
new wxHtmlFontCell(m_WParser->CreateCurrentFont()));
ParseInner(tag); ParseInner(tag);
m_WParser->SetFontUnderlined(underlined); m_WParser->SetFontUnderlined(underlined);
m_WParser->GetContainer()->InsertCell(new wxHtmlFontCell(m_WParser->CreateCurrentFont())); m_WParser->GetContainer()->InsertCell(
new wxHtmlFontCell(m_WParser->CreateCurrentFont()));
return TRUE; return TRUE;
} }
@@ -144,12 +143,14 @@ TAG_HANDLER_BEGIN(FACES_B, "B,STRONG")
int bold = m_WParser->GetFontBold(); int bold = m_WParser->GetFontBold();
m_WParser->SetFontBold(TRUE); m_WParser->SetFontBold(TRUE);
m_WParser->GetContainer()->InsertCell(new wxHtmlFontCell(m_WParser->CreateCurrentFont())); m_WParser->GetContainer()->InsertCell(
new wxHtmlFontCell(m_WParser->CreateCurrentFont()));
ParseInner(tag); ParseInner(tag);
m_WParser->SetFontBold(bold); m_WParser->SetFontBold(bold);
m_WParser->GetContainer()->InsertCell(new wxHtmlFontCell(m_WParser->CreateCurrentFont())); m_WParser->GetContainer()->InsertCell(
new wxHtmlFontCell(m_WParser->CreateCurrentFont()));
return TRUE; return TRUE;
} }
@@ -165,12 +166,14 @@ TAG_HANDLER_BEGIN(FACES_I, "I,EM,CITE,ADDRESS")
int italic = m_WParser->GetFontItalic(); int italic = m_WParser->GetFontItalic();
m_WParser->SetFontItalic(TRUE); m_WParser->SetFontItalic(TRUE);
m_WParser->GetContainer()->InsertCell(new wxHtmlFontCell(m_WParser->CreateCurrentFont())); m_WParser->GetContainer()->InsertCell(
new wxHtmlFontCell(m_WParser->CreateCurrentFont()));
ParseInner(tag); ParseInner(tag);
m_WParser->SetFontItalic(italic); m_WParser->SetFontItalic(italic);
m_WParser->GetContainer()->InsertCell(new wxHtmlFontCell(m_WParser->CreateCurrentFont())); m_WParser->GetContainer()->InsertCell(
new wxHtmlFontCell(m_WParser->CreateCurrentFont()));
return TRUE; return TRUE;
} }
@@ -186,12 +189,14 @@ TAG_HANDLER_BEGIN(FACES_TT, "TT,CODE,KBD,SAMP")
int fixed = m_WParser->GetFontFixed(); int fixed = m_WParser->GetFontFixed();
m_WParser->SetFontFixed(TRUE); m_WParser->SetFontFixed(TRUE);
m_WParser->GetContainer()->InsertCell(new wxHtmlFontCell(m_WParser->CreateCurrentFont())); m_WParser->GetContainer()->InsertCell(
new wxHtmlFontCell(m_WParser->CreateCurrentFont()));
ParseInner(tag); ParseInner(tag);
m_WParser->SetFontFixed(fixed); m_WParser->SetFontFixed(fixed);
m_WParser->GetContainer()->InsertCell(new wxHtmlFontCell(m_WParser->CreateCurrentFont())); m_WParser->GetContainer()->InsertCell(
new wxHtmlFontCell(m_WParser->CreateCurrentFont()));
return TRUE; return TRUE;
} }
@@ -264,7 +269,8 @@ TAG_HANDLER_BEGIN(Hx, "H1,H2,H3,H4,H5,H6")
m_WParser->SetFontFixed(old_f); m_WParser->SetFontFixed(old_f);
m_WParser->SetAlign(old_al); m_WParser->SetAlign(old_al);
m_WParser->GetContainer()->InsertCell(new wxHtmlFontCell(m_WParser->CreateCurrentFont())); m_WParser->GetContainer()->InsertCell(
new wxHtmlFontCell(m_WParser->CreateCurrentFont()));
m_WParser->CloseContainer(); m_WParser->CloseContainer();
m_WParser->OpenContainer(); m_WParser->OpenContainer();
c = m_WParser->GetContainer(); c = m_WParser->GetContainer();
@@ -284,12 +290,14 @@ TAG_HANDLER_BEGIN(BIGSMALL, "BIG,SMALL")
int sz = (tag.GetName() == wxT("BIG")) ? +1 : -1; int sz = (tag.GetName() == wxT("BIG")) ? +1 : -1;
m_WParser->SetFontSize(sz); m_WParser->SetFontSize(sz);
m_WParser->GetContainer()->InsertCell(new wxHtmlFontCell(m_WParser->CreateCurrentFont())); m_WParser->GetContainer()->InsertCell(
new wxHtmlFontCell(m_WParser->CreateCurrentFont()));
ParseInner(tag); ParseInner(tag);
m_WParser->SetFontSize(oldsize); m_WParser->SetFontSize(oldsize);
m_WParser->GetContainer()->InsertCell(new wxHtmlFontCell(m_WParser->CreateCurrentFont())); m_WParser->GetContainer()->InsertCell(
new wxHtmlFontCell(m_WParser->CreateCurrentFont()));
return TRUE; return TRUE;
} }

View File

@@ -80,7 +80,7 @@ TAG_HANDLER_BEGIN(HR, "HR")
c->SetAlign(tag); c->SetAlign(tag);
c->SetWidthFloat(tag); c->SetWidthFloat(tag);
sz = 1; sz = 1;
if (tag.HasParam(wxT("SIZE")) && tag.ScanParam(wxT("SIZE"), wxT("%i"), &sz) == 1) {} tag.GetParamAsInt(wxT("SIZE"), &sz);
c->InsertCell(new wxHtmlLineCell((int)((double)sz * m_WParser->GetPixelScale()))); c->InsertCell(new wxHtmlLineCell((int)((double)sz * m_WParser->GetPixelScale())));
m_WParser->CloseContainer(); m_WParser->CloseContainer();

View File

@@ -404,20 +404,24 @@ TAG_HANDLER_BEGIN(IMG, "IMG,MAP,AREA")
wxString mn = wxEmptyString; wxString mn = wxEmptyString;
str = m_WParser->GetFS()->OpenFile(tmp); str = m_WParser->GetFS()->OpenFile(tmp);
if (tag.HasParam(wxT("WIDTH"))) tag.ScanParam(wxT("WIDTH"), wxT("%i"), &w); if (tag.HasParam(wxT("WIDTH")))
if (tag.HasParam(wxT("HEIGHT"))) tag.ScanParam(wxT("HEIGHT"), wxT("%i"), &h); tag.GetParamAsInt(wxT("WIDTH"), &w);
if (tag.HasParam(wxT("HEIGHT")))
tag.GetParamAsInt(wxT("HEIGHT"), &h);
al = wxHTML_ALIGN_BOTTOM; al = wxHTML_ALIGN_BOTTOM;
if (tag.HasParam(wxT("ALIGN"))) if (tag.HasParam(wxT("ALIGN")))
{ {
wxString alstr = tag.GetParam(wxT("ALIGN")); wxString alstr = tag.GetParam(wxT("ALIGN"));
alstr.MakeUpper(); // for the case alignment was in ".." alstr.MakeUpper(); // for the case alignment was in ".."
if (alstr == wxT("TEXTTOP")) al = wxHTML_ALIGN_TOP; if (alstr == wxT("TEXTTOP"))
else if ((alstr == wxT("CENTER")) || (alstr == wxT("ABSCENTER"))) al = wxHTML_ALIGN_CENTER; al = wxHTML_ALIGN_TOP;
else if ((alstr == wxT("CENTER")) || (alstr == wxT("ABSCENTER")))
al = wxHTML_ALIGN_CENTER;
} }
if (tag.HasParam(wxT("USEMAP"))) if (tag.HasParam(wxT("USEMAP")))
{ {
mn = tag.GetParam( wxT("USEMAP") ); mn = tag.GetParam( wxT("USEMAP") );
if (mn[ (unsigned int) 0 ] == wxT('#')) if (mn.GetChar(0) == wxT('#'))
{ {
mn = mn.Mid( 1 ); mn = mn.Mid( 1 );
} }

View File

@@ -174,43 +174,23 @@ TAG_HANDLER_BEGIN(BODY, "BODY")
TAG_HANDLER_PROC(tag) TAG_HANDLER_PROC(tag)
{ {
unsigned long tmp;
wxColour clr; wxColour clr;
if (tag.HasParam(wxT("TEXT"))) if (tag.GetParamAsColour(wxT("TEXT"), &clr))
{ {
if (tag.ScanParam(wxT("TEXT"), wxT("#%lX"), &tmp) == 1) m_WParser->SetActualColor(clr);
{ m_WParser->GetContainer()->InsertCell(new wxHtmlColourCell(clr));
clr = wxColour((unsigned char)((tmp & 0xFF0000) >> 16),
(unsigned char)((tmp & 0x00FF00) >> 8),
(unsigned char)(tmp & 0x0000FF));
m_WParser->SetActualColor(clr);
m_WParser->GetContainer()->InsertCell(new wxHtmlColourCell(clr));
}
}
if (tag.HasParam(wxT("LINK")))
{
if (tag.ScanParam(wxT("LINK"), wxT("#%lX"), &tmp) == 1)
{
clr = wxColour((unsigned char)((tmp & 0xFF0000) >> 16),
(unsigned char)((tmp & 0x00FF00) >> 8),
(unsigned char)(tmp & 0x0000FF));
m_WParser->SetLinkColor(clr);
}
} }
if (tag.HasParam(wxT("BGCOLOR"))) if (tag.GetParamAsColour(wxT("LINK"), &clr))
m_WParser->SetLinkColor(clr);
if (tag.GetParamAsColour(wxT("BGCOLOR"), &clr))
{ {
if (tag.ScanParam(wxT("BGCOLOR"), wxT("#%lX"), &tmp) == 1) m_WParser->GetContainer()->InsertCell(
{ new wxHtmlColourCell(clr, wxHTML_CLR_BACKGROUND));
clr = wxColour((unsigned char)((tmp & 0xFF0000) >> 16), if (m_WParser->GetWindow() != NULL)
(unsigned char)((tmp & 0x00FF00) >> 8), m_WParser->GetWindow()->SetBackgroundColour(clr);
(unsigned char)(tmp & 0x0000FF));
m_WParser->GetContainer()->InsertCell(new wxHtmlColourCell(clr, wxHTML_CLR_BACKGROUND));
if (m_WParser->GetWindow() != NULL)
m_WParser->GetWindow()->SetBackgroundColour(clr);
}
} }
return FALSE; return FALSE;
} }

View File

@@ -49,8 +49,10 @@ FORCE_LINK_ME(m_tables)
typedef struct { typedef struct {
int width, units; // universal int width, units;
int leftpos, pixwidth, maxrealwidth; // temporary (depends on width of table) // universal
int leftpos, pixwidth, maxrealwidth;
// temporary (depends on width of table)
} colStruct; } colStruct;
typedef enum { typedef enum {
@@ -90,7 +92,7 @@ class wxHtmlTableCell : public wxHtmlContainerCell
// number of actual column (ranging from 0..m_NumCols) // number of actual column (ranging from 0..m_NumCols)
// default values (for table and row): // default values (for table and row):
int m_tBkg, m_rBkg; wxColour m_tBkg, m_rBkg;
wxString m_tValign, m_rValign; wxString m_tValign, m_rValign;
double m_PixelScale; double m_PixelScale;
@@ -117,18 +119,23 @@ wxHtmlTableCell::wxHtmlTableCell(wxHtmlContainerCell *parent, const wxHtmlTag& t
: wxHtmlContainerCell(parent) : wxHtmlContainerCell(parent)
{ {
m_PixelScale = pixel_scale; m_PixelScale = pixel_scale;
m_HasBorders = (tag.HasParam(wxT("BORDER")) && tag.GetParam(wxT("BORDER")) != wxT("0")); m_HasBorders = (tag.GetParam(wxT("BORDER")) != wxT("0"));
m_ColsInfo = NULL; m_ColsInfo = NULL;
m_NumCols = m_NumRows = 0; m_NumCols = m_NumRows = 0;
m_CellInfo = NULL; m_CellInfo = NULL;
m_ActualCol = m_ActualRow = -1; m_ActualCol = m_ActualRow = -1;
/* scan params: */ /* scan params: */
m_tBkg = m_rBkg = -1; if (tag.HasParam(wxT("BGCOLOR")))
if (tag.HasParam(wxT("BGCOLOR"))) tag.ScanParam(wxT("BGCOLOR"), wxT("#%lX"), &m_tBkg); tag.GetParamAsColour(wxT("BGCOLOR"), &m_tBkg);
if (tag.HasParam(wxT("VALIGN"))) m_tValign = tag.GetParam(wxT("VALIGN")); else m_tValign = wxEmptyString; if (tag.HasParam(wxT("VALIGN")))
if (tag.HasParam(wxT("CELLSPACING")) && tag.ScanParam(wxT("CELLSPACING"), wxT("%i"), &m_Spacing) == 1) {} else m_Spacing = 2; m_tValign = tag.GetParam(wxT("VALIGN"));
if (tag.HasParam(wxT("CELLPADDING")) && tag.ScanParam(wxT("CELLPADDING"), wxT("%i"), &m_Padding) == 1) {} else m_Padding = 3; else
m_tValign = wxEmptyString;
if (!tag.GetParamAsInt(wxT("CELLSPACING"), &m_Spacing))
m_Spacing = 2;
if (!tag.GetParamAsInt(wxT("CELLPADDING"), &m_Padding))
m_Padding = 3;
m_Spacing = (int)(m_PixelScale * (double)m_Spacing); m_Spacing = (int)(m_PixelScale * (double)m_Spacing);
m_Padding = (int)(m_PixelScale * (double)m_Padding); m_Padding = (int)(m_PixelScale * (double)m_Padding);
@@ -202,7 +209,7 @@ void wxHtmlTableCell::AddRow(const wxHtmlTag& tag)
// scan params: // scan params:
m_rBkg = m_tBkg; m_rBkg = m_tBkg;
if (tag.HasParam(wxT("BGCOLOR"))) if (tag.HasParam(wxT("BGCOLOR")))
tag.ScanParam(wxT("BGCOLOR"), wxT("#%lX"), &m_rBkg); tag.GetParamAsColour(wxT("BGCOLOR"), &m_rBkg);
if (tag.HasParam(wxT("VALIGN"))) if (tag.HasParam(wxT("VALIGN")))
m_rValign = tag.GetParam(wxT("VALIGN")); m_rValign = tag.GetParam(wxT("VALIGN"));
else else
@@ -226,7 +233,8 @@ void wxHtmlTableCell::AddCell(wxHtmlContainerCell *cell, const wxHtmlTag& tag)
do do
{ {
m_ActualCol++; m_ActualCol++;
} while ((m_ActualCol < m_NumCols) && (m_CellInfo[m_ActualRow][m_ActualCol].flag != cellFree)); } while ((m_ActualCol < m_NumCols) &&
(m_CellInfo[m_ActualRow][m_ActualCol].flag != cellFree));
if (m_ActualCol > m_NumCols - 1) if (m_ActualCol > m_NumCols - 1)
ReallocCols(m_ActualCol + 1); ReallocCols(m_ActualCol + 1);
@@ -244,11 +252,11 @@ void wxHtmlTableCell::AddCell(wxHtmlContainerCell *cell, const wxHtmlTag& tag)
// width: // width:
{ {
if (tag.HasParam("WIDTH")) if (tag.HasParam(wxT("WIDTH")))
{ {
wxString wd = tag.GetParam("WIDTH"); wxString wd = tag.GetParam(wxT("WIDTH"));
if (wd[wd.Length()-1] == '%') if (wd[wd.Length()-1] == wxT('%'))
{ {
wxSscanf(wd.c_str(), wxT("%i%%"), &m_ColsInfo[c].width); wxSscanf(wd.c_str(), wxT("%i%%"), &m_ColsInfo[c].width);
m_ColsInfo[c].units = wxHTML_UNITS_PERCENT; m_ColsInfo[c].units = wxHTML_UNITS_PERCENT;
@@ -265,14 +273,16 @@ void wxHtmlTableCell::AddCell(wxHtmlContainerCell *cell, const wxHtmlTag& tag)
// spanning: // spanning:
{ {
if (tag.HasParam(wxT("COLSPAN"))) tag.ScanParam(wxT("COLSPAN"), wxT("%i"), &m_CellInfo[r][c].colspan); tag.GetParamAsInt(wxT("COLSPAN"), &m_CellInfo[r][c].colspan);
if (tag.HasParam(wxT("ROWSPAN"))) tag.ScanParam(wxT("ROWSPAN"), wxT("%i"), &m_CellInfo[r][c].rowspan); tag.GetParamAsInt(wxT("ROWSPAN"), &m_CellInfo[r][c].rowspan);
if ((m_CellInfo[r][c].colspan != 1) || (m_CellInfo[r][c].rowspan != 1)) if ((m_CellInfo[r][c].colspan != 1) || (m_CellInfo[r][c].rowspan != 1))
{ {
int i, j; int i, j;
if (r + m_CellInfo[r][c].rowspan > m_NumRows) ReallocRows(r + m_CellInfo[r][c].rowspan); if (r + m_CellInfo[r][c].rowspan > m_NumRows)
if (c + m_CellInfo[r][c].colspan > m_NumCols) ReallocCols(c + m_CellInfo[r][c].colspan); ReallocRows(r + m_CellInfo[r][c].rowspan);
if (c + m_CellInfo[r][c].colspan > m_NumCols)
ReallocCols(c + m_CellInfo[r][c].colspan);
for (i = r; i < r + m_CellInfo[r][c].rowspan; i++) for (i = r; i < r + m_CellInfo[r][c].rowspan; i++)
for (j = c; j < c + m_CellInfo[r][c].colspan; j++) for (j = c; j < c + m_CellInfo[r][c].colspan; j++)
m_CellInfo[i][j].flag = cellSpan; m_CellInfo[i][j].flag = cellSpan;
@@ -282,13 +292,11 @@ void wxHtmlTableCell::AddCell(wxHtmlContainerCell *cell, const wxHtmlTag& tag)
//background color: //background color:
{ {
int bk = m_rBkg; wxColour bk = m_rBkg;
if (tag.HasParam(wxT("BGCOLOR"))) tag.ScanParam(wxT("BGCOLOR"), wxT("#%lX"), &bk); if (tag.HasParam(wxT("BGCOLOR")))
if (bk != -1) tag.GetParamAsColour(wxT("BGCOLOR"), &bk);
{ if (bk.Ok())
wxColour clr = wxColour((bk & 0xFF0000) >> 16 , (bk & 0x00FF00) >> 8, (bk & 0x0000FF)); cell->SetBackgroundColour(bk);
cell->SetBackgroundColour(clr);
}
} }
if (m_HasBorders) if (m_HasBorders)
cell->SetBorder(TABLE_BORDER_CLR_2, TABLE_BORDER_CLR_1); cell->SetBorder(TABLE_BORDER_CLR_2, TABLE_BORDER_CLR_1);
@@ -296,10 +304,15 @@ void wxHtmlTableCell::AddCell(wxHtmlContainerCell *cell, const wxHtmlTag& tag)
// vertical alignment: // vertical alignment:
{ {
wxString valign; wxString valign;
if (tag.HasParam(wxT("VALIGN"))) valign = tag.GetParam(wxT("VALIGN")); else valign = m_tValign; if (tag.HasParam(wxT("VALIGN")))
valign = tag.GetParam(wxT("VALIGN"));
else
valign = m_tValign;
valign.MakeUpper(); valign.MakeUpper();
if (valign == wxT("TOP")) m_CellInfo[r][c].valign = wxHTML_ALIGN_TOP; if (valign == wxT("TOP"))
else if (valign == wxT("BOTTOM")) m_CellInfo[r][c].valign = wxHTML_ALIGN_BOTTOM; m_CellInfo[r][c].valign = wxHTML_ALIGN_TOP;
else if (valign == wxT("BOTTOM"))
m_CellInfo[r][c].valign = wxHTML_ALIGN_BOTTOM;
else m_CellInfo[r][c].valign = wxHTML_ALIGN_CENTER; else m_CellInfo[r][c].valign = wxHTML_ALIGN_CENTER;
} }
@@ -470,7 +483,8 @@ TAG_HANDLER_BEGIN(TABLE, "TABLE,TR,TD,TH")
m_Table = new wxHtmlTableCell(c, tag, m_WParser->GetPixelScale()); m_Table = new wxHtmlTableCell(c, tag, m_WParser->GetPixelScale());
m_OldAlign = m_WParser->GetAlign(); m_OldAlign = m_WParser->GetAlign();
m_tAlign = wxEmptyString; m_tAlign = wxEmptyString;
if (tag.HasParam(wxT("ALIGN"))) m_tAlign = tag.GetParam(wxT("ALIGN")); if (tag.HasParam(wxT("ALIGN")))
m_tAlign = tag.GetParam(wxT("ALIGN"));
ParseInner(tag); ParseInner(tag);
@@ -489,7 +503,8 @@ TAG_HANDLER_BEGIN(TABLE, "TABLE,TR,TD,TH")
{ {
m_Table->AddRow(tag); m_Table->AddRow(tag);
m_rAlign = m_tAlign; m_rAlign = m_tAlign;
if (tag.HasParam(wxT("ALIGN"))) m_rAlign = tag.GetParam(wxT("ALIGN")); if (tag.HasParam(wxT("ALIGN")))
m_rAlign = tag.GetParam(wxT("ALIGN"));
} }
// new cell // new cell
@@ -510,10 +525,13 @@ TAG_HANDLER_BEGIN(TABLE, "TABLE,TR,TD,TH")
wxString als; wxString als;
als = m_rAlign; als = m_rAlign;
if (tag.HasParam(wxT("ALIGN"))) als = tag.GetParam(wxT("ALIGN")); if (tag.HasParam(wxT("ALIGN")))
als = tag.GetParam(wxT("ALIGN"));
als.MakeUpper(); als.MakeUpper();
if (als == wxT("RIGHT")) m_WParser->SetAlign(wxHTML_ALIGN_RIGHT); if (als == wxT("RIGHT"))
else if (als == wxT("CENTER")) m_WParser->SetAlign(wxHTML_ALIGN_CENTER); m_WParser->SetAlign(wxHTML_ALIGN_RIGHT);
else if (als == wxT("CENTER"))
m_WParser->SetAlign(wxHTML_ALIGN_CENTER);
} }
m_WParser->OpenContainer(); m_WParser->OpenContainer();
} }