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