]> git.saurik.com Git - wxWidgets.git/blame - src/html/m_layout.cpp
warning fix
[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
314260fb 23#include "wx/wx.h"
3364ab79
RS
24#endif
25
5526e819 26
69941f05
VS
27#include "wx/html/forcelnk.h"
28#include "wx/html/m_templ.h"
5526e819 29
69941f05 30#include "wx/html/htmlwin.h"
5526e819 31
c88293a4 32FORCE_LINK_ME(m_layout)
5526e819
VS
33
34
35TAG_HANDLER_BEGIN(P, "P")
36
37 TAG_HANDLER_PROC(tag)
38 {
33ac7e6f 39 if (m_WParser->GetContainer()->GetFirstCell() != NULL)
4f9297b0
VS
40 {
41 m_WParser->CloseContainer();
42 m_WParser->OpenContainer();
8c651ab7 43 }
4f9297b0
VS
44 m_WParser->GetContainer()->SetIndent(m_WParser->GetCharHeight(), wxHTML_INDENT_TOP);
45 m_WParser->GetContainer()->SetAlign(tag);
5526e819
VS
46 return FALSE;
47 }
48
49TAG_HANDLER_END(P)
50
51
52
53TAG_HANDLER_BEGIN(BR, "BR")
54
55 TAG_HANDLER_PROC(tag)
56 {
4f9297b0 57 int al = m_WParser->GetContainer()->GetAlignHor();
5526e819 58 wxHtmlContainerCell *c;
33ac7e6f 59
4f9297b0
VS
60 m_WParser->CloseContainer();
61 c = m_WParser->OpenContainer();
62 c->SetAlignHor(al);
63 c->SetAlign(tag);
64 c->SetMinHeight(m_WParser->GetCharHeight());
5526e819
VS
65 return FALSE;
66 }
67
68TAG_HANDLER_END(BR)
69
70
71
72TAG_HANDLER_BEGIN(CENTER, "CENTER")
73
74 TAG_HANDLER_PROC(tag)
75 {
4f9297b0
VS
76 int old = m_WParser->GetAlign();
77 wxHtmlContainerCell *c = m_WParser->GetContainer();
78
79 m_WParser->SetAlign(wxHTML_ALIGN_CENTER);
33ac7e6f 80 if (c->GetFirstCell() != NULL)
4f9297b0
VS
81 {
82 m_WParser->CloseContainer();
83 m_WParser->OpenContainer();
5526e819
VS
84 }
85 else
4f9297b0 86 c->SetAlignHor(wxHTML_ALIGN_CENTER);
5526e819 87
33ac7e6f 88 if (tag.HasEnding())
4f9297b0 89 {
5526e819
VS
90 ParseInner(tag);
91
4f9297b0 92 m_WParser->SetAlign(old);
33ac7e6f 93 if (c->GetFirstCell() != NULL)
4f9297b0
VS
94 {
95 m_WParser->CloseContainer();
96 m_WParser->OpenContainer();
5526e819
VS
97 }
98 else
4f9297b0 99 c->SetAlignHor(old);
5526e819
VS
100
101 return TRUE;
102 }
103 else return FALSE;
104 }
105
106TAG_HANDLER_END(CENTER)
107
108
109
110TAG_HANDLER_BEGIN(DIV, "DIV")
111
112 TAG_HANDLER_PROC(tag)
113 {
4f9297b0
VS
114 int old = m_WParser->GetAlign();
115 wxHtmlContainerCell *c = m_WParser->GetContainer();
33ac7e6f 116 if (c->GetFirstCell() != NULL)
4f9297b0
VS
117 {
118 m_WParser->CloseContainer();
119 m_WParser->OpenContainer();
120 c = m_WParser->GetContainer();
121 c->SetAlign(tag);
122 m_WParser->SetAlign(c->GetAlignHor());
5526e819 123 }
33ac7e6f 124 else
4f9297b0
VS
125 {
126 c->SetAlign(tag);
127 m_WParser->SetAlign(c->GetAlignHor());
5526e819
VS
128 }
129
130 ParseInner(tag);
131
4f9297b0 132 m_WParser->SetAlign(old);
33ac7e6f 133 if (c->GetFirstCell() != NULL)
4f9297b0
VS
134 {
135 m_WParser->CloseContainer();
136 m_WParser->OpenContainer();
5526e819
VS
137 }
138 else
4f9297b0 139 c->SetAlignHor(old);
5526e819
VS
140
141 return TRUE;
142 }
143
144TAG_HANDLER_END(DIV)
145
146
147
148
149TAG_HANDLER_BEGIN(TITLE, "TITLE")
150
151 TAG_HANDLER_PROC(tag)
152 {
33ac7e6f 153 if (m_WParser->GetWindow())
4f9297b0
VS
154 {
155 wxHtmlWindow *wfr = (wxHtmlWindow*)(m_WParser->GetWindow());
33ac7e6f 156 if (wfr)
4f9297b0 157 {
5526e819 158 wxString title = "";
4f9297b0 159 wxString *src = m_WParser->GetSource();
5526e819 160
01dba85a 161 for (int i = tag.GetBeginPos(); i < tag.GetEndPos1(); i++) title += (*src)[(unsigned int) i];
4f9297b0 162 wfr->OnSetTitle(title);
5526e819
VS
163 }
164 }
165 return TRUE;
166 }
167
168TAG_HANDLER_END(TITLE)
169
170
171
172
173TAG_HANDLER_BEGIN(BODY, "BODY")
174
175 TAG_HANDLER_PROC(tag)
176 {
177 unsigned long tmp;
178 wxColour clr;
179
33ac7e6f 180 if (tag.HasParam(wxT("TEXT")))
4f9297b0 181 {
33ac7e6f 182 if (tag.ScanParam(wxT("TEXT"), wxT("#%lX"), &tmp) == 1)
4f9297b0 183 {
33ac7e6f
KB
184 clr = wxColour((unsigned char)((tmp & 0xFF0000) >> 16),
185 (unsigned char)((tmp & 0x00FF00) >> 8),
186 (unsigned char)(tmp & 0x0000FF));
4f9297b0
VS
187 m_WParser->SetActualColor(clr);
188 m_WParser->GetContainer()->InsertCell(new wxHtmlColourCell(clr));
72aa4a98 189 }
4f9297b0 190 }
5526e819 191
33ac7e6f 192 if (tag.HasParam(wxT("LINK")))
4f9297b0 193 {
33ac7e6f 194 if (tag.ScanParam(wxT("LINK"), wxT("#%lX"), &tmp) == 1)
4f9297b0 195 {
33ac7e6f
KB
196 clr = wxColour((unsigned char)((tmp & 0xFF0000) >> 16),
197 (unsigned char)((tmp & 0x00FF00) >> 8),
198 (unsigned char)(tmp & 0x0000FF));
4f9297b0
VS
199 m_WParser->SetLinkColor(clr);
200 }
5526e819
VS
201 }
202
33ac7e6f 203 if (tag.HasParam(wxT("BGCOLOR")))
4f9297b0 204 {
33ac7e6f 205 if (tag.ScanParam(wxT("BGCOLOR"), wxT("#%lX"), &tmp) == 1)
4f9297b0 206 {
33ac7e6f
KB
207 clr = wxColour((unsigned char)((tmp & 0xFF0000) >> 16),
208 (unsigned char)((tmp & 0x00FF00) >> 8),
209 (unsigned char)(tmp & 0x0000FF));
4f9297b0
VS
210 m_WParser->GetContainer()->InsertCell(new wxHtmlColourCell(clr, wxHTML_CLR_BACKGROUND));
211 if (m_WParser->GetWindow() != NULL)
212 m_WParser->GetWindow()->SetBackgroundColour(clr);
213 }
5526e819
VS
214 }
215 return FALSE;
216 }
217
218TAG_HANDLER_END(BODY)
219
220
221
222TAG_HANDLER_BEGIN(BLOCKQUOTE, "BLOCKQUOTE")
223
224 TAG_HANDLER_PROC(tag)
225 {
226 wxHtmlContainerCell *c;
33ac7e6f 227
4f9297b0
VS
228 m_WParser->CloseContainer();
229 c = m_WParser->OpenContainer();
33ac7e6f 230
4f9297b0
VS
231 if (c->GetAlignHor() == wxHTML_ALIGN_RIGHT)
232 c->SetIndent(5 * m_WParser->GetCharWidth(), wxHTML_INDENT_RIGHT);
5526e819 233 else
4f9297b0 234 c->SetIndent(5 * m_WParser->GetCharWidth(), wxHTML_INDENT_LEFT);
33ac7e6f 235
4f9297b0
VS
236 c->SetIndent(m_WParser->GetCharHeight(), wxHTML_INDENT_TOP);
237 m_WParser->OpenContainer();
5526e819 238 ParseInner(tag);
4f9297b0
VS
239 c = m_WParser->CloseContainer();
240 c->SetIndent(m_WParser->GetCharHeight(), wxHTML_INDENT_BOTTOM);
241 m_WParser->CloseContainer();
242 m_WParser->OpenContainer();
5526e819
VS
243 return TRUE;
244 }
245
246TAG_HANDLER_END(BLOCKQUOTE)
247
248
249
250
251
252
253TAGS_MODULE_BEGIN(Layout)
254
255 TAGS_MODULE_ADD(P)
256 TAGS_MODULE_ADD(BR)
257 TAGS_MODULE_ADD(CENTER)
258 TAGS_MODULE_ADD(DIV)
259 TAGS_MODULE_ADD(TITLE)
260 TAGS_MODULE_ADD(BODY)
261 TAGS_MODULE_ADD(BLOCKQUOTE)
262
263TAGS_MODULE_END(Layout)
264
265#endif