]> git.saurik.com Git - wxWidgets.git/blob - src/html/htmlcell.cpp
moved bookmarks to Contents panel
[wxWidgets.git] / src / html / htmlcell.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: htmlcell.cpp
3 // Purpose: wxHtmlCell - basic element of HTML output
4 // Author: Vaclav Slavik
5 // RCS-ID: $Id$
6 // Copyright: (c) 1999 Vaclav Slavik
7 // Licence: wxWindows Licence
8 /////////////////////////////////////////////////////////////////////////////
9
10 #ifdef __GNUG__
11 #pragma implementation
12 #endif
13
14 #include "wx/wxprec.h"
15
16 #include "wx/defs.h"
17 #if wxUSE_HTML
18
19 #ifdef __BORDLANDC__
20 #pragma hdrstop
21 #endif
22
23 #ifndef WXPRECOMP
24 #include "wx/wx.h"
25 #endif
26
27 #include "wx/html/htmlcell.h"
28 #include "wx/html/htmlwin.h"
29 #include <stdlib.h>
30
31
32 //-----------------------------------------------------------------------------
33 // wxHtmlCell
34 //-----------------------------------------------------------------------------
35
36 wxHtmlCell::wxHtmlCell() : wxObject()
37 {
38 m_Next = NULL;
39 m_Parent = NULL;
40 m_Width = m_Height = m_Descent = 0;
41 m_CanLiveOnPagebreak = TRUE;
42 m_Link = NULL;
43 }
44
45 wxHtmlCell::~wxHtmlCell()
46 {
47 if (m_Link) delete m_Link;
48 if (m_Next) delete m_Next;
49 }
50
51
52 void wxHtmlCell::OnMouseClick(wxWindow *parent, int x, int y,
53 const wxMouseEvent& event)
54 {
55 wxHtmlLinkInfo *lnk = GetLink(x, y);
56 if (lnk != NULL)
57 {
58 wxHtmlLinkInfo lnk2(*lnk);
59 lnk2.SetEvent(&event);
60 lnk2.SetHtmlCell(this);
61 ((wxHtmlWindow*)parent) -> OnLinkClicked(lnk2);
62 // note : this overcasting is legal because parent is *always* wxHtmlWindow
63 }
64 }
65
66
67
68 bool wxHtmlCell::AdjustPagebreak(int *pagebreak) const
69 {
70 if ((!m_CanLiveOnPagebreak) &&
71 m_PosY < *pagebreak && m_PosY + m_Height > *pagebreak) {
72 *pagebreak = m_PosY;
73 if (m_Next != NULL) m_Next -> AdjustPagebreak(pagebreak);
74 return TRUE;
75 }
76
77 else {
78 if (m_Next != NULL) return m_Next -> AdjustPagebreak(pagebreak);
79 else return FALSE;
80 }
81 }
82
83
84
85 void wxHtmlCell::SetLink(const wxHtmlLinkInfo& link)
86 {
87 if (m_Link) delete m_Link;
88 m_Link = NULL;
89 if (link.GetHref() != wxEmptyString)
90 m_Link = new wxHtmlLinkInfo(link);
91 }
92
93
94
95 //-----------------------------------------------------------------------------
96 // wxHtmlWordCell
97 //-----------------------------------------------------------------------------
98
99 wxHtmlWordCell::wxHtmlWordCell(const wxString& word, wxDC& dc) : wxHtmlCell()
100 {
101 m_Word = word;
102
103 if (m_Word.Find(wxT('&')) != -1)
104 {
105 #define ESCSEQ(escape, subst) \
106 { wxT("&"escape";"), wxT("&"escape" "), wxT(subst) }
107 static wxChar* substitutions[][3] =
108 {
109 ESCSEQ("quot", "\""),
110 ESCSEQ("lt", "<"),
111 ESCSEQ("gt", ">"),
112
113 ESCSEQ("nbsp", " "),
114 ESCSEQ("iexcl", "!"),
115 ESCSEQ("cent", "¢"),
116
117 ESCSEQ("yen", " "),
118 ESCSEQ("brkbar", " "),
119 ESCSEQ("sect", " "),
120 ESCSEQ("uml", " "),
121
122 ESCSEQ("copy", "(c)"),
123 ESCSEQ("ordf", " "),
124 ESCSEQ("laquo", " "),
125 ESCSEQ("not", " "),
126
127 ESCSEQ("reg", "(r)"),
128
129 ESCSEQ("deg", " "),
130 ESCSEQ("plusm", " "),
131
132 ESCSEQ("acute", " "),
133 ESCSEQ("micro", " "),
134 ESCSEQ("para", " "),
135
136 ESCSEQ("ordm", " "),
137 ESCSEQ("raquo", " "),
138
139 ESCSEQ("iquest", " "),
140 ESCSEQ("Agrave", "À"),
141
142 ESCSEQ("Acirc", "Â"),
143 ESCSEQ("Atilde", "Ã"),
144 ESCSEQ("Auml", "Ä"),
145 ESCSEQ("Aring", " "),
146 ESCSEQ("AElig", " "),
147 ESCSEQ("Ccedil", "ç"),
148 ESCSEQ("Egrave", "È"),
149 ESCSEQ("Eacute", "É"),
150 ESCSEQ("Ecirc", "Ê"),
151 ESCSEQ("Euml", "Ë"),
152 ESCSEQ("Igrave", "Ì"),
153
154 ESCSEQ("Icirc", "Î"),
155 ESCSEQ("Iuml", "Ï"),
156
157 ESCSEQ("Ntilde", "Ñ"),
158 ESCSEQ("Ograve", "Ò"),
159
160 ESCSEQ("Ocirc", "Ô"),
161 ESCSEQ("Otilde", "Õ"),
162 ESCSEQ("Ouml", "Ö"),
163
164 ESCSEQ("Oslash", " "),
165 ESCSEQ("Ugrave", "Ù"),
166
167 ESCSEQ("Ucirc", " "),
168 ESCSEQ("Uuml", "Ü"),
169
170 ESCSEQ("szlig", "§"),
171 ESCSEQ("agrave;","à"),
172 ESCSEQ("aacute", "á"),
173 ESCSEQ("acirc", "â"),
174 ESCSEQ("atilde", "ã"),
175 ESCSEQ("auml", "ä"),
176 ESCSEQ("aring", "a"),
177 ESCSEQ("aelig", "ae"),
178 ESCSEQ("ccedil", "ç"),
179 ESCSEQ("egrave", "è"),
180 ESCSEQ("eacute", "é"),
181 ESCSEQ("ecirc", "ê"),
182 ESCSEQ("euml", "ë"),
183 ESCSEQ("igrave", "ì"),
184 ESCSEQ("iacute", "í"),
185 ESCSEQ("icirc", " "),
186 ESCSEQ("iuml", "ï"),
187 ESCSEQ("eth", " "),
188 ESCSEQ("ntilde", "ñ"),
189 ESCSEQ("ograve", "ò"),
190 ESCSEQ("oacute", "ó"),
191 ESCSEQ("ocirc", "ô"),
192 ESCSEQ("otilde", "õ"),
193 ESCSEQ("ouml", "ö"),
194 ESCSEQ("divide", " "),
195 ESCSEQ("oslash", " "),
196 ESCSEQ("ugrave", "ù"),
197 ESCSEQ("uacute", "ú"),
198 ESCSEQ("ucirc", "û"),
199 ESCSEQ("uuml", "ü"),
200
201 ESCSEQ("yuml", ""),
202
203 /* this one should ALWAYS stay the last one!!! */
204 ESCSEQ("amp", "&"),
205
206 { NULL, NULL, NULL }
207 };
208
209 for (int i = 0; substitutions[i][0] != NULL; i++)
210 {
211 m_Word.Replace(substitutions[i][0], substitutions[i][2], TRUE);
212 m_Word.Replace(substitutions[i][1], substitutions[i][2], TRUE);
213 }
214 }
215
216 dc.GetTextExtent(m_Word, &m_Width, &m_Height, &m_Descent);
217 SetCanLiveOnPagebreak(FALSE);
218 }
219
220
221
222 void wxHtmlWordCell::Draw(wxDC& dc, int x, int y, int view_y1, int view_y2)
223 {
224 dc.DrawText(m_Word, x + m_PosX, y + m_PosY);
225 wxHtmlCell::Draw(dc, x, y, view_y1, view_y2);
226 }
227
228
229
230 //-----------------------------------------------------------------------------
231 // wxHtmlContainerCell
232 //-----------------------------------------------------------------------------
233
234
235 wxHtmlContainerCell::wxHtmlContainerCell(wxHtmlContainerCell *parent) : wxHtmlCell()
236 {
237 m_Cells = m_LastCell = NULL;
238 m_Parent = parent;
239 if (m_Parent) m_Parent -> InsertCell(this);
240 m_AlignHor = wxHTML_ALIGN_LEFT;
241 m_AlignVer = wxHTML_ALIGN_BOTTOM;
242 m_IndentLeft = m_IndentRight = m_IndentTop = m_IndentBottom = 0;
243 m_WidthFloat = 100; m_WidthFloatUnits = wxHTML_UNITS_PERCENT;
244 m_UseBkColour = FALSE;
245 m_UseBorder = FALSE;
246 m_MinHeight = 0;
247 m_MinHeightAlign = wxHTML_ALIGN_TOP;
248 m_LastLayout = -1;
249 }
250
251
252
253 void wxHtmlContainerCell::SetIndent(int i, int what, int units)
254 {
255 int val = (units == wxHTML_UNITS_PIXELS) ? i : -i;
256 if (what & wxHTML_INDENT_LEFT) m_IndentLeft = val;
257 if (what & wxHTML_INDENT_RIGHT) m_IndentRight = val;
258 if (what & wxHTML_INDENT_TOP) m_IndentTop = val;
259 if (what & wxHTML_INDENT_BOTTOM) m_IndentBottom = val;
260 m_LastLayout = -1;
261 }
262
263
264
265 int wxHtmlContainerCell::GetIndent(int ind) const
266 {
267 if (ind & wxHTML_INDENT_LEFT) return m_IndentLeft;
268 else if (ind & wxHTML_INDENT_RIGHT) return m_IndentRight;
269 else if (ind & wxHTML_INDENT_TOP) return m_IndentTop;
270 else if (ind & wxHTML_INDENT_BOTTOM) return m_IndentBottom;
271 else return -1; /* BUG! Should not be called... */
272 }
273
274
275
276
277 int wxHtmlContainerCell::GetIndentUnits(int ind) const
278 {
279 bool p = FALSE;
280 if (ind & wxHTML_INDENT_LEFT) p = m_IndentLeft < 0;
281 else if (ind & wxHTML_INDENT_RIGHT) p = m_IndentRight < 0;
282 else if (ind & wxHTML_INDENT_TOP) p = m_IndentTop < 0;
283 else if (ind & wxHTML_INDENT_BOTTOM) p = m_IndentBottom < 0;
284 if (p) return wxHTML_UNITS_PERCENT;
285 else return wxHTML_UNITS_PIXELS;
286 }
287
288
289
290 bool wxHtmlContainerCell::AdjustPagebreak(int *pagebreak) const
291 {
292 if (!m_CanLiveOnPagebreak)
293 return wxHtmlCell::AdjustPagebreak(pagebreak);
294
295 else {
296 wxHtmlCell *c = GetFirstCell();
297 bool rt = FALSE;
298 int pbrk = *pagebreak - m_PosY;
299
300 while (c) {
301 if (c -> AdjustPagebreak(&pbrk)) rt = TRUE;
302 c = c -> GetNext();
303 }
304 if (rt) *pagebreak = pbrk + m_PosY;
305 return rt;
306 }
307 }
308
309
310
311 void wxHtmlContainerCell::Layout(int w)
312 {
313 if (m_LastLayout == w) {
314 wxHtmlCell::Layout(w);
315 return;
316 }
317
318 wxHtmlCell *cell = m_Cells, *line = m_Cells;
319 long xpos = 0, ypos = m_IndentTop;
320 int xdelta = 0, ybasicpos = 0, ydiff;
321 int s_width, s_indent;
322 int ysizeup = 0, ysizedown = 0;
323 int MaxLineWidth = 0;
324 int xcnt = 0;
325
326
327 /*
328
329 WIDTH ADJUSTING :
330
331 */
332
333 if (m_WidthFloatUnits == wxHTML_UNITS_PERCENT) {
334 if (m_WidthFloat < 0) m_Width = (100 + m_WidthFloat) * w / 100;
335 else m_Width = m_WidthFloat * w / 100;
336 }
337 else {
338 if (m_WidthFloat < 0) m_Width = w + m_WidthFloat;
339 else m_Width = m_WidthFloat;
340 }
341
342 if (m_Cells) {
343 int l = (m_IndentLeft < 0) ? (-m_IndentLeft * m_Width / 100) : m_IndentLeft;
344 int r = (m_IndentRight < 0) ? (-m_IndentRight * m_Width / 100) : m_IndentRight;
345 m_Cells -> Layout(m_Width - (l + r));
346 }
347
348 /*
349
350 LAYOUTING :
351
352 */
353
354 // adjust indentation:
355 s_indent = (m_IndentLeft < 0) ? (-m_IndentLeft * m_Width / 100) : m_IndentLeft;
356 s_width = m_Width - s_indent - ((m_IndentRight < 0) ? (-m_IndentRight * m_Width / 100) : m_IndentRight);
357
358 // my own layouting:
359 while (cell != NULL) {
360 switch (m_AlignVer) {
361 case wxHTML_ALIGN_TOP : ybasicpos = 0; break;
362 case wxHTML_ALIGN_BOTTOM : ybasicpos = - cell -> GetHeight(); break;
363 case wxHTML_ALIGN_CENTER : ybasicpos = - cell -> GetHeight() / 2; break;
364 }
365 ydiff = cell -> GetHeight() + ybasicpos;
366
367 if (cell -> GetDescent() + ydiff > ysizedown) ysizedown = cell -> GetDescent() + ydiff;
368 if (ybasicpos + cell -> GetDescent() < -ysizeup) ysizeup = - (ybasicpos + cell -> GetDescent());
369
370 cell -> SetPos(xpos, ybasicpos + cell -> GetDescent());
371 xpos += cell -> GetWidth();
372 cell = cell -> GetNext();
373 xcnt++;
374
375 // force new line if occured:
376 if ((cell == NULL) || (xpos + cell -> GetWidth() > s_width)) {
377 if (xpos > MaxLineWidth) MaxLineWidth = xpos;
378 if (ysizeup < 0) ysizeup = 0;
379 if (ysizedown < 0) ysizedown = 0;
380 switch (m_AlignHor) {
381 case wxHTML_ALIGN_LEFT :
382 case wxHTML_ALIGN_JUSTIFY :
383 xdelta = 0;
384 break;
385 case wxHTML_ALIGN_RIGHT :
386 xdelta = 0 + (s_width - xpos);
387 break;
388 case wxHTML_ALIGN_CENTER :
389 xdelta = 0 + (s_width - xpos) / 2;
390 break;
391 }
392 if (xdelta < 0) xdelta = 0;
393 xdelta += s_indent;
394
395 ypos += ysizeup;
396
397 if (m_AlignHor != wxHTML_ALIGN_JUSTIFY || cell == NULL)
398 while (line != cell) {
399 line -> SetPos(line -> GetPosX() + xdelta,
400 ypos + line -> GetPosY());
401 line = line -> GetNext();
402 }
403 else
404 {
405 int counter = 0;
406 int step = (s_width - xpos);
407 if (step < 0) step = 0;
408 while (line != cell) {
409 line -> SetPos(line -> GetPosX() + s_indent +
410 (counter++ * step / xcnt),
411 ypos + line -> GetPosY());
412 line = line -> GetNext();
413 }
414 }
415
416 ypos += ysizedown;
417 xpos = xcnt = 0;
418 ysizeup = ysizedown = 0;
419 line = cell;
420 }
421 }
422
423 // setup height & width, depending on container layout:
424 m_Height = ypos + (ysizedown + ysizeup) + m_IndentBottom;
425
426 if (m_Height < m_MinHeight) {
427 if (m_MinHeightAlign != wxHTML_ALIGN_TOP) {
428 int diff = m_MinHeight - m_Height;
429 if (m_MinHeightAlign == wxHTML_ALIGN_CENTER) diff /= 2;
430 cell = m_Cells;
431 while (cell) {
432 cell -> SetPos(cell -> GetPosX(), cell -> GetPosY() + diff);
433 cell = cell -> GetNext();
434 }
435 }
436 m_Height = m_MinHeight;
437 }
438
439 MaxLineWidth += s_indent + ((m_IndentRight < 0) ? (-m_IndentRight * m_Width / 100) : m_IndentRight);
440 if (m_Width < MaxLineWidth) m_Width = MaxLineWidth;
441
442 m_LastLayout = w;
443
444 wxHtmlCell::Layout(w);
445 }
446
447
448 #define mMin(a, b) (((a) < (b)) ? (a) : (b))
449 #define mMax(a, b) (((a) < (b)) ? (b) : (a))
450
451 void wxHtmlContainerCell::Draw(wxDC& dc, int x, int y, int view_y1, int view_y2)
452 {
453 // container visible, draw it:
454 if ((y + m_PosY < view_y2) && (y + m_PosY + m_Height > view_y1)) {
455
456 if (m_UseBkColour) {
457 wxBrush myb = wxBrush(m_BkColour, wxSOLID);
458
459 int real_y1 = mMax(y + m_PosY, view_y1);
460 int real_y2 = mMin(y + m_PosY + m_Height - 1, view_y2);
461
462 dc.SetBrush(myb);
463 dc.SetPen(*wxTRANSPARENT_PEN);
464 dc.DrawRectangle(x + m_PosX, real_y1, m_Width, real_y2 - real_y1 + 1);
465 }
466
467 if (m_UseBorder) {
468 wxPen mypen1(m_BorderColour1, 1, wxSOLID);
469 wxPen mypen2(m_BorderColour2, 1, wxSOLID);
470
471 dc.SetPen(mypen1);
472 dc.DrawLine(x + m_PosX, y + m_PosY, x + m_PosX, y + m_PosY + m_Height - 1);
473 dc.DrawLine(x + m_PosX, y + m_PosY, x + m_PosX + m_Width - 1, y + m_PosY);
474 dc.SetPen(mypen2);
475 dc.DrawLine(x + m_PosX + m_Width - 1, y + m_PosY, x + m_PosX + m_Width - 1, y + m_PosY + m_Height - 1);
476 dc.DrawLine(x + m_PosX, y + m_PosY + m_Height - 1, x + m_PosX + m_Width - 1, y + m_PosY + m_Height - 1);
477 }
478
479 if (m_Cells) m_Cells -> Draw(dc, x + m_PosX, y + m_PosY, view_y1, view_y2);
480 }
481 // container invisible, just proceed font+color changing:
482 else {
483 if (m_Cells) m_Cells -> DrawInvisible(dc, x + m_PosX, y + m_PosY);
484 }
485
486 wxHtmlCell::Draw(dc, x, y, view_y1, view_y2);
487 }
488
489
490
491 void wxHtmlContainerCell::DrawInvisible(wxDC& dc, int x, int y)
492 {
493 if (m_Cells) m_Cells -> DrawInvisible(dc, x + m_PosX, y + m_PosY);
494 wxHtmlCell::DrawInvisible(dc, x, y);
495 }
496
497
498
499 wxHtmlLinkInfo *wxHtmlContainerCell::GetLink(int x, int y) const
500 {
501 wxHtmlCell *c = m_Cells;
502 int cx, cy, cw, ch;
503
504 while (c) {
505 cx = c -> GetPosX(), cy = c -> GetPosY();
506 cw = c -> GetWidth(), ch = c -> GetHeight();
507 if ((x >= cx) && (x < cx + cw) && (y >= cy) && (y < cy + ch))
508 return c -> GetLink(x - cx, y - cy);
509 c = c -> GetNext();
510 }
511 return NULL;
512 }
513
514
515
516 void wxHtmlContainerCell::InsertCell(wxHtmlCell *f)
517 {
518 if (!m_Cells) m_Cells = m_LastCell = f;
519 else {
520 m_LastCell -> SetNext(f);
521 m_LastCell = f;
522 if (m_LastCell) while (m_LastCell -> GetNext()) m_LastCell = m_LastCell -> GetNext();
523 }
524 f -> SetParent(this);
525 m_LastLayout = -1;
526 }
527
528
529
530 void wxHtmlContainerCell::SetAlign(const wxHtmlTag& tag)
531 {
532 if (tag.HasParam(wxT("ALIGN"))) {
533 wxString alg = tag.GetParam(wxT("ALIGN"));
534 alg.MakeUpper();
535 if (alg == wxT("CENTER"))
536 SetAlignHor(wxHTML_ALIGN_CENTER);
537 else if (alg == wxT("LEFT"))
538 SetAlignHor(wxHTML_ALIGN_LEFT);
539 else if (alg == wxT("JUSTIFY"))
540 SetAlignHor(wxHTML_ALIGN_JUSTIFY);
541 else if (alg == wxT("RIGHT"))
542 SetAlignHor(wxHTML_ALIGN_RIGHT);
543 m_LastLayout = -1;
544 }
545 }
546
547
548
549 void wxHtmlContainerCell::SetWidthFloat(const wxHtmlTag& tag, double pixel_scale)
550 {
551 if (tag.HasParam(wxT("WIDTH"))) {
552 int wdi;
553 wxString wd = tag.GetParam(wxT("WIDTH"));
554
555 if (wd[wd.Length()-1] == wxT('%')) {
556 wxSscanf(wd.c_str(), wxT("%i%%"), &wdi);
557 SetWidthFloat(wdi, wxHTML_UNITS_PERCENT);
558 }
559 else {
560 wxSscanf(wd.c_str(), wxT("%i"), &wdi);
561 SetWidthFloat((int)(pixel_scale * (double)wdi), wxHTML_UNITS_PIXELS);
562 }
563 m_LastLayout = -1;
564 }
565 }
566
567
568
569 const wxHtmlCell* wxHtmlContainerCell::Find(int condition, const void* param) const
570 {
571 const wxHtmlCell *r = NULL;
572
573 if (m_Cells) {
574 r = m_Cells -> Find(condition, param);
575 if (r) return r;
576 }
577
578 return wxHtmlCell::Find(condition, param);
579 }
580
581
582
583 void wxHtmlContainerCell::OnMouseClick(wxWindow *parent, int x, int y, const wxMouseEvent& event)
584 {
585 if (m_Cells) {
586 wxHtmlCell *c = m_Cells;
587 while (c) {
588 if ( (c -> GetPosX() <= x) &&
589 (c -> GetPosY() <= y) &&
590 (c -> GetPosX() + c -> GetWidth() > x) &&
591 (c -> GetPosY() + c -> GetHeight() > y)) {
592 c -> OnMouseClick(parent, x - c -> GetPosX(), y - c -> GetPosY(), event);
593 break;
594 }
595 c = c -> GetNext();
596 }
597 }
598 }
599
600
601
602
603
604 //--------------------------------------------------------------------------------
605 // wxHtmlColourCell
606 //--------------------------------------------------------------------------------
607
608 void wxHtmlColourCell::Draw(wxDC& dc, int x, int y, int view_y1, int view_y2)
609 {
610 if (m_Flags & wxHTML_CLR_FOREGROUND)
611 dc.SetTextForeground(m_Colour);
612 if (m_Flags & wxHTML_CLR_BACKGROUND) {
613 dc.SetBackground(wxBrush(m_Colour, wxSOLID));
614 dc.SetTextBackground(m_Colour);
615 }
616 wxHtmlCell::Draw(dc, x, y, view_y1, view_y2);
617 }
618
619 void wxHtmlColourCell::DrawInvisible(wxDC& dc, int x, int y)
620 {
621 if (m_Flags & wxHTML_CLR_FOREGROUND)
622 dc.SetTextForeground(m_Colour);
623 if (m_Flags & wxHTML_CLR_BACKGROUND) {
624 dc.SetBackground(wxBrush(m_Colour, wxSOLID));
625 dc.SetTextBackground(m_Colour);
626 }
627 wxHtmlCell::DrawInvisible(dc, x, y);
628 }
629
630
631
632
633 //--------------------------------------------------------------------------------
634 // wxHtmlFontCell
635 //--------------------------------------------------------------------------------
636
637 void wxHtmlFontCell::Draw(wxDC& dc, int x, int y, int view_y1, int view_y2)
638 {
639 dc.SetFont(m_Font);
640 wxHtmlCell::Draw(dc, x, y, view_y1, view_y2);
641 }
642
643 void wxHtmlFontCell::DrawInvisible(wxDC& dc, int x, int y)
644 {
645 dc.SetFont(m_Font);
646 wxHtmlCell::DrawInvisible(dc, x, y);
647 }
648
649
650
651
652
653
654
655
656 //--------------------------------------------------------------------------------
657 // wxHtmlWidgetCell
658 //--------------------------------------------------------------------------------
659
660 wxHtmlWidgetCell::wxHtmlWidgetCell(wxWindow *wnd, int w)
661 {
662 int sx, sy;
663 m_Wnd = wnd;
664 m_Wnd -> GetSize(&sx, &sy);
665 m_Width = sx, m_Height = sy;
666 m_WidthFloat = w;
667 }
668
669
670 void wxHtmlWidgetCell::Draw(wxDC& dc, int x, int y, int view_y1, int view_y2)
671 {
672 int absx = 0, absy = 0, stx, sty;
673 wxHtmlCell *c = this;
674
675 while (c) {
676 absx += c -> GetPosX();
677 absy += c -> GetPosY();
678 c = c -> GetParent();
679 }
680
681 ((wxScrolledWindow*)(m_Wnd -> GetParent())) -> ViewStart(&stx, &sty);
682 m_Wnd -> SetSize(absx - wxHTML_SCROLL_STEP * stx, absy - wxHTML_SCROLL_STEP * sty, m_Width, m_Height);
683
684 wxHtmlCell::Draw(dc, x, y, view_y1, view_y2);
685 }
686
687
688
689 void wxHtmlWidgetCell::DrawInvisible(wxDC& dc, int x, int y)
690 {
691 int absx = 0, absy = 0, stx, sty;
692 wxHtmlCell *c = this;
693
694 while (c) {
695 absx += c -> GetPosX();
696 absy += c -> GetPosY();
697 c = c -> GetParent();
698 }
699
700 ((wxScrolledWindow*)(m_Wnd -> GetParent())) -> ViewStart(&stx, &sty);
701 m_Wnd -> SetSize(absx - wxHTML_SCROLL_STEP * stx, absy - wxHTML_SCROLL_STEP * sty, m_Width, m_Height);
702
703 wxHtmlCell::DrawInvisible(dc, x, y);
704 }
705
706
707
708 void wxHtmlWidgetCell::Layout(int w)
709 {
710 if (m_WidthFloat != 0) {
711 m_Width = (w * m_WidthFloat) / 100;
712 m_Wnd -> SetSize(m_Width, m_Height);
713 }
714
715 wxHtmlCell::Layout(w);
716 }
717
718 #endif