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"
17 #if wxUSE_HTML && wxUSE_STREAMS
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
)
41 m_WParser
->CloseContainer();
42 m_WParser
->OpenContainer();
44 m_WParser
->GetContainer()->SetIndent(m_WParser
->GetCharHeight(), wxHTML_INDENT_TOP
);
45 m_WParser
->GetContainer()->SetAlign(tag
);
53 TAG_HANDLER_BEGIN(BR
, "BR")
57 int al
= m_WParser
->GetContainer()->GetAlignHor();
58 wxHtmlContainerCell
*c
;
60 m_WParser
->CloseContainer();
61 c
= m_WParser
->OpenContainer();
64 c
->SetMinHeight(m_WParser
->GetCharHeight());
72 TAG_HANDLER_BEGIN(CENTER
, "CENTER")
76 int old
= m_WParser
->GetAlign();
77 wxHtmlContainerCell
*c
= m_WParser
->GetContainer();
79 m_WParser
->SetAlign(wxHTML_ALIGN_CENTER
);
80 if (c
->GetFirstCell() != NULL
)
82 m_WParser
->CloseContainer();
83 m_WParser
->OpenContainer();
86 c
->SetAlignHor(wxHTML_ALIGN_CENTER
);
92 m_WParser
->SetAlign(old
);
93 if (c
->GetFirstCell() != NULL
)
95 m_WParser
->CloseContainer();
96 m_WParser
->OpenContainer();
106 TAG_HANDLER_END(CENTER
)
110 TAG_HANDLER_BEGIN(DIV
, "DIV")
112 TAG_HANDLER_PROC(tag
)
114 int old
= m_WParser
->GetAlign();
115 wxHtmlContainerCell
*c
= m_WParser
->GetContainer();
116 if (c
->GetFirstCell() != NULL
)
118 m_WParser
->CloseContainer();
119 m_WParser
->OpenContainer();
120 c
= m_WParser
->GetContainer();
122 m_WParser
->SetAlign(c
->GetAlignHor());
127 m_WParser
->SetAlign(c
->GetAlignHor());
132 m_WParser
->SetAlign(old
);
133 if (c
->GetFirstCell() != NULL
)
135 m_WParser
->CloseContainer();
136 m_WParser
->OpenContainer();
149 TAG_HANDLER_BEGIN(TITLE
, "TITLE")
151 TAG_HANDLER_PROC(tag
)
153 if (m_WParser
->GetWindow())
155 wxHtmlWindow
*wfr
= (wxHtmlWindow
*)(m_WParser
->GetWindow());
159 wxString
*src
= m_WParser
->GetSource();
161 for (int i
= tag
.GetBeginPos(); i
< tag
.GetEndPos1(); i
++) title
+= (*src
)[(unsigned int) i
];
162 wfr
->OnSetTitle(title
);
168 TAG_HANDLER_END(TITLE
)
173 TAG_HANDLER_BEGIN(BODY
, "BODY")
175 TAG_HANDLER_PROC(tag
)
179 if (tag
.GetParamAsColour(wxT("TEXT"), &clr
))
181 m_WParser
->SetActualColor(clr
);
182 m_WParser
->GetContainer()->InsertCell(new wxHtmlColourCell(clr
));
185 if (tag
.GetParamAsColour(wxT("LINK"), &clr
))
186 m_WParser
->SetLinkColor(clr
);
188 if (tag
.GetParamAsColour(wxT("BGCOLOR"), &clr
))
190 m_WParser
->GetContainer()->InsertCell(
191 new wxHtmlColourCell(clr
, wxHTML_CLR_BACKGROUND
));
192 if (m_WParser
->GetWindow() != NULL
)
193 m_WParser
->GetWindow()->SetBackgroundColour(clr
);
198 TAG_HANDLER_END(BODY
)
202 TAG_HANDLER_BEGIN(BLOCKQUOTE
, "BLOCKQUOTE")
204 TAG_HANDLER_PROC(tag
)
206 wxHtmlContainerCell
*c
;
208 m_WParser
->CloseContainer();
209 c
= m_WParser
->OpenContainer();
211 if (c
->GetAlignHor() == wxHTML_ALIGN_RIGHT
)
212 c
->SetIndent(5 * m_WParser
->GetCharWidth(), wxHTML_INDENT_RIGHT
);
214 c
->SetIndent(5 * m_WParser
->GetCharWidth(), wxHTML_INDENT_LEFT
);
216 c
->SetIndent(m_WParser
->GetCharHeight(), wxHTML_INDENT_TOP
);
217 m_WParser
->OpenContainer();
219 c
= m_WParser
->CloseContainer();
220 c
->SetIndent(m_WParser
->GetCharHeight(), wxHTML_INDENT_BOTTOM
);
221 m_WParser
->CloseContainer();
222 m_WParser
->OpenContainer();
226 TAG_HANDLER_END(BLOCKQUOTE
)
233 TAGS_MODULE_BEGIN(Layout
)
237 TAGS_MODULE_ADD(CENTER
)
239 TAGS_MODULE_ADD(TITLE
)
240 TAGS_MODULE_ADD(BODY
)
241 TAGS_MODULE_ADD(BLOCKQUOTE
)
243 TAGS_MODULE_END(Layout
)