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