]>
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());
158 wxString
*src
= m_WParser
->GetSource();
160 for (int i
= tag
.GetBeginPos(); i
< tag
.GetEndPos1(); i
++) title
+= (*src
)[(unsigned int) i
];
161 wfr
->OnSetTitle(title
);
167 TAG_HANDLER_END(TITLE
)
172 TAG_HANDLER_BEGIN(BODY
, "BODY")
174 TAG_HANDLER_PROC(tag
)
178 if (tag
.GetParamAsColour(wxT("TEXT"), &clr
))
180 m_WParser
->SetActualColor(clr
);
181 m_WParser
->GetContainer()->InsertCell(new wxHtmlColourCell(clr
));
184 if (tag
.GetParamAsColour(wxT("LINK"), &clr
))
185 m_WParser
->SetLinkColor(clr
);
187 if (tag
.GetParamAsColour(wxT("BGCOLOR"), &clr
))
189 m_WParser
->GetContainer()->InsertCell(
190 new wxHtmlColourCell(clr
, wxHTML_CLR_BACKGROUND
));
191 if (m_WParser
->GetWindow() != NULL
)
192 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();
210 if (c
->GetAlignHor() == wxHTML_ALIGN_RIGHT
)
211 c
->SetIndent(5 * m_WParser
->GetCharWidth(), wxHTML_INDENT_RIGHT
);
213 c
->SetIndent(5 * m_WParser
->GetCharWidth(), wxHTML_INDENT_LEFT
);
215 c
->SetIndent(m_WParser
->GetCharHeight(), wxHTML_INDENT_TOP
);
216 m_WParser
->OpenContainer();
218 c
= m_WParser
->CloseContainer();
219 c
->SetIndent(m_WParser
->GetCharHeight(), wxHTML_INDENT_BOTTOM
);
220 m_WParser
->CloseContainer();
221 m_WParser
->OpenContainer();
225 TAG_HANDLER_END(BLOCKQUOTE
)
232 TAGS_MODULE_BEGIN(Layout
)
236 TAGS_MODULE_ADD(CENTER
)
238 TAGS_MODULE_ADD(TITLE
)
239 TAGS_MODULE_ADD(BODY
)
240 TAGS_MODULE_ADD(BLOCKQUOTE
)
242 TAGS_MODULE_END(Layout
)