]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/html/m_layout.cpp
corrected a too eager error message (patch 648599)
[wxWidgets.git] / src / html / m_layout.cpp
... / ...
CommitLineData
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 __BORLANDC__
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
31FORCE_LINK_ME(m_layout)
32
33
34TAG_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
48TAG_HANDLER_END(P)
49
50
51
52TAG_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
67TAG_HANDLER_END(BR)
68
69
70
71TAG_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
105TAG_HANDLER_END(CENTER)
106
107
108
109TAG_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
143TAG_HANDLER_END(DIV)
144
145
146
147
148TAG_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 const wxString& src = *m_WParser->GetSource();
158 wfr->OnSetTitle(src.Mid(tag.GetBeginPos(),
159 tag.GetEndPos1()-tag.GetBeginPos()));
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 {
174 wxColour clr;
175
176 if (tag.GetParamAsColour(wxT("TEXT"), &clr))
177 {
178 m_WParser->SetActualColor(clr);
179 m_WParser->GetContainer()->InsertCell(new wxHtmlColourCell(clr));
180 }
181
182 if (tag.GetParamAsColour(wxT("LINK"), &clr))
183 m_WParser->SetLinkColor(clr);
184
185 if (tag.GetParamAsColour(wxT("BGCOLOR"), &clr))
186 {
187 m_WParser->GetContainer()->InsertCell(
188 new wxHtmlColourCell(clr, wxHTML_CLR_BACKGROUND));
189 if (m_WParser->GetWindow() != NULL)
190 m_WParser->GetWindow()->SetBackgroundColour(clr);
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;
204
205 m_WParser->CloseContainer();
206 c = m_WParser->OpenContainer();
207
208 if (c->GetAlignHor() == wxHTML_ALIGN_RIGHT)
209 c->SetIndent(5 * m_WParser->GetCharWidth(), wxHTML_INDENT_RIGHT);
210 else
211 c->SetIndent(5 * m_WParser->GetCharWidth(), wxHTML_INDENT_LEFT);
212
213 c->SetIndent(m_WParser->GetCharHeight(), wxHTML_INDENT_TOP);
214 m_WParser->OpenContainer();
215 ParseInner(tag);
216 c = m_WParser->CloseContainer();
217 c->SetIndent(m_WParser->GetCharHeight(), wxHTML_INDENT_BOTTOM);
218 m_WParser->CloseContainer();
219 m_WParser->OpenContainer();
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