X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/f30e67dbea3b6476ce25b593285fdaec128f8fd1..2f64c3bb2348ecd31a2f3973a6a10d1abff34e55:/src/html/htmlcell.cpp diff --git a/src/html/htmlcell.cpp b/src/html/htmlcell.cpp index bb16393f36..8a5cdb1f53 100644 --- a/src/html/htmlcell.cpp +++ b/src/html/htmlcell.cpp @@ -36,8 +36,8 @@ // 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; @@ -45,7 +45,7 @@ void wxHtmlSelection::Set(const wxPoint& fromPos, wxHtmlCell *fromCell, 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; @@ -58,7 +58,7 @@ void wxHtmlSelection::Set(wxHtmlCell *fromCell, wxHtmlCell *toCell) } wxColour wxDefaultHtmlRenderingStyle::GetSelectedTextColour( - const wxColour& WXUNUSED(clr)) + const wxColour& clr) { return wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT); } @@ -249,7 +249,7 @@ wxHtmlWordCell::wxHtmlWordCell(const wxString& word, wxDC& dc) : wxHtmlCell() // 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 { @@ -353,9 +353,22 @@ void wxHtmlWordCell::Draw(wxDC& dc, int x, int y, 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; @@ -372,7 +385,7 @@ void wxHtmlWordCell::Draw(wxDC& dc, int x, int 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; @@ -1003,13 +1016,19 @@ void wxHtmlColourCell::DrawInvisible(wxDC& dc, { 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)); } }