]>
Commit | Line | Data |
---|---|---|
5526e819 VS |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: htmlcell.cpp | |
3 | // Purpose: wxHtmlCell - basic element of HTML output | |
4 | // Author: Vaclav Slavik | |
69941f05 | 5 | // RCS-ID: $Id$ |
5526e819 VS |
6 | // Copyright: (c) 1999 Vaclav Slavik |
7 | // Licence: wxWindows Licence | |
8 | ///////////////////////////////////////////////////////////////////////////// | |
9 | ||
5526e819 | 10 | #ifdef __GNUG__ |
1aedb1dd | 11 | #pragma implementation "htmlcell.h" |
5526e819 VS |
12 | #endif |
13 | ||
4dcaf11a | 14 | #include "wx/wxprec.h" |
5526e819 | 15 | |
314260fb | 16 | #include "wx/defs.h" |
f6bcfd97 BP |
17 | |
18 | #if wxUSE_HTML && wxUSE_STREAMS | |
5526e819 | 19 | |
2b5f62a0 | 20 | #ifdef __BORLANDC__ |
5526e819 VS |
21 | #pragma hdrstop |
22 | #endif | |
23 | ||
24 | #ifndef WXPRECOMP | |
04dbb646 VZ |
25 | #include "wx/brush.h" |
26 | #include "wx/colour.h" | |
27 | #include "wx/dc.h" | |
5526e819 VS |
28 | #endif |
29 | ||
4dcaf11a RR |
30 | #include "wx/html/htmlcell.h" |
31 | #include "wx/html/htmlwin.h" | |
36c4ff4d | 32 | #include "wx/settings.h" |
5526e819 VS |
33 | #include <stdlib.h> |
34 | ||
e3774124 VS |
35 | //----------------------------------------------------------------------------- |
36 | // Helper classes | |
37 | //----------------------------------------------------------------------------- | |
38 | ||
39 | void wxHtmlSelection::Set(const wxPoint& fromPos, wxHtmlCell *fromCell, | |
40 | const wxPoint& toPos, wxHtmlCell *toCell) | |
41 | { | |
42 | m_fromCell = fromCell; | |
43 | m_toCell = toCell; | |
44 | m_fromPos = fromPos; | |
45 | m_toPos = toPos; | |
46 | } | |
47 | ||
48 | void wxHtmlSelection::Set(wxHtmlCell *fromCell, wxHtmlCell *toCell) | |
49 | { | |
50 | wxPoint p1 = fromCell ? fromCell->GetAbsPos() : wxDefaultPosition; | |
51 | wxPoint p2 = toCell ? toCell->GetAbsPos() : wxDefaultPosition; | |
52 | if ( toCell ) | |
53 | { | |
54 | p2.x += toCell->GetWidth()-1; | |
55 | p2.y += toCell->GetHeight()-1; | |
56 | } | |
57 | Set(p1, fromCell, p2, toCell); | |
58 | } | |
5526e819 | 59 | |
5526e819 VS |
60 | //----------------------------------------------------------------------------- |
61 | // wxHtmlCell | |
62 | //----------------------------------------------------------------------------- | |
63 | ||
04dbb646 | 64 | wxHtmlCell::wxHtmlCell() : wxObject() |
846914d1 | 65 | { |
04dbb646 VZ |
66 | m_Next = NULL; |
67 | m_Parent = NULL; | |
68 | m_Width = m_Height = m_Descent = 0; | |
846914d1 VS |
69 | m_CanLiveOnPagebreak = TRUE; |
70 | m_Link = NULL; | |
71 | } | |
72 | ||
04dbb646 | 73 | wxHtmlCell::~wxHtmlCell() |
846914d1 | 74 | { |
0cb9cfb2 | 75 | delete m_Link; |
846914d1 VS |
76 | } |
77 | ||
5526e819 | 78 | |
04dbb646 | 79 | void wxHtmlCell::OnMouseClick(wxWindow *parent, int x, int y, |
0b2dadd3 | 80 | const wxMouseEvent& event) |
5526e819 | 81 | { |
846914d1 VS |
82 | wxHtmlLinkInfo *lnk = GetLink(x, y); |
83 | if (lnk != NULL) | |
0b2dadd3 VS |
84 | { |
85 | wxHtmlLinkInfo lnk2(*lnk); | |
86 | lnk2.SetEvent(&event); | |
9bc8fded | 87 | lnk2.SetHtmlCell(this); |
0cb9cfb2 VZ |
88 | |
89 | // note : this cast is legal because parent is *always* wxHtmlWindow | |
90 | wxStaticCast(parent, wxHtmlWindow)->OnLinkClicked(lnk2); | |
0b2dadd3 | 91 | } |
5526e819 VS |
92 | } |
93 | ||
94 | ||
95 | ||
f2034f1b | 96 | bool wxHtmlCell::AdjustPagebreak(int *pagebreak, int* WXUNUSED(known_pagebreaks), int WXUNUSED(number_of_pages)) const |
db98870d | 97 | { |
04dbb646 VZ |
98 | if ((!m_CanLiveOnPagebreak) && |
99 | m_PosY < *pagebreak && m_PosY + m_Height > *pagebreak) | |
0cb9cfb2 | 100 | { |
db98870d | 101 | *pagebreak = m_PosY; |
db98870d VS |
102 | return TRUE; |
103 | } | |
0cb9cfb2 VZ |
104 | |
105 | return FALSE; | |
db98870d VS |
106 | } |
107 | ||
108 | ||
109 | ||
04dbb646 | 110 | void wxHtmlCell::SetLink(const wxHtmlLinkInfo& link) |
846914d1 VS |
111 | { |
112 | if (m_Link) delete m_Link; | |
af1ed0c1 VS |
113 | m_Link = NULL; |
114 | if (link.GetHref() != wxEmptyString) | |
115 | m_Link = new wxHtmlLinkInfo(link); | |
846914d1 VS |
116 | } |
117 | ||
118 | ||
db98870d | 119 | |
d699f48b | 120 | void wxHtmlCell::Layout(int WXUNUSED(w)) |
721ab905 | 121 | { |
04dbb646 | 122 | SetPos(0, 0); |
721ab905 VS |
123 | } |
124 | ||
125 | ||
79d6c018 VS |
126 | |
127 | void wxHtmlCell::GetHorizontalConstraints(int *left, int *right) const | |
128 | { | |
129 | if (left) | |
130 | *left = m_PosX; | |
131 | if (right) | |
026d1fac | 132 | *right = m_PosX + m_Width; |
79d6c018 VS |
133 | } |
134 | ||
135 | ||
136 | ||
d699f48b | 137 | const wxHtmlCell* wxHtmlCell::Find(int WXUNUSED(condition), const void* WXUNUSED(param)) const |
721ab905 | 138 | { |
bf7d7ee7 | 139 | return NULL; |
721ab905 VS |
140 | } |
141 | ||
142 | ||
36c4ff4d VS |
143 | wxHtmlCell *wxHtmlCell::FindCellByPos(wxCoord x, wxCoord y, |
144 | unsigned flags) const | |
f6010d8f | 145 | { |
adf2eb2d | 146 | if ( x >= 0 && x < m_Width && y >= 0 && y < m_Height ) |
36c4ff4d | 147 | { |
f6010d8f | 148 | return wxConstCast(this, wxHtmlCell); |
36c4ff4d | 149 | } |
adf2eb2d VS |
150 | else |
151 | { | |
152 | if ((flags & wxHTML_FIND_NEAREST_AFTER) && | |
153 | (y < 0 || (y == 0 && x <= 0))) | |
154 | return wxConstCast(this, wxHtmlCell); | |
155 | else if ((flags & wxHTML_FIND_NEAREST_BEFORE) && | |
156 | (y > m_Height-1 || (y == m_Height-1 && x >= m_Width))) | |
157 | return wxConstCast(this, wxHtmlCell); | |
158 | else | |
159 | return NULL; | |
160 | } | |
161 | } | |
162 | ||
163 | ||
164 | wxPoint wxHtmlCell::GetAbsPos() const | |
165 | { | |
166 | wxPoint p(m_PosX, m_PosY); | |
167 | for (wxHtmlCell *parent = m_Parent; parent; parent = parent->m_Parent) | |
168 | { | |
169 | p.x += parent->m_PosX; | |
170 | p.y += parent->m_PosY; | |
171 | } | |
172 | return p; | |
f6010d8f | 173 | } |
e3774124 VS |
174 | |
175 | unsigned wxHtmlCell::GetDepth() const | |
176 | { | |
177 | unsigned d = 0; | |
178 | for (wxHtmlCell *p = m_Parent; p; p = p->m_Parent) | |
179 | d++; | |
180 | return d; | |
181 | } | |
182 | ||
183 | bool wxHtmlCell::IsBefore(wxHtmlCell *cell) const | |
184 | { | |
185 | const wxHtmlCell *c1 = this; | |
186 | const wxHtmlCell *c2 = cell; | |
187 | unsigned d1 = GetDepth(); | |
188 | unsigned d2 = cell->GetDepth(); | |
189 | ||
190 | if ( d1 > d2 ) | |
191 | for (; d1 != d2; d1-- ) | |
192 | c1 = c1->m_Parent; | |
193 | else if ( d1 < d2 ) | |
194 | for (; d1 != d2; d2-- ) | |
195 | c2 = c2->m_Parent; | |
196 | ||
197 | if ( cell == this ) | |
198 | return true; | |
199 | ||
200 | while ( c1 && c2 ) | |
201 | { | |
202 | if ( c1->m_Parent == c2->m_Parent ) | |
203 | { | |
204 | while ( c1 ) | |
205 | { | |
206 | if ( c1 == c2 ) | |
207 | return true; | |
208 | c1 = c1->GetNext(); | |
209 | } | |
210 | return false; | |
211 | } | |
212 | else | |
213 | { | |
214 | c1 = c1->m_Parent; | |
215 | c2 = c2->m_Parent; | |
216 | } | |
217 | } | |
218 | ||
219 | wxFAIL_MSG(_T("Cells are in different trees")); | |
220 | return false; | |
221 | } | |
f6010d8f | 222 | |
721ab905 | 223 | |
5526e819 VS |
224 | //----------------------------------------------------------------------------- |
225 | // wxHtmlWordCell | |
226 | //----------------------------------------------------------------------------- | |
227 | ||
228 | wxHtmlWordCell::wxHtmlWordCell(const wxString& word, wxDC& dc) : wxHtmlCell() | |
229 | { | |
230 | m_Word = word; | |
5526e819 | 231 | dc.GetTextExtent(m_Word, &m_Width, &m_Height, &m_Descent); |
db98870d | 232 | SetCanLiveOnPagebreak(FALSE); |
5526e819 VS |
233 | } |
234 | ||
235 | ||
236 | ||
36c4ff4d VS |
237 | void wxHtmlWordCell::Draw(wxDC& dc, int x, int y, |
238 | int WXUNUSED(view_y1), int WXUNUSED(view_y2), | |
239 | wxHtmlRenderingState& state) | |
5526e819 | 240 | { |
adf2eb2d | 241 | if (state.GetSelectionState() != wxHTML_SEL_OUT && |
36c4ff4d VS |
242 | dc.GetBackgroundMode() != wxSOLID) |
243 | { | |
244 | dc.SetBackgroundMode(wxSOLID); | |
245 | dc.SetTextBackground( | |
246 | wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT)); | |
247 | dc.SetTextForeground( | |
248 | wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT)); | |
249 | } | |
250 | else if (state.GetSelectionState() == wxHTML_SEL_OUT && | |
251 | dc.GetBackgroundMode() == wxSOLID) | |
252 | { | |
253 | dc.SetBackgroundMode(wxTRANSPARENT); | |
254 | dc.SetTextForeground(state.GetFgColour()); | |
255 | dc.SetTextBackground(state.GetBgColour()); | |
256 | } | |
257 | ||
e3774124 | 258 | // FIXME - use selection |
5526e819 | 259 | dc.DrawText(m_Word, x + m_PosX, y + m_PosY); |
5526e819 | 260 | } |
e3774124 VS |
261 | |
262 | ||
263 | wxString wxHtmlWordCell::ConvertToText(wxHtmlSelection *sel) const | |
264 | { | |
265 | // FIXME - use selection | |
266 | return m_Word; | |
267 | } | |
5526e819 VS |
268 | |
269 | ||
270 | ||
5526e819 VS |
271 | //----------------------------------------------------------------------------- |
272 | // wxHtmlContainerCell | |
273 | //----------------------------------------------------------------------------- | |
274 | ||
275 | ||
276 | wxHtmlContainerCell::wxHtmlContainerCell(wxHtmlContainerCell *parent) : wxHtmlCell() | |
277 | { | |
278 | m_Cells = m_LastCell = NULL; | |
279 | m_Parent = parent; | |
4f9297b0 | 280 | if (m_Parent) m_Parent->InsertCell(this); |
efba2b89 VS |
281 | m_AlignHor = wxHTML_ALIGN_LEFT; |
282 | m_AlignVer = wxHTML_ALIGN_BOTTOM; | |
5526e819 | 283 | m_IndentLeft = m_IndentRight = m_IndentTop = m_IndentBottom = 0; |
efba2b89 | 284 | m_WidthFloat = 100; m_WidthFloatUnits = wxHTML_UNITS_PERCENT; |
5526e819 VS |
285 | m_UseBkColour = FALSE; |
286 | m_UseBorder = FALSE; | |
5c1bfc5d | 287 | m_MinHeight = 0; |
efba2b89 | 288 | m_MinHeightAlign = wxHTML_ALIGN_TOP; |
5660c520 | 289 | m_LastLayout = -1; |
5526e819 VS |
290 | } |
291 | ||
04dbb646 | 292 | wxHtmlContainerCell::~wxHtmlContainerCell() |
721ab905 | 293 | { |
491c9920 VZ |
294 | wxHtmlCell *cell = m_Cells; |
295 | while ( cell ) | |
bf7d7ee7 | 296 | { |
491c9920 VZ |
297 | wxHtmlCell *cellNext = cell->GetNext(); |
298 | delete cell; | |
299 | cell = cellNext; | |
bf7d7ee7 | 300 | } |
721ab905 VS |
301 | } |
302 | ||
5526e819 VS |
303 | |
304 | ||
305 | void wxHtmlContainerCell::SetIndent(int i, int what, int units) | |
306 | { | |
efba2b89 VS |
307 | int val = (units == wxHTML_UNITS_PIXELS) ? i : -i; |
308 | if (what & wxHTML_INDENT_LEFT) m_IndentLeft = val; | |
309 | if (what & wxHTML_INDENT_RIGHT) m_IndentRight = val; | |
310 | if (what & wxHTML_INDENT_TOP) m_IndentTop = val; | |
311 | if (what & wxHTML_INDENT_BOTTOM) m_IndentBottom = val; | |
5660c520 | 312 | m_LastLayout = -1; |
5526e819 VS |
313 | } |
314 | ||
315 | ||
316 | ||
317 | int wxHtmlContainerCell::GetIndent(int ind) const | |
318 | { | |
efba2b89 VS |
319 | if (ind & wxHTML_INDENT_LEFT) return m_IndentLeft; |
320 | else if (ind & wxHTML_INDENT_RIGHT) return m_IndentRight; | |
321 | else if (ind & wxHTML_INDENT_TOP) return m_IndentTop; | |
322 | else if (ind & wxHTML_INDENT_BOTTOM) return m_IndentBottom; | |
5526e819 VS |
323 | else return -1; /* BUG! Should not be called... */ |
324 | } | |
325 | ||
326 | ||
327 | ||
328 | ||
329 | int wxHtmlContainerCell::GetIndentUnits(int ind) const | |
330 | { | |
331 | bool p = FALSE; | |
efba2b89 VS |
332 | if (ind & wxHTML_INDENT_LEFT) p = m_IndentLeft < 0; |
333 | else if (ind & wxHTML_INDENT_RIGHT) p = m_IndentRight < 0; | |
334 | else if (ind & wxHTML_INDENT_TOP) p = m_IndentTop < 0; | |
335 | else if (ind & wxHTML_INDENT_BOTTOM) p = m_IndentBottom < 0; | |
336 | if (p) return wxHTML_UNITS_PERCENT; | |
337 | else return wxHTML_UNITS_PIXELS; | |
5526e819 VS |
338 | } |
339 | ||
340 | ||
341 | ||
f2034f1b | 342 | bool wxHtmlContainerCell::AdjustPagebreak(int *pagebreak, int* known_pagebreaks, int number_of_pages) const |
db98870d | 343 | { |
04dbb646 | 344 | if (!m_CanLiveOnPagebreak) |
f2034f1b | 345 | return wxHtmlCell::AdjustPagebreak(pagebreak, known_pagebreaks, number_of_pages); |
e52d6dbc | 346 | |
04dbb646 | 347 | else |
4f9297b0 | 348 | { |
e3774124 | 349 | wxHtmlCell *c = GetFirstChild(); |
db98870d | 350 | bool rt = FALSE; |
e52d6dbc | 351 | int pbrk = *pagebreak - m_PosY; |
db98870d | 352 | |
04dbb646 | 353 | while (c) |
0cb9cfb2 | 354 | { |
f2034f1b | 355 | if (c->AdjustPagebreak(&pbrk, known_pagebreaks, number_of_pages)) |
bf7d7ee7 | 356 | rt = TRUE; |
4f9297b0 | 357 | c = c->GetNext(); |
db98870d | 358 | } |
d699f48b | 359 | if (rt) |
bf7d7ee7 | 360 | *pagebreak = pbrk + m_PosY; |
db98870d VS |
361 | return rt; |
362 | } | |
363 | } | |
364 | ||
365 | ||
366 | ||
5526e819 VS |
367 | void wxHtmlContainerCell::Layout(int w) |
368 | { | |
026d1fac VS |
369 | wxHtmlCell::Layout(w); |
370 | ||
371 | if (m_LastLayout == w) return; | |
0cb9cfb2 | 372 | |
026d1fac VS |
373 | // VS: Any attempt to layout with negative or zero width leads to hell, |
374 | // but we can't ignore such attempts completely, since it sometimes | |
375 | // happen (e.g. when trying how small a table can be). The best thing we | |
376 | // can do is to set the width of child cells to zero | |
0cb9cfb2 | 377 | if (w < 1) |
4f9297b0 | 378 | { |
026d1fac VS |
379 | m_Width = 0; |
380 | for (wxHtmlCell *cell = m_Cells; cell; cell = cell->GetNext()) | |
381 | cell->Layout(0); | |
2b5f62a0 VZ |
382 | // this does two things: it recursively calls this code on all |
383 | // child contrainers and resets children's position to (0,0) | |
026d1fac | 384 | return; |
04dbb646 | 385 | } |
5660c520 | 386 | |
5526e819 VS |
387 | wxHtmlCell *cell = m_Cells, *line = m_Cells; |
388 | long xpos = 0, ypos = m_IndentTop; | |
389 | int xdelta = 0, ybasicpos = 0, ydiff; | |
390 | int s_width, s_indent; | |
391 | int ysizeup = 0, ysizedown = 0; | |
5c1bfc5d VS |
392 | int MaxLineWidth = 0; |
393 | int xcnt = 0; | |
394 | ||
5526e819 VS |
395 | |
396 | /* | |
7e941458 | 397 | |
5526e819 | 398 | WIDTH ADJUSTING : |
7e941458 | 399 | |
5526e819 VS |
400 | */ |
401 | ||
04dbb646 | 402 | if (m_WidthFloatUnits == wxHTML_UNITS_PERCENT) |
4f9297b0 | 403 | { |
5526e819 VS |
404 | if (m_WidthFloat < 0) m_Width = (100 + m_WidthFloat) * w / 100; |
405 | else m_Width = m_WidthFloat * w / 100; | |
406 | } | |
04dbb646 | 407 | else |
4f9297b0 | 408 | { |
5526e819 VS |
409 | if (m_WidthFloat < 0) m_Width = w + m_WidthFloat; |
410 | else m_Width = m_WidthFloat; | |
411 | } | |
412 | ||
04dbb646 | 413 | if (m_Cells) |
4f9297b0 | 414 | { |
5526e819 VS |
415 | int l = (m_IndentLeft < 0) ? (-m_IndentLeft * m_Width / 100) : m_IndentLeft; |
416 | int r = (m_IndentRight < 0) ? (-m_IndentRight * m_Width / 100) : m_IndentRight; | |
bf7d7ee7 VS |
417 | for (wxHtmlCell *cell = m_Cells; cell; cell = cell->GetNext()) |
418 | cell->Layout(m_Width - (l + r)); | |
5526e819 VS |
419 | } |
420 | ||
421 | /* | |
422 | ||
423 | LAYOUTING : | |
7e941458 | 424 | |
5526e819 VS |
425 | */ |
426 | ||
427 | // adjust indentation: | |
428 | s_indent = (m_IndentLeft < 0) ? (-m_IndentLeft * m_Width / 100) : m_IndentLeft; | |
429 | s_width = m_Width - s_indent - ((m_IndentRight < 0) ? (-m_IndentRight * m_Width / 100) : m_IndentRight); | |
430 | ||
5526e819 | 431 | // my own layouting: |
04dbb646 | 432 | while (cell != NULL) |
4f9297b0 | 433 | { |
04dbb646 | 434 | switch (m_AlignVer) |
0cb9cfb2 | 435 | { |
efba2b89 | 436 | case wxHTML_ALIGN_TOP : ybasicpos = 0; break; |
4f9297b0 VS |
437 | case wxHTML_ALIGN_BOTTOM : ybasicpos = - cell->GetHeight(); break; |
438 | case wxHTML_ALIGN_CENTER : ybasicpos = - cell->GetHeight() / 2; break; | |
5526e819 | 439 | } |
4f9297b0 | 440 | ydiff = cell->GetHeight() + ybasicpos; |
5526e819 | 441 | |
4f9297b0 VS |
442 | if (cell->GetDescent() + ydiff > ysizedown) ysizedown = cell->GetDescent() + ydiff; |
443 | if (ybasicpos + cell->GetDescent() < -ysizeup) ysizeup = - (ybasicpos + cell->GetDescent()); | |
5526e819 | 444 | |
4f9297b0 VS |
445 | cell->SetPos(xpos, ybasicpos + cell->GetDescent()); |
446 | xpos += cell->GetWidth(); | |
447 | cell = cell->GetNext(); | |
5c1bfc5d | 448 | xcnt++; |
5526e819 VS |
449 | |
450 | // force new line if occured: | |
04dbb646 | 451 | if ((cell == NULL) || (xpos + cell->GetWidth() > s_width)) |
0cb9cfb2 | 452 | { |
5c1bfc5d | 453 | if (xpos > MaxLineWidth) MaxLineWidth = xpos; |
5526e819 VS |
454 | if (ysizeup < 0) ysizeup = 0; |
455 | if (ysizedown < 0) ysizedown = 0; | |
456 | switch (m_AlignHor) { | |
04dbb646 VZ |
457 | case wxHTML_ALIGN_LEFT : |
458 | case wxHTML_ALIGN_JUSTIFY : | |
459 | xdelta = 0; | |
5c1bfc5d | 460 | break; |
04dbb646 VZ |
461 | case wxHTML_ALIGN_RIGHT : |
462 | xdelta = 0 + (s_width - xpos); | |
5c1bfc5d | 463 | break; |
04dbb646 VZ |
464 | case wxHTML_ALIGN_CENTER : |
465 | xdelta = 0 + (s_width - xpos) / 2; | |
5c1bfc5d | 466 | break; |
5526e819 VS |
467 | } |
468 | if (xdelta < 0) xdelta = 0; | |
469 | xdelta += s_indent; | |
470 | ||
471 | ypos += ysizeup; | |
04dbb646 | 472 | |
5c1bfc5d | 473 | if (m_AlignHor != wxHTML_ALIGN_JUSTIFY || cell == NULL) |
04dbb646 | 474 | while (line != cell) |
0cb9cfb2 | 475 | { |
04dbb646 | 476 | line->SetPos(line->GetPosX() + xdelta, |
4f9297b0 VS |
477 | ypos + line->GetPosY()); |
478 | line = line->GetNext(); | |
5c1bfc5d VS |
479 | } |
480 | else | |
04dbb646 | 481 | { |
5c1bfc5d VS |
482 | int counter = 0; |
483 | int step = (s_width - xpos); | |
484 | if (step < 0) step = 0; | |
c1e5e881 | 485 | xcnt--; |
04dbb646 | 486 | if (xcnt > 0) while (line != cell) |
0cb9cfb2 | 487 | { |
4f9297b0 | 488 | line->SetPos(line->GetPosX() + s_indent + |
5c1bfc5d | 489 | (counter++ * step / xcnt), |
4f9297b0 VS |
490 | ypos + line->GetPosY()); |
491 | line = line->GetNext(); | |
5c1bfc5d | 492 | } |
c1e5e881 | 493 | xcnt++; |
5526e819 VS |
494 | } |
495 | ||
496 | ypos += ysizedown; | |
5c1bfc5d | 497 | xpos = xcnt = 0; |
5526e819 VS |
498 | ysizeup = ysizedown = 0; |
499 | line = cell; | |
500 | } | |
501 | } | |
502 | ||
503 | // setup height & width, depending on container layout: | |
504 | m_Height = ypos + (ysizedown + ysizeup) + m_IndentBottom; | |
505 | ||
04dbb646 | 506 | if (m_Height < m_MinHeight) |
4f9297b0 | 507 | { |
04dbb646 | 508 | if (m_MinHeightAlign != wxHTML_ALIGN_TOP) |
0cb9cfb2 | 509 | { |
5526e819 | 510 | int diff = m_MinHeight - m_Height; |
efba2b89 | 511 | if (m_MinHeightAlign == wxHTML_ALIGN_CENTER) diff /= 2; |
5526e819 | 512 | cell = m_Cells; |
04dbb646 | 513 | while (cell) |
0cb9cfb2 | 514 | { |
4f9297b0 VS |
515 | cell->SetPos(cell->GetPosX(), cell->GetPosY() + diff); |
516 | cell = cell->GetNext(); | |
5526e819 VS |
517 | } |
518 | } | |
519 | m_Height = m_MinHeight; | |
520 | } | |
521 | ||
5c1bfc5d VS |
522 | MaxLineWidth += s_indent + ((m_IndentRight < 0) ? (-m_IndentRight * m_Width / 100) : m_IndentRight); |
523 | if (m_Width < MaxLineWidth) m_Width = MaxLineWidth; | |
5526e819 | 524 | |
5660c520 | 525 | m_LastLayout = w; |
5526e819 VS |
526 | } |
527 | ||
36c4ff4d VS |
528 | void wxHtmlContainerCell::UpdateRenderingStatePre(wxHtmlRenderingState& state, |
529 | wxHtmlCell *cell) const | |
530 | { | |
531 | wxHtmlSelection *s = state.GetSelection(); | |
532 | if (!s) return; | |
cd275246 | 533 | if (s->GetFromCell() == cell || s->GetToCell() == cell) |
36c4ff4d VS |
534 | { |
535 | state.SetSelectionState(wxHTML_SEL_CHANGING); | |
536 | } | |
537 | } | |
538 | ||
539 | void wxHtmlContainerCell::UpdateRenderingStatePost(wxHtmlRenderingState& state, | |
540 | wxHtmlCell *cell) const | |
541 | { | |
542 | wxHtmlSelection *s = state.GetSelection(); | |
543 | if (!s) return; | |
adf2eb2d | 544 | if (s->GetToCell() == cell) |
36c4ff4d | 545 | state.SetSelectionState(wxHTML_SEL_OUT); |
adf2eb2d VS |
546 | else if (s->GetFromCell() == cell) |
547 | state.SetSelectionState(wxHTML_SEL_IN); | |
36c4ff4d | 548 | } |
5526e819 VS |
549 | |
550 | #define mMin(a, b) (((a) < (b)) ? (a) : (b)) | |
551 | #define mMax(a, b) (((a) < (b)) ? (b) : (a)) | |
552 | ||
36c4ff4d VS |
553 | void wxHtmlContainerCell::Draw(wxDC& dc, int x, int y, int view_y1, int view_y2, |
554 | wxHtmlRenderingState& state) | |
5526e819 | 555 | { |
94bc8b14 VS |
556 | // container visible, draw it: |
557 | if ((y + m_PosY <= view_y2) && (y + m_PosY + m_Height > view_y1)) | |
4f9297b0 | 558 | { |
04dbb646 | 559 | if (m_UseBkColour) |
0cb9cfb2 | 560 | { |
5526e819 VS |
561 | wxBrush myb = wxBrush(m_BkColour, wxSOLID); |
562 | ||
563 | int real_y1 = mMax(y + m_PosY, view_y1); | |
564 | int real_y2 = mMin(y + m_PosY + m_Height - 1, view_y2); | |
565 | ||
566 | dc.SetBrush(myb); | |
567 | dc.SetPen(*wxTRANSPARENT_PEN); | |
568 | dc.DrawRectangle(x + m_PosX, real_y1, m_Width, real_y2 - real_y1 + 1); | |
569 | } | |
570 | ||
04dbb646 | 571 | if (m_UseBorder) |
0cb9cfb2 | 572 | { |
5526e819 VS |
573 | wxPen mypen1(m_BorderColour1, 1, wxSOLID); |
574 | wxPen mypen2(m_BorderColour2, 1, wxSOLID); | |
575 | ||
576 | dc.SetPen(mypen1); | |
577 | dc.DrawLine(x + m_PosX, y + m_PosY, x + m_PosX, y + m_PosY + m_Height - 1); | |
5f265f87 | 578 | dc.DrawLine(x + m_PosX, y + m_PosY, x + m_PosX + m_Width, y + m_PosY); |
5526e819 VS |
579 | dc.SetPen(mypen2); |
580 | dc.DrawLine(x + m_PosX + m_Width - 1, y + m_PosY, x + m_PosX + m_Width - 1, y + m_PosY + m_Height - 1); | |
5f265f87 | 581 | dc.DrawLine(x + m_PosX, y + m_PosY + m_Height - 1, x + m_PosX + m_Width, y + m_PosY + m_Height - 1); |
5526e819 VS |
582 | } |
583 | ||
d699f48b | 584 | if (m_Cells) |
bf7d7ee7 | 585 | { |
36c4ff4d | 586 | // draw container's contents: |
bf7d7ee7 | 587 | for (wxHtmlCell *cell = m_Cells; cell; cell = cell->GetNext()) |
36c4ff4d VS |
588 | { |
589 | UpdateRenderingStatePre(state, cell); | |
590 | cell->Draw(dc, | |
591 | x + m_PosX, y + m_PosY, view_y1, view_y2, | |
592 | state); | |
593 | UpdateRenderingStatePost(state, cell); | |
594 | } | |
bf7d7ee7 | 595 | } |
5526e819 VS |
596 | } |
597 | // container invisible, just proceed font+color changing: | |
04dbb646 | 598 | else |
4f9297b0 | 599 | { |
36c4ff4d | 600 | DrawInvisible(dc, x, y, state); |
5526e819 | 601 | } |
5526e819 VS |
602 | } |
603 | ||
604 | ||
605 | ||
36c4ff4d VS |
606 | void wxHtmlContainerCell::DrawInvisible(wxDC& dc, int x, int y, |
607 | wxHtmlRenderingState& state) | |
5526e819 | 608 | { |
d699f48b | 609 | if (m_Cells) |
bf7d7ee7 VS |
610 | { |
611 | for (wxHtmlCell *cell = m_Cells; cell; cell = cell->GetNext()) | |
36c4ff4d VS |
612 | { |
613 | UpdateRenderingStatePre(state, cell); | |
614 | cell->DrawInvisible(dc, x + m_PosX, y + m_PosY, state); | |
615 | UpdateRenderingStatePost(state, cell); | |
616 | } | |
bf7d7ee7 | 617 | } |
5526e819 VS |
618 | } |
619 | ||
620 | ||
2b5f62a0 VZ |
621 | wxColour wxHtmlContainerCell::GetBackgroundColour() |
622 | { | |
623 | if (m_UseBkColour) | |
624 | return m_BkColour; | |
625 | else | |
626 | return wxNullColour; | |
627 | } | |
628 | ||
629 | ||
5526e819 | 630 | |
846914d1 | 631 | wxHtmlLinkInfo *wxHtmlContainerCell::GetLink(int x, int y) const |
5526e819 | 632 | { |
f6010d8f | 633 | wxHtmlCell *cell = FindCellByPos(x, y); |
5526e819 | 634 | |
f6010d8f VZ |
635 | // VZ: I don't know if we should pass absolute or relative coords to |
636 | // wxHtmlCell::GetLink()? As the base class version just ignores them | |
637 | // anyhow, it hardly matters right now but should still be clarified | |
638 | return cell ? cell->GetLink(x, y) : NULL; | |
5526e819 VS |
639 | } |
640 | ||
641 | ||
642 | ||
643 | void wxHtmlContainerCell::InsertCell(wxHtmlCell *f) | |
644 | { | |
645 | if (!m_Cells) m_Cells = m_LastCell = f; | |
04dbb646 | 646 | else |
4f9297b0 VS |
647 | { |
648 | m_LastCell->SetNext(f); | |
5526e819 | 649 | m_LastCell = f; |
4f9297b0 | 650 | if (m_LastCell) while (m_LastCell->GetNext()) m_LastCell = m_LastCell->GetNext(); |
5526e819 | 651 | } |
4f9297b0 | 652 | f->SetParent(this); |
5660c520 | 653 | m_LastLayout = -1; |
5526e819 VS |
654 | } |
655 | ||
656 | ||
657 | ||
658 | void wxHtmlContainerCell::SetAlign(const wxHtmlTag& tag) | |
659 | { | |
04dbb646 | 660 | if (tag.HasParam(wxT("ALIGN"))) |
4f9297b0 | 661 | { |
0413cec5 | 662 | wxString alg = tag.GetParam(wxT("ALIGN")); |
5526e819 | 663 | alg.MakeUpper(); |
0413cec5 | 664 | if (alg == wxT("CENTER")) |
efba2b89 | 665 | SetAlignHor(wxHTML_ALIGN_CENTER); |
0413cec5 | 666 | else if (alg == wxT("LEFT")) |
efba2b89 | 667 | SetAlignHor(wxHTML_ALIGN_LEFT); |
5c1bfc5d VS |
668 | else if (alg == wxT("JUSTIFY")) |
669 | SetAlignHor(wxHTML_ALIGN_JUSTIFY); | |
0413cec5 | 670 | else if (alg == wxT("RIGHT")) |
efba2b89 | 671 | SetAlignHor(wxHTML_ALIGN_RIGHT); |
5660c520 | 672 | m_LastLayout = -1; |
5526e819 VS |
673 | } |
674 | } | |
675 | ||
676 | ||
677 | ||
edbd0635 | 678 | void wxHtmlContainerCell::SetWidthFloat(const wxHtmlTag& tag, double pixel_scale) |
5526e819 | 679 | { |
04dbb646 | 680 | if (tag.HasParam(wxT("WIDTH"))) |
4f9297b0 | 681 | { |
5526e819 | 682 | int wdi; |
0413cec5 | 683 | wxString wd = tag.GetParam(wxT("WIDTH")); |
5526e819 | 684 | |
04dbb646 | 685 | if (wd[wd.Length()-1] == wxT('%')) |
0cb9cfb2 | 686 | { |
66a77a74 | 687 | wxSscanf(wd.c_str(), wxT("%i%%"), &wdi); |
efba2b89 | 688 | SetWidthFloat(wdi, wxHTML_UNITS_PERCENT); |
5526e819 | 689 | } |
04dbb646 | 690 | else |
0cb9cfb2 | 691 | { |
66a77a74 | 692 | wxSscanf(wd.c_str(), wxT("%i"), &wdi); |
edbd0635 | 693 | SetWidthFloat((int)(pixel_scale * (double)wdi), wxHTML_UNITS_PIXELS); |
5526e819 | 694 | } |
5660c520 | 695 | m_LastLayout = -1; |
5526e819 VS |
696 | } |
697 | } | |
698 | ||
699 | ||
700 | ||
701 | const wxHtmlCell* wxHtmlContainerCell::Find(int condition, const void* param) const | |
702 | { | |
04dbb646 | 703 | if (m_Cells) |
d699f48b | 704 | { |
bf7d7ee7 | 705 | const wxHtmlCell *r = NULL; |
5526e819 | 706 | |
bf7d7ee7 VS |
707 | for (wxHtmlCell *cell = m_Cells; cell; cell = cell->GetNext()) |
708 | { | |
709 | r = cell->Find(condition, param); | |
710 | if (r) return r; | |
711 | } | |
712 | } | |
713 | return NULL; | |
5526e819 VS |
714 | } |
715 | ||
716 | ||
36c4ff4d VS |
717 | wxHtmlCell *wxHtmlContainerCell::FindCellByPos(wxCoord x, wxCoord y, |
718 | unsigned flags) const | |
5526e819 | 719 | { |
6d41981d | 720 | if ( flags & wxHTML_FIND_EXACT ) |
4f9297b0 | 721 | { |
adf2eb2d VS |
722 | for ( const wxHtmlCell *cell = m_Cells; cell; cell = cell->GetNext() ) |
723 | { | |
724 | int cx = cell->GetPosX(), | |
725 | cy = cell->GetPosY(); | |
726 | ||
727 | if ( (cx <= x) && (cx + cell->GetWidth() > x) && | |
728 | (cy <= y) && (cy + cell->GetHeight() > y) ) | |
729 | { | |
730 | return cell->FindCellByPos(x - cx, y - cy, flags); | |
731 | } | |
732 | } | |
adf2eb2d | 733 | } |
6d41981d | 734 | else if ( flags & wxHTML_FIND_NEAREST_AFTER ) |
adf2eb2d VS |
735 | { |
736 | wxHtmlCell *c; | |
737 | int y2; | |
738 | for ( const wxHtmlCell *cell = m_Cells; cell; cell = cell->GetNext() ) | |
0cb9cfb2 | 739 | { |
adf2eb2d VS |
740 | y2 = cell->GetPosY() + cell->GetHeight() - 1; |
741 | if (y2 < y || (y2 == y && cell->GetPosX()+cell->GetWidth()-1 < x)) | |
742 | continue; | |
743 | c = cell->FindCellByPos(x - cell->GetPosX(), y - cell->GetPosY(), | |
744 | flags); | |
745 | if (c) return c; | |
5526e819 VS |
746 | } |
747 | } | |
6d41981d | 748 | else if ( flags & wxHTML_FIND_NEAREST_BEFORE ) |
adf2eb2d | 749 | { |
e24529d7 | 750 | wxHtmlCell *c2, *c = NULL; |
adf2eb2d VS |
751 | for ( const wxHtmlCell *cell = m_Cells; cell; cell = cell->GetNext() ) |
752 | { | |
753 | if (cell->GetPosY() > y || | |
754 | (cell->GetPosY() == y && cell->GetPosX() > x)) | |
755 | break; | |
e24529d7 VS |
756 | c2 = cell->FindCellByPos(x - cell->GetPosX(), y - cell->GetPosY(), |
757 | flags); | |
758 | if (c2) | |
759 | c = c2; | |
adf2eb2d | 760 | } |
e24529d7 | 761 | if (c) return c; |
adf2eb2d | 762 | } |
6d41981d VZ |
763 | |
764 | return NULL; | |
f6010d8f VZ |
765 | } |
766 | ||
767 | ||
768 | void wxHtmlContainerCell::OnMouseClick(wxWindow *parent, int x, int y, const wxMouseEvent& event) | |
769 | { | |
770 | wxHtmlCell *cell = FindCellByPos(x, y); | |
771 | if ( cell ) | |
772 | cell->OnMouseClick(parent, x, y, event); | |
5526e819 VS |
773 | } |
774 | ||
775 | ||
776 | ||
79d6c018 VS |
777 | void wxHtmlContainerCell::GetHorizontalConstraints(int *left, int *right) const |
778 | { | |
779 | int cleft = m_PosX + m_Width, cright = m_PosX; // worst case | |
780 | int l, r; | |
0cb9cfb2 | 781 | |
79d6c018 VS |
782 | for (wxHtmlCell *cell = m_Cells; cell; cell = cell->GetNext()) |
783 | { | |
784 | cell->GetHorizontalConstraints(&l, &r); | |
785 | if (l < cleft) | |
786 | cleft = l; | |
787 | if (r > cright) | |
788 | cright = r; | |
0cb9cfb2 | 789 | } |
79d6c018 | 790 | |
026d1fac VS |
791 | cleft -= (m_IndentLeft < 0) ? (-m_IndentLeft * m_Width / 100) : m_IndentLeft; |
792 | cright += (m_IndentRight < 0) ? (-m_IndentRight * m_Width / 100) : m_IndentRight; | |
793 | ||
79d6c018 VS |
794 | if (left) |
795 | *left = cleft; | |
796 | if (right) | |
797 | *right = cright; | |
798 | } | |
799 | ||
adf2eb2d VS |
800 | |
801 | wxHtmlCell *wxHtmlContainerCell::GetFirstTerminal() const | |
802 | { | |
e3774124 VS |
803 | if ( m_Cells ) |
804 | { | |
805 | wxHtmlCell *c2; | |
806 | for (wxHtmlCell *c = m_Cells; c; c = c->GetNext()) | |
807 | { | |
808 | c2 = c->GetFirstTerminal(); | |
809 | if ( c2 ) | |
810 | return c2; | |
811 | } | |
812 | } | |
813 | return NULL; | |
adf2eb2d VS |
814 | } |
815 | ||
816 | wxHtmlCell *wxHtmlContainerCell::GetLastTerminal() const | |
817 | { | |
e3774124 | 818 | if ( m_Cells ) |
adf2eb2d | 819 | { |
e3774124 | 820 | // most common case first: |
4ce19ed7 | 821 | wxHtmlCell *c = m_LastCell->GetLastTerminal(); |
e3774124 VS |
822 | if ( c ) |
823 | return c; | |
4ce19ed7 VZ |
824 | |
825 | wxHtmlCell *c2 = NULL; | |
826 | for (c = m_Cells; c; c = c->GetNext()) | |
e3774124 VS |
827 | c2 = c->GetLastTerminal(); |
828 | return c2; | |
adf2eb2d VS |
829 | } |
830 | else | |
831 | return NULL; | |
832 | } | |
79d6c018 VS |
833 | |
834 | ||
5526e819 VS |
835 | |
836 | ||
36c4ff4d | 837 | // -------------------------------------------------------------------------- |
5526e819 | 838 | // wxHtmlColourCell |
36c4ff4d | 839 | // -------------------------------------------------------------------------- |
5526e819 | 840 | |
36c4ff4d VS |
841 | void wxHtmlColourCell::Draw(wxDC& dc, |
842 | int x, int y, | |
843 | int WXUNUSED(view_y1), int WXUNUSED(view_y2), | |
844 | wxHtmlRenderingState& state) | |
5526e819 | 845 | { |
36c4ff4d | 846 | DrawInvisible(dc, x, y, state); |
5526e819 VS |
847 | } |
848 | ||
36c4ff4d VS |
849 | void wxHtmlColourCell::DrawInvisible(wxDC& dc, |
850 | int WXUNUSED(x), int WXUNUSED(y), | |
851 | wxHtmlRenderingState& state) | |
5526e819 | 852 | { |
efba2b89 | 853 | if (m_Flags & wxHTML_CLR_FOREGROUND) |
36c4ff4d VS |
854 | { |
855 | state.SetFgColour(m_Colour); | |
856 | if (state.GetSelectionState() != wxHTML_SEL_IN) | |
857 | dc.SetTextForeground(m_Colour); | |
858 | } | |
04dbb646 | 859 | if (m_Flags & wxHTML_CLR_BACKGROUND) |
4f9297b0 | 860 | { |
36c4ff4d VS |
861 | state.SetBgColour(m_Colour); |
862 | if (state.GetSelectionState() != wxHTML_SEL_IN) | |
863 | dc.SetTextBackground(m_Colour); | |
5526e819 | 864 | dc.SetBackground(wxBrush(m_Colour, wxSOLID)); |
5526e819 | 865 | } |
5526e819 VS |
866 | } |
867 | ||
868 | ||
869 | ||
870 | ||
36c4ff4d | 871 | // --------------------------------------------------------------------------- |
5526e819 | 872 | // wxHtmlFontCell |
36c4ff4d | 873 | // --------------------------------------------------------------------------- |
5526e819 | 874 | |
36c4ff4d VS |
875 | void wxHtmlFontCell::Draw(wxDC& dc, |
876 | int WXUNUSED(x), int WXUNUSED(y), | |
877 | int WXUNUSED(view_y1), int WXUNUSED(view_y2), | |
878 | wxHtmlRenderingState& WXUNUSED(state)) | |
5526e819 | 879 | { |
921d0fb1 | 880 | dc.SetFont(m_Font); |
5526e819 VS |
881 | } |
882 | ||
36c4ff4d VS |
883 | void wxHtmlFontCell::DrawInvisible(wxDC& dc, int WXUNUSED(x), int WXUNUSED(y), |
884 | wxHtmlRenderingState& WXUNUSED(state)) | |
5526e819 | 885 | { |
921d0fb1 | 886 | dc.SetFont(m_Font); |
5526e819 VS |
887 | } |
888 | ||
889 | ||
890 | ||
891 | ||
892 | ||
893 | ||
894 | ||
895 | ||
36c4ff4d | 896 | // --------------------------------------------------------------------------- |
5526e819 | 897 | // wxHtmlWidgetCell |
36c4ff4d | 898 | // --------------------------------------------------------------------------- |
5526e819 VS |
899 | |
900 | wxHtmlWidgetCell::wxHtmlWidgetCell(wxWindow *wnd, int w) | |
901 | { | |
902 | int sx, sy; | |
903 | m_Wnd = wnd; | |
4f9297b0 | 904 | m_Wnd->GetSize(&sx, &sy); |
5526e819 VS |
905 | m_Width = sx, m_Height = sy; |
906 | m_WidthFloat = w; | |
907 | } | |
908 | ||
909 | ||
36c4ff4d VS |
910 | void wxHtmlWidgetCell::Draw(wxDC& WXUNUSED(dc), |
911 | int WXUNUSED(x), int WXUNUSED(y), | |
912 | int WXUNUSED(view_y1), int WXUNUSED(view_y2), | |
913 | wxHtmlRenderingState& WXUNUSED(state)) | |
5526e819 VS |
914 | { |
915 | int absx = 0, absy = 0, stx, sty; | |
916 | wxHtmlCell *c = this; | |
917 | ||
04dbb646 | 918 | while (c) |
4f9297b0 VS |
919 | { |
920 | absx += c->GetPosX(); | |
921 | absy += c->GetPosY(); | |
922 | c = c->GetParent(); | |
5526e819 VS |
923 | } |
924 | ||
e421922f | 925 | ((wxScrolledWindow*)(m_Wnd->GetParent()))->GetViewStart(&stx, &sty); |
4f9297b0 | 926 | m_Wnd->SetSize(absx - wxHTML_SCROLL_STEP * stx, absy - wxHTML_SCROLL_STEP * sty, m_Width, m_Height); |
5526e819 VS |
927 | } |
928 | ||
929 | ||
930 | ||
36c4ff4d VS |
931 | void wxHtmlWidgetCell::DrawInvisible(wxDC& WXUNUSED(dc), |
932 | int WXUNUSED(x), int WXUNUSED(y), | |
933 | wxHtmlRenderingState& WXUNUSED(state)) | |
5526e819 VS |
934 | { |
935 | int absx = 0, absy = 0, stx, sty; | |
936 | wxHtmlCell *c = this; | |
937 | ||
04dbb646 | 938 | while (c) |
4f9297b0 VS |
939 | { |
940 | absx += c->GetPosX(); | |
941 | absy += c->GetPosY(); | |
942 | c = c->GetParent(); | |
5526e819 | 943 | } |
7e941458 | 944 | |
e421922f | 945 | ((wxScrolledWindow*)(m_Wnd->GetParent()))->GetViewStart(&stx, &sty); |
4f9297b0 | 946 | m_Wnd->SetSize(absx - wxHTML_SCROLL_STEP * stx, absy - wxHTML_SCROLL_STEP * sty, m_Width, m_Height); |
5526e819 VS |
947 | } |
948 | ||
949 | ||
950 | ||
951 | void wxHtmlWidgetCell::Layout(int w) | |
952 | { | |
04dbb646 | 953 | if (m_WidthFloat != 0) |
4f9297b0 | 954 | { |
5526e819 | 955 | m_Width = (w * m_WidthFloat) / 100; |
4f9297b0 | 956 | m_Wnd->SetSize(m_Width, m_Height); |
5526e819 VS |
957 | } |
958 | ||
959 | wxHtmlCell::Layout(w); | |
960 | } | |
961 | ||
e3774124 VS |
962 | |
963 | ||
964 | // ---------------------------------------------------------------------------- | |
965 | // wxHtmlTerminalCellsInterator | |
966 | // ---------------------------------------------------------------------------- | |
967 | ||
968 | const wxHtmlCell* wxHtmlTerminalCellsInterator::operator++() | |
969 | { | |
970 | if ( !m_pos ) | |
971 | return NULL; | |
972 | ||
973 | do | |
974 | { | |
975 | if ( m_pos == m_to ) | |
976 | { | |
977 | m_pos = NULL; | |
978 | return NULL; | |
979 | } | |
980 | ||
981 | if ( m_pos->GetNext() ) | |
982 | m_pos = m_pos->GetNext(); | |
983 | else | |
984 | { | |
985 | // we must go up the hierarchy until we reach container where this | |
986 | // is not the last child, and then go down to first terminal cell: | |
987 | while ( m_pos->GetNext() == NULL ) | |
988 | { | |
989 | m_pos = m_pos->GetParent(); | |
990 | if ( !m_pos ) | |
991 | return NULL; | |
992 | } | |
993 | m_pos = m_pos->GetNext(); | |
994 | } | |
995 | while ( m_pos->GetFirstChild() != NULL ) | |
996 | m_pos = m_pos->GetFirstChild(); | |
997 | } while ( !m_pos->IsTerminalCell() ); | |
998 | ||
999 | return m_pos; | |
1000 | } | |
1001 | ||
5526e819 | 1002 | #endif |