]> git.saurik.com Git - wxWidgets.git/blobdiff - src/html/htmlcell.cpp
Accepts Focus was incorrectly returning FALSE for a panel w/o children on mac because...
[wxWidgets.git] / src / html / htmlcell.cpp
index bb16393f36b81a1a52da279a3e801ade9e590d24..8a5cdb1f532bb6155ff59cae3d1a44d8aa6986ee 100644 (file)
@@ -36,8 +36,8 @@
 // Helper classes
 //-----------------------------------------------------------------------------
 
 // 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_fromCell = fromCell;
     m_toCell = toCell;
@@ -45,7 +45,7 @@ void wxHtmlSelection::Set(const wxPoint& fromPos, wxHtmlCell *fromCell,
     m_toPos = toPos;
 }
 
     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;
 {
     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(
 }
 
 wxColour wxDefaultHtmlRenderingStyle::GetSelectedTextColour(
-                                        const wxColour& WXUNUSED(clr))
+                                        const wxColour& clr)
 {
     return wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT);
 }
 {
     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:
 // 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
 {
                            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;
         wxString txt;
         int w, h;
         int ofs = 0;
-        
+       
         wxPoint priv = (this == s->GetFromCell()) ? 
                            s->GetFromPrivPos() : s->GetToPrivPos();
         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;
 
         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);
 
         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;
         {
             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)
     {
         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);
     }
     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));
     }
 }
         dc.SetBackground(wxBrush(m_Colour, wxSOLID));
     }
 }