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