]>
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
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
)
180 if (tag
.HasParam(wxT("TEXT")))
182 if (tag
.ScanParam(wxT("TEXT"), wxT("#%lX"), &tmp
) == 1)
184 clr
= wxColour((tmp
& 0xFF0000) >> 16 , (tmp
& 0x00FF00) >> 8, (tmp
& 0x0000FF));
185 m_WParser
->SetActualColor(clr
);
186 m_WParser
->GetContainer()->InsertCell(new wxHtmlColourCell(clr
));
190 if (tag
.HasParam(wxT("LINK")))
192 if (tag
.ScanParam(wxT("LINK"), wxT("#%lX"), &tmp
) == 1)
194 clr
= wxColour((tmp
& 0xFF0000) >> 16 , (tmp
& 0x00FF00) >> 8, (tmp
& 0x0000FF));
195 m_WParser
->SetLinkColor(clr
);
199 if (tag
.HasParam(wxT("BGCOLOR")))
201 if (tag
.ScanParam(wxT("BGCOLOR"), wxT("#%lX"), &tmp
) == 1)
203 clr
= wxColour((tmp
& 0xFF0000) >> 16 , (tmp
& 0x00FF00) >> 8, (tmp
& 0x0000FF));
204 m_WParser
->GetContainer()->InsertCell(new wxHtmlColourCell(clr
, wxHTML_CLR_BACKGROUND
));
205 if (m_WParser
->GetWindow() != NULL
)
206 m_WParser
->GetWindow()->SetBackgroundColour(clr
);
212 TAG_HANDLER_END(BODY
)
216 TAG_HANDLER_BEGIN(BLOCKQUOTE
, "BLOCKQUOTE")
218 TAG_HANDLER_PROC(tag
)
220 wxHtmlContainerCell
*c
;
222 m_WParser
->CloseContainer();
223 c
= m_WParser
->OpenContainer();
225 if (c
->GetAlignHor() == wxHTML_ALIGN_RIGHT
)
226 c
->SetIndent(5 * m_WParser
->GetCharWidth(), wxHTML_INDENT_RIGHT
);
228 c
->SetIndent(5 * m_WParser
->GetCharWidth(), wxHTML_INDENT_LEFT
);
230 c
->SetIndent(m_WParser
->GetCharHeight(), wxHTML_INDENT_TOP
);
231 m_WParser
->OpenContainer();
233 c
= m_WParser
->CloseContainer();
234 c
->SetIndent(m_WParser
->GetCharHeight(), wxHTML_INDENT_BOTTOM
);
235 m_WParser
->CloseContainer();
236 m_WParser
->OpenContainer();
240 TAG_HANDLER_END(BLOCKQUOTE
)
247 TAGS_MODULE_BEGIN(Layout
)
251 TAGS_MODULE_ADD(CENTER
)
253 TAGS_MODULE_ADD(TITLE
)
254 TAGS_MODULE_ADD(BODY
)
255 TAGS_MODULE_ADD(BLOCKQUOTE
)
257 TAGS_MODULE_END(Layout
)