]>
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
6 // Copyright: wxWidgets team
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
10 #include "wx/wxprec.h"
11 #include "wx/tokenzr.h"
12 #include "wx/html/htmltag.h"
13 #include "wx/html/styleparams.h"
21 wxHtmlStyleParams::wxHtmlStyleParams(const wxHtmlTag
& tag
)
23 wxString wd
= tag
.GetParam(wxT("STYLE"));
25 // Make sure no whitespace
26 wd
.Trim(true).Trim(false);
30 // Check for bracketed entries
31 // Only support element properties and not pseudo-element or pseudo-classes
32 if (wd
.Find('{') == 0)
34 // Extract string up to end bracket
35 int endBracket
= wd
.Find('}');
36 if (endBracket
!= wxNOT_FOUND
)
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);
45 // Syntax problem change to blank string
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() )
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
63 // Extract and trim name
64 tempString
= token
.SubString(0, colonIndex
- 1);
65 tempString
.Trim(true).Trim(false);
67 m_names
.Add(tempString
);
69 // Extract and trim values
70 tempString
= token
.SubString(colonIndex
+ 1, token
.Length() - 1);
71 tempString
.Trim(true).Trim(false);
73 m_values
.Add(tempString
);