]>
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((unsigned char)((tmp
& 0xFF0000) >> 16),
185 (unsigned char)((tmp
& 0x00FF00) >> 8),
186 (unsigned char)(tmp
& 0x0000FF));
187 m_WParser
->SetActualColor(clr
);
188 m_WParser
->GetContainer()->InsertCell(new wxHtmlColourCell(clr
));
192 if (tag
.HasParam(wxT("LINK")))
194 if (tag
.ScanParam(wxT("LINK"), wxT("#%lX"), &tmp
) == 1)
196 clr
= wxColour((unsigned char)((tmp
& 0xFF0000) >> 16),
197 (unsigned char)((tmp
& 0x00FF00) >> 8),
198 (unsigned char)(tmp
& 0x0000FF));
199 m_WParser
->SetLinkColor(clr
);
203 if (tag
.HasParam(wxT("BGCOLOR")))
205 if (tag
.ScanParam(wxT("BGCOLOR"), wxT("#%lX"), &tmp
) == 1)
207 clr
= wxColour((unsigned char)((tmp
& 0xFF0000) >> 16),
208 (unsigned char)((tmp
& 0x00FF00) >> 8),
209 (unsigned char)(tmp
& 0x0000FF));
210 m_WParser
->GetContainer()->InsertCell(new wxHtmlColourCell(clr
, wxHTML_CLR_BACKGROUND
));
211 if (m_WParser
->GetWindow() != NULL
)
212 m_WParser
->GetWindow()->SetBackgroundColour(clr
);
218 TAG_HANDLER_END(BODY
)
222 TAG_HANDLER_BEGIN(BLOCKQUOTE
, "BLOCKQUOTE")
224 TAG_HANDLER_PROC(tag
)
226 wxHtmlContainerCell
*c
;
228 m_WParser
->CloseContainer();
229 c
= m_WParser
->OpenContainer();
231 if (c
->GetAlignHor() == wxHTML_ALIGN_RIGHT
)
232 c
->SetIndent(5 * m_WParser
->GetCharWidth(), wxHTML_INDENT_RIGHT
);
234 c
->SetIndent(5 * m_WParser
->GetCharWidth(), wxHTML_INDENT_LEFT
);
236 c
->SetIndent(m_WParser
->GetCharHeight(), wxHTML_INDENT_TOP
);
237 m_WParser
->OpenContainer();
239 c
= m_WParser
->CloseContainer();
240 c
->SetIndent(m_WParser
->GetCharHeight(), wxHTML_INDENT_BOTTOM
);
241 m_WParser
->CloseContainer();
242 m_WParser
->OpenContainer();
246 TAG_HANDLER_END(BLOCKQUOTE
)
253 TAGS_MODULE_BEGIN(Layout
)
257 TAGS_MODULE_ADD(CENTER
)
259 TAGS_MODULE_ADD(TITLE
)
260 TAGS_MODULE_ADD(BODY
)
261 TAGS_MODULE_ADD(BLOCKQUOTE
)
263 TAGS_MODULE_END(Layout
)