]>
git.saurik.com Git - wxWidgets.git/blob - src/html/styleparams.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/html/styleparams.cpp
3 // Purpose: wxHtml helper code for extracting style parameters
5 // Copyright: wxWidgets team
6 // Licence: wxWindows licence
7 /////////////////////////////////////////////////////////////////////////////
10 #include "wx/tokenzr.h"
11 #include "wx/html/htmltag.h"
12 #include "wx/html/styleparams.h"
20 wxHtmlStyleParams::wxHtmlStyleParams(const wxHtmlTag
& tag
)
22 wxString wd
= tag
.GetParam(wxT("STYLE"));
24 // Make sure no whitespace
25 wd
.Trim(true).Trim(false);
29 // Check for bracketed entries
30 // Only support element properties and not pseudo-element or pseudo-classes
31 if (wd
.Find('{') == 0)
33 // Extract string up to end bracket
34 int endBracket
= wd
.Find('}');
35 if (endBracket
!= wxNOT_FOUND
)
37 // Replace original string with bracketed options
38 wd
= wd
.SubString(1, endBracket
- 1);
39 // Make sure no whitespace
40 wd
.Trim(true).Trim(false);
44 // Syntax problem change to blank string
49 // Should now have a semi-colon delimited list of options
50 // Each option is a name and a value separated by a colon
51 // Split the list into names and values
52 wxStringTokenizer
tkz(wd
, wxT(";"), wxTOKEN_STRTOK
);
53 while ( tkz
.HasMoreTokens() )
55 wxString token
= tkz
.GetNextToken();
56 // Split into name and value
57 int colonIndex
= token
.Find(':');
58 if ((colonIndex
!= wxNOT_FOUND
) && // Not a name value pair
59 (colonIndex
!= 0)) // No name
62 // Extract and trim name
63 tempString
= token
.SubString(0, colonIndex
- 1);
64 tempString
.Trim(true).Trim(false);
66 m_names
.Add(tempString
);
68 // Extract and trim values
69 tempString
= token
.SubString(colonIndex
+ 1, token
.Length() - 1);
70 tempString
.Trim(true).Trim(false);
72 m_values
.Add(tempString
);