]> git.saurik.com Git - wxWidgets.git/blame - src/html/m_layout.cpp
added © -> (c) conversion in html docs
[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
314260fb 13#include "wx/wxprec.h"
5526e819 14
314260fb
VS
15
16#include "wx/defs.h"
5526e819 17#if wxUSE_HTML
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
VS
31
32FORCE_LINK_ME(mod_layout)
33
34
35TAG_HANDLER_BEGIN(P, "P")
36
37 TAG_HANDLER_PROC(tag)
38 {
39 if (m_WParser -> GetContainer() -> GetFirstCell() != NULL) {
40 m_WParser -> CloseContainer();
41 m_WParser -> OpenContainer();
8c651ab7 42 }
efba2b89 43 m_WParser -> GetContainer() -> SetIndent(m_WParser -> GetCharHeight(), wxHTML_INDENT_TOP);
5526e819
VS
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);
8c651ab7 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 {
75 int old = m_WParser -> GetAlign();
76 wxHtmlContainerCell *c = m_WParser -> GetContainer();
77
efba2b89 78 m_WParser -> SetAlign(wxHTML_ALIGN_CENTER);
5526e819
VS
79 if (c -> GetFirstCell() != NULL) {
80 m_WParser -> CloseContainer();
81 m_WParser -> OpenContainer();
82 }
83 else
efba2b89 84 c -> SetAlignHor(wxHTML_ALIGN_CENTER);
5526e819
VS
85
86 if (tag.HasEnding()) {
87 ParseInner(tag);
88
89 m_WParser -> SetAlign(old);
90 if (c -> GetFirstCell() != NULL) {
91 m_WParser -> CloseContainer();
92 m_WParser -> OpenContainer();
93 }
94 else
95 c -> SetAlignHor(old);
96
97 return TRUE;
98 }
99 else return FALSE;
100 }
101
102TAG_HANDLER_END(CENTER)
103
104
105
106TAG_HANDLER_BEGIN(DIV, "DIV")
107
108 TAG_HANDLER_PROC(tag)
109 {
110 int old = m_WParser -> GetAlign();
111 wxHtmlContainerCell *c = m_WParser -> GetContainer();
112 if (c -> GetFirstCell() != NULL) {
113 m_WParser -> CloseContainer();
114 m_WParser -> OpenContainer();
115 c = m_WParser -> GetContainer();
116 c -> SetAlign(tag);
117 m_WParser -> SetAlign(c -> GetAlignHor());
118 }
119 else {
120 c -> SetAlign(tag);
121 m_WParser -> SetAlign(c -> GetAlignHor());
122 }
123
124 ParseInner(tag);
125
126 m_WParser -> SetAlign(old);
127 if (c -> GetFirstCell() != NULL) {
128 m_WParser -> CloseContainer();
129 m_WParser -> OpenContainer();
130 }
131 else
132 c -> SetAlignHor(old);
133
134 return TRUE;
135 }
136
137TAG_HANDLER_END(DIV)
138
139
140
141
142TAG_HANDLER_BEGIN(TITLE, "TITLE")
143
144 TAG_HANDLER_PROC(tag)
145 {
146 if (m_WParser -> GetWindow()) {
147 wxHtmlWindow *wfr = (wxHtmlWindow*)(m_WParser -> GetWindow());
148 if (wfr) {
149 wxString title = "";
150 wxString *src = m_WParser -> GetSource();
151
01dba85a 152 for (int i = tag.GetBeginPos(); i < tag.GetEndPos1(); i++) title += (*src)[(unsigned int) i];
5526e819
VS
153 wfr -> SetTitle(title);
154 }
155 }
156 return TRUE;
157 }
158
159TAG_HANDLER_END(TITLE)
160
161
162
163
164TAG_HANDLER_BEGIN(BODY, "BODY")
165
166 TAG_HANDLER_PROC(tag)
167 {
168 unsigned long tmp;
169 wxColour clr;
170
66a77a74
OK
171 if (tag.HasParam(wxT("TEXT"))) {
172 if (tag.ScanParam(wxT("TEXT"), wxT("#%lX"), &tmp) == 1) {
72aa4a98
VS
173 clr = wxColour((tmp & 0xFF0000) >> 16 , (tmp & 0x00FF00) >> 8, (tmp & 0x0000FF));
174 m_WParser -> SetActualColor(clr);
175 m_WParser -> GetContainer() -> InsertCell(new wxHtmlColourCell(clr));
176 }
177 }
5526e819 178
66a77a74
OK
179 if (tag.HasParam(wxT("LINK"))) {
180 if (tag.ScanParam(wxT("LINK"), wxT("#%lX"), &tmp) == 1) {
72aa4a98
VS
181 clr = wxColour((tmp & 0xFF0000) >> 16 , (tmp & 0x00FF00) >> 8, (tmp & 0x0000FF));
182 m_WParser -> SetLinkColor(clr);
183 }
5526e819
VS
184 }
185
66a77a74
OK
186 if (tag.HasParam(wxT("BGCOLOR"))) {
187 if (tag.ScanParam(wxT("BGCOLOR"), wxT("#%lX"), &tmp) == 1) {
72aa4a98 188 clr = wxColour((tmp & 0xFF0000) >> 16 , (tmp & 0x00FF00) >> 8, (tmp & 0x0000FF));
efba2b89 189 m_WParser -> GetContainer() -> InsertCell(new wxHtmlColourCell(clr, wxHTML_CLR_BACKGROUND));
72aa4a98
VS
190 if (m_WParser -> GetWindow() != NULL)
191 m_WParser -> GetWindow() -> SetBackgroundColour(clr);
192 }
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;
206
207 m_WParser -> CloseContainer();
208 c = m_WParser -> OpenContainer();
efba2b89
VS
209 if (c -> GetAlignHor() == wxHTML_ALIGN_RIGHT)
210 c -> SetIndent(5 * m_WParser -> GetCharWidth(), wxHTML_INDENT_RIGHT);
5526e819 211 else
efba2b89
VS
212 c -> SetIndent(5 * m_WParser -> GetCharWidth(), wxHTML_INDENT_LEFT);
213 c -> SetIndent(m_WParser -> GetCharHeight(), wxHTML_INDENT_TOP);
5526e819
VS
214 m_WParser -> OpenContainer();
215 ParseInner(tag);
216 c = m_WParser -> CloseContainer();
efba2b89 217 c -> SetIndent(m_WParser -> GetCharHeight(), wxHTML_INDENT_BOTTOM);
5526e819
VS
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