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:
78
src/html/styleparams.cpp
Normal file
78
src/html/styleparams.cpp
Normal file
@@ -0,0 +1,78 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: src/html/styleparams.cpp
|
||||
// Purpose: wxHtml helper code for extracting style parameters
|
||||
// Author: Nigel Paton
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: wxWidgets team
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "wx/wxprec.h"
|
||||
#include "wx/tokenzr.h"
|
||||
#include "wx/html/htmltag.h"
|
||||
#include "wx/html/styleparams.h"
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#if wxUSE_HTML
|
||||
|
||||
wxHtmlStyleParams::wxHtmlStyleParams(const wxHtmlTag& tag)
|
||||
{
|
||||
wxString wd = tag.GetParam(wxT("STYLE"));
|
||||
|
||||
// Make sure no whitespace
|
||||
wd.Trim(true).Trim(false);
|
||||
if ( wd.empty() )
|
||||
return;
|
||||
|
||||
// Check for bracketed entries
|
||||
// Only support element properties and not pseudo-element or pseudo-classes
|
||||
if (wd.Find('{') == 0)
|
||||
{
|
||||
// Extract string up to end bracket
|
||||
int endBracket = wd.Find('}');
|
||||
if (endBracket != wxNOT_FOUND)
|
||||
{
|
||||
// Replace original string with bracketed options
|
||||
wd = wd.SubString(1, endBracket - 1);
|
||||
// Make sure no whitespace
|
||||
wd.Trim(true).Trim(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Syntax problem change to blank string
|
||||
wd = "";
|
||||
}
|
||||
}
|
||||
|
||||
// Should now have a semi-colon delimited list of options
|
||||
// Each option is a name and a value separated by a colon
|
||||
// Split the list into names and values
|
||||
wxStringTokenizer tkz(wd, wxT(";"), wxTOKEN_STRTOK);
|
||||
while ( tkz.HasMoreTokens() )
|
||||
{
|
||||
wxString token = tkz.GetNextToken();
|
||||
// Split into name and value
|
||||
int colonIndex = token.Find(':');
|
||||
if ((colonIndex != wxNOT_FOUND) && // Not a name value pair
|
||||
(colonIndex != 0)) // No name
|
||||
{
|
||||
wxString tempString;
|
||||
// Extract and trim name
|
||||
tempString = token.SubString(0, colonIndex - 1);
|
||||
tempString.Trim(true).Trim(false);
|
||||
// Add to name list
|
||||
m_names.Add(tempString);
|
||||
|
||||
// Extract and trim values
|
||||
tempString = token.SubString(colonIndex + 1, token.Length() - 1);
|
||||
tempString.Trim(true).Trim(false);
|
||||
// Add to values list
|
||||
m_values.Add(tempString);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif // wxUSE_HTML
|
||||
Reference in New Issue
Block a user