]>
git.saurik.com Git - wxWidgets.git/blob - src/html/mod_fonts.cpp
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxHtml module for fonts & colors of fonts
4 // Author: Vaclav Slavik
5 // Copyright: (c) 1999 Vaclav Slavik
6 // Licence: wxWindows Licence
7 /////////////////////////////////////////////////////////////////////////////
10 #pragma implementation
13 #include <wx/wxprec.h>
26 #include <wx/html/forcelink.h>
27 #include <wx/html/mod_templ.h>
29 FORCE_LINK_ME(mod_fonts
)
32 TAG_HANDLER_BEGIN(FONT
, "FONT")
36 wxColour oldclr
= m_WParser
-> GetActualColor();
37 int oldsize
= m_WParser
-> GetFontSize();
39 if (tag
.HasParam("COLOR")) {
40 unsigned long tmp
= 0;
42 if (tag
.ScanParam("COLOR", "#%lX", &tmp
) == 1) {
43 clr
= wxColour((tmp
& 0xFF0000) >> 16 , (tmp
& 0x00FF00) >> 8, (tmp
& 0x0000FF));
44 m_WParser
-> SetActualColor(clr
);
45 m_WParser
-> GetContainer() -> InsertCell(new wxHtmlColourCell(clr
));
49 if (tag
.HasParam("SIZE")) {
51 if (tag
.ScanParam("SIZE", "%li", &tmp
) == 1) {
52 m_WParser
-> SetFontSize(oldsize
+tmp
);
53 m_WParser
-> GetContainer() -> InsertCell(new wxHtmlFontCell(m_WParser
-> CreateCurrentFont()));
59 if (oldclr
!= m_WParser
-> GetActualColor()) {
60 m_WParser
-> SetActualColor(oldclr
);
61 m_WParser
-> GetContainer() -> InsertCell(new wxHtmlColourCell(oldclr
));
63 if (oldsize
!= m_WParser
-> GetFontSize()) {
64 m_WParser
-> SetFontSize(oldsize
);
65 m_WParser
-> GetContainer() -> InsertCell(new wxHtmlFontCell(m_WParser
-> CreateCurrentFont()));
73 TAG_HANDLER_BEGIN(FACES
, "U,I,B,TT")
77 int fixed
= m_WParser
-> GetFontFixed(),
78 italic
= m_WParser
-> GetFontItalic(),
79 underlined
= m_WParser
-> GetFontUnderlined(),
80 bold
= m_WParser
-> GetFontBold();
82 if (tag
.GetName() == "U")
83 m_WParser
-> SetFontUnderlined(TRUE
);
84 else if (tag
.GetName() == "B")
85 m_WParser
-> SetFontBold(TRUE
);
86 else if (tag
.GetName() == "I")
87 m_WParser
-> SetFontItalic(TRUE
);
89 m_WParser
-> SetFontFixed(TRUE
);
90 m_WParser
-> GetContainer() -> InsertCell(new wxHtmlFontCell(m_WParser
-> CreateCurrentFont()));
94 m_WParser
-> SetFontUnderlined(underlined
);
95 m_WParser
-> SetFontBold(bold
);
96 m_WParser
-> SetFontItalic(italic
);
97 m_WParser
-> SetFontFixed(fixed
);
98 m_WParser
-> GetContainer() -> InsertCell(new wxHtmlFontCell(m_WParser
-> CreateCurrentFont()));
102 TAG_HANDLER_END(FACES
)
108 TAG_HANDLER_BEGIN(Hx
, "H1,H2,H3,H4,H5,H6")
110 TAG_HANDLER_PROC(tag
)
112 int old_size
, old_b
, old_i
, old_u
, old_f
, old_al
;
113 wxHtmlContainerCell
*c
;
115 old_size
= m_WParser
-> GetFontSize();
116 old_b
= m_WParser
-> GetFontBold();
117 old_i
= m_WParser
-> GetFontItalic();
118 old_u
= m_WParser
-> GetFontUnderlined();
119 old_f
= m_WParser
-> GetFontFixed();
120 old_al
= m_WParser
-> GetAlign();
122 m_WParser
-> SetFontBold(TRUE
);
123 m_WParser
-> SetFontItalic(FALSE
);
124 m_WParser
-> SetFontUnderlined(FALSE
);
125 m_WParser
-> SetFontFixed(FALSE
);
127 if (tag
.GetName() == "H1")
128 m_WParser
-> SetFontSize(+4);
129 else if (tag
.GetName() == "H2")
130 m_WParser
-> SetFontSize(+3);
131 else if (tag
.GetName() == "H3")
132 m_WParser
-> SetFontSize(+2);
133 else if (tag
.GetName() == "H4") {
134 m_WParser
-> SetFontSize(+2);
135 m_WParser
-> SetFontItalic(TRUE
);
136 m_WParser
-> SetFontBold(FALSE
);
138 else if (tag
.GetName() == "H5")
139 m_WParser
-> SetFontSize(+1);
140 else if (tag
.GetName() == "H6") {
141 m_WParser
-> SetFontSize(+1);
142 m_WParser
-> SetFontItalic(TRUE
);
143 m_WParser
-> SetFontBold(FALSE
);
146 c
= m_WParser
-> GetContainer();
147 if (c
-> GetFirstCell()) {
148 m_WParser
-> CloseContainer();
149 m_WParser
-> OpenContainer();
150 c
= m_WParser
-> GetContainer();
152 c
= m_WParser
-> GetContainer();
155 c
-> InsertCell(new wxHtmlFontCell(m_WParser
-> CreateCurrentFont()));
156 c
-> SetIndent(m_WParser
-> GetCharHeight(), HTML_INDENT_TOP
);
157 m_WParser
-> SetAlign(c
-> GetAlignHor());
161 m_WParser
-> SetFontSize(old_size
);
162 m_WParser
-> SetFontBold(old_b
);
163 m_WParser
-> SetFontItalic(old_i
);
164 m_WParser
-> SetFontUnderlined(old_u
);
165 m_WParser
-> SetFontFixed(old_f
);
166 m_WParser
-> SetAlign(old_al
);
168 m_WParser
-> GetContainer() -> InsertCell(new wxHtmlFontCell(m_WParser
-> CreateCurrentFont()));
169 m_WParser
-> CloseContainer();
170 m_WParser
-> OpenContainer();
171 c
= m_WParser
-> GetContainer();
172 c
-> SetIndent(m_WParser
-> GetCharHeight(), HTML_INDENT_TOP
);
182 TAGS_MODULE_BEGIN(Fonts
)
184 TAGS_MODULE_ADD(FONT
)
185 TAGS_MODULE_ADD(FACES
)
188 TAGS_MODULE_END(Fonts
)