1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/html/htmlcell.cpp
3 // Purpose: wxHtmlCell - basic element of HTML output
4 // Author: Vaclav Slavik
5 // Copyright: (c) 1999 Vaclav Slavik
6 // Licence: wxWindows licence
7 /////////////////////////////////////////////////////////////////////////////
15 #if wxUSE_HTML && wxUSE_STREAMS
18 #include "wx/dynarray.h"
20 #include "wx/colour.h"
22 #include "wx/settings.h"
23 #include "wx/module.h"
24 #include "wx/wxcrtvararg.h"
27 #include "wx/html/htmlcell.h"
28 #include "wx/html/htmlwin.h"
32 //-----------------------------------------------------------------------------
34 //-----------------------------------------------------------------------------
36 void wxHtmlSelection::Set(const wxPoint
& fromPos
, const wxHtmlCell
*fromCell
,
37 const wxPoint
& toPos
, const wxHtmlCell
*toCell
)
39 m_fromCell
= fromCell
;
45 void wxHtmlSelection::Set(const wxHtmlCell
*fromCell
, const wxHtmlCell
*toCell
)
47 wxPoint p1
= fromCell
? fromCell
->GetAbsPos() : wxDefaultPosition
;
48 wxPoint p2
= toCell
? toCell
->GetAbsPos() : wxDefaultPosition
;
51 p2
.x
+= toCell
->GetWidth();
52 p2
.y
+= toCell
->GetHeight();
54 Set(p1
, fromCell
, p2
, toCell
);
58 wxDefaultHtmlRenderingStyle::
59 GetSelectedTextColour(const wxColour
& WXUNUSED(clr
))
61 return wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT
);
65 wxDefaultHtmlRenderingStyle::
66 GetSelectedTextBgColour(const wxColour
& WXUNUSED(clr
))
68 return wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT
);
72 //-----------------------------------------------------------------------------
74 //-----------------------------------------------------------------------------
76 IMPLEMENT_ABSTRACT_CLASS(wxHtmlCell
, wxObject
)
78 wxHtmlCell::wxHtmlCell() : wxObject()
82 m_Width
= m_Height
= m_Descent
= 0;
83 m_ScriptMode
= wxHTML_SCRIPT_NORMAL
; // <sub> or <sup> mode
84 m_ScriptBaseline
= 0; // <sub> or <sup> baseline
85 m_CanLiveOnPagebreak
= true;
89 wxHtmlCell::~wxHtmlCell()
94 // Update the descent value when whe are in a <sub> or <sup>.
95 // prevbase is the parent base
96 void wxHtmlCell::SetScriptMode(wxHtmlScriptMode mode
, long previousBase
)
100 if (mode
== wxHTML_SCRIPT_SUP
)
101 m_ScriptBaseline
= previousBase
- (m_Height
+ 1) / 2;
102 else if (mode
== wxHTML_SCRIPT_SUB
)
103 m_ScriptBaseline
= previousBase
+ (m_Height
+ 1) / 6;
105 m_ScriptBaseline
= 0;
107 m_Descent
+= m_ScriptBaseline
;
110 #if WXWIN_COMPATIBILITY_2_6
112 struct wxHtmlCellOnMouseClickCompatHelper
;
114 static wxHtmlCellOnMouseClickCompatHelper
*gs_helperOnMouseClick
= NULL
;
116 // helper for routing calls to new ProcessMouseClick() method to deprecated
117 // OnMouseClick() method
118 struct wxHtmlCellOnMouseClickCompatHelper
120 wxHtmlCellOnMouseClickCompatHelper(wxHtmlWindowInterface
*window_
,
122 const wxMouseEvent
& event_
)
123 : window(window_
), pos(pos_
), event(event_
), retval(false)
127 bool CallOnMouseClick(wxHtmlCell
*cell
)
129 wxHtmlCellOnMouseClickCompatHelper
*oldHelper
= gs_helperOnMouseClick
;
130 gs_helperOnMouseClick
= this;
133 window
? window
->GetHTMLWindow() : NULL
,
137 gs_helperOnMouseClick
= oldHelper
;
141 wxHtmlWindowInterface
*window
;
143 const wxMouseEvent
& event
;
146 #endif // WXWIN_COMPATIBILITY_2_6
148 bool wxHtmlCell::ProcessMouseClick(wxHtmlWindowInterface
*window
,
150 const wxMouseEvent
& event
)
152 wxCHECK_MSG( window
, false, wxT("window interface must be provided") );
154 #if WXWIN_COMPATIBILITY_2_6
155 // NB: this hack puts the body of ProcessMouseClick() into OnMouseClick()
156 // (for which it has to pass the arguments and return value via a
157 // helper variable because these two methods have different
158 // signatures), so that old code overriding OnMouseClick will continue
160 wxHtmlCellOnMouseClickCompatHelper
compat(window
, pos
, event
);
161 return compat
.CallOnMouseClick(this);
164 void wxHtmlCell::OnMouseClick(wxWindow
*, int, int, const wxMouseEvent
& event
)
166 wxCHECK_RET( gs_helperOnMouseClick
, wxT("unexpected call to OnMouseClick") );
167 wxHtmlWindowInterface
*window
= gs_helperOnMouseClick
->window
;
168 const wxPoint
& pos
= gs_helperOnMouseClick
->pos
;
169 #endif // WXWIN_COMPATIBILITY_2_6
171 wxHtmlLinkInfo
*lnk
= GetLink(pos
.x
, pos
.y
);
176 wxHtmlLinkInfo
lnk2(*lnk
);
177 lnk2
.SetEvent(&event
);
178 lnk2
.SetHtmlCell(this);
180 window
->OnHTMLLinkClicked(lnk2
);
184 #if WXWIN_COMPATIBILITY_2_6
185 gs_helperOnMouseClick
->retval
= retval
;
188 #endif // WXWIN_COMPATIBILITY_2_6
191 #if WXWIN_COMPATIBILITY_2_6
192 wxCursor
wxHtmlCell::GetCursor() const
196 #endif // WXWIN_COMPATIBILITY_2_6
199 wxHtmlCell::GetMouseCursor(wxHtmlWindowInterface
* WXUNUSED(window
)) const
201 // This is never called directly, only from GetMouseCursorAt() and we
202 // return an invalid cursor by default to let it delegate to the window.
207 wxHtmlCell::GetMouseCursorAt(wxHtmlWindowInterface
*window
,
208 const wxPoint
& relPos
) const
210 #if WXWIN_COMPATIBILITY_2_6
211 // NB: Older versions of wx used GetCursor() virtual method in place of
212 // GetMouseCursor(interface). This code ensures that user code that
213 // overridden GetCursor() continues to work. The trick is that the base
214 // wxHtmlCell::GetCursor() method simply returns wxNullCursor, so we
215 // know that GetCursor() was overridden iff it returns valid cursor.
216 wxCursor cur
= GetCursor();
219 #endif // WXWIN_COMPATIBILITY_2_6
221 const wxCursor curCell
= GetMouseCursor(window
);
222 if ( curCell
.IsOk() )
225 if ( GetLink(relPos
.x
, relPos
.y
) )
227 return window
->GetHTMLCursor(wxHtmlWindowInterface::HTMLCursor_Link
);
231 return window
->GetHTMLCursor(wxHtmlWindowInterface::HTMLCursor_Default
);
237 wxHtmlCell::AdjustPagebreak(int *pagebreak
,
238 const wxArrayInt
& WXUNUSED(known_pagebreaks
),
239 int pageHeight
) const
241 // Notice that we always break the cells bigger than the page height here
242 // as otherwise we wouldn't be able to break them at all.
243 if ( m_Height
<= pageHeight
&&
244 (!m_CanLiveOnPagebreak
&&
245 m_PosY
< *pagebreak
&& m_PosY
+ m_Height
> *pagebreak
) )
256 void wxHtmlCell::SetLink(const wxHtmlLinkInfo
& link
)
259 if (link
.GetHref() != wxEmptyString
)
260 m_Link
= new wxHtmlLinkInfo(link
);
264 void wxHtmlCell::Layout(int WXUNUSED(w
))
271 const wxHtmlCell
* wxHtmlCell::Find(int WXUNUSED(condition
), const void* WXUNUSED(param
)) const
277 wxHtmlCell
*wxHtmlCell::FindCellByPos(wxCoord x
, wxCoord y
,
278 unsigned flags
) const
280 if ( x
>= 0 && x
< m_Width
&& y
>= 0 && y
< m_Height
)
282 return wxConstCast(this, wxHtmlCell
);
286 if ((flags
& wxHTML_FIND_NEAREST_AFTER
) &&
287 (y
< 0 || (y
< 0+m_Height
&& x
< 0+m_Width
)))
288 return wxConstCast(this, wxHtmlCell
);
289 else if ((flags
& wxHTML_FIND_NEAREST_BEFORE
) &&
290 (y
>= 0+m_Height
|| (y
>= 0 && x
>= 0)))
291 return wxConstCast(this, wxHtmlCell
);
298 wxPoint
wxHtmlCell::GetAbsPos(wxHtmlCell
*rootCell
) const
300 wxPoint
p(m_PosX
, m_PosY
);
301 for (wxHtmlCell
*parent
= m_Parent
; parent
&& parent
!= rootCell
;
302 parent
= parent
->m_Parent
)
304 p
.x
+= parent
->m_PosX
;
305 p
.y
+= parent
->m_PosY
;
310 wxHtmlCell
*wxHtmlCell::GetRootCell() const
312 wxHtmlCell
*c
= wxConstCast(this, wxHtmlCell
);
313 while ( c
->m_Parent
)
318 unsigned wxHtmlCell::GetDepth() const
321 for (wxHtmlCell
*p
= m_Parent
; p
; p
= p
->m_Parent
)
326 bool wxHtmlCell::IsBefore(wxHtmlCell
*cell
) const
328 const wxHtmlCell
*c1
= this;
329 const wxHtmlCell
*c2
= cell
;
330 unsigned d1
= GetDepth();
331 unsigned d2
= cell
->GetDepth();
334 for (; d1
!= d2
; d1
-- )
337 for (; d1
!= d2
; d2
-- )
345 if ( c1
->m_Parent
== c2
->m_Parent
)
362 wxFAIL_MSG(wxT("Cells are in different trees"));
367 //-----------------------------------------------------------------------------
369 //-----------------------------------------------------------------------------
371 IMPLEMENT_ABSTRACT_CLASS(wxHtmlWordCell
, wxHtmlCell
)
373 wxHtmlWordCell::wxHtmlWordCell(const wxString
& word
, const wxDC
& dc
) : wxHtmlCell()
377 dc
.GetTextExtent(m_Word
, &w
, &h
, &d
);
381 SetCanLiveOnPagebreak(false);
382 m_allowLinebreak
= true;
385 void wxHtmlWordCell::SetPreviousWord(wxHtmlWordCell
*cell
)
387 if ( cell
&& m_Parent
== cell
->m_Parent
&&
388 !wxIsspace(cell
->m_Word
.Last()) && !wxIsspace(m_Word
[0u]) )
390 m_allowLinebreak
= false;
394 // Splits m_Word into up to three parts according to selection, returns
395 // substring before, in and after selection and the points (in relative coords)
396 // where s2 and s3 start:
397 void wxHtmlWordCell::Split(const wxDC
& dc
,
398 const wxPoint
& selFrom
, const wxPoint
& selTo
,
399 unsigned& pos1
, unsigned& pos2
) const
401 wxPoint pt1
= (selFrom
== wxDefaultPosition
) ?
402 wxDefaultPosition
: selFrom
- GetAbsPos();
403 wxPoint pt2
= (selTo
== wxDefaultPosition
) ?
404 wxPoint(m_Width
, wxDefaultCoord
) : selTo
- GetAbsPos();
406 // if the selection is entirely within this cell, make sure pt1 < pt2 in
407 // order to make the rest of this function simpler:
408 if ( selFrom
!= wxDefaultPosition
&& selTo
!= wxDefaultPosition
&&
409 selFrom
.x
> selTo
.x
)
416 unsigned len
= m_Word
.length();
420 // adjust for cases when the start/end position is completely
424 if ( pt2
.y
>= m_Height
)
428 // (include character under caret only if in first half of width)
430 // implementation using PartialExtents to support fractional widths
432 dc
.GetPartialTextExtents(m_Word
,widths
) ;
433 while( i
< len
&& pt1
.x
>= widths
[i
] )
437 int charW
= (i
> 0) ? widths
[i
] - widths
[i
-1] : widths
[i
];
438 if ( widths
[i
] - pt1
.x
< charW
/2 )
442 wxCoord charW
, charH
;
443 while ( pt1
.x
> 0 && i
< len
)
445 dc
.GetTextExtent(m_Word
[i
], &charW
, &charH
);
447 if ( pt1
.x
>= -charW
/2 )
453 #endif // __WXMAC__/!__WXMAC__
456 // (include character under caret only if in first half of width)
459 while( j
< len
&& pt2
.x
>= widths
[j
] )
463 int charW
= (j
> 0) ? widths
[j
] - widths
[j
-1] : widths
[j
];
464 if ( widths
[j
] - pt2
.x
< charW
/2 )
470 while ( pt2
.x
> 0 && j
< len
)
472 dc
.GetTextExtent(m_Word
[j
], &charW
, &charH
);
474 if ( pt2
.x
>= -charW
/2 )
480 #endif // __WXMAC__/!__WXMAC__
485 wxASSERT( pos2
>= pos1
);
488 void wxHtmlWordCell::SetSelectionPrivPos(const wxDC
& dc
, wxHtmlSelection
*s
) const
493 this == s
->GetFromCell() ? s
->GetFromPos() : wxDefaultPosition
,
494 this == s
->GetToCell() ? s
->GetToPos() : wxDefaultPosition
,
497 if ( this == s
->GetFromCell() )
498 s
->SetFromCharacterPos (p1
); // selection starts here
499 if ( this == s
->GetToCell() )
500 s
->SetToCharacterPos (p2
); // selection ends here
504 static void SwitchSelState(wxDC
& dc
, wxHtmlRenderingInfo
& info
,
507 wxColour fg
= info
.GetState().GetFgColour();
508 wxColour bg
= info
.GetState().GetBgColour();
512 dc
.SetBackgroundMode(wxSOLID
);
513 dc
.SetTextForeground(info
.GetStyle().GetSelectedTextColour(fg
));
514 dc
.SetTextBackground(info
.GetStyle().GetSelectedTextBgColour(bg
));
515 dc
.SetBackground(wxBrush(info
.GetStyle().GetSelectedTextBgColour(bg
),
516 wxBRUSHSTYLE_SOLID
));
520 const int mode
= info
.GetState().GetBgMode();
521 dc
.SetBackgroundMode(mode
);
522 dc
.SetTextForeground(fg
);
523 dc
.SetTextBackground(bg
);
524 if ( mode
!= wxTRANSPARENT
)
525 dc
.SetBackground(wxBrush(bg
, mode
));
530 void wxHtmlWordCell::Draw(wxDC
& dc
, int x
, int y
,
531 int WXUNUSED(view_y1
), int WXUNUSED(view_y2
),
532 wxHtmlRenderingInfo
& info
)
534 #if 0 // useful for debugging
535 dc
.SetPen(*wxBLACK_PEN
);
536 dc
.DrawRectangle(x
+m_PosX
,y
+m_PosY
,m_Width
/* VZ: +1? */ ,m_Height
);
539 bool drawSelectionAfterCell
= false;
541 if ( info
.GetState().GetSelectionState() == wxHTML_SEL_CHANGING
)
543 // Selection changing, we must draw the word piecewise:
544 wxHtmlSelection
*s
= info
.GetSelection();
549 // NB: this is quite a hack: in order to compute selection boundaries
550 // (in word's characters) we must know current font, which is only
551 // possible inside rendering code. Therefore we update the
552 // information here and store it in wxHtmlSelection so that
553 // ConvertToText can use it later:
554 if ( !s
->AreFromToCharacterPosSet () )
556 SetSelectionPrivPos(dc
, s
);
559 int part1
= s
->GetFromCell()==this ? s
->GetFromCharacterPos() : 0;
560 int part2
= s
->GetToCell()==this ? s
->GetToCharacterPos() : m_Word
.Length();
564 txt
= m_Word
.Mid(0, part1
);
565 dc
.DrawText(txt
, x
+ m_PosX
, y
+ m_PosY
);
566 dc
.GetTextExtent(txt
, &w
, &h
);
570 SwitchSelState(dc
, info
, true);
572 txt
= m_Word
.Mid(part1
, part2
-part1
);
573 dc
.DrawText(txt
, ofs
+ x
+ m_PosX
, y
+ m_PosY
);
575 if ( (size_t)part2
< m_Word
.length() )
577 dc
.GetTextExtent(txt
, &w
, &h
);
579 SwitchSelState(dc
, info
, false);
580 txt
= m_Word
.Mid(part2
);
581 dc
.DrawText(txt
, ofs
+ x
+ m_PosX
, y
+ m_PosY
);
584 drawSelectionAfterCell
= true;
588 wxHtmlSelectionState selstate
= info
.GetState().GetSelectionState();
589 // Not changing selection state, draw the word in single mode:
590 SwitchSelState(dc
, info
, selstate
!= wxHTML_SEL_OUT
);
591 dc
.DrawText(m_Word
, x
+ m_PosX
, y
+ m_PosY
);
592 drawSelectionAfterCell
= (selstate
!= wxHTML_SEL_OUT
);
595 // NB: If the text is justified then there is usually some free space
596 // between adjacent cells and drawing the selection only onto cells
597 // would result in ugly unselected spaces. The code below detects
598 // this special case and renders the selection *outside* the sell,
600 if ( m_Parent
->GetAlignHor() == wxHTML_ALIGN_JUSTIFY
&&
601 drawSelectionAfterCell
)
603 wxHtmlCell
*nextCell
= m_Next
;
604 while ( nextCell
&& nextCell
->IsFormattingCell() )
605 nextCell
= nextCell
->GetNext();
608 int nextX
= nextCell
->GetPosX();
609 if ( m_PosX
+ m_Width
< nextX
)
611 dc
.SetBrush(dc
.GetBackground());
612 dc
.SetPen(*wxTRANSPARENT_PEN
);
613 dc
.DrawRectangle(x
+ m_PosX
+ m_Width
, y
+ m_PosY
,
614 nextX
- m_PosX
- m_Width
, m_Height
);
620 wxCursor
wxHtmlWordCell::GetMouseCursor(wxHtmlWindowInterface
*window
) const
624 return window
->GetHTMLCursor(wxHtmlWindowInterface::HTMLCursor_Text
);
628 return wxHtmlCell::GetMouseCursor(window
);
632 wxString
wxHtmlWordCell::ConvertToText(wxHtmlSelection
*s
) const
634 if ( s
&& (this == s
->GetFromCell() || this == s
->GetToCell()) )
636 // VZ: we may be called before we had a chance to re-render ourselves
637 // and in this case GetFrom/ToPrivPos() is not set yet -- assume
638 // that this only happens in case of a double/triple click (which
639 // seems to be the case now) and so it makes sense to select the
640 // entire contents of the cell in this case
642 // TODO: but this really needs to be fixed in some better way later...
643 if ( s
->AreFromToCharacterPosSet() )
645 const int part1
= s
->GetFromCell()==this ? s
->GetFromCharacterPos() : 0;
646 const int part2
= s
->GetToCell()==this ? s
->GetToCharacterPos() : m_Word
.Length();
647 if ( part1
== part2
)
648 return wxEmptyString
;
649 return GetPartAsText(part1
, part2
);
651 //else: return the whole word below
654 return GetAllAsText();
657 wxString
wxHtmlWordWithTabsCell::GetAllAsText() const
662 wxString
wxHtmlWordWithTabsCell::GetPartAsText(int begin
, int end
) const
664 // NB: The 'begin' and 'end' positions are in the _displayed_ text
665 // (stored in m_Word) and not in the text with tabs that should
666 // be copied to clipboard (m_wordOrig).
668 // NB: Because selection is performed on displayed text, it's possible
669 // to select e.g. "half of TAB character" -- IOW, 'begin' and 'end'
670 // may be in the middle of TAB character expansion into ' 's. In this
671 // case, we copy the TAB character to clipboard once.
673 wxASSERT( begin
< end
);
675 const unsigned SPACES_PER_TAB
= 8;
680 wxString::const_iterator i
= m_wordOrig
.begin();
682 // find the beginning of text to copy:
683 for ( ; pos
< begin
; ++i
)
687 pos
+= 8 - (m_linepos
+ pos
) % SPACES_PER_TAB
;
699 // copy the content until we reach 'end':
700 for ( ; pos
< end
; ++i
)
706 pos
+= 8 - (m_linepos
+ pos
) % SPACES_PER_TAB
;
716 //-----------------------------------------------------------------------------
717 // wxHtmlContainerCell
718 //-----------------------------------------------------------------------------
720 IMPLEMENT_ABSTRACT_CLASS(wxHtmlContainerCell
, wxHtmlCell
)
722 wxHtmlContainerCell::wxHtmlContainerCell(wxHtmlContainerCell
*parent
) : wxHtmlCell()
724 m_Cells
= m_LastCell
= NULL
;
727 if (m_Parent
) m_Parent
->InsertCell(this);
728 m_AlignHor
= wxHTML_ALIGN_LEFT
;
729 m_AlignVer
= wxHTML_ALIGN_BOTTOM
;
730 m_IndentLeft
= m_IndentRight
= m_IndentTop
= m_IndentBottom
= 0;
731 m_WidthFloat
= 100; m_WidthFloatUnits
= wxHTML_UNITS_PERCENT
;
732 m_BkColour
= wxNullColour
;
735 m_MinHeightAlign
= wxHTML_ALIGN_TOP
;
739 wxHtmlContainerCell::~wxHtmlContainerCell()
741 wxHtmlCell
*cell
= m_Cells
;
744 wxHtmlCell
*cellNext
= cell
->GetNext();
752 void wxHtmlContainerCell::SetIndent(int i
, int what
, int units
)
754 int val
= (units
== wxHTML_UNITS_PIXELS
) ? i
: -i
;
755 if (what
& wxHTML_INDENT_LEFT
) m_IndentLeft
= val
;
756 if (what
& wxHTML_INDENT_RIGHT
) m_IndentRight
= val
;
757 if (what
& wxHTML_INDENT_TOP
) m_IndentTop
= val
;
758 if (what
& wxHTML_INDENT_BOTTOM
) m_IndentBottom
= val
;
764 int wxHtmlContainerCell::GetIndent(int ind
) const
766 if (ind
& wxHTML_INDENT_LEFT
) return m_IndentLeft
;
767 else if (ind
& wxHTML_INDENT_RIGHT
) return m_IndentRight
;
768 else if (ind
& wxHTML_INDENT_TOP
) return m_IndentTop
;
769 else if (ind
& wxHTML_INDENT_BOTTOM
) return m_IndentBottom
;
770 else return -1; /* BUG! Should not be called... */
776 int wxHtmlContainerCell::GetIndentUnits(int ind
) const
779 if (ind
& wxHTML_INDENT_LEFT
) p
= m_IndentLeft
< 0;
780 else if (ind
& wxHTML_INDENT_RIGHT
) p
= m_IndentRight
< 0;
781 else if (ind
& wxHTML_INDENT_TOP
) p
= m_IndentTop
< 0;
782 else if (ind
& wxHTML_INDENT_BOTTOM
) p
= m_IndentBottom
< 0;
783 if (p
) return wxHTML_UNITS_PERCENT
;
784 else return wxHTML_UNITS_PIXELS
;
789 wxHtmlContainerCell::AdjustPagebreak(int *pagebreak
,
790 const wxArrayInt
& known_pagebreaks
,
791 int pageHeight
) const
793 if (!m_CanLiveOnPagebreak
)
794 return wxHtmlCell::AdjustPagebreak(pagebreak
, known_pagebreaks
, pageHeight
);
796 wxHtmlCell
*c
= GetFirstChild();
798 int pbrk
= *pagebreak
- m_PosY
;
802 if (c
->AdjustPagebreak(&pbrk
, known_pagebreaks
, pageHeight
))
807 *pagebreak
= pbrk
+ m_PosY
;
812 void wxHtmlContainerCell::Layout(int w
)
814 wxHtmlCell::Layout(w
);
816 if (m_LastLayout
== w
)
820 // VS: Any attempt to layout with negative or zero width leads to hell,
821 // but we can't ignore such attempts completely, since it sometimes
822 // happen (e.g. when trying how small a table can be). The best thing we
823 // can do is to set the width of child cells to zero
827 for (wxHtmlCell
*cell
= m_Cells
; cell
; cell
= cell
->GetNext())
829 // this does two things: it recursively calls this code on all
830 // child contrainers and resets children's position to (0,0)
834 wxHtmlCell
*nextCell
;
835 long xpos
= 0, ypos
= m_IndentTop
;
836 int xdelta
= 0, ybasicpos
= 0, ydiff
;
837 int s_width
, nextWordWidth
, s_indent
;
838 int ysizeup
= 0, ysizedown
= 0;
839 int MaxLineWidth
= 0;
840 int curLineWidth
= 0;
850 if (m_WidthFloatUnits
== wxHTML_UNITS_PERCENT
)
852 if (m_WidthFloat
< 0) m_Width
= (100 + m_WidthFloat
) * w
/ 100;
853 else m_Width
= m_WidthFloat
* w
/ 100;
857 if (m_WidthFloat
< 0) m_Width
= w
+ m_WidthFloat
;
858 else m_Width
= m_WidthFloat
;
863 int l
= (m_IndentLeft
< 0) ? (-m_IndentLeft
* m_Width
/ 100) : m_IndentLeft
;
864 int r
= (m_IndentRight
< 0) ? (-m_IndentRight
* m_Width
/ 100) : m_IndentRight
;
865 for (wxHtmlCell
*cell
= m_Cells
; cell
; cell
= cell
->GetNext())
866 cell
->Layout(m_Width
- (l
+ r
));
875 // adjust indentation:
876 s_indent
= (m_IndentLeft
< 0) ? (-m_IndentLeft
* m_Width
/ 100) : m_IndentLeft
;
877 s_width
= m_Width
- s_indent
- ((m_IndentRight
< 0) ? (-m_IndentRight
* m_Width
/ 100) : m_IndentRight
);
880 wxHtmlCell
*cell
= m_Cells
,
886 case wxHTML_ALIGN_TOP
: ybasicpos
= 0; break;
887 case wxHTML_ALIGN_BOTTOM
: ybasicpos
= - cell
->GetHeight(); break;
888 case wxHTML_ALIGN_CENTER
: ybasicpos
= - cell
->GetHeight() / 2; break;
890 ydiff
= cell
->GetHeight() + ybasicpos
;
892 if (cell
->GetDescent() + ydiff
> ysizedown
) ysizedown
= cell
->GetDescent() + ydiff
;
893 if (ybasicpos
+ cell
->GetDescent() < -ysizeup
) ysizeup
= - (ybasicpos
+ cell
->GetDescent());
895 // layout nonbreakable run of cells:
896 cell
->SetPos(xpos
, ybasicpos
+ cell
->GetDescent());
897 xpos
+= cell
->GetWidth();
898 if (!cell
->IsTerminalCell())
900 // Container cell indicates new line
901 if (curLineWidth
> m_MaxTotalWidth
)
902 m_MaxTotalWidth
= curLineWidth
;
904 if (wxMax(cell
->GetWidth(), cell
->GetMaxTotalWidth()) > m_MaxTotalWidth
)
905 m_MaxTotalWidth
= cell
->GetMaxTotalWidth();
909 // Normal cell, add maximum cell width to line width
910 curLineWidth
+= cell
->GetMaxTotalWidth();
912 cell
= cell
->GetNext();
914 // compute length of the next word that would be added:
921 nextWordWidth
+= nextCell
->GetWidth();
922 nextCell
= nextCell
->GetNext();
923 } while (nextCell
&& !nextCell
->IsLinebreakAllowed());
926 // force new line if occurred:
927 if ((cell
== NULL
) ||
928 (xpos
+ nextWordWidth
> s_width
&& cell
->IsLinebreakAllowed()))
930 if (xpos
> MaxLineWidth
) MaxLineWidth
= xpos
;
931 if (ysizeup
< 0) ysizeup
= 0;
932 if (ysizedown
< 0) ysizedown
= 0;
933 switch (m_AlignHor
) {
934 case wxHTML_ALIGN_LEFT
:
935 case wxHTML_ALIGN_JUSTIFY
:
938 case wxHTML_ALIGN_RIGHT
:
939 xdelta
= 0 + (s_width
- xpos
);
941 case wxHTML_ALIGN_CENTER
:
942 xdelta
= 0 + (s_width
- xpos
) / 2;
945 if (xdelta
< 0) xdelta
= 0;
950 if (m_AlignHor
!= wxHTML_ALIGN_JUSTIFY
|| cell
== NULL
)
954 line
->SetPos(line
->GetPosX() + xdelta
,
955 ypos
+ line
->GetPosY());
956 line
= line
->GetNext();
959 else // align == justify
961 // we have to distribute the extra horz space between the cells
964 // an added complication is that some cells have fixed size and
965 // shouldn't get any increment (it so happens that these cells
966 // also don't allow line break on them which provides with an
967 // easy way to test for this) -- and neither should the cells
968 // adjacent to them as this could result in a visible space
969 // between two cells separated by, e.g. font change, cell which
972 int step
= s_width
- xpos
;
975 // first count the cells which will get extra space
981 for ( c
= line
; c
!= cell
; c
= c
->GetNext() )
983 if ( c
->IsLinebreakAllowed() )
990 // and now extra space to those cells which merit it
993 // first visible cell on line is not moved:
994 while (line
!=cell
&& !line
->IsLinebreakAllowed())
996 line
->SetPos(line
->GetPosX() + s_indent
,
997 line
->GetPosY() + ypos
);
998 line
= line
->GetNext();
1003 line
->SetPos(line
->GetPosX() + s_indent
,
1004 line
->GetPosY() + ypos
);
1006 line
= line
->GetNext();
1009 for ( int n
= 0; line
!= cell
; line
= line
->GetNext() )
1011 if ( line
->IsLinebreakAllowed() )
1013 // offset the next cell relative to this one
1014 // thus increasing our size
1018 line
->SetPos(line
->GetPosX() + s_indent
+
1019 ((n
* step
) / total
),
1020 line
->GetPosY() + ypos
);
1025 // this will cause the code to enter "else branch" below:
1030 if ( step
<= 0 ) // no extra space to distribute
1032 // just set the indent properly
1033 while (line
!= cell
)
1035 line
->SetPos(line
->GetPosX() + s_indent
,
1036 line
->GetPosY() + ypos
);
1037 line
= line
->GetNext();
1044 ysizeup
= ysizedown
= 0;
1049 // setup height & width, depending on container layout:
1050 m_Height
= ypos
+ (ysizedown
+ ysizeup
) + m_IndentBottom
;
1052 if (m_Height
< m_MinHeight
)
1054 if (m_MinHeightAlign
!= wxHTML_ALIGN_TOP
)
1056 int diff
= m_MinHeight
- m_Height
;
1057 if (m_MinHeightAlign
== wxHTML_ALIGN_CENTER
) diff
/= 2;
1061 cell
->SetPos(cell
->GetPosX(), cell
->GetPosY() + diff
);
1062 cell
= cell
->GetNext();
1065 m_Height
= m_MinHeight
;
1068 if (curLineWidth
> m_MaxTotalWidth
)
1069 m_MaxTotalWidth
= curLineWidth
;
1071 m_MaxTotalWidth
+= s_indent
+ ((m_IndentRight
< 0) ? (-m_IndentRight
* m_Width
/ 100) : m_IndentRight
);
1072 MaxLineWidth
+= s_indent
+ ((m_IndentRight
< 0) ? (-m_IndentRight
* m_Width
/ 100) : m_IndentRight
);
1073 if (m_Width
< MaxLineWidth
) m_Width
= MaxLineWidth
;
1076 void wxHtmlContainerCell::UpdateRenderingStatePre(wxHtmlRenderingInfo
& info
,
1077 wxHtmlCell
*cell
) const
1079 wxHtmlSelection
*s
= info
.GetSelection();
1081 if (s
->GetFromCell() == cell
|| s
->GetToCell() == cell
)
1083 info
.GetState().SetSelectionState(wxHTML_SEL_CHANGING
);
1087 void wxHtmlContainerCell::UpdateRenderingStatePost(wxHtmlRenderingInfo
& info
,
1088 wxHtmlCell
*cell
) const
1090 wxHtmlSelection
*s
= info
.GetSelection();
1092 if (s
->GetToCell() == cell
)
1093 info
.GetState().SetSelectionState(wxHTML_SEL_OUT
);
1094 else if (s
->GetFromCell() == cell
)
1095 info
.GetState().SetSelectionState(wxHTML_SEL_IN
);
1098 #define mMin(a, b) (((a) < (b)) ? (a) : (b))
1099 #define mMax(a, b) (((a) < (b)) ? (b) : (a))
1101 void wxHtmlContainerCell::Draw(wxDC
& dc
, int x
, int y
, int view_y1
, int view_y2
,
1102 wxHtmlRenderingInfo
& info
)
1104 #if 0 // useful for debugging
1105 dc
.SetPen(*wxRED_PEN
);
1106 dc
.DrawRectangle(x
+m_PosX
,y
+m_PosY
,m_Width
,m_Height
);
1109 int xlocal
= x
+ m_PosX
;
1110 int ylocal
= y
+ m_PosY
;
1112 if (m_BkColour
.IsOk())
1114 wxBrush myb
= wxBrush(m_BkColour
, wxBRUSHSTYLE_SOLID
);
1116 int real_y1
= mMax(ylocal
, view_y1
);
1117 int real_y2
= mMin(ylocal
+ m_Height
- 1, view_y2
);
1120 dc
.SetPen(*wxTRANSPARENT_PEN
);
1121 dc
.DrawRectangle(xlocal
, real_y1
, m_Width
, real_y2
- real_y1
+ 1);
1126 // draw thin border using lines
1127 wxPen
mypen1(m_BorderColour1
, 1, wxPENSTYLE_SOLID
);
1128 wxPen
mypen2(m_BorderColour2
, 1, wxPENSTYLE_SOLID
);
1131 dc
.DrawLine(xlocal
, ylocal
, xlocal
, ylocal
+ m_Height
- 1);
1132 dc
.DrawLine(xlocal
, ylocal
, xlocal
+ m_Width
, ylocal
);
1134 dc
.DrawLine(xlocal
+ m_Width
- 1, ylocal
, xlocal
+ m_Width
- 1, ylocal
+ m_Height
- 1);
1135 dc
.DrawLine(xlocal
, ylocal
+ m_Height
- 1, xlocal
+ m_Width
, ylocal
+ m_Height
- 1);
1137 else if (m_Border
> 0)
1139 wxBrush
mybrush1(m_BorderColour1
, wxBRUSHSTYLE_SOLID
);
1140 wxBrush
mybrush2(m_BorderColour2
, wxBRUSHSTYLE_SOLID
);
1142 // draw upper left corner
1143 // 0---------------5
1152 poly
[0].x
=m_PosX
; poly
[0].y
= m_PosY
;
1153 poly
[1].x
=m_PosX
; poly
[1].y
= m_PosY
+ m_Height
;
1154 poly
[2].x
=m_PosX
+ m_Border
; poly
[2].y
= poly
[1].y
- m_Border
;
1155 poly
[3].x
=poly
[2].x
; poly
[3].y
= m_PosY
+ m_Border
;
1156 poly
[4].x
=m_PosX
+ m_Width
- m_Border
; poly
[4].y
= poly
[3].y
;
1157 poly
[5].x
=m_PosX
+ m_Width
; poly
[5].y
= m_PosY
;
1159 dc
.SetBrush(mybrush1
);
1160 dc
.SetPen(*wxTRANSPARENT_PEN
);
1161 dc
.DrawPolygon(6, poly
, x
, y
);
1163 // draw lower right corner reusing point 1,2,4 and 5
1170 // 1---------------0
1171 dc
.SetBrush(mybrush2
);
1172 poly
[0].x
= poly
[5].x
; poly
[0].y
= poly
[1].y
;
1173 poly
[3].x
= poly
[4].x
; poly
[3].y
= poly
[2].y
;
1174 dc
.DrawPolygon(6, poly
, x
, y
);
1176 // smooth color transition like firefox
1177 wxColour
borderMediumColour(
1178 (m_BorderColour1
.Red() + m_BorderColour2
.Red()) /2 ,
1179 (m_BorderColour1
.Green() + m_BorderColour2
.Green()) /2 ,
1180 (m_BorderColour1
.Blue() + m_BorderColour2
.Blue()) /2
1182 wxPen
mypen3(borderMediumColour
, 1, wxPENSTYLE_SOLID
);
1184 dc
.DrawLines(2, &poly
[1], x
, y
- 1); // between 1 and 2
1185 dc
.DrawLines(2, &poly
[4], x
, y
- 1); // between 4 and 5
1189 // draw container's contents:
1190 for (wxHtmlCell
*cell
= m_Cells
; cell
; cell
= cell
->GetNext())
1193 // optimize drawing: don't render off-screen content:
1194 if ((ylocal
+ cell
->GetPosY() <= view_y2
) &&
1195 (ylocal
+ cell
->GetPosY() + cell
->GetHeight() > view_y1
))
1197 // the cell is visible, draw it:
1198 UpdateRenderingStatePre(info
, cell
);
1200 xlocal
, ylocal
, view_y1
, view_y2
,
1202 UpdateRenderingStatePost(info
, cell
);
1206 // the cell is off-screen, proceed with font+color+etc.
1208 cell
->DrawInvisible(dc
, xlocal
, ylocal
, info
);
1216 void wxHtmlContainerCell::DrawInvisible(wxDC
& dc
, int x
, int y
,
1217 wxHtmlRenderingInfo
& info
)
1221 for (wxHtmlCell
*cell
= m_Cells
; cell
; cell
= cell
->GetNext())
1223 UpdateRenderingStatePre(info
, cell
);
1224 cell
->DrawInvisible(dc
, x
+ m_PosX
, y
+ m_PosY
, info
);
1225 UpdateRenderingStatePost(info
, cell
);
1231 wxColour
wxHtmlContainerCell::GetBackgroundColour()
1238 wxHtmlLinkInfo
*wxHtmlContainerCell::GetLink(int x
, int y
) const
1240 wxHtmlCell
*cell
= FindCellByPos(x
, y
);
1242 // VZ: I don't know if we should pass absolute or relative coords to
1243 // wxHtmlCell::GetLink()? As the base class version just ignores them
1244 // anyhow, it hardly matters right now but should still be clarified
1245 return cell
? cell
->GetLink(x
, y
) : NULL
;
1250 void wxHtmlContainerCell::InsertCell(wxHtmlCell
*f
)
1252 if (!m_Cells
) m_Cells
= m_LastCell
= f
;
1255 m_LastCell
->SetNext(f
);
1257 if (m_LastCell
) while (m_LastCell
->GetNext()) m_LastCell
= m_LastCell
->GetNext();
1265 void wxHtmlContainerCell::SetAlign(const wxHtmlTag
& tag
)
1268 if (tag
.GetParamAsString(wxT("ALIGN"), &alg
))
1271 if (alg
== wxT("CENTER"))
1272 SetAlignHor(wxHTML_ALIGN_CENTER
);
1273 else if (alg
== wxT("LEFT"))
1274 SetAlignHor(wxHTML_ALIGN_LEFT
);
1275 else if (alg
== wxT("JUSTIFY"))
1276 SetAlignHor(wxHTML_ALIGN_JUSTIFY
);
1277 else if (alg
== wxT("RIGHT"))
1278 SetAlignHor(wxHTML_ALIGN_RIGHT
);
1285 void wxHtmlContainerCell::SetWidthFloat(const wxHtmlTag
& tag
, double pixel_scale
)
1289 if (tag
.GetParamAsIntOrPercent(wxT("WIDTH"), &wdi
, wpercent
))
1293 SetWidthFloat(wdi
, wxHTML_UNITS_PERCENT
);
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 state
.SetBgMode(wxSOLID
);
1556 const wxColour c
= state
.GetSelectionState() == wxHTML_SEL_IN
1557 ? info
.GetStyle().GetSelectedTextBgColour(m_Colour
)
1559 dc
.SetTextBackground(c
);
1560 dc
.SetBackground(c
);
1561 dc
.SetBackgroundMode(wxSOLID
);
1563 if (m_Flags
& wxHTML_CLR_TRANSPARENT_BACKGROUND
)
1565 state
.SetBgColour(m_Colour
);
1566 state
.SetBgMode(wxTRANSPARENT
);
1567 const wxColour c
= state
.GetSelectionState() == wxHTML_SEL_IN
1568 ? info
.GetStyle().GetSelectedTextBgColour(m_Colour
)
1570 dc
.SetTextBackground(c
);
1571 dc
.SetBackgroundMode(wxTRANSPARENT
);
1578 // ---------------------------------------------------------------------------
1580 // ---------------------------------------------------------------------------
1582 IMPLEMENT_ABSTRACT_CLASS(wxHtmlFontCell
, wxHtmlCell
)
1584 void wxHtmlFontCell::Draw(wxDC
& dc
,
1585 int WXUNUSED(x
), int WXUNUSED(y
),
1586 int WXUNUSED(view_y1
), int WXUNUSED(view_y2
),
1587 wxHtmlRenderingInfo
& WXUNUSED(info
))
1592 void wxHtmlFontCell::DrawInvisible(wxDC
& dc
, int WXUNUSED(x
), int WXUNUSED(y
),
1593 wxHtmlRenderingInfo
& WXUNUSED(info
))
1605 // ---------------------------------------------------------------------------
1607 // ---------------------------------------------------------------------------
1609 IMPLEMENT_ABSTRACT_CLASS(wxHtmlWidgetCell
, wxHtmlCell
)
1611 wxHtmlWidgetCell::wxHtmlWidgetCell(wxWindow
*wnd
, int w
)
1615 m_Wnd
->GetSize(&sx
, &sy
);
1616 m_Width
= sx
, m_Height
= sy
;
1621 void wxHtmlWidgetCell::Draw(wxDC
& WXUNUSED(dc
),
1622 int WXUNUSED(x
), int WXUNUSED(y
),
1623 int WXUNUSED(view_y1
), int WXUNUSED(view_y2
),
1624 wxHtmlRenderingInfo
& WXUNUSED(info
))
1626 int absx
= 0, absy
= 0, stx
, sty
;
1627 wxHtmlCell
*c
= this;
1631 absx
+= c
->GetPosX();
1632 absy
+= c
->GetPosY();
1636 wxScrolledWindow
*scrolwin
=
1637 wxDynamicCast(m_Wnd
->GetParent(), wxScrolledWindow
);
1638 wxCHECK_RET( scrolwin
,
1639 wxT("widget cells can only be placed in wxHtmlWindow") );
1641 scrolwin
->GetViewStart(&stx
, &sty
);
1642 m_Wnd
->SetSize(absx
- wxHTML_SCROLL_STEP
* stx
,
1643 absy
- wxHTML_SCROLL_STEP
* sty
,
1649 void wxHtmlWidgetCell::DrawInvisible(wxDC
& WXUNUSED(dc
),
1650 int WXUNUSED(x
), int WXUNUSED(y
),
1651 wxHtmlRenderingInfo
& WXUNUSED(info
))
1653 int absx
= 0, absy
= 0, stx
, sty
;
1654 wxHtmlCell
*c
= this;
1658 absx
+= c
->GetPosX();
1659 absy
+= c
->GetPosY();
1663 ((wxScrolledWindow
*)(m_Wnd
->GetParent()))->GetViewStart(&stx
, &sty
);
1664 m_Wnd
->SetSize(absx
- wxHTML_SCROLL_STEP
* stx
, absy
- wxHTML_SCROLL_STEP
* sty
, m_Width
, m_Height
);
1669 void wxHtmlWidgetCell::Layout(int w
)
1671 if (m_WidthFloat
!= 0)
1673 m_Width
= (w
* m_WidthFloat
) / 100;
1674 m_Wnd
->SetSize(m_Width
, m_Height
);
1677 wxHtmlCell::Layout(w
);
1682 // ----------------------------------------------------------------------------
1683 // wxHtmlTerminalCellsInterator
1684 // ----------------------------------------------------------------------------
1686 const wxHtmlCell
* wxHtmlTerminalCellsInterator::operator++()
1693 if ( m_pos
== m_to
)
1699 if ( m_pos
->GetNext() )
1700 m_pos
= m_pos
->GetNext();
1703 // we must go up the hierarchy until we reach container where this
1704 // is not the last child, and then go down to first terminal cell:
1705 while ( m_pos
->GetNext() == NULL
)
1707 m_pos
= m_pos
->GetParent();
1711 m_pos
= m_pos
->GetNext();
1713 while ( m_pos
->GetFirstChild() != NULL
)
1714 m_pos
= m_pos
->GetFirstChild();
1715 } while ( !m_pos
->IsTerminalCell() );