1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxHtmlCell - basic element of HTML output
4 // Author: Vaclav Slavik
6 // Copyright: (c) 1999 Vaclav Slavik
7 // Licence: wxWindows Licence
8 /////////////////////////////////////////////////////////////////////////////
11 #pragma implementation "htmlcell.h"
14 #include "wx/wxprec.h"
18 #if wxUSE_HTML && wxUSE_STREAMS
26 #include "wx/colour.h"
30 #include "wx/html/htmlcell.h"
31 #include "wx/html/htmlwin.h"
32 #include "wx/settings.h"
35 //-----------------------------------------------------------------------------
37 //-----------------------------------------------------------------------------
39 void wxHtmlSelection::Set(const wxPoint
& fromPos
, wxHtmlCell
*fromCell
,
40 const wxPoint
& toPos
, wxHtmlCell
*toCell
)
42 m_fromCell
= fromCell
;
48 void wxHtmlSelection::Set(wxHtmlCell
*fromCell
, wxHtmlCell
*toCell
)
50 wxPoint p1
= fromCell
? fromCell
->GetAbsPos() : wxDefaultPosition
;
51 wxPoint p2
= toCell
? toCell
->GetAbsPos() : wxDefaultPosition
;
54 p2
.x
+= toCell
->GetWidth()-1;
55 p2
.y
+= toCell
->GetHeight()-1;
57 Set(p1
, fromCell
, p2
, toCell
);
60 //-----------------------------------------------------------------------------
62 //-----------------------------------------------------------------------------
64 wxHtmlCell::wxHtmlCell() : wxObject()
68 m_Width
= m_Height
= m_Descent
= 0;
69 m_CanLiveOnPagebreak
= TRUE
;
73 wxHtmlCell::~wxHtmlCell()
79 void wxHtmlCell::OnMouseClick(wxWindow
*parent
, int x
, int y
,
80 const wxMouseEvent
& event
)
82 wxHtmlLinkInfo
*lnk
= GetLink(x
, y
);
85 wxHtmlLinkInfo
lnk2(*lnk
);
86 lnk2
.SetEvent(&event
);
87 lnk2
.SetHtmlCell(this);
89 // note : this cast is legal because parent is *always* wxHtmlWindow
90 wxStaticCast(parent
, wxHtmlWindow
)->OnLinkClicked(lnk2
);
96 bool wxHtmlCell::AdjustPagebreak(int *pagebreak
, int* WXUNUSED(known_pagebreaks
), int WXUNUSED(number_of_pages
)) const
98 if ((!m_CanLiveOnPagebreak
) &&
99 m_PosY
< *pagebreak
&& m_PosY
+ m_Height
> *pagebreak
)
110 void wxHtmlCell::SetLink(const wxHtmlLinkInfo
& link
)
112 if (m_Link
) delete m_Link
;
114 if (link
.GetHref() != wxEmptyString
)
115 m_Link
= new wxHtmlLinkInfo(link
);
120 void wxHtmlCell::Layout(int WXUNUSED(w
))
127 void wxHtmlCell::GetHorizontalConstraints(int *left
, int *right
) const
132 *right
= m_PosX
+ m_Width
;
137 const wxHtmlCell
* wxHtmlCell::Find(int WXUNUSED(condition
), const void* WXUNUSED(param
)) const
143 wxHtmlCell
*wxHtmlCell::FindCellByPos(wxCoord x
, wxCoord y
,
144 unsigned flags
) const
146 if ( x
>= 0 && x
< m_Width
&& y
>= 0 && y
< m_Height
)
148 return wxConstCast(this, wxHtmlCell
);
152 if ((flags
& wxHTML_FIND_NEAREST_AFTER
) &&
153 (y
< 0 || (y
== 0 && x
<= 0)))
154 return wxConstCast(this, wxHtmlCell
);
155 else if ((flags
& wxHTML_FIND_NEAREST_BEFORE
) &&
156 (y
> m_Height
-1 || (y
== m_Height
-1 && x
>= m_Width
)))
157 return wxConstCast(this, wxHtmlCell
);
164 wxPoint
wxHtmlCell::GetAbsPos() const
166 wxPoint
p(m_PosX
, m_PosY
);
167 for (wxHtmlCell
*parent
= m_Parent
; parent
; parent
= parent
->m_Parent
)
169 p
.x
+= parent
->m_PosX
;
170 p
.y
+= parent
->m_PosY
;
175 unsigned wxHtmlCell::GetDepth() const
178 for (wxHtmlCell
*p
= m_Parent
; p
; p
= p
->m_Parent
)
183 bool wxHtmlCell::IsBefore(wxHtmlCell
*cell
) const
185 const wxHtmlCell
*c1
= this;
186 const wxHtmlCell
*c2
= cell
;
187 unsigned d1
= GetDepth();
188 unsigned d2
= cell
->GetDepth();
191 for (; d1
!= d2
; d1
-- )
194 for (; d1
!= d2
; d2
-- )
202 if ( c1
->m_Parent
== c2
->m_Parent
)
219 wxFAIL_MSG(_T("Cells are in different trees"));
224 //-----------------------------------------------------------------------------
226 //-----------------------------------------------------------------------------
228 wxHtmlWordCell::wxHtmlWordCell(const wxString
& word
, wxDC
& dc
) : wxHtmlCell()
231 dc
.GetTextExtent(m_Word
, &m_Width
, &m_Height
, &m_Descent
);
232 SetCanLiveOnPagebreak(FALSE
);
237 void wxHtmlWordCell::Draw(wxDC
& dc
, int x
, int y
,
238 int WXUNUSED(view_y1
), int WXUNUSED(view_y2
),
239 wxHtmlRenderingState
& state
)
241 if (state
.GetSelectionState() != wxHTML_SEL_OUT
&&
242 dc
.GetBackgroundMode() != wxSOLID
)
244 dc
.SetBackgroundMode(wxSOLID
);
245 dc
.SetTextBackground(
246 wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT
));
247 dc
.SetTextForeground(
248 wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT
));
250 else if (state
.GetSelectionState() == wxHTML_SEL_OUT
&&
251 dc
.GetBackgroundMode() == wxSOLID
)
253 dc
.SetBackgroundMode(wxTRANSPARENT
);
254 dc
.SetTextForeground(state
.GetFgColour());
255 dc
.SetTextBackground(state
.GetBgColour());
258 // FIXME - use selection
259 dc
.DrawText(m_Word
, x
+ m_PosX
, y
+ m_PosY
);
263 wxString
wxHtmlWordCell::ConvertToText(wxHtmlSelection
*sel
) const
265 // FIXME - use selection
271 //-----------------------------------------------------------------------------
272 // wxHtmlContainerCell
273 //-----------------------------------------------------------------------------
276 wxHtmlContainerCell::wxHtmlContainerCell(wxHtmlContainerCell
*parent
) : wxHtmlCell()
278 m_Cells
= m_LastCell
= NULL
;
280 if (m_Parent
) m_Parent
->InsertCell(this);
281 m_AlignHor
= wxHTML_ALIGN_LEFT
;
282 m_AlignVer
= wxHTML_ALIGN_BOTTOM
;
283 m_IndentLeft
= m_IndentRight
= m_IndentTop
= m_IndentBottom
= 0;
284 m_WidthFloat
= 100; m_WidthFloatUnits
= wxHTML_UNITS_PERCENT
;
285 m_UseBkColour
= FALSE
;
288 m_MinHeightAlign
= wxHTML_ALIGN_TOP
;
292 wxHtmlContainerCell::~wxHtmlContainerCell()
294 wxHtmlCell
*cell
= m_Cells
;
297 wxHtmlCell
*cellNext
= cell
->GetNext();
305 void wxHtmlContainerCell::SetIndent(int i
, int what
, int units
)
307 int val
= (units
== wxHTML_UNITS_PIXELS
) ? i
: -i
;
308 if (what
& wxHTML_INDENT_LEFT
) m_IndentLeft
= val
;
309 if (what
& wxHTML_INDENT_RIGHT
) m_IndentRight
= val
;
310 if (what
& wxHTML_INDENT_TOP
) m_IndentTop
= val
;
311 if (what
& wxHTML_INDENT_BOTTOM
) m_IndentBottom
= val
;
317 int wxHtmlContainerCell::GetIndent(int ind
) const
319 if (ind
& wxHTML_INDENT_LEFT
) return m_IndentLeft
;
320 else if (ind
& wxHTML_INDENT_RIGHT
) return m_IndentRight
;
321 else if (ind
& wxHTML_INDENT_TOP
) return m_IndentTop
;
322 else if (ind
& wxHTML_INDENT_BOTTOM
) return m_IndentBottom
;
323 else return -1; /* BUG! Should not be called... */
329 int wxHtmlContainerCell::GetIndentUnits(int ind
) const
332 if (ind
& wxHTML_INDENT_LEFT
) p
= m_IndentLeft
< 0;
333 else if (ind
& wxHTML_INDENT_RIGHT
) p
= m_IndentRight
< 0;
334 else if (ind
& wxHTML_INDENT_TOP
) p
= m_IndentTop
< 0;
335 else if (ind
& wxHTML_INDENT_BOTTOM
) p
= m_IndentBottom
< 0;
336 if (p
) return wxHTML_UNITS_PERCENT
;
337 else return wxHTML_UNITS_PIXELS
;
342 bool wxHtmlContainerCell::AdjustPagebreak(int *pagebreak
, int* known_pagebreaks
, int number_of_pages
) const
344 if (!m_CanLiveOnPagebreak
)
345 return wxHtmlCell::AdjustPagebreak(pagebreak
, known_pagebreaks
, number_of_pages
);
349 wxHtmlCell
*c
= GetFirstChild();
351 int pbrk
= *pagebreak
- m_PosY
;
355 if (c
->AdjustPagebreak(&pbrk
, known_pagebreaks
, number_of_pages
))
360 *pagebreak
= pbrk
+ m_PosY
;
367 void wxHtmlContainerCell::Layout(int w
)
369 wxHtmlCell::Layout(w
);
371 if (m_LastLayout
== w
) return;
373 // VS: Any attempt to layout with negative or zero width leads to hell,
374 // but we can't ignore such attempts completely, since it sometimes
375 // happen (e.g. when trying how small a table can be). The best thing we
376 // can do is to set the width of child cells to zero
380 for (wxHtmlCell
*cell
= m_Cells
; cell
; cell
= cell
->GetNext())
382 // this does two things: it recursively calls this code on all
383 // child contrainers and resets children's position to (0,0)
387 wxHtmlCell
*cell
= m_Cells
, *line
= m_Cells
;
388 long xpos
= 0, ypos
= m_IndentTop
;
389 int xdelta
= 0, ybasicpos
= 0, ydiff
;
390 int s_width
, s_indent
;
391 int ysizeup
= 0, ysizedown
= 0;
392 int MaxLineWidth
= 0;
402 if (m_WidthFloatUnits
== wxHTML_UNITS_PERCENT
)
404 if (m_WidthFloat
< 0) m_Width
= (100 + m_WidthFloat
) * w
/ 100;
405 else m_Width
= m_WidthFloat
* w
/ 100;
409 if (m_WidthFloat
< 0) m_Width
= w
+ m_WidthFloat
;
410 else m_Width
= m_WidthFloat
;
415 int l
= (m_IndentLeft
< 0) ? (-m_IndentLeft
* m_Width
/ 100) : m_IndentLeft
;
416 int r
= (m_IndentRight
< 0) ? (-m_IndentRight
* m_Width
/ 100) : m_IndentRight
;
417 for (wxHtmlCell
*cell
= m_Cells
; cell
; cell
= cell
->GetNext())
418 cell
->Layout(m_Width
- (l
+ r
));
427 // adjust indentation:
428 s_indent
= (m_IndentLeft
< 0) ? (-m_IndentLeft
* m_Width
/ 100) : m_IndentLeft
;
429 s_width
= m_Width
- s_indent
- ((m_IndentRight
< 0) ? (-m_IndentRight
* m_Width
/ 100) : m_IndentRight
);
436 case wxHTML_ALIGN_TOP
: ybasicpos
= 0; break;
437 case wxHTML_ALIGN_BOTTOM
: ybasicpos
= - cell
->GetHeight(); break;
438 case wxHTML_ALIGN_CENTER
: ybasicpos
= - cell
->GetHeight() / 2; break;
440 ydiff
= cell
->GetHeight() + ybasicpos
;
442 if (cell
->GetDescent() + ydiff
> ysizedown
) ysizedown
= cell
->GetDescent() + ydiff
;
443 if (ybasicpos
+ cell
->GetDescent() < -ysizeup
) ysizeup
= - (ybasicpos
+ cell
->GetDescent());
445 cell
->SetPos(xpos
, ybasicpos
+ cell
->GetDescent());
446 xpos
+= cell
->GetWidth();
447 cell
= cell
->GetNext();
450 // force new line if occured:
451 if ((cell
== NULL
) || (xpos
+ cell
->GetWidth() > s_width
))
453 if (xpos
> MaxLineWidth
) MaxLineWidth
= xpos
;
454 if (ysizeup
< 0) ysizeup
= 0;
455 if (ysizedown
< 0) ysizedown
= 0;
456 switch (m_AlignHor
) {
457 case wxHTML_ALIGN_LEFT
:
458 case wxHTML_ALIGN_JUSTIFY
:
461 case wxHTML_ALIGN_RIGHT
:
462 xdelta
= 0 + (s_width
- xpos
);
464 case wxHTML_ALIGN_CENTER
:
465 xdelta
= 0 + (s_width
- xpos
) / 2;
468 if (xdelta
< 0) xdelta
= 0;
473 if (m_AlignHor
!= wxHTML_ALIGN_JUSTIFY
|| cell
== NULL
)
476 line
->SetPos(line
->GetPosX() + xdelta
,
477 ypos
+ line
->GetPosY());
478 line
= line
->GetNext();
483 int step
= (s_width
- xpos
);
484 if (step
< 0) step
= 0;
486 if (xcnt
> 0) while (line
!= cell
)
488 line
->SetPos(line
->GetPosX() + s_indent
+
489 (counter
++ * step
/ xcnt
),
490 ypos
+ line
->GetPosY());
491 line
= line
->GetNext();
498 ysizeup
= ysizedown
= 0;
503 // setup height & width, depending on container layout:
504 m_Height
= ypos
+ (ysizedown
+ ysizeup
) + m_IndentBottom
;
506 if (m_Height
< m_MinHeight
)
508 if (m_MinHeightAlign
!= wxHTML_ALIGN_TOP
)
510 int diff
= m_MinHeight
- m_Height
;
511 if (m_MinHeightAlign
== wxHTML_ALIGN_CENTER
) diff
/= 2;
515 cell
->SetPos(cell
->GetPosX(), cell
->GetPosY() + diff
);
516 cell
= cell
->GetNext();
519 m_Height
= m_MinHeight
;
522 MaxLineWidth
+= s_indent
+ ((m_IndentRight
< 0) ? (-m_IndentRight
* m_Width
/ 100) : m_IndentRight
);
523 if (m_Width
< MaxLineWidth
) m_Width
= MaxLineWidth
;
528 void wxHtmlContainerCell::UpdateRenderingStatePre(wxHtmlRenderingState
& state
,
529 wxHtmlCell
*cell
) const
531 wxHtmlSelection
*s
= state
.GetSelection();
533 if (s
->GetFromCell() == cell
|| s
->GetToCell() == cell
)
535 state
.SetSelectionState(wxHTML_SEL_CHANGING
);
539 void wxHtmlContainerCell::UpdateRenderingStatePost(wxHtmlRenderingState
& state
,
540 wxHtmlCell
*cell
) const
542 wxHtmlSelection
*s
= state
.GetSelection();
544 if (s
->GetToCell() == cell
)
545 state
.SetSelectionState(wxHTML_SEL_OUT
);
546 else if (s
->GetFromCell() == cell
)
547 state
.SetSelectionState(wxHTML_SEL_IN
);
550 #define mMin(a, b) (((a) < (b)) ? (a) : (b))
551 #define mMax(a, b) (((a) < (b)) ? (b) : (a))
553 void wxHtmlContainerCell::Draw(wxDC
& dc
, int x
, int y
, int view_y1
, int view_y2
,
554 wxHtmlRenderingState
& state
)
556 // container visible, draw it:
557 if ((y
+ m_PosY
<= view_y2
) && (y
+ m_PosY
+ m_Height
> view_y1
))
561 wxBrush myb
= wxBrush(m_BkColour
, wxSOLID
);
563 int real_y1
= mMax(y
+ m_PosY
, view_y1
);
564 int real_y2
= mMin(y
+ m_PosY
+ m_Height
- 1, view_y2
);
567 dc
.SetPen(*wxTRANSPARENT_PEN
);
568 dc
.DrawRectangle(x
+ m_PosX
, real_y1
, m_Width
, real_y2
- real_y1
+ 1);
573 wxPen
mypen1(m_BorderColour1
, 1, wxSOLID
);
574 wxPen
mypen2(m_BorderColour2
, 1, wxSOLID
);
577 dc
.DrawLine(x
+ m_PosX
, y
+ m_PosY
, x
+ m_PosX
, y
+ m_PosY
+ m_Height
- 1);
578 dc
.DrawLine(x
+ m_PosX
, y
+ m_PosY
, x
+ m_PosX
+ m_Width
, y
+ m_PosY
);
580 dc
.DrawLine(x
+ m_PosX
+ m_Width
- 1, y
+ m_PosY
, x
+ m_PosX
+ m_Width
- 1, y
+ m_PosY
+ m_Height
- 1);
581 dc
.DrawLine(x
+ m_PosX
, y
+ m_PosY
+ m_Height
- 1, x
+ m_PosX
+ m_Width
, y
+ m_PosY
+ m_Height
- 1);
586 // draw container's contents:
587 for (wxHtmlCell
*cell
= m_Cells
; cell
; cell
= cell
->GetNext())
589 UpdateRenderingStatePre(state
, cell
);
591 x
+ m_PosX
, y
+ m_PosY
, view_y1
, view_y2
,
593 UpdateRenderingStatePost(state
, cell
);
597 // container invisible, just proceed font+color changing:
600 DrawInvisible(dc
, x
, y
, state
);
606 void wxHtmlContainerCell::DrawInvisible(wxDC
& dc
, int x
, int y
,
607 wxHtmlRenderingState
& state
)
611 for (wxHtmlCell
*cell
= m_Cells
; cell
; cell
= cell
->GetNext())
613 UpdateRenderingStatePre(state
, cell
);
614 cell
->DrawInvisible(dc
, x
+ m_PosX
, y
+ m_PosY
, state
);
615 UpdateRenderingStatePost(state
, cell
);
621 wxColour
wxHtmlContainerCell::GetBackgroundColour()
631 wxHtmlLinkInfo
*wxHtmlContainerCell::GetLink(int x
, int y
) const
633 wxHtmlCell
*cell
= FindCellByPos(x
, y
);
635 // VZ: I don't know if we should pass absolute or relative coords to
636 // wxHtmlCell::GetLink()? As the base class version just ignores them
637 // anyhow, it hardly matters right now but should still be clarified
638 return cell
? cell
->GetLink(x
, y
) : NULL
;
643 void wxHtmlContainerCell::InsertCell(wxHtmlCell
*f
)
645 if (!m_Cells
) m_Cells
= m_LastCell
= f
;
648 m_LastCell
->SetNext(f
);
650 if (m_LastCell
) while (m_LastCell
->GetNext()) m_LastCell
= m_LastCell
->GetNext();
658 void wxHtmlContainerCell::SetAlign(const wxHtmlTag
& tag
)
660 if (tag
.HasParam(wxT("ALIGN")))
662 wxString alg
= tag
.GetParam(wxT("ALIGN"));
664 if (alg
== wxT("CENTER"))
665 SetAlignHor(wxHTML_ALIGN_CENTER
);
666 else if (alg
== wxT("LEFT"))
667 SetAlignHor(wxHTML_ALIGN_LEFT
);
668 else if (alg
== wxT("JUSTIFY"))
669 SetAlignHor(wxHTML_ALIGN_JUSTIFY
);
670 else if (alg
== wxT("RIGHT"))
671 SetAlignHor(wxHTML_ALIGN_RIGHT
);
678 void wxHtmlContainerCell::SetWidthFloat(const wxHtmlTag
& tag
, double pixel_scale
)
680 if (tag
.HasParam(wxT("WIDTH")))
683 wxString wd
= tag
.GetParam(wxT("WIDTH"));
685 if (wd
[wd
.Length()-1] == wxT('%'))
687 wxSscanf(wd
.c_str(), wxT("%i%%"), &wdi
);
688 SetWidthFloat(wdi
, wxHTML_UNITS_PERCENT
);
692 wxSscanf(wd
.c_str(), wxT("%i"), &wdi
);
693 SetWidthFloat((int)(pixel_scale
* (double)wdi
), wxHTML_UNITS_PIXELS
);
701 const wxHtmlCell
* wxHtmlContainerCell::Find(int condition
, const void* param
) const
705 const wxHtmlCell
*r
= NULL
;
707 for (wxHtmlCell
*cell
= m_Cells
; cell
; cell
= cell
->GetNext())
709 r
= cell
->Find(condition
, param
);
717 wxHtmlCell
*wxHtmlContainerCell::FindCellByPos(wxCoord x
, wxCoord y
,
718 unsigned flags
) const
720 if ( flags
& wxHTML_FIND_EXACT
)
722 for ( const wxHtmlCell
*cell
= m_Cells
; cell
; cell
= cell
->GetNext() )
724 int cx
= cell
->GetPosX(),
725 cy
= cell
->GetPosY();
727 if ( (cx
<= x
) && (cx
+ cell
->GetWidth() > x
) &&
728 (cy
<= y
) && (cy
+ cell
->GetHeight() > y
) )
730 return cell
->FindCellByPos(x
- cx
, y
- cy
, flags
);
734 else if ( flags
& wxHTML_FIND_NEAREST_AFTER
)
738 for ( const wxHtmlCell
*cell
= m_Cells
; cell
; cell
= cell
->GetNext() )
740 y2
= cell
->GetPosY() + cell
->GetHeight() - 1;
741 if (y2
< y
|| (y2
== y
&& cell
->GetPosX()+cell
->GetWidth()-1 < x
))
743 c
= cell
->FindCellByPos(x
- cell
->GetPosX(), y
- cell
->GetPosY(),
748 else if ( flags
& wxHTML_FIND_NEAREST_BEFORE
)
751 for ( const wxHtmlCell
*cell
= m_Cells
; cell
; cell
= cell
->GetNext() )
753 if (cell
->GetPosY() > y
||
754 (cell
->GetPosY() == y
&& cell
->GetPosX() > x
))
756 c
= cell
->FindCellByPos(x
- cell
->GetPosX(), y
- cell
->GetPosY(),
766 void wxHtmlContainerCell::OnMouseClick(wxWindow
*parent
, int x
, int y
, const wxMouseEvent
& event
)
768 wxHtmlCell
*cell
= FindCellByPos(x
, y
);
770 cell
->OnMouseClick(parent
, x
, y
, event
);
775 void wxHtmlContainerCell::GetHorizontalConstraints(int *left
, int *right
) const
777 int cleft
= m_PosX
+ m_Width
, cright
= m_PosX
; // worst case
780 for (wxHtmlCell
*cell
= m_Cells
; cell
; cell
= cell
->GetNext())
782 cell
->GetHorizontalConstraints(&l
, &r
);
789 cleft
-= (m_IndentLeft
< 0) ? (-m_IndentLeft
* m_Width
/ 100) : m_IndentLeft
;
790 cright
+= (m_IndentRight
< 0) ? (-m_IndentRight
* m_Width
/ 100) : m_IndentRight
;
799 wxHtmlCell
*wxHtmlContainerCell::GetFirstTerminal() const
804 for (wxHtmlCell
*c
= m_Cells
; c
; c
= c
->GetNext())
806 c2
= c
->GetFirstTerminal();
814 wxHtmlCell
*wxHtmlContainerCell::GetLastTerminal() const
818 // most common case first:
819 wxHtmlCell
*c
= m_LastCell
->GetLastTerminal();
823 wxHtmlCell
*c2
= NULL
;
824 for (c
= m_Cells
; c
; c
= c
->GetNext())
825 c2
= c
->GetLastTerminal();
835 // --------------------------------------------------------------------------
837 // --------------------------------------------------------------------------
839 void wxHtmlColourCell::Draw(wxDC
& dc
,
841 int WXUNUSED(view_y1
), int WXUNUSED(view_y2
),
842 wxHtmlRenderingState
& state
)
844 DrawInvisible(dc
, x
, y
, state
);
847 void wxHtmlColourCell::DrawInvisible(wxDC
& dc
,
848 int WXUNUSED(x
), int WXUNUSED(y
),
849 wxHtmlRenderingState
& state
)
851 if (m_Flags
& wxHTML_CLR_FOREGROUND
)
853 state
.SetFgColour(m_Colour
);
854 if (state
.GetSelectionState() != wxHTML_SEL_IN
)
855 dc
.SetTextForeground(m_Colour
);
857 if (m_Flags
& wxHTML_CLR_BACKGROUND
)
859 state
.SetBgColour(m_Colour
);
860 if (state
.GetSelectionState() != wxHTML_SEL_IN
)
861 dc
.SetTextBackground(m_Colour
);
862 dc
.SetBackground(wxBrush(m_Colour
, wxSOLID
));
869 // ---------------------------------------------------------------------------
871 // ---------------------------------------------------------------------------
873 void wxHtmlFontCell::Draw(wxDC
& dc
,
874 int WXUNUSED(x
), int WXUNUSED(y
),
875 int WXUNUSED(view_y1
), int WXUNUSED(view_y2
),
876 wxHtmlRenderingState
& WXUNUSED(state
))
881 void wxHtmlFontCell::DrawInvisible(wxDC
& dc
, int WXUNUSED(x
), int WXUNUSED(y
),
882 wxHtmlRenderingState
& WXUNUSED(state
))
894 // ---------------------------------------------------------------------------
896 // ---------------------------------------------------------------------------
898 wxHtmlWidgetCell::wxHtmlWidgetCell(wxWindow
*wnd
, int w
)
902 m_Wnd
->GetSize(&sx
, &sy
);
903 m_Width
= sx
, m_Height
= sy
;
908 void wxHtmlWidgetCell::Draw(wxDC
& WXUNUSED(dc
),
909 int WXUNUSED(x
), int WXUNUSED(y
),
910 int WXUNUSED(view_y1
), int WXUNUSED(view_y2
),
911 wxHtmlRenderingState
& WXUNUSED(state
))
913 int absx
= 0, absy
= 0, stx
, sty
;
914 wxHtmlCell
*c
= this;
918 absx
+= c
->GetPosX();
919 absy
+= c
->GetPosY();
923 ((wxScrolledWindow
*)(m_Wnd
->GetParent()))->GetViewStart(&stx
, &sty
);
924 m_Wnd
->SetSize(absx
- wxHTML_SCROLL_STEP
* stx
, absy
- wxHTML_SCROLL_STEP
* sty
, m_Width
, m_Height
);
929 void wxHtmlWidgetCell::DrawInvisible(wxDC
& WXUNUSED(dc
),
930 int WXUNUSED(x
), int WXUNUSED(y
),
931 wxHtmlRenderingState
& WXUNUSED(state
))
933 int absx
= 0, absy
= 0, stx
, sty
;
934 wxHtmlCell
*c
= this;
938 absx
+= c
->GetPosX();
939 absy
+= c
->GetPosY();
943 ((wxScrolledWindow
*)(m_Wnd
->GetParent()))->GetViewStart(&stx
, &sty
);
944 m_Wnd
->SetSize(absx
- wxHTML_SCROLL_STEP
* stx
, absy
- wxHTML_SCROLL_STEP
* sty
, m_Width
, m_Height
);
949 void wxHtmlWidgetCell::Layout(int w
)
951 if (m_WidthFloat
!= 0)
953 m_Width
= (w
* m_WidthFloat
) / 100;
954 m_Wnd
->SetSize(m_Width
, m_Height
);
957 wxHtmlCell::Layout(w
);
962 // ----------------------------------------------------------------------------
963 // wxHtmlTerminalCellsInterator
964 // ----------------------------------------------------------------------------
966 const wxHtmlCell
* wxHtmlTerminalCellsInterator::operator++()
979 if ( m_pos
->GetNext() )
980 m_pos
= m_pos
->GetNext();
983 // we must go up the hierarchy until we reach container where this
984 // is not the last child, and then go down to first terminal cell:
985 while ( m_pos
->GetNext() == NULL
)
987 m_pos
= m_pos
->GetParent();
991 m_pos
= m_pos
->GetNext();
993 while ( m_pos
->GetFirstChild() != NULL
)
994 m_pos
= m_pos
->GetFirstChild();
995 } while ( !m_pos
->IsTerminalCell() );