Add <span> tag and limited support for CSS styles to wxHTML.
Parse "style" attributes of the HTML tags and honour those of them that can be mapped to the HTML 3 attributes. Also add a handler for <span> tag. Closes #10631. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@64443 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -23,6 +23,8 @@
|
||||
#endif
|
||||
|
||||
#include "wx/html/htmlpars.h"
|
||||
#include "wx/html/styleparams.h"
|
||||
|
||||
#include "wx/vector.h"
|
||||
|
||||
#include <stdio.h> // for vsscanf
|
||||
@@ -430,6 +432,32 @@ wxHtmlTag::wxHtmlTag(wxHtmlTag *parent,
|
||||
#if WXWIN_COMPATIBILITY_2_8
|
||||
m_sourceStart = source->begin();
|
||||
#endif
|
||||
|
||||
// Try to parse any style parameters that can be handled simply by
|
||||
// converting them to the equivalent HTML 3 attributes: this is a far cry
|
||||
// from perfect but better than nothing.
|
||||
static const struct EquivAttr
|
||||
{
|
||||
const char *style;
|
||||
const char *attr;
|
||||
} equivAttrs[] =
|
||||
{
|
||||
{ "text-align", "ALIGN" },
|
||||
{ "width", "WIDTH" },
|
||||
{ "vertical-align", "VALIGN" },
|
||||
{ "background", "BGCOLOR" },
|
||||
};
|
||||
|
||||
wxHtmlStyleParams styleParams(*this);
|
||||
for ( unsigned n = 0; n < WXSIZEOF(equivAttrs); n++ )
|
||||
{
|
||||
const EquivAttr& ea = equivAttrs[n];
|
||||
if ( styleParams.HasParam(ea.style) && !HasParam(ea.attr) )
|
||||
{
|
||||
m_ParamNames.Add(ea.attr);
|
||||
m_ParamValues.Add(styleParams.GetParam(ea.style));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
wxHtmlTag::~wxHtmlTag()
|
||||
@@ -481,12 +509,11 @@ int wxHtmlTag::ScanParam(const wxString& par,
|
||||
return wxSscanf(parval, format, param);
|
||||
}
|
||||
|
||||
bool wxHtmlTag::GetParamAsColour(const wxString& par, wxColour *clr) const
|
||||
/* static */
|
||||
bool wxHtmlTag::ParseAsColour(const wxString& str, wxColour *clr)
|
||||
{
|
||||
wxCHECK_MSG( clr, false, wxT("invalid colour argument") );
|
||||
|
||||
wxString str = GetParam(par);
|
||||
|
||||
// handle colours defined in HTML 4.0 first:
|
||||
if (str.length() > 1 && str[0] != wxT('#'))
|
||||
{
|
||||
@@ -522,6 +549,12 @@ bool wxHtmlTag::GetParamAsColour(const wxString& par, wxColour *clr) const
|
||||
return false;
|
||||
}
|
||||
|
||||
bool wxHtmlTag::GetParamAsColour(const wxString& par, wxColour *clr) const
|
||||
{
|
||||
const wxString str = GetParam(par);
|
||||
return !str.empty() && ParseAsColour(str, clr);
|
||||
}
|
||||
|
||||
bool wxHtmlTag::GetParamAsInt(const wxString& par, int *clr) const
|
||||
{
|
||||
if ( !HasParam(par) )
|
||||
|
Reference in New Issue
Block a user