+#ifndef NO_TEXT_WINDOW_STREAM
+
+// ----------------------------------------------------------------------------
+// wxStreamToTextRedirector: this class redirects all data sent to the given
+// C++ stream to the wxTextCtrl given to its ctor during its lifetime.
+// ----------------------------------------------------------------------------
+
+class WXDLLEXPORT wxStreamToTextRedirector
+{
+public:
+ wxStreamToTextRedirector(wxTextCtrl *text, wxSTD ostream *ostr = NULL)
+ : m_ostr(ostr ? *ostr : wxSTD cout)
+ {
+ m_sbufOld = m_ostr.rdbuf();
+ m_ostr.rdbuf(text);
+ }
+
+ ~wxStreamToTextRedirector()
+ {
+ m_ostr.rdbuf(m_sbufOld);
+ }
+
+private:
+ // the stream we're redirecting
+ wxSTD ostream& m_ostr;
+
+ // the old streambuf (before we changed it)
+ wxSTD streambuf *m_sbufOld;
+};
+
+#endif // !NO_TEXT_WINDOW_STREAM
+