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(wxSOLID
);
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 const int mode
= info
.GetState().GetBgMode();
508 dc
.SetBackgroundMode(mode
);
509 dc
.SetTextForeground(fg
);
510 dc
.SetTextBackground(bg
);
511 if ( mode
!= wxTRANSPARENT
)
512 dc
.SetBackground(wxBrush(bg
, mode
));
517 void wxHtmlWordCell::Draw(wxDC
& dc
, int x
, int y
,
518 int WXUNUSED(view_y1
), int WXUNUSED(view_y2
),
519 wxHtmlRenderingInfo
& info
)
521 #if 0 // useful for debugging
522 dc
.SetPen(*wxBLACK_PEN
);
523 dc
.DrawRectangle(x
+m_PosX
,y
+m_PosY
,m_Width
/* VZ: +1? */ ,m_Height
);
526 bool drawSelectionAfterCell
= false;
528 if ( info
.GetState().GetSelectionState() == wxHTML_SEL_CHANGING
)
530 // Selection changing, we must draw the word piecewise:
531 wxHtmlSelection
*s
= info
.GetSelection();
536 // NB: this is quite a hack: in order to compute selection boundaries
537 // (in word's characters) we must know current font, which is only
538 // possible inside rendering code. Therefore we update the
539 // information here and store it in wxHtmlSelection so that
540 // ConvertToText can use it later:
541 if ( !s
->AreFromToCharacterPosSet () )
543 SetSelectionPrivPos(dc
, s
);
546 int part1
= s
->GetFromCell()==this ? s
->GetFromCharacterPos() : 0;
547 int part2
= s
->GetToCell()==this ? s
->GetToCharacterPos() : m_Word
.Length();
551 txt
= m_Word
.Mid(0, part1
);
552 dc
.DrawText(txt
, x
+ m_PosX
, y
+ m_PosY
);
553 dc
.GetTextExtent(txt
, &w
, &h
);
557 SwitchSelState(dc
, info
, true);
559 txt
= m_Word
.Mid(part1
, part2
-part1
);
560 dc
.DrawText(txt
, ofs
+ x
+ m_PosX
, y
+ m_PosY
);
562 if ( (size_t)part2
< m_Word
.length() )
564 dc
.GetTextExtent(txt
, &w
, &h
);
566 SwitchSelState(dc
, info
, false);
567 txt
= m_Word
.Mid(part2
);
568 dc
.DrawText(txt
, ofs
+ x
+ m_PosX
, y
+ m_PosY
);
571 drawSelectionAfterCell
= true;
575 wxHtmlSelectionState selstate
= info
.GetState().GetSelectionState();
576 // Not changing selection state, draw the word in single mode:
577 SwitchSelState(dc
, info
, selstate
!= wxHTML_SEL_OUT
);
578 dc
.DrawText(m_Word
, x
+ m_PosX
, y
+ m_PosY
);
579 drawSelectionAfterCell
= (selstate
!= wxHTML_SEL_OUT
);
582 // NB: If the text is justified then there is usually some free space
583 // between adjacent cells and drawing the selection only onto cells
584 // would result in ugly unselected spaces. The code below detects
585 // this special case and renders the selection *outside* the sell,
587 if ( m_Parent
->GetAlignHor() == wxHTML_ALIGN_JUSTIFY
&&
588 drawSelectionAfterCell
)
590 wxHtmlCell
*nextCell
= m_Next
;
591 while ( nextCell
&& nextCell
->IsFormattingCell() )
592 nextCell
= nextCell
->GetNext();
595 int nextX
= nextCell
->GetPosX();
596 if ( m_PosX
+ m_Width
< nextX
)
598 dc
.SetBrush(dc
.GetBackground());
599 dc
.SetPen(*wxTRANSPARENT_PEN
);
600 dc
.DrawRectangle(x
+ m_PosX
+ m_Width
, y
+ m_PosY
,
601 nextX
- m_PosX
- m_Width
, m_Height
);
607 wxCursor
wxHtmlWordCell::GetMouseCursor(wxHtmlWindowInterface
*window
) const
611 return window
->GetHTMLCursor(wxHtmlWindowInterface::HTMLCursor_Text
);
615 return wxHtmlCell::GetMouseCursor(window
);
619 wxString
wxHtmlWordCell::ConvertToText(wxHtmlSelection
*s
) const
621 if ( s
&& (this == s
->GetFromCell() || this == s
->GetToCell()) )
623 // VZ: we may be called before we had a chance to re-render ourselves
624 // and in this case GetFrom/ToPrivPos() is not set yet -- assume
625 // that this only happens in case of a double/triple click (which
626 // seems to be the case now) and so it makes sense to select the
627 // entire contents of the cell in this case
629 // TODO: but this really needs to be fixed in some better way later...
630 if ( s
->AreFromToCharacterPosSet() )
632 const int part1
= s
->GetFromCell()==this ? s
->GetFromCharacterPos() : 0;
633 const int part2
= s
->GetToCell()==this ? s
->GetToCharacterPos() : m_Word
.Length();
634 if ( part1
== part2
)
635 return wxEmptyString
;
636 return GetPartAsText(part1
, part2
);
638 //else: return the whole word below
641 return GetAllAsText();
644 wxString
wxHtmlWordWithTabsCell::GetAllAsText() const
649 wxString
wxHtmlWordWithTabsCell::GetPartAsText(int begin
, int end
) const
651 // NB: The 'begin' and 'end' positions are in the _displayed_ text
652 // (stored in m_Word) and not in the text with tabs that should
653 // be copied to clipboard (m_wordOrig).
655 // NB: Because selection is performed on displayed text, it's possible
656 // to select e.g. "half of TAB character" -- IOW, 'begin' and 'end'
657 // may be in the middle of TAB character expansion into ' 's. In this
658 // case, we copy the TAB character to clipboard once.
660 wxASSERT( begin
< end
);
662 const unsigned SPACES_PER_TAB
= 8;
667 wxString::const_iterator i
= m_wordOrig
.begin();
669 // find the beginning of text to copy:
670 for ( ; pos
< begin
; ++i
)
674 pos
+= 8 - (m_linepos
+ pos
) % SPACES_PER_TAB
;
686 // copy the content until we reach 'end':
687 for ( ; pos
< end
; ++i
)
693 pos
+= 8 - (m_linepos
+ pos
) % SPACES_PER_TAB
;
703 //-----------------------------------------------------------------------------
704 // wxHtmlContainerCell
705 //-----------------------------------------------------------------------------
707 IMPLEMENT_ABSTRACT_CLASS(wxHtmlContainerCell
, wxHtmlCell
)
709 wxHtmlContainerCell::wxHtmlContainerCell(wxHtmlContainerCell
*parent
) : wxHtmlCell()
711 m_Cells
= m_LastCell
= NULL
;
714 if (m_Parent
) m_Parent
->InsertCell(this);
715 m_AlignHor
= wxHTML_ALIGN_LEFT
;
716 m_AlignVer
= wxHTML_ALIGN_BOTTOM
;
717 m_IndentLeft
= m_IndentRight
= m_IndentTop
= m_IndentBottom
= 0;
718 m_WidthFloat
= 100; m_WidthFloatUnits
= wxHTML_UNITS_PERCENT
;
719 m_BkColour
= wxNullColour
;
722 m_MinHeightAlign
= wxHTML_ALIGN_TOP
;
726 wxHtmlContainerCell::~wxHtmlContainerCell()
728 wxHtmlCell
*cell
= m_Cells
;
731 wxHtmlCell
*cellNext
= cell
->GetNext();
739 void wxHtmlContainerCell::SetIndent(int i
, int what
, int units
)
741 int val
= (units
== wxHTML_UNITS_PIXELS
) ? i
: -i
;
742 if (what
& wxHTML_INDENT_LEFT
) m_IndentLeft
= val
;
743 if (what
& wxHTML_INDENT_RIGHT
) m_IndentRight
= val
;
744 if (what
& wxHTML_INDENT_TOP
) m_IndentTop
= val
;
745 if (what
& wxHTML_INDENT_BOTTOM
) m_IndentBottom
= val
;
751 int wxHtmlContainerCell::GetIndent(int ind
) const
753 if (ind
& wxHTML_INDENT_LEFT
) return m_IndentLeft
;
754 else if (ind
& wxHTML_INDENT_RIGHT
) return m_IndentRight
;
755 else if (ind
& wxHTML_INDENT_TOP
) return m_IndentTop
;
756 else if (ind
& wxHTML_INDENT_BOTTOM
) return m_IndentBottom
;
757 else return -1; /* BUG! Should not be called... */
763 int wxHtmlContainerCell::GetIndentUnits(int ind
) const
766 if (ind
& wxHTML_INDENT_LEFT
) p
= m_IndentLeft
< 0;
767 else if (ind
& wxHTML_INDENT_RIGHT
) p
= m_IndentRight
< 0;
768 else if (ind
& wxHTML_INDENT_TOP
) p
= m_IndentTop
< 0;
769 else if (ind
& wxHTML_INDENT_BOTTOM
) p
= m_IndentBottom
< 0;
770 if (p
) return wxHTML_UNITS_PERCENT
;
771 else return wxHTML_UNITS_PIXELS
;
776 wxHtmlContainerCell::AdjustPagebreak(int *pagebreak
,
777 const wxArrayInt
& known_pagebreaks
,
778 int pageHeight
) const
780 if (!m_CanLiveOnPagebreak
)
781 return wxHtmlCell::AdjustPagebreak(pagebreak
, known_pagebreaks
, pageHeight
);
783 wxHtmlCell
*c
= GetFirstChild();
785 int pbrk
= *pagebreak
- m_PosY
;
789 if (c
->AdjustPagebreak(&pbrk
, known_pagebreaks
, pageHeight
))
794 *pagebreak
= pbrk
+ m_PosY
;
799 void wxHtmlContainerCell::Layout(int w
)
801 wxHtmlCell::Layout(w
);
803 if (m_LastLayout
== w
)
807 // VS: Any attempt to layout with negative or zero width leads to hell,
808 // but we can't ignore such attempts completely, since it sometimes
809 // happen (e.g. when trying how small a table can be). The best thing we
810 // can do is to set the width of child cells to zero
814 for (wxHtmlCell
*cell
= m_Cells
; cell
; cell
= cell
->GetNext())
816 // this does two things: it recursively calls this code on all
817 // child contrainers and resets children's position to (0,0)
821 wxHtmlCell
*nextCell
;
822 long xpos
= 0, ypos
= m_IndentTop
;
823 int xdelta
= 0, ybasicpos
= 0, ydiff
;
824 int s_width
, nextWordWidth
, s_indent
;
825 int ysizeup
= 0, ysizedown
= 0;
826 int MaxLineWidth
= 0;
827 int curLineWidth
= 0;
837 if (m_WidthFloatUnits
== wxHTML_UNITS_PERCENT
)
839 if (m_WidthFloat
< 0) m_Width
= (100 + m_WidthFloat
) * w
/ 100;
840 else m_Width
= m_WidthFloat
* w
/ 100;
844 if (m_WidthFloat
< 0) m_Width
= w
+ m_WidthFloat
;
845 else m_Width
= m_WidthFloat
;
850 int l
= (m_IndentLeft
< 0) ? (-m_IndentLeft
* m_Width
/ 100) : m_IndentLeft
;
851 int r
= (m_IndentRight
< 0) ? (-m_IndentRight
* m_Width
/ 100) : m_IndentRight
;
852 for (wxHtmlCell
*cell
= m_Cells
; cell
; cell
= cell
->GetNext())
853 cell
->Layout(m_Width
- (l
+ r
));
862 // adjust indentation:
863 s_indent
= (m_IndentLeft
< 0) ? (-m_IndentLeft
* m_Width
/ 100) : m_IndentLeft
;
864 s_width
= m_Width
- s_indent
- ((m_IndentRight
< 0) ? (-m_IndentRight
* m_Width
/ 100) : m_IndentRight
);
867 wxHtmlCell
*cell
= m_Cells
,
873 case wxHTML_ALIGN_TOP
: ybasicpos
= 0; break;
874 case wxHTML_ALIGN_BOTTOM
: ybasicpos
= - cell
->GetHeight(); break;
875 case wxHTML_ALIGN_CENTER
: ybasicpos
= - cell
->GetHeight() / 2; break;
877 ydiff
= cell
->GetHeight() + ybasicpos
;
879 if (cell
->GetDescent() + ydiff
> ysizedown
) ysizedown
= cell
->GetDescent() + ydiff
;
880 if (ybasicpos
+ cell
->GetDescent() < -ysizeup
) ysizeup
= - (ybasicpos
+ cell
->GetDescent());
882 // layout nonbreakable run of cells:
883 cell
->SetPos(xpos
, ybasicpos
+ cell
->GetDescent());
884 xpos
+= cell
->GetWidth();
885 if (!cell
->IsTerminalCell())
887 // Container cell indicates new line
888 if (curLineWidth
> m_MaxTotalWidth
)
889 m_MaxTotalWidth
= curLineWidth
;
891 if (wxMax(cell
->GetWidth(), cell
->GetMaxTotalWidth()) > m_MaxTotalWidth
)
892 m_MaxTotalWidth
= cell
->GetMaxTotalWidth();
896 // Normal cell, add maximum cell width to line width
897 curLineWidth
+= cell
->GetMaxTotalWidth();
899 cell
= cell
->GetNext();
901 // compute length of the next word that would be added:
908 nextWordWidth
+= nextCell
->GetWidth();
909 nextCell
= nextCell
->GetNext();
910 } while (nextCell
&& !nextCell
->IsLinebreakAllowed());
913 // force new line if occurred:
914 if ((cell
== NULL
) ||
915 (xpos
+ nextWordWidth
> s_width
&& cell
->IsLinebreakAllowed()))
917 if (xpos
> MaxLineWidth
) MaxLineWidth
= xpos
;
918 if (ysizeup
< 0) ysizeup
= 0;
919 if (ysizedown
< 0) ysizedown
= 0;
920 switch (m_AlignHor
) {
921 case wxHTML_ALIGN_LEFT
:
922 case wxHTML_ALIGN_JUSTIFY
:
925 case wxHTML_ALIGN_RIGHT
:
926 xdelta
= 0 + (s_width
- xpos
);
928 case wxHTML_ALIGN_CENTER
:
929 xdelta
= 0 + (s_width
- xpos
) / 2;
932 if (xdelta
< 0) xdelta
= 0;
937 if (m_AlignHor
!= wxHTML_ALIGN_JUSTIFY
|| cell
== NULL
)
941 line
->SetPos(line
->GetPosX() + xdelta
,
942 ypos
+ line
->GetPosY());
943 line
= line
->GetNext();
946 else // align == justify
948 // we have to distribute the extra horz space between the cells
951 // an added complication is that some cells have fixed size and
952 // shouldn't get any increment (it so happens that these cells
953 // also don't allow line break on them which provides with an
954 // easy way to test for this) -- and neither should the cells
955 // adjacent to them as this could result in a visible space
956 // between two cells separated by, e.g. font change, cell which
959 int step
= s_width
- xpos
;
962 // first count the cells which will get extra space
968 for ( c
= line
; c
!= cell
; c
= c
->GetNext() )
970 if ( c
->IsLinebreakAllowed() )
977 // and now extra space to those cells which merit it
980 // first visible cell on line is not moved:
981 while (line
!=cell
&& !line
->IsLinebreakAllowed())
983 line
->SetPos(line
->GetPosX() + s_indent
,
984 line
->GetPosY() + ypos
);
985 line
= line
->GetNext();
990 line
->SetPos(line
->GetPosX() + s_indent
,
991 line
->GetPosY() + ypos
);
993 line
= line
->GetNext();
996 for ( int n
= 0; line
!= cell
; line
= line
->GetNext() )
998 if ( line
->IsLinebreakAllowed() )
1000 // offset the next cell relative to this one
1001 // thus increasing our size
1005 line
->SetPos(line
->GetPosX() + s_indent
+
1006 ((n
* step
) / total
),
1007 line
->GetPosY() + ypos
);
1012 // this will cause the code to enter "else branch" below:
1017 if ( step
<= 0 ) // no extra space to distribute
1019 // just set the indent properly
1020 while (line
!= cell
)
1022 line
->SetPos(line
->GetPosX() + s_indent
,
1023 line
->GetPosY() + ypos
);
1024 line
= line
->GetNext();
1031 ysizeup
= ysizedown
= 0;
1036 // setup height & width, depending on container layout:
1037 m_Height
= ypos
+ (ysizedown
+ ysizeup
) + m_IndentBottom
;
1039 if (m_Height
< m_MinHeight
)
1041 if (m_MinHeightAlign
!= wxHTML_ALIGN_TOP
)
1043 int diff
= m_MinHeight
- m_Height
;
1044 if (m_MinHeightAlign
== wxHTML_ALIGN_CENTER
) diff
/= 2;
1048 cell
->SetPos(cell
->GetPosX(), cell
->GetPosY() + diff
);
1049 cell
= cell
->GetNext();
1052 m_Height
= m_MinHeight
;
1055 if (curLineWidth
> m_MaxTotalWidth
)
1056 m_MaxTotalWidth
= curLineWidth
;
1058 m_MaxTotalWidth
+= s_indent
+ ((m_IndentRight
< 0) ? (-m_IndentRight
* m_Width
/ 100) : m_IndentRight
);
1059 MaxLineWidth
+= s_indent
+ ((m_IndentRight
< 0) ? (-m_IndentRight
* m_Width
/ 100) : m_IndentRight
);
1060 if (m_Width
< MaxLineWidth
) m_Width
= MaxLineWidth
;
1063 void wxHtmlContainerCell::UpdateRenderingStatePre(wxHtmlRenderingInfo
& info
,
1064 wxHtmlCell
*cell
) const
1066 wxHtmlSelection
*s
= info
.GetSelection();
1068 if (s
->GetFromCell() == cell
|| s
->GetToCell() == cell
)
1070 info
.GetState().SetSelectionState(wxHTML_SEL_CHANGING
);
1074 void wxHtmlContainerCell::UpdateRenderingStatePost(wxHtmlRenderingInfo
& info
,
1075 wxHtmlCell
*cell
) const
1077 wxHtmlSelection
*s
= info
.GetSelection();
1079 if (s
->GetToCell() == cell
)
1080 info
.GetState().SetSelectionState(wxHTML_SEL_OUT
);
1081 else if (s
->GetFromCell() == cell
)
1082 info
.GetState().SetSelectionState(wxHTML_SEL_IN
);
1085 #define mMin(a, b) (((a) < (b)) ? (a) : (b))
1086 #define mMax(a, b) (((a) < (b)) ? (b) : (a))
1088 void wxHtmlContainerCell::Draw(wxDC
& dc
, int x
, int y
, int view_y1
, int view_y2
,
1089 wxHtmlRenderingInfo
& info
)
1091 #if 0 // useful for debugging
1092 dc
.SetPen(*wxRED_PEN
);
1093 dc
.DrawRectangle(x
+m_PosX
,y
+m_PosY
,m_Width
,m_Height
);
1096 int xlocal
= x
+ m_PosX
;
1097 int ylocal
= y
+ m_PosY
;
1099 if (m_BkColour
.IsOk())
1101 wxBrush myb
= wxBrush(m_BkColour
, wxBRUSHSTYLE_SOLID
);
1103 int real_y1
= mMax(ylocal
, view_y1
);
1104 int real_y2
= mMin(ylocal
+ m_Height
- 1, view_y2
);
1107 dc
.SetPen(*wxTRANSPARENT_PEN
);
1108 dc
.DrawRectangle(xlocal
, real_y1
, m_Width
, real_y2
- real_y1
+ 1);
1113 // draw thin border using lines
1114 wxPen
mypen1(m_BorderColour1
, 1, wxPENSTYLE_SOLID
);
1115 wxPen
mypen2(m_BorderColour2
, 1, wxPENSTYLE_SOLID
);
1118 dc
.DrawLine(xlocal
, ylocal
, xlocal
, ylocal
+ m_Height
- 1);
1119 dc
.DrawLine(xlocal
, ylocal
, xlocal
+ m_Width
, ylocal
);
1121 dc
.DrawLine(xlocal
+ m_Width
- 1, ylocal
, xlocal
+ m_Width
- 1, ylocal
+ m_Height
- 1);
1122 dc
.DrawLine(xlocal
, ylocal
+ m_Height
- 1, xlocal
+ m_Width
, ylocal
+ m_Height
- 1);
1124 else if (m_Border
> 0)
1126 wxBrush
mybrush1(m_BorderColour1
, wxBRUSHSTYLE_SOLID
);
1127 wxBrush
mybrush2(m_BorderColour2
, wxBRUSHSTYLE_SOLID
);
1129 // draw upper left corner
1130 // 0---------------5
1139 poly
[0].x
=m_PosX
; poly
[0].y
= m_PosY
;
1140 poly
[1].x
=m_PosX
; poly
[1].y
= m_PosY
+ m_Height
;
1141 poly
[2].x
=m_PosX
+ m_Border
; poly
[2].y
= poly
[1].y
- m_Border
;
1142 poly
[3].x
=poly
[2].x
; poly
[3].y
= m_PosY
+ m_Border
;
1143 poly
[4].x
=m_PosX
+ m_Width
- m_Border
; poly
[4].y
= poly
[3].y
;
1144 poly
[5].x
=m_PosX
+ m_Width
; poly
[5].y
= m_PosY
;
1146 dc
.SetBrush(mybrush1
);
1147 dc
.SetPen(*wxTRANSPARENT_PEN
);
1148 dc
.DrawPolygon(6, poly
, x
, y
);
1150 // draw lower right corner reusing point 1,2,4 and 5
1157 // 1---------------0
1158 dc
.SetBrush(mybrush2
);
1159 poly
[0].x
= poly
[5].x
; poly
[0].y
= poly
[1].y
;
1160 poly
[3].x
= poly
[4].x
; poly
[3].y
= poly
[2].y
;
1161 dc
.DrawPolygon(6, poly
, x
, y
);
1163 // smooth color transition like firefox
1164 wxColour
borderMediumColour(
1165 (m_BorderColour1
.Red() + m_BorderColour2
.Red()) /2 ,
1166 (m_BorderColour1
.Green() + m_BorderColour2
.Green()) /2 ,
1167 (m_BorderColour1
.Blue() + m_BorderColour2
.Blue()) /2
1169 wxPen
mypen3(borderMediumColour
, 1, wxPENSTYLE_SOLID
);
1171 dc
.DrawLines(2, &poly
[1], x
, y
- 1); // between 1 and 2
1172 dc
.DrawLines(2, &poly
[4], x
, y
- 1); // between 4 and 5
1176 // draw container's contents:
1177 for (wxHtmlCell
*cell
= m_Cells
; cell
; cell
= cell
->GetNext())
1180 // optimize drawing: don't render off-screen content:
1181 if ((ylocal
+ cell
->GetPosY() <= view_y2
) &&
1182 (ylocal
+ cell
->GetPosY() + cell
->GetHeight() > view_y1
))
1184 // the cell is visible, draw it:
1185 UpdateRenderingStatePre(info
, cell
);
1187 xlocal
, ylocal
, view_y1
, view_y2
,
1189 UpdateRenderingStatePost(info
, cell
);
1193 // the cell is off-screen, proceed with font+color+etc.
1195 cell
->DrawInvisible(dc
, xlocal
, ylocal
, info
);
1203 void wxHtmlContainerCell::DrawInvisible(wxDC
& dc
, int x
, int y
,
1204 wxHtmlRenderingInfo
& info
)
1208 for (wxHtmlCell
*cell
= m_Cells
; cell
; cell
= cell
->GetNext())
1210 UpdateRenderingStatePre(info
, cell
);
1211 cell
->DrawInvisible(dc
, x
+ m_PosX
, y
+ m_PosY
, info
);
1212 UpdateRenderingStatePost(info
, cell
);
1218 wxColour
wxHtmlContainerCell::GetBackgroundColour()
1225 wxHtmlLinkInfo
*wxHtmlContainerCell::GetLink(int x
, int y
) const
1227 wxHtmlCell
*cell
= FindCellByPos(x
, y
);
1229 // VZ: I don't know if we should pass absolute or relative coords to
1230 // wxHtmlCell::GetLink()? As the base class version just ignores them
1231 // anyhow, it hardly matters right now but should still be clarified
1232 return cell
? cell
->GetLink(x
, y
) : NULL
;
1237 void wxHtmlContainerCell::InsertCell(wxHtmlCell
*f
)
1239 if (!m_Cells
) m_Cells
= m_LastCell
= f
;
1242 m_LastCell
->SetNext(f
);
1244 if (m_LastCell
) while (m_LastCell
->GetNext()) m_LastCell
= m_LastCell
->GetNext();
1252 void wxHtmlContainerCell::SetAlign(const wxHtmlTag
& tag
)
1254 if (tag
.HasParam(wxT("ALIGN")))
1256 wxString alg
= tag
.GetParam(wxT("ALIGN"));
1258 if (alg
== wxT("CENTER"))
1259 SetAlignHor(wxHTML_ALIGN_CENTER
);
1260 else if (alg
== wxT("LEFT"))
1261 SetAlignHor(wxHTML_ALIGN_LEFT
);
1262 else if (alg
== wxT("JUSTIFY"))
1263 SetAlignHor(wxHTML_ALIGN_JUSTIFY
);
1264 else if (alg
== wxT("RIGHT"))
1265 SetAlignHor(wxHTML_ALIGN_RIGHT
);
1272 void wxHtmlContainerCell::SetWidthFloat(const wxHtmlTag
& tag
, double pixel_scale
)
1274 if (tag
.HasParam(wxT("WIDTH")))
1277 wxString wd
= tag
.GetParam(wxT("WIDTH"));
1279 if (wd
[wd
.length()-1] == wxT('%'))
1281 wxSscanf(wd
.c_str(), wxT("%i%%"), &wdi
);
1282 SetWidthFloat(wdi
, wxHTML_UNITS_PERCENT
);
1286 wxSscanf(wd
.c_str(), wxT("%i"), &wdi
);
1287 SetWidthFloat((int)(pixel_scale
* (double)wdi
), wxHTML_UNITS_PIXELS
);
1295 const wxHtmlCell
* wxHtmlContainerCell::Find(int condition
, const void* param
) const
1299 for (wxHtmlCell
*cell
= m_Cells
; cell
; cell
= cell
->GetNext())
1301 const wxHtmlCell
*r
= cell
->Find(condition
, param
);
1309 wxHtmlCell
*wxHtmlContainerCell::FindCellByPos(wxCoord x
, wxCoord y
,
1310 unsigned flags
) const
1312 if ( flags
& wxHTML_FIND_EXACT
)
1314 for ( const wxHtmlCell
*cell
= m_Cells
; cell
; cell
= cell
->GetNext() )
1316 int cx
= cell
->GetPosX(),
1317 cy
= cell
->GetPosY();
1319 if ( (cx
<= x
) && (cx
+ cell
->GetWidth() > x
) &&
1320 (cy
<= y
) && (cy
+ cell
->GetHeight() > y
) )
1322 return cell
->FindCellByPos(x
- cx
, y
- cy
, flags
);
1326 else if ( flags
& wxHTML_FIND_NEAREST_AFTER
)
1329 for ( const wxHtmlCell
*cell
= m_Cells
; cell
; cell
= cell
->GetNext() )
1331 if ( cell
->IsFormattingCell() )
1333 int cellY
= cell
->GetPosY();
1334 if (!( y
< cellY
|| (y
< cellY
+ cell
->GetHeight() &&
1335 x
< cell
->GetPosX() + cell
->GetWidth()) ))
1338 c
= cell
->FindCellByPos(x
- cell
->GetPosX(), y
- cellY
, flags
);
1342 else if ( flags
& wxHTML_FIND_NEAREST_BEFORE
)
1344 wxHtmlCell
*c2
, *c
= NULL
;
1345 for ( const wxHtmlCell
*cell
= m_Cells
; cell
; cell
= cell
->GetNext() )
1347 if ( cell
->IsFormattingCell() )
1349 int cellY
= cell
->GetPosY();
1350 if (!( cellY
+ cell
->GetHeight() <= y
||
1351 (y
>= cellY
&& x
>= cell
->GetPosX()) ))
1353 c2
= cell
->FindCellByPos(x
- cell
->GetPosX(), y
- cellY
, flags
);
1364 bool wxHtmlContainerCell::ProcessMouseClick(wxHtmlWindowInterface
*window
,
1366 const wxMouseEvent
& event
)
1368 #if WXWIN_COMPATIBILITY_2_6
1369 wxHtmlCellOnMouseClickCompatHelper
compat(window
, pos
, event
);
1370 return compat
.CallOnMouseClick(this);
1373 void wxHtmlContainerCell::OnMouseClick(wxWindow
*,
1374 int, int, const wxMouseEvent
& event
)
1376 wxCHECK_RET( gs_helperOnMouseClick
, wxT("unexpected call to OnMouseClick") );
1377 wxHtmlWindowInterface
*window
= gs_helperOnMouseClick
->window
;
1378 const wxPoint
& pos
= gs_helperOnMouseClick
->pos
;
1379 #endif // WXWIN_COMPATIBILITY_2_6
1381 bool retval
= false;
1382 wxHtmlCell
*cell
= FindCellByPos(pos
.x
, pos
.y
);
1384 retval
= cell
->ProcessMouseClick(window
, pos
, event
);
1386 #if WXWIN_COMPATIBILITY_2_6
1387 gs_helperOnMouseClick
->retval
= retval
;
1390 #endif // WXWIN_COMPATIBILITY_2_6
1394 wxHtmlCell
*wxHtmlContainerCell::GetFirstTerminal() const
1399 for (wxHtmlCell
*c
= m_Cells
; c
; c
= c
->GetNext())
1401 c2
= c
->GetFirstTerminal();
1409 wxHtmlCell
*wxHtmlContainerCell::GetLastTerminal() const
1413 // most common case first:
1414 wxHtmlCell
*c
= m_LastCell
->GetLastTerminal();
1419 wxHtmlCell
*c2
= NULL
;
1420 for (c
= m_Cells
; c
; c
= c
->GetNext())
1422 ctmp
= c
->GetLastTerminal();
1433 static bool IsEmptyContainer(wxHtmlContainerCell
*cell
)
1435 for ( wxHtmlCell
*c
= cell
->GetFirstChild(); c
; c
= c
->GetNext() )
1437 if ( !c
->IsTerminalCell() || !c
->IsFormattingCell() )
1443 void wxHtmlContainerCell::RemoveExtraSpacing(bool top
, bool bottom
)
1446 SetIndent(0, wxHTML_INDENT_TOP
);
1448 SetIndent(0, wxHTML_INDENT_BOTTOM
);
1453 wxHtmlContainerCell
*cont
;
1456 for ( c
= m_Cells
; c
; c
= c
->GetNext() )
1458 if ( c
->IsTerminalCell() )
1460 if ( !c
->IsFormattingCell() )
1465 cont
= (wxHtmlContainerCell
*)c
;
1466 if ( IsEmptyContainer(cont
) )
1468 cont
->SetIndent(0, wxHTML_INDENT_VERTICAL
);
1472 cont
->RemoveExtraSpacing(true, false);
1482 for ( c
= m_Cells
; c
; c
= c
->GetNext() )
1485 for ( int i
= arr
.GetCount() - 1; i
>= 0; i
--)
1487 c
= (wxHtmlCell
*)arr
[i
];
1488 if ( c
->IsTerminalCell() )
1490 if ( !c
->IsFormattingCell() )
1495 cont
= (wxHtmlContainerCell
*)c
;
1496 if ( IsEmptyContainer(cont
) )
1498 cont
->SetIndent(0, wxHTML_INDENT_VERTICAL
);
1502 cont
->RemoveExtraSpacing(false, true);
1514 // --------------------------------------------------------------------------
1516 // --------------------------------------------------------------------------
1518 IMPLEMENT_ABSTRACT_CLASS(wxHtmlColourCell
, wxHtmlCell
)
1520 void wxHtmlColourCell::Draw(wxDC
& dc
,
1522 int WXUNUSED(view_y1
), int WXUNUSED(view_y2
),
1523 wxHtmlRenderingInfo
& info
)
1525 DrawInvisible(dc
, x
, y
, info
);
1528 void wxHtmlColourCell::DrawInvisible(wxDC
& dc
,
1529 int WXUNUSED(x
), int WXUNUSED(y
),
1530 wxHtmlRenderingInfo
& info
)
1532 wxHtmlRenderingState
& state
= info
.GetState();
1533 if (m_Flags
& wxHTML_CLR_FOREGROUND
)
1535 state
.SetFgColour(m_Colour
);
1536 if (state
.GetSelectionState() != wxHTML_SEL_IN
)
1537 dc
.SetTextForeground(m_Colour
);
1539 dc
.SetTextForeground(
1540 info
.GetStyle().GetSelectedTextColour(m_Colour
));
1542 if (m_Flags
& wxHTML_CLR_BACKGROUND
)
1544 state
.SetBgColour(m_Colour
);
1545 state
.SetBgMode(wxSOLID
);
1546 const wxColour c
= state
.GetSelectionState() == wxHTML_SEL_IN
1547 ? info
.GetStyle().GetSelectedTextBgColour(m_Colour
)
1549 dc
.SetTextBackground(c
);
1550 dc
.SetBackground(c
);
1551 dc
.SetBackgroundMode(wxSOLID
);
1553 if (m_Flags
& wxHTML_CLR_TRANSPARENT_BACKGROUND
)
1555 state
.SetBgColour(m_Colour
);
1556 state
.SetBgMode(wxTRANSPARENT
);
1557 const wxColour c
= state
.GetSelectionState() == wxHTML_SEL_IN
1558 ? info
.GetStyle().GetSelectedTextBgColour(m_Colour
)
1560 dc
.SetTextBackground(c
);
1561 dc
.SetBackgroundMode(wxTRANSPARENT
);
1568 // ---------------------------------------------------------------------------
1570 // ---------------------------------------------------------------------------
1572 IMPLEMENT_ABSTRACT_CLASS(wxHtmlFontCell
, wxHtmlCell
)
1574 void wxHtmlFontCell::Draw(wxDC
& dc
,
1575 int WXUNUSED(x
), int WXUNUSED(y
),
1576 int WXUNUSED(view_y1
), int WXUNUSED(view_y2
),
1577 wxHtmlRenderingInfo
& WXUNUSED(info
))
1582 void wxHtmlFontCell::DrawInvisible(wxDC
& dc
, int WXUNUSED(x
), int WXUNUSED(y
),
1583 wxHtmlRenderingInfo
& WXUNUSED(info
))
1595 // ---------------------------------------------------------------------------
1597 // ---------------------------------------------------------------------------
1599 IMPLEMENT_ABSTRACT_CLASS(wxHtmlWidgetCell
, wxHtmlCell
)
1601 wxHtmlWidgetCell::wxHtmlWidgetCell(wxWindow
*wnd
, int w
)
1605 m_Wnd
->GetSize(&sx
, &sy
);
1606 m_Width
= sx
, m_Height
= sy
;
1611 void wxHtmlWidgetCell::Draw(wxDC
& WXUNUSED(dc
),
1612 int WXUNUSED(x
), int WXUNUSED(y
),
1613 int WXUNUSED(view_y1
), int WXUNUSED(view_y2
),
1614 wxHtmlRenderingInfo
& WXUNUSED(info
))
1616 int absx
= 0, absy
= 0, stx
, sty
;
1617 wxHtmlCell
*c
= this;
1621 absx
+= c
->GetPosX();
1622 absy
+= c
->GetPosY();
1626 wxScrolledWindow
*scrolwin
=
1627 wxDynamicCast(m_Wnd
->GetParent(), wxScrolledWindow
);
1628 wxCHECK_RET( scrolwin
,
1629 wxT("widget cells can only be placed in wxHtmlWindow") );
1631 scrolwin
->GetViewStart(&stx
, &sty
);
1632 m_Wnd
->SetSize(absx
- wxHTML_SCROLL_STEP
* stx
,
1633 absy
- wxHTML_SCROLL_STEP
* sty
,
1639 void wxHtmlWidgetCell::DrawInvisible(wxDC
& WXUNUSED(dc
),
1640 int WXUNUSED(x
), int WXUNUSED(y
),
1641 wxHtmlRenderingInfo
& WXUNUSED(info
))
1643 int absx
= 0, absy
= 0, stx
, sty
;
1644 wxHtmlCell
*c
= this;
1648 absx
+= c
->GetPosX();
1649 absy
+= c
->GetPosY();
1653 ((wxScrolledWindow
*)(m_Wnd
->GetParent()))->GetViewStart(&stx
, &sty
);
1654 m_Wnd
->SetSize(absx
- wxHTML_SCROLL_STEP
* stx
, absy
- wxHTML_SCROLL_STEP
* sty
, m_Width
, m_Height
);
1659 void wxHtmlWidgetCell::Layout(int w
)
1661 if (m_WidthFloat
!= 0)
1663 m_Width
= (w
* m_WidthFloat
) / 100;
1664 m_Wnd
->SetSize(m_Width
, m_Height
);
1667 wxHtmlCell::Layout(w
);
1672 // ----------------------------------------------------------------------------
1673 // wxHtmlTerminalCellsInterator
1674 // ----------------------------------------------------------------------------
1676 const wxHtmlCell
* wxHtmlTerminalCellsInterator::operator++()
1683 if ( m_pos
== m_to
)
1689 if ( m_pos
->GetNext() )
1690 m_pos
= m_pos
->GetNext();
1693 // we must go up the hierarchy until we reach container where this
1694 // is not the last child, and then go down to first terminal cell:
1695 while ( m_pos
->GetNext() == NULL
)
1697 m_pos
= m_pos
->GetParent();
1701 m_pos
= m_pos
->GetNext();
1703 while ( m_pos
->GetFirstChild() != NULL
)
1704 m_pos
= m_pos
->GetFirstChild();
1705 } while ( !m_pos
->IsTerminalCell() );