pos1 = i;
pos2 = j;
+
+ wxASSERT( pos2 >= pos1 );
}
void wxHtmlWordCell::SetSelectionPrivPos(const wxDC& dc, wxHtmlSelection *s) const
if ( toSelection )
{
- dc.SetBackgroundMode(wxSOLID);
+ dc.SetBackgroundMode(wxBRUSHSTYLE_SOLID);
dc.SetTextForeground(info.GetStyle().GetSelectedTextColour(fg));
dc.SetTextBackground(info.GetStyle().GetSelectedTextBgColour(bg));
dc.SetBackground(wxBrush(info.GetStyle().GetSelectedTextBgColour(bg),
- wxSOLID));
+ wxBRUSHSTYLE_SOLID));
}
else
{
- dc.SetBackgroundMode(wxTRANSPARENT);
+ dc.SetBackgroundMode(wxBRUSHSTYLE_TRANSPARENT);
dc.SetTextForeground(fg);
dc.SetTextBackground(bg);
- dc.SetBackground(wxBrush(bg, wxSOLID));
+ dc.SetBackground(wxBrush(bg, wxBRUSHSTYLE_SOLID));
}
}
wxHtmlSelectionState selstate = info.GetState().GetSelectionState();
// Not changing selection state, draw the word in single mode:
if ( selstate != wxHTML_SEL_OUT &&
- dc.GetBackgroundMode() != wxSOLID )
+ dc.GetBackgroundMode() != wxBRUSHSTYLE_SOLID )
{
SwitchSelState(dc, info, true);
}
else if ( selstate == wxHTML_SEL_OUT &&
- dc.GetBackgroundMode() == wxSOLID )
+ dc.GetBackgroundMode() == wxBRUSHSTYLE_SOLID )
{
SwitchSelState(dc, info, false);
}
}
}
+wxCursor wxHtmlWordCell::GetMouseCursor(wxHtmlWindowInterface *window) const
+{
+ if ( !GetLink() )
+ {
+ return window->GetHTMLCursor(wxHtmlWindowInterface::HTMLCursor_Text);
+ }
+ else
+ {
+ return wxHtmlCell::GetMouseCursor(window);
+ }
+}
wxString wxHtmlWordCell::ConvertToText(wxHtmlSelection *s) const
{
// TODO: but this really needs to be fixed in some better way later...
if ( priv != wxDefaultPosition )
{
- int part1 = priv.x;
- int part2 = priv.y;
- return m_Word.Mid(part1, part2-part1);
+ const int part1 = priv.x;
+ const int part2 = priv.y;
+ if ( part1 == part2 )
+ return wxEmptyString;
+ return GetPartAsText(part1, part2);
}
//else: return the whole word below
}
- return m_Word;
+ return GetAllAsText();
}
-wxCursor wxHtmlWordCell::GetMouseCursor(wxHtmlWindowInterface *window) const
+wxString wxHtmlWordWithTabsCell::GetAllAsText() const
{
- if ( !GetLink() )
+ return m_wordOrig;
+}
+
+wxString wxHtmlWordWithTabsCell::GetPartAsText(int begin, int end) const
+{
+ // NB: The 'begin' and 'end' positions are in the _displayed_ text
+ // (stored in m_Word) and not in the text with tabs that should
+ // be copied to clipboard (m_wordOrig).
+ //
+ // NB: Because selection is performed on displayed text, it's possible
+ // to select e.g. "half of TAB character" -- IOW, 'begin' and 'end'
+ // may be in the middle of TAB character expansion into ' 's. In this
+ // case, we copy the TAB character to clipboard once.
+
+ wxASSERT( begin < end );
+
+ const unsigned SPACES_PER_TAB = 8;
+
+ wxString sel;
+
+ int pos = 0;
+ wxString::const_iterator i = m_wordOrig.begin();
+
+ // find the beginning of text to copy:
+ for ( ; pos < begin; ++i )
{
- return window->GetHTMLCursor(wxHtmlWindowInterface::HTMLCursor_Text);
+ if ( *i == '\t' )
+ {
+ pos += 8 - (m_linepos + pos) % SPACES_PER_TAB;
+ if ( pos >= begin )
+ {
+ sel += '\t';
+ }
+ }
+ else
+ {
+ ++pos;
+ }
}
- else
+
+ // copy the content until we reach 'end':
+ for ( ; pos < end; ++i )
{
- return wxHtmlCell::GetMouseCursor(window);
+ const wxChar c = *i;
+ sel += c;
+
+ if ( c == '\t' )
+ pos += 8 - (m_linepos + pos) % SPACES_PER_TAB;
+ else
+ ++pos;
}
+
+ return sel;
}
+
//-----------------------------------------------------------------------------
// wxHtmlContainerCell
//-----------------------------------------------------------------------------
{
wxHtmlCell::Layout(w);
- if (m_LastLayout == w) return;
+ if (m_LastLayout == w)
+ return;
+ m_LastLayout = w;
// VS: Any attempt to layout with negative or zero width leads to hell,
// but we can't ignore such attempts completely, since it sometimes
m_MaxTotalWidth += s_indent + ((m_IndentRight < 0) ? (-m_IndentRight * m_Width / 100) : m_IndentRight);
MaxLineWidth += s_indent + ((m_IndentRight < 0) ? (-m_IndentRight * m_Width / 100) : m_IndentRight);
if (m_Width < MaxLineWidth) m_Width = MaxLineWidth;
-
- m_LastLayout = w;
}
void wxHtmlContainerCell::UpdateRenderingStatePre(wxHtmlRenderingInfo& info,
if (m_UseBkColour)
{
- wxBrush myb = wxBrush(m_BkColour, wxSOLID);
+ wxBrush myb = wxBrush(m_BkColour, wxBRUSHSTYLE_SOLID);
int real_y1 = mMax(ylocal, view_y1);
int real_y2 = mMin(ylocal + m_Height - 1, view_y2);
if (m_UseBorder)
{
- wxPen mypen1(m_BorderColour1, 1, wxSOLID);
- wxPen mypen2(m_BorderColour2, 1, wxSOLID);
+ wxPen mypen1(m_BorderColour1, 1, wxPENSTYLE_SOLID);
+ wxPen mypen2(m_BorderColour2, 1, wxPENSTYLE_SOLID);
dc.SetPen(mypen1);
dc.DrawLine(xlocal, ylocal, xlocal, ylocal + m_Height - 1);
if (state.GetSelectionState() != wxHTML_SEL_IN)
{
dc.SetTextBackground(m_Colour);
- dc.SetBackground(wxBrush(m_Colour, wxSOLID));
+ dc.SetBackground(wxBrush(m_Colour, wxBRUSHSTYLE_SOLID));
}
else
{
wxColour c = info.GetStyle().GetSelectedTextBgColour(m_Colour);
dc.SetTextBackground(c);
- dc.SetBackground(wxBrush(c, wxSOLID));
+ dc.SetBackground(wxBrush(c, wxBRUSHSTYLE_SOLID));
}
}
}