]>
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 tag
.ScanParam("TEXT", "#%lX", &tmp
);
169 clr
= wxColour((tmp
& 0xFF0000) >> 16 , (tmp
& 0x00FF00) >> 8, (tmp
& 0x0000FF));
170 m_WParser
-> SetActualColor(clr
);
171 m_WParser
-> GetContainer() -> InsertCell(new wxHtmlColourCell(clr
));
174 if (tag
.HasParam("LINK")) {
175 tag
.ScanParam("LINK", "#%lX", &tmp
);
176 clr
= wxColour((tmp
& 0xFF0000) >> 16 , (tmp
& 0x00FF00) >> 8, (tmp
& 0x0000FF));
177 m_WParser
-> SetLinkColor(clr
);
180 if (tag
.HasParam("BGCOLOR")) {
181 tag
.ScanParam("BGCOLOR", "#%lX", &tmp
);
182 clr
= wxColour((tmp
& 0xFF0000) >> 16 , (tmp
& 0x00FF00) >> 8, (tmp
& 0x0000FF));
183 m_WParser
-> GetContainer() -> InsertCell(new wxHtmlColourCell(clr
, HTML_CLR_BACKGROUND
));
184 if (m_WParser
-> GetWindow() != NULL
)
185 m_WParser
-> GetWindow() -> SetBackgroundColour(clr
);
190 TAG_HANDLER_END(BODY
)
194 TAG_HANDLER_BEGIN(BLOCKQUOTE
, "BLOCKQUOTE")
196 TAG_HANDLER_PROC(tag
)
198 wxHtmlContainerCell
*c
;
200 m_WParser
-> CloseContainer();
201 c
= m_WParser
-> OpenContainer();
202 if (c
-> GetAlignHor() == HTML_ALIGN_RIGHT
)
203 c
-> SetIndent(5 * m_WParser
-> GetCharWidth(), HTML_INDENT_RIGHT
);
205 c
-> SetIndent(5 * m_WParser
-> GetCharWidth(), HTML_INDENT_LEFT
);
206 c
-> SetIndent(m_WParser
-> GetCharHeight(), HTML_INDENT_TOP
);
207 m_WParser
-> OpenContainer();
209 c
= m_WParser
-> CloseContainer();
210 c
-> SetIndent(m_WParser
-> GetCharHeight(), HTML_INDENT_BOTTOM
);
211 m_WParser
-> CloseContainer();
212 m_WParser
-> OpenContainer();
216 TAG_HANDLER_END(BLOCKQUOTE
)
223 TAGS_MODULE_BEGIN(Layout
)
227 TAGS_MODULE_ADD(CENTER
)
229 TAGS_MODULE_ADD(TITLE
)
230 TAGS_MODULE_ADD(BODY
)
231 TAGS_MODULE_ADD(BLOCKQUOTE
)
233 TAGS_MODULE_END(Layout
)