]> git.saurik.com Git - wxWidgets.git/blob - src/html/htmlcell.cpp
fixed incorrect parsing of http://domain.com:portnumber/
[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 while (line != cell) {
443 line -> SetPos(line -> GetPosX() + s_indent +
444 (counter++ * step / xcnt),
445 ypos + line -> GetPosY());
446 line = line -> GetNext();
447 }
448 }
449
450 ypos += ysizedown;
451 xpos = xcnt = 0;
452 ysizeup = ysizedown = 0;
453 line = cell;
454 }
455 }
456
457 // setup height & width, depending on container layout:
458 m_Height = ypos + (ysizedown + ysizeup) + m_IndentBottom;
459
460 if (m_Height < m_MinHeight) {
461 if (m_MinHeightAlign != wxHTML_ALIGN_TOP) {
462 int diff = m_MinHeight - m_Height;
463 if (m_MinHeightAlign == wxHTML_ALIGN_CENTER) diff /= 2;
464 cell = m_Cells;
465 while (cell) {
466 cell -> SetPos(cell -> GetPosX(), cell -> GetPosY() + diff);
467 cell = cell -> GetNext();
468 }
469 }
470 m_Height = m_MinHeight;
471 }
472
473 MaxLineWidth += s_indent + ((m_IndentRight < 0) ? (-m_IndentRight * m_Width / 100) : m_IndentRight);
474 if (m_Width < MaxLineWidth) m_Width = MaxLineWidth;
475
476 m_LastLayout = w;
477
478 wxHtmlCell::Layout(w);
479 }
480
481
482 #define mMin(a, b) (((a) < (b)) ? (a) : (b))
483 #define mMax(a, b) (((a) < (b)) ? (b) : (a))
484
485 void wxHtmlContainerCell::Draw(wxDC& dc, int x, int y, int view_y1, int view_y2)
486 {
487 // container visible, draw it:
488 if ((y + m_PosY < view_y2) && (y + m_PosY + m_Height > view_y1)) {
489
490 if (m_UseBkColour) {
491 wxBrush myb = wxBrush(m_BkColour, wxSOLID);
492
493 int real_y1 = mMax(y + m_PosY, view_y1);
494 int real_y2 = mMin(y + m_PosY + m_Height - 1, view_y2);
495
496 dc.SetBrush(myb);
497 dc.SetPen(*wxTRANSPARENT_PEN);
498 dc.DrawRectangle(x + m_PosX, real_y1, m_Width, real_y2 - real_y1 + 1);
499 }
500
501 if (m_UseBorder) {
502 wxPen mypen1(m_BorderColour1, 1, wxSOLID);
503 wxPen mypen2(m_BorderColour2, 1, wxSOLID);
504
505 dc.SetPen(mypen1);
506 dc.DrawLine(x + m_PosX, y + m_PosY, x + m_PosX, y + m_PosY + m_Height - 1);
507 dc.DrawLine(x + m_PosX, y + m_PosY, x + m_PosX + m_Width - 1, y + m_PosY);
508 dc.SetPen(mypen2);
509 dc.DrawLine(x + m_PosX + m_Width - 1, y + m_PosY, x + m_PosX + m_Width - 1, y + m_PosY + m_Height - 1);
510 dc.DrawLine(x + m_PosX, y + m_PosY + m_Height - 1, x + m_PosX + m_Width - 1, y + m_PosY + m_Height - 1);
511 }
512
513 if (m_Cells) m_Cells -> Draw(dc, x + m_PosX, y + m_PosY, view_y1, view_y2);
514 }
515 // container invisible, just proceed font+color changing:
516 else {
517 if (m_Cells) m_Cells -> DrawInvisible(dc, x + m_PosX, y + m_PosY);
518 }
519
520 wxHtmlCell::Draw(dc, x, y, view_y1, view_y2);
521 }
522
523
524
525 void wxHtmlContainerCell::DrawInvisible(wxDC& dc, int x, int y)
526 {
527 if (m_Cells) m_Cells -> DrawInvisible(dc, x + m_PosX, y + m_PosY);
528 wxHtmlCell::DrawInvisible(dc, x, y);
529 }
530
531
532
533 wxHtmlLinkInfo *wxHtmlContainerCell::GetLink(int x, int y) const
534 {
535 wxHtmlCell *c = m_Cells;
536 int cx, cy, cw, ch;
537
538 while (c) {
539 cx = c -> GetPosX(), cy = c -> GetPosY();
540 cw = c -> GetWidth(), ch = c -> GetHeight();
541 if ((x >= cx) && (x < cx + cw) && (y >= cy) && (y < cy + ch))
542 return c -> GetLink(x - cx, y - cy);
543 c = c -> GetNext();
544 }
545 return NULL;
546 }
547
548
549
550 void wxHtmlContainerCell::InsertCell(wxHtmlCell *f)
551 {
552 if (!m_Cells) m_Cells = m_LastCell = f;
553 else {
554 m_LastCell -> SetNext(f);
555 m_LastCell = f;
556 if (m_LastCell) while (m_LastCell -> GetNext()) m_LastCell = m_LastCell -> GetNext();
557 }
558 f -> SetParent(this);
559 m_LastLayout = -1;
560 }
561
562
563
564 void wxHtmlContainerCell::SetAlign(const wxHtmlTag& tag)
565 {
566 if (tag.HasParam(wxT("ALIGN"))) {
567 wxString alg = tag.GetParam(wxT("ALIGN"));
568 alg.MakeUpper();
569 if (alg == wxT("CENTER"))
570 SetAlignHor(wxHTML_ALIGN_CENTER);
571 else if (alg == wxT("LEFT"))
572 SetAlignHor(wxHTML_ALIGN_LEFT);
573 else if (alg == wxT("JUSTIFY"))
574 SetAlignHor(wxHTML_ALIGN_JUSTIFY);
575 else if (alg == wxT("RIGHT"))
576 SetAlignHor(wxHTML_ALIGN_RIGHT);
577 m_LastLayout = -1;
578 }
579 }
580
581
582
583 void wxHtmlContainerCell::SetWidthFloat(const wxHtmlTag& tag, double pixel_scale)
584 {
585 if (tag.HasParam(wxT("WIDTH"))) {
586 int wdi;
587 wxString wd = tag.GetParam(wxT("WIDTH"));
588
589 if (wd[wd.Length()-1] == wxT('%')) {
590 wxSscanf(wd.c_str(), wxT("%i%%"), &wdi);
591 SetWidthFloat(wdi, wxHTML_UNITS_PERCENT);
592 }
593 else {
594 wxSscanf(wd.c_str(), wxT("%i"), &wdi);
595 SetWidthFloat((int)(pixel_scale * (double)wdi), wxHTML_UNITS_PIXELS);
596 }
597 m_LastLayout = -1;
598 }
599 }
600
601
602
603 const wxHtmlCell* wxHtmlContainerCell::Find(int condition, const void* param) const
604 {
605 const wxHtmlCell *r = NULL;
606
607 if (m_Cells) {
608 r = m_Cells -> Find(condition, param);
609 if (r) return r;
610 }
611
612 return wxHtmlCell::Find(condition, param);
613 }
614
615
616
617 void wxHtmlContainerCell::OnMouseClick(wxWindow *parent, int x, int y, const wxMouseEvent& event)
618 {
619 if (m_Cells) {
620 wxHtmlCell *c = m_Cells;
621 while (c) {
622 if ( (c -> GetPosX() <= x) &&
623 (c -> GetPosY() <= y) &&
624 (c -> GetPosX() + c -> GetWidth() > x) &&
625 (c -> GetPosY() + c -> GetHeight() > y)) {
626 c -> OnMouseClick(parent, x - c -> GetPosX(), y - c -> GetPosY(), event);
627 break;
628 }
629 c = c -> GetNext();
630 }
631 }
632 }
633
634
635
636
637
638 //--------------------------------------------------------------------------------
639 // wxHtmlColourCell
640 //--------------------------------------------------------------------------------
641
642 void wxHtmlColourCell::Draw(wxDC& dc, int x, int y, int view_y1, int view_y2)
643 {
644 if (m_Flags & wxHTML_CLR_FOREGROUND)
645 dc.SetTextForeground(m_Colour);
646 if (m_Flags & wxHTML_CLR_BACKGROUND) {
647 dc.SetBackground(wxBrush(m_Colour, wxSOLID));
648 dc.SetTextBackground(m_Colour);
649 }
650 wxHtmlCell::Draw(dc, x, y, view_y1, view_y2);
651 }
652
653 void wxHtmlColourCell::DrawInvisible(wxDC& dc, int x, int y)
654 {
655 if (m_Flags & wxHTML_CLR_FOREGROUND)
656 dc.SetTextForeground(m_Colour);
657 if (m_Flags & wxHTML_CLR_BACKGROUND) {
658 dc.SetBackground(wxBrush(m_Colour, wxSOLID));
659 dc.SetTextBackground(m_Colour);
660 }
661 wxHtmlCell::DrawInvisible(dc, x, y);
662 }
663
664
665
666
667 //--------------------------------------------------------------------------------
668 // wxHtmlFontCell
669 //--------------------------------------------------------------------------------
670
671 void wxHtmlFontCell::Draw(wxDC& dc, int x, int y, int view_y1, int view_y2)
672 {
673 dc.SetFont(m_Font);
674 wxHtmlCell::Draw(dc, x, y, view_y1, view_y2);
675 }
676
677 void wxHtmlFontCell::DrawInvisible(wxDC& dc, int x, int y)
678 {
679 dc.SetFont(m_Font);
680 wxHtmlCell::DrawInvisible(dc, x, y);
681 }
682
683
684
685
686
687
688
689
690 //--------------------------------------------------------------------------------
691 // wxHtmlWidgetCell
692 //--------------------------------------------------------------------------------
693
694 wxHtmlWidgetCell::wxHtmlWidgetCell(wxWindow *wnd, int w)
695 {
696 int sx, sy;
697 m_Wnd = wnd;
698 m_Wnd -> GetSize(&sx, &sy);
699 m_Width = sx, m_Height = sy;
700 m_WidthFloat = w;
701 }
702
703
704 void wxHtmlWidgetCell::Draw(wxDC& dc, int x, int y, int view_y1, int view_y2)
705 {
706 int absx = 0, absy = 0, stx, sty;
707 wxHtmlCell *c = this;
708
709 while (c) {
710 absx += c -> GetPosX();
711 absy += c -> GetPosY();
712 c = c -> GetParent();
713 }
714
715 ((wxScrolledWindow*)(m_Wnd -> GetParent())) -> ViewStart(&stx, &sty);
716 m_Wnd -> SetSize(absx - wxHTML_SCROLL_STEP * stx, absy - wxHTML_SCROLL_STEP * sty, m_Width, m_Height);
717
718 wxHtmlCell::Draw(dc, x, y, view_y1, view_y2);
719 }
720
721
722
723 void wxHtmlWidgetCell::DrawInvisible(wxDC& dc, int x, int y)
724 {
725 int absx = 0, absy = 0, stx, sty;
726 wxHtmlCell *c = this;
727
728 while (c) {
729 absx += c -> GetPosX();
730 absy += c -> GetPosY();
731 c = c -> GetParent();
732 }
733
734 ((wxScrolledWindow*)(m_Wnd -> GetParent())) -> ViewStart(&stx, &sty);
735 m_Wnd -> SetSize(absx - wxHTML_SCROLL_STEP * stx, absy - wxHTML_SCROLL_STEP * sty, m_Width, m_Height);
736
737 wxHtmlCell::DrawInvisible(dc, x, y);
738 }
739
740
741
742 void wxHtmlWidgetCell::Layout(int w)
743 {
744 if (m_WidthFloat != 0) {
745 m_Width = (w * m_WidthFloat) / 100;
746 m_Wnd -> SetSize(m_Width, m_Height);
747 }
748
749 wxHtmlCell::Layout(w);
750 }
751
752 #endif