]>
Commit | Line | Data |
---|---|---|
5526e819 VS |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: htmlcell.cpp | |
3 | // Purpose: wxHtmlCell - basic element of HTML output | |
4 | // Author: Vaclav Slavik | |
69941f05 | 5 | // RCS-ID: $Id$ |
5526e819 | 6 | // Copyright: (c) 1999 Vaclav Slavik |
65571936 | 7 | // Licence: wxWindows licence |
5526e819 VS |
8 | ///////////////////////////////////////////////////////////////////////////// |
9 | ||
14f355c2 | 10 | #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) |
1aedb1dd | 11 | #pragma implementation "htmlcell.h" |
5526e819 VS |
12 | #endif |
13 | ||
4dcaf11a | 14 | #include "wx/wxprec.h" |
5526e819 | 15 | |
314260fb | 16 | #include "wx/defs.h" |
f6bcfd97 BP |
17 | |
18 | #if wxUSE_HTML && wxUSE_STREAMS | |
5526e819 | 19 | |
2b5f62a0 | 20 | #ifdef __BORLANDC__ |
5526e819 VS |
21 | #pragma hdrstop |
22 | #endif | |
23 | ||
24 | #ifndef WXPRECOMP | |
04dbb646 VZ |
25 | #include "wx/brush.h" |
26 | #include "wx/colour.h" | |
27 | #include "wx/dc.h" | |
5526e819 VS |
28 | #endif |
29 | ||
4dcaf11a RR |
30 | #include "wx/html/htmlcell.h" |
31 | #include "wx/html/htmlwin.h" | |
36c4ff4d | 32 | #include "wx/settings.h" |
77bae5e2 | 33 | #include "wx/module.h" |
ace0fab4 | 34 | #include "wx/dynarray.h" |
77bae5e2 | 35 | |
5526e819 VS |
36 | #include <stdlib.h> |
37 | ||
77bae5e2 VS |
38 | //----------------------------------------------------------------------------- |
39 | // Global variables | |
40 | //----------------------------------------------------------------------------- | |
41 | ||
42 | static wxCursor *gs_cursorLink = NULL; | |
43 | static wxCursor *gs_cursorText = NULL; | |
44 | ||
45 | ||
e3774124 VS |
46 | //----------------------------------------------------------------------------- |
47 | // Helper classes | |
48 | //----------------------------------------------------------------------------- | |
49 | ||
1338c59a VS |
50 | void wxHtmlSelection::Set(const wxPoint& fromPos, const wxHtmlCell *fromCell, |
51 | const wxPoint& toPos, const wxHtmlCell *toCell) | |
e3774124 VS |
52 | { |
53 | m_fromCell = fromCell; | |
54 | m_toCell = toCell; | |
55 | m_fromPos = fromPos; | |
56 | m_toPos = toPos; | |
57 | } | |
58 | ||
1338c59a | 59 | void wxHtmlSelection::Set(const wxHtmlCell *fromCell, const wxHtmlCell *toCell) |
e3774124 VS |
60 | { |
61 | wxPoint p1 = fromCell ? fromCell->GetAbsPos() : wxDefaultPosition; | |
62 | wxPoint p2 = toCell ? toCell->GetAbsPos() : wxDefaultPosition; | |
63 | if ( toCell ) | |
64 | { | |
afcc5de1 VS |
65 | p2.x += toCell->GetWidth(); |
66 | p2.y += toCell->GetHeight(); | |
e3774124 VS |
67 | } |
68 | Set(p1, fromCell, p2, toCell); | |
69 | } | |
5526e819 | 70 | |
fc7a2a60 VZ |
71 | wxColour |
72 | wxDefaultHtmlRenderingStyle:: | |
73 | GetSelectedTextColour(const wxColour& WXUNUSED(clr)) | |
f30e67db VS |
74 | { |
75 | return wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT); | |
76 | } | |
77 | ||
fc7a2a60 VZ |
78 | wxColour |
79 | wxDefaultHtmlRenderingStyle:: | |
80 | GetSelectedTextBgColour(const wxColour& WXUNUSED(clr)) | |
f30e67db VS |
81 | { |
82 | return wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT); | |
83 | } | |
84 | ||
85 | ||
5526e819 VS |
86 | //----------------------------------------------------------------------------- |
87 | // wxHtmlCell | |
88 | //----------------------------------------------------------------------------- | |
89 | ||
4f44ea36 MB |
90 | IMPLEMENT_ABSTRACT_CLASS(wxHtmlCell, wxObject) |
91 | ||
04dbb646 | 92 | wxHtmlCell::wxHtmlCell() : wxObject() |
846914d1 | 93 | { |
04dbb646 VZ |
94 | m_Next = NULL; |
95 | m_Parent = NULL; | |
96 | m_Width = m_Height = m_Descent = 0; | |
49f6740f | 97 | m_CanLiveOnPagebreak = true; |
846914d1 VS |
98 | m_Link = NULL; |
99 | } | |
100 | ||
04dbb646 | 101 | wxHtmlCell::~wxHtmlCell() |
846914d1 | 102 | { |
0cb9cfb2 | 103 | delete m_Link; |
846914d1 VS |
104 | } |
105 | ||
5526e819 | 106 | |
04dbb646 | 107 | void wxHtmlCell::OnMouseClick(wxWindow *parent, int x, int y, |
0b2dadd3 | 108 | const wxMouseEvent& event) |
5526e819 | 109 | { |
846914d1 VS |
110 | wxHtmlLinkInfo *lnk = GetLink(x, y); |
111 | if (lnk != NULL) | |
0b2dadd3 VS |
112 | { |
113 | wxHtmlLinkInfo lnk2(*lnk); | |
114 | lnk2.SetEvent(&event); | |
9bc8fded | 115 | lnk2.SetHtmlCell(this); |
0cb9cfb2 VZ |
116 | |
117 | // note : this cast is legal because parent is *always* wxHtmlWindow | |
118 | wxStaticCast(parent, wxHtmlWindow)->OnLinkClicked(lnk2); | |
0b2dadd3 | 119 | } |
5526e819 VS |
120 | } |
121 | ||
122 | ||
77bae5e2 VS |
123 | wxCursor wxHtmlCell::GetCursor() const |
124 | { | |
125 | if ( GetLink() ) | |
126 | { | |
127 | if ( !gs_cursorLink ) | |
128 | gs_cursorLink = new wxCursor(wxCURSOR_HAND); | |
129 | return *gs_cursorLink; | |
130 | } | |
131 | else | |
132 | return *wxSTANDARD_CURSOR; | |
133 | } | |
134 | ||
5526e819 | 135 | |
f2034f1b | 136 | bool wxHtmlCell::AdjustPagebreak(int *pagebreak, int* WXUNUSED(known_pagebreaks), int WXUNUSED(number_of_pages)) const |
db98870d | 137 | { |
04dbb646 VZ |
138 | if ((!m_CanLiveOnPagebreak) && |
139 | m_PosY < *pagebreak && m_PosY + m_Height > *pagebreak) | |
0cb9cfb2 | 140 | { |
db98870d | 141 | *pagebreak = m_PosY; |
49f6740f | 142 | return true; |
db98870d | 143 | } |
0cb9cfb2 | 144 | |
49f6740f | 145 | return false; |
db98870d VS |
146 | } |
147 | ||
148 | ||
149 | ||
04dbb646 | 150 | void wxHtmlCell::SetLink(const wxHtmlLinkInfo& link) |
846914d1 VS |
151 | { |
152 | if (m_Link) delete m_Link; | |
af1ed0c1 VS |
153 | m_Link = NULL; |
154 | if (link.GetHref() != wxEmptyString) | |
155 | m_Link = new wxHtmlLinkInfo(link); | |
846914d1 VS |
156 | } |
157 | ||
158 | ||
d699f48b | 159 | void wxHtmlCell::Layout(int WXUNUSED(w)) |
721ab905 | 160 | { |
04dbb646 | 161 | SetPos(0, 0); |
721ab905 VS |
162 | } |
163 | ||
164 | ||
79d6c018 | 165 | |
d699f48b | 166 | const wxHtmlCell* wxHtmlCell::Find(int WXUNUSED(condition), const void* WXUNUSED(param)) const |
721ab905 | 167 | { |
bf7d7ee7 | 168 | return NULL; |
721ab905 VS |
169 | } |
170 | ||
171 | ||
36c4ff4d VS |
172 | wxHtmlCell *wxHtmlCell::FindCellByPos(wxCoord x, wxCoord y, |
173 | unsigned flags) const | |
f6010d8f | 174 | { |
adf2eb2d | 175 | if ( x >= 0 && x < m_Width && y >= 0 && y < m_Height ) |
36c4ff4d | 176 | { |
f6010d8f | 177 | return wxConstCast(this, wxHtmlCell); |
36c4ff4d | 178 | } |
adf2eb2d VS |
179 | else |
180 | { | |
181 | if ((flags & wxHTML_FIND_NEAREST_AFTER) && | |
03693319 | 182 | (y < 0 || (y < 0+m_Height && x < 0+m_Width))) |
adf2eb2d VS |
183 | return wxConstCast(this, wxHtmlCell); |
184 | else if ((flags & wxHTML_FIND_NEAREST_BEFORE) && | |
03693319 | 185 | (y >= 0+m_Height || (y >= 0 && x >= 0))) |
adf2eb2d VS |
186 | return wxConstCast(this, wxHtmlCell); |
187 | else | |
188 | return NULL; | |
189 | } | |
190 | } | |
191 | ||
192 | ||
193 | wxPoint wxHtmlCell::GetAbsPos() const | |
194 | { | |
195 | wxPoint p(m_PosX, m_PosY); | |
196 | for (wxHtmlCell *parent = m_Parent; parent; parent = parent->m_Parent) | |
197 | { | |
198 | p.x += parent->m_PosX; | |
199 | p.y += parent->m_PosY; | |
200 | } | |
201 | return p; | |
f6010d8f | 202 | } |
86ff9b45 | 203 | |
e3774124 VS |
204 | unsigned wxHtmlCell::GetDepth() const |
205 | { | |
206 | unsigned d = 0; | |
207 | for (wxHtmlCell *p = m_Parent; p; p = p->m_Parent) | |
208 | d++; | |
209 | return d; | |
210 | } | |
86ff9b45 | 211 | |
e3774124 VS |
212 | bool wxHtmlCell::IsBefore(wxHtmlCell *cell) const |
213 | { | |
214 | const wxHtmlCell *c1 = this; | |
215 | const wxHtmlCell *c2 = cell; | |
216 | unsigned d1 = GetDepth(); | |
217 | unsigned d2 = cell->GetDepth(); | |
218 | ||
219 | if ( d1 > d2 ) | |
220 | for (; d1 != d2; d1-- ) | |
221 | c1 = c1->m_Parent; | |
222 | else if ( d1 < d2 ) | |
223 | for (; d1 != d2; d2-- ) | |
224 | c2 = c2->m_Parent; | |
225 | ||
226 | if ( cell == this ) | |
227 | return true; | |
228 | ||
229 | while ( c1 && c2 ) | |
230 | { | |
231 | if ( c1->m_Parent == c2->m_Parent ) | |
232 | { | |
233 | while ( c1 ) | |
234 | { | |
235 | if ( c1 == c2 ) | |
236 | return true; | |
237 | c1 = c1->GetNext(); | |
86ff9b45 | 238 | } |
e3774124 VS |
239 | return false; |
240 | } | |
241 | else | |
242 | { | |
243 | c1 = c1->m_Parent; | |
244 | c2 = c2->m_Parent; | |
245 | } | |
246 | } | |
247 | ||
248 | wxFAIL_MSG(_T("Cells are in different trees")); | |
249 | return false; | |
250 | } | |
f6010d8f | 251 | |
721ab905 | 252 | |
5526e819 VS |
253 | //----------------------------------------------------------------------------- |
254 | // wxHtmlWordCell | |
255 | //----------------------------------------------------------------------------- | |
256 | ||
4f44ea36 MB |
257 | IMPLEMENT_ABSTRACT_CLASS(wxHtmlWordCell, wxHtmlCell) |
258 | ||
5526e819 VS |
259 | wxHtmlWordCell::wxHtmlWordCell(const wxString& word, wxDC& dc) : wxHtmlCell() |
260 | { | |
261 | m_Word = word; | |
5526e819 | 262 | dc.GetTextExtent(m_Word, &m_Width, &m_Height, &m_Descent); |
49f6740f | 263 | SetCanLiveOnPagebreak(false); |
b6d93b26 | 264 | m_allowLinebreak = true; |
5526e819 VS |
265 | } |
266 | ||
b6d93b26 VS |
267 | void wxHtmlWordCell::SetPreviousWord(wxHtmlWordCell *cell) |
268 | { | |
269 | if ( cell && m_Parent == cell->m_Parent && | |
270 | !wxIsspace(cell->m_Word.Last()) && !wxIsspace(m_Word[0u]) ) | |
271 | { | |
272 | m_allowLinebreak = false; | |
273 | } | |
274 | } | |
5526e819 | 275 | |
5a1597e9 VS |
276 | // Splits m_Word into up to three parts according to selection, returns |
277 | // substring before, in and after selection and the points (in relative coords) | |
278 | // where s2 and s3 start: | |
1338c59a | 279 | void wxHtmlWordCell::Split(wxDC& dc, |
5a1597e9 | 280 | const wxPoint& selFrom, const wxPoint& selTo, |
f30e67db | 281 | unsigned& pos1, unsigned& pos2) const |
5a1597e9 VS |
282 | { |
283 | wxPoint pt1 = (selFrom == wxDefaultPosition) ? | |
284 | wxDefaultPosition : selFrom - GetAbsPos(); | |
285 | wxPoint pt2 = (selTo == wxDefaultPosition) ? | |
422d0ff0 | 286 | wxPoint(m_Width, wxDefaultCoord) : selTo - GetAbsPos(); |
5a1597e9 | 287 | |
5a1597e9 VS |
288 | unsigned len = m_Word.length(); |
289 | unsigned i = 0; | |
290 | pos1 = 0; | |
5a1597e9 | 291 | |
03693319 VS |
292 | // adjust for cases when the start/end position is completely |
293 | // outside the cell: | |
294 | if ( pt1.y < 0 ) | |
295 | pt1.x = 0; | |
296 | if ( pt2.y >= m_Height ) | |
297 | pt2.x = m_Width; | |
95af070a VZ |
298 | |
299 | // before selection: | |
300 | #ifdef __WXMAC__ | |
89e94a4b SC |
301 | // implementation using PartialExtents to support fractional widths |
302 | wxArrayInt widths ; | |
303 | dc.GetPartialTextExtents(m_Word,widths) ; | |
89e94a4b SC |
304 | while( i < len && pt1.x >= widths[i] ) |
305 | i++ ; | |
95af070a VZ |
306 | #else // __WXMAC__ |
307 | wxCoord charW, charH; | |
5a1597e9 VS |
308 | while ( pt1.x > 0 && i < len ) |
309 | { | |
310 | dc.GetTextExtent(m_Word[i], &charW, &charH); | |
311 | pt1.x -= charW; | |
312 | if ( pt1.x >= 0 ) | |
313 | { | |
314 | pos1 += charW; | |
315 | i++; | |
316 | } | |
317 | } | |
95af070a | 318 | #endif // __WXMAC__/!__WXMAC__ |
5526e819 | 319 | |
5a1597e9 VS |
320 | // in selection: |
321 | unsigned j = i; | |
95af070a | 322 | #ifdef __WXMAC__ |
89e94a4b SC |
323 | while( j < len && pt2.x >= widths[j] ) |
324 | j++ ; | |
95af070a | 325 | #else // __WXMAC__ |
5a1597e9 | 326 | pos2 = pos1; |
f30e67db | 327 | pt2.x -= pos2; |
5a1597e9 VS |
328 | while ( pt2.x > 0 && j < len ) |
329 | { | |
330 | dc.GetTextExtent(m_Word[j], &charW, &charH); | |
331 | pt2.x -= charW; | |
332 | if ( pt2.x >= 0 ) | |
333 | { | |
334 | pos2 += charW; | |
335 | j++; | |
336 | } | |
337 | } | |
95af070a | 338 | #endif // __WXMAC__/!__WXMAC__ |
f30e67db VS |
339 | |
340 | pos1 = i; | |
341 | pos2 = j; | |
342 | } | |
343 | ||
344 | void wxHtmlWordCell::SetSelectionPrivPos(wxDC& dc, wxHtmlSelection *s) const | |
345 | { | |
346 | unsigned p1, p2; | |
86ff9b45 VZ |
347 | |
348 | Split(dc, | |
f30e67db VS |
349 | this == s->GetFromCell() ? s->GetFromPos() : wxDefaultPosition, |
350 | this == s->GetToCell() ? s->GetToPos() : wxDefaultPosition, | |
351 | p1, p2); | |
352 | ||
353 | wxPoint p(0, m_Word.length()); | |
86ff9b45 | 354 | |
f30e67db VS |
355 | if ( this == s->GetFromCell() ) |
356 | p.x = p1; // selection starts here | |
357 | if ( this == s->GetToCell() ) | |
358 | p.y = p2; // selection ends here | |
86ff9b45 | 359 | |
f30e67db VS |
360 | if ( this == s->GetFromCell() ) |
361 | s->SetFromPrivPos(p); | |
362 | if ( this == s->GetToCell() ) | |
363 | s->SetToPrivPos(p); | |
5a1597e9 VS |
364 | } |
365 | ||
366 | ||
f30e67db | 367 | static void SwitchSelState(wxDC& dc, wxHtmlRenderingInfo& info, |
5a1597e9 | 368 | bool toSelection) |
5526e819 | 369 | { |
f30e67db VS |
370 | wxColour fg = info.GetState().GetFgColour(); |
371 | wxColour bg = info.GetState().GetBgColour(); | |
86ff9b45 | 372 | |
5a1597e9 | 373 | if ( toSelection ) |
36c4ff4d VS |
374 | { |
375 | dc.SetBackgroundMode(wxSOLID); | |
f30e67db VS |
376 | dc.SetTextForeground(info.GetStyle().GetSelectedTextColour(fg)); |
377 | dc.SetTextBackground(info.GetStyle().GetSelectedTextBgColour(bg)); | |
b87dd6f5 VS |
378 | dc.SetBackground(wxBrush(info.GetStyle().GetSelectedTextBgColour(bg), |
379 | wxSOLID)); | |
36c4ff4d | 380 | } |
5a1597e9 | 381 | else |
36c4ff4d VS |
382 | { |
383 | dc.SetBackgroundMode(wxTRANSPARENT); | |
f30e67db VS |
384 | dc.SetTextForeground(fg); |
385 | dc.SetTextBackground(bg); | |
b87dd6f5 | 386 | dc.SetBackground(wxBrush(bg, wxSOLID)); |
36c4ff4d | 387 | } |
5a1597e9 | 388 | } |
36c4ff4d | 389 | |
5a1597e9 VS |
390 | |
391 | void wxHtmlWordCell::Draw(wxDC& dc, int x, int y, | |
2a2e4f4a | 392 | int WXUNUSED(view_y1), int WXUNUSED(view_y2), |
f30e67db | 393 | wxHtmlRenderingInfo& info) |
5a1597e9 VS |
394 | { |
395 | #if 0 // useful for debugging | |
ace0fab4 | 396 | dc.SetPen(*wxBLACK_PEN); |
4dd9ae57 | 397 | dc.DrawRectangle(x+m_PosX,y+m_PosY,m_Width /* VZ: +1? */ ,m_Height); |
5a1597e9 VS |
398 | #endif |
399 | ||
b87dd6f5 | 400 | bool drawSelectionAfterCell = false; |
d1da8872 | 401 | |
f30e67db | 402 | if ( info.GetState().GetSelectionState() == wxHTML_SEL_CHANGING ) |
5a1597e9 VS |
403 | { |
404 | // Selection changing, we must draw the word piecewise: | |
f30e67db VS |
405 | wxHtmlSelection *s = info.GetSelection(); |
406 | wxString txt; | |
407 | int w, h; | |
408 | int ofs = 0; | |
86ff9b45 VZ |
409 | |
410 | wxPoint priv = (this == s->GetFromCell()) ? | |
f30e67db | 411 | s->GetFromPrivPos() : s->GetToPrivPos(); |
1338c59a VS |
412 | |
413 | // NB: this is quite a hack: in order to compute selection boundaries | |
414 | // (in word's characters) we must know current font, which is only | |
415 | // possible inside rendering code. Therefore we update the | |
416 | // information here and store it in wxHtmlSelection so that | |
417 | // ConvertToText can use it later: | |
418 | if ( priv == wxDefaultPosition ) | |
419 | { | |
420 | SetSelectionPrivPos(dc, s); | |
86ff9b45 | 421 | priv = (this == s->GetFromCell()) ? |
1338c59a VS |
422 | s->GetFromPrivPos() : s->GetToPrivPos(); |
423 | } | |
86ff9b45 | 424 | |
f30e67db VS |
425 | int part1 = priv.x; |
426 | int part2 = priv.y; | |
427 | ||
428 | if ( part1 > 0 ) | |
5a1597e9 | 429 | { |
f30e67db VS |
430 | txt = m_Word.Mid(0, part1); |
431 | dc.DrawText(txt, x + m_PosX, y + m_PosY); | |
432 | dc.GetTextExtent(txt, &w, &h); | |
433 | ofs += w; | |
5a1597e9 | 434 | } |
86ff9b45 | 435 | |
f30e67db | 436 | SwitchSelState(dc, info, true); |
86ff9b45 | 437 | |
f30e67db VS |
438 | txt = m_Word.Mid(part1, part2-part1); |
439 | dc.DrawText(txt, ofs + x + m_PosX, y + m_PosY); | |
440 | ||
70bae016 | 441 | if ( (size_t)part2 < m_Word.length() ) |
5a1597e9 | 442 | { |
f30e67db VS |
443 | dc.GetTextExtent(txt, &w, &h); |
444 | ofs += w; | |
445 | SwitchSelState(dc, info, false); | |
446 | txt = m_Word.Mid(part2); | |
447 | dc.DrawText(txt, ofs + x + m_PosX, y + m_PosY); | |
5a1597e9 | 448 | } |
b87dd6f5 VS |
449 | else |
450 | drawSelectionAfterCell = true; | |
5a1597e9 VS |
451 | } |
452 | else | |
453 | { | |
b87dd6f5 | 454 | wxHtmlSelectionState selstate = info.GetState().GetSelectionState(); |
5a1597e9 | 455 | // Not changing selection state, draw the word in single mode: |
b87dd6f5 | 456 | if ( selstate != wxHTML_SEL_OUT && |
5a1597e9 VS |
457 | dc.GetBackgroundMode() != wxSOLID ) |
458 | { | |
f30e67db | 459 | SwitchSelState(dc, info, true); |
5a1597e9 | 460 | } |
b87dd6f5 | 461 | else if ( selstate == wxHTML_SEL_OUT && |
5a1597e9 VS |
462 | dc.GetBackgroundMode() == wxSOLID ) |
463 | { | |
f30e67db | 464 | SwitchSelState(dc, info, false); |
5a1597e9 VS |
465 | } |
466 | dc.DrawText(m_Word, x + m_PosX, y + m_PosY); | |
b87dd6f5 VS |
467 | drawSelectionAfterCell = (selstate != wxHTML_SEL_OUT); |
468 | } | |
469 | ||
470 | // NB: If the text is justified then there is usually some free space | |
471 | // between adjacent cells and drawing the selection only onto cells | |
472 | // would result in ugly unselected spaces. The code below detects | |
473 | // this special case and renders the selection *outside* the sell, | |
474 | // too. | |
475 | if ( m_Parent->GetAlignHor() == wxHTML_ALIGN_JUSTIFY && | |
476 | drawSelectionAfterCell ) | |
477 | { | |
478 | wxHtmlCell *nextCell = m_Next; | |
479 | while ( nextCell && nextCell->IsFormattingCell() ) | |
480 | nextCell = nextCell->GetNext(); | |
481 | if ( nextCell ) | |
482 | { | |
483 | int nextX = nextCell->GetPosX(); | |
484 | if ( m_PosX + m_Width < nextX ) | |
485 | { | |
486 | dc.SetBrush(dc.GetBackground()); | |
487 | dc.SetPen(*wxTRANSPARENT_PEN); | |
488 | dc.DrawRectangle(x + m_PosX + m_Width, y + m_PosY, | |
489 | nextX - m_PosX - m_Width, m_Height); | |
490 | } | |
491 | } | |
5a1597e9 | 492 | } |
5526e819 | 493 | } |
86ff9b45 | 494 | |
e3774124 | 495 | |
f30e67db | 496 | wxString wxHtmlWordCell::ConvertToText(wxHtmlSelection *s) const |
e3774124 | 497 | { |
f30e67db VS |
498 | if ( s && (this == s->GetFromCell() || this == s->GetToCell()) ) |
499 | { | |
86ff9b45 VZ |
500 | wxPoint priv = this == s->GetFromCell() ? s->GetFromPrivPos() |
501 | : s->GetToPrivPos(); | |
502 | ||
503 | // VZ: we may be called before we had a chance to re-render ourselves | |
504 | // and in this case GetFrom/ToPrivPos() is not set yet -- assume | |
505 | // that this only happens in case of a double/triple click (which | |
506 | // seems to be the case now) and so it makes sense to select the | |
507 | // entire contents of the cell in this case | |
508 | // | |
509 | // TODO: but this really needs to be fixed in some better way later... | |
510 | if ( priv != wxDefaultPosition ) | |
511 | { | |
512 | int part1 = priv.x; | |
513 | int part2 = priv.y; | |
514 | return m_Word.Mid(part1, part2-part1); | |
515 | } | |
516 | //else: return the whole word below | |
f30e67db | 517 | } |
86ff9b45 VZ |
518 | |
519 | return m_Word; | |
e3774124 | 520 | } |
5526e819 | 521 | |
77bae5e2 VS |
522 | wxCursor wxHtmlWordCell::GetCursor() const |
523 | { | |
524 | if ( !GetLink() ) | |
525 | { | |
526 | if ( !gs_cursorText ) | |
527 | gs_cursorText = new wxCursor(wxCURSOR_IBEAM); | |
528 | return *gs_cursorText; | |
529 | } | |
530 | else | |
531 | return wxHtmlCell::GetCursor(); | |
532 | } | |
533 | ||
5526e819 | 534 | |
5526e819 VS |
535 | //----------------------------------------------------------------------------- |
536 | // wxHtmlContainerCell | |
537 | //----------------------------------------------------------------------------- | |
538 | ||
4f44ea36 | 539 | IMPLEMENT_ABSTRACT_CLASS(wxHtmlContainerCell, wxHtmlCell) |
5526e819 VS |
540 | |
541 | wxHtmlContainerCell::wxHtmlContainerCell(wxHtmlContainerCell *parent) : wxHtmlCell() | |
542 | { | |
543 | m_Cells = m_LastCell = NULL; | |
544 | m_Parent = parent; | |
ca16b7a9 | 545 | m_MaxTotalWidth = 0; |
4f9297b0 | 546 | if (m_Parent) m_Parent->InsertCell(this); |
efba2b89 VS |
547 | m_AlignHor = wxHTML_ALIGN_LEFT; |
548 | m_AlignVer = wxHTML_ALIGN_BOTTOM; | |
5526e819 | 549 | m_IndentLeft = m_IndentRight = m_IndentTop = m_IndentBottom = 0; |
efba2b89 | 550 | m_WidthFloat = 100; m_WidthFloatUnits = wxHTML_UNITS_PERCENT; |
49f6740f WS |
551 | m_UseBkColour = false; |
552 | m_UseBorder = false; | |
5c1bfc5d | 553 | m_MinHeight = 0; |
efba2b89 | 554 | m_MinHeightAlign = wxHTML_ALIGN_TOP; |
5660c520 | 555 | m_LastLayout = -1; |
5526e819 VS |
556 | } |
557 | ||
04dbb646 | 558 | wxHtmlContainerCell::~wxHtmlContainerCell() |
721ab905 | 559 | { |
491c9920 VZ |
560 | wxHtmlCell *cell = m_Cells; |
561 | while ( cell ) | |
bf7d7ee7 | 562 | { |
491c9920 VZ |
563 | wxHtmlCell *cellNext = cell->GetNext(); |
564 | delete cell; | |
565 | cell = cellNext; | |
bf7d7ee7 | 566 | } |
721ab905 VS |
567 | } |
568 | ||
5526e819 VS |
569 | |
570 | ||
571 | void wxHtmlContainerCell::SetIndent(int i, int what, int units) | |
572 | { | |
efba2b89 VS |
573 | int val = (units == wxHTML_UNITS_PIXELS) ? i : -i; |
574 | if (what & wxHTML_INDENT_LEFT) m_IndentLeft = val; | |
575 | if (what & wxHTML_INDENT_RIGHT) m_IndentRight = val; | |
576 | if (what & wxHTML_INDENT_TOP) m_IndentTop = val; | |
577 | if (what & wxHTML_INDENT_BOTTOM) m_IndentBottom = val; | |
5660c520 | 578 | m_LastLayout = -1; |
5526e819 VS |
579 | } |
580 | ||
581 | ||
582 | ||
583 | int wxHtmlContainerCell::GetIndent(int ind) const | |
584 | { | |
efba2b89 VS |
585 | if (ind & wxHTML_INDENT_LEFT) return m_IndentLeft; |
586 | else if (ind & wxHTML_INDENT_RIGHT) return m_IndentRight; | |
587 | else if (ind & wxHTML_INDENT_TOP) return m_IndentTop; | |
588 | else if (ind & wxHTML_INDENT_BOTTOM) return m_IndentBottom; | |
5526e819 VS |
589 | else return -1; /* BUG! Should not be called... */ |
590 | } | |
591 | ||
592 | ||
593 | ||
594 | ||
595 | int wxHtmlContainerCell::GetIndentUnits(int ind) const | |
596 | { | |
49f6740f | 597 | bool p = false; |
efba2b89 VS |
598 | if (ind & wxHTML_INDENT_LEFT) p = m_IndentLeft < 0; |
599 | else if (ind & wxHTML_INDENT_RIGHT) p = m_IndentRight < 0; | |
600 | else if (ind & wxHTML_INDENT_TOP) p = m_IndentTop < 0; | |
601 | else if (ind & wxHTML_INDENT_BOTTOM) p = m_IndentBottom < 0; | |
602 | if (p) return wxHTML_UNITS_PERCENT; | |
603 | else return wxHTML_UNITS_PIXELS; | |
5526e819 VS |
604 | } |
605 | ||
606 | ||
607 | ||
f2034f1b | 608 | bool wxHtmlContainerCell::AdjustPagebreak(int *pagebreak, int* known_pagebreaks, int number_of_pages) const |
db98870d | 609 | { |
04dbb646 | 610 | if (!m_CanLiveOnPagebreak) |
f2034f1b | 611 | return wxHtmlCell::AdjustPagebreak(pagebreak, known_pagebreaks, number_of_pages); |
e52d6dbc | 612 | |
04dbb646 | 613 | else |
4f9297b0 | 614 | { |
e3774124 | 615 | wxHtmlCell *c = GetFirstChild(); |
49f6740f | 616 | bool rt = false; |
e52d6dbc | 617 | int pbrk = *pagebreak - m_PosY; |
db98870d | 618 | |
04dbb646 | 619 | while (c) |
0cb9cfb2 | 620 | { |
f2034f1b | 621 | if (c->AdjustPagebreak(&pbrk, known_pagebreaks, number_of_pages)) |
49f6740f | 622 | rt = true; |
4f9297b0 | 623 | c = c->GetNext(); |
db98870d | 624 | } |
d699f48b | 625 | if (rt) |
bf7d7ee7 | 626 | *pagebreak = pbrk + m_PosY; |
db98870d VS |
627 | return rt; |
628 | } | |
629 | } | |
630 | ||
631 | ||
632 | ||
5526e819 VS |
633 | void wxHtmlContainerCell::Layout(int w) |
634 | { | |
026d1fac VS |
635 | wxHtmlCell::Layout(w); |
636 | ||
637 | if (m_LastLayout == w) return; | |
0cb9cfb2 | 638 | |
026d1fac VS |
639 | // VS: Any attempt to layout with negative or zero width leads to hell, |
640 | // but we can't ignore such attempts completely, since it sometimes | |
641 | // happen (e.g. when trying how small a table can be). The best thing we | |
642 | // can do is to set the width of child cells to zero | |
0cb9cfb2 | 643 | if (w < 1) |
4f9297b0 | 644 | { |
026d1fac VS |
645 | m_Width = 0; |
646 | for (wxHtmlCell *cell = m_Cells; cell; cell = cell->GetNext()) | |
647 | cell->Layout(0); | |
2b5f62a0 VZ |
648 | // this does two things: it recursively calls this code on all |
649 | // child contrainers and resets children's position to (0,0) | |
026d1fac | 650 | return; |
04dbb646 | 651 | } |
5660c520 | 652 | |
a1ae1090 VZ |
653 | wxHtmlCell *cell = m_Cells, |
654 | *line = m_Cells; | |
b6d93b26 | 655 | wxHtmlCell *nextCell; |
5526e819 VS |
656 | long xpos = 0, ypos = m_IndentTop; |
657 | int xdelta = 0, ybasicpos = 0, ydiff; | |
b6d93b26 | 658 | int s_width, nextWordWidth, s_indent; |
5526e819 | 659 | int ysizeup = 0, ysizedown = 0; |
5c1bfc5d | 660 | int MaxLineWidth = 0; |
ca16b7a9 VS |
661 | int curLineWidth = 0; |
662 | m_MaxTotalWidth = 0; | |
5c1bfc5d | 663 | |
5526e819 VS |
664 | |
665 | /* | |
7e941458 | 666 | |
5526e819 | 667 | WIDTH ADJUSTING : |
7e941458 | 668 | |
5526e819 VS |
669 | */ |
670 | ||
04dbb646 | 671 | if (m_WidthFloatUnits == wxHTML_UNITS_PERCENT) |
4f9297b0 | 672 | { |
5526e819 VS |
673 | if (m_WidthFloat < 0) m_Width = (100 + m_WidthFloat) * w / 100; |
674 | else m_Width = m_WidthFloat * w / 100; | |
675 | } | |
04dbb646 | 676 | else |
4f9297b0 | 677 | { |
5526e819 VS |
678 | if (m_WidthFloat < 0) m_Width = w + m_WidthFloat; |
679 | else m_Width = m_WidthFloat; | |
680 | } | |
681 | ||
04dbb646 | 682 | if (m_Cells) |
4f9297b0 | 683 | { |
5526e819 VS |
684 | int l = (m_IndentLeft < 0) ? (-m_IndentLeft * m_Width / 100) : m_IndentLeft; |
685 | int r = (m_IndentRight < 0) ? (-m_IndentRight * m_Width / 100) : m_IndentRight; | |
bf7d7ee7 VS |
686 | for (wxHtmlCell *cell = m_Cells; cell; cell = cell->GetNext()) |
687 | cell->Layout(m_Width - (l + r)); | |
5526e819 VS |
688 | } |
689 | ||
690 | /* | |
691 | ||
692 | LAYOUTING : | |
7e941458 | 693 | |
5526e819 VS |
694 | */ |
695 | ||
696 | // adjust indentation: | |
697 | s_indent = (m_IndentLeft < 0) ? (-m_IndentLeft * m_Width / 100) : m_IndentLeft; | |
698 | s_width = m_Width - s_indent - ((m_IndentRight < 0) ? (-m_IndentRight * m_Width / 100) : m_IndentRight); | |
699 | ||
5526e819 | 700 | // my own layouting: |
04dbb646 | 701 | while (cell != NULL) |
4f9297b0 | 702 | { |
04dbb646 | 703 | switch (m_AlignVer) |
0cb9cfb2 | 704 | { |
efba2b89 | 705 | case wxHTML_ALIGN_TOP : ybasicpos = 0; break; |
4f9297b0 VS |
706 | case wxHTML_ALIGN_BOTTOM : ybasicpos = - cell->GetHeight(); break; |
707 | case wxHTML_ALIGN_CENTER : ybasicpos = - cell->GetHeight() / 2; break; | |
5526e819 | 708 | } |
4f9297b0 | 709 | ydiff = cell->GetHeight() + ybasicpos; |
5526e819 | 710 | |
4f9297b0 VS |
711 | if (cell->GetDescent() + ydiff > ysizedown) ysizedown = cell->GetDescent() + ydiff; |
712 | if (ybasicpos + cell->GetDescent() < -ysizeup) ysizeup = - (ybasicpos + cell->GetDescent()); | |
5526e819 | 713 | |
b6d93b26 | 714 | // layout nonbreakable run of cells: |
4f9297b0 VS |
715 | cell->SetPos(xpos, ybasicpos + cell->GetDescent()); |
716 | xpos += cell->GetWidth(); | |
ca16b7a9 VS |
717 | if (!cell->IsTerminalCell()) |
718 | { | |
719 | // Container cell indicates new line | |
720 | if (curLineWidth > m_MaxTotalWidth) | |
721 | m_MaxTotalWidth = curLineWidth; | |
722 | ||
723 | if (wxMax(cell->GetWidth(), cell->GetMaxTotalWidth()) > m_MaxTotalWidth) | |
724 | m_MaxTotalWidth = cell->GetMaxTotalWidth(); | |
725 | curLineWidth = 0; | |
726 | } | |
727 | else | |
728 | // Normal cell, add maximum cell width to line width | |
729 | curLineWidth += cell->GetMaxTotalWidth(); | |
730 | ||
4f9297b0 | 731 | cell = cell->GetNext(); |
d1da8872 | 732 | |
b6d93b26 VS |
733 | // compute length of the next word that would be added: |
734 | nextWordWidth = 0; | |
735 | if (cell) | |
736 | { | |
737 | nextCell = cell; | |
738 | do | |
739 | { | |
740 | nextWordWidth += nextCell->GetWidth(); | |
741 | nextCell = nextCell->GetNext(); | |
742 | } while (nextCell && !nextCell->IsLinebreakAllowed()); | |
743 | } | |
d1da8872 | 744 | |
3103e8a9 | 745 | // force new line if occurred: |
d1da8872 | 746 | if ((cell == NULL) || |
b6d93b26 | 747 | (xpos + nextWordWidth > s_width && cell->IsLinebreakAllowed())) |
0cb9cfb2 | 748 | { |
5c1bfc5d | 749 | if (xpos > MaxLineWidth) MaxLineWidth = xpos; |
5526e819 VS |
750 | if (ysizeup < 0) ysizeup = 0; |
751 | if (ysizedown < 0) ysizedown = 0; | |
752 | switch (m_AlignHor) { | |
04dbb646 VZ |
753 | case wxHTML_ALIGN_LEFT : |
754 | case wxHTML_ALIGN_JUSTIFY : | |
755 | xdelta = 0; | |
5c1bfc5d | 756 | break; |
04dbb646 VZ |
757 | case wxHTML_ALIGN_RIGHT : |
758 | xdelta = 0 + (s_width - xpos); | |
5c1bfc5d | 759 | break; |
04dbb646 VZ |
760 | case wxHTML_ALIGN_CENTER : |
761 | xdelta = 0 + (s_width - xpos) / 2; | |
5c1bfc5d | 762 | break; |
5526e819 VS |
763 | } |
764 | if (xdelta < 0) xdelta = 0; | |
765 | xdelta += s_indent; | |
766 | ||
767 | ypos += ysizeup; | |
04dbb646 | 768 | |
5c1bfc5d | 769 | if (m_AlignHor != wxHTML_ALIGN_JUSTIFY || cell == NULL) |
a1ae1090 | 770 | { |
04dbb646 | 771 | while (line != cell) |
0cb9cfb2 | 772 | { |
04dbb646 | 773 | line->SetPos(line->GetPosX() + xdelta, |
4f9297b0 VS |
774 | ypos + line->GetPosY()); |
775 | line = line->GetNext(); | |
5c1bfc5d | 776 | } |
a1ae1090 VZ |
777 | } |
778 | else // align == justify | |
04dbb646 | 779 | { |
a1ae1090 VZ |
780 | // we have to distribute the extra horz space between the cells |
781 | // on this line | |
782 | ||
783 | // an added complication is that some cells have fixed size and | |
784 | // shouldn't get any increment (it so happens that these cells | |
785 | // also don't allow line break on them which provides with an | |
4dd9ae57 VZ |
786 | // easy way to test for this) -- and neither should the cells |
787 | // adjacent to them as this could result in a visible space | |
788 | // between two cells separated by, e.g. font change, cell which | |
789 | // is wrong | |
a1ae1090 | 790 | |
2d1d813e | 791 | int step = s_width - xpos; |
a1ae1090 | 792 | if ( step > 0 ) |
0cb9cfb2 | 793 | { |
a1ae1090 VZ |
794 | // first count the cells which will get extra space |
795 | int total = 0; | |
4dd9ae57 | 796 | |
1c0ee565 VS |
797 | const wxHtmlCell *c; |
798 | if ( line != cell ) | |
a1ae1090 | 799 | { |
1c0ee565 | 800 | for ( c = line->GetNext(); c != cell; c = c->GetNext() ) |
4dd9ae57 | 801 | { |
1c0ee565 VS |
802 | if ( c->IsLinebreakAllowed() ) |
803 | { | |
804 | total++; | |
805 | } | |
4dd9ae57 | 806 | } |
a1ae1090 VZ |
807 | } |
808 | ||
809 | // and now extra space to those cells which merit it | |
810 | if ( total ) | |
811 | { | |
1c0ee565 VS |
812 | // first cell on line is not moved: |
813 | line->SetPos(line->GetPosX() + s_indent, | |
814 | line->GetPosY() + ypos); | |
d1da8872 | 815 | |
1c0ee565 VS |
816 | line = line->GetNext(); |
817 | for ( int n = 0; line != cell; line = line->GetNext() ) | |
a1ae1090 | 818 | { |
1c0ee565 | 819 | if ( line->IsLinebreakAllowed() ) |
a1ae1090 VZ |
820 | { |
821 | // offset the next cell relative to this one | |
822 | // thus increasing our size | |
823 | n++; | |
824 | } | |
d1da8872 | 825 | |
1c0ee565 VS |
826 | line->SetPos(line->GetPosX() + s_indent + |
827 | ((n * step) / total), | |
828 | line->GetPosY() + ypos); | |
a1ae1090 VZ |
829 | } |
830 | } | |
2d1d813e VS |
831 | else |
832 | { | |
833 | // this will cause the code to enter "else branch" below: | |
834 | step = 0; | |
835 | } | |
a1ae1090 | 836 | } |
2d1d813e VS |
837 | // else branch: |
838 | if ( step <= 0 ) // no extra space to distribute | |
a1ae1090 VZ |
839 | { |
840 | // just set the indent properly | |
841 | while (line != cell) | |
842 | { | |
843 | line->SetPos(line->GetPosX() + s_indent, | |
844 | line->GetPosY() + ypos); | |
845 | line = line->GetNext(); | |
846 | } | |
5c1bfc5d | 847 | } |
5526e819 VS |
848 | } |
849 | ||
850 | ypos += ysizedown; | |
49f6740f | 851 | xpos = 0; |
5526e819 VS |
852 | ysizeup = ysizedown = 0; |
853 | line = cell; | |
854 | } | |
855 | } | |
856 | ||
857 | // setup height & width, depending on container layout: | |
858 | m_Height = ypos + (ysizedown + ysizeup) + m_IndentBottom; | |
859 | ||
04dbb646 | 860 | if (m_Height < m_MinHeight) |
4f9297b0 | 861 | { |
04dbb646 | 862 | if (m_MinHeightAlign != wxHTML_ALIGN_TOP) |
0cb9cfb2 | 863 | { |
5526e819 | 864 | int diff = m_MinHeight - m_Height; |
efba2b89 | 865 | if (m_MinHeightAlign == wxHTML_ALIGN_CENTER) diff /= 2; |
5526e819 | 866 | cell = m_Cells; |
04dbb646 | 867 | while (cell) |
0cb9cfb2 | 868 | { |
4f9297b0 VS |
869 | cell->SetPos(cell->GetPosX(), cell->GetPosY() + diff); |
870 | cell = cell->GetNext(); | |
5526e819 VS |
871 | } |
872 | } | |
873 | m_Height = m_MinHeight; | |
874 | } | |
875 | ||
ca16b7a9 VS |
876 | if (curLineWidth > m_MaxTotalWidth) |
877 | m_MaxTotalWidth = curLineWidth; | |
d1da8872 | 878 | |
ca16b7a9 | 879 | m_MaxTotalWidth += s_indent + ((m_IndentRight < 0) ? (-m_IndentRight * m_Width / 100) : m_IndentRight); |
5c1bfc5d VS |
880 | MaxLineWidth += s_indent + ((m_IndentRight < 0) ? (-m_IndentRight * m_Width / 100) : m_IndentRight); |
881 | if (m_Width < MaxLineWidth) m_Width = MaxLineWidth; | |
5526e819 | 882 | |
5660c520 | 883 | m_LastLayout = w; |
5526e819 VS |
884 | } |
885 | ||
f30e67db | 886 | void wxHtmlContainerCell::UpdateRenderingStatePre(wxHtmlRenderingInfo& info, |
36c4ff4d VS |
887 | wxHtmlCell *cell) const |
888 | { | |
f30e67db | 889 | wxHtmlSelection *s = info.GetSelection(); |
36c4ff4d | 890 | if (!s) return; |
cd275246 | 891 | if (s->GetFromCell() == cell || s->GetToCell() == cell) |
36c4ff4d | 892 | { |
f30e67db | 893 | info.GetState().SetSelectionState(wxHTML_SEL_CHANGING); |
36c4ff4d VS |
894 | } |
895 | } | |
896 | ||
f30e67db | 897 | void wxHtmlContainerCell::UpdateRenderingStatePost(wxHtmlRenderingInfo& info, |
36c4ff4d VS |
898 | wxHtmlCell *cell) const |
899 | { | |
f30e67db | 900 | wxHtmlSelection *s = info.GetSelection(); |
36c4ff4d | 901 | if (!s) return; |
adf2eb2d | 902 | if (s->GetToCell() == cell) |
f30e67db | 903 | info.GetState().SetSelectionState(wxHTML_SEL_OUT); |
adf2eb2d | 904 | else if (s->GetFromCell() == cell) |
f30e67db | 905 | info.GetState().SetSelectionState(wxHTML_SEL_IN); |
36c4ff4d | 906 | } |
5526e819 VS |
907 | |
908 | #define mMin(a, b) (((a) < (b)) ? (a) : (b)) | |
909 | #define mMax(a, b) (((a) < (b)) ? (b) : (a)) | |
910 | ||
36c4ff4d | 911 | void wxHtmlContainerCell::Draw(wxDC& dc, int x, int y, int view_y1, int view_y2, |
f30e67db | 912 | wxHtmlRenderingInfo& info) |
5526e819 | 913 | { |
ace0fab4 VS |
914 | #if 0 // useful for debugging |
915 | dc.SetPen(*wxRED_PEN); | |
916 | dc.DrawRectangle(x+m_PosX,y+m_PosY,m_Width,m_Height); | |
917 | #endif | |
95af070a | 918 | |
848c4eb2 VS |
919 | int xlocal = x + m_PosX; |
920 | int ylocal = y + m_PosY; | |
921 | ||
922 | if (m_UseBkColour) | |
4f9297b0 | 923 | { |
848c4eb2 | 924 | wxBrush myb = wxBrush(m_BkColour, wxSOLID); |
5526e819 | 925 | |
848c4eb2 VS |
926 | int real_y1 = mMax(ylocal, view_y1); |
927 | int real_y2 = mMin(ylocal + m_Height - 1, view_y2); | |
5526e819 | 928 | |
848c4eb2 VS |
929 | dc.SetBrush(myb); |
930 | dc.SetPen(*wxTRANSPARENT_PEN); | |
931 | dc.DrawRectangle(xlocal, real_y1, m_Width, real_y2 - real_y1 + 1); | |
932 | } | |
5526e819 | 933 | |
848c4eb2 VS |
934 | if (m_UseBorder) |
935 | { | |
936 | wxPen mypen1(m_BorderColour1, 1, wxSOLID); | |
937 | wxPen mypen2(m_BorderColour2, 1, wxSOLID); | |
938 | ||
939 | dc.SetPen(mypen1); | |
940 | dc.DrawLine(xlocal, ylocal, xlocal, ylocal + m_Height - 1); | |
941 | dc.DrawLine(xlocal, ylocal, xlocal + m_Width, ylocal); | |
942 | dc.SetPen(mypen2); | |
943 | dc.DrawLine(xlocal + m_Width - 1, ylocal, xlocal + m_Width - 1, ylocal + m_Height - 1); | |
944 | dc.DrawLine(xlocal, ylocal + m_Height - 1, xlocal + m_Width, ylocal + m_Height - 1); | |
945 | } | |
5526e819 | 946 | |
848c4eb2 VS |
947 | if (m_Cells) |
948 | { | |
949 | // draw container's contents: | |
950 | for (wxHtmlCell *cell = m_Cells; cell; cell = cell->GetNext()) | |
bf7d7ee7 | 951 | { |
95af070a | 952 | |
848c4eb2 VS |
953 | // optimize drawing: don't render off-screen content: |
954 | if ((ylocal + cell->GetPosY() <= view_y2) && | |
955 | (ylocal + cell->GetPosY() + cell->GetHeight() > view_y1)) | |
36c4ff4d | 956 | { |
848c4eb2 | 957 | // the cell is visible, draw it: |
f30e67db | 958 | UpdateRenderingStatePre(info, cell); |
36c4ff4d | 959 | cell->Draw(dc, |
848c4eb2 | 960 | xlocal, ylocal, view_y1, view_y2, |
f30e67db VS |
961 | info); |
962 | UpdateRenderingStatePost(info, cell); | |
36c4ff4d | 963 | } |
848c4eb2 VS |
964 | else |
965 | { | |
966 | // the cell is off-screen, proceed with font+color+etc. | |
967 | // changes only: | |
968 | cell->DrawInvisible(dc, xlocal, ylocal, info); | |
969 | } | |
bf7d7ee7 | 970 | } |
5526e819 | 971 | } |
5526e819 VS |
972 | } |
973 | ||
974 | ||
975 | ||
36c4ff4d | 976 | void wxHtmlContainerCell::DrawInvisible(wxDC& dc, int x, int y, |
f30e67db | 977 | wxHtmlRenderingInfo& info) |
5526e819 | 978 | { |
d699f48b | 979 | if (m_Cells) |
bf7d7ee7 VS |
980 | { |
981 | for (wxHtmlCell *cell = m_Cells; cell; cell = cell->GetNext()) | |
36c4ff4d | 982 | { |
f30e67db VS |
983 | UpdateRenderingStatePre(info, cell); |
984 | cell->DrawInvisible(dc, x + m_PosX, y + m_PosY, info); | |
985 | UpdateRenderingStatePost(info, cell); | |
36c4ff4d | 986 | } |
bf7d7ee7 | 987 | } |
5526e819 VS |
988 | } |
989 | ||
990 | ||
2b5f62a0 VZ |
991 | wxColour wxHtmlContainerCell::GetBackgroundColour() |
992 | { | |
993 | if (m_UseBkColour) | |
994 | return m_BkColour; | |
995 | else | |
996 | return wxNullColour; | |
997 | } | |
998 | ||
999 | ||
5526e819 | 1000 | |
846914d1 | 1001 | wxHtmlLinkInfo *wxHtmlContainerCell::GetLink(int x, int y) const |
5526e819 | 1002 | { |
f6010d8f | 1003 | wxHtmlCell *cell = FindCellByPos(x, y); |
5526e819 | 1004 | |
f6010d8f VZ |
1005 | // VZ: I don't know if we should pass absolute or relative coords to |
1006 | // wxHtmlCell::GetLink()? As the base class version just ignores them | |
1007 | // anyhow, it hardly matters right now but should still be clarified | |
1008 | return cell ? cell->GetLink(x, y) : NULL; | |
5526e819 VS |
1009 | } |
1010 | ||
1011 | ||
1012 | ||
1013 | void wxHtmlContainerCell::InsertCell(wxHtmlCell *f) | |
1014 | { | |
1015 | if (!m_Cells) m_Cells = m_LastCell = f; | |
04dbb646 | 1016 | else |
4f9297b0 VS |
1017 | { |
1018 | m_LastCell->SetNext(f); | |
5526e819 | 1019 | m_LastCell = f; |
4f9297b0 | 1020 | if (m_LastCell) while (m_LastCell->GetNext()) m_LastCell = m_LastCell->GetNext(); |
5526e819 | 1021 | } |
4f9297b0 | 1022 | f->SetParent(this); |
5660c520 | 1023 | m_LastLayout = -1; |
5526e819 VS |
1024 | } |
1025 | ||
1026 | ||
1027 | ||
1028 | void wxHtmlContainerCell::SetAlign(const wxHtmlTag& tag) | |
1029 | { | |
04dbb646 | 1030 | if (tag.HasParam(wxT("ALIGN"))) |
4f9297b0 | 1031 | { |
0413cec5 | 1032 | wxString alg = tag.GetParam(wxT("ALIGN")); |
5526e819 | 1033 | alg.MakeUpper(); |
0413cec5 | 1034 | if (alg == wxT("CENTER")) |
efba2b89 | 1035 | SetAlignHor(wxHTML_ALIGN_CENTER); |
0413cec5 | 1036 | else if (alg == wxT("LEFT")) |
efba2b89 | 1037 | SetAlignHor(wxHTML_ALIGN_LEFT); |
5c1bfc5d VS |
1038 | else if (alg == wxT("JUSTIFY")) |
1039 | SetAlignHor(wxHTML_ALIGN_JUSTIFY); | |
0413cec5 | 1040 | else if (alg == wxT("RIGHT")) |
efba2b89 | 1041 | SetAlignHor(wxHTML_ALIGN_RIGHT); |
5660c520 | 1042 | m_LastLayout = -1; |
5526e819 VS |
1043 | } |
1044 | } | |
1045 | ||
1046 | ||
1047 | ||
edbd0635 | 1048 | void wxHtmlContainerCell::SetWidthFloat(const wxHtmlTag& tag, double pixel_scale) |
5526e819 | 1049 | { |
04dbb646 | 1050 | if (tag.HasParam(wxT("WIDTH"))) |
4f9297b0 | 1051 | { |
5526e819 | 1052 | int wdi; |
0413cec5 | 1053 | wxString wd = tag.GetParam(wxT("WIDTH")); |
5526e819 | 1054 | |
04dbb646 | 1055 | if (wd[wd.Length()-1] == wxT('%')) |
0cb9cfb2 | 1056 | { |
66a77a74 | 1057 | wxSscanf(wd.c_str(), wxT("%i%%"), &wdi); |
efba2b89 | 1058 | SetWidthFloat(wdi, wxHTML_UNITS_PERCENT); |
5526e819 | 1059 | } |
04dbb646 | 1060 | else |
0cb9cfb2 | 1061 | { |
66a77a74 | 1062 | wxSscanf(wd.c_str(), wxT("%i"), &wdi); |
edbd0635 | 1063 | SetWidthFloat((int)(pixel_scale * (double)wdi), wxHTML_UNITS_PIXELS); |
5526e819 | 1064 | } |
5660c520 | 1065 | m_LastLayout = -1; |
5526e819 VS |
1066 | } |
1067 | } | |
1068 | ||
1069 | ||
1070 | ||
1071 | const wxHtmlCell* wxHtmlContainerCell::Find(int condition, const void* param) const | |
1072 | { | |
04dbb646 | 1073 | if (m_Cells) |
d699f48b | 1074 | { |
bf7d7ee7 VS |
1075 | for (wxHtmlCell *cell = m_Cells; cell; cell = cell->GetNext()) |
1076 | { | |
999836aa | 1077 | const wxHtmlCell *r = cell->Find(condition, param); |
bf7d7ee7 VS |
1078 | if (r) return r; |
1079 | } | |
1080 | } | |
1081 | return NULL; | |
5526e819 VS |
1082 | } |
1083 | ||
1084 | ||
36c4ff4d VS |
1085 | wxHtmlCell *wxHtmlContainerCell::FindCellByPos(wxCoord x, wxCoord y, |
1086 | unsigned flags) const | |
5526e819 | 1087 | { |
6d41981d | 1088 | if ( flags & wxHTML_FIND_EXACT ) |
4f9297b0 | 1089 | { |
adf2eb2d VS |
1090 | for ( const wxHtmlCell *cell = m_Cells; cell; cell = cell->GetNext() ) |
1091 | { | |
1092 | int cx = cell->GetPosX(), | |
1093 | cy = cell->GetPosY(); | |
1094 | ||
1095 | if ( (cx <= x) && (cx + cell->GetWidth() > x) && | |
1096 | (cy <= y) && (cy + cell->GetHeight() > y) ) | |
1097 | { | |
1098 | return cell->FindCellByPos(x - cx, y - cy, flags); | |
1099 | } | |
1100 | } | |
adf2eb2d | 1101 | } |
6d41981d | 1102 | else if ( flags & wxHTML_FIND_NEAREST_AFTER ) |
adf2eb2d VS |
1103 | { |
1104 | wxHtmlCell *c; | |
adf2eb2d | 1105 | for ( const wxHtmlCell *cell = m_Cells; cell; cell = cell->GetNext() ) |
0cb9cfb2 | 1106 | { |
03693319 VS |
1107 | if ( cell->IsFormattingCell() ) |
1108 | continue; | |
1109 | int cellY = cell->GetPosY(); | |
d1da8872 | 1110 | if (!( y < cellY || (y < cellY + cell->GetHeight() && |
03693319 | 1111 | x < cell->GetPosX() + cell->GetWidth()) )) |
adf2eb2d | 1112 | continue; |
d1da8872 | 1113 | |
03693319 | 1114 | c = cell->FindCellByPos(x - cell->GetPosX(), y - cellY, flags); |
adf2eb2d | 1115 | if (c) return c; |
5526e819 VS |
1116 | } |
1117 | } | |
6d41981d | 1118 | else if ( flags & wxHTML_FIND_NEAREST_BEFORE ) |
adf2eb2d | 1119 | { |
e24529d7 | 1120 | wxHtmlCell *c2, *c = NULL; |
adf2eb2d VS |
1121 | for ( const wxHtmlCell *cell = m_Cells; cell; cell = cell->GetNext() ) |
1122 | { | |
03693319 VS |
1123 | if ( cell->IsFormattingCell() ) |
1124 | continue; | |
1125 | int cellY = cell->GetPosY(); | |
1126 | if (!( cellY + cell->GetHeight() <= y || | |
1127 | (y >= cellY && x >= cell->GetPosX()) )) | |
adf2eb2d | 1128 | break; |
03693319 | 1129 | c2 = cell->FindCellByPos(x - cell->GetPosX(), y - cellY, flags); |
e24529d7 VS |
1130 | if (c2) |
1131 | c = c2; | |
adf2eb2d | 1132 | } |
e24529d7 | 1133 | if (c) return c; |
adf2eb2d | 1134 | } |
6d41981d VZ |
1135 | |
1136 | return NULL; | |
f6010d8f VZ |
1137 | } |
1138 | ||
1139 | ||
1140 | void wxHtmlContainerCell::OnMouseClick(wxWindow *parent, int x, int y, const wxMouseEvent& event) | |
1141 | { | |
1142 | wxHtmlCell *cell = FindCellByPos(x, y); | |
1143 | if ( cell ) | |
1144 | cell->OnMouseClick(parent, x, y, event); | |
5526e819 VS |
1145 | } |
1146 | ||
1147 | ||
1148 | ||
adf2eb2d VS |
1149 | wxHtmlCell *wxHtmlContainerCell::GetFirstTerminal() const |
1150 | { | |
e3774124 VS |
1151 | if ( m_Cells ) |
1152 | { | |
1153 | wxHtmlCell *c2; | |
1154 | for (wxHtmlCell *c = m_Cells; c; c = c->GetNext()) | |
1155 | { | |
1156 | c2 = c->GetFirstTerminal(); | |
1157 | if ( c2 ) | |
1158 | return c2; | |
1159 | } | |
1160 | } | |
1161 | return NULL; | |
adf2eb2d VS |
1162 | } |
1163 | ||
1164 | wxHtmlCell *wxHtmlContainerCell::GetLastTerminal() const | |
1165 | { | |
e3774124 | 1166 | if ( m_Cells ) |
adf2eb2d | 1167 | { |
e3774124 | 1168 | // most common case first: |
4ce19ed7 | 1169 | wxHtmlCell *c = m_LastCell->GetLastTerminal(); |
e3774124 VS |
1170 | if ( c ) |
1171 | return c; | |
4ce19ed7 | 1172 | |
ace0fab4 | 1173 | wxHtmlCell *ctmp; |
4ce19ed7 VZ |
1174 | wxHtmlCell *c2 = NULL; |
1175 | for (c = m_Cells; c; c = c->GetNext()) | |
ace0fab4 VS |
1176 | { |
1177 | ctmp = c->GetLastTerminal(); | |
1178 | if ( ctmp ) | |
1179 | c2 = ctmp; | |
1180 | } | |
e3774124 | 1181 | return c2; |
adf2eb2d VS |
1182 | } |
1183 | else | |
1184 | return NULL; | |
1185 | } | |
79d6c018 VS |
1186 | |
1187 | ||
ace0fab4 VS |
1188 | static bool IsEmptyContainer(wxHtmlContainerCell *cell) |
1189 | { | |
1190 | for ( wxHtmlCell *c = cell->GetFirstChild(); c; c = c->GetNext() ) | |
1191 | { | |
1192 | if ( !c->IsTerminalCell() || !c->IsFormattingCell() ) | |
1193 | return false; | |
1194 | } | |
1195 | return true; | |
1196 | } | |
1197 | ||
1198 | void wxHtmlContainerCell::RemoveExtraSpacing(bool top, bool bottom) | |
d1da8872 | 1199 | { |
ace0fab4 VS |
1200 | if ( top ) |
1201 | SetIndent(0, wxHTML_INDENT_TOP); | |
1202 | if ( bottom ) | |
1203 | SetIndent(0, wxHTML_INDENT_BOTTOM); | |
1204 | ||
1205 | if ( m_Cells ) | |
1206 | { | |
1207 | wxHtmlCell *c; | |
1208 | wxHtmlContainerCell *cont; | |
1209 | if ( top ) | |
1210 | { | |
1211 | for ( c = m_Cells; c; c = c->GetNext() ) | |
1212 | { | |
1213 | if ( c->IsTerminalCell() ) | |
1214 | { | |
1215 | if ( !c->IsFormattingCell() ) | |
1216 | break; | |
1217 | } | |
1218 | else | |
1219 | { | |
1220 | cont = (wxHtmlContainerCell*)c; | |
1221 | if ( IsEmptyContainer(cont) ) | |
1222 | { | |
1223 | cont->SetIndent(0, wxHTML_INDENT_VERTICAL); | |
1224 | } | |
1225 | else | |
1226 | { | |
1227 | cont->RemoveExtraSpacing(true, false); | |
1228 | break; | |
1229 | } | |
1230 | } | |
1231 | } | |
1232 | } | |
d1da8872 | 1233 | |
ace0fab4 VS |
1234 | if ( bottom ) |
1235 | { | |
1236 | wxArrayPtrVoid arr; | |
1237 | for ( c = m_Cells; c; c = c->GetNext() ) | |
1238 | arr.Add((void*)c); | |
d1da8872 | 1239 | |
ace0fab4 VS |
1240 | for ( int i = arr.GetCount() - 1; i >= 0; i--) |
1241 | { | |
1242 | c = (wxHtmlCell*)arr[i]; | |
1243 | if ( c->IsTerminalCell() ) | |
1244 | { | |
1245 | if ( !c->IsFormattingCell() ) | |
1246 | break; | |
1247 | } | |
1248 | else | |
1249 | { | |
1250 | cont = (wxHtmlContainerCell*)c; | |
1251 | if ( IsEmptyContainer(cont) ) | |
1252 | { | |
3e905c52 RD |
1253 | cont->SetIndent(0, wxHTML_INDENT_VERTICAL); |
1254 | } | |
ace0fab4 VS |
1255 | else |
1256 | { | |
1257 | cont->RemoveExtraSpacing(false, true); | |
1258 | break; | |
1259 | } | |
1260 | } | |
1261 | } | |
1262 | } | |
1263 | } | |
1264 | } | |
1265 | ||
1266 | ||
5526e819 VS |
1267 | |
1268 | ||
36c4ff4d | 1269 | // -------------------------------------------------------------------------- |
5526e819 | 1270 | // wxHtmlColourCell |
36c4ff4d | 1271 | // -------------------------------------------------------------------------- |
5526e819 | 1272 | |
4f44ea36 MB |
1273 | IMPLEMENT_ABSTRACT_CLASS(wxHtmlColourCell, wxHtmlCell) |
1274 | ||
36c4ff4d VS |
1275 | void wxHtmlColourCell::Draw(wxDC& dc, |
1276 | int x, int y, | |
1277 | int WXUNUSED(view_y1), int WXUNUSED(view_y2), | |
f30e67db | 1278 | wxHtmlRenderingInfo& info) |
5526e819 | 1279 | { |
f30e67db | 1280 | DrawInvisible(dc, x, y, info); |
5526e819 VS |
1281 | } |
1282 | ||
36c4ff4d VS |
1283 | void wxHtmlColourCell::DrawInvisible(wxDC& dc, |
1284 | int WXUNUSED(x), int WXUNUSED(y), | |
f30e67db | 1285 | wxHtmlRenderingInfo& info) |
5526e819 | 1286 | { |
f30e67db | 1287 | wxHtmlRenderingState& state = info.GetState(); |
efba2b89 | 1288 | if (m_Flags & wxHTML_CLR_FOREGROUND) |
36c4ff4d VS |
1289 | { |
1290 | state.SetFgColour(m_Colour); | |
1291 | if (state.GetSelectionState() != wxHTML_SEL_IN) | |
bfc248a3 VS |
1292 | dc.SetTextForeground(m_Colour); |
1293 | else | |
1294 | dc.SetTextForeground( | |
1295 | info.GetStyle().GetSelectedTextColour(m_Colour)); | |
36c4ff4d | 1296 | } |
04dbb646 | 1297 | if (m_Flags & wxHTML_CLR_BACKGROUND) |
4f9297b0 | 1298 | { |
36c4ff4d VS |
1299 | state.SetBgColour(m_Colour); |
1300 | if (state.GetSelectionState() != wxHTML_SEL_IN) | |
b87dd6f5 | 1301 | { |
36c4ff4d | 1302 | dc.SetTextBackground(m_Colour); |
b87dd6f5 VS |
1303 | dc.SetBackground(wxBrush(m_Colour, wxSOLID)); |
1304 | } | |
bfc248a3 | 1305 | else |
b87dd6f5 VS |
1306 | { |
1307 | wxColour c = info.GetStyle().GetSelectedTextBgColour(m_Colour); | |
1308 | dc.SetTextBackground(c); | |
1309 | dc.SetBackground(wxBrush(c, wxSOLID)); | |
1310 | } | |
5526e819 | 1311 | } |
5526e819 VS |
1312 | } |
1313 | ||
1314 | ||
1315 | ||
1316 | ||
36c4ff4d | 1317 | // --------------------------------------------------------------------------- |
5526e819 | 1318 | // wxHtmlFontCell |
36c4ff4d | 1319 | // --------------------------------------------------------------------------- |
5526e819 | 1320 | |
4f44ea36 MB |
1321 | IMPLEMENT_ABSTRACT_CLASS(wxHtmlFontCell, wxHtmlCell) |
1322 | ||
36c4ff4d VS |
1323 | void wxHtmlFontCell::Draw(wxDC& dc, |
1324 | int WXUNUSED(x), int WXUNUSED(y), | |
1325 | int WXUNUSED(view_y1), int WXUNUSED(view_y2), | |
f30e67db | 1326 | wxHtmlRenderingInfo& WXUNUSED(info)) |
5526e819 | 1327 | { |
921d0fb1 | 1328 | dc.SetFont(m_Font); |
5526e819 VS |
1329 | } |
1330 | ||
36c4ff4d | 1331 | void wxHtmlFontCell::DrawInvisible(wxDC& dc, int WXUNUSED(x), int WXUNUSED(y), |
f30e67db | 1332 | wxHtmlRenderingInfo& WXUNUSED(info)) |
5526e819 | 1333 | { |
921d0fb1 | 1334 | dc.SetFont(m_Font); |
5526e819 VS |
1335 | } |
1336 | ||
1337 | ||
1338 | ||
1339 | ||
1340 | ||
1341 | ||
1342 | ||
1343 | ||
36c4ff4d | 1344 | // --------------------------------------------------------------------------- |
5526e819 | 1345 | // wxHtmlWidgetCell |
36c4ff4d | 1346 | // --------------------------------------------------------------------------- |
5526e819 | 1347 | |
4f44ea36 MB |
1348 | IMPLEMENT_ABSTRACT_CLASS(wxHtmlWidgetCell, wxHtmlCell) |
1349 | ||
5526e819 VS |
1350 | wxHtmlWidgetCell::wxHtmlWidgetCell(wxWindow *wnd, int w) |
1351 | { | |
1352 | int sx, sy; | |
1353 | m_Wnd = wnd; | |
4f9297b0 | 1354 | m_Wnd->GetSize(&sx, &sy); |
5526e819 VS |
1355 | m_Width = sx, m_Height = sy; |
1356 | m_WidthFloat = w; | |
1357 | } | |
1358 | ||
1359 | ||
36c4ff4d VS |
1360 | void wxHtmlWidgetCell::Draw(wxDC& WXUNUSED(dc), |
1361 | int WXUNUSED(x), int WXUNUSED(y), | |
1362 | int WXUNUSED(view_y1), int WXUNUSED(view_y2), | |
f30e67db | 1363 | wxHtmlRenderingInfo& WXUNUSED(info)) |
5526e819 VS |
1364 | { |
1365 | int absx = 0, absy = 0, stx, sty; | |
1366 | wxHtmlCell *c = this; | |
1367 | ||
04dbb646 | 1368 | while (c) |
4f9297b0 VS |
1369 | { |
1370 | absx += c->GetPosX(); | |
1371 | absy += c->GetPosY(); | |
1372 | c = c->GetParent(); | |
5526e819 VS |
1373 | } |
1374 | ||
e421922f | 1375 | ((wxScrolledWindow*)(m_Wnd->GetParent()))->GetViewStart(&stx, &sty); |
4f9297b0 | 1376 | m_Wnd->SetSize(absx - wxHTML_SCROLL_STEP * stx, absy - wxHTML_SCROLL_STEP * sty, m_Width, m_Height); |
5526e819 VS |
1377 | } |
1378 | ||
1379 | ||
1380 | ||
36c4ff4d VS |
1381 | void wxHtmlWidgetCell::DrawInvisible(wxDC& WXUNUSED(dc), |
1382 | int WXUNUSED(x), int WXUNUSED(y), | |
f30e67db | 1383 | wxHtmlRenderingInfo& WXUNUSED(info)) |
5526e819 VS |
1384 | { |
1385 | int absx = 0, absy = 0, stx, sty; | |
1386 | wxHtmlCell *c = this; | |
1387 | ||
04dbb646 | 1388 | while (c) |
4f9297b0 VS |
1389 | { |
1390 | absx += c->GetPosX(); | |
1391 | absy += c->GetPosY(); | |
1392 | c = c->GetParent(); | |
5526e819 | 1393 | } |
7e941458 | 1394 | |
e421922f | 1395 | ((wxScrolledWindow*)(m_Wnd->GetParent()))->GetViewStart(&stx, &sty); |
4f9297b0 | 1396 | m_Wnd->SetSize(absx - wxHTML_SCROLL_STEP * stx, absy - wxHTML_SCROLL_STEP * sty, m_Width, m_Height); |
5526e819 VS |
1397 | } |
1398 | ||
1399 | ||
1400 | ||
1401 | void wxHtmlWidgetCell::Layout(int w) | |
1402 | { | |
04dbb646 | 1403 | if (m_WidthFloat != 0) |
4f9297b0 | 1404 | { |
5526e819 | 1405 | m_Width = (w * m_WidthFloat) / 100; |
4f9297b0 | 1406 | m_Wnd->SetSize(m_Width, m_Height); |
5526e819 VS |
1407 | } |
1408 | ||
1409 | wxHtmlCell::Layout(w); | |
1410 | } | |
1411 | ||
e3774124 VS |
1412 | |
1413 | ||
1414 | // ---------------------------------------------------------------------------- | |
1415 | // wxHtmlTerminalCellsInterator | |
1416 | // ---------------------------------------------------------------------------- | |
1417 | ||
1418 | const wxHtmlCell* wxHtmlTerminalCellsInterator::operator++() | |
1419 | { | |
1420 | if ( !m_pos ) | |
1421 | return NULL; | |
1422 | ||
1423 | do | |
1424 | { | |
1425 | if ( m_pos == m_to ) | |
1426 | { | |
1427 | m_pos = NULL; | |
1428 | return NULL; | |
1429 | } | |
1430 | ||
1431 | if ( m_pos->GetNext() ) | |
1432 | m_pos = m_pos->GetNext(); | |
1433 | else | |
1434 | { | |
1435 | // we must go up the hierarchy until we reach container where this | |
1436 | // is not the last child, and then go down to first terminal cell: | |
1437 | while ( m_pos->GetNext() == NULL ) | |
1438 | { | |
1439 | m_pos = m_pos->GetParent(); | |
1440 | if ( !m_pos ) | |
1441 | return NULL; | |
1442 | } | |
1443 | m_pos = m_pos->GetNext(); | |
1444 | } | |
1445 | while ( m_pos->GetFirstChild() != NULL ) | |
1446 | m_pos = m_pos->GetFirstChild(); | |
1447 | } while ( !m_pos->IsTerminalCell() ); | |
86ff9b45 | 1448 | |
e3774124 VS |
1449 | return m_pos; |
1450 | } | |
1451 | ||
77bae5e2 VS |
1452 | |
1453 | ||
1454 | ||
1455 | ||
1456 | ||
1457 | ||
1458 | //----------------------------------------------------------------------------- | |
1459 | // Cleanup | |
1460 | //----------------------------------------------------------------------------- | |
1461 | ||
1462 | class wxHtmlCellModule: public wxModule | |
1463 | { | |
1464 | DECLARE_DYNAMIC_CLASS(wxHtmlCellModule) | |
1465 | public: | |
1466 | wxHtmlCellModule() : wxModule() {} | |
1467 | bool OnInit() { return true; } | |
1468 | void OnExit() | |
1469 | { | |
1470 | wxDELETE(gs_cursorLink); | |
1471 | wxDELETE(gs_cursorText); | |
1472 | } | |
1473 | }; | |
1474 | ||
1475 | IMPLEMENT_DYNAMIC_CLASS(wxHtmlCellModule, wxModule) | |
1476 | ||
5526e819 | 1477 | #endif |