]> git.saurik.com Git - wxWidgets.git/blame - src/html/m_layout.cpp
removed the SetMargins call
[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 {
9eeca6df
VS
157 const wxString& src = *m_WParser->GetSource();
158 wfr->OnSetTitle(src.Mid(tag.GetBeginPos(),
159 tag.GetEndPos1()-tag.GetBeginPos()));
5526e819
VS
160 }
161 }
162 return TRUE;
163 }
164
165TAG_HANDLER_END(TITLE)
166
167
168
169
170TAG_HANDLER_BEGIN(BODY, "BODY")
171
172 TAG_HANDLER_PROC(tag)
173 {
5526e819
VS
174 wxColour clr;
175
8bd72d90 176 if (tag.GetParamAsColour(wxT("TEXT"), &clr))
04dbb646 177 {
8bd72d90
VS
178 m_WParser->SetActualColor(clr);
179 m_WParser->GetContainer()->InsertCell(new wxHtmlColourCell(clr));
5526e819
VS
180 }
181
8bd72d90
VS
182 if (tag.GetParamAsColour(wxT("LINK"), &clr))
183 m_WParser->SetLinkColor(clr);
184
185 if (tag.GetParamAsColour(wxT("BGCOLOR"), &clr))
04dbb646 186 {
8bd72d90
VS
187 m_WParser->GetContainer()->InsertCell(
188 new wxHtmlColourCell(clr, wxHTML_CLR_BACKGROUND));
189 if (m_WParser->GetWindow() != NULL)
190 m_WParser->GetWindow()->SetBackgroundColour(clr);
5526e819
VS
191 }
192 return FALSE;
193 }
194
195TAG_HANDLER_END(BODY)
196
197
198
199TAG_HANDLER_BEGIN(BLOCKQUOTE, "BLOCKQUOTE")
200
201 TAG_HANDLER_PROC(tag)
202 {
203 wxHtmlContainerCell *c;
33ac7e6f 204
4f9297b0
VS
205 m_WParser->CloseContainer();
206 c = m_WParser->OpenContainer();
33ac7e6f 207
04dbb646 208 if (c->GetAlignHor() == wxHTML_ALIGN_RIGHT)
4f9297b0 209 c->SetIndent(5 * m_WParser->GetCharWidth(), wxHTML_INDENT_RIGHT);
5526e819 210 else
4f9297b0 211 c->SetIndent(5 * m_WParser->GetCharWidth(), wxHTML_INDENT_LEFT);
33ac7e6f 212
04dbb646 213 c->SetIndent(m_WParser->GetCharHeight(), wxHTML_INDENT_TOP);
4f9297b0 214 m_WParser->OpenContainer();
5526e819 215 ParseInner(tag);
4f9297b0
VS
216 c = m_WParser->CloseContainer();
217 c->SetIndent(m_WParser->GetCharHeight(), wxHTML_INDENT_BOTTOM);
218 m_WParser->CloseContainer();
219 m_WParser->OpenContainer();
5526e819
VS
220 return TRUE;
221 }
222
223TAG_HANDLER_END(BLOCKQUOTE)
224
225
226
227
228
229
230TAGS_MODULE_BEGIN(Layout)
231
232 TAGS_MODULE_ADD(P)
233 TAGS_MODULE_ADD(BR)
234 TAGS_MODULE_ADD(CENTER)
235 TAGS_MODULE_ADD(DIV)
236 TAGS_MODULE_ADD(TITLE)
237 TAGS_MODULE_ADD(BODY)
238 TAGS_MODULE_ADD(BLOCKQUOTE)
239
240TAGS_MODULE_END(Layout)
241
242#endif