]>
git.saurik.com Git - wxWidgets.git/blob - src/html/m_span.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/html/m_span.cpp
3 // Purpose: wxHtml module for span handling
6 // Copyright: wxWidgets team
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
10 #include "wx/wxprec.h"
18 #include "wx/html/forcelnk.h"
19 #include "wx/html/m_templ.h"
20 #include "wx/fontenum.h"
21 #include "wx/tokenzr.h"
22 #include "wx/html/styleparams.h"
27 TAG_HANDLER_BEGIN(SPAN
, "SPAN" )
30 wxArrayString m_Faces
;
32 TAG_HANDLER_CONSTR(SPAN
) { }
36 wxColour oldclr
= m_WParser
->GetActualColor();
37 int oldsize
= m_WParser
->GetFontSize();
38 int oldbold
= m_WParser
->GetFontBold();
39 int olditalic
= m_WParser
->GetFontItalic();
40 int oldunderlined
= m_WParser
->GetFontUnderlined();
41 wxString oldfontface
= m_WParser
->GetFontFace();
43 // Load any style parameters
44 wxHtmlStyleParams
styleParams(tag
);
48 str
= styleParams
.GetParam(wxS("color"));
52 if ( wxHtmlTag::ParseAsColour(str
, &clr
) )
54 m_WParser
->SetActualColor(clr
);
55 m_WParser
->GetContainer()->InsertCell(new wxHtmlColourCell(clr
));
59 str
= styleParams
.GetParam(wxS("font-size"));
63 int foundIndex
= str
.Find(wxS("pt"));
64 if (foundIndex
!= wxNOT_FOUND
)
66 str
.Truncate(foundIndex
);
69 if (str
.ToLong(&sizeValue
) == true)
72 m_WParser
->SetFontPointSize(sizeValue
);
73 m_WParser
->GetContainer()->InsertCell(
74 new wxHtmlFontCell(m_WParser
->CreateCurrentFont()));
77 // else: check for other ways of specifying size (TODO)
80 str
= styleParams
.GetParam(wxS("font-weight"));
83 // Only bold and normal supported just now
84 if ( str
== wxS("bold") )
86 m_WParser
->SetFontBold(true);
87 m_WParser
->GetContainer()->InsertCell(
88 new wxHtmlFontCell(m_WParser
->CreateCurrentFont()));
90 else if ( str
== wxS("normal") )
92 m_WParser
->SetFontBold(false);
93 m_WParser
->GetContainer()->InsertCell(
94 new wxHtmlFontCell(m_WParser
->CreateCurrentFont()));
98 str
= styleParams
.GetParam(wxS("font-style"));
101 // "oblique" and "italic" are more or less the same.
102 // "inherit" (using the parent font) is not supported.
103 if ( str
== wxS("oblique") || str
== wxS("italic") )
105 m_WParser
->SetFontItalic(true);
106 m_WParser
->GetContainer()->InsertCell(
107 new wxHtmlFontCell(m_WParser
->CreateCurrentFont()));
109 else if ( str
== wxS("normal") )
111 m_WParser
->SetFontItalic(false);
112 m_WParser
->GetContainer()->InsertCell(
113 new wxHtmlFontCell(m_WParser
->CreateCurrentFont()));
117 str
= styleParams
.GetParam(wxS("text-decoration"));
120 // Only underline is supported.
121 if ( str
== wxS("underline") )
123 m_WParser
->SetFontUnderlined(true);
124 m_WParser
->GetContainer()->InsertCell(
125 new wxHtmlFontCell(m_WParser
->CreateCurrentFont()));
129 str
= styleParams
.GetParam(wxS("font-family"));
132 m_WParser
->SetFontFace(str
);
133 m_WParser
->GetContainer()->InsertCell(
134 new wxHtmlFontCell(m_WParser
->CreateCurrentFont()));
139 m_WParser
->SetFontSize(oldsize
);
140 m_WParser
->SetFontBold(oldbold
);
141 m_WParser
->SetFontUnderlined(oldunderlined
);
142 m_WParser
->SetFontFace(oldfontface
);
143 m_WParser
->SetFontItalic(olditalic
);
144 m_WParser
->GetContainer()->InsertCell(
145 new wxHtmlFontCell(m_WParser
->CreateCurrentFont()));
147 if (oldclr
!= m_WParser
->GetActualColor())
149 m_WParser
->SetActualColor(oldclr
);
150 m_WParser
->GetContainer()->InsertCell(
151 new wxHtmlColourCell(oldclr
));
157 TAG_HANDLER_END(SPAN
)
160 TAGS_MODULE_BEGIN(Spans
)
162 TAGS_MODULE_ADD(SPAN
)
164 TAGS_MODULE_END(Spans
)