]> git.saurik.com Git - wxWidgets.git/blame - src/html/m_fonts.cpp
added bookmarks support
[wxWidgets.git] / src / html / m_fonts.cpp
CommitLineData
5526e819
VS
1/////////////////////////////////////////////////////////////////////////////
2// Name: mod_fonts.cpp
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
VS
29
30FORCE_LINK_ME(mod_fonts)
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
9b64e798 74TAG_HANDLER_BEGIN(FACES, "U,I,B,TT")
5526e819
VS
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
103TAG_HANDLER_END(FACES)
104
105
106
107
108
109TAG_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()));
efba2b89 157 c -> SetIndent(m_WParser -> GetCharHeight(), wxHTML_INDENT_TOP);
5526e819
VS
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();
efba2b89 173 c -> SetIndent(m_WParser -> GetCharHeight(), wxHTML_INDENT_TOP);
5526e819
VS
174
175 return TRUE;
176 }
177
178TAG_HANDLER_END(Hx)
179
180
181
182
183TAGS_MODULE_BEGIN(Fonts)
184
185 TAGS_MODULE_ADD(FONT)
186 TAGS_MODULE_ADD(FACES)
187 TAGS_MODULE_ADD(Hx)
188
189TAGS_MODULE_END(Fonts)
190
191
3364ab79 192#endif