]> git.saurik.com Git - wxWidgets.git/blobdiff - src/gtk1/textctrl.cpp
Added implementations for two cases of wxSystemSettingsNative::GetMetric to
[wxWidgets.git] / src / gtk1 / textctrl.cpp
index c91af21b5e1ea6f2d57917ffe86b319d2d0a672d..23b5a380f2d98c7fd23ebe4ffc382d87cb71f336 100644 (file)
@@ -994,7 +994,14 @@ void wxTextCtrl::SetSelection( long from, long to )
     if (m_windowStyle & wxTE_MULTILINE)
     {
 #ifdef __WXGTK20__
     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
 #else
         gtk_editable_select_region( GTK_EDITABLE(m_text), (gint)from, (gint)to );
 #endif
@@ -1079,7 +1086,7 @@ void wxTextCtrl::Remove( long from, long to )
     wxCHECK_RET( m_text != NULL, wxT("invalid text ctrl") );
 
 #ifdef __WXGTK20__
     wxCHECK_RET( m_text != NULL, wxT("invalid text ctrl") );
 
 #ifdef __WXGTK20__
-    if ( m_windowStyle & wxTE_MULTILINE )
+    if (m_windowStyle & wxTE_MULTILINE)
     {
         GtkTextBuffer *
             text_buffer = gtk_text_view_get_buffer( GTK_TEXT_VIEW(m_text) );
     {
         GtkTextBuffer *
             text_buffer = gtk_text_view_get_buffer( GTK_TEXT_VIEW(m_text) );
@@ -1180,7 +1187,9 @@ void wxTextCtrl::GetSelection(long* fromOut, long* toOut) const
 
     gint from, to;
 #ifdef __WXGTK20__
 
     gint from, to;
 #ifdef __WXGTK20__
-    if ( !gtk_editable_get_selection_bounds(GTK_EDITABLE(m_text), &from, &to) )
+    GtkTextBuffer *buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (m_text));
+    GtkTextIter ifrom, ito;
+    if (!gtk_text_buffer_get_selection_bounds(buffer, &ifrom, &ito))
 #else
     if ( !(GTK_EDITABLE(m_text)->has_selection) )
 #endif
 #else
     if ( !(GTK_EDITABLE(m_text)->has_selection) )
 #endif
@@ -1190,7 +1199,10 @@ void wxTextCtrl::GetSelection(long* fromOut, long* toOut) const
     }
     else // got selection
     {
     }
     else // got selection
     {
-#ifndef __WXGTK20__
+#ifdef __WXGTK20__
+        from = gtk_text_iter_get_offset(&ifrom);
+        to = gtk_text_iter_get_offset(&ito);
+#else
         from = (long) GTK_EDITABLE(m_text)->selection_start_pos;
         to = (long) GTK_EDITABLE(m_text)->selection_end_pos;
 #endif
         from = (long) GTK_EDITABLE(m_text)->selection_start_pos;
         to = (long) GTK_EDITABLE(m_text)->selection_end_pos;
 #endif
@@ -1215,7 +1227,14 @@ bool wxTextCtrl::IsEditable() const
     wxCHECK_MSG( m_text != NULL, FALSE, wxT("invalid text ctrl") );
 
 #ifdef __WXGTK20__
     wxCHECK_MSG( m_text != NULL, FALSE, wxT("invalid text ctrl") );
 
 #ifdef __WXGTK20__
-    return gtk_editable_get_editable(GTK_EDITABLE(m_text));
+    if (m_windowStyle & wxTE_MULTILINE)
+    {
+        return gtk_text_view_get_editable(GTK_TEXT_VIEW(m_text));
+    }
+    else
+    {
+        return gtk_editable_get_editable(GTK_EDITABLE(m_text));
+    }
 #else
     return GTK_EDITABLE(m_text)->editable;
 #endif
 #else
     return GTK_EDITABLE(m_text)->editable;
 #endif
@@ -1572,7 +1591,8 @@ void wxTextCtrl::OnInternalIdle()
         }
     }
 
         }
     }
 
-    UpdateWindowUI();
+    if (wxUpdateUIEvent::CanUpdate(this))
+        UpdateWindowUI(wxUPDATE_UI_FROMIDLE);
 }
 
 wxSize wxTextCtrl::DoGetBestSize() const
 }
 
 wxSize wxTextCtrl::DoGetBestSize() const