an eternity per call. Also closes bug #
1250464. Not sure if this should go into changes.txt.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@35060
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
{
if ( m_windowStyle & wxTE_MULTILINE )
{
{
if ( m_windowStyle & wxTE_MULTILINE )
{
+#ifdef __WXGTK20__
+ GtkTextIter iter;
+ gtk_text_buffer_get_iter_at_offset(m_buffer, &iter, pos);
+ if (gtk_text_iter_is_end(&iter))
+ return false;
+
+ *y = gtk_text_iter_get_line(&iter);
+ *x = gtk_text_iter_get_line_offset(&iter);
+#else
wxString text = GetValue();
// cast to prevent warning. But pos really should've been unsigned.
wxString text = GetValue();
// cast to prevent warning. But pos really should've been unsigned.
}
else // single line control
{
}
else // single line control
{
{
if (!(m_windowStyle & wxTE_MULTILINE)) return 0;
{
if (!(m_windowStyle & wxTE_MULTILINE)) return 0;
+#ifdef __WXGTK20__
+ GtkTextIter iter;
+ gtk_text_buffer_get_iter_at_line_offset(m_buffer, &iter, y, x);
+ return gtk_text_iter_get_offset(&iter);
+#else
long pos=0;
for( int i=0; i<y; i++ ) pos += GetLineLength(i) + 1; // one for '\n'
pos += x;
return pos;
long pos=0;
for( int i=0; i<y; i++ ) pos += GetLineLength(i) + 1; // one for '\n'
pos += x;
return pos;
}
int wxTextCtrl::GetLineLength(long lineNo) const
{
}
int wxTextCtrl::GetLineLength(long lineNo) const
{
- wxString str = GetLineText (lineNo);
- return (int) str.Length();
+#ifdef __WXGTK20__
+ if (m_windowStyle & wxTE_MULTILINE)
+ {
+ int last_line = gtk_text_buffer_get_line_count( m_buffer ) - 1;
+ if (lineNo > last_line)
+ return -1;
+
+ GtkTextIter iter;
+ gtk_text_buffer_get_iter_at_line(m_buffer, &iter, lineNo);
+ // get_chars_in_line return includes paragraph delimiters, so need to subtract 1 IF it is not the last line
+ return gtk_text_iter_get_chars_in_line(&iter) - ((lineNo == last_line) ? 0 : 1);
+ }
+ else
+#endif
+ {
+ wxString str = GetLineText (lineNo);
+ return (int) str.Length();
+ }
}
int wxTextCtrl::GetNumberOfLines() const
}
int wxTextCtrl::GetNumberOfLines() const
{
if ( m_windowStyle & wxTE_MULTILINE )
{
{
if ( m_windowStyle & wxTE_MULTILINE )
{
+#ifdef __WXGTK20__
+ GtkTextIter iter;
+ gtk_text_buffer_get_iter_at_offset(m_buffer, &iter, pos);
+ if (gtk_text_iter_is_end(&iter))
+ return false;
+
+ *y = gtk_text_iter_get_line(&iter);
+ *x = gtk_text_iter_get_line_offset(&iter);
+#else
wxString text = GetValue();
// cast to prevent warning. But pos really should've been unsigned.
wxString text = GetValue();
// cast to prevent warning. But pos really should've been unsigned.
}
else // single line control
{
}
else // single line control
{
{
if (!(m_windowStyle & wxTE_MULTILINE)) return 0;
{
if (!(m_windowStyle & wxTE_MULTILINE)) return 0;
+#ifdef __WXGTK20__
+ GtkTextIter iter;
+ gtk_text_buffer_get_iter_at_line_offset(m_buffer, &iter, y, x);
+ return gtk_text_iter_get_offset(&iter);
+#else
long pos=0;
for( int i=0; i<y; i++ ) pos += GetLineLength(i) + 1; // one for '\n'
pos += x;
return pos;
long pos=0;
for( int i=0; i<y; i++ ) pos += GetLineLength(i) + 1; // one for '\n'
pos += x;
return pos;
}
int wxTextCtrl::GetLineLength(long lineNo) const
{
}
int wxTextCtrl::GetLineLength(long lineNo) const
{
- wxString str = GetLineText (lineNo);
- return (int) str.Length();
+#ifdef __WXGTK20__
+ if (m_windowStyle & wxTE_MULTILINE)
+ {
+ int last_line = gtk_text_buffer_get_line_count( m_buffer ) - 1;
+ if (lineNo > last_line)
+ return -1;
+
+ GtkTextIter iter;
+ gtk_text_buffer_get_iter_at_line(m_buffer, &iter, lineNo);
+ // get_chars_in_line return includes paragraph delimiters, so need to subtract 1 IF it is not the last line
+ return gtk_text_iter_get_chars_in_line(&iter) - ((lineNo == last_line) ? 0 : 1);
+ }
+ else
+#endif
+ {
+ wxString str = GetLineText (lineNo);
+ return (int) str.Length();
+ }
}
int wxTextCtrl::GetNumberOfLines() const
}
int wxTextCtrl::GetNumberOfLines() const