fix text scrolling in GTK2 (patch 703988)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@23697 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -47,13 +47,17 @@ Base:
|
|||||||
|
|
||||||
- wxDateTime::ParseDateTime() implemented (Linus McCabe)
|
- wxDateTime::ParseDateTime() implemented (Linus McCabe)
|
||||||
|
|
||||||
|
All (GUI):
|
||||||
|
|
||||||
|
- added wxListCtrl::GetViewRect()
|
||||||
|
|
||||||
wxMSW:
|
wxMSW:
|
||||||
|
|
||||||
- fixed wxTE_*WRAP styles handling
|
- fixed wxTE_*WRAP styles handling
|
||||||
|
|
||||||
All (GUI):
|
wxGTK:
|
||||||
|
|
||||||
- added wxListCtrl::GetViewRect()
|
- fixes to wxTextCtrl scrolling under GTK2 (Nerijus Baliunas)
|
||||||
|
|
||||||
|
|
||||||
2.5.0
|
2.5.0
|
||||||
|
@@ -587,10 +587,13 @@ void wxTextCtrl::WriteText( const wxString &text )
|
|||||||
// TODO: Call whatever is needed to delete the selection.
|
// TODO: Call whatever is needed to delete the selection.
|
||||||
wxGtkTextInsert( m_text, text_buffer, m_defaultStyle, buffer );
|
wxGtkTextInsert( m_text, text_buffer, m_defaultStyle, buffer );
|
||||||
|
|
||||||
// Scroll to cursor.
|
GtkAdjustment *adj = gtk_scrolled_window_get_vadjustment( GTK_SCROLLED_WINDOW(m_widget) );
|
||||||
GtkTextIter iter;
|
// Scroll to cursor, but only if scrollbar thumb is at the very bottom
|
||||||
gtk_text_buffer_get_iter_at_mark( text_buffer, &iter, gtk_text_buffer_get_insert( text_buffer ) );
|
if ( adj->value == adj->upper - adj->page_size )
|
||||||
gtk_text_view_scroll_to_iter( GTK_TEXT_VIEW(m_text), &iter, 0.0, FALSE, 0.0, 1.0 );
|
{
|
||||||
|
gtk_text_view_scroll_to_mark( GTK_TEXT_VIEW(m_text),
|
||||||
|
gtk_text_buffer_get_insert( text_buffer ), 0.0, FALSE, 0.0, 1.0 );
|
||||||
|
}
|
||||||
#else // GTK 1.x
|
#else // GTK 1.x
|
||||||
// After cursor movements, gtk_text_get_point() is wrong by one.
|
// After cursor movements, gtk_text_get_point() is wrong by one.
|
||||||
gtk_text_set_point( GTK_TEXT(m_text), GET_EDITABLE_POS(m_text) );
|
gtk_text_set_point( GTK_TEXT(m_text), GET_EDITABLE_POS(m_text) );
|
||||||
@@ -1005,9 +1008,16 @@ void wxTextCtrl::SetSelection( long from, long to )
|
|||||||
|
|
||||||
void wxTextCtrl::ShowPosition( long pos )
|
void wxTextCtrl::ShowPosition( long pos )
|
||||||
{
|
{
|
||||||
#ifndef __WXGTK20__
|
|
||||||
if (m_windowStyle & wxTE_MULTILINE)
|
if (m_windowStyle & wxTE_MULTILINE)
|
||||||
{
|
{
|
||||||
|
#ifdef __WXGTK20__
|
||||||
|
GtkTextBuffer *buf = gtk_text_view_get_buffer( GTK_TEXT_VIEW(m_text) );
|
||||||
|
GtkTextIter iter;
|
||||||
|
gtk_text_buffer_get_start_iter( buf, &iter );
|
||||||
|
gtk_text_iter_set_offset( &iter, pos );
|
||||||
|
GtkTextMark *mark = gtk_text_buffer_create_mark( buf, NULL, &iter, TRUE );
|
||||||
|
gtk_text_view_scroll_to_mark( GTK_TEXT_VIEW(m_text), mark, 0.0, FALSE, 0.0, 0.0 );
|
||||||
|
#else // GTK 1.x
|
||||||
GtkAdjustment *vp = GTK_TEXT(m_text)->vadj;
|
GtkAdjustment *vp = GTK_TEXT(m_text)->vadj;
|
||||||
float totalLines = (float) GetNumberOfLines();
|
float totalLines = (float) GetNumberOfLines();
|
||||||
long posX;
|
long posX;
|
||||||
@@ -1016,8 +1026,8 @@ void wxTextCtrl::ShowPosition( long pos )
|
|||||||
float posLine = (float) posY;
|
float posLine = (float) posY;
|
||||||
float p = (posLine/totalLines)*(vp->upper - vp->lower) + vp->lower;
|
float p = (posLine/totalLines)*(vp->upper - vp->lower) + vp->lower;
|
||||||
gtk_adjustment_set_value(GTK_TEXT(m_text)->vadj, p);
|
gtk_adjustment_set_value(GTK_TEXT(m_text)->vadj, p);
|
||||||
|
#endif // GTK 1.x/2.x
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
long wxTextCtrl::GetInsertionPoint() const
|
long wxTextCtrl::GetInsertionPoint() const
|
||||||
|
@@ -587,10 +587,13 @@ void wxTextCtrl::WriteText( const wxString &text )
|
|||||||
// TODO: Call whatever is needed to delete the selection.
|
// TODO: Call whatever is needed to delete the selection.
|
||||||
wxGtkTextInsert( m_text, text_buffer, m_defaultStyle, buffer );
|
wxGtkTextInsert( m_text, text_buffer, m_defaultStyle, buffer );
|
||||||
|
|
||||||
// Scroll to cursor.
|
GtkAdjustment *adj = gtk_scrolled_window_get_vadjustment( GTK_SCROLLED_WINDOW(m_widget) );
|
||||||
GtkTextIter iter;
|
// Scroll to cursor, but only if scrollbar thumb is at the very bottom
|
||||||
gtk_text_buffer_get_iter_at_mark( text_buffer, &iter, gtk_text_buffer_get_insert( text_buffer ) );
|
if ( adj->value == adj->upper - adj->page_size )
|
||||||
gtk_text_view_scroll_to_iter( GTK_TEXT_VIEW(m_text), &iter, 0.0, FALSE, 0.0, 1.0 );
|
{
|
||||||
|
gtk_text_view_scroll_to_mark( GTK_TEXT_VIEW(m_text),
|
||||||
|
gtk_text_buffer_get_insert( text_buffer ), 0.0, FALSE, 0.0, 1.0 );
|
||||||
|
}
|
||||||
#else // GTK 1.x
|
#else // GTK 1.x
|
||||||
// After cursor movements, gtk_text_get_point() is wrong by one.
|
// After cursor movements, gtk_text_get_point() is wrong by one.
|
||||||
gtk_text_set_point( GTK_TEXT(m_text), GET_EDITABLE_POS(m_text) );
|
gtk_text_set_point( GTK_TEXT(m_text), GET_EDITABLE_POS(m_text) );
|
||||||
@@ -1005,9 +1008,16 @@ void wxTextCtrl::SetSelection( long from, long to )
|
|||||||
|
|
||||||
void wxTextCtrl::ShowPosition( long pos )
|
void wxTextCtrl::ShowPosition( long pos )
|
||||||
{
|
{
|
||||||
#ifndef __WXGTK20__
|
|
||||||
if (m_windowStyle & wxTE_MULTILINE)
|
if (m_windowStyle & wxTE_MULTILINE)
|
||||||
{
|
{
|
||||||
|
#ifdef __WXGTK20__
|
||||||
|
GtkTextBuffer *buf = gtk_text_view_get_buffer( GTK_TEXT_VIEW(m_text) );
|
||||||
|
GtkTextIter iter;
|
||||||
|
gtk_text_buffer_get_start_iter( buf, &iter );
|
||||||
|
gtk_text_iter_set_offset( &iter, pos );
|
||||||
|
GtkTextMark *mark = gtk_text_buffer_create_mark( buf, NULL, &iter, TRUE );
|
||||||
|
gtk_text_view_scroll_to_mark( GTK_TEXT_VIEW(m_text), mark, 0.0, FALSE, 0.0, 0.0 );
|
||||||
|
#else // GTK 1.x
|
||||||
GtkAdjustment *vp = GTK_TEXT(m_text)->vadj;
|
GtkAdjustment *vp = GTK_TEXT(m_text)->vadj;
|
||||||
float totalLines = (float) GetNumberOfLines();
|
float totalLines = (float) GetNumberOfLines();
|
||||||
long posX;
|
long posX;
|
||||||
@@ -1016,8 +1026,8 @@ void wxTextCtrl::ShowPosition( long pos )
|
|||||||
float posLine = (float) posY;
|
float posLine = (float) posY;
|
||||||
float p = (posLine/totalLines)*(vp->upper - vp->lower) + vp->lower;
|
float p = (posLine/totalLines)*(vp->upper - vp->lower) + vp->lower;
|
||||||
gtk_adjustment_set_value(GTK_TEXT(m_text)->vadj, p);
|
gtk_adjustment_set_value(GTK_TEXT(m_text)->vadj, p);
|
||||||
|
#endif // GTK 1.x/2.x
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
long wxTextCtrl::GetInsertionPoint() const
|
long wxTextCtrl::GetInsertionPoint() const
|
||||||
|
Reference in New Issue
Block a user