Corrections to take into account that range in the API has an end position

that is 1 more than the last affected position


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@41298 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Julian Smart
2006-09-19 13:47:32 +00:00
parent 7807a2b499
commit 96c9f0f677
3 changed files with 55 additions and 15 deletions

View File

@@ -214,6 +214,7 @@ public:
void operator =(const wxRichTextRange& range) { m_start = range.m_start; m_end = range.m_end; }
bool operator ==(const wxRichTextRange& range) const { return (m_start == range.m_start && m_end == range.m_end); }
bool operator !=(const wxRichTextRange& range) const { return (m_start != range.m_start && m_end != range.m_end); }
wxRichTextRange operator -(const wxRichTextRange& range) const { return wxRichTextRange(m_start - range.m_start, m_end - range.m_end); }
wxRichTextRange operator +(const wxRichTextRange& range) const { return wxRichTextRange(m_start + range.m_start, m_end + range.m_end); }
@@ -246,6 +247,12 @@ public:
/// Swaps the start and end
void Swap() { long tmp = m_start; m_start = m_end; m_end = tmp; }
/// Convert to internal form: (n, n) is the range of a single character.
wxRichTextRange ToInternal() const { return wxRichTextRange(m_start, m_end-1); }
/// Convert from internal to public API form: (n, n+1) is the range of a single character.
wxRichTextRange FromInternal() const { return wxRichTextRange(m_start, m_end+1); }
protected:
long m_start;
long m_end;