// Helper classes
//-----------------------------------------------------------------------------
-void wxHtmlSelection::Set(const wxPoint& fromPos, wxHtmlCell *fromCell,
- const wxPoint& toPos, wxHtmlCell *toCell)
+void wxHtmlSelection::Set(const wxPoint& fromPos, const wxHtmlCell *fromCell,
+ const wxPoint& toPos, const wxHtmlCell *toCell)
{
m_fromCell = fromCell;
m_toCell = toCell;
m_toPos = toPos;
}
-void wxHtmlSelection::Set(wxHtmlCell *fromCell, wxHtmlCell *toCell)
+void wxHtmlSelection::Set(const wxHtmlCell *fromCell, const wxHtmlCell *toCell)
{
wxPoint p1 = fromCell ? fromCell->GetAbsPos() : wxDefaultPosition;
wxPoint p2 = toCell ? toCell->GetAbsPos() : wxDefaultPosition;
}
wxColour wxDefaultHtmlRenderingStyle::GetSelectedTextColour(
- const wxColour& WXUNUSED(clr))
+ const wxColour& clr)
{
return wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT);
}
// 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(wxDC& dc,
const wxPoint& selFrom, const wxPoint& selTo,
unsigned& pos1, unsigned& pos2) const
{
wxString txt;
int w, h;
int ofs = 0;
-
+
wxPoint priv = (this == s->GetFromCell()) ?
s->GetFromPrivPos() : s->GetToPrivPos();
+
+ // NB: this is quite a hack: in order to compute selection boundaries
+ // (in word's characters) we must know current font, which is only
+ // possible inside rendering code. Therefore we update the
+ // information here and store it in wxHtmlSelection so that
+ // ConvertToText can use it later:
+ if ( priv == wxDefaultPosition )
+ {
+ SetSelectionPrivPos(dc, s);
+ priv = (this == s->GetFromCell()) ?
+ s->GetFromPrivPos() : s->GetToPrivPos();
+ }
+
int part1 = priv.x;
int part2 = priv.y;
txt = m_Word.Mid(part1, part2-part1);
dc.DrawText(txt, ofs + x + m_PosX, y + m_PosY);
- if ( part2 < m_Word.length() )
+ if ( (size_t)part2 < m_Word.length() )
{
dc.GetTextExtent(txt, &w, &h);
ofs += w;
{
state.SetFgColour(m_Colour);
if (state.GetSelectionState() != wxHTML_SEL_IN)
- dc.SetTextForeground(m_Colour);
+ dc.SetTextForeground(m_Colour);
+ else
+ dc.SetTextForeground(
+ info.GetStyle().GetSelectedTextColour(m_Colour));
}
if (m_Flags & wxHTML_CLR_BACKGROUND)
{
state.SetBgColour(m_Colour);
if (state.GetSelectionState() != wxHTML_SEL_IN)
dc.SetTextBackground(m_Colour);
+ else
+ dc.SetTextBackground(
+ info.GetStyle().GetSelectedTextBgColour(m_Colour));
dc.SetBackground(wxBrush(m_Colour, wxSOLID));
}
}