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 // overriden GetCursor() continues to work. The trick is that the base
205 // wxHtmlCell::GetCursor() method simply returns wxNullCursor, so we
206 // know that GetCursor() was overriden 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
);
223 bool wxHtmlCell::AdjustPagebreak(int *pagebreak
,
224 wxArrayInt
& WXUNUSED(known_pagebreaks
)) const
226 if ((!m_CanLiveOnPagebreak
) &&
227 m_PosY
< *pagebreak
&& m_PosY
+ m_Height
> *pagebreak
)
238 void wxHtmlCell::SetLink(const wxHtmlLinkInfo
& link
)
240 if (m_Link
) delete m_Link
;
242 if (link
.GetHref() != wxEmptyString
)
243 m_Link
= new wxHtmlLinkInfo(link
);
247 void wxHtmlCell::Layout(int WXUNUSED(w
))
254 const wxHtmlCell
* wxHtmlCell::Find(int WXUNUSED(condition
), const void* WXUNUSED(param
)) const
260 wxHtmlCell
*wxHtmlCell::FindCellByPos(wxCoord x
, wxCoord y
,
261 unsigned flags
) const
263 if ( x
>= 0 && x
< m_Width
&& y
>= 0 && y
< m_Height
)
265 return wxConstCast(this, wxHtmlCell
);
269 if ((flags
& wxHTML_FIND_NEAREST_AFTER
) &&
270 (y
< 0 || (y
< 0+m_Height
&& x
< 0+m_Width
)))
271 return wxConstCast(this, wxHtmlCell
);
272 else if ((flags
& wxHTML_FIND_NEAREST_BEFORE
) &&
273 (y
>= 0+m_Height
|| (y
>= 0 && x
>= 0)))
274 return wxConstCast(this, wxHtmlCell
);
281 wxPoint
wxHtmlCell::GetAbsPos(wxHtmlCell
*rootCell
) const
283 wxPoint
p(m_PosX
, m_PosY
);
284 for (wxHtmlCell
*parent
= m_Parent
; parent
&& parent
!= rootCell
;
285 parent
= parent
->m_Parent
)
287 p
.x
+= parent
->m_PosX
;
288 p
.y
+= parent
->m_PosY
;
293 wxHtmlCell
*wxHtmlCell::GetRootCell() const
295 wxHtmlCell
*c
= wxConstCast(this, wxHtmlCell
);
296 while ( c
->m_Parent
)
301 unsigned wxHtmlCell::GetDepth() const
304 for (wxHtmlCell
*p
= m_Parent
; p
; p
= p
->m_Parent
)
309 bool wxHtmlCell::IsBefore(wxHtmlCell
*cell
) const
311 const wxHtmlCell
*c1
= this;
312 const wxHtmlCell
*c2
= cell
;
313 unsigned d1
= GetDepth();
314 unsigned d2
= cell
->GetDepth();
317 for (; d1
!= d2
; d1
-- )
320 for (; d1
!= d2
; d2
-- )
328 if ( c1
->m_Parent
== c2
->m_Parent
)
345 wxFAIL_MSG(wxT("Cells are in different trees"));
350 //-----------------------------------------------------------------------------
352 //-----------------------------------------------------------------------------
354 IMPLEMENT_ABSTRACT_CLASS(wxHtmlWordCell
, wxHtmlCell
)
356 wxHtmlWordCell::wxHtmlWordCell(const wxString
& word
, const wxDC
& dc
) : wxHtmlCell()
360 dc
.GetTextExtent(m_Word
, &w
, &h
, &d
);
364 SetCanLiveOnPagebreak(false);
365 m_allowLinebreak
= true;
368 void wxHtmlWordCell::SetPreviousWord(wxHtmlWordCell
*cell
)
370 if ( cell
&& m_Parent
== cell
->m_Parent
&&
371 !wxIsspace(cell
->m_Word
.Last()) && !wxIsspace(m_Word
[0u]) )
373 m_allowLinebreak
= false;
377 // Splits m_Word into up to three parts according to selection, returns
378 // substring before, in and after selection and the points (in relative coords)
379 // where s2 and s3 start:
380 void wxHtmlWordCell::Split(const wxDC
& dc
,
381 const wxPoint
& selFrom
, const wxPoint
& selTo
,
382 unsigned& pos1
, unsigned& pos2
) const
384 wxPoint pt1
= (selFrom
== wxDefaultPosition
) ?
385 wxDefaultPosition
: selFrom
- GetAbsPos();
386 wxPoint pt2
= (selTo
== wxDefaultPosition
) ?
387 wxPoint(m_Width
, wxDefaultCoord
) : selTo
- GetAbsPos();
389 // if the selection is entirely within this cell, make sure pt1 < pt2 in
390 // order to make the rest of this function simpler:
391 if ( selFrom
!= wxDefaultPosition
&& selTo
!= wxDefaultPosition
&&
392 selFrom
.x
> selTo
.x
)
399 unsigned len
= m_Word
.length();
403 // adjust for cases when the start/end position is completely
407 if ( pt2
.y
>= m_Height
)
411 // (include character under caret only if in first half of width)
413 // implementation using PartialExtents to support fractional widths
415 dc
.GetPartialTextExtents(m_Word
,widths
) ;
416 while( i
< len
&& pt1
.x
>= widths
[i
] )
420 int charW
= (i
> 0) ? widths
[i
] - widths
[i
-1] : widths
[i
];
421 if ( widths
[i
] - pt1
.x
< charW
/2 )
425 wxCoord charW
, charH
;
426 while ( pt1
.x
> 0 && i
< len
)
428 dc
.GetTextExtent(m_Word
[i
], &charW
, &charH
);
430 if ( pt1
.x
>= -charW
/2 )
436 #endif // __WXMAC__/!__WXMAC__
439 // (include character under caret only if in first half of width)
442 while( j
< len
&& pt2
.x
>= widths
[j
] )
446 int charW
= (j
> 0) ? widths
[j
] - widths
[j
-1] : widths
[j
];
447 if ( widths
[j
] - pt2
.x
< charW
/2 )
453 while ( pt2
.x
> 0 && j
< len
)
455 dc
.GetTextExtent(m_Word
[j
], &charW
, &charH
);
457 if ( pt2
.x
>= -charW
/2 )
463 #endif // __WXMAC__/!__WXMAC__
468 wxASSERT( pos2
>= pos1
);
471 void wxHtmlWordCell::SetSelectionPrivPos(const wxDC
& dc
, wxHtmlSelection
*s
) const
476 this == s
->GetFromCell() ? s
->GetFromPos() : wxDefaultPosition
,
477 this == s
->GetToCell() ? s
->GetToPos() : wxDefaultPosition
,
480 wxPoint
p(0, m_Word
.length());
482 if ( this == s
->GetFromCell() )
483 p
.x
= p1
; // selection starts here
484 if ( this == s
->GetToCell() )
485 p
.y
= p2
; // selection ends here
487 if ( this == s
->GetFromCell() )
488 s
->SetFromPrivPos(p
);
489 if ( this == s
->GetToCell() )
494 static void SwitchSelState(wxDC
& dc
, wxHtmlRenderingInfo
& info
,
497 wxColour fg
= info
.GetState().GetFgColour();
498 wxColour bg
= info
.GetState().GetBgColour();
502 dc
.SetBackgroundMode(wxBRUSHSTYLE_SOLID
);
503 dc
.SetTextForeground(info
.GetStyle().GetSelectedTextColour(fg
));
504 dc
.SetTextBackground(info
.GetStyle().GetSelectedTextBgColour(bg
));
505 dc
.SetBackground(wxBrush(info
.GetStyle().GetSelectedTextBgColour(bg
),
506 wxBRUSHSTYLE_SOLID
));
510 dc
.SetBackgroundMode(wxBRUSHSTYLE_TRANSPARENT
);
511 dc
.SetTextForeground(fg
);
512 dc
.SetTextBackground(bg
);
513 dc
.SetBackground(wxBrush(bg
, wxBRUSHSTYLE_SOLID
));
518 void wxHtmlWordCell::Draw(wxDC
& dc
, int x
, int y
,
519 int WXUNUSED(view_y1
), int WXUNUSED(view_y2
),
520 wxHtmlRenderingInfo
& info
)
522 #if 0 // useful for debugging
523 dc
.SetPen(*wxBLACK_PEN
);
524 dc
.DrawRectangle(x
+m_PosX
,y
+m_PosY
,m_Width
/* VZ: +1? */ ,m_Height
);
527 bool drawSelectionAfterCell
= false;
529 if ( info
.GetState().GetSelectionState() == wxHTML_SEL_CHANGING
)
531 // Selection changing, we must draw the word piecewise:
532 wxHtmlSelection
*s
= info
.GetSelection();
537 wxPoint priv
= (this == s
->GetFromCell()) ?
538 s
->GetFromPrivPos() : s
->GetToPrivPos();
540 // NB: this is quite a hack: in order to compute selection boundaries
541 // (in word's characters) we must know current font, which is only
542 // possible inside rendering code. Therefore we update the
543 // information here and store it in wxHtmlSelection so that
544 // ConvertToText can use it later:
545 if ( priv
== wxDefaultPosition
)
547 SetSelectionPrivPos(dc
, s
);
548 priv
= (this == s
->GetFromCell()) ?
549 s
->GetFromPrivPos() : s
->GetToPrivPos();
557 txt
= m_Word
.Mid(0, part1
);
558 dc
.DrawText(txt
, x
+ m_PosX
, y
+ m_PosY
);
559 dc
.GetTextExtent(txt
, &w
, &h
);
563 SwitchSelState(dc
, info
, true);
565 txt
= m_Word
.Mid(part1
, part2
-part1
);
566 dc
.DrawText(txt
, ofs
+ x
+ m_PosX
, y
+ m_PosY
);
568 if ( (size_t)part2
< m_Word
.length() )
570 dc
.GetTextExtent(txt
, &w
, &h
);
572 SwitchSelState(dc
, info
, false);
573 txt
= m_Word
.Mid(part2
);
574 dc
.DrawText(txt
, ofs
+ x
+ m_PosX
, y
+ m_PosY
);
577 drawSelectionAfterCell
= true;
581 wxHtmlSelectionState selstate
= info
.GetState().GetSelectionState();
582 // Not changing selection state, draw the word in single mode:
583 if ( selstate
!= wxHTML_SEL_OUT
&&
584 dc
.GetBackgroundMode() != wxBRUSHSTYLE_SOLID
)
586 SwitchSelState(dc
, info
, true);
588 else if ( selstate
== wxHTML_SEL_OUT
&&
589 dc
.GetBackgroundMode() == wxBRUSHSTYLE_SOLID
)
591 SwitchSelState(dc
, info
, false);
593 dc
.DrawText(m_Word
, x
+ m_PosX
, y
+ m_PosY
);
594 drawSelectionAfterCell
= (selstate
!= wxHTML_SEL_OUT
);
597 // NB: If the text is justified then there is usually some free space
598 // between adjacent cells and drawing the selection only onto cells
599 // would result in ugly unselected spaces. The code below detects
600 // this special case and renders the selection *outside* the sell,
602 if ( m_Parent
->GetAlignHor() == wxHTML_ALIGN_JUSTIFY
&&
603 drawSelectionAfterCell
)
605 wxHtmlCell
*nextCell
= m_Next
;
606 while ( nextCell
&& nextCell
->IsFormattingCell() )
607 nextCell
= nextCell
->GetNext();
610 int nextX
= nextCell
->GetPosX();
611 if ( m_PosX
+ m_Width
< nextX
)
613 dc
.SetBrush(dc
.GetBackground());
614 dc
.SetPen(*wxTRANSPARENT_PEN
);
615 dc
.DrawRectangle(x
+ m_PosX
+ m_Width
, y
+ m_PosY
,
616 nextX
- m_PosX
- m_Width
, m_Height
);
622 wxCursor
wxHtmlWordCell::GetMouseCursor(wxHtmlWindowInterface
*window
) const
626 return window
->GetHTMLCursor(wxHtmlWindowInterface::HTMLCursor_Text
);
630 return wxHtmlCell::GetMouseCursor(window
);
634 wxString
wxHtmlWordCell::ConvertToText(wxHtmlSelection
*s
) const
636 if ( s
&& (this == s
->GetFromCell() || this == s
->GetToCell()) )
638 wxPoint priv
= this == s
->GetFromCell() ? s
->GetFromPrivPos()
641 // VZ: we may be called before we had a chance to re-render ourselves
642 // and in this case GetFrom/ToPrivPos() is not set yet -- assume
643 // that this only happens in case of a double/triple click (which
644 // seems to be the case now) and so it makes sense to select the
645 // entire contents of the cell in this case
647 // TODO: but this really needs to be fixed in some better way later...
648 if ( priv
!= wxDefaultPosition
)
650 const int part1
= priv
.x
;
651 const int part2
= priv
.y
;
652 if ( part1
== part2
)
653 return wxEmptyString
;
654 return GetPartAsText(part1
, part2
);
656 //else: return the whole word below
659 return GetAllAsText();
662 wxString
wxHtmlWordWithTabsCell::GetAllAsText() const
667 wxString
wxHtmlWordWithTabsCell::GetPartAsText(int begin
, int end
) const
669 // NB: The 'begin' and 'end' positions are in the _displayed_ text
670 // (stored in m_Word) and not in the text with tabs that should
671 // be copied to clipboard (m_wordOrig).
673 // NB: Because selection is performed on displayed text, it's possible
674 // to select e.g. "half of TAB character" -- IOW, 'begin' and 'end'
675 // may be in the middle of TAB character expansion into ' 's. In this
676 // case, we copy the TAB character to clipboard once.
678 wxASSERT( begin
< end
);
680 const unsigned SPACES_PER_TAB
= 8;
685 wxString::const_iterator i
= m_wordOrig
.begin();
687 // find the beginning of text to copy:
688 for ( ; pos
< begin
; ++i
)
692 pos
+= 8 - (m_linepos
+ pos
) % SPACES_PER_TAB
;
704 // copy the content until we reach 'end':
705 for ( ; pos
< end
; ++i
)
711 pos
+= 8 - (m_linepos
+ pos
) % SPACES_PER_TAB
;
721 //-----------------------------------------------------------------------------
722 // wxHtmlContainerCell
723 //-----------------------------------------------------------------------------
725 IMPLEMENT_ABSTRACT_CLASS(wxHtmlContainerCell
, wxHtmlCell
)
727 wxHtmlContainerCell::wxHtmlContainerCell(wxHtmlContainerCell
*parent
) : wxHtmlCell()
729 m_Cells
= m_LastCell
= NULL
;
732 if (m_Parent
) m_Parent
->InsertCell(this);
733 m_AlignHor
= wxHTML_ALIGN_LEFT
;
734 m_AlignVer
= wxHTML_ALIGN_BOTTOM
;
735 m_IndentLeft
= m_IndentRight
= m_IndentTop
= m_IndentBottom
= 0;
736 m_WidthFloat
= 100; m_WidthFloatUnits
= wxHTML_UNITS_PERCENT
;
737 m_UseBkColour
= false;
740 m_MinHeightAlign
= wxHTML_ALIGN_TOP
;
744 wxHtmlContainerCell::~wxHtmlContainerCell()
746 wxHtmlCell
*cell
= m_Cells
;
749 wxHtmlCell
*cellNext
= cell
->GetNext();
757 void wxHtmlContainerCell::SetIndent(int i
, int what
, int units
)
759 int val
= (units
== wxHTML_UNITS_PIXELS
) ? i
: -i
;
760 if (what
& wxHTML_INDENT_LEFT
) m_IndentLeft
= val
;
761 if (what
& wxHTML_INDENT_RIGHT
) m_IndentRight
= val
;
762 if (what
& wxHTML_INDENT_TOP
) m_IndentTop
= val
;
763 if (what
& wxHTML_INDENT_BOTTOM
) m_IndentBottom
= val
;
769 int wxHtmlContainerCell::GetIndent(int ind
) const
771 if (ind
& wxHTML_INDENT_LEFT
) return m_IndentLeft
;
772 else if (ind
& wxHTML_INDENT_RIGHT
) return m_IndentRight
;
773 else if (ind
& wxHTML_INDENT_TOP
) return m_IndentTop
;
774 else if (ind
& wxHTML_INDENT_BOTTOM
) return m_IndentBottom
;
775 else return -1; /* BUG! Should not be called... */
781 int wxHtmlContainerCell::GetIndentUnits(int ind
) const
784 if (ind
& wxHTML_INDENT_LEFT
) p
= m_IndentLeft
< 0;
785 else if (ind
& wxHTML_INDENT_RIGHT
) p
= m_IndentRight
< 0;
786 else if (ind
& wxHTML_INDENT_TOP
) p
= m_IndentTop
< 0;
787 else if (ind
& wxHTML_INDENT_BOTTOM
) p
= m_IndentBottom
< 0;
788 if (p
) return wxHTML_UNITS_PERCENT
;
789 else return wxHTML_UNITS_PIXELS
;
793 bool wxHtmlContainerCell::AdjustPagebreak(int *pagebreak
,
794 wxArrayInt
& known_pagebreaks
) const
796 if (!m_CanLiveOnPagebreak
)
797 return wxHtmlCell::AdjustPagebreak(pagebreak
, known_pagebreaks
);
799 wxHtmlCell
*c
= GetFirstChild();
801 int pbrk
= *pagebreak
- m_PosY
;
805 if (c
->AdjustPagebreak(&pbrk
, known_pagebreaks
))
810 *pagebreak
= pbrk
+ m_PosY
;
815 void wxHtmlContainerCell::Layout(int w
)
817 wxHtmlCell::Layout(w
);
819 if (m_LastLayout
== w
)
823 // VS: Any attempt to layout with negative or zero width leads to hell,
824 // but we can't ignore such attempts completely, since it sometimes
825 // happen (e.g. when trying how small a table can be). The best thing we
826 // can do is to set the width of child cells to zero
830 for (wxHtmlCell
*cell
= m_Cells
; cell
; cell
= cell
->GetNext())
832 // this does two things: it recursively calls this code on all
833 // child contrainers and resets children's position to (0,0)
837 wxHtmlCell
*nextCell
;
838 long xpos
= 0, ypos
= m_IndentTop
;
839 int xdelta
= 0, ybasicpos
= 0, ydiff
;
840 int s_width
, nextWordWidth
, s_indent
;
841 int ysizeup
= 0, ysizedown
= 0;
842 int MaxLineWidth
= 0;
843 int curLineWidth
= 0;
853 if (m_WidthFloatUnits
== wxHTML_UNITS_PERCENT
)
855 if (m_WidthFloat
< 0) m_Width
= (100 + m_WidthFloat
) * w
/ 100;
856 else m_Width
= m_WidthFloat
* w
/ 100;
860 if (m_WidthFloat
< 0) m_Width
= w
+ m_WidthFloat
;
861 else m_Width
= m_WidthFloat
;
866 int l
= (m_IndentLeft
< 0) ? (-m_IndentLeft
* m_Width
/ 100) : m_IndentLeft
;
867 int r
= (m_IndentRight
< 0) ? (-m_IndentRight
* m_Width
/ 100) : m_IndentRight
;
868 for (wxHtmlCell
*cell
= m_Cells
; cell
; cell
= cell
->GetNext())
869 cell
->Layout(m_Width
- (l
+ r
));
878 // adjust indentation:
879 s_indent
= (m_IndentLeft
< 0) ? (-m_IndentLeft
* m_Width
/ 100) : m_IndentLeft
;
880 s_width
= m_Width
- s_indent
- ((m_IndentRight
< 0) ? (-m_IndentRight
* m_Width
/ 100) : m_IndentRight
);
883 wxHtmlCell
*cell
= m_Cells
,
889 case wxHTML_ALIGN_TOP
: ybasicpos
= 0; break;
890 case wxHTML_ALIGN_BOTTOM
: ybasicpos
= - cell
->GetHeight(); break;
891 case wxHTML_ALIGN_CENTER
: ybasicpos
= - cell
->GetHeight() / 2; break;
893 ydiff
= cell
->GetHeight() + ybasicpos
;
895 if (cell
->GetDescent() + ydiff
> ysizedown
) ysizedown
= cell
->GetDescent() + ydiff
;
896 if (ybasicpos
+ cell
->GetDescent() < -ysizeup
) ysizeup
= - (ybasicpos
+ cell
->GetDescent());
898 // layout nonbreakable run of cells:
899 cell
->SetPos(xpos
, ybasicpos
+ cell
->GetDescent());
900 xpos
+= cell
->GetWidth();
901 if (!cell
->IsTerminalCell())
903 // Container cell indicates new line
904 if (curLineWidth
> m_MaxTotalWidth
)
905 m_MaxTotalWidth
= curLineWidth
;
907 if (wxMax(cell
->GetWidth(), cell
->GetMaxTotalWidth()) > m_MaxTotalWidth
)
908 m_MaxTotalWidth
= cell
->GetMaxTotalWidth();
912 // Normal cell, add maximum cell width to line width
913 curLineWidth
+= cell
->GetMaxTotalWidth();
915 cell
= cell
->GetNext();
917 // compute length of the next word that would be added:
924 nextWordWidth
+= nextCell
->GetWidth();
925 nextCell
= nextCell
->GetNext();
926 } while (nextCell
&& !nextCell
->IsLinebreakAllowed());
929 // force new line if occurred:
930 if ((cell
== NULL
) ||
931 (xpos
+ nextWordWidth
> s_width
&& cell
->IsLinebreakAllowed()))
933 if (xpos
> MaxLineWidth
) MaxLineWidth
= xpos
;
934 if (ysizeup
< 0) ysizeup
= 0;
935 if (ysizedown
< 0) ysizedown
= 0;
936 switch (m_AlignHor
) {
937 case wxHTML_ALIGN_LEFT
:
938 case wxHTML_ALIGN_JUSTIFY
:
941 case wxHTML_ALIGN_RIGHT
:
942 xdelta
= 0 + (s_width
- xpos
);
944 case wxHTML_ALIGN_CENTER
:
945 xdelta
= 0 + (s_width
- xpos
) / 2;
948 if (xdelta
< 0) xdelta
= 0;
953 if (m_AlignHor
!= wxHTML_ALIGN_JUSTIFY
|| cell
== NULL
)
957 line
->SetPos(line
->GetPosX() + xdelta
,
958 ypos
+ line
->GetPosY());
959 line
= line
->GetNext();
962 else // align == justify
964 // we have to distribute the extra horz space between the cells
967 // an added complication is that some cells have fixed size and
968 // shouldn't get any increment (it so happens that these cells
969 // also don't allow line break on them which provides with an
970 // easy way to test for this) -- and neither should the cells
971 // adjacent to them as this could result in a visible space
972 // between two cells separated by, e.g. font change, cell which
975 int step
= s_width
- xpos
;
978 // first count the cells which will get extra space
984 for ( c
= line
; c
!= cell
; c
= c
->GetNext() )
986 if ( c
->IsLinebreakAllowed() )
993 // and now extra space to those cells which merit it
996 // first visible cell on line is not moved:
997 while (line
!=cell
&& !line
->IsLinebreakAllowed())
999 line
->SetPos(line
->GetPosX() + s_indent
,
1000 line
->GetPosY() + ypos
);
1001 line
= line
->GetNext();
1006 line
->SetPos(line
->GetPosX() + s_indent
,
1007 line
->GetPosY() + ypos
);
1009 line
= line
->GetNext();
1012 for ( int n
= 0; line
!= cell
; line
= line
->GetNext() )
1014 if ( line
->IsLinebreakAllowed() )
1016 // offset the next cell relative to this one
1017 // thus increasing our size
1021 line
->SetPos(line
->GetPosX() + s_indent
+
1022 ((n
* step
) / total
),
1023 line
->GetPosY() + ypos
);
1028 // this will cause the code to enter "else branch" below:
1033 if ( step
<= 0 ) // no extra space to distribute
1035 // just set the indent properly
1036 while (line
!= cell
)
1038 line
->SetPos(line
->GetPosX() + s_indent
,
1039 line
->GetPosY() + ypos
);
1040 line
= line
->GetNext();
1047 ysizeup
= ysizedown
= 0;
1052 // setup height & width, depending on container layout:
1053 m_Height
= ypos
+ (ysizedown
+ ysizeup
) + m_IndentBottom
;
1055 if (m_Height
< m_MinHeight
)
1057 if (m_MinHeightAlign
!= wxHTML_ALIGN_TOP
)
1059 int diff
= m_MinHeight
- m_Height
;
1060 if (m_MinHeightAlign
== wxHTML_ALIGN_CENTER
) diff
/= 2;
1064 cell
->SetPos(cell
->GetPosX(), cell
->GetPosY() + diff
);
1065 cell
= cell
->GetNext();
1068 m_Height
= m_MinHeight
;
1071 if (curLineWidth
> m_MaxTotalWidth
)
1072 m_MaxTotalWidth
= curLineWidth
;
1074 m_MaxTotalWidth
+= s_indent
+ ((m_IndentRight
< 0) ? (-m_IndentRight
* m_Width
/ 100) : m_IndentRight
);
1075 MaxLineWidth
+= s_indent
+ ((m_IndentRight
< 0) ? (-m_IndentRight
* m_Width
/ 100) : m_IndentRight
);
1076 if (m_Width
< MaxLineWidth
) m_Width
= MaxLineWidth
;
1079 void wxHtmlContainerCell::UpdateRenderingStatePre(wxHtmlRenderingInfo
& info
,
1080 wxHtmlCell
*cell
) const
1082 wxHtmlSelection
*s
= info
.GetSelection();
1084 if (s
->GetFromCell() == cell
|| s
->GetToCell() == cell
)
1086 info
.GetState().SetSelectionState(wxHTML_SEL_CHANGING
);
1090 void wxHtmlContainerCell::UpdateRenderingStatePost(wxHtmlRenderingInfo
& info
,
1091 wxHtmlCell
*cell
) const
1093 wxHtmlSelection
*s
= info
.GetSelection();
1095 if (s
->GetToCell() == cell
)
1096 info
.GetState().SetSelectionState(wxHTML_SEL_OUT
);
1097 else if (s
->GetFromCell() == cell
)
1098 info
.GetState().SetSelectionState(wxHTML_SEL_IN
);
1101 #define mMin(a, b) (((a) < (b)) ? (a) : (b))
1102 #define mMax(a, b) (((a) < (b)) ? (b) : (a))
1104 void wxHtmlContainerCell::Draw(wxDC
& dc
, int x
, int y
, int view_y1
, int view_y2
,
1105 wxHtmlRenderingInfo
& info
)
1107 #if 0 // useful for debugging
1108 dc
.SetPen(*wxRED_PEN
);
1109 dc
.DrawRectangle(x
+m_PosX
,y
+m_PosY
,m_Width
,m_Height
);
1112 int xlocal
= x
+ m_PosX
;
1113 int ylocal
= y
+ m_PosY
;
1117 wxBrush myb
= wxBrush(m_BkColour
, wxBRUSHSTYLE_SOLID
);
1119 int real_y1
= mMax(ylocal
, view_y1
);
1120 int real_y2
= mMin(ylocal
+ m_Height
- 1, view_y2
);
1123 dc
.SetPen(*wxTRANSPARENT_PEN
);
1124 dc
.DrawRectangle(xlocal
, real_y1
, m_Width
, real_y2
- real_y1
+ 1);
1129 // draw thin border using lines
1130 wxPen
mypen1(m_BorderColour1
, 1, wxPENSTYLE_SOLID
);
1131 wxPen
mypen2(m_BorderColour2
, 1, wxPENSTYLE_SOLID
);
1134 dc
.DrawLine(xlocal
, ylocal
, xlocal
, ylocal
+ m_Height
- 1);
1135 dc
.DrawLine(xlocal
, ylocal
, xlocal
+ m_Width
, ylocal
);
1137 dc
.DrawLine(xlocal
+ m_Width
- 1, ylocal
, xlocal
+ m_Width
- 1, ylocal
+ m_Height
- 1);
1138 dc
.DrawLine(xlocal
, ylocal
+ m_Height
- 1, xlocal
+ m_Width
, ylocal
+ m_Height
- 1);
1140 else if (m_Border
> 0)
1142 wxBrush
mybrush1(m_BorderColour1
, wxBRUSHSTYLE_SOLID
);
1143 wxBrush
mybrush2(m_BorderColour2
, wxBRUSHSTYLE_SOLID
);
1145 // draw upper left corner
1146 // 0---------------5
1155 poly
[0].x
=m_PosX
; poly
[0].y
= m_PosY
;
1156 poly
[1].x
=m_PosX
; poly
[1].y
= m_PosY
+ m_Height
;
1157 poly
[2].x
=m_PosX
+ m_Border
; poly
[2].y
= poly
[1].y
- m_Border
;
1158 poly
[3].x
=poly
[2].x
; poly
[3].y
= m_PosY
+ m_Border
;
1159 poly
[4].x
=m_PosX
+ m_Width
- m_Border
; poly
[4].y
= poly
[3].y
;
1160 poly
[5].x
=m_PosX
+ m_Width
; poly
[5].y
= m_PosY
;
1162 dc
.SetBrush(mybrush1
);
1163 dc
.SetPen(*wxTRANSPARENT_PEN
);
1164 dc
.DrawPolygon(6, poly
, x
, y
);
1166 // draw lower right corner reusing point 1,2,4 and 5
1173 // 1---------------0
1174 dc
.SetBrush(mybrush2
);
1175 poly
[0].x
= poly
[5].x
; poly
[0].y
= poly
[1].y
;
1176 poly
[3].x
= poly
[4].x
; poly
[3].y
= poly
[2].y
;
1177 dc
.DrawPolygon(6, poly
, x
, y
);
1179 // smooth color transition like firefox
1180 wxColour
borderMediumColour(
1181 (m_BorderColour1
.Red() + m_BorderColour2
.Red()) /2 ,
1182 (m_BorderColour1
.Green() + m_BorderColour2
.Green()) /2 ,
1183 (m_BorderColour1
.Blue() + m_BorderColour2
.Blue()) /2
1185 wxPen
mypen3(borderMediumColour
, 1, wxPENSTYLE_SOLID
);
1187 dc
.DrawLines(2, &poly
[1], x
, y
- 1); // between 1 and 2
1188 dc
.DrawLines(2, &poly
[4], x
, y
- 1); // between 4 and 5
1192 // draw container's contents:
1193 for (wxHtmlCell
*cell
= m_Cells
; cell
; cell
= cell
->GetNext())
1196 // optimize drawing: don't render off-screen content:
1197 if ((ylocal
+ cell
->GetPosY() <= view_y2
) &&
1198 (ylocal
+ cell
->GetPosY() + cell
->GetHeight() > view_y1
))
1200 // the cell is visible, draw it:
1201 UpdateRenderingStatePre(info
, cell
);
1203 xlocal
, ylocal
, view_y1
, view_y2
,
1205 UpdateRenderingStatePost(info
, cell
);
1209 // the cell is off-screen, proceed with font+color+etc.
1211 cell
->DrawInvisible(dc
, xlocal
, ylocal
, info
);
1219 void wxHtmlContainerCell::DrawInvisible(wxDC
& dc
, int x
, int y
,
1220 wxHtmlRenderingInfo
& info
)
1224 for (wxHtmlCell
*cell
= m_Cells
; cell
; cell
= cell
->GetNext())
1226 UpdateRenderingStatePre(info
, cell
);
1227 cell
->DrawInvisible(dc
, x
+ m_PosX
, y
+ m_PosY
, info
);
1228 UpdateRenderingStatePost(info
, cell
);
1234 wxColour
wxHtmlContainerCell::GetBackgroundColour()
1239 return wxNullColour
;
1244 wxHtmlLinkInfo
*wxHtmlContainerCell::GetLink(int x
, int y
) const
1246 wxHtmlCell
*cell
= FindCellByPos(x
, y
);
1248 // VZ: I don't know if we should pass absolute or relative coords to
1249 // wxHtmlCell::GetLink()? As the base class version just ignores them
1250 // anyhow, it hardly matters right now but should still be clarified
1251 return cell
? cell
->GetLink(x
, y
) : NULL
;
1256 void wxHtmlContainerCell::InsertCell(wxHtmlCell
*f
)
1258 if (!m_Cells
) m_Cells
= m_LastCell
= f
;
1261 m_LastCell
->SetNext(f
);
1263 if (m_LastCell
) while (m_LastCell
->GetNext()) m_LastCell
= m_LastCell
->GetNext();
1271 void wxHtmlContainerCell::SetAlign(const wxHtmlTag
& tag
)
1273 if (tag
.HasParam(wxT("ALIGN")))
1275 wxString alg
= tag
.GetParam(wxT("ALIGN"));
1277 if (alg
== wxT("CENTER"))
1278 SetAlignHor(wxHTML_ALIGN_CENTER
);
1279 else if (alg
== wxT("LEFT"))
1280 SetAlignHor(wxHTML_ALIGN_LEFT
);
1281 else if (alg
== wxT("JUSTIFY"))
1282 SetAlignHor(wxHTML_ALIGN_JUSTIFY
);
1283 else if (alg
== wxT("RIGHT"))
1284 SetAlignHor(wxHTML_ALIGN_RIGHT
);
1291 void wxHtmlContainerCell::SetWidthFloat(const wxHtmlTag
& tag
, double pixel_scale
)
1293 if (tag
.HasParam(wxT("WIDTH")))
1296 wxString wd
= tag
.GetParam(wxT("WIDTH"));
1298 if (wd
[wd
.length()-1] == wxT('%'))
1300 wxSscanf(wd
.c_str(), wxT("%i%%"), &wdi
);
1301 SetWidthFloat(wdi
, wxHTML_UNITS_PERCENT
);
1305 wxSscanf(wd
.c_str(), wxT("%i"), &wdi
);
1306 SetWidthFloat((int)(pixel_scale
* (double)wdi
), wxHTML_UNITS_PIXELS
);
1314 const wxHtmlCell
* wxHtmlContainerCell::Find(int condition
, const void* param
) const
1318 for (wxHtmlCell
*cell
= m_Cells
; cell
; cell
= cell
->GetNext())
1320 const wxHtmlCell
*r
= cell
->Find(condition
, param
);
1328 wxHtmlCell
*wxHtmlContainerCell::FindCellByPos(wxCoord x
, wxCoord y
,
1329 unsigned flags
) const
1331 if ( flags
& wxHTML_FIND_EXACT
)
1333 for ( const wxHtmlCell
*cell
= m_Cells
; cell
; cell
= cell
->GetNext() )
1335 int cx
= cell
->GetPosX(),
1336 cy
= cell
->GetPosY();
1338 if ( (cx
<= x
) && (cx
+ cell
->GetWidth() > x
) &&
1339 (cy
<= y
) && (cy
+ cell
->GetHeight() > y
) )
1341 return cell
->FindCellByPos(x
- cx
, y
- cy
, flags
);
1345 else if ( flags
& wxHTML_FIND_NEAREST_AFTER
)
1348 for ( const wxHtmlCell
*cell
= m_Cells
; cell
; cell
= cell
->GetNext() )
1350 if ( cell
->IsFormattingCell() )
1352 int cellY
= cell
->GetPosY();
1353 if (!( y
< cellY
|| (y
< cellY
+ cell
->GetHeight() &&
1354 x
< cell
->GetPosX() + cell
->GetWidth()) ))
1357 c
= cell
->FindCellByPos(x
- cell
->GetPosX(), y
- cellY
, flags
);
1361 else if ( flags
& wxHTML_FIND_NEAREST_BEFORE
)
1363 wxHtmlCell
*c2
, *c
= NULL
;
1364 for ( const wxHtmlCell
*cell
= m_Cells
; cell
; cell
= cell
->GetNext() )
1366 if ( cell
->IsFormattingCell() )
1368 int cellY
= cell
->GetPosY();
1369 if (!( cellY
+ cell
->GetHeight() <= y
||
1370 (y
>= cellY
&& x
>= cell
->GetPosX()) ))
1372 c2
= cell
->FindCellByPos(x
- cell
->GetPosX(), y
- cellY
, flags
);
1383 bool wxHtmlContainerCell::ProcessMouseClick(wxHtmlWindowInterface
*window
,
1385 const wxMouseEvent
& event
)
1387 #if WXWIN_COMPATIBILITY_2_6
1388 wxHtmlCellOnMouseClickCompatHelper
compat(window
, pos
, event
);
1389 return compat
.CallOnMouseClick(this);
1392 void wxHtmlContainerCell::OnMouseClick(wxWindow
*,
1393 int, int, const wxMouseEvent
& event
)
1395 wxCHECK_RET( gs_helperOnMouseClick
, wxT("unexpected call to OnMouseClick") );
1396 wxHtmlWindowInterface
*window
= gs_helperOnMouseClick
->window
;
1397 const wxPoint
& pos
= gs_helperOnMouseClick
->pos
;
1398 #endif // WXWIN_COMPATIBILITY_2_6
1400 bool retval
= false;
1401 wxHtmlCell
*cell
= FindCellByPos(pos
.x
, pos
.y
);
1403 retval
= cell
->ProcessMouseClick(window
, pos
, event
);
1405 #if WXWIN_COMPATIBILITY_2_6
1406 gs_helperOnMouseClick
->retval
= retval
;
1409 #endif // WXWIN_COMPATIBILITY_2_6
1413 wxHtmlCell
*wxHtmlContainerCell::GetFirstTerminal() const
1418 for (wxHtmlCell
*c
= m_Cells
; c
; c
= c
->GetNext())
1420 c2
= c
->GetFirstTerminal();
1428 wxHtmlCell
*wxHtmlContainerCell::GetLastTerminal() const
1432 // most common case first:
1433 wxHtmlCell
*c
= m_LastCell
->GetLastTerminal();
1438 wxHtmlCell
*c2
= NULL
;
1439 for (c
= m_Cells
; c
; c
= c
->GetNext())
1441 ctmp
= c
->GetLastTerminal();
1452 static bool IsEmptyContainer(wxHtmlContainerCell
*cell
)
1454 for ( wxHtmlCell
*c
= cell
->GetFirstChild(); c
; c
= c
->GetNext() )
1456 if ( !c
->IsTerminalCell() || !c
->IsFormattingCell() )
1462 void wxHtmlContainerCell::RemoveExtraSpacing(bool top
, bool bottom
)
1465 SetIndent(0, wxHTML_INDENT_TOP
);
1467 SetIndent(0, wxHTML_INDENT_BOTTOM
);
1472 wxHtmlContainerCell
*cont
;
1475 for ( c
= m_Cells
; c
; c
= c
->GetNext() )
1477 if ( c
->IsTerminalCell() )
1479 if ( !c
->IsFormattingCell() )
1484 cont
= (wxHtmlContainerCell
*)c
;
1485 if ( IsEmptyContainer(cont
) )
1487 cont
->SetIndent(0, wxHTML_INDENT_VERTICAL
);
1491 cont
->RemoveExtraSpacing(true, false);
1501 for ( c
= m_Cells
; c
; c
= c
->GetNext() )
1504 for ( int i
= arr
.GetCount() - 1; i
>= 0; i
--)
1506 c
= (wxHtmlCell
*)arr
[i
];
1507 if ( c
->IsTerminalCell() )
1509 if ( !c
->IsFormattingCell() )
1514 cont
= (wxHtmlContainerCell
*)c
;
1515 if ( IsEmptyContainer(cont
) )
1517 cont
->SetIndent(0, wxHTML_INDENT_VERTICAL
);
1521 cont
->RemoveExtraSpacing(false, true);
1533 // --------------------------------------------------------------------------
1535 // --------------------------------------------------------------------------
1537 IMPLEMENT_ABSTRACT_CLASS(wxHtmlColourCell
, wxHtmlCell
)
1539 void wxHtmlColourCell::Draw(wxDC
& dc
,
1541 int WXUNUSED(view_y1
), int WXUNUSED(view_y2
),
1542 wxHtmlRenderingInfo
& info
)
1544 DrawInvisible(dc
, x
, y
, info
);
1547 void wxHtmlColourCell::DrawInvisible(wxDC
& dc
,
1548 int WXUNUSED(x
), int WXUNUSED(y
),
1549 wxHtmlRenderingInfo
& info
)
1551 wxHtmlRenderingState
& state
= info
.GetState();
1552 if (m_Flags
& wxHTML_CLR_FOREGROUND
)
1554 state
.SetFgColour(m_Colour
);
1555 if (state
.GetSelectionState() != wxHTML_SEL_IN
)
1556 dc
.SetTextForeground(m_Colour
);
1558 dc
.SetTextForeground(
1559 info
.GetStyle().GetSelectedTextColour(m_Colour
));
1561 if (m_Flags
& wxHTML_CLR_BACKGROUND
)
1563 state
.SetBgColour(m_Colour
);
1564 if (state
.GetSelectionState() != wxHTML_SEL_IN
)
1566 dc
.SetTextBackground(m_Colour
);
1567 dc
.SetBackground(wxBrush(m_Colour
, wxBRUSHSTYLE_SOLID
));
1571 wxColour c
= info
.GetStyle().GetSelectedTextBgColour(m_Colour
);
1572 dc
.SetTextBackground(c
);
1573 dc
.SetBackground(wxBrush(c
, wxBRUSHSTYLE_SOLID
));
1581 // ---------------------------------------------------------------------------
1583 // ---------------------------------------------------------------------------
1585 IMPLEMENT_ABSTRACT_CLASS(wxHtmlFontCell
, wxHtmlCell
)
1587 void wxHtmlFontCell::Draw(wxDC
& dc
,
1588 int WXUNUSED(x
), int WXUNUSED(y
),
1589 int WXUNUSED(view_y1
), int WXUNUSED(view_y2
),
1590 wxHtmlRenderingInfo
& WXUNUSED(info
))
1595 void wxHtmlFontCell::DrawInvisible(wxDC
& dc
, int WXUNUSED(x
), int WXUNUSED(y
),
1596 wxHtmlRenderingInfo
& WXUNUSED(info
))
1608 // ---------------------------------------------------------------------------
1610 // ---------------------------------------------------------------------------
1612 IMPLEMENT_ABSTRACT_CLASS(wxHtmlWidgetCell
, wxHtmlCell
)
1614 wxHtmlWidgetCell::wxHtmlWidgetCell(wxWindow
*wnd
, int w
)
1618 m_Wnd
->GetSize(&sx
, &sy
);
1619 m_Width
= sx
, m_Height
= sy
;
1624 void wxHtmlWidgetCell::Draw(wxDC
& WXUNUSED(dc
),
1625 int WXUNUSED(x
), int WXUNUSED(y
),
1626 int WXUNUSED(view_y1
), int WXUNUSED(view_y2
),
1627 wxHtmlRenderingInfo
& WXUNUSED(info
))
1629 int absx
= 0, absy
= 0, stx
, sty
;
1630 wxHtmlCell
*c
= this;
1634 absx
+= c
->GetPosX();
1635 absy
+= c
->GetPosY();
1639 wxScrolledWindow
*scrolwin
=
1640 wxDynamicCast(m_Wnd
->GetParent(), wxScrolledWindow
);
1641 wxCHECK_RET( scrolwin
,
1642 wxT("widget cells can only be placed in wxHtmlWindow") );
1644 scrolwin
->GetViewStart(&stx
, &sty
);
1645 m_Wnd
->SetSize(absx
- wxHTML_SCROLL_STEP
* stx
,
1646 absy
- wxHTML_SCROLL_STEP
* sty
,
1652 void wxHtmlWidgetCell::DrawInvisible(wxDC
& WXUNUSED(dc
),
1653 int WXUNUSED(x
), int WXUNUSED(y
),
1654 wxHtmlRenderingInfo
& WXUNUSED(info
))
1656 int absx
= 0, absy
= 0, stx
, sty
;
1657 wxHtmlCell
*c
= this;
1661 absx
+= c
->GetPosX();
1662 absy
+= c
->GetPosY();
1666 ((wxScrolledWindow
*)(m_Wnd
->GetParent()))->GetViewStart(&stx
, &sty
);
1667 m_Wnd
->SetSize(absx
- wxHTML_SCROLL_STEP
* stx
, absy
- wxHTML_SCROLL_STEP
* sty
, m_Width
, m_Height
);
1672 void wxHtmlWidgetCell::Layout(int w
)
1674 if (m_WidthFloat
!= 0)
1676 m_Width
= (w
* m_WidthFloat
) / 100;
1677 m_Wnd
->SetSize(m_Width
, m_Height
);
1680 wxHtmlCell::Layout(w
);
1685 // ----------------------------------------------------------------------------
1686 // wxHtmlTerminalCellsInterator
1687 // ----------------------------------------------------------------------------
1689 const wxHtmlCell
* wxHtmlTerminalCellsInterator::operator++()
1696 if ( m_pos
== m_to
)
1702 if ( m_pos
->GetNext() )
1703 m_pos
= m_pos
->GetNext();
1706 // we must go up the hierarchy until we reach container where this
1707 // is not the last child, and then go down to first terminal cell:
1708 while ( m_pos
->GetNext() == NULL
)
1710 m_pos
= m_pos
->GetParent();
1714 m_pos
= m_pos
->GetNext();
1716 while ( m_pos
->GetFirstChild() != NULL
)
1717 m_pos
= m_pos
->GetFirstChild();
1718 } while ( !m_pos
->IsTerminalCell() );