class CMyRedirector
Overview
This auxiliary class redirects the output sent to a streambuf to a wxTextCtrl object.
Uses code from http://www.devmaster.net/forums/showthread.php?t=7037 Jose Luis Blanco - Dec 2007 NOTE (10-Aug-2009): Added thread-safe support: We cannot write in a wxTextCtrl from a thread different than the main wx one, so if this object will be used by several threads, set “m_threadSafe” to true. In this mode, the object will NEVER write the text to the text control, unless the method “dumpNow()” is explicitly called FROM THE MAIN THREAD.
#include <mrpt/gui/CMyRedirector.h> class CMyRedirector: public std::streambuf { public: // construction CMyRedirector( wxTextCtrl* obj, bool yieldApplication = false, int bufferSize = 3000, bool also_cerr = false, bool threadSafe = false, bool also_to_cout_cerr = false ); // methods void flush(); virtual void writeString(const std::string& str); void dumpNow(); };
Methods
void dumpNow()
Writes all the stored strings to the text control (only for threadSafe mode).
CALL THIS METHOD FROM THE MAIN THREAD!