]>
Commit | Line | Data |
---|---|---|
5526e819 VS |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: mod_layout.cpp | |
3 | // Purpose: wxHtml module for basic paragraphs/layout handling | |
4 | // Author: Vaclav Slavik | |
69941f05 | 5 | // RCS-ID: $Id$ |
5526e819 VS |
6 | // Copyright: (c) 1999 Vaclav Slavik |
7 | // Licence: wxWindows Licence | |
8 | ///////////////////////////////////////////////////////////////////////////// | |
3364ab79 RS |
9 | #ifdef __GNUG__ |
10 | #pragma implementation | |
11 | #endif | |
12 | ||
314260fb | 13 | #include "wx/wxprec.h" |
5526e819 | 14 | |
314260fb VS |
15 | |
16 | #include "wx/defs.h" | |
5526e819 | 17 | #if wxUSE_HTML |
3364ab79 RS |
18 | #ifdef __BORDLANDC__ |
19 | #pragma hdrstop | |
20 | #endif | |
21 | ||
22 | #ifndef WXPRECOMP | |
314260fb | 23 | #include "wx/wx.h" |
3364ab79 RS |
24 | #endif |
25 | ||
5526e819 | 26 | |
69941f05 VS |
27 | #include "wx/html/forcelnk.h" |
28 | #include "wx/html/m_templ.h" | |
5526e819 | 29 | |
69941f05 | 30 | #include "wx/html/htmlwin.h" |
5526e819 VS |
31 | |
32 | FORCE_LINK_ME(mod_layout) | |
33 | ||
34 | ||
35 | TAG_HANDLER_BEGIN(P, "P") | |
36 | ||
37 | TAG_HANDLER_PROC(tag) | |
38 | { | |
39 | if (m_WParser -> GetContainer() -> GetFirstCell() != NULL) { | |
40 | m_WParser -> CloseContainer(); | |
41 | m_WParser -> OpenContainer(); | |
42 | } | |
efba2b89 | 43 | m_WParser -> GetContainer() -> SetIndent(m_WParser -> GetCharHeight(), wxHTML_INDENT_TOP); |
5526e819 VS |
44 | m_WParser -> GetContainer() -> SetAlign(tag); |
45 | return FALSE; | |
46 | } | |
47 | ||
48 | TAG_HANDLER_END(P) | |
49 | ||
50 | ||
51 | ||
52 | TAG_HANDLER_BEGIN(BR, "BR") | |
53 | ||
54 | TAG_HANDLER_PROC(tag) | |
55 | { | |
56 | int al = m_WParser -> GetContainer() -> GetAlignHor(); | |
57 | wxHtmlContainerCell *c; | |
58 | ||
59 | m_WParser -> CloseContainer(); | |
60 | c = m_WParser -> OpenContainer(); | |
61 | c -> SetAlignHor(al); | |
62 | c -> SetAlign(tag); | |
63 | return FALSE; | |
64 | } | |
65 | ||
66 | TAG_HANDLER_END(BR) | |
67 | ||
68 | ||
69 | ||
70 | TAG_HANDLER_BEGIN(CENTER, "CENTER") | |
71 | ||
72 | TAG_HANDLER_PROC(tag) | |
73 | { | |
74 | int old = m_WParser -> GetAlign(); | |
75 | wxHtmlContainerCell *c = m_WParser -> GetContainer(); | |
76 | ||
efba2b89 | 77 | m_WParser -> SetAlign(wxHTML_ALIGN_CENTER); |
5526e819 VS |
78 | if (c -> GetFirstCell() != NULL) { |
79 | m_WParser -> CloseContainer(); | |
80 | m_WParser -> OpenContainer(); | |
81 | } | |
82 | else | |
efba2b89 | 83 | c -> SetAlignHor(wxHTML_ALIGN_CENTER); |
5526e819 VS |
84 | |
85 | if (tag.HasEnding()) { | |
86 | ParseInner(tag); | |
87 | ||
88 | m_WParser -> SetAlign(old); | |
89 | if (c -> GetFirstCell() != NULL) { | |
90 | m_WParser -> CloseContainer(); | |
91 | m_WParser -> OpenContainer(); | |
92 | } | |
93 | else | |
94 | c -> SetAlignHor(old); | |
95 | ||
96 | return TRUE; | |
97 | } | |
98 | else return FALSE; | |
99 | } | |
100 | ||
101 | TAG_HANDLER_END(CENTER) | |
102 | ||
103 | ||
104 | ||
105 | TAG_HANDLER_BEGIN(DIV, "DIV") | |
106 | ||
107 | TAG_HANDLER_PROC(tag) | |
108 | { | |
109 | int old = m_WParser -> GetAlign(); | |
110 | wxHtmlContainerCell *c = m_WParser -> GetContainer(); | |
111 | if (c -> GetFirstCell() != NULL) { | |
112 | m_WParser -> CloseContainer(); | |
113 | m_WParser -> OpenContainer(); | |
114 | c = m_WParser -> GetContainer(); | |
115 | c -> SetAlign(tag); | |
116 | m_WParser -> SetAlign(c -> GetAlignHor()); | |
117 | } | |
118 | else { | |
119 | c -> SetAlign(tag); | |
120 | m_WParser -> SetAlign(c -> GetAlignHor()); | |
121 | } | |
122 | ||
123 | ParseInner(tag); | |
124 | ||
125 | m_WParser -> SetAlign(old); | |
126 | if (c -> GetFirstCell() != NULL) { | |
127 | m_WParser -> CloseContainer(); | |
128 | m_WParser -> OpenContainer(); | |
129 | } | |
130 | else | |
131 | c -> SetAlignHor(old); | |
132 | ||
133 | return TRUE; | |
134 | } | |
135 | ||
136 | TAG_HANDLER_END(DIV) | |
137 | ||
138 | ||
139 | ||
140 | ||
141 | TAG_HANDLER_BEGIN(TITLE, "TITLE") | |
142 | ||
143 | TAG_HANDLER_PROC(tag) | |
144 | { | |
145 | if (m_WParser -> GetWindow()) { | |
146 | wxHtmlWindow *wfr = (wxHtmlWindow*)(m_WParser -> GetWindow()); | |
147 | if (wfr) { | |
148 | wxString title = ""; | |
149 | wxString *src = m_WParser -> GetSource(); | |
150 | ||
151 | for (int i = tag.GetBeginPos(); i < tag.GetEndPos1(); i++) title += (*src)[i]; | |
152 | wfr -> SetTitle(title); | |
153 | } | |
154 | } | |
155 | return TRUE; | |
156 | } | |
157 | ||
158 | TAG_HANDLER_END(TITLE) | |
159 | ||
160 | ||
161 | ||
162 | ||
163 | TAG_HANDLER_BEGIN(BODY, "BODY") | |
164 | ||
165 | TAG_HANDLER_PROC(tag) | |
166 | { | |
167 | unsigned long tmp; | |
168 | wxColour clr; | |
169 | ||
66a77a74 OK |
170 | if (tag.HasParam(wxT("TEXT"))) { |
171 | if (tag.ScanParam(wxT("TEXT"), wxT("#%lX"), &tmp) == 1) { | |
72aa4a98 VS |
172 | clr = wxColour((tmp & 0xFF0000) >> 16 , (tmp & 0x00FF00) >> 8, (tmp & 0x0000FF)); |
173 | m_WParser -> SetActualColor(clr); | |
174 | m_WParser -> GetContainer() -> InsertCell(new wxHtmlColourCell(clr)); | |
175 | } | |
176 | } | |
5526e819 | 177 | |
66a77a74 OK |
178 | if (tag.HasParam(wxT("LINK"))) { |
179 | if (tag.ScanParam(wxT("LINK"), wxT("#%lX"), &tmp) == 1) { | |
72aa4a98 VS |
180 | clr = wxColour((tmp & 0xFF0000) >> 16 , (tmp & 0x00FF00) >> 8, (tmp & 0x0000FF)); |
181 | m_WParser -> SetLinkColor(clr); | |
182 | } | |
5526e819 VS |
183 | } |
184 | ||
66a77a74 OK |
185 | if (tag.HasParam(wxT("BGCOLOR"))) { |
186 | if (tag.ScanParam(wxT("BGCOLOR"), wxT("#%lX"), &tmp) == 1) { | |
72aa4a98 | 187 | clr = wxColour((tmp & 0xFF0000) >> 16 , (tmp & 0x00FF00) >> 8, (tmp & 0x0000FF)); |
efba2b89 | 188 | m_WParser -> GetContainer() -> InsertCell(new wxHtmlColourCell(clr, wxHTML_CLR_BACKGROUND)); |
72aa4a98 VS |
189 | if (m_WParser -> GetWindow() != NULL) |
190 | m_WParser -> GetWindow() -> SetBackgroundColour(clr); | |
191 | } | |
5526e819 VS |
192 | } |
193 | return FALSE; | |
194 | } | |
195 | ||
196 | TAG_HANDLER_END(BODY) | |
197 | ||
198 | ||
199 | ||
200 | TAG_HANDLER_BEGIN(BLOCKQUOTE, "BLOCKQUOTE") | |
201 | ||
202 | TAG_HANDLER_PROC(tag) | |
203 | { | |
204 | wxHtmlContainerCell *c; | |
205 | ||
206 | m_WParser -> CloseContainer(); | |
207 | c = m_WParser -> OpenContainer(); | |
efba2b89 VS |
208 | if (c -> GetAlignHor() == wxHTML_ALIGN_RIGHT) |
209 | c -> SetIndent(5 * m_WParser -> GetCharWidth(), wxHTML_INDENT_RIGHT); | |
5526e819 | 210 | else |
efba2b89 VS |
211 | c -> SetIndent(5 * m_WParser -> GetCharWidth(), wxHTML_INDENT_LEFT); |
212 | c -> SetIndent(m_WParser -> GetCharHeight(), wxHTML_INDENT_TOP); | |
5526e819 VS |
213 | m_WParser -> OpenContainer(); |
214 | ParseInner(tag); | |
215 | c = m_WParser -> CloseContainer(); | |
efba2b89 | 216 | c -> SetIndent(m_WParser -> GetCharHeight(), wxHTML_INDENT_BOTTOM); |
5526e819 VS |
217 | m_WParser -> CloseContainer(); |
218 | m_WParser -> OpenContainer(); | |
219 | return TRUE; | |
220 | } | |
221 | ||
222 | TAG_HANDLER_END(BLOCKQUOTE) | |
223 | ||
224 | ||
225 | ||
226 | ||
227 | ||
228 | ||
229 | TAGS_MODULE_BEGIN(Layout) | |
230 | ||
231 | TAGS_MODULE_ADD(P) | |
232 | TAGS_MODULE_ADD(BR) | |
233 | TAGS_MODULE_ADD(CENTER) | |
234 | TAGS_MODULE_ADD(DIV) | |
235 | TAGS_MODULE_ADD(TITLE) | |
236 | TAGS_MODULE_ADD(BODY) | |
237 | TAGS_MODULE_ADD(BLOCKQUOTE) | |
238 | ||
239 | TAGS_MODULE_END(Layout) | |
240 | ||
241 | #endif |