]> git.saurik.com Git - wxWidgets.git/blame - src/html/m_fonts.cpp
Some doc updates.
[wxWidgets.git] / src / html / m_fonts.cpp
CommitLineData
5526e819 1/////////////////////////////////////////////////////////////////////////////
ef01b72f 2// Name: m_fonts.cpp
5526e819
VS
3// Purpose: wxHtml module for fonts & colors of fonts
4// Author: Vaclav Slavik
69941f05 5// RCS-ID: $Id$
5526e819
VS
6// Copyright: (c) 1999 Vaclav Slavik
7// Licence: wxWindows Licence
8/////////////////////////////////////////////////////////////////////////////
9
3364ab79
RS
10#ifdef __GNUG__
11#pragma implementation
12#endif
13
3096bd2f 14#include "wx/wxprec.h"
5526e819
VS
15
16#include "wx/defs.h"
17#if wxUSE_HTML
18
3364ab79
RS
19#ifdef __BORDLANDC__
20#pragma hdrstop
21#endif
22
23#ifndef WXPRECOMP
3096bd2f 24#include "wx/wx.h"
3364ab79
RS
25#endif
26
69941f05
VS
27#include "wx/html/forcelnk.h"
28#include "wx/html/m_templ.h"
5526e819 29
ef01b72f 30FORCE_LINK_ME(m_fonts)
5526e819
VS
31
32
9b64e798 33TAG_HANDLER_BEGIN(FONT, "FONT")
5526e819
VS
34
35 TAG_HANDLER_PROC(tag)
36 {
5526e819
VS
37 wxColour oldclr = m_WParser -> GetActualColor();
38 int oldsize = m_WParser -> GetFontSize();
39
66a77a74 40 if (tag.HasParam(wxT("COLOR"))) {
c15d098c 41 unsigned long tmp = 0;
5526e819 42 wxColour clr;
66a77a74 43 if (tag.ScanParam(wxT("COLOR"), wxT("#%lX"), &tmp) == 1) {
72aa4a98
VS
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 }
5526e819
VS
48 }
49
66a77a74 50 if (tag.HasParam(wxT("SIZE"))) {
c15d098c 51 long tmp = 0;
66a77a74 52 if (tag.ScanParam(wxT("SIZE"), wxT("%li"), &tmp) == 1) {
72aa4a98
VS
53 m_WParser -> SetFontSize(oldsize+tmp);
54 m_WParser -> GetContainer() -> InsertCell(new wxHtmlFontCell(m_WParser -> CreateCurrentFont()));
55 }
5526e819
VS
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
71TAG_HANDLER_END(FONT)
72
73
ef01b72f 74TAG_HANDLER_BEGIN(FACES_U, "U")
5526e819
VS
75
76 TAG_HANDLER_PROC(tag)
77 {
ef01b72f
VS
78 int underlined = m_WParser -> GetFontUnderlined();
79
80 m_WParser -> SetFontUnderlined(TRUE);
5526e819
VS
81 m_WParser -> GetContainer() -> InsertCell(new wxHtmlFontCell(m_WParser -> CreateCurrentFont()));
82
83 ParseInner(tag);
84
85 m_WParser -> SetFontUnderlined(underlined);
ef01b72f
VS
86 m_WParser -> GetContainer() -> InsertCell(new wxHtmlFontCell(m_WParser -> CreateCurrentFont()));
87 return TRUE;
88 }
89
90TAG_HANDLER_END(FACES_U)
91
92
93
94
95TAG_HANDLER_BEGIN(FACES_B, "B,STRONG")
96
97 TAG_HANDLER_PROC(tag)
98 {
99 int bold = m_WParser -> GetFontBold();
100
101 m_WParser -> SetFontBold(TRUE);
102 m_WParser -> GetContainer() -> InsertCell(new wxHtmlFontCell(m_WParser -> CreateCurrentFont()));
103
104 ParseInner(tag);
105
5526e819 106 m_WParser -> SetFontBold(bold);
ef01b72f
VS
107 m_WParser -> GetContainer() -> InsertCell(new wxHtmlFontCell(m_WParser -> CreateCurrentFont()));
108 return TRUE;
109 }
110
111TAG_HANDLER_END(FACES_B)
112
113
114
115
116TAG_HANDLER_BEGIN(FACES_I, "I,EM,CITE")
117
118 TAG_HANDLER_PROC(tag)
119 {
120 int italic = m_WParser -> GetFontItalic();
121
122 m_WParser -> SetFontItalic(TRUE);
123 m_WParser -> GetContainer() -> InsertCell(new wxHtmlFontCell(m_WParser -> CreateCurrentFont()));
124
125 ParseInner(tag);
126
5526e819 127 m_WParser -> SetFontItalic(italic);
ef01b72f
VS
128 m_WParser -> GetContainer() -> InsertCell(new wxHtmlFontCell(m_WParser -> CreateCurrentFont()));
129 return TRUE;
130 }
131
132TAG_HANDLER_END(FACES_I)
133
134
135
136
137TAG_HANDLER_BEGIN(FACES_TT, "TT")
138
139 TAG_HANDLER_PROC(tag)
140 {
141 int fixed = m_WParser -> GetFontFixed();
142
143 m_WParser -> SetFontFixed(TRUE);
144 m_WParser -> GetContainer() -> InsertCell(new wxHtmlFontCell(m_WParser -> CreateCurrentFont()));
145
146 ParseInner(tag);
147
5526e819
VS
148 m_WParser -> SetFontFixed(fixed);
149 m_WParser -> GetContainer() -> InsertCell(new wxHtmlFontCell(m_WParser -> CreateCurrentFont()));
150 return TRUE;
151 }
152
ef01b72f 153TAG_HANDLER_END(FACES_TT)
5526e819
VS
154
155
156
157
158
159TAG_HANDLER_BEGIN(Hx, "H1,H2,H3,H4,H5,H6")
160
161 TAG_HANDLER_PROC(tag)
162 {
163 int old_size, old_b, old_i, old_u, old_f, old_al;
164 wxHtmlContainerCell *c;
165
166 old_size = m_WParser -> GetFontSize();
167 old_b = m_WParser -> GetFontBold();
168 old_i = m_WParser -> GetFontItalic();
169 old_u = m_WParser -> GetFontUnderlined();
170 old_f = m_WParser -> GetFontFixed();
171 old_al = m_WParser -> GetAlign();
172
173 m_WParser -> SetFontBold(TRUE);
174 m_WParser -> SetFontItalic(FALSE);
175 m_WParser -> SetFontUnderlined(FALSE);
176 m_WParser -> SetFontFixed(FALSE);
177
178 if (tag.GetName() == "H1")
179 m_WParser -> SetFontSize(+4);
180 else if (tag.GetName() == "H2")
181 m_WParser -> SetFontSize(+3);
182 else if (tag.GetName() == "H3")
183 m_WParser -> SetFontSize(+2);
184 else if (tag.GetName() == "H4") {
185 m_WParser -> SetFontSize(+2);
186 m_WParser -> SetFontItalic(TRUE);
187 m_WParser -> SetFontBold(FALSE);
188 }
189 else if (tag.GetName() == "H5")
190 m_WParser -> SetFontSize(+1);
191 else if (tag.GetName() == "H6") {
192 m_WParser -> SetFontSize(+1);
193 m_WParser -> SetFontItalic(TRUE);
194 m_WParser -> SetFontBold(FALSE);
195 }
196
197 c = m_WParser -> GetContainer();
198 if (c -> GetFirstCell()) {
199 m_WParser -> CloseContainer();
200 m_WParser -> OpenContainer();
201 c = m_WParser -> GetContainer();
202 }
203 c = m_WParser -> GetContainer();
204
205 c -> SetAlign(tag);
206 c -> InsertCell(new wxHtmlFontCell(m_WParser -> CreateCurrentFont()));
efba2b89 207 c -> SetIndent(m_WParser -> GetCharHeight(), wxHTML_INDENT_TOP);
5526e819
VS
208 m_WParser -> SetAlign(c -> GetAlignHor());
209
210 ParseInner(tag);
211
212 m_WParser -> SetFontSize(old_size);
213 m_WParser -> SetFontBold(old_b);
214 m_WParser -> SetFontItalic(old_i);
215 m_WParser -> SetFontUnderlined(old_u);
216 m_WParser -> SetFontFixed(old_f);
217 m_WParser -> SetAlign(old_al);
218
219 m_WParser -> GetContainer() -> InsertCell(new wxHtmlFontCell(m_WParser -> CreateCurrentFont()));
220 m_WParser -> CloseContainer();
221 m_WParser -> OpenContainer();
222 c = m_WParser -> GetContainer();
efba2b89 223 c -> SetIndent(m_WParser -> GetCharHeight(), wxHTML_INDENT_TOP);
5526e819
VS
224
225 return TRUE;
226 }
227
228TAG_HANDLER_END(Hx)
229
230
231
232
233TAGS_MODULE_BEGIN(Fonts)
234
235 TAGS_MODULE_ADD(FONT)
ef01b72f
VS
236 TAGS_MODULE_ADD(FACES_U)
237 TAGS_MODULE_ADD(FACES_I)
238 TAGS_MODULE_ADD(FACES_B)
239 TAGS_MODULE_ADD(FACES_TT)
5526e819
VS
240 TAGS_MODULE_ADD(Hx)
241
242TAGS_MODULE_END(Fonts)
243
244
3364ab79 245#endif