1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/html/htmlcell.cpp
3 // Purpose: wxHtmlCell - basic element of HTML output
4 // Author: Vaclav Slavik
6 // Copyright: (c) 1999 Vaclav Slavik
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
10 #include "wx/wxprec.h"
16 #if wxUSE_HTML && wxUSE_STREAMS
19 #include "wx/dynarray.h"
21 #include "wx/colour.h"
23 #include "wx/settings.h"
24 #include "wx/module.h"
25 #include "wx/wxcrtvararg.h"
28 #include "wx/html/htmlcell.h"
29 #include "wx/html/htmlwin.h"
33 //-----------------------------------------------------------------------------
35 //-----------------------------------------------------------------------------
37 void wxHtmlSelection::Set(const wxPoint
& fromPos
, const wxHtmlCell
*fromCell
,
38 const wxPoint
& toPos
, const wxHtmlCell
*toCell
)
40 m_fromCell
= fromCell
;
46 void wxHtmlSelection::Set(const wxHtmlCell
*fromCell
, const wxHtmlCell
*toCell
)
48 wxPoint p1
= fromCell
? fromCell
->GetAbsPos() : wxDefaultPosition
;
49 wxPoint p2
= toCell
? toCell
->GetAbsPos() : wxDefaultPosition
;
52 p2
.x
+= toCell
->GetWidth();
53 p2
.y
+= toCell
->GetHeight();
55 Set(p1
, fromCell
, p2
, toCell
);
59 wxDefaultHtmlRenderingStyle::
60 GetSelectedTextColour(const wxColour
& WXUNUSED(clr
))
62 return wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT
);
66 wxDefaultHtmlRenderingStyle::
67 GetSelectedTextBgColour(const wxColour
& WXUNUSED(clr
))
69 return wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT
);
73 //-----------------------------------------------------------------------------
75 //-----------------------------------------------------------------------------
77 IMPLEMENT_ABSTRACT_CLASS(wxHtmlCell
, wxObject
)
79 wxHtmlCell::wxHtmlCell() : wxObject()
83 m_Width
= m_Height
= m_Descent
= 0;
84 m_ScriptMode
= wxHTML_SCRIPT_NORMAL
; // <sub> or <sup> mode
85 m_ScriptBaseline
= 0; // <sub> or <sup> baseline
86 m_CanLiveOnPagebreak
= true;
90 wxHtmlCell::~wxHtmlCell()
95 // Update the descent value when whe are in a <sub> or <sup>.
96 // prevbase is the parent base
97 void wxHtmlCell::SetScriptMode(wxHtmlScriptMode mode
, long previousBase
)
101 if (mode
== wxHTML_SCRIPT_SUP
)
102 m_ScriptBaseline
= previousBase
- (m_Height
+ 1) / 2;
103 else if (mode
== wxHTML_SCRIPT_SUB
)
104 m_ScriptBaseline
= previousBase
+ (m_Height
+ 1) / 6;
106 m_ScriptBaseline
= 0;
108 m_Descent
+= m_ScriptBaseline
;
111 #if WXWIN_COMPATIBILITY_2_6
113 struct wxHtmlCellOnMouseClickCompatHelper
;
115 static wxHtmlCellOnMouseClickCompatHelper
*gs_helperOnMouseClick
= NULL
;
117 // helper for routing calls to new ProcessMouseClick() method to deprecated
118 // OnMouseClick() method
119 struct wxHtmlCellOnMouseClickCompatHelper
121 wxHtmlCellOnMouseClickCompatHelper(wxHtmlWindowInterface
*window_
,
123 const wxMouseEvent
& event_
)
124 : window(window_
), pos(pos_
), event(event_
), retval(false)
128 bool CallOnMouseClick(wxHtmlCell
*cell
)
130 wxHtmlCellOnMouseClickCompatHelper
*oldHelper
= gs_helperOnMouseClick
;
131 gs_helperOnMouseClick
= this;
134 window
? window
->GetHTMLWindow() : NULL
,
138 gs_helperOnMouseClick
= oldHelper
;
142 wxHtmlWindowInterface
*window
;
144 const wxMouseEvent
& event
;
147 #endif // WXWIN_COMPATIBILITY_2_6
149 bool wxHtmlCell::ProcessMouseClick(wxHtmlWindowInterface
*window
,
151 const wxMouseEvent
& event
)
153 wxCHECK_MSG( window
, false, wxT("window interface must be provided") );
155 #if WXWIN_COMPATIBILITY_2_6
156 // NB: this hack puts the body of ProcessMouseClick() into OnMouseClick()
157 // (for which it has to pass the arguments and return value via a
158 // helper variable because these two methods have different
159 // signatures), so that old code overriding OnMouseClick will continue
161 wxHtmlCellOnMouseClickCompatHelper
compat(window
, pos
, event
);
162 return compat
.CallOnMouseClick(this);
165 void wxHtmlCell::OnMouseClick(wxWindow
*, int, int, const wxMouseEvent
& event
)
167 wxCHECK_RET( gs_helperOnMouseClick
, wxT("unexpected call to OnMouseClick") );
168 wxHtmlWindowInterface
*window
= gs_helperOnMouseClick
->window
;
169 const wxPoint
& pos
= gs_helperOnMouseClick
->pos
;
170 #endif // WXWIN_COMPATIBILITY_2_6
172 wxHtmlLinkInfo
*lnk
= GetLink(pos
.x
, pos
.y
);
177 wxHtmlLinkInfo
lnk2(*lnk
);
178 lnk2
.SetEvent(&event
);
179 lnk2
.SetHtmlCell(this);
181 window
->OnHTMLLinkClicked(lnk2
);
185 #if WXWIN_COMPATIBILITY_2_6
186 gs_helperOnMouseClick
->retval
= retval
;
189 #endif // WXWIN_COMPATIBILITY_2_6
192 #if WXWIN_COMPATIBILITY_2_6
193 wxCursor
wxHtmlCell::GetCursor() const
197 #endif // WXWIN_COMPATIBILITY_2_6
199 wxCursor
wxHtmlCell::GetMouseCursor(wxHtmlWindowInterface
*window
) const
201 #if WXWIN_COMPATIBILITY_2_6
202 // NB: Older versions of wx used GetCursor() virtual method in place of
203 // GetMouseCursor(interface). This code ensures that user code that
204 // overridden GetCursor() continues to work. The trick is that the base
205 // wxHtmlCell::GetCursor() method simply returns wxNullCursor, so we
206 // know that GetCursor() was overridden iff it returns valid cursor.
207 wxCursor cur
= GetCursor();
210 #endif // WXWIN_COMPATIBILITY_2_6
214 return window
->GetHTMLCursor(wxHtmlWindowInterface::HTMLCursor_Link
);
218 return window
->GetHTMLCursor(wxHtmlWindowInterface::HTMLCursor_Default
);
224 wxHtmlCell::AdjustPagebreak(int *pagebreak
,
225 const wxArrayInt
& WXUNUSED(known_pagebreaks
),
226 int pageHeight
) const
228 // Notice that we always break the cells bigger than the page height here
229 // as otherwise we wouldn't be able to break them at all.
230 if ( m_Height
<= pageHeight
&&
231 (!m_CanLiveOnPagebreak
&&
232 m_PosY
< *pagebreak
&& m_PosY
+ m_Height
> *pagebreak
) )
243 void wxHtmlCell::SetLink(const wxHtmlLinkInfo
& link
)
246 if (link
.GetHref() != wxEmptyString
)
247 m_Link
= new wxHtmlLinkInfo(link
);
251 void wxHtmlCell::Layout(int WXUNUSED(w
))
258 const wxHtmlCell
* wxHtmlCell::Find(int WXUNUSED(condition
), const void* WXUNUSED(param
)) const
264 wxHtmlCell
*wxHtmlCell::FindCellByPos(wxCoord x
, wxCoord y
,
265 unsigned flags
) const
267 if ( x
>= 0 && x
< m_Width
&& y
>= 0 && y
< m_Height
)
269 return wxConstCast(this, wxHtmlCell
);
273 if ((flags
& wxHTML_FIND_NEAREST_AFTER
) &&
274 (y
< 0 || (y
< 0+m_Height
&& x
< 0+m_Width
)))
275 return wxConstCast(this, wxHtmlCell
);
276 else if ((flags
& wxHTML_FIND_NEAREST_BEFORE
) &&
277 (y
>= 0+m_Height
|| (y
>= 0 && x
>= 0)))
278 return wxConstCast(this, wxHtmlCell
);
285 wxPoint
wxHtmlCell::GetAbsPos(wxHtmlCell
*rootCell
) const
287 wxPoint
p(m_PosX
, m_PosY
);
288 for (wxHtmlCell
*parent
= m_Parent
; parent
&& parent
!= rootCell
;
289 parent
= parent
->m_Parent
)
291 p
.x
+= parent
->m_PosX
;
292 p
.y
+= parent
->m_PosY
;
297 wxHtmlCell
*wxHtmlCell::GetRootCell() const
299 wxHtmlCell
*c
= wxConstCast(this, wxHtmlCell
);
300 while ( c
->m_Parent
)
305 unsigned wxHtmlCell::GetDepth() const
308 for (wxHtmlCell
*p
= m_Parent
; p
; p
= p
->m_Parent
)
313 bool wxHtmlCell::IsBefore(wxHtmlCell
*cell
) const
315 const wxHtmlCell
*c1
= this;
316 const wxHtmlCell
*c2
= cell
;
317 unsigned d1
= GetDepth();
318 unsigned d2
= cell
->GetDepth();
321 for (; d1
!= d2
; d1
-- )
324 for (; d1
!= d2
; d2
-- )
332 if ( c1
->m_Parent
== c2
->m_Parent
)
349 wxFAIL_MSG(wxT("Cells are in different trees"));
354 //-----------------------------------------------------------------------------
356 //-----------------------------------------------------------------------------
358 IMPLEMENT_ABSTRACT_CLASS(wxHtmlWordCell
, wxHtmlCell
)
360 wxHtmlWordCell::wxHtmlWordCell(const wxString
& word
, const wxDC
& dc
) : wxHtmlCell()
364 dc
.GetTextExtent(m_Word
, &w
, &h
, &d
);
368 SetCanLiveOnPagebreak(false);
369 m_allowLinebreak
= true;
372 void wxHtmlWordCell::SetPreviousWord(wxHtmlWordCell
*cell
)
374 if ( cell
&& m_Parent
== cell
->m_Parent
&&
375 !wxIsspace(cell
->m_Word
.Last()) && !wxIsspace(m_Word
[0u]) )
377 m_allowLinebreak
= false;
381 // Splits m_Word into up to three parts according to selection, returns
382 // substring before, in and after selection and the points (in relative coords)
383 // where s2 and s3 start:
384 void wxHtmlWordCell::Split(const wxDC
& dc
,
385 const wxPoint
& selFrom
, const wxPoint
& selTo
,
386 unsigned& pos1
, unsigned& pos2
) const
388 wxPoint pt1
= (selFrom
== wxDefaultPosition
) ?
389 wxDefaultPosition
: selFrom
- GetAbsPos();
390 wxPoint pt2
= (selTo
== wxDefaultPosition
) ?
391 wxPoint(m_Width
, wxDefaultCoord
) : selTo
- GetAbsPos();
393 // if the selection is entirely within this cell, make sure pt1 < pt2 in
394 // order to make the rest of this function simpler:
395 if ( selFrom
!= wxDefaultPosition
&& selTo
!= wxDefaultPosition
&&
396 selFrom
.x
> selTo
.x
)
403 unsigned len
= m_Word
.length();
407 // adjust for cases when the start/end position is completely
411 if ( pt2
.y
>= m_Height
)
415 // (include character under caret only if in first half of width)
417 // implementation using PartialExtents to support fractional widths
419 dc
.GetPartialTextExtents(m_Word
,widths
) ;
420 while( i
< len
&& pt1
.x
>= widths
[i
] )
424 int charW
= (i
> 0) ? widths
[i
] - widths
[i
-1] : widths
[i
];
425 if ( widths
[i
] - pt1
.x
< charW
/2 )
429 wxCoord charW
, charH
;
430 while ( pt1
.x
> 0 && i
< len
)
432 dc
.GetTextExtent(m_Word
[i
], &charW
, &charH
);
434 if ( pt1
.x
>= -charW
/2 )
440 #endif // __WXMAC__/!__WXMAC__
443 // (include character under caret only if in first half of width)
446 while( j
< len
&& pt2
.x
>= widths
[j
] )
450 int charW
= (j
> 0) ? widths
[j
] - widths
[j
-1] : widths
[j
];
451 if ( widths
[j
] - pt2
.x
< charW
/2 )
457 while ( pt2
.x
> 0 && j
< len
)
459 dc
.GetTextExtent(m_Word
[j
], &charW
, &charH
);
461 if ( pt2
.x
>= -charW
/2 )
467 #endif // __WXMAC__/!__WXMAC__
472 wxASSERT( pos2
>= pos1
);
475 void wxHtmlWordCell::SetSelectionPrivPos(const wxDC
& dc
, wxHtmlSelection
*s
) const
480 this == s
->GetFromCell() ? s
->GetFromPos() : wxDefaultPosition
,
481 this == s
->GetToCell() ? s
->GetToPos() : wxDefaultPosition
,
484 if ( this == s
->GetFromCell() )
485 s
->SetFromCharacterPos (p1
); // selection starts here
486 if ( this == s
->GetToCell() )
487 s
->SetToCharacterPos (p2
); // selection ends here
491 static void SwitchSelState(wxDC
& dc
, wxHtmlRenderingInfo
& info
,
494 wxColour fg
= info
.GetState().GetFgColour();
495 wxColour bg
= info
.GetState().GetBgColour();
499 dc
.SetBackgroundMode(wxBRUSHSTYLE_SOLID
);
500 dc
.SetTextForeground(info
.GetStyle().GetSelectedTextColour(fg
));
501 dc
.SetTextBackground(info
.GetStyle().GetSelectedTextBgColour(bg
));
502 dc
.SetBackground(wxBrush(info
.GetStyle().GetSelectedTextBgColour(bg
),
503 wxBRUSHSTYLE_SOLID
));
507 dc
.SetBackgroundMode(wxBRUSHSTYLE_TRANSPARENT
);
508 dc
.SetTextForeground(fg
);
509 dc
.SetTextBackground(bg
);
510 dc
.SetBackground(wxBrush(bg
, wxBRUSHSTYLE_SOLID
));
515 void wxHtmlWordCell::Draw(wxDC
& dc
, int x
, int y
,
516 int WXUNUSED(view_y1
), int WXUNUSED(view_y2
),
517 wxHtmlRenderingInfo
& info
)
519 #if 0 // useful for debugging
520 dc
.SetPen(*wxBLACK_PEN
);
521 dc
.DrawRectangle(x
+m_PosX
,y
+m_PosY
,m_Width
/* VZ: +1? */ ,m_Height
);
524 bool drawSelectionAfterCell
= false;
526 if ( info
.GetState().GetSelectionState() == wxHTML_SEL_CHANGING
)
528 // Selection changing, we must draw the word piecewise:
529 wxHtmlSelection
*s
= info
.GetSelection();
534 // NB: this is quite a hack: in order to compute selection boundaries
535 // (in word's characters) we must know current font, which is only
536 // possible inside rendering code. Therefore we update the
537 // information here and store it in wxHtmlSelection so that
538 // ConvertToText can use it later:
539 if ( !s
->AreFromToCharacterPosSet () )
541 SetSelectionPrivPos(dc
, s
);
544 int part1
= s
->GetFromCell()==this ? s
->GetFromCharacterPos() : 0;
545 int part2
= s
->GetToCell()==this ? s
->GetToCharacterPos() : m_Word
.Length();
549 txt
= m_Word
.Mid(0, part1
);
550 dc
.DrawText(txt
, x
+ m_PosX
, y
+ m_PosY
);
551 dc
.GetTextExtent(txt
, &w
, &h
);
555 SwitchSelState(dc
, info
, true);
557 txt
= m_Word
.Mid(part1
, part2
-part1
);
558 dc
.DrawText(txt
, ofs
+ x
+ m_PosX
, y
+ m_PosY
);
560 if ( (size_t)part2
< m_Word
.length() )
562 dc
.GetTextExtent(txt
, &w
, &h
);
564 SwitchSelState(dc
, info
, false);
565 txt
= m_Word
.Mid(part2
);
566 dc
.DrawText(txt
, ofs
+ x
+ m_PosX
, y
+ m_PosY
);
569 drawSelectionAfterCell
= true;
573 wxHtmlSelectionState selstate
= info
.GetState().GetSelectionState();
574 // Not changing selection state, draw the word in single mode:
575 if ( selstate
!= wxHTML_SEL_OUT
&&
576 dc
.GetBackgroundMode() != wxBRUSHSTYLE_SOLID
)
578 SwitchSelState(dc
, info
, true);
580 else if ( selstate
== wxHTML_SEL_OUT
&&
581 dc
.GetBackgroundMode() == wxBRUSHSTYLE_SOLID
)
583 SwitchSelState(dc
, info
, false);
585 dc
.DrawText(m_Word
, x
+ m_PosX
, y
+ m_PosY
);
586 drawSelectionAfterCell
= (selstate
!= wxHTML_SEL_OUT
);
589 // NB: If the text is justified then there is usually some free space
590 // between adjacent cells and drawing the selection only onto cells
591 // would result in ugly unselected spaces. The code below detects
592 // this special case and renders the selection *outside* the sell,
594 if ( m_Parent
->GetAlignHor() == wxHTML_ALIGN_JUSTIFY
&&
595 drawSelectionAfterCell
)
597 wxHtmlCell
*nextCell
= m_Next
;
598 while ( nextCell
&& nextCell
->IsFormattingCell() )
599 nextCell
= nextCell
->GetNext();
602 int nextX
= nextCell
->GetPosX();
603 if ( m_PosX
+ m_Width
< nextX
)
605 dc
.SetBrush(dc
.GetBackground());
606 dc
.SetPen(*wxTRANSPARENT_PEN
);
607 dc
.DrawRectangle(x
+ m_PosX
+ m_Width
, y
+ m_PosY
,
608 nextX
- m_PosX
- m_Width
, m_Height
);
614 wxCursor
wxHtmlWordCell::GetMouseCursor(wxHtmlWindowInterface
*window
) const
618 return window
->GetHTMLCursor(wxHtmlWindowInterface::HTMLCursor_Text
);
622 return wxHtmlCell::GetMouseCursor(window
);
626 wxString
wxHtmlWordCell::ConvertToText(wxHtmlSelection
*s
) const
628 if ( s
&& (this == s
->GetFromCell() || this == s
->GetToCell()) )
630 // VZ: we may be called before we had a chance to re-render ourselves
631 // and in this case GetFrom/ToPrivPos() is not set yet -- assume
632 // that this only happens in case of a double/triple click (which
633 // seems to be the case now) and so it makes sense to select the
634 // entire contents of the cell in this case
636 // TODO: but this really needs to be fixed in some better way later...
637 if ( s
->AreFromToCharacterPosSet() )
639 const int part1
= s
->GetFromCell()==this ? s
->GetFromCharacterPos() : 0;
640 const int part2
= s
->GetToCell()==this ? s
->GetToCharacterPos() : m_Word
.Length();
641 if ( part1
== part2
)
642 return wxEmptyString
;
643 return GetPartAsText(part1
, part2
);
645 //else: return the whole word below
648 return GetAllAsText();
651 wxString
wxHtmlWordWithTabsCell::GetAllAsText() const
656 wxString
wxHtmlWordWithTabsCell::GetPartAsText(int begin
, int end
) const
658 // NB: The 'begin' and 'end' positions are in the _displayed_ text
659 // (stored in m_Word) and not in the text with tabs that should
660 // be copied to clipboard (m_wordOrig).
662 // NB: Because selection is performed on displayed text, it's possible
663 // to select e.g. "half of TAB character" -- IOW, 'begin' and 'end'
664 // may be in the middle of TAB character expansion into ' 's. In this
665 // case, we copy the TAB character to clipboard once.
667 wxASSERT( begin
< end
);
669 const unsigned SPACES_PER_TAB
= 8;
674 wxString::const_iterator i
= m_wordOrig
.begin();
676 // find the beginning of text to copy:
677 for ( ; pos
< begin
; ++i
)
681 pos
+= 8 - (m_linepos
+ pos
) % SPACES_PER_TAB
;
693 // copy the content until we reach 'end':
694 for ( ; pos
< end
; ++i
)
700 pos
+= 8 - (m_linepos
+ pos
) % SPACES_PER_TAB
;
710 //-----------------------------------------------------------------------------
711 // wxHtmlContainerCell
712 //-----------------------------------------------------------------------------
714 IMPLEMENT_ABSTRACT_CLASS(wxHtmlContainerCell
, wxHtmlCell
)
716 wxHtmlContainerCell::wxHtmlContainerCell(wxHtmlContainerCell
*parent
) : wxHtmlCell()
718 m_Cells
= m_LastCell
= NULL
;
721 if (m_Parent
) m_Parent
->InsertCell(this);
722 m_AlignHor
= wxHTML_ALIGN_LEFT
;
723 m_AlignVer
= wxHTML_ALIGN_BOTTOM
;
724 m_IndentLeft
= m_IndentRight
= m_IndentTop
= m_IndentBottom
= 0;
725 m_WidthFloat
= 100; m_WidthFloatUnits
= wxHTML_UNITS_PERCENT
;
726 m_UseBkColour
= false;
729 m_MinHeightAlign
= wxHTML_ALIGN_TOP
;
733 wxHtmlContainerCell::~wxHtmlContainerCell()
735 wxHtmlCell
*cell
= m_Cells
;
738 wxHtmlCell
*cellNext
= cell
->GetNext();
746 void wxHtmlContainerCell::SetIndent(int i
, int what
, int units
)
748 int val
= (units
== wxHTML_UNITS_PIXELS
) ? i
: -i
;
749 if (what
& wxHTML_INDENT_LEFT
) m_IndentLeft
= val
;
750 if (what
& wxHTML_INDENT_RIGHT
) m_IndentRight
= val
;
751 if (what
& wxHTML_INDENT_TOP
) m_IndentTop
= val
;
752 if (what
& wxHTML_INDENT_BOTTOM
) m_IndentBottom
= val
;
758 int wxHtmlContainerCell::GetIndent(int ind
) const
760 if (ind
& wxHTML_INDENT_LEFT
) return m_IndentLeft
;
761 else if (ind
& wxHTML_INDENT_RIGHT
) return m_IndentRight
;
762 else if (ind
& wxHTML_INDENT_TOP
) return m_IndentTop
;
763 else if (ind
& wxHTML_INDENT_BOTTOM
) return m_IndentBottom
;
764 else return -1; /* BUG! Should not be called... */
770 int wxHtmlContainerCell::GetIndentUnits(int ind
) const
773 if (ind
& wxHTML_INDENT_LEFT
) p
= m_IndentLeft
< 0;
774 else if (ind
& wxHTML_INDENT_RIGHT
) p
= m_IndentRight
< 0;
775 else if (ind
& wxHTML_INDENT_TOP
) p
= m_IndentTop
< 0;
776 else if (ind
& wxHTML_INDENT_BOTTOM
) p
= m_IndentBottom
< 0;
777 if (p
) return wxHTML_UNITS_PERCENT
;
778 else return wxHTML_UNITS_PIXELS
;
783 wxHtmlContainerCell::AdjustPagebreak(int *pagebreak
,
784 const wxArrayInt
& known_pagebreaks
,
785 int pageHeight
) const
787 if (!m_CanLiveOnPagebreak
)
788 return wxHtmlCell::AdjustPagebreak(pagebreak
, known_pagebreaks
, pageHeight
);
790 wxHtmlCell
*c
= GetFirstChild();
792 int pbrk
= *pagebreak
- m_PosY
;
796 if (c
->AdjustPagebreak(&pbrk
, known_pagebreaks
, pageHeight
))
801 *pagebreak
= pbrk
+ m_PosY
;
806 void wxHtmlContainerCell::Layout(int w
)
808 wxHtmlCell::Layout(w
);
810 if (m_LastLayout
== w
)
814 // VS: Any attempt to layout with negative or zero width leads to hell,
815 // but we can't ignore such attempts completely, since it sometimes
816 // happen (e.g. when trying how small a table can be). The best thing we
817 // can do is to set the width of child cells to zero
821 for (wxHtmlCell
*cell
= m_Cells
; cell
; cell
= cell
->GetNext())
823 // this does two things: it recursively calls this code on all
824 // child contrainers and resets children's position to (0,0)
828 wxHtmlCell
*nextCell
;
829 long xpos
= 0, ypos
= m_IndentTop
;
830 int xdelta
= 0, ybasicpos
= 0, ydiff
;
831 int s_width
, nextWordWidth
, s_indent
;
832 int ysizeup
= 0, ysizedown
= 0;
833 int MaxLineWidth
= 0;
834 int curLineWidth
= 0;
844 if (m_WidthFloatUnits
== wxHTML_UNITS_PERCENT
)
846 if (m_WidthFloat
< 0) m_Width
= (100 + m_WidthFloat
) * w
/ 100;
847 else m_Width
= m_WidthFloat
* w
/ 100;
851 if (m_WidthFloat
< 0) m_Width
= w
+ m_WidthFloat
;
852 else m_Width
= m_WidthFloat
;
857 int l
= (m_IndentLeft
< 0) ? (-m_IndentLeft
* m_Width
/ 100) : m_IndentLeft
;
858 int r
= (m_IndentRight
< 0) ? (-m_IndentRight
* m_Width
/ 100) : m_IndentRight
;
859 for (wxHtmlCell
*cell
= m_Cells
; cell
; cell
= cell
->GetNext())
860 cell
->Layout(m_Width
- (l
+ r
));
869 // adjust indentation:
870 s_indent
= (m_IndentLeft
< 0) ? (-m_IndentLeft
* m_Width
/ 100) : m_IndentLeft
;
871 s_width
= m_Width
- s_indent
- ((m_IndentRight
< 0) ? (-m_IndentRight
* m_Width
/ 100) : m_IndentRight
);
874 wxHtmlCell
*cell
= m_Cells
,
880 case wxHTML_ALIGN_TOP
: ybasicpos
= 0; break;
881 case wxHTML_ALIGN_BOTTOM
: ybasicpos
= - cell
->GetHeight(); break;
882 case wxHTML_ALIGN_CENTER
: ybasicpos
= - cell
->GetHeight() / 2; break;
884 ydiff
= cell
->GetHeight() + ybasicpos
;
886 if (cell
->GetDescent() + ydiff
> ysizedown
) ysizedown
= cell
->GetDescent() + ydiff
;
887 if (ybasicpos
+ cell
->GetDescent() < -ysizeup
) ysizeup
= - (ybasicpos
+ cell
->GetDescent());
889 // layout nonbreakable run of cells:
890 cell
->SetPos(xpos
, ybasicpos
+ cell
->GetDescent());
891 xpos
+= cell
->GetWidth();
892 if (!cell
->IsTerminalCell())
894 // Container cell indicates new line
895 if (curLineWidth
> m_MaxTotalWidth
)
896 m_MaxTotalWidth
= curLineWidth
;
898 if (wxMax(cell
->GetWidth(), cell
->GetMaxTotalWidth()) > m_MaxTotalWidth
)
899 m_MaxTotalWidth
= cell
->GetMaxTotalWidth();
903 // Normal cell, add maximum cell width to line width
904 curLineWidth
+= cell
->GetMaxTotalWidth();
906 cell
= cell
->GetNext();
908 // compute length of the next word that would be added:
915 nextWordWidth
+= nextCell
->GetWidth();
916 nextCell
= nextCell
->GetNext();
917 } while (nextCell
&& !nextCell
->IsLinebreakAllowed());
920 // force new line if occurred:
921 if ((cell
== NULL
) ||
922 (xpos
+ nextWordWidth
> s_width
&& cell
->IsLinebreakAllowed()))
924 if (xpos
> MaxLineWidth
) MaxLineWidth
= xpos
;
925 if (ysizeup
< 0) ysizeup
= 0;
926 if (ysizedown
< 0) ysizedown
= 0;
927 switch (m_AlignHor
) {
928 case wxHTML_ALIGN_LEFT
:
929 case wxHTML_ALIGN_JUSTIFY
:
932 case wxHTML_ALIGN_RIGHT
:
933 xdelta
= 0 + (s_width
- xpos
);
935 case wxHTML_ALIGN_CENTER
:
936 xdelta
= 0 + (s_width
- xpos
) / 2;
939 if (xdelta
< 0) xdelta
= 0;
944 if (m_AlignHor
!= wxHTML_ALIGN_JUSTIFY
|| cell
== NULL
)
948 line
->SetPos(line
->GetPosX() + xdelta
,
949 ypos
+ line
->GetPosY());
950 line
= line
->GetNext();
953 else // align == justify
955 // we have to distribute the extra horz space between the cells
958 // an added complication is that some cells have fixed size and
959 // shouldn't get any increment (it so happens that these cells
960 // also don't allow line break on them which provides with an
961 // easy way to test for this) -- and neither should the cells
962 // adjacent to them as this could result in a visible space
963 // between two cells separated by, e.g. font change, cell which
966 int step
= s_width
- xpos
;
969 // first count the cells which will get extra space
975 for ( c
= line
; c
!= cell
; c
= c
->GetNext() )
977 if ( c
->IsLinebreakAllowed() )
984 // and now extra space to those cells which merit it
987 // first visible cell on line is not moved:
988 while (line
!=cell
&& !line
->IsLinebreakAllowed())
990 line
->SetPos(line
->GetPosX() + s_indent
,
991 line
->GetPosY() + ypos
);
992 line
= line
->GetNext();
997 line
->SetPos(line
->GetPosX() + s_indent
,
998 line
->GetPosY() + ypos
);
1000 line
= line
->GetNext();
1003 for ( int n
= 0; line
!= cell
; line
= line
->GetNext() )
1005 if ( line
->IsLinebreakAllowed() )
1007 // offset the next cell relative to this one
1008 // thus increasing our size
1012 line
->SetPos(line
->GetPosX() + s_indent
+
1013 ((n
* step
) / total
),
1014 line
->GetPosY() + ypos
);
1019 // this will cause the code to enter "else branch" below:
1024 if ( step
<= 0 ) // no extra space to distribute
1026 // just set the indent properly
1027 while (line
!= cell
)
1029 line
->SetPos(line
->GetPosX() + s_indent
,
1030 line
->GetPosY() + ypos
);
1031 line
= line
->GetNext();
1038 ysizeup
= ysizedown
= 0;
1043 // setup height & width, depending on container layout:
1044 m_Height
= ypos
+ (ysizedown
+ ysizeup
) + m_IndentBottom
;
1046 if (m_Height
< m_MinHeight
)
1048 if (m_MinHeightAlign
!= wxHTML_ALIGN_TOP
)
1050 int diff
= m_MinHeight
- m_Height
;
1051 if (m_MinHeightAlign
== wxHTML_ALIGN_CENTER
) diff
/= 2;
1055 cell
->SetPos(cell
->GetPosX(), cell
->GetPosY() + diff
);
1056 cell
= cell
->GetNext();
1059 m_Height
= m_MinHeight
;
1062 if (curLineWidth
> m_MaxTotalWidth
)
1063 m_MaxTotalWidth
= curLineWidth
;
1065 m_MaxTotalWidth
+= s_indent
+ ((m_IndentRight
< 0) ? (-m_IndentRight
* m_Width
/ 100) : m_IndentRight
);
1066 MaxLineWidth
+= s_indent
+ ((m_IndentRight
< 0) ? (-m_IndentRight
* m_Width
/ 100) : m_IndentRight
);
1067 if (m_Width
< MaxLineWidth
) m_Width
= MaxLineWidth
;
1070 void wxHtmlContainerCell::UpdateRenderingStatePre(wxHtmlRenderingInfo
& info
,
1071 wxHtmlCell
*cell
) const
1073 wxHtmlSelection
*s
= info
.GetSelection();
1075 if (s
->GetFromCell() == cell
|| s
->GetToCell() == cell
)
1077 info
.GetState().SetSelectionState(wxHTML_SEL_CHANGING
);
1081 void wxHtmlContainerCell::UpdateRenderingStatePost(wxHtmlRenderingInfo
& info
,
1082 wxHtmlCell
*cell
) const
1084 wxHtmlSelection
*s
= info
.GetSelection();
1086 if (s
->GetToCell() == cell
)
1087 info
.GetState().SetSelectionState(wxHTML_SEL_OUT
);
1088 else if (s
->GetFromCell() == cell
)
1089 info
.GetState().SetSelectionState(wxHTML_SEL_IN
);
1092 #define mMin(a, b) (((a) < (b)) ? (a) : (b))
1093 #define mMax(a, b) (((a) < (b)) ? (b) : (a))
1095 void wxHtmlContainerCell::Draw(wxDC
& dc
, int x
, int y
, int view_y1
, int view_y2
,
1096 wxHtmlRenderingInfo
& info
)
1098 #if 0 // useful for debugging
1099 dc
.SetPen(*wxRED_PEN
);
1100 dc
.DrawRectangle(x
+m_PosX
,y
+m_PosY
,m_Width
,m_Height
);
1103 int xlocal
= x
+ m_PosX
;
1104 int ylocal
= y
+ m_PosY
;
1108 wxBrush myb
= wxBrush(m_BkColour
, wxBRUSHSTYLE_SOLID
);
1110 int real_y1
= mMax(ylocal
, view_y1
);
1111 int real_y2
= mMin(ylocal
+ m_Height
- 1, view_y2
);
1114 dc
.SetPen(*wxTRANSPARENT_PEN
);
1115 dc
.DrawRectangle(xlocal
, real_y1
, m_Width
, real_y2
- real_y1
+ 1);
1120 // draw thin border using lines
1121 wxPen
mypen1(m_BorderColour1
, 1, wxPENSTYLE_SOLID
);
1122 wxPen
mypen2(m_BorderColour2
, 1, wxPENSTYLE_SOLID
);
1125 dc
.DrawLine(xlocal
, ylocal
, xlocal
, ylocal
+ m_Height
- 1);
1126 dc
.DrawLine(xlocal
, ylocal
, xlocal
+ m_Width
, ylocal
);
1128 dc
.DrawLine(xlocal
+ m_Width
- 1, ylocal
, xlocal
+ m_Width
- 1, ylocal
+ m_Height
- 1);
1129 dc
.DrawLine(xlocal
, ylocal
+ m_Height
- 1, xlocal
+ m_Width
, ylocal
+ m_Height
- 1);
1131 else if (m_Border
> 0)
1133 wxBrush
mybrush1(m_BorderColour1
, wxBRUSHSTYLE_SOLID
);
1134 wxBrush
mybrush2(m_BorderColour2
, wxBRUSHSTYLE_SOLID
);
1136 // draw upper left corner
1137 // 0---------------5
1146 poly
[0].x
=m_PosX
; poly
[0].y
= m_PosY
;
1147 poly
[1].x
=m_PosX
; poly
[1].y
= m_PosY
+ m_Height
;
1148 poly
[2].x
=m_PosX
+ m_Border
; poly
[2].y
= poly
[1].y
- m_Border
;
1149 poly
[3].x
=poly
[2].x
; poly
[3].y
= m_PosY
+ m_Border
;
1150 poly
[4].x
=m_PosX
+ m_Width
- m_Border
; poly
[4].y
= poly
[3].y
;
1151 poly
[5].x
=m_PosX
+ m_Width
; poly
[5].y
= m_PosY
;
1153 dc
.SetBrush(mybrush1
);
1154 dc
.SetPen(*wxTRANSPARENT_PEN
);
1155 dc
.DrawPolygon(6, poly
, x
, y
);
1157 // draw lower right corner reusing point 1,2,4 and 5
1164 // 1---------------0
1165 dc
.SetBrush(mybrush2
);
1166 poly
[0].x
= poly
[5].x
; poly
[0].y
= poly
[1].y
;
1167 poly
[3].x
= poly
[4].x
; poly
[3].y
= poly
[2].y
;
1168 dc
.DrawPolygon(6, poly
, x
, y
);
1170 // smooth color transition like firefox
1171 wxColour
borderMediumColour(
1172 (m_BorderColour1
.Red() + m_BorderColour2
.Red()) /2 ,
1173 (m_BorderColour1
.Green() + m_BorderColour2
.Green()) /2 ,
1174 (m_BorderColour1
.Blue() + m_BorderColour2
.Blue()) /2
1176 wxPen
mypen3(borderMediumColour
, 1, wxPENSTYLE_SOLID
);
1178 dc
.DrawLines(2, &poly
[1], x
, y
- 1); // between 1 and 2
1179 dc
.DrawLines(2, &poly
[4], x
, y
- 1); // between 4 and 5
1183 // draw container's contents:
1184 for (wxHtmlCell
*cell
= m_Cells
; cell
; cell
= cell
->GetNext())
1187 // optimize drawing: don't render off-screen content:
1188 if ((ylocal
+ cell
->GetPosY() <= view_y2
) &&
1189 (ylocal
+ cell
->GetPosY() + cell
->GetHeight() > view_y1
))
1191 // the cell is visible, draw it:
1192 UpdateRenderingStatePre(info
, cell
);
1194 xlocal
, ylocal
, view_y1
, view_y2
,
1196 UpdateRenderingStatePost(info
, cell
);
1200 // the cell is off-screen, proceed with font+color+etc.
1202 cell
->DrawInvisible(dc
, xlocal
, ylocal
, info
);
1210 void wxHtmlContainerCell::DrawInvisible(wxDC
& dc
, int x
, int y
,
1211 wxHtmlRenderingInfo
& info
)
1215 for (wxHtmlCell
*cell
= m_Cells
; cell
; cell
= cell
->GetNext())
1217 UpdateRenderingStatePre(info
, cell
);
1218 cell
->DrawInvisible(dc
, x
+ m_PosX
, y
+ m_PosY
, info
);
1219 UpdateRenderingStatePost(info
, cell
);
1225 wxColour
wxHtmlContainerCell::GetBackgroundColour()
1230 return wxNullColour
;
1235 wxHtmlLinkInfo
*wxHtmlContainerCell::GetLink(int x
, int y
) const
1237 wxHtmlCell
*cell
= FindCellByPos(x
, y
);
1239 // VZ: I don't know if we should pass absolute or relative coords to
1240 // wxHtmlCell::GetLink()? As the base class version just ignores them
1241 // anyhow, it hardly matters right now but should still be clarified
1242 return cell
? cell
->GetLink(x
, y
) : NULL
;
1247 void wxHtmlContainerCell::InsertCell(wxHtmlCell
*f
)
1249 if (!m_Cells
) m_Cells
= m_LastCell
= f
;
1252 m_LastCell
->SetNext(f
);
1254 if (m_LastCell
) while (m_LastCell
->GetNext()) m_LastCell
= m_LastCell
->GetNext();
1262 void wxHtmlContainerCell::SetAlign(const wxHtmlTag
& tag
)
1264 if (tag
.HasParam(wxT("ALIGN")))
1266 wxString alg
= tag
.GetParam(wxT("ALIGN"));
1268 if (alg
== wxT("CENTER"))
1269 SetAlignHor(wxHTML_ALIGN_CENTER
);
1270 else if (alg
== wxT("LEFT"))
1271 SetAlignHor(wxHTML_ALIGN_LEFT
);
1272 else if (alg
== wxT("JUSTIFY"))
1273 SetAlignHor(wxHTML_ALIGN_JUSTIFY
);
1274 else if (alg
== wxT("RIGHT"))
1275 SetAlignHor(wxHTML_ALIGN_RIGHT
);
1282 void wxHtmlContainerCell::SetWidthFloat(const wxHtmlTag
& tag
, double pixel_scale
)
1284 if (tag
.HasParam(wxT("WIDTH")))
1287 wxString wd
= tag
.GetParam(wxT("WIDTH"));
1289 if (wd
[wd
.length()-1] == wxT('%'))
1291 wxSscanf(wd
.c_str(), wxT("%i%%"), &wdi
);
1292 SetWidthFloat(wdi
, wxHTML_UNITS_PERCENT
);
1296 wxSscanf(wd
.c_str(), wxT("%i"), &wdi
);
1297 SetWidthFloat((int)(pixel_scale
* (double)wdi
), wxHTML_UNITS_PIXELS
);
1305 const wxHtmlCell
* wxHtmlContainerCell::Find(int condition
, const void* param
) const
1309 for (wxHtmlCell
*cell
= m_Cells
; cell
; cell
= cell
->GetNext())
1311 const wxHtmlCell
*r
= cell
->Find(condition
, param
);
1319 wxHtmlCell
*wxHtmlContainerCell::FindCellByPos(wxCoord x
, wxCoord y
,
1320 unsigned flags
) const
1322 if ( flags
& wxHTML_FIND_EXACT
)
1324 for ( const wxHtmlCell
*cell
= m_Cells
; cell
; cell
= cell
->GetNext() )
1326 int cx
= cell
->GetPosX(),
1327 cy
= cell
->GetPosY();
1329 if ( (cx
<= x
) && (cx
+ cell
->GetWidth() > x
) &&
1330 (cy
<= y
) && (cy
+ cell
->GetHeight() > y
) )
1332 return cell
->FindCellByPos(x
- cx
, y
- cy
, flags
);
1336 else if ( flags
& wxHTML_FIND_NEAREST_AFTER
)
1339 for ( const wxHtmlCell
*cell
= m_Cells
; cell
; cell
= cell
->GetNext() )
1341 if ( cell
->IsFormattingCell() )
1343 int cellY
= cell
->GetPosY();
1344 if (!( y
< cellY
|| (y
< cellY
+ cell
->GetHeight() &&
1345 x
< cell
->GetPosX() + cell
->GetWidth()) ))
1348 c
= cell
->FindCellByPos(x
- cell
->GetPosX(), y
- cellY
, flags
);
1352 else if ( flags
& wxHTML_FIND_NEAREST_BEFORE
)
1354 wxHtmlCell
*c2
, *c
= NULL
;
1355 for ( const wxHtmlCell
*cell
= m_Cells
; cell
; cell
= cell
->GetNext() )
1357 if ( cell
->IsFormattingCell() )
1359 int cellY
= cell
->GetPosY();
1360 if (!( cellY
+ cell
->GetHeight() <= y
||
1361 (y
>= cellY
&& x
>= cell
->GetPosX()) ))
1363 c2
= cell
->FindCellByPos(x
- cell
->GetPosX(), y
- cellY
, flags
);
1374 bool wxHtmlContainerCell::ProcessMouseClick(wxHtmlWindowInterface
*window
,
1376 const wxMouseEvent
& event
)
1378 #if WXWIN_COMPATIBILITY_2_6
1379 wxHtmlCellOnMouseClickCompatHelper
compat(window
, pos
, event
);
1380 return compat
.CallOnMouseClick(this);
1383 void wxHtmlContainerCell::OnMouseClick(wxWindow
*,
1384 int, int, const wxMouseEvent
& event
)
1386 wxCHECK_RET( gs_helperOnMouseClick
, wxT("unexpected call to OnMouseClick") );
1387 wxHtmlWindowInterface
*window
= gs_helperOnMouseClick
->window
;
1388 const wxPoint
& pos
= gs_helperOnMouseClick
->pos
;
1389 #endif // WXWIN_COMPATIBILITY_2_6
1391 bool retval
= false;
1392 wxHtmlCell
*cell
= FindCellByPos(pos
.x
, pos
.y
);
1394 retval
= cell
->ProcessMouseClick(window
, pos
, event
);
1396 #if WXWIN_COMPATIBILITY_2_6
1397 gs_helperOnMouseClick
->retval
= retval
;
1400 #endif // WXWIN_COMPATIBILITY_2_6
1404 wxHtmlCell
*wxHtmlContainerCell::GetFirstTerminal() const
1409 for (wxHtmlCell
*c
= m_Cells
; c
; c
= c
->GetNext())
1411 c2
= c
->GetFirstTerminal();
1419 wxHtmlCell
*wxHtmlContainerCell::GetLastTerminal() const
1423 // most common case first:
1424 wxHtmlCell
*c
= m_LastCell
->GetLastTerminal();
1429 wxHtmlCell
*c2
= NULL
;
1430 for (c
= m_Cells
; c
; c
= c
->GetNext())
1432 ctmp
= c
->GetLastTerminal();
1443 static bool IsEmptyContainer(wxHtmlContainerCell
*cell
)
1445 for ( wxHtmlCell
*c
= cell
->GetFirstChild(); c
; c
= c
->GetNext() )
1447 if ( !c
->IsTerminalCell() || !c
->IsFormattingCell() )
1453 void wxHtmlContainerCell::RemoveExtraSpacing(bool top
, bool bottom
)
1456 SetIndent(0, wxHTML_INDENT_TOP
);
1458 SetIndent(0, wxHTML_INDENT_BOTTOM
);
1463 wxHtmlContainerCell
*cont
;
1466 for ( c
= m_Cells
; c
; c
= c
->GetNext() )
1468 if ( c
->IsTerminalCell() )
1470 if ( !c
->IsFormattingCell() )
1475 cont
= (wxHtmlContainerCell
*)c
;
1476 if ( IsEmptyContainer(cont
) )
1478 cont
->SetIndent(0, wxHTML_INDENT_VERTICAL
);
1482 cont
->RemoveExtraSpacing(true, false);
1492 for ( c
= m_Cells
; c
; c
= c
->GetNext() )
1495 for ( int i
= arr
.GetCount() - 1; i
>= 0; i
--)
1497 c
= (wxHtmlCell
*)arr
[i
];
1498 if ( c
->IsTerminalCell() )
1500 if ( !c
->IsFormattingCell() )
1505 cont
= (wxHtmlContainerCell
*)c
;
1506 if ( IsEmptyContainer(cont
) )
1508 cont
->SetIndent(0, wxHTML_INDENT_VERTICAL
);
1512 cont
->RemoveExtraSpacing(false, true);
1524 // --------------------------------------------------------------------------
1526 // --------------------------------------------------------------------------
1528 IMPLEMENT_ABSTRACT_CLASS(wxHtmlColourCell
, wxHtmlCell
)
1530 void wxHtmlColourCell::Draw(wxDC
& dc
,
1532 int WXUNUSED(view_y1
), int WXUNUSED(view_y2
),
1533 wxHtmlRenderingInfo
& info
)
1535 DrawInvisible(dc
, x
, y
, info
);
1538 void wxHtmlColourCell::DrawInvisible(wxDC
& dc
,
1539 int WXUNUSED(x
), int WXUNUSED(y
),
1540 wxHtmlRenderingInfo
& info
)
1542 wxHtmlRenderingState
& state
= info
.GetState();
1543 if (m_Flags
& wxHTML_CLR_FOREGROUND
)
1545 state
.SetFgColour(m_Colour
);
1546 if (state
.GetSelectionState() != wxHTML_SEL_IN
)
1547 dc
.SetTextForeground(m_Colour
);
1549 dc
.SetTextForeground(
1550 info
.GetStyle().GetSelectedTextColour(m_Colour
));
1552 if (m_Flags
& wxHTML_CLR_BACKGROUND
)
1554 state
.SetBgColour(m_Colour
);
1555 if (state
.GetSelectionState() != wxHTML_SEL_IN
)
1557 dc
.SetTextBackground(m_Colour
);
1558 dc
.SetBackground(wxBrush(m_Colour
, wxBRUSHSTYLE_SOLID
));
1562 wxColour c
= info
.GetStyle().GetSelectedTextBgColour(m_Colour
);
1563 dc
.SetTextBackground(c
);
1564 dc
.SetBackground(wxBrush(c
, wxBRUSHSTYLE_SOLID
));
1572 // ---------------------------------------------------------------------------
1574 // ---------------------------------------------------------------------------
1576 IMPLEMENT_ABSTRACT_CLASS(wxHtmlFontCell
, wxHtmlCell
)
1578 void wxHtmlFontCell::Draw(wxDC
& dc
,
1579 int WXUNUSED(x
), int WXUNUSED(y
),
1580 int WXUNUSED(view_y1
), int WXUNUSED(view_y2
),
1581 wxHtmlRenderingInfo
& WXUNUSED(info
))
1586 void wxHtmlFontCell::DrawInvisible(wxDC
& dc
, int WXUNUSED(x
), int WXUNUSED(y
),
1587 wxHtmlRenderingInfo
& WXUNUSED(info
))
1599 // ---------------------------------------------------------------------------
1601 // ---------------------------------------------------------------------------
1603 IMPLEMENT_ABSTRACT_CLASS(wxHtmlWidgetCell
, wxHtmlCell
)
1605 wxHtmlWidgetCell::wxHtmlWidgetCell(wxWindow
*wnd
, int w
)
1609 m_Wnd
->GetSize(&sx
, &sy
);
1610 m_Width
= sx
, m_Height
= sy
;
1615 void wxHtmlWidgetCell::Draw(wxDC
& WXUNUSED(dc
),
1616 int WXUNUSED(x
), int WXUNUSED(y
),
1617 int WXUNUSED(view_y1
), int WXUNUSED(view_y2
),
1618 wxHtmlRenderingInfo
& WXUNUSED(info
))
1620 int absx
= 0, absy
= 0, stx
, sty
;
1621 wxHtmlCell
*c
= this;
1625 absx
+= c
->GetPosX();
1626 absy
+= c
->GetPosY();
1630 wxScrolledWindow
*scrolwin
=
1631 wxDynamicCast(m_Wnd
->GetParent(), wxScrolledWindow
);
1632 wxCHECK_RET( scrolwin
,
1633 wxT("widget cells can only be placed in wxHtmlWindow") );
1635 scrolwin
->GetViewStart(&stx
, &sty
);
1636 m_Wnd
->SetSize(absx
- wxHTML_SCROLL_STEP
* stx
,
1637 absy
- wxHTML_SCROLL_STEP
* sty
,
1643 void wxHtmlWidgetCell::DrawInvisible(wxDC
& WXUNUSED(dc
),
1644 int WXUNUSED(x
), int WXUNUSED(y
),
1645 wxHtmlRenderingInfo
& WXUNUSED(info
))
1647 int absx
= 0, absy
= 0, stx
, sty
;
1648 wxHtmlCell
*c
= this;
1652 absx
+= c
->GetPosX();
1653 absy
+= c
->GetPosY();
1657 ((wxScrolledWindow
*)(m_Wnd
->GetParent()))->GetViewStart(&stx
, &sty
);
1658 m_Wnd
->SetSize(absx
- wxHTML_SCROLL_STEP
* stx
, absy
- wxHTML_SCROLL_STEP
* sty
, m_Width
, m_Height
);
1663 void wxHtmlWidgetCell::Layout(int w
)
1665 if (m_WidthFloat
!= 0)
1667 m_Width
= (w
* m_WidthFloat
) / 100;
1668 m_Wnd
->SetSize(m_Width
, m_Height
);
1671 wxHtmlCell::Layout(w
);
1676 // ----------------------------------------------------------------------------
1677 // wxHtmlTerminalCellsInterator
1678 // ----------------------------------------------------------------------------
1680 const wxHtmlCell
* wxHtmlTerminalCellsInterator::operator++()
1687 if ( m_pos
== m_to
)
1693 if ( m_pos
->GetNext() )
1694 m_pos
= m_pos
->GetNext();
1697 // we must go up the hierarchy until we reach container where this
1698 // is not the last child, and then go down to first terminal cell:
1699 while ( m_pos
->GetNext() == NULL
)
1701 m_pos
= m_pos
->GetParent();
1705 m_pos
= m_pos
->GetNext();
1707 while ( m_pos
->GetFirstChild() != NULL
)
1708 m_pos
= m_pos
->GetFirstChild();
1709 } while ( !m_pos
->IsTerminalCell() );