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