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
);
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
)
241 if (link
.GetHref() != wxEmptyString
)
242 m_Link
= new wxHtmlLinkInfo(link
);
246 void wxHtmlCell::Layout(int WXUNUSED(w
))
253 const wxHtmlCell
* wxHtmlCell::Find(int WXUNUSED(condition
), const void* WXUNUSED(param
)) const
259 wxHtmlCell
*wxHtmlCell::FindCellByPos(wxCoord x
, wxCoord y
,
260 unsigned flags
) const
262 if ( x
>= 0 && x
< m_Width
&& y
>= 0 && y
< m_Height
)
264 return wxConstCast(this, wxHtmlCell
);
268 if ((flags
& wxHTML_FIND_NEAREST_AFTER
) &&
269 (y
< 0 || (y
< 0+m_Height
&& x
< 0+m_Width
)))
270 return wxConstCast(this, wxHtmlCell
);
271 else if ((flags
& wxHTML_FIND_NEAREST_BEFORE
) &&
272 (y
>= 0+m_Height
|| (y
>= 0 && x
>= 0)))
273 return wxConstCast(this, wxHtmlCell
);
280 wxPoint
wxHtmlCell::GetAbsPos(wxHtmlCell
*rootCell
) const
282 wxPoint
p(m_PosX
, m_PosY
);
283 for (wxHtmlCell
*parent
= m_Parent
; parent
&& parent
!= rootCell
;
284 parent
= parent
->m_Parent
)
286 p
.x
+= parent
->m_PosX
;
287 p
.y
+= parent
->m_PosY
;
292 wxHtmlCell
*wxHtmlCell::GetRootCell() const
294 wxHtmlCell
*c
= wxConstCast(this, wxHtmlCell
);
295 while ( c
->m_Parent
)
300 unsigned wxHtmlCell::GetDepth() const
303 for (wxHtmlCell
*p
= m_Parent
; p
; p
= p
->m_Parent
)
308 bool wxHtmlCell::IsBefore(wxHtmlCell
*cell
) const
310 const wxHtmlCell
*c1
= this;
311 const wxHtmlCell
*c2
= cell
;
312 unsigned d1
= GetDepth();
313 unsigned d2
= cell
->GetDepth();
316 for (; d1
!= d2
; d1
-- )
319 for (; d1
!= d2
; d2
-- )
327 if ( c1
->m_Parent
== c2
->m_Parent
)
344 wxFAIL_MSG(wxT("Cells are in different trees"));
349 //-----------------------------------------------------------------------------
351 //-----------------------------------------------------------------------------
353 IMPLEMENT_ABSTRACT_CLASS(wxHtmlWordCell
, wxHtmlCell
)
355 wxHtmlWordCell::wxHtmlWordCell(const wxString
& word
, const wxDC
& dc
) : wxHtmlCell()
359 dc
.GetTextExtent(m_Word
, &w
, &h
, &d
);
363 SetCanLiveOnPagebreak(false);
364 m_allowLinebreak
= true;
367 void wxHtmlWordCell::SetPreviousWord(wxHtmlWordCell
*cell
)
369 if ( cell
&& m_Parent
== cell
->m_Parent
&&
370 !wxIsspace(cell
->m_Word
.Last()) && !wxIsspace(m_Word
[0u]) )
372 m_allowLinebreak
= false;
376 // Splits m_Word into up to three parts according to selection, returns
377 // substring before, in and after selection and the points (in relative coords)
378 // where s2 and s3 start:
379 void wxHtmlWordCell::Split(const wxDC
& dc
,
380 const wxPoint
& selFrom
, const wxPoint
& selTo
,
381 unsigned& pos1
, unsigned& pos2
) const
383 wxPoint pt1
= (selFrom
== wxDefaultPosition
) ?
384 wxDefaultPosition
: selFrom
- GetAbsPos();
385 wxPoint pt2
= (selTo
== wxDefaultPosition
) ?
386 wxPoint(m_Width
, wxDefaultCoord
) : selTo
- GetAbsPos();
388 // if the selection is entirely within this cell, make sure pt1 < pt2 in
389 // order to make the rest of this function simpler:
390 if ( selFrom
!= wxDefaultPosition
&& selTo
!= wxDefaultPosition
&&
391 selFrom
.x
> selTo
.x
)
398 unsigned len
= m_Word
.length();
402 // adjust for cases when the start/end position is completely
406 if ( pt2
.y
>= m_Height
)
410 // (include character under caret only if in first half of width)
412 // implementation using PartialExtents to support fractional widths
414 dc
.GetPartialTextExtents(m_Word
,widths
) ;
415 while( i
< len
&& pt1
.x
>= widths
[i
] )
419 int charW
= (i
> 0) ? widths
[i
] - widths
[i
-1] : widths
[i
];
420 if ( widths
[i
] - pt1
.x
< charW
/2 )
424 wxCoord charW
, charH
;
425 while ( pt1
.x
> 0 && i
< len
)
427 dc
.GetTextExtent(m_Word
[i
], &charW
, &charH
);
429 if ( pt1
.x
>= -charW
/2 )
435 #endif // __WXMAC__/!__WXMAC__
438 // (include character under caret only if in first half of width)
441 while( j
< len
&& pt2
.x
>= widths
[j
] )
445 int charW
= (j
> 0) ? widths
[j
] - widths
[j
-1] : widths
[j
];
446 if ( widths
[j
] - pt2
.x
< charW
/2 )
452 while ( pt2
.x
> 0 && j
< len
)
454 dc
.GetTextExtent(m_Word
[j
], &charW
, &charH
);
456 if ( pt2
.x
>= -charW
/2 )
462 #endif // __WXMAC__/!__WXMAC__
467 wxASSERT( pos2
>= pos1
);
470 void wxHtmlWordCell::SetSelectionPrivPos(const wxDC
& dc
, wxHtmlSelection
*s
) const
475 this == s
->GetFromCell() ? s
->GetFromPos() : wxDefaultPosition
,
476 this == s
->GetToCell() ? s
->GetToPos() : wxDefaultPosition
,
479 if ( this == s
->GetFromCell() )
480 s
->SetFromCharacterPos (p1
); // selection starts here
481 if ( this == s
->GetToCell() )
482 s
->SetToCharacterPos (p2
); // selection ends here
486 static void SwitchSelState(wxDC
& dc
, wxHtmlRenderingInfo
& info
,
489 wxColour fg
= info
.GetState().GetFgColour();
490 wxColour bg
= info
.GetState().GetBgColour();
494 dc
.SetBackgroundMode(wxBRUSHSTYLE_SOLID
);
495 dc
.SetTextForeground(info
.GetStyle().GetSelectedTextColour(fg
));
496 dc
.SetTextBackground(info
.GetStyle().GetSelectedTextBgColour(bg
));
497 dc
.SetBackground(wxBrush(info
.GetStyle().GetSelectedTextBgColour(bg
),
498 wxBRUSHSTYLE_SOLID
));
502 dc
.SetBackgroundMode(wxBRUSHSTYLE_TRANSPARENT
);
503 dc
.SetTextForeground(fg
);
504 dc
.SetTextBackground(bg
);
505 dc
.SetBackground(wxBrush(bg
, wxBRUSHSTYLE_SOLID
));
510 void wxHtmlWordCell::Draw(wxDC
& dc
, int x
, int y
,
511 int WXUNUSED(view_y1
), int WXUNUSED(view_y2
),
512 wxHtmlRenderingInfo
& info
)
514 #if 0 // useful for debugging
515 dc
.SetPen(*wxBLACK_PEN
);
516 dc
.DrawRectangle(x
+m_PosX
,y
+m_PosY
,m_Width
/* VZ: +1? */ ,m_Height
);
519 bool drawSelectionAfterCell
= false;
521 if ( info
.GetState().GetSelectionState() == wxHTML_SEL_CHANGING
)
523 // Selection changing, we must draw the word piecewise:
524 wxHtmlSelection
*s
= info
.GetSelection();
529 // NB: this is quite a hack: in order to compute selection boundaries
530 // (in word's characters) we must know current font, which is only
531 // possible inside rendering code. Therefore we update the
532 // information here and store it in wxHtmlSelection so that
533 // ConvertToText can use it later:
534 if ( !s
->AreFromToCharacterPosSet () )
536 SetSelectionPrivPos(dc
, s
);
539 int part1
= s
->GetFromCell()==this ? s
->GetFromCharacterPos() : 0;
540 int part2
= s
->GetToCell()==this ? s
->GetToCharacterPos() : m_Word
.Length();
544 txt
= m_Word
.Mid(0, part1
);
545 dc
.DrawText(txt
, x
+ m_PosX
, y
+ m_PosY
);
546 dc
.GetTextExtent(txt
, &w
, &h
);
550 SwitchSelState(dc
, info
, true);
552 txt
= m_Word
.Mid(part1
, part2
-part1
);
553 dc
.DrawText(txt
, ofs
+ x
+ m_PosX
, y
+ m_PosY
);
555 if ( (size_t)part2
< m_Word
.length() )
557 dc
.GetTextExtent(txt
, &w
, &h
);
559 SwitchSelState(dc
, info
, false);
560 txt
= m_Word
.Mid(part2
);
561 dc
.DrawText(txt
, ofs
+ x
+ m_PosX
, y
+ m_PosY
);
564 drawSelectionAfterCell
= true;
568 wxHtmlSelectionState selstate
= info
.GetState().GetSelectionState();
569 // Not changing selection state, draw the word in single mode:
570 if ( selstate
!= wxHTML_SEL_OUT
&&
571 dc
.GetBackgroundMode() != wxBRUSHSTYLE_SOLID
)
573 SwitchSelState(dc
, info
, true);
575 else if ( selstate
== wxHTML_SEL_OUT
&&
576 dc
.GetBackgroundMode() == wxBRUSHSTYLE_SOLID
)
578 SwitchSelState(dc
, info
, false);
580 dc
.DrawText(m_Word
, x
+ m_PosX
, y
+ m_PosY
);
581 drawSelectionAfterCell
= (selstate
!= wxHTML_SEL_OUT
);
584 // NB: If the text is justified then there is usually some free space
585 // between adjacent cells and drawing the selection only onto cells
586 // would result in ugly unselected spaces. The code below detects
587 // this special case and renders the selection *outside* the sell,
589 if ( m_Parent
->GetAlignHor() == wxHTML_ALIGN_JUSTIFY
&&
590 drawSelectionAfterCell
)
592 wxHtmlCell
*nextCell
= m_Next
;
593 while ( nextCell
&& nextCell
->IsFormattingCell() )
594 nextCell
= nextCell
->GetNext();
597 int nextX
= nextCell
->GetPosX();
598 if ( m_PosX
+ m_Width
< nextX
)
600 dc
.SetBrush(dc
.GetBackground());
601 dc
.SetPen(*wxTRANSPARENT_PEN
);
602 dc
.DrawRectangle(x
+ m_PosX
+ m_Width
, y
+ m_PosY
,
603 nextX
- m_PosX
- m_Width
, m_Height
);
609 wxCursor
wxHtmlWordCell::GetMouseCursor(wxHtmlWindowInterface
*window
) const
613 return window
->GetHTMLCursor(wxHtmlWindowInterface::HTMLCursor_Text
);
617 return wxHtmlCell::GetMouseCursor(window
);
621 wxString
wxHtmlWordCell::ConvertToText(wxHtmlSelection
*s
) const
623 if ( s
&& (this == s
->GetFromCell() || this == s
->GetToCell()) )
625 // VZ: we may be called before we had a chance to re-render ourselves
626 // and in this case GetFrom/ToPrivPos() is not set yet -- assume
627 // that this only happens in case of a double/triple click (which
628 // seems to be the case now) and so it makes sense to select the
629 // entire contents of the cell in this case
631 // TODO: but this really needs to be fixed in some better way later...
632 if ( s
->AreFromToCharacterPosSet() )
634 const int part1
= s
->GetFromCell()==this ? s
->GetFromCharacterPos() : 0;
635 const int part2
= s
->GetToCell()==this ? s
->GetToCharacterPos() : m_Word
.Length();
636 if ( part1
== part2
)
637 return wxEmptyString
;
638 return GetPartAsText(part1
, part2
);
640 //else: return the whole word below
643 return GetAllAsText();
646 wxString
wxHtmlWordWithTabsCell::GetAllAsText() const
651 wxString
wxHtmlWordWithTabsCell::GetPartAsText(int begin
, int end
) const
653 // NB: The 'begin' and 'end' positions are in the _displayed_ text
654 // (stored in m_Word) and not in the text with tabs that should
655 // be copied to clipboard (m_wordOrig).
657 // NB: Because selection is performed on displayed text, it's possible
658 // to select e.g. "half of TAB character" -- IOW, 'begin' and 'end'
659 // may be in the middle of TAB character expansion into ' 's. In this
660 // case, we copy the TAB character to clipboard once.
662 wxASSERT( begin
< end
);
664 const unsigned SPACES_PER_TAB
= 8;
669 wxString::const_iterator i
= m_wordOrig
.begin();
671 // find the beginning of text to copy:
672 for ( ; pos
< begin
; ++i
)
676 pos
+= 8 - (m_linepos
+ pos
) % SPACES_PER_TAB
;
688 // copy the content until we reach 'end':
689 for ( ; pos
< end
; ++i
)
695 pos
+= 8 - (m_linepos
+ pos
) % SPACES_PER_TAB
;
705 //-----------------------------------------------------------------------------
706 // wxHtmlContainerCell
707 //-----------------------------------------------------------------------------
709 IMPLEMENT_ABSTRACT_CLASS(wxHtmlContainerCell
, wxHtmlCell
)
711 wxHtmlContainerCell::wxHtmlContainerCell(wxHtmlContainerCell
*parent
) : wxHtmlCell()
713 m_Cells
= m_LastCell
= NULL
;
716 if (m_Parent
) m_Parent
->InsertCell(this);
717 m_AlignHor
= wxHTML_ALIGN_LEFT
;
718 m_AlignVer
= wxHTML_ALIGN_BOTTOM
;
719 m_IndentLeft
= m_IndentRight
= m_IndentTop
= m_IndentBottom
= 0;
720 m_WidthFloat
= 100; m_WidthFloatUnits
= wxHTML_UNITS_PERCENT
;
721 m_UseBkColour
= false;
724 m_MinHeightAlign
= wxHTML_ALIGN_TOP
;
728 wxHtmlContainerCell::~wxHtmlContainerCell()
730 wxHtmlCell
*cell
= m_Cells
;
733 wxHtmlCell
*cellNext
= cell
->GetNext();
741 void wxHtmlContainerCell::SetIndent(int i
, int what
, int units
)
743 int val
= (units
== wxHTML_UNITS_PIXELS
) ? i
: -i
;
744 if (what
& wxHTML_INDENT_LEFT
) m_IndentLeft
= val
;
745 if (what
& wxHTML_INDENT_RIGHT
) m_IndentRight
= val
;
746 if (what
& wxHTML_INDENT_TOP
) m_IndentTop
= val
;
747 if (what
& wxHTML_INDENT_BOTTOM
) m_IndentBottom
= val
;
753 int wxHtmlContainerCell::GetIndent(int ind
) const
755 if (ind
& wxHTML_INDENT_LEFT
) return m_IndentLeft
;
756 else if (ind
& wxHTML_INDENT_RIGHT
) return m_IndentRight
;
757 else if (ind
& wxHTML_INDENT_TOP
) return m_IndentTop
;
758 else if (ind
& wxHTML_INDENT_BOTTOM
) return m_IndentBottom
;
759 else return -1; /* BUG! Should not be called... */
765 int wxHtmlContainerCell::GetIndentUnits(int ind
) const
768 if (ind
& wxHTML_INDENT_LEFT
) p
= m_IndentLeft
< 0;
769 else if (ind
& wxHTML_INDENT_RIGHT
) p
= m_IndentRight
< 0;
770 else if (ind
& wxHTML_INDENT_TOP
) p
= m_IndentTop
< 0;
771 else if (ind
& wxHTML_INDENT_BOTTOM
) p
= m_IndentBottom
< 0;
772 if (p
) return wxHTML_UNITS_PERCENT
;
773 else return wxHTML_UNITS_PIXELS
;
777 bool wxHtmlContainerCell::AdjustPagebreak(int *pagebreak
,
778 wxArrayInt
& known_pagebreaks
) const
780 if (!m_CanLiveOnPagebreak
)
781 return wxHtmlCell::AdjustPagebreak(pagebreak
, known_pagebreaks
);
783 wxHtmlCell
*c
= GetFirstChild();
785 int pbrk
= *pagebreak
- m_PosY
;
789 if (c
->AdjustPagebreak(&pbrk
, known_pagebreaks
))
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
;
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()
1223 return wxNullColour
;
1228 wxHtmlLinkInfo
*wxHtmlContainerCell::GetLink(int x
, int y
) const
1230 wxHtmlCell
*cell
= FindCellByPos(x
, y
);
1232 // VZ: I don't know if we should pass absolute or relative coords to
1233 // wxHtmlCell::GetLink()? As the base class version just ignores them
1234 // anyhow, it hardly matters right now but should still be clarified
1235 return cell
? cell
->GetLink(x
, y
) : NULL
;
1240 void wxHtmlContainerCell::InsertCell(wxHtmlCell
*f
)
1242 if (!m_Cells
) m_Cells
= m_LastCell
= f
;
1245 m_LastCell
->SetNext(f
);
1247 if (m_LastCell
) while (m_LastCell
->GetNext()) m_LastCell
= m_LastCell
->GetNext();
1255 void wxHtmlContainerCell::SetAlign(const wxHtmlTag
& tag
)
1257 if (tag
.HasParam(wxT("ALIGN")))
1259 wxString alg
= tag
.GetParam(wxT("ALIGN"));
1261 if (alg
== wxT("CENTER"))
1262 SetAlignHor(wxHTML_ALIGN_CENTER
);
1263 else if (alg
== wxT("LEFT"))
1264 SetAlignHor(wxHTML_ALIGN_LEFT
);
1265 else if (alg
== wxT("JUSTIFY"))
1266 SetAlignHor(wxHTML_ALIGN_JUSTIFY
);
1267 else if (alg
== wxT("RIGHT"))
1268 SetAlignHor(wxHTML_ALIGN_RIGHT
);
1275 void wxHtmlContainerCell::SetWidthFloat(const wxHtmlTag
& tag
, double pixel_scale
)
1277 if (tag
.HasParam(wxT("WIDTH")))
1280 wxString wd
= tag
.GetParam(wxT("WIDTH"));
1282 if (wd
[wd
.length()-1] == wxT('%'))
1284 wxSscanf(wd
.c_str(), wxT("%i%%"), &wdi
);
1285 SetWidthFloat(wdi
, wxHTML_UNITS_PERCENT
);
1289 wxSscanf(wd
.c_str(), wxT("%i"), &wdi
);
1290 SetWidthFloat((int)(pixel_scale
* (double)wdi
), wxHTML_UNITS_PIXELS
);
1298 const wxHtmlCell
* wxHtmlContainerCell::Find(int condition
, const void* param
) const
1302 for (wxHtmlCell
*cell
= m_Cells
; cell
; cell
= cell
->GetNext())
1304 const wxHtmlCell
*r
= cell
->Find(condition
, param
);
1312 wxHtmlCell
*wxHtmlContainerCell::FindCellByPos(wxCoord x
, wxCoord y
,
1313 unsigned flags
) const
1315 if ( flags
& wxHTML_FIND_EXACT
)
1317 for ( const wxHtmlCell
*cell
= m_Cells
; cell
; cell
= cell
->GetNext() )
1319 int cx
= cell
->GetPosX(),
1320 cy
= cell
->GetPosY();
1322 if ( (cx
<= x
) && (cx
+ cell
->GetWidth() > x
) &&
1323 (cy
<= y
) && (cy
+ cell
->GetHeight() > y
) )
1325 return cell
->FindCellByPos(x
- cx
, y
- cy
, flags
);
1329 else if ( flags
& wxHTML_FIND_NEAREST_AFTER
)
1332 for ( const wxHtmlCell
*cell
= m_Cells
; cell
; cell
= cell
->GetNext() )
1334 if ( cell
->IsFormattingCell() )
1336 int cellY
= cell
->GetPosY();
1337 if (!( y
< cellY
|| (y
< cellY
+ cell
->GetHeight() &&
1338 x
< cell
->GetPosX() + cell
->GetWidth()) ))
1341 c
= cell
->FindCellByPos(x
- cell
->GetPosX(), y
- cellY
, flags
);
1345 else if ( flags
& wxHTML_FIND_NEAREST_BEFORE
)
1347 wxHtmlCell
*c2
, *c
= NULL
;
1348 for ( const wxHtmlCell
*cell
= m_Cells
; cell
; cell
= cell
->GetNext() )
1350 if ( cell
->IsFormattingCell() )
1352 int cellY
= cell
->GetPosY();
1353 if (!( cellY
+ cell
->GetHeight() <= y
||
1354 (y
>= cellY
&& x
>= cell
->GetPosX()) ))
1356 c2
= cell
->FindCellByPos(x
- cell
->GetPosX(), y
- cellY
, flags
);
1367 bool wxHtmlContainerCell::ProcessMouseClick(wxHtmlWindowInterface
*window
,
1369 const wxMouseEvent
& event
)
1371 #if WXWIN_COMPATIBILITY_2_6
1372 wxHtmlCellOnMouseClickCompatHelper
compat(window
, pos
, event
);
1373 return compat
.CallOnMouseClick(this);
1376 void wxHtmlContainerCell::OnMouseClick(wxWindow
*,
1377 int, int, const wxMouseEvent
& event
)
1379 wxCHECK_RET( gs_helperOnMouseClick
, wxT("unexpected call to OnMouseClick") );
1380 wxHtmlWindowInterface
*window
= gs_helperOnMouseClick
->window
;
1381 const wxPoint
& pos
= gs_helperOnMouseClick
->pos
;
1382 #endif // WXWIN_COMPATIBILITY_2_6
1384 bool retval
= false;
1385 wxHtmlCell
*cell
= FindCellByPos(pos
.x
, pos
.y
);
1387 retval
= cell
->ProcessMouseClick(window
, pos
, event
);
1389 #if WXWIN_COMPATIBILITY_2_6
1390 gs_helperOnMouseClick
->retval
= retval
;
1393 #endif // WXWIN_COMPATIBILITY_2_6
1397 wxHtmlCell
*wxHtmlContainerCell::GetFirstTerminal() const
1402 for (wxHtmlCell
*c
= m_Cells
; c
; c
= c
->GetNext())
1404 c2
= c
->GetFirstTerminal();
1412 wxHtmlCell
*wxHtmlContainerCell::GetLastTerminal() const
1416 // most common case first:
1417 wxHtmlCell
*c
= m_LastCell
->GetLastTerminal();
1422 wxHtmlCell
*c2
= NULL
;
1423 for (c
= m_Cells
; c
; c
= c
->GetNext())
1425 ctmp
= c
->GetLastTerminal();
1436 static bool IsEmptyContainer(wxHtmlContainerCell
*cell
)
1438 for ( wxHtmlCell
*c
= cell
->GetFirstChild(); c
; c
= c
->GetNext() )
1440 if ( !c
->IsTerminalCell() || !c
->IsFormattingCell() )
1446 void wxHtmlContainerCell::RemoveExtraSpacing(bool top
, bool bottom
)
1449 SetIndent(0, wxHTML_INDENT_TOP
);
1451 SetIndent(0, wxHTML_INDENT_BOTTOM
);
1456 wxHtmlContainerCell
*cont
;
1459 for ( c
= m_Cells
; c
; c
= c
->GetNext() )
1461 if ( c
->IsTerminalCell() )
1463 if ( !c
->IsFormattingCell() )
1468 cont
= (wxHtmlContainerCell
*)c
;
1469 if ( IsEmptyContainer(cont
) )
1471 cont
->SetIndent(0, wxHTML_INDENT_VERTICAL
);
1475 cont
->RemoveExtraSpacing(true, false);
1485 for ( c
= m_Cells
; c
; c
= c
->GetNext() )
1488 for ( int i
= arr
.GetCount() - 1; i
>= 0; i
--)
1490 c
= (wxHtmlCell
*)arr
[i
];
1491 if ( c
->IsTerminalCell() )
1493 if ( !c
->IsFormattingCell() )
1498 cont
= (wxHtmlContainerCell
*)c
;
1499 if ( IsEmptyContainer(cont
) )
1501 cont
->SetIndent(0, wxHTML_INDENT_VERTICAL
);
1505 cont
->RemoveExtraSpacing(false, true);
1517 // --------------------------------------------------------------------------
1519 // --------------------------------------------------------------------------
1521 IMPLEMENT_ABSTRACT_CLASS(wxHtmlColourCell
, wxHtmlCell
)
1523 void wxHtmlColourCell::Draw(wxDC
& dc
,
1525 int WXUNUSED(view_y1
), int WXUNUSED(view_y2
),
1526 wxHtmlRenderingInfo
& info
)
1528 DrawInvisible(dc
, x
, y
, info
);
1531 void wxHtmlColourCell::DrawInvisible(wxDC
& dc
,
1532 int WXUNUSED(x
), int WXUNUSED(y
),
1533 wxHtmlRenderingInfo
& info
)
1535 wxHtmlRenderingState
& state
= info
.GetState();
1536 if (m_Flags
& wxHTML_CLR_FOREGROUND
)
1538 state
.SetFgColour(m_Colour
);
1539 if (state
.GetSelectionState() != wxHTML_SEL_IN
)
1540 dc
.SetTextForeground(m_Colour
);
1542 dc
.SetTextForeground(
1543 info
.GetStyle().GetSelectedTextColour(m_Colour
));
1545 if (m_Flags
& wxHTML_CLR_BACKGROUND
)
1547 state
.SetBgColour(m_Colour
);
1548 if (state
.GetSelectionState() != wxHTML_SEL_IN
)
1550 dc
.SetTextBackground(m_Colour
);
1551 dc
.SetBackground(wxBrush(m_Colour
, wxBRUSHSTYLE_SOLID
));
1555 wxColour c
= info
.GetStyle().GetSelectedTextBgColour(m_Colour
);
1556 dc
.SetTextBackground(c
);
1557 dc
.SetBackground(wxBrush(c
, wxBRUSHSTYLE_SOLID
));
1565 // ---------------------------------------------------------------------------
1567 // ---------------------------------------------------------------------------
1569 IMPLEMENT_ABSTRACT_CLASS(wxHtmlFontCell
, wxHtmlCell
)
1571 void wxHtmlFontCell::Draw(wxDC
& dc
,
1572 int WXUNUSED(x
), int WXUNUSED(y
),
1573 int WXUNUSED(view_y1
), int WXUNUSED(view_y2
),
1574 wxHtmlRenderingInfo
& WXUNUSED(info
))
1579 void wxHtmlFontCell::DrawInvisible(wxDC
& dc
, int WXUNUSED(x
), int WXUNUSED(y
),
1580 wxHtmlRenderingInfo
& WXUNUSED(info
))
1592 // ---------------------------------------------------------------------------
1594 // ---------------------------------------------------------------------------
1596 IMPLEMENT_ABSTRACT_CLASS(wxHtmlWidgetCell
, wxHtmlCell
)
1598 wxHtmlWidgetCell::wxHtmlWidgetCell(wxWindow
*wnd
, int w
)
1602 m_Wnd
->GetSize(&sx
, &sy
);
1603 m_Width
= sx
, m_Height
= sy
;
1608 void wxHtmlWidgetCell::Draw(wxDC
& WXUNUSED(dc
),
1609 int WXUNUSED(x
), int WXUNUSED(y
),
1610 int WXUNUSED(view_y1
), int WXUNUSED(view_y2
),
1611 wxHtmlRenderingInfo
& WXUNUSED(info
))
1613 int absx
= 0, absy
= 0, stx
, sty
;
1614 wxHtmlCell
*c
= this;
1618 absx
+= c
->GetPosX();
1619 absy
+= c
->GetPosY();
1623 wxScrolledWindow
*scrolwin
=
1624 wxDynamicCast(m_Wnd
->GetParent(), wxScrolledWindow
);
1625 wxCHECK_RET( scrolwin
,
1626 wxT("widget cells can only be placed in wxHtmlWindow") );
1628 scrolwin
->GetViewStart(&stx
, &sty
);
1629 m_Wnd
->SetSize(absx
- wxHTML_SCROLL_STEP
* stx
,
1630 absy
- wxHTML_SCROLL_STEP
* sty
,
1636 void wxHtmlWidgetCell::DrawInvisible(wxDC
& WXUNUSED(dc
),
1637 int WXUNUSED(x
), int WXUNUSED(y
),
1638 wxHtmlRenderingInfo
& WXUNUSED(info
))
1640 int absx
= 0, absy
= 0, stx
, sty
;
1641 wxHtmlCell
*c
= this;
1645 absx
+= c
->GetPosX();
1646 absy
+= c
->GetPosY();
1650 ((wxScrolledWindow
*)(m_Wnd
->GetParent()))->GetViewStart(&stx
, &sty
);
1651 m_Wnd
->SetSize(absx
- wxHTML_SCROLL_STEP
* stx
, absy
- wxHTML_SCROLL_STEP
* sty
, m_Width
, m_Height
);
1656 void wxHtmlWidgetCell::Layout(int w
)
1658 if (m_WidthFloat
!= 0)
1660 m_Width
= (w
* m_WidthFloat
) / 100;
1661 m_Wnd
->SetSize(m_Width
, m_Height
);
1664 wxHtmlCell::Layout(w
);
1669 // ----------------------------------------------------------------------------
1670 // wxHtmlTerminalCellsInterator
1671 // ----------------------------------------------------------------------------
1673 const wxHtmlCell
* wxHtmlTerminalCellsInterator::operator++()
1680 if ( m_pos
== m_to
)
1686 if ( m_pos
->GetNext() )
1687 m_pos
= m_pos
->GetNext();
1690 // we must go up the hierarchy until we reach container where this
1691 // is not the last child, and then go down to first terminal cell:
1692 while ( m_pos
->GetNext() == NULL
)
1694 m_pos
= m_pos
->GetParent();
1698 m_pos
= m_pos
->GetNext();
1700 while ( m_pos
->GetFirstChild() != NULL
)
1701 m_pos
= m_pos
->GetFirstChild();
1702 } while ( !m_pos
->IsTerminalCell() );