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