- gtk_editable_delete_text( GTK_EDITABLE(m_text), (gint)from, (gint)to );
- if (value.IsNull()) return;
- gint pos = (gint)to;
- gtk_editable_insert_text( GTK_EDITABLE(m_text), value, value.Length(), &pos );
-};
+ wxCHECK_RET( m_text != NULL, wxT("invalid text ctrl") );
+
+ gtk_editable_delete_text( GTK_EDITABLE(m_text), (gint)from, (gint)to );
+
+ if (!value.IsEmpty())
+ {
+ gint pos = (gint)from;
+#if wxUSE_UNICODE
+ wxWX2MBbuf buf = value.mbc_str();
+ gtk_editable_insert_text( GTK_EDITABLE(m_text), buf, strlen(buf), &pos );
+#else
+ gtk_editable_insert_text( GTK_EDITABLE(m_text), value, value.Length(), &pos );
+#endif
+ }
+}
+
+void wxTextCtrl::Cut()
+{
+ wxCHECK_RET( m_text != NULL, wxT("invalid text ctrl") );
+
+#if (GTK_MINOR_VERSION > 0)
+ gtk_editable_cut_clipboard( GTK_EDITABLE(m_text) );
+#else
+ gtk_editable_cut_clipboard( GTK_EDITABLE(m_text), 0 );
+#endif
+}
+
+void wxTextCtrl::Copy()
+{
+ wxCHECK_RET( m_text != NULL, wxT("invalid text ctrl") );
+
+#if (GTK_MINOR_VERSION > 0)
+ gtk_editable_copy_clipboard( GTK_EDITABLE(m_text) );
+#else
+ gtk_editable_copy_clipboard( GTK_EDITABLE(m_text), 0 );
+#endif
+}
+
+void wxTextCtrl::Paste()
+{
+ wxCHECK_RET( m_text != NULL, wxT("invalid text ctrl") );
+
+#if (GTK_MINOR_VERSION > 0)
+ gtk_editable_paste_clipboard( GTK_EDITABLE(m_text) );
+#else
+ gtk_editable_paste_clipboard( GTK_EDITABLE(m_text), 0 );
+#endif
+}
+
+bool wxTextCtrl::CanCopy() const
+{
+ // Can copy if there's a selection
+ long from, to;
+ GetSelection(& from, & to);
+ return (from != to) ;
+}
+
+bool wxTextCtrl::CanCut() const
+{
+ // Can cut if there's a selection
+ long from, to;
+ GetSelection(& from, & to);
+ return (from != to) ;
+}
+
+bool wxTextCtrl::CanPaste() const
+{
+ return IsEditable() ;
+}
+
+// Undo/redo
+void wxTextCtrl::Undo()
+{
+ // TODO
+ wxFAIL_MSG( wxT("wxTextCtrl::Undo not implemented") );
+}
+
+void wxTextCtrl::Redo()
+{
+ // TODO
+ wxFAIL_MSG( wxT("wxTextCtrl::Redo not implemented") );
+}