]>
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 /////////////////////////////////////////////////////////////////////////////
13 #include <wx/html/forcelink.h>
14 #include <wx/html/mod_templ.h>
16 FORCE_LINK_ME(mod_fonts
)
19 TAG_HANDLER_BEGIN(FONT
, "FONT")
24 wxColour oldclr
= m_WParser
-> GetActualColor();
25 int oldsize
= m_WParser
-> GetFontSize();
27 if (tag
.HasParam("COLOR")) {
29 tag
.ScanParam("COLOR", "#%lX", &tmp
);
30 clr
= wxColour((tmp
& 0xFF0000) >> 16 , (tmp
& 0x00FF00) >> 8, (tmp
& 0x0000FF));
31 m_WParser
-> SetActualColor(clr
);
32 m_WParser
-> GetContainer() -> InsertCell(new wxHtmlColourCell(clr
));
35 if (tag
.HasParam("SIZE")) {
36 tag
.ScanParam("SIZE", "%li", &tmp
);
37 m_WParser
-> SetFontSize(tmp
);
38 m_WParser
-> GetContainer() -> InsertCell(new wxHtmlFontCell(m_WParser
-> CreateCurrentFont()));
43 if (oldclr
!= m_WParser
-> GetActualColor()) {
44 m_WParser
-> SetActualColor(oldclr
);
45 m_WParser
-> GetContainer() -> InsertCell(new wxHtmlColourCell(oldclr
));
47 if (oldsize
!= m_WParser
-> GetFontSize()) {
48 m_WParser
-> SetFontSize(oldsize
);
49 m_WParser
-> GetContainer() -> InsertCell(new wxHtmlFontCell(m_WParser
-> CreateCurrentFont()));
57 TAG_HANDLER_BEGIN(FACES
, "U,I,B,TT")
61 int fixed
= m_WParser
-> GetFontFixed(),
62 italic
= m_WParser
-> GetFontItalic(),
63 underlined
= m_WParser
-> GetFontUnderlined(),
64 bold
= m_WParser
-> GetFontBold();
66 if (tag
.GetName() == "U")
67 m_WParser
-> SetFontUnderlined(TRUE
);
68 else if (tag
.GetName() == "B")
69 m_WParser
-> SetFontBold(TRUE
);
70 else if (tag
.GetName() == "I")
71 m_WParser
-> SetFontItalic(TRUE
);
73 m_WParser
-> SetFontFixed(TRUE
);
74 m_WParser
-> GetContainer() -> InsertCell(new wxHtmlFontCell(m_WParser
-> CreateCurrentFont()));
78 m_WParser
-> SetFontUnderlined(underlined
);
79 m_WParser
-> SetFontBold(bold
);
80 m_WParser
-> SetFontItalic(italic
);
81 m_WParser
-> SetFontFixed(fixed
);
82 m_WParser
-> GetContainer() -> InsertCell(new wxHtmlFontCell(m_WParser
-> CreateCurrentFont()));
86 TAG_HANDLER_END(FACES
)
92 TAG_HANDLER_BEGIN(Hx
, "H1,H2,H3,H4,H5,H6")
96 int old_size
, old_b
, old_i
, old_u
, old_f
, old_al
;
97 wxHtmlContainerCell
*c
;
99 old_size
= m_WParser
-> GetFontSize();
100 old_b
= m_WParser
-> GetFontBold();
101 old_i
= m_WParser
-> GetFontItalic();
102 old_u
= m_WParser
-> GetFontUnderlined();
103 old_f
= m_WParser
-> GetFontFixed();
104 old_al
= m_WParser
-> GetAlign();
106 m_WParser
-> SetFontBold(TRUE
);
107 m_WParser
-> SetFontItalic(FALSE
);
108 m_WParser
-> SetFontUnderlined(FALSE
);
109 m_WParser
-> SetFontFixed(FALSE
);
111 if (tag
.GetName() == "H1")
112 m_WParser
-> SetFontSize(+4);
113 else if (tag
.GetName() == "H2")
114 m_WParser
-> SetFontSize(+3);
115 else if (tag
.GetName() == "H3")
116 m_WParser
-> SetFontSize(+2);
117 else if (tag
.GetName() == "H4") {
118 m_WParser
-> SetFontSize(+2);
119 m_WParser
-> SetFontItalic(TRUE
);
120 m_WParser
-> SetFontBold(FALSE
);
122 else if (tag
.GetName() == "H5")
123 m_WParser
-> SetFontSize(+1);
124 else if (tag
.GetName() == "H6") {
125 m_WParser
-> SetFontSize(+1);
126 m_WParser
-> SetFontItalic(TRUE
);
127 m_WParser
-> SetFontBold(FALSE
);
130 c
= m_WParser
-> GetContainer();
131 if (c
-> GetFirstCell()) {
132 m_WParser
-> CloseContainer();
133 m_WParser
-> OpenContainer();
134 c
= m_WParser
-> GetContainer();
136 c
= m_WParser
-> GetContainer();
139 c
-> InsertCell(new wxHtmlFontCell(m_WParser
-> CreateCurrentFont()));
140 c
-> SetIndent(m_WParser
-> GetCharHeight(), HTML_INDENT_TOP
);
141 m_WParser
-> SetAlign(c
-> GetAlignHor());
145 m_WParser
-> SetFontSize(old_size
);
146 m_WParser
-> SetFontBold(old_b
);
147 m_WParser
-> SetFontItalic(old_i
);
148 m_WParser
-> SetFontUnderlined(old_u
);
149 m_WParser
-> SetFontFixed(old_f
);
150 m_WParser
-> SetAlign(old_al
);
152 m_WParser
-> GetContainer() -> InsertCell(new wxHtmlFontCell(m_WParser
-> CreateCurrentFont()));
153 m_WParser
-> CloseContainer();
154 m_WParser
-> OpenContainer();
155 c
= m_WParser
-> GetContainer();
156 c
-> SetIndent(m_WParser
-> GetCharHeight(), HTML_INDENT_TOP
);
166 TAGS_MODULE_BEGIN(Fonts
)
168 TAGS_MODULE_ADD(FONT
)
169 TAGS_MODULE_ADD(FACES
)
172 TAGS_MODULE_END(Fonts
)