]>
git.saurik.com Git - wxWidgets.git/blob - src/html/mod_layout.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: mod_layout.cpp
3 // Purpose: wxHtml module for basic paragraphs/layout handling
4 // Author: Vaclav Slavik
5 // Copyright: (c) 1999 Vaclav Slavik
6 // Licence: wxWindows Licence
7 /////////////////////////////////////////////////////////////////////////////
12 #include <wx/html/forcelink.h>
13 #include <wx/html/mod_templ.h>
15 #include <wx/html/htmlwin.h>
17 FORCE_LINK_ME(mod_layout
)
20 TAG_HANDLER_BEGIN(P
, "P")
24 if (m_WParser
-> GetContainer() -> GetFirstCell() != NULL
) {
25 m_WParser
-> CloseContainer();
26 m_WParser
-> OpenContainer();
28 m_WParser
-> GetContainer() -> SetIndent(m_WParser
-> GetCharHeight(), HTML_INDENT_TOP
);
29 m_WParser
-> GetContainer() -> SetAlign(tag
);
37 TAG_HANDLER_BEGIN(BR
, "BR")
41 int al
= m_WParser
-> GetContainer() -> GetAlignHor();
42 wxHtmlContainerCell
*c
;
44 m_WParser
-> CloseContainer();
45 c
= m_WParser
-> OpenContainer();
55 TAG_HANDLER_BEGIN(CENTER
, "CENTER")
59 int old
= m_WParser
-> GetAlign();
60 wxHtmlContainerCell
*c
= m_WParser
-> GetContainer();
62 m_WParser
-> SetAlign(HTML_ALIGN_CENTER
);
63 if (c
-> GetFirstCell() != NULL
) {
64 m_WParser
-> CloseContainer();
65 m_WParser
-> OpenContainer();
68 c
-> SetAlignHor(HTML_ALIGN_CENTER
);
70 if (tag
.HasEnding()) {
73 m_WParser
-> SetAlign(old
);
74 if (c
-> GetFirstCell() != NULL
) {
75 m_WParser
-> CloseContainer();
76 m_WParser
-> OpenContainer();
79 c
-> SetAlignHor(old
);
86 TAG_HANDLER_END(CENTER
)
90 TAG_HANDLER_BEGIN(DIV
, "DIV")
94 int old
= m_WParser
-> GetAlign();
95 wxHtmlContainerCell
*c
= m_WParser
-> GetContainer();
96 if (c
-> GetFirstCell() != NULL
) {
97 m_WParser
-> CloseContainer();
98 m_WParser
-> OpenContainer();
99 c
= m_WParser
-> GetContainer();
101 m_WParser
-> SetAlign(c
-> GetAlignHor());
105 m_WParser
-> SetAlign(c
-> GetAlignHor());
110 m_WParser
-> SetAlign(old
);
111 if (c
-> GetFirstCell() != NULL
) {
112 m_WParser
-> CloseContainer();
113 m_WParser
-> OpenContainer();
116 c
-> SetAlignHor(old
);
126 TAG_HANDLER_BEGIN(TITLE
, "TITLE")
128 TAG_HANDLER_PROC(tag
)
130 if (m_WParser
-> GetWindow()) {
131 wxHtmlWindow
*wfr
= (wxHtmlWindow
*)(m_WParser
-> GetWindow());
134 wxString
*src
= m_WParser
-> GetSource();
136 for (int i
= tag
.GetBeginPos(); i
< tag
.GetEndPos1(); i
++) title
+= (*src
)[i
];
137 wfr
-> SetTitle(title
);
143 TAG_HANDLER_END(TITLE
)
148 TAG_HANDLER_BEGIN(BODY
, "BODY")
150 TAG_HANDLER_PROC(tag
)
155 if (tag
.HasParam("TEXT")) {
156 tag
.ScanParam("TEXT", "#%lX", &tmp
);
157 clr
= wxColour((tmp
& 0xFF0000) >> 16 , (tmp
& 0x00FF00) >> 8, (tmp
& 0x0000FF));
158 m_WParser
-> SetActualColor(clr
);
159 m_WParser
-> GetContainer() -> InsertCell(new wxHtmlColourCell(clr
));
162 if (tag
.HasParam("LINK")) {
163 tag
.ScanParam("LINK", "#%lX", &tmp
);
164 clr
= wxColour((tmp
& 0xFF0000) >> 16 , (tmp
& 0x00FF00) >> 8, (tmp
& 0x0000FF));
165 m_WParser
-> SetLinkColor(clr
);
168 if (tag
.HasParam("BGCOLOR")) {
169 tag
.ScanParam("BGCOLOR", "#%lX", &tmp
);
170 clr
= wxColour((tmp
& 0xFF0000) >> 16 , (tmp
& 0x00FF00) >> 8, (tmp
& 0x0000FF));
171 m_WParser
-> GetContainer() -> InsertCell(new wxHtmlColourCell(clr
, HTML_CLR_BACKGROUND
));
172 if (m_WParser
-> GetWindow() != NULL
)
173 m_WParser
-> GetWindow() -> SetBackgroundColour(clr
);
178 TAG_HANDLER_END(BODY
)
182 TAG_HANDLER_BEGIN(BLOCKQUOTE
, "BLOCKQUOTE")
184 TAG_HANDLER_PROC(tag
)
186 wxHtmlContainerCell
*c
;
188 m_WParser
-> CloseContainer();
189 c
= m_WParser
-> OpenContainer();
190 if (c
-> GetAlignHor() == HTML_ALIGN_RIGHT
)
191 c
-> SetIndent(5 * m_WParser
-> GetCharWidth(), HTML_INDENT_RIGHT
);
193 c
-> SetIndent(5 * m_WParser
-> GetCharWidth(), HTML_INDENT_LEFT
);
194 c
-> SetIndent(m_WParser
-> GetCharHeight(), HTML_INDENT_TOP
);
195 m_WParser
-> OpenContainer();
197 c
= m_WParser
-> CloseContainer();
198 c
-> SetIndent(m_WParser
-> GetCharHeight(), HTML_INDENT_BOTTOM
);
199 m_WParser
-> CloseContainer();
200 m_WParser
-> OpenContainer();
204 TAG_HANDLER_END(BLOCKQUOTE
)
211 TAGS_MODULE_BEGIN(Layout
)
215 TAGS_MODULE_ADD(CENTER
)
217 TAGS_MODULE_ADD(TITLE
)
218 TAGS_MODULE_ADD(BODY
)
219 TAGS_MODULE_ADD(BLOCKQUOTE
)
221 TAGS_MODULE_END(Layout
)