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