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