]>
git.saurik.com Git - wxWidgets.git/blob - src/html/m_fonts.cpp
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxHtml module for fonts & colors of fonts
4 // Author: Vaclav Slavik
6 // Copyright: (c) 1999 Vaclav Slavik
7 // Licence: wxWindows Licence
8 /////////////////////////////////////////////////////////////////////////////
11 #pragma implementation
14 #include <wx/wxprec.h>
27 #include "wx/html/forcelnk.h"
28 #include "wx/html/m_templ.h"
30 FORCE_LINK_ME(mod_fonts
)
33 TAG_HANDLER_BEGIN(FONT
, "FONT")
37 wxColour oldclr
= m_WParser
-> GetActualColor();
38 int oldsize
= m_WParser
-> GetFontSize();
40 if (tag
.HasParam("COLOR")) {
41 unsigned long tmp
= 0;
43 if (tag
.ScanParam("COLOR", "#%lX", &tmp
) == 1) {
44 clr
= wxColour((tmp
& 0xFF0000) >> 16 , (tmp
& 0x00FF00) >> 8, (tmp
& 0x0000FF));
45 m_WParser
-> SetActualColor(clr
);
46 m_WParser
-> GetContainer() -> InsertCell(new wxHtmlColourCell(clr
));
50 if (tag
.HasParam("SIZE")) {
52 if (tag
.ScanParam("SIZE", "%li", &tmp
) == 1) {
53 m_WParser
-> SetFontSize(oldsize
+tmp
);
54 m_WParser
-> GetContainer() -> InsertCell(new wxHtmlFontCell(m_WParser
-> CreateCurrentFont()));
60 if (oldclr
!= m_WParser
-> GetActualColor()) {
61 m_WParser
-> SetActualColor(oldclr
);
62 m_WParser
-> GetContainer() -> InsertCell(new wxHtmlColourCell(oldclr
));
64 if (oldsize
!= m_WParser
-> GetFontSize()) {
65 m_WParser
-> SetFontSize(oldsize
);
66 m_WParser
-> GetContainer() -> InsertCell(new wxHtmlFontCell(m_WParser
-> CreateCurrentFont()));
74 TAG_HANDLER_BEGIN(FACES
, "U,I,B,TT")
78 int fixed
= m_WParser
-> GetFontFixed(),
79 italic
= m_WParser
-> GetFontItalic(),
80 underlined
= m_WParser
-> GetFontUnderlined(),
81 bold
= m_WParser
-> GetFontBold();
83 if (tag
.GetName() == "U")
84 m_WParser
-> SetFontUnderlined(TRUE
);
85 else if (tag
.GetName() == "B")
86 m_WParser
-> SetFontBold(TRUE
);
87 else if (tag
.GetName() == "I")
88 m_WParser
-> SetFontItalic(TRUE
);
90 m_WParser
-> SetFontFixed(TRUE
);
91 m_WParser
-> GetContainer() -> InsertCell(new wxHtmlFontCell(m_WParser
-> CreateCurrentFont()));
95 m_WParser
-> SetFontUnderlined(underlined
);
96 m_WParser
-> SetFontBold(bold
);
97 m_WParser
-> SetFontItalic(italic
);
98 m_WParser
-> SetFontFixed(fixed
);
99 m_WParser
-> GetContainer() -> InsertCell(new wxHtmlFontCell(m_WParser
-> CreateCurrentFont()));
103 TAG_HANDLER_END(FACES
)
109 TAG_HANDLER_BEGIN(Hx
, "H1,H2,H3,H4,H5,H6")
111 TAG_HANDLER_PROC(tag
)
113 int old_size
, old_b
, old_i
, old_u
, old_f
, old_al
;
114 wxHtmlContainerCell
*c
;
116 old_size
= m_WParser
-> GetFontSize();
117 old_b
= m_WParser
-> GetFontBold();
118 old_i
= m_WParser
-> GetFontItalic();
119 old_u
= m_WParser
-> GetFontUnderlined();
120 old_f
= m_WParser
-> GetFontFixed();
121 old_al
= m_WParser
-> GetAlign();
123 m_WParser
-> SetFontBold(TRUE
);
124 m_WParser
-> SetFontItalic(FALSE
);
125 m_WParser
-> SetFontUnderlined(FALSE
);
126 m_WParser
-> SetFontFixed(FALSE
);
128 if (tag
.GetName() == "H1")
129 m_WParser
-> SetFontSize(+4);
130 else if (tag
.GetName() == "H2")
131 m_WParser
-> SetFontSize(+3);
132 else if (tag
.GetName() == "H3")
133 m_WParser
-> SetFontSize(+2);
134 else if (tag
.GetName() == "H4") {
135 m_WParser
-> SetFontSize(+2);
136 m_WParser
-> SetFontItalic(TRUE
);
137 m_WParser
-> SetFontBold(FALSE
);
139 else if (tag
.GetName() == "H5")
140 m_WParser
-> SetFontSize(+1);
141 else if (tag
.GetName() == "H6") {
142 m_WParser
-> SetFontSize(+1);
143 m_WParser
-> SetFontItalic(TRUE
);
144 m_WParser
-> SetFontBold(FALSE
);
147 c
= m_WParser
-> GetContainer();
148 if (c
-> GetFirstCell()) {
149 m_WParser
-> CloseContainer();
150 m_WParser
-> OpenContainer();
151 c
= m_WParser
-> GetContainer();
153 c
= m_WParser
-> GetContainer();
156 c
-> InsertCell(new wxHtmlFontCell(m_WParser
-> CreateCurrentFont()));
157 c
-> SetIndent(m_WParser
-> GetCharHeight(), wxHTML_INDENT_TOP
);
158 m_WParser
-> SetAlign(c
-> GetAlignHor());
162 m_WParser
-> SetFontSize(old_size
);
163 m_WParser
-> SetFontBold(old_b
);
164 m_WParser
-> SetFontItalic(old_i
);
165 m_WParser
-> SetFontUnderlined(old_u
);
166 m_WParser
-> SetFontFixed(old_f
);
167 m_WParser
-> SetAlign(old_al
);
169 m_WParser
-> GetContainer() -> InsertCell(new wxHtmlFontCell(m_WParser
-> CreateCurrentFont()));
170 m_WParser
-> CloseContainer();
171 m_WParser
-> OpenContainer();
172 c
= m_WParser
-> GetContainer();
173 c
-> SetIndent(m_WParser
-> GetCharHeight(), wxHTML_INDENT_TOP
);
183 TAGS_MODULE_BEGIN(Fonts
)
185 TAGS_MODULE_ADD(FONT
)
186 TAGS_MODULE_ADD(FACES
)
189 TAGS_MODULE_END(Fonts
)