]> git.saurik.com Git - wxWidgets.git/blame - src/html/styleparams.cpp
Rename wxWebNavigationError to wxWebViewNavigationError and wxWebNavigationEvent...
[wxWidgets.git] / src / html / styleparams.cpp
CommitLineData
f68e16c5
VZ
1/////////////////////////////////////////////////////////////////////////////
2// Name: src/html/styleparams.cpp
3// Purpose: wxHtml helper code for extracting style parameters
4// Author: Nigel Paton
5// RCS-ID: $Id$
6// Copyright: wxWidgets team
7// Licence: wxWindows licence
8/////////////////////////////////////////////////////////////////////////////
9
10#include "wx/wxprec.h"
11#include "wx/tokenzr.h"
12#include "wx/html/htmltag.h"
13#include "wx/html/styleparams.h"
14
15#ifdef __BORLANDC__
16 #pragma hdrstop
17#endif
18
19#if wxUSE_HTML
20
21wxHtmlStyleParams::wxHtmlStyleParams(const wxHtmlTag& tag)
22{
23 wxString wd = tag.GetParam(wxT("STYLE"));
24
25 // Make sure no whitespace
26 wd.Trim(true).Trim(false);
27 if ( wd.empty() )
28 return;
29
30 // Check for bracketed entries
31 // Only support element properties and not pseudo-element or pseudo-classes
32 if (wd.Find('{') == 0)
33 {
34 // Extract string up to end bracket
35 int endBracket = wd.Find('}');
36 if (endBracket != wxNOT_FOUND)
37 {
38 // Replace original string with bracketed options
39 wd = wd.SubString(1, endBracket - 1);
40 // Make sure no whitespace
41 wd.Trim(true).Trim(false);
42 }
43 else
44 {
45 // Syntax problem change to blank string
46 wd = "";
47 }
48 }
49
50 // Should now have a semi-colon delimited list of options
51 // Each option is a name and a value separated by a colon
52 // Split the list into names and values
53 wxStringTokenizer tkz(wd, wxT(";"), wxTOKEN_STRTOK);
54 while ( tkz.HasMoreTokens() )
55 {
56 wxString token = tkz.GetNextToken();
57 // Split into name and value
58 int colonIndex = token.Find(':');
59 if ((colonIndex != wxNOT_FOUND) && // Not a name value pair
60 (colonIndex != 0)) // No name
61 {
62 wxString tempString;
63 // Extract and trim name
64 tempString = token.SubString(0, colonIndex - 1);
65 tempString.Trim(true).Trim(false);
66 // Add to name list
67 m_names.Add(tempString);
68
69 // Extract and trim values
70 tempString = token.SubString(colonIndex + 1, token.Length() - 1);
71 tempString.Trim(true).Trim(false);
72 // Add to values list
73 m_values.Add(tempString);
74 }
75 }
76}
77
78#endif // wxUSE_HTML