]> git.saurik.com Git - wxWidgets.git/blame - src/html/m_span.cpp
avoid deprecated functions and direct struct access
[wxWidgets.git] / src / html / m_span.cpp
CommitLineData
f68e16c5
VZ
1/////////////////////////////////////////////////////////////////////////////
2// Name: src/html/m_span.cpp
3// Purpose: wxHtml module for span handling
4// Author: Nigel Paton
5// RCS-ID: $Id$
6// Copyright: wxWidgets team
7// Licence: wxWindows licence
8/////////////////////////////////////////////////////////////////////////////
9
10#include "wx/wxprec.h"
11
12#ifdef __BORLANDC__
13 #pragma hdrstop
14#endif
15
16#if wxUSE_HTML
17
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"
23
24FORCE_LINK_ME(m_span)
25
26
27TAG_HANDLER_BEGIN(SPAN, "SPAN" )
28
29 TAG_HANDLER_VARS
30 wxArrayString m_Faces;
31
32 TAG_HANDLER_CONSTR(SPAN) { }
33
34 TAG_HANDLER_PROC(tag)
35 {
36 wxColour oldclr = m_WParser->GetActualColor();
37 int oldsize = m_WParser->GetFontSize();
38 int oldbold = m_WParser->GetFontBold();
39
40 // Load any style parameters
41 wxHtmlStyleParams styleParams(tag);
42
43 wxString str;
44
45 str = styleParams.GetParam(wxS("color"));
46 if ( !str.empty() )
47 {
48 wxColour clr;
49 if ( wxHtmlTag::ParseAsColour(str, &clr) )
50 {
51 m_WParser->SetActualColor(clr);
52 m_WParser->GetContainer()->InsertCell(new wxHtmlColourCell(clr));
53 }
54 }
55
56 str = styleParams.GetParam(wxS("font-size"));
57 if ( !str.empty() )
58 {
59 // Point size
60 int foundIndex = str.Find(wxS("pt"));
61 if (foundIndex != wxNOT_FOUND)
62 {
63 str.Truncate(foundIndex);
64
65 long sizeValue;
66 if (str.ToLong(&sizeValue) == true)
67 {
68 // Set point size
69 m_WParser->SetFontPointSize(sizeValue);
70 m_WParser->GetContainer()->InsertCell(
71 new wxHtmlFontCell(m_WParser->CreateCurrentFont()));
72 }
73 }
74 // else: check for other ways of specifying size (TODO)
75 }
76
77 str = styleParams.GetParam(wxS("font-weight"));
78 if ( !str.empty() )
79 {
80 // Only bold and normal supported just now
81 if ( str == wxS("bold") )
82 {
83 m_WParser->SetFontBold(true);
84 m_WParser->GetContainer()->InsertCell(
85 new wxHtmlFontCell(m_WParser->CreateCurrentFont()));
86 }
87 else if ( str == wxS("normal") )
88 {
89 m_WParser->SetFontBold(false);
90 m_WParser->GetContainer()->InsertCell(
91 new wxHtmlFontCell(m_WParser->CreateCurrentFont()));
92 }
93 }
94
95 ParseInner(tag);
96
97 if (oldbold != m_WParser->GetFontBold())
98 {
99 m_WParser->SetFontBold(oldbold);
100 m_WParser->GetContainer()->InsertCell(new wxHtmlFontCell(m_WParser->CreateCurrentFont()));
101 }
102 if (oldsize != m_WParser->GetFontSize())
103 {
104 m_WParser->SetFontSize(oldsize);
105 m_WParser->GetContainer()->InsertCell(new wxHtmlFontCell(m_WParser->CreateCurrentFont()));
106 }
107 if (oldclr != m_WParser->GetActualColor())
108 {
109 m_WParser->SetActualColor(oldclr);
110 m_WParser->GetContainer()->InsertCell(new wxHtmlColourCell(oldclr));
111 }
112
113 return true;
114 }
115
116TAG_HANDLER_END(SPAN)
117
118
119TAGS_MODULE_BEGIN(Spans)
120
121 TAGS_MODULE_ADD(SPAN)
122
123TAGS_MODULE_END(Spans)
124
125#endif // wxUSE_HTML