]>
git.saurik.com Git - wxWidgets.git/blob - src/html/m_layout.cpp
1 /////////////////////////////////////////////////////////////////////////////
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(m_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();
63 c
-> SetMinHeight(m_WParser
-> GetCharHeight());
71 TAG_HANDLER_BEGIN(CENTER
, "CENTER")
75 int old
= m_WParser
-> GetAlign();
76 wxHtmlContainerCell
*c
= m_WParser
-> GetContainer();
78 m_WParser
-> SetAlign(wxHTML_ALIGN_CENTER
);
79 if (c
-> GetFirstCell() != NULL
) {
80 m_WParser
-> CloseContainer();
81 m_WParser
-> OpenContainer();
84 c
-> SetAlignHor(wxHTML_ALIGN_CENTER
);
86 if (tag
.HasEnding()) {
89 m_WParser
-> SetAlign(old
);
90 if (c
-> GetFirstCell() != NULL
) {
91 m_WParser
-> CloseContainer();
92 m_WParser
-> OpenContainer();
95 c
-> SetAlignHor(old
);
102 TAG_HANDLER_END(CENTER
)
106 TAG_HANDLER_BEGIN(DIV
, "DIV")
108 TAG_HANDLER_PROC(tag
)
110 int old
= m_WParser
-> GetAlign();
111 wxHtmlContainerCell
*c
= m_WParser
-> GetContainer();
112 if (c
-> GetFirstCell() != NULL
) {
113 m_WParser
-> CloseContainer();
114 m_WParser
-> OpenContainer();
115 c
= m_WParser
-> GetContainer();
117 m_WParser
-> SetAlign(c
-> GetAlignHor());
121 m_WParser
-> SetAlign(c
-> GetAlignHor());
126 m_WParser
-> SetAlign(old
);
127 if (c
-> GetFirstCell() != NULL
) {
128 m_WParser
-> CloseContainer();
129 m_WParser
-> OpenContainer();
132 c
-> SetAlignHor(old
);
142 TAG_HANDLER_BEGIN(TITLE
, "TITLE")
144 TAG_HANDLER_PROC(tag
)
146 if (m_WParser
-> GetWindow()) {
147 wxHtmlWindow
*wfr
= (wxHtmlWindow
*)(m_WParser
-> GetWindow());
150 wxString
*src
= m_WParser
-> GetSource();
152 for (int i
= tag
.GetBeginPos(); i
< tag
.GetEndPos1(); i
++) title
+= (*src
)[(unsigned int) i
];
153 wfr
-> OnSetTitle(title
);
159 TAG_HANDLER_END(TITLE
)
164 TAG_HANDLER_BEGIN(BODY
, "BODY")
166 TAG_HANDLER_PROC(tag
)
171 if (tag
.HasParam(wxT("TEXT"))) {
172 if (tag
.ScanParam(wxT("TEXT"), wxT("#%lX"), &tmp
) == 1) {
173 clr
= wxColour((tmp
& 0xFF0000) >> 16 , (tmp
& 0x00FF00) >> 8, (tmp
& 0x0000FF));
174 m_WParser
-> SetActualColor(clr
);
175 m_WParser
-> GetContainer() -> InsertCell(new wxHtmlColourCell(clr
));
179 if (tag
.HasParam(wxT("LINK"))) {
180 if (tag
.ScanParam(wxT("LINK"), wxT("#%lX"), &tmp
) == 1) {
181 clr
= wxColour((tmp
& 0xFF0000) >> 16 , (tmp
& 0x00FF00) >> 8, (tmp
& 0x0000FF));
182 m_WParser
-> SetLinkColor(clr
);
186 if (tag
.HasParam(wxT("BGCOLOR"))) {
187 if (tag
.ScanParam(wxT("BGCOLOR"), wxT("#%lX"), &tmp
) == 1) {
188 clr
= wxColour((tmp
& 0xFF0000) >> 16 , (tmp
& 0x00FF00) >> 8, (tmp
& 0x0000FF));
189 m_WParser
-> GetContainer() -> InsertCell(new wxHtmlColourCell(clr
, wxHTML_CLR_BACKGROUND
));
190 if (m_WParser
-> GetWindow() != NULL
)
191 m_WParser
-> GetWindow() -> SetBackgroundColour(clr
);
197 TAG_HANDLER_END(BODY
)
201 TAG_HANDLER_BEGIN(BLOCKQUOTE
, "BLOCKQUOTE")
203 TAG_HANDLER_PROC(tag
)
205 wxHtmlContainerCell
*c
;
207 m_WParser
-> CloseContainer();
208 c
= m_WParser
-> OpenContainer();
209 if (c
-> GetAlignHor() == wxHTML_ALIGN_RIGHT
)
210 c
-> SetIndent(5 * m_WParser
-> GetCharWidth(), wxHTML_INDENT_RIGHT
);
212 c
-> SetIndent(5 * m_WParser
-> GetCharWidth(), wxHTML_INDENT_LEFT
);
213 c
-> SetIndent(m_WParser
-> GetCharHeight(), wxHTML_INDENT_TOP
);
214 m_WParser
-> OpenContainer();
216 c
= m_WParser
-> CloseContainer();
217 c
-> SetIndent(m_WParser
-> GetCharHeight(), wxHTML_INDENT_BOTTOM
);
218 m_WParser
-> CloseContainer();
219 m_WParser
-> OpenContainer();
223 TAG_HANDLER_END(BLOCKQUOTE
)
230 TAGS_MODULE_BEGIN(Layout
)
234 TAGS_MODULE_ADD(CENTER
)
236 TAGS_MODULE_ADD(TITLE
)
237 TAGS_MODULE_ADD(BODY
)
238 TAGS_MODULE_ADD(BLOCKQUOTE
)
240 TAGS_MODULE_END(Layout
)