+int wxTextCtrl::GTKIMFilterKeypress(GdkEventKey* event) const
+{
+#if GTK_CHECK_VERSION(2, 22, 0)
+ if ( gtk_check_version(2, 12, 0) == 0 )
+ {
+ if ( IsSingleLine() )
+ {
+ return wxTextEntry::GTKIMFilterKeypress(event);
+ }
+ else
+ {
+ return gtk_text_view_im_context_filter_keypress(
+ GTK_TEXT_VIEW(m_text),
+ event
+ );
+ }
+ }
+#else // GTK+ < 2.22
+ wxUnusedVar(event);
+#endif // GTK+ 2.22+
+
+ return FALSE;
+}
+
+// ----------------------------------------------------------------------------
+// flags handling
+// ----------------------------------------------------------------------------
+
+void wxTextCtrl::GTKSetEditable()
+{
+ gboolean editable = !HasFlag(wxTE_READONLY);
+ if ( IsSingleLine() )
+ gtk_editable_set_editable(GTK_EDITABLE(m_text), editable);
+ else
+ gtk_text_view_set_editable(GTK_TEXT_VIEW(m_text), editable);
+}
+
+void wxTextCtrl::GTKSetVisibility()
+{
+ wxCHECK_RET( IsSingleLine(),
+ "wxTE_PASSWORD is for single line text controls only" );
+
+ gtk_entry_set_visibility(GTK_ENTRY(m_text), !HasFlag(wxTE_PASSWORD));
+}
+
+void wxTextCtrl::GTKSetActivatesDefault()
+{
+ wxCHECK_RET( IsSingleLine(),
+ "wxTE_PROCESS_ENTER is for single line text controls only" );
+
+ gtk_entry_set_activates_default(GTK_ENTRY(m_text),
+ !HasFlag(wxTE_PROCESS_ENTER));
+}
+
+void wxTextCtrl::GTKSetWrapMode()
+{
+ // no wrapping in single line controls
+ if ( !IsMultiLine() )
+ return;
+
+ // translate wx wrapping style to GTK+
+ GtkWrapMode wrap;
+ if ( HasFlag( wxTE_DONTWRAP ) )
+ 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
+ wrap = GTK_WRAP_WORD_CHAR;
+
+ gtk_text_view_set_wrap_mode( GTK_TEXT_VIEW( m_text ), wrap );
+}
+
+void wxTextCtrl::GTKSetJustification()
+{
+ if ( IsMultiLine() )
+ {
+ GtkJustification just;
+ if ( HasFlag(wxTE_RIGHT) )
+ just = GTK_JUSTIFY_RIGHT;
+ else if ( HasFlag(wxTE_CENTRE) )
+ just = GTK_JUSTIFY_CENTER;
+ else // wxTE_LEFT == 0
+ just = GTK_JUSTIFY_LEFT;
+
+ gtk_text_view_set_justification(GTK_TEXT_VIEW(m_text), just);
+ }
+ else // single line
+ {
+ gfloat align;
+ if ( HasFlag(wxTE_RIGHT) )
+ align = 1.0;
+ else if ( HasFlag(wxTE_CENTRE) )
+ align = 0.5;
+ else // single line
+ align = 0.0;
+
+ gtk_entry_set_alignment(GTK_ENTRY(m_text), align);
+ }
+}
+
+void wxTextCtrl::SetWindowStyleFlag(long style)
+{
+ long styleOld = GetWindowStyleFlag();
+
+ wxTextCtrlBase::SetWindowStyleFlag(style);
+
+ if ( (style & wxTE_READONLY) != (styleOld & wxTE_READONLY) )
+ GTKSetEditable();
+
+ if ( (style & wxTE_PASSWORD) != (styleOld & wxTE_PASSWORD) )
+ GTKSetVisibility();
+
+ if ( (style & wxTE_PROCESS_ENTER) != (styleOld & wxTE_PROCESS_ENTER) )
+ GTKSetActivatesDefault();
+
+ static const long flagsWrap = wxTE_WORDWRAP | wxTE_CHARWRAP | wxTE_DONTWRAP;
+ if ( (style & flagsWrap) != (styleOld & flagsWrap) )
+ GTKSetWrapMode();
+
+ static const long flagsAlign = wxTE_LEFT | wxTE_CENTRE | wxTE_RIGHT;
+ if ( (style & flagsAlign) != (styleOld & flagsAlign) )
+ GTKSetJustification();
+}
+
+// ----------------------------------------------------------------------------
+// control value
+// ----------------------------------------------------------------------------
+