]> git.saurik.com Git - wxWidgets.git/blame - src/html/m_layout.cpp
Renameing funktions from DIB to prevent name clashes
[wxWidgets.git] / src / html / m_layout.cpp
CommitLineData
5526e819
VS
1/////////////////////////////////////////////////////////////////////////////
2// Name: mod_layout.cpp
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
13#include <wx/wxprec.h>
5526e819 14
5526e819 15#if wxUSE_HTML
3364ab79
RS
16#ifdef __BORDLANDC__
17#pragma hdrstop
18#endif
19
20#ifndef WXPRECOMP
21#include <wx/wx.h>
22#endif
23
5526e819 24
69941f05
VS
25#include "wx/html/forcelnk.h"
26#include "wx/html/m_templ.h"
5526e819 27
69941f05 28#include "wx/html/htmlwin.h"
5526e819
VS
29
30FORCE_LINK_ME(mod_layout)
31
32
33TAG_HANDLER_BEGIN(P, "P")
34
35 TAG_HANDLER_PROC(tag)
36 {
37 if (m_WParser -> GetContainer() -> GetFirstCell() != NULL) {
38 m_WParser -> CloseContainer();
39 m_WParser -> OpenContainer();
40 }
41 m_WParser -> GetContainer() -> SetIndent(m_WParser -> GetCharHeight(), HTML_INDENT_TOP);
42 m_WParser -> GetContainer() -> SetAlign(tag);
43 return FALSE;
44 }
45
46TAG_HANDLER_END(P)
47
48
49
50TAG_HANDLER_BEGIN(BR, "BR")
51
52 TAG_HANDLER_PROC(tag)
53 {
54 int al = m_WParser -> GetContainer() -> GetAlignHor();
55 wxHtmlContainerCell *c;
56
57 m_WParser -> CloseContainer();
58 c = m_WParser -> OpenContainer();
59 c -> SetAlignHor(al);
60 c -> SetAlign(tag);
61 return FALSE;
62 }
63
64TAG_HANDLER_END(BR)
65
66
67
68TAG_HANDLER_BEGIN(CENTER, "CENTER")
69
70 TAG_HANDLER_PROC(tag)
71 {
72 int old = m_WParser -> GetAlign();
73 wxHtmlContainerCell *c = m_WParser -> GetContainer();
74
75 m_WParser -> SetAlign(HTML_ALIGN_CENTER);
76 if (c -> GetFirstCell() != NULL) {
77 m_WParser -> CloseContainer();
78 m_WParser -> OpenContainer();
79 }
80 else
81 c -> SetAlignHor(HTML_ALIGN_CENTER);
82
83 if (tag.HasEnding()) {
84 ParseInner(tag);
85
86 m_WParser -> SetAlign(old);
87 if (c -> GetFirstCell() != NULL) {
88 m_WParser -> CloseContainer();
89 m_WParser -> OpenContainer();
90 }
91 else
92 c -> SetAlignHor(old);
93
94 return TRUE;
95 }
96 else return FALSE;
97 }
98
99TAG_HANDLER_END(CENTER)
100
101
102
103TAG_HANDLER_BEGIN(DIV, "DIV")
104
105 TAG_HANDLER_PROC(tag)
106 {
107 int old = m_WParser -> GetAlign();
108 wxHtmlContainerCell *c = m_WParser -> GetContainer();
109 if (c -> GetFirstCell() != NULL) {
110 m_WParser -> CloseContainer();
111 m_WParser -> OpenContainer();
112 c = m_WParser -> GetContainer();
113 c -> SetAlign(tag);
114 m_WParser -> SetAlign(c -> GetAlignHor());
115 }
116 else {
117 c -> SetAlign(tag);
118 m_WParser -> SetAlign(c -> GetAlignHor());
119 }
120
121 ParseInner(tag);
122
123 m_WParser -> SetAlign(old);
124 if (c -> GetFirstCell() != NULL) {
125 m_WParser -> CloseContainer();
126 m_WParser -> OpenContainer();
127 }
128 else
129 c -> SetAlignHor(old);
130
131 return TRUE;
132 }
133
134TAG_HANDLER_END(DIV)
135
136
137
138
139TAG_HANDLER_BEGIN(TITLE, "TITLE")
140
141 TAG_HANDLER_PROC(tag)
142 {
143 if (m_WParser -> GetWindow()) {
144 wxHtmlWindow *wfr = (wxHtmlWindow*)(m_WParser -> GetWindow());
145 if (wfr) {
146 wxString title = "";
147 wxString *src = m_WParser -> GetSource();
148
149 for (int i = tag.GetBeginPos(); i < tag.GetEndPos1(); i++) title += (*src)[i];
150 wfr -> SetTitle(title);
151 }
152 }
153 return TRUE;
154 }
155
156TAG_HANDLER_END(TITLE)
157
158
159
160
161TAG_HANDLER_BEGIN(BODY, "BODY")
162
163 TAG_HANDLER_PROC(tag)
164 {
165 unsigned long tmp;
166 wxColour clr;
167
168 if (tag.HasParam("TEXT")) {
72aa4a98
VS
169 if (tag.ScanParam("TEXT", "#%lX", &tmp) == 1) {
170 clr = wxColour((tmp & 0xFF0000) >> 16 , (tmp & 0x00FF00) >> 8, (tmp & 0x0000FF));
171 m_WParser -> SetActualColor(clr);
172 m_WParser -> GetContainer() -> InsertCell(new wxHtmlColourCell(clr));
173 }
174 }
5526e819
VS
175
176 if (tag.HasParam("LINK")) {
72aa4a98
VS
177 if (tag.ScanParam("LINK", "#%lX", &tmp) == 1) {
178 clr = wxColour((tmp & 0xFF0000) >> 16 , (tmp & 0x00FF00) >> 8, (tmp & 0x0000FF));
179 m_WParser -> SetLinkColor(clr);
180 }
5526e819
VS
181 }
182
183 if (tag.HasParam("BGCOLOR")) {
72aa4a98
VS
184 if (tag.ScanParam("BGCOLOR", "#%lX", &tmp) == 1) {
185 clr = wxColour((tmp & 0xFF0000) >> 16 , (tmp & 0x00FF00) >> 8, (tmp & 0x0000FF));
186 m_WParser -> GetContainer() -> InsertCell(new wxHtmlColourCell(clr, HTML_CLR_BACKGROUND));
187 if (m_WParser -> GetWindow() != NULL)
188 m_WParser -> GetWindow() -> SetBackgroundColour(clr);
189 }
5526e819
VS
190 }
191 return FALSE;
192 }
193
194TAG_HANDLER_END(BODY)
195
196
197
198TAG_HANDLER_BEGIN(BLOCKQUOTE, "BLOCKQUOTE")
199
200 TAG_HANDLER_PROC(tag)
201 {
202 wxHtmlContainerCell *c;
203
204 m_WParser -> CloseContainer();
205 c = m_WParser -> OpenContainer();
206 if (c -> GetAlignHor() == HTML_ALIGN_RIGHT)
207 c -> SetIndent(5 * m_WParser -> GetCharWidth(), HTML_INDENT_RIGHT);
208 else
209 c -> SetIndent(5 * m_WParser -> GetCharWidth(), HTML_INDENT_LEFT);
210 c -> SetIndent(m_WParser -> GetCharHeight(), HTML_INDENT_TOP);
211 m_WParser -> OpenContainer();
212 ParseInner(tag);
213 c = m_WParser -> CloseContainer();
214 c -> SetIndent(m_WParser -> GetCharHeight(), HTML_INDENT_BOTTOM);
215 m_WParser -> CloseContainer();
216 m_WParser -> OpenContainer();
217 return TRUE;
218 }
219
220TAG_HANDLER_END(BLOCKQUOTE)
221
222
223
224
225
226
227TAGS_MODULE_BEGIN(Layout)
228
229 TAGS_MODULE_ADD(P)
230 TAGS_MODULE_ADD(BR)
231 TAGS_MODULE_ADD(CENTER)
232 TAGS_MODULE_ADD(DIV)
233 TAGS_MODULE_ADD(TITLE)
234 TAGS_MODULE_ADD(BODY)
235 TAGS_MODULE_ADD(BLOCKQUOTE)
236
237TAGS_MODULE_END(Layout)
238
239#endif