X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/865bb3251ecf83ddac350b734f4fed1d258e250b..283587a491a718c8f568f70a143c9b1b2992306b:/src/gtk/textctrl.cpp diff --git a/src/gtk/textctrl.cpp b/src/gtk/textctrl.cpp index d896b04035..47dca6fb4d 100644 --- a/src/gtk/textctrl.cpp +++ b/src/gtk/textctrl.cpp @@ -598,12 +598,27 @@ bool wxTextCtrl::Create( wxWindow *parent, gtk_container_add( GTK_CONTAINER(m_widget), m_text ); // translate wx wrapping style to GTK+ + GtkWrapMode wrap; if ( HasFlag( wxTE_DONTWRAP ) ) - gtk_text_view_set_wrap_mode( GTK_TEXT_VIEW( m_text ), GTK_WRAP_NONE ); - else if ( HasFlag( wxTE_LINEWRAP ) ) - gtk_text_view_set_wrap_mode( GTK_TEXT_VIEW( m_text ), GTK_WRAP_CHAR ); - else // HasFlag(wxTE_WORDWRAP) always true as wxTE_WORDWRAP == 0 - gtk_text_view_set_wrap_mode( GTK_TEXT_VIEW( m_text ), GTK_WRAP_WORD_CHAR ); + wrap = GTK_WRAP_NONE; + else if ( HasFlag( wxTE_CHARWRAP ) ) + wrap = GTK_WRAP_CHAR; + else if ( HasFlag( wxTE_WORDWRAP ) ) + wrap = GTK_WRAP_WORD; + else // HasFlag(wxTE_BESTWRAP) always true as wxTE_BESTWRAP == 0 + { + // GTK_WRAP_WORD_CHAR seems to be new in GTK+ 2.4 +#ifdef __WXGTK24__ + if ( !gtk_check_version(2,4,0) ) + { + wrap = GTK_WRAP_WORD_CHAR; + } + else +#endif + wrap = GTK_WRAP_WORD; + } + + gtk_text_view_set_wrap_mode( GTK_TEXT_VIEW( m_text ), wrap ); if (!HasFlag(wxNO_BORDER)) gtk_scrolled_window_set_shadow_type( GTK_SCROLLED_WINDOW(m_widget), GTK_SHADOW_IN ); @@ -892,6 +907,12 @@ void wxTextCtrl::SetValue( const wxString &value ) if (gtk_text_buffer_get_char_count(m_buffer) != 0) IgnoreNextTextUpdate(); + if ( !buffer ) + { + // what else can we do? at least don't crash... + return; + } + gtk_text_buffer_set_text( m_buffer, buffer, strlen(buffer) ); #else @@ -987,6 +1008,12 @@ void wxTextCtrl::WriteText( const wxString &text ) #else wxCharBuffer buffer( wxConvUTF8.cWC2MB( wxConvLocal.cWX2WC( text ) ) ); #endif + if ( !buffer ) + { + // what else can we do? at least don't crash... + return; + } + gtk_editable_insert_text( GTK_EDITABLE(m_text), buffer, strlen(buffer), &len ); #else