]>
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")
37 wxColour oldclr
= m_WParser
-> GetActualColor();
38 int oldsize
= m_WParser
-> GetFontSize();
40 if (tag
.HasParam("COLOR")) {
42 tag
.ScanParam("COLOR", "#%lX", &tmp
);
43 clr
= wxColour((tmp
& 0xFF0000) >> 16 , (tmp
& 0x00FF00) >> 8, (tmp
& 0x0000FF));
44 m_WParser
-> SetActualColor(clr
);
45 m_WParser
-> GetContainer() -> InsertCell(new wxHtmlColourCell(clr
));
48 if (tag
.HasParam("SIZE")) {
49 tag
.ScanParam("SIZE", "%li", &tmp
);
50 m_WParser
-> SetFontSize(tmp
);
51 m_WParser
-> GetContainer() -> InsertCell(new wxHtmlFontCell(m_WParser
-> CreateCurrentFont()));
56 if (oldclr
!= m_WParser
-> GetActualColor()) {
57 m_WParser
-> SetActualColor(oldclr
);
58 m_WParser
-> GetContainer() -> InsertCell(new wxHtmlColourCell(oldclr
));
60 if (oldsize
!= m_WParser
-> GetFontSize()) {
61 m_WParser
-> SetFontSize(oldsize
);
62 m_WParser
-> GetContainer() -> InsertCell(new wxHtmlFontCell(m_WParser
-> CreateCurrentFont()));
70 TAG_HANDLER_BEGIN(FACES
, "U,I,B,TT")
74 int fixed
= m_WParser
-> GetFontFixed(),
75 italic
= m_WParser
-> GetFontItalic(),
76 underlined
= m_WParser
-> GetFontUnderlined(),
77 bold
= m_WParser
-> GetFontBold();
79 if (tag
.GetName() == "U")
80 m_WParser
-> SetFontUnderlined(TRUE
);
81 else if (tag
.GetName() == "B")
82 m_WParser
-> SetFontBold(TRUE
);
83 else if (tag
.GetName() == "I")
84 m_WParser
-> SetFontItalic(TRUE
);
86 m_WParser
-> SetFontFixed(TRUE
);
87 m_WParser
-> GetContainer() -> InsertCell(new wxHtmlFontCell(m_WParser
-> CreateCurrentFont()));
91 m_WParser
-> SetFontUnderlined(underlined
);
92 m_WParser
-> SetFontBold(bold
);
93 m_WParser
-> SetFontItalic(italic
);
94 m_WParser
-> SetFontFixed(fixed
);
95 m_WParser
-> GetContainer() -> InsertCell(new wxHtmlFontCell(m_WParser
-> CreateCurrentFont()));
99 TAG_HANDLER_END(FACES
)
105 TAG_HANDLER_BEGIN(Hx
, "H1,H2,H3,H4,H5,H6")
107 TAG_HANDLER_PROC(tag
)
109 int old_size
, old_b
, old_i
, old_u
, old_f
, old_al
;
110 wxHtmlContainerCell
*c
;
112 old_size
= m_WParser
-> GetFontSize();
113 old_b
= m_WParser
-> GetFontBold();
114 old_i
= m_WParser
-> GetFontItalic();
115 old_u
= m_WParser
-> GetFontUnderlined();
116 old_f
= m_WParser
-> GetFontFixed();
117 old_al
= m_WParser
-> GetAlign();
119 m_WParser
-> SetFontBold(TRUE
);
120 m_WParser
-> SetFontItalic(FALSE
);
121 m_WParser
-> SetFontUnderlined(FALSE
);
122 m_WParser
-> SetFontFixed(FALSE
);
124 if (tag
.GetName() == "H1")
125 m_WParser
-> SetFontSize(+4);
126 else if (tag
.GetName() == "H2")
127 m_WParser
-> SetFontSize(+3);
128 else if (tag
.GetName() == "H3")
129 m_WParser
-> SetFontSize(+2);
130 else if (tag
.GetName() == "H4") {
131 m_WParser
-> SetFontSize(+2);
132 m_WParser
-> SetFontItalic(TRUE
);
133 m_WParser
-> SetFontBold(FALSE
);
135 else if (tag
.GetName() == "H5")
136 m_WParser
-> SetFontSize(+1);
137 else if (tag
.GetName() == "H6") {
138 m_WParser
-> SetFontSize(+1);
139 m_WParser
-> SetFontItalic(TRUE
);
140 m_WParser
-> SetFontBold(FALSE
);
143 c
= m_WParser
-> GetContainer();
144 if (c
-> GetFirstCell()) {
145 m_WParser
-> CloseContainer();
146 m_WParser
-> OpenContainer();
147 c
= m_WParser
-> GetContainer();
149 c
= m_WParser
-> GetContainer();
152 c
-> InsertCell(new wxHtmlFontCell(m_WParser
-> CreateCurrentFont()));
153 c
-> SetIndent(m_WParser
-> GetCharHeight(), HTML_INDENT_TOP
);
154 m_WParser
-> SetAlign(c
-> GetAlignHor());
158 m_WParser
-> SetFontSize(old_size
);
159 m_WParser
-> SetFontBold(old_b
);
160 m_WParser
-> SetFontItalic(old_i
);
161 m_WParser
-> SetFontUnderlined(old_u
);
162 m_WParser
-> SetFontFixed(old_f
);
163 m_WParser
-> SetAlign(old_al
);
165 m_WParser
-> GetContainer() -> InsertCell(new wxHtmlFontCell(m_WParser
-> CreateCurrentFont()));
166 m_WParser
-> CloseContainer();
167 m_WParser
-> OpenContainer();
168 c
= m_WParser
-> GetContainer();
169 c
-> SetIndent(m_WParser
-> GetCharHeight(), HTML_INDENT_TOP
);
179 TAGS_MODULE_BEGIN(Fonts
)
181 TAGS_MODULE_ADD(FONT
)
182 TAGS_MODULE_ADD(FACES
)
185 TAGS_MODULE_END(Fonts
)