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