From f17ce8604726b0ea73c8e3d327a64c4f0b6631ca Mon Sep 17 00:00:00 2001 From: Julian Smart Date: Wed, 2 Apr 2003 17:55:42 +0000 Subject: [PATCH] Applied patch [ 705212 ] wxTextCtrl::SetSelection() for wxGTK2 git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_4_BRANCH@19939 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/gtk/textctrl.cpp | 10 +++++++++- src/gtk1/textctrl.cpp | 10 +++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/gtk/textctrl.cpp b/src/gtk/textctrl.cpp index 1afca19c49..faf1eec7bc 100644 --- a/src/gtk/textctrl.cpp +++ b/src/gtk/textctrl.cpp @@ -1,3 +1,4 @@ + ///////////////////////////////////////////////////////////////////////////// // Name: textctrl.cpp // Purpose: @@ -995,7 +996,14 @@ void wxTextCtrl::SetSelection( long from, long to ) if (m_windowStyle & wxTE_MULTILINE) { #ifdef __WXGTK20__ - // ???? + GtkTextBuffer *buf = gtk_text_view_get_buffer( GTK_TEXT_VIEW(m_text) ); + + GtkTextIter fromi, toi; + gtk_text_buffer_get_iter_at_offset( buf, &fromi, from ); + gtk_text_buffer_get_iter_at_offset( buf, &toi, to ); + + gtk_text_buffer_place_cursor( buf, &toi ); + gtk_text_buffer_move_mark_by_name( buf, "selection_bound", &fromi ); #else gtk_editable_select_region( GTK_EDITABLE(m_text), (gint)from, (gint)to ); #endif diff --git a/src/gtk1/textctrl.cpp b/src/gtk1/textctrl.cpp index 1afca19c49..faf1eec7bc 100644 --- a/src/gtk1/textctrl.cpp +++ b/src/gtk1/textctrl.cpp @@ -1,3 +1,4 @@ + ///////////////////////////////////////////////////////////////////////////// // Name: textctrl.cpp // Purpose: @@ -995,7 +996,14 @@ void wxTextCtrl::SetSelection( long from, long to ) if (m_windowStyle & wxTE_MULTILINE) { #ifdef __WXGTK20__ - // ???? + GtkTextBuffer *buf = gtk_text_view_get_buffer( GTK_TEXT_VIEW(m_text) ); + + GtkTextIter fromi, toi; + gtk_text_buffer_get_iter_at_offset( buf, &fromi, from ); + gtk_text_buffer_get_iter_at_offset( buf, &toi, to ); + + gtk_text_buffer_place_cursor( buf, &toi ); + gtk_text_buffer_move_mark_by_name( buf, "selection_bound", &fromi ); #else gtk_editable_select_region( GTK_EDITABLE(m_text), (gint)from, (gint)to ); #endif