]>
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"
17 #if wxUSE_HTML && wxUSE_STREAMS
26 #include "wx/html/forcelnk.h"
27 #include "wx/html/m_templ.h"
29 #include "wx/html/htmlwin.h"
31 FORCE_LINK_ME(m_layout
)
34 TAG_HANDLER_BEGIN(P
, "P")
38 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
)
81 m_WParser
->CloseContainer();
82 m_WParser
->OpenContainer();
85 c
->SetAlignHor(wxHTML_ALIGN_CENTER
);
91 m_WParser
->SetAlign(old
);
92 if (c
->GetFirstCell() != NULL
)
94 m_WParser
->CloseContainer();
95 m_WParser
->OpenContainer();
105 TAG_HANDLER_END(CENTER
)
109 TAG_HANDLER_BEGIN(DIV
, "DIV")
111 TAG_HANDLER_PROC(tag
)
113 int old
= m_WParser
->GetAlign();
114 wxHtmlContainerCell
*c
= m_WParser
->GetContainer();
115 if (c
->GetFirstCell() != NULL
)
117 m_WParser
->CloseContainer();
118 m_WParser
->OpenContainer();
119 c
= m_WParser
->GetContainer();
121 m_WParser
->SetAlign(c
->GetAlignHor());
126 m_WParser
->SetAlign(c
->GetAlignHor());
131 m_WParser
->SetAlign(old
);
132 if (c
->GetFirstCell() != NULL
)
134 m_WParser
->CloseContainer();
135 m_WParser
->OpenContainer();
148 TAG_HANDLER_BEGIN(TITLE
, "TITLE")
150 TAG_HANDLER_PROC(tag
)
152 if (m_WParser
->GetWindow())
154 wxHtmlWindow
*wfr
= (wxHtmlWindow
*)(m_WParser
->GetWindow());
157 const wxString
& src
= *m_WParser
->GetSource();
158 wfr
->OnSetTitle(src
.Mid(tag
.GetBeginPos(),
159 tag
.GetEndPos1()-tag
.GetBeginPos()));
165 TAG_HANDLER_END(TITLE
)
170 TAG_HANDLER_BEGIN(BODY
, "BODY")
172 TAG_HANDLER_PROC(tag
)
176 if (tag
.GetParamAsColour(wxT("TEXT"), &clr
))
178 m_WParser
->SetActualColor(clr
);
179 m_WParser
->GetContainer()->InsertCell(new wxHtmlColourCell(clr
));
182 if (tag
.GetParamAsColour(wxT("LINK"), &clr
))
183 m_WParser
->SetLinkColor(clr
);
185 if (tag
.GetParamAsColour(wxT("BGCOLOR"), &clr
))
187 m_WParser
->GetContainer()->InsertCell(
188 new wxHtmlColourCell(clr
, wxHTML_CLR_BACKGROUND
));
189 if (m_WParser
->GetWindow() != NULL
)
190 m_WParser
->GetWindow()->SetBackgroundColour(clr
);
195 TAG_HANDLER_END(BODY
)
199 TAG_HANDLER_BEGIN(BLOCKQUOTE
, "BLOCKQUOTE")
201 TAG_HANDLER_PROC(tag
)
203 wxHtmlContainerCell
*c
;
205 m_WParser
->CloseContainer();
206 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
);
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
)