]> git.saurik.com Git - wxWidgets.git/blob - src/html/m_layout.cpp
compilation fix for broken OS/2 compiler
[wxWidgets.git] / src / html / m_layout.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: m_layout.cpp
3 // Purpose: wxHtml module for basic paragraphs/layout handling
4 // Author: Vaclav Slavik
5 // RCS-ID: $Id$
6 // Copyright: (c) 1999 Vaclav Slavik
7 // Licence: wxWindows Licence
8 /////////////////////////////////////////////////////////////////////////////
9 #ifdef __GNUG__
10 #pragma implementation
11 #endif
12
13 #include "wx/wxprec.h"
14
15
16 #include "wx/defs.h"
17 #if wxUSE_HTML && wxUSE_STREAMS
18 #ifdef __BORDLANDC__
19 #pragma hdrstop
20 #endif
21
22 #ifndef WXPRECOMP
23 #endif
24
25
26 #include "wx/html/forcelnk.h"
27 #include "wx/html/m_templ.h"
28
29 #include "wx/html/htmlwin.h"
30
31 FORCE_LINK_ME(m_layout)
32
33
34 TAG_HANDLER_BEGIN(P, "P")
35
36 TAG_HANDLER_PROC(tag)
37 {
38 if (m_WParser->GetContainer()->GetFirstCell() != NULL)
39 {
40 m_WParser->CloseContainer();
41 m_WParser->OpenContainer();
42 }
43 m_WParser->GetContainer()->SetIndent(m_WParser->GetCharHeight(), wxHTML_INDENT_TOP);
44 m_WParser->GetContainer()->SetAlign(tag);
45 return FALSE;
46 }
47
48 TAG_HANDLER_END(P)
49
50
51
52 TAG_HANDLER_BEGIN(BR, "BR")
53
54 TAG_HANDLER_PROC(tag)
55 {
56 int al = m_WParser->GetContainer()->GetAlignHor();
57 wxHtmlContainerCell *c;
58
59 m_WParser->CloseContainer();
60 c = m_WParser->OpenContainer();
61 c->SetAlignHor(al);
62 c->SetAlign(tag);
63 c->SetMinHeight(m_WParser->GetCharHeight());
64 return FALSE;
65 }
66
67 TAG_HANDLER_END(BR)
68
69
70
71 TAG_HANDLER_BEGIN(CENTER, "CENTER")
72
73 TAG_HANDLER_PROC(tag)
74 {
75 int old = m_WParser->GetAlign();
76 wxHtmlContainerCell *c = m_WParser->GetContainer();
77
78 m_WParser->SetAlign(wxHTML_ALIGN_CENTER);
79 if (c->GetFirstCell() != NULL)
80 {
81 m_WParser->CloseContainer();
82 m_WParser->OpenContainer();
83 }
84 else
85 c->SetAlignHor(wxHTML_ALIGN_CENTER);
86
87 if (tag.HasEnding())
88 {
89 ParseInner(tag);
90
91 m_WParser->SetAlign(old);
92 if (c->GetFirstCell() != NULL)
93 {
94 m_WParser->CloseContainer();
95 m_WParser->OpenContainer();
96 }
97 else
98 c->SetAlignHor(old);
99
100 return TRUE;
101 }
102 else return FALSE;
103 }
104
105 TAG_HANDLER_END(CENTER)
106
107
108
109 TAG_HANDLER_BEGIN(DIV, "DIV")
110
111 TAG_HANDLER_PROC(tag)
112 {
113 int old = m_WParser->GetAlign();
114 wxHtmlContainerCell *c = m_WParser->GetContainer();
115 if (c->GetFirstCell() != NULL)
116 {
117 m_WParser->CloseContainer();
118 m_WParser->OpenContainer();
119 c = m_WParser->GetContainer();
120 c->SetAlign(tag);
121 m_WParser->SetAlign(c->GetAlignHor());
122 }
123 else
124 {
125 c->SetAlign(tag);
126 m_WParser->SetAlign(c->GetAlignHor());
127 }
128
129 ParseInner(tag);
130
131 m_WParser->SetAlign(old);
132 if (c->GetFirstCell() != NULL)
133 {
134 m_WParser->CloseContainer();
135 m_WParser->OpenContainer();
136 }
137 else
138 c->SetAlignHor(old);
139
140 return TRUE;
141 }
142
143 TAG_HANDLER_END(DIV)
144
145
146
147
148 TAG_HANDLER_BEGIN(TITLE, "TITLE")
149
150 TAG_HANDLER_PROC(tag)
151 {
152 if (m_WParser->GetWindow())
153 {
154 wxHtmlWindow *wfr = (wxHtmlWindow*)(m_WParser->GetWindow());
155 if (wfr)
156 {
157 wxString title = "";
158 wxString *src = m_WParser->GetSource();
159
160 for (int i = tag.GetBeginPos(); i < tag.GetEndPos1(); i++) title += (*src)[(unsigned int) i];
161 wfr->OnSetTitle(title);
162 }
163 }
164 return TRUE;
165 }
166
167 TAG_HANDLER_END(TITLE)
168
169
170
171
172 TAG_HANDLER_BEGIN(BODY, "BODY")
173
174 TAG_HANDLER_PROC(tag)
175 {
176 wxColour clr;
177
178 if (tag.GetParamAsColour(wxT("TEXT"), &clr))
179 {
180 m_WParser->SetActualColor(clr);
181 m_WParser->GetContainer()->InsertCell(new wxHtmlColourCell(clr));
182 }
183
184 if (tag.GetParamAsColour(wxT("LINK"), &clr))
185 m_WParser->SetLinkColor(clr);
186
187 if (tag.GetParamAsColour(wxT("BGCOLOR"), &clr))
188 {
189 m_WParser->GetContainer()->InsertCell(
190 new wxHtmlColourCell(clr, wxHTML_CLR_BACKGROUND));
191 if (m_WParser->GetWindow() != NULL)
192 m_WParser->GetWindow()->SetBackgroundColour(clr);
193 }
194 return FALSE;
195 }
196
197 TAG_HANDLER_END(BODY)
198
199
200
201 TAG_HANDLER_BEGIN(BLOCKQUOTE, "BLOCKQUOTE")
202
203 TAG_HANDLER_PROC(tag)
204 {
205 wxHtmlContainerCell *c;
206
207 m_WParser->CloseContainer();
208 c = m_WParser->OpenContainer();
209
210 if (c->GetAlignHor() == wxHTML_ALIGN_RIGHT)
211 c->SetIndent(5 * m_WParser->GetCharWidth(), wxHTML_INDENT_RIGHT);
212 else
213 c->SetIndent(5 * m_WParser->GetCharWidth(), wxHTML_INDENT_LEFT);
214
215 c->SetIndent(m_WParser->GetCharHeight(), wxHTML_INDENT_TOP);
216 m_WParser->OpenContainer();
217 ParseInner(tag);
218 c = m_WParser->CloseContainer();
219 c->SetIndent(m_WParser->GetCharHeight(), wxHTML_INDENT_BOTTOM);
220 m_WParser->CloseContainer();
221 m_WParser->OpenContainer();
222 return TRUE;
223 }
224
225 TAG_HANDLER_END(BLOCKQUOTE)
226
227
228
229
230
231
232 TAGS_MODULE_BEGIN(Layout)
233
234 TAGS_MODULE_ADD(P)
235 TAGS_MODULE_ADD(BR)
236 TAGS_MODULE_ADD(CENTER)
237 TAGS_MODULE_ADD(DIV)
238 TAGS_MODULE_ADD(TITLE)
239 TAGS_MODULE_ADD(BODY)
240 TAGS_MODULE_ADD(BLOCKQUOTE)
241
242 TAGS_MODULE_END(Layout)
243
244 #endif