]>
git.saurik.com Git - wxWidgets.git/blob - src/html/m_layout.cpp
3a1ad13dbbaa3a634a2e9c6c870ee868931483ea
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: mod_layout.cpp
3 // Purpose: wxHtml module for basic paragraphs/layout handling
4 // Author: Vaclav Slavik
6 // Copyright: (c) 1999 Vaclav Slavik
7 // Licence: wxWindows Licence
8 /////////////////////////////////////////////////////////////////////////////
10 #pragma implementation
13 #include <wx/wxprec.h>
25 #include "wx/html/forcelnk.h"
26 #include "wx/html/m_templ.h"
28 #include "wx/html/htmlwin.h"
30 FORCE_LINK_ME(mod_layout
)
33 TAG_HANDLER_BEGIN(P
, "P")
37 if (m_WParser
-> GetContainer() -> GetFirstCell() != NULL
) {
38 m_WParser
-> CloseContainer();
39 m_WParser
-> OpenContainer();
41 m_WParser
-> GetContainer() -> SetIndent(m_WParser
-> GetCharHeight(), wxHTML_INDENT_TOP
);
42 m_WParser
-> GetContainer() -> SetAlign(tag
);
50 TAG_HANDLER_BEGIN(BR
, "BR")
54 int al
= m_WParser
-> GetContainer() -> GetAlignHor();
55 wxHtmlContainerCell
*c
;
57 m_WParser
-> CloseContainer();
58 c
= m_WParser
-> OpenContainer();
68 TAG_HANDLER_BEGIN(CENTER
, "CENTER")
72 int old
= m_WParser
-> GetAlign();
73 wxHtmlContainerCell
*c
= m_WParser
-> GetContainer();
75 m_WParser
-> SetAlign(wxHTML_ALIGN_CENTER
);
76 if (c
-> GetFirstCell() != NULL
) {
77 m_WParser
-> CloseContainer();
78 m_WParser
-> OpenContainer();
81 c
-> SetAlignHor(wxHTML_ALIGN_CENTER
);
83 if (tag
.HasEnding()) {
86 m_WParser
-> SetAlign(old
);
87 if (c
-> GetFirstCell() != NULL
) {
88 m_WParser
-> CloseContainer();
89 m_WParser
-> OpenContainer();
92 c
-> SetAlignHor(old
);
99 TAG_HANDLER_END(CENTER
)
103 TAG_HANDLER_BEGIN(DIV
, "DIV")
105 TAG_HANDLER_PROC(tag
)
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();
114 m_WParser
-> SetAlign(c
-> GetAlignHor());
118 m_WParser
-> SetAlign(c
-> GetAlignHor());
123 m_WParser
-> SetAlign(old
);
124 if (c
-> GetFirstCell() != NULL
) {
125 m_WParser
-> CloseContainer();
126 m_WParser
-> OpenContainer();
129 c
-> SetAlignHor(old
);
139 TAG_HANDLER_BEGIN(TITLE
, "TITLE")
141 TAG_HANDLER_PROC(tag
)
143 if (m_WParser
-> GetWindow()) {
144 wxHtmlWindow
*wfr
= (wxHtmlWindow
*)(m_WParser
-> GetWindow());
147 wxString
*src
= m_WParser
-> GetSource();
149 for (int i
= tag
.GetBeginPos(); i
< tag
.GetEndPos1(); i
++) title
+= (*src
)[i
];
150 wfr
-> SetTitle(title
);
156 TAG_HANDLER_END(TITLE
)
161 TAG_HANDLER_BEGIN(BODY
, "BODY")
163 TAG_HANDLER_PROC(tag
)
168 if (tag
.HasParam("TEXT")) {
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
));
176 if (tag
.HasParam("LINK")) {
177 if (tag
.ScanParam("LINK", "#%lX", &tmp
) == 1) {
178 clr
= wxColour((tmp
& 0xFF0000) >> 16 , (tmp
& 0x00FF00) >> 8, (tmp
& 0x0000FF));
179 m_WParser
-> SetLinkColor(clr
);
183 if (tag
.HasParam("BGCOLOR")) {
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
, wxHTML_CLR_BACKGROUND
));
187 if (m_WParser
-> GetWindow() != NULL
)
188 m_WParser
-> GetWindow() -> SetBackgroundColour(clr
);
194 TAG_HANDLER_END(BODY
)
198 TAG_HANDLER_BEGIN(BLOCKQUOTE
, "BLOCKQUOTE")
200 TAG_HANDLER_PROC(tag
)
202 wxHtmlContainerCell
*c
;
204 m_WParser
-> CloseContainer();
205 c
= m_WParser
-> OpenContainer();
206 if (c
-> GetAlignHor() == wxHTML_ALIGN_RIGHT
)
207 c
-> SetIndent(5 * m_WParser
-> GetCharWidth(), wxHTML_INDENT_RIGHT
);
209 c
-> SetIndent(5 * m_WParser
-> GetCharWidth(), wxHTML_INDENT_LEFT
);
210 c
-> SetIndent(m_WParser
-> GetCharHeight(), wxHTML_INDENT_TOP
);
211 m_WParser
-> OpenContainer();
213 c
= m_WParser
-> CloseContainer();
214 c
-> SetIndent(m_WParser
-> GetCharHeight(), wxHTML_INDENT_BOTTOM
);
215 m_WParser
-> CloseContainer();
216 m_WParser
-> OpenContainer();
220 TAG_HANDLER_END(BLOCKQUOTE
)
227 TAGS_MODULE_BEGIN(Layout
)
231 TAGS_MODULE_ADD(CENTER
)
233 TAGS_MODULE_ADD(TITLE
)
234 TAGS_MODULE_ADD(BODY
)
235 TAGS_MODULE_ADD(BLOCKQUOTE
)
237 TAGS_MODULE_END(Layout
)