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