// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
-#pragma implementation "htmlcell.h"
-#endif
-
#include "wx/wxprec.h"
#include "wx/defs.h"
IMPLEMENT_ABSTRACT_CLASS(wxHtmlWordCell, wxHtmlCell)
-wxHtmlWordCell::wxHtmlWordCell(const wxString& word, wxDC& dc) : wxHtmlCell()
+wxHtmlWordCell::wxHtmlWordCell(const wxString& word, const wxDC& dc) : wxHtmlCell()
{
m_Word = word;
dc.GetTextExtent(m_Word, &m_Width, &m_Height, &m_Descent);
// Splits m_Word into up to three parts according to selection, returns
// substring before, in and after selection and the points (in relative coords)
// where s2 and s3 start:
-void wxHtmlWordCell::Split(wxDC& dc,
+void wxHtmlWordCell::Split(const wxDC& dc,
const wxPoint& selFrom, const wxPoint& selTo,
unsigned& pos1, unsigned& pos2) const
{
wxPoint pt2 = (selTo == wxDefaultPosition) ?
wxPoint(m_Width, wxDefaultCoord) : selTo - GetAbsPos();
- wxCoord charW, charH;
unsigned len = m_Word.length();
unsigned i = 0;
pos1 = 0;
pt1.x = 0;
if ( pt2.y >= m_Height )
pt2.x = m_Width;
-#ifdef __WXMAC__
+
+ // before selection:
+#ifdef __WXMAC__
// implementation using PartialExtents to support fractional widths
wxArrayInt widths ;
dc.GetPartialTextExtents(m_Word,widths) ;
-#endif
-
- // before selection:
-#ifdef __WXMAC__
while( i < len && pt1.x >= widths[i] )
i++ ;
-#else
+#else // __WXMAC__
+ wxCoord charW, charH;
while ( pt1.x > 0 && i < len )
{
dc.GetTextExtent(m_Word[i], &charW, &charH);
i++;
}
}
-#endif
+#endif // __WXMAC__/!__WXMAC__
// in selection:
unsigned j = i;
-#ifdef __WXMAC__
+#ifdef __WXMAC__
while( j < len && pt2.x >= widths[j] )
j++ ;
-#else
+#else // __WXMAC__
pos2 = pos1;
pt2.x -= pos2;
while ( pt2.x > 0 && j < len )
j++;
}
}
-#endif
+#endif // __WXMAC__/!__WXMAC__
pos1 = i;
pos2 = j;
}
-void wxHtmlWordCell::SetSelectionPrivPos(wxDC& dc, wxHtmlSelection *s) const
+void wxHtmlWordCell::SetSelectionPrivPos(const wxDC& dc, wxHtmlSelection *s) const
{
unsigned p1, p2;
dc.SetPen(*wxRED_PEN);
dc.DrawRectangle(x+m_PosX,y+m_PosY,m_Width,m_Height);
#endif
-
+
int xlocal = x + m_PosX;
int ylocal = y + m_PosY;
// draw container's contents:
for (wxHtmlCell *cell = m_Cells; cell; cell = cell->GetNext())
{
-
+
// optimize drawing: don't render off-screen content:
if ((ylocal + cell->GetPosY() <= view_y2) &&
(ylocal + cell->GetPosY() + cell->GetHeight() > view_y1))