]>
git.saurik.com Git - wxWidgets.git/blob - src/html/m_layout.cpp
4fd163e68bf7f456eec4731484263ced77d659c4
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"
27 #include "wx/html/forcelnk.h"
28 #include "wx/html/m_templ.h"
30 #include "wx/html/htmlwin.h"
32 FORCE_LINK_ME(mod_layout
)
35 TAG_HANDLER_BEGIN(P
, "P")
39 if (m_WParser
-> GetContainer() -> GetFirstCell() != NULL
) {
40 m_WParser
-> CloseContainer();
41 m_WParser
-> OpenContainer();
43 m_WParser
-> GetContainer() -> SetIndent(m_WParser
-> GetCharHeight(), wxHTML_INDENT_TOP
);
44 m_WParser
-> GetContainer() -> SetAlign(tag
);
52 TAG_HANDLER_BEGIN(BR
, "BR")
56 int al
= m_WParser
-> GetContainer() -> GetAlignHor();
57 wxHtmlContainerCell
*c
;
59 m_WParser
-> CloseContainer();
60 c
= m_WParser
-> OpenContainer();
70 TAG_HANDLER_BEGIN(CENTER
, "CENTER")
74 int old
= m_WParser
-> GetAlign();
75 wxHtmlContainerCell
*c
= m_WParser
-> GetContainer();
77 m_WParser
-> SetAlign(wxHTML_ALIGN_CENTER
);
78 if (c
-> GetFirstCell() != NULL
) {
79 m_WParser
-> CloseContainer();
80 m_WParser
-> OpenContainer();
83 c
-> SetAlignHor(wxHTML_ALIGN_CENTER
);
85 if (tag
.HasEnding()) {
88 m_WParser
-> SetAlign(old
);
89 if (c
-> GetFirstCell() != NULL
) {
90 m_WParser
-> CloseContainer();
91 m_WParser
-> OpenContainer();
94 c
-> SetAlignHor(old
);
101 TAG_HANDLER_END(CENTER
)
105 TAG_HANDLER_BEGIN(DIV
, "DIV")
107 TAG_HANDLER_PROC(tag
)
109 int old
= m_WParser
-> GetAlign();
110 wxHtmlContainerCell
*c
= m_WParser
-> GetContainer();
111 if (c
-> GetFirstCell() != NULL
) {
112 m_WParser
-> CloseContainer();
113 m_WParser
-> OpenContainer();
114 c
= m_WParser
-> GetContainer();
116 m_WParser
-> SetAlign(c
-> GetAlignHor());
120 m_WParser
-> SetAlign(c
-> GetAlignHor());
125 m_WParser
-> SetAlign(old
);
126 if (c
-> GetFirstCell() != NULL
) {
127 m_WParser
-> CloseContainer();
128 m_WParser
-> OpenContainer();
131 c
-> SetAlignHor(old
);
141 TAG_HANDLER_BEGIN(TITLE
, "TITLE")
143 TAG_HANDLER_PROC(tag
)
145 if (m_WParser
-> GetWindow()) {
146 wxHtmlWindow
*wfr
= (wxHtmlWindow
*)(m_WParser
-> GetWindow());
149 wxString
*src
= m_WParser
-> GetSource();
151 for (int i
= tag
.GetBeginPos(); i
< tag
.GetEndPos1(); i
++) title
+= (*src
)[i
];
152 wfr
-> SetTitle(title
);
158 TAG_HANDLER_END(TITLE
)
163 TAG_HANDLER_BEGIN(BODY
, "BODY")
165 TAG_HANDLER_PROC(tag
)
170 if (tag
.HasParam("TEXT")) {
171 if (tag
.ScanParam("TEXT", "#%lX", &tmp
) == 1) {
172 clr
= wxColour((tmp
& 0xFF0000) >> 16 , (tmp
& 0x00FF00) >> 8, (tmp
& 0x0000FF));
173 m_WParser
-> SetActualColor(clr
);
174 m_WParser
-> GetContainer() -> InsertCell(new wxHtmlColourCell(clr
));
178 if (tag
.HasParam("LINK")) {
179 if (tag
.ScanParam("LINK", "#%lX", &tmp
) == 1) {
180 clr
= wxColour((tmp
& 0xFF0000) >> 16 , (tmp
& 0x00FF00) >> 8, (tmp
& 0x0000FF));
181 m_WParser
-> SetLinkColor(clr
);
185 if (tag
.HasParam("BGCOLOR")) {
186 if (tag
.ScanParam("BGCOLOR", "#%lX", &tmp
) == 1) {
187 clr
= wxColour((tmp
& 0xFF0000) >> 16 , (tmp
& 0x00FF00) >> 8, (tmp
& 0x0000FF));
188 m_WParser
-> GetContainer() -> InsertCell(new wxHtmlColourCell(clr
, wxHTML_CLR_BACKGROUND
));
189 if (m_WParser
-> GetWindow() != NULL
)
190 m_WParser
-> GetWindow() -> SetBackgroundColour(clr
);
196 TAG_HANDLER_END(BODY
)
200 TAG_HANDLER_BEGIN(BLOCKQUOTE
, "BLOCKQUOTE")
202 TAG_HANDLER_PROC(tag
)
204 wxHtmlContainerCell
*c
;
206 m_WParser
-> CloseContainer();
207 c
= m_WParser
-> OpenContainer();
208 if (c
-> GetAlignHor() == wxHTML_ALIGN_RIGHT
)
209 c
-> SetIndent(5 * m_WParser
-> GetCharWidth(), wxHTML_INDENT_RIGHT
);
211 c
-> SetIndent(5 * m_WParser
-> GetCharWidth(), wxHTML_INDENT_LEFT
);
212 c
-> SetIndent(m_WParser
-> GetCharHeight(), wxHTML_INDENT_TOP
);
213 m_WParser
-> OpenContainer();
215 c
= m_WParser
-> CloseContainer();
216 c
-> SetIndent(m_WParser
-> GetCharHeight(), wxHTML_INDENT_BOTTOM
);
217 m_WParser
-> CloseContainer();
218 m_WParser
-> OpenContainer();
222 TAG_HANDLER_END(BLOCKQUOTE
)
229 TAGS_MODULE_BEGIN(Layout
)
233 TAGS_MODULE_ADD(CENTER
)
235 TAGS_MODULE_ADD(TITLE
)
236 TAGS_MODULE_ADD(BODY
)
237 TAGS_MODULE_ADD(BLOCKQUOTE
)
239 TAGS_MODULE_END(Layout
)