]>
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/wxprec.h>
24 #include <wx/html/forcelink.h>
25 #include <wx/html/mod_templ.h>
27 #include <wx/html/htmlwin.h>
29 FORCE_LINK_ME(mod_layout
)
32 TAG_HANDLER_BEGIN(P
, "P")
36 if (m_WParser
-> GetContainer() -> GetFirstCell() != NULL
) {
37 m_WParser
-> CloseContainer();
38 m_WParser
-> OpenContainer();
40 m_WParser
-> GetContainer() -> SetIndent(m_WParser
-> GetCharHeight(), HTML_INDENT_TOP
);
41 m_WParser
-> GetContainer() -> SetAlign(tag
);
49 TAG_HANDLER_BEGIN(BR
, "BR")
53 int al
= m_WParser
-> GetContainer() -> GetAlignHor();
54 wxHtmlContainerCell
*c
;
56 m_WParser
-> CloseContainer();
57 c
= m_WParser
-> OpenContainer();
67 TAG_HANDLER_BEGIN(CENTER
, "CENTER")
71 int old
= m_WParser
-> GetAlign();
72 wxHtmlContainerCell
*c
= m_WParser
-> GetContainer();
74 m_WParser
-> SetAlign(HTML_ALIGN_CENTER
);
75 if (c
-> GetFirstCell() != NULL
) {
76 m_WParser
-> CloseContainer();
77 m_WParser
-> OpenContainer();
80 c
-> SetAlignHor(HTML_ALIGN_CENTER
);
82 if (tag
.HasEnding()) {
85 m_WParser
-> SetAlign(old
);
86 if (c
-> GetFirstCell() != NULL
) {
87 m_WParser
-> CloseContainer();
88 m_WParser
-> OpenContainer();
91 c
-> SetAlignHor(old
);
98 TAG_HANDLER_END(CENTER
)
102 TAG_HANDLER_BEGIN(DIV
, "DIV")
104 TAG_HANDLER_PROC(tag
)
106 int old
= m_WParser
-> GetAlign();
107 wxHtmlContainerCell
*c
= m_WParser
-> GetContainer();
108 if (c
-> GetFirstCell() != NULL
) {
109 m_WParser
-> CloseContainer();
110 m_WParser
-> OpenContainer();
111 c
= m_WParser
-> GetContainer();
113 m_WParser
-> SetAlign(c
-> GetAlignHor());
117 m_WParser
-> SetAlign(c
-> GetAlignHor());
122 m_WParser
-> SetAlign(old
);
123 if (c
-> GetFirstCell() != NULL
) {
124 m_WParser
-> CloseContainer();
125 m_WParser
-> OpenContainer();
128 c
-> SetAlignHor(old
);
138 TAG_HANDLER_BEGIN(TITLE
, "TITLE")
140 TAG_HANDLER_PROC(tag
)
142 if (m_WParser
-> GetWindow()) {
143 wxHtmlWindow
*wfr
= (wxHtmlWindow
*)(m_WParser
-> GetWindow());
146 wxString
*src
= m_WParser
-> GetSource();
148 for (int i
= tag
.GetBeginPos(); i
< tag
.GetEndPos1(); i
++) title
+= (*src
)[i
];
149 wfr
-> SetTitle(title
);
155 TAG_HANDLER_END(TITLE
)
160 TAG_HANDLER_BEGIN(BODY
, "BODY")
162 TAG_HANDLER_PROC(tag
)
167 if (tag
.HasParam("TEXT")) {
168 if (tag
.ScanParam("TEXT", "#%lX", &tmp
) == 1) {
169 clr
= wxColour((tmp
& 0xFF0000) >> 16 , (tmp
& 0x00FF00) >> 8, (tmp
& 0x0000FF));
170 m_WParser
-> SetActualColor(clr
);
171 m_WParser
-> GetContainer() -> InsertCell(new wxHtmlColourCell(clr
));
175 if (tag
.HasParam("LINK")) {
176 if (tag
.ScanParam("LINK", "#%lX", &tmp
) == 1) {
177 clr
= wxColour((tmp
& 0xFF0000) >> 16 , (tmp
& 0x00FF00) >> 8, (tmp
& 0x0000FF));
178 m_WParser
-> SetLinkColor(clr
);
182 if (tag
.HasParam("BGCOLOR")) {
183 if (tag
.ScanParam("BGCOLOR", "#%lX", &tmp
) == 1) {
184 clr
= wxColour((tmp
& 0xFF0000) >> 16 , (tmp
& 0x00FF00) >> 8, (tmp
& 0x0000FF));
185 m_WParser
-> GetContainer() -> InsertCell(new wxHtmlColourCell(clr
, HTML_CLR_BACKGROUND
));
186 if (m_WParser
-> GetWindow() != NULL
)
187 m_WParser
-> GetWindow() -> SetBackgroundColour(clr
);
193 TAG_HANDLER_END(BODY
)
197 TAG_HANDLER_BEGIN(BLOCKQUOTE
, "BLOCKQUOTE")
199 TAG_HANDLER_PROC(tag
)
201 wxHtmlContainerCell
*c
;
203 m_WParser
-> CloseContainer();
204 c
= m_WParser
-> OpenContainer();
205 if (c
-> GetAlignHor() == HTML_ALIGN_RIGHT
)
206 c
-> SetIndent(5 * m_WParser
-> GetCharWidth(), HTML_INDENT_RIGHT
);
208 c
-> SetIndent(5 * m_WParser
-> GetCharWidth(), HTML_INDENT_LEFT
);
209 c
-> SetIndent(m_WParser
-> GetCharHeight(), HTML_INDENT_TOP
);
210 m_WParser
-> OpenContainer();
212 c
= m_WParser
-> CloseContainer();
213 c
-> SetIndent(m_WParser
-> GetCharHeight(), HTML_INDENT_BOTTOM
);
214 m_WParser
-> CloseContainer();
215 m_WParser
-> OpenContainer();
219 TAG_HANDLER_END(BLOCKQUOTE
)
226 TAGS_MODULE_BEGIN(Layout
)
230 TAGS_MODULE_ADD(CENTER
)
232 TAGS_MODULE_ADD(TITLE
)
233 TAGS_MODULE_ADD(BODY
)
234 TAGS_MODULE_ADD(BLOCKQUOTE
)
236 TAGS_MODULE_END(Layout
)