]> git.saurik.com Git - wxWidgets.git/blob - src/html/m_fonts.cpp
wxDialUpManager fixes
[wxWidgets.git] / src / html / m_fonts.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: mod_fonts.cpp
3 // Purpose: wxHtml module for fonts & colors of fonts
4 // Author: Vaclav Slavik
5 // RCS-ID: $Id$
6 // Copyright: (c) 1999 Vaclav Slavik
7 // Licence: wxWindows Licence
8 /////////////////////////////////////////////////////////////////////////////
9
10 #ifdef __GNUG__
11 #pragma implementation
12 #endif
13
14 #include <wx/wxprec.h>
15
16 #include "wx/defs.h"
17 #if wxUSE_HTML
18
19 #ifdef __BORDLANDC__
20 #pragma hdrstop
21 #endif
22
23 #ifndef WXPRECOMP
24 #include <wx/wx.h>
25 #endif
26
27 #include "wx/html/forcelnk.h"
28 #include "wx/html/m_templ.h"
29
30 FORCE_LINK_ME(mod_fonts)
31
32
33 TAG_HANDLER_BEGIN(FONT, "FONT")
34
35 TAG_HANDLER_PROC(tag)
36 {
37 wxColour oldclr = m_WParser -> GetActualColor();
38 int oldsize = m_WParser -> GetFontSize();
39
40 if (tag.HasParam("COLOR")) {
41 unsigned long tmp = 0;
42 wxColour clr;
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));
47 }
48 }
49
50 if (tag.HasParam("SIZE")) {
51 long tmp = 0;
52 if (tag.ScanParam("SIZE", "%li", &tmp) == 1) {
53 m_WParser -> SetFontSize(oldsize+tmp);
54 m_WParser -> GetContainer() -> InsertCell(new wxHtmlFontCell(m_WParser -> CreateCurrentFont()));
55 }
56 }
57
58 ParseInner(tag);
59
60 if (oldclr != m_WParser -> GetActualColor()) {
61 m_WParser -> SetActualColor(oldclr);
62 m_WParser -> GetContainer() -> InsertCell(new wxHtmlColourCell(oldclr));
63 }
64 if (oldsize != m_WParser -> GetFontSize()) {
65 m_WParser -> SetFontSize(oldsize);
66 m_WParser -> GetContainer() -> InsertCell(new wxHtmlFontCell(m_WParser -> CreateCurrentFont()));
67 }
68 return TRUE;
69 }
70
71 TAG_HANDLER_END(FONT)
72
73
74 TAG_HANDLER_BEGIN(FACES, "U,I,B,TT")
75
76 TAG_HANDLER_PROC(tag)
77 {
78 int fixed = m_WParser -> GetFontFixed(),
79 italic = m_WParser -> GetFontItalic(),
80 underlined = m_WParser -> GetFontUnderlined(),
81 bold = m_WParser -> GetFontBold();
82
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);
89 else
90 m_WParser -> SetFontFixed(TRUE);
91 m_WParser -> GetContainer() -> InsertCell(new wxHtmlFontCell(m_WParser -> CreateCurrentFont()));
92
93 ParseInner(tag);
94
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()));
100 return TRUE;
101 }
102
103 TAG_HANDLER_END(FACES)
104
105
106
107
108
109 TAG_HANDLER_BEGIN(Hx, "H1,H2,H3,H4,H5,H6")
110
111 TAG_HANDLER_PROC(tag)
112 {
113 int old_size, old_b, old_i, old_u, old_f, old_al;
114 wxHtmlContainerCell *c;
115
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();
122
123 m_WParser -> SetFontBold(TRUE);
124 m_WParser -> SetFontItalic(FALSE);
125 m_WParser -> SetFontUnderlined(FALSE);
126 m_WParser -> SetFontFixed(FALSE);
127
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);
138 }
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);
145 }
146
147 c = m_WParser -> GetContainer();
148 if (c -> GetFirstCell()) {
149 m_WParser -> CloseContainer();
150 m_WParser -> OpenContainer();
151 c = m_WParser -> GetContainer();
152 }
153 c = m_WParser -> GetContainer();
154
155 c -> SetAlign(tag);
156 c -> InsertCell(new wxHtmlFontCell(m_WParser -> CreateCurrentFont()));
157 c -> SetIndent(m_WParser -> GetCharHeight(), HTML_INDENT_TOP);
158 m_WParser -> SetAlign(c -> GetAlignHor());
159
160 ParseInner(tag);
161
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);
168
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(), HTML_INDENT_TOP);
174
175 return TRUE;
176 }
177
178 TAG_HANDLER_END(Hx)
179
180
181
182
183 TAGS_MODULE_BEGIN(Fonts)
184
185 TAGS_MODULE_ADD(FONT)
186 TAGS_MODULE_ADD(FACES)
187 TAGS_MODULE_ADD(Hx)
188
189 TAGS_MODULE_END(Fonts)
190
191
192 #endif