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