Version: 3.3.0
wxStreamToTextRedirector Class Reference

#include <wx/textctrl.h>

Detailed Description

This class can be used to (temporarily) redirect all output sent to a C++ ostream object to a wxTextCtrl instead.

Note
This class is not available if wxUSE_STD_IOSTREAM is set to 0 (which is done by --disable-std_iostreams option when using configure).

Example of usage:

using namespace std;
wxTextCtrl* text = new wxTextCtrl(...);
{
wxStreamToTextRedirector redirect(text);
// this goes to the text control
cout << "Hello, text!" << endl;
}
// this goes somewhere else, presumably to stdout
cout << "Hello, console!" << endl;
This class can be used to (temporarily) redirect all output sent to a C++ ostream object to a wxTextC...
Definition: textctrl.h:2271
A text control allows text to be displayed and edited.
Definition: textctrl.h:1580
wxTextOutputStream & endl(wxTextOutputStream &stream)
Writes '\n' to stream.

Library:  wxCore
Category:  Logging
See also
wxTextCtrl

Public Member Functions

 wxStreamToTextRedirector (wxTextCtrl *text, ostream *ostr)
 The constructor starts redirecting output sent to ostr or cout for the default parameter value to the text control text. More...
 
 ~wxStreamToTextRedirector ()
 When a wxStreamToTextRedirector object is destroyed, the redirection is ended and any output sent to the C++ ostream which had been specified at the time of the object construction will go to its original destination. More...
 

Constructor & Destructor Documentation

◆ wxStreamToTextRedirector()

wxStreamToTextRedirector::wxStreamToTextRedirector ( wxTextCtrl text,
ostream *  ostr 
)

The constructor starts redirecting output sent to ostr or cout for the default parameter value to the text control text.

Parameters
textThe text control to append output too, must be non-null
ostrThe C++ stream to redirect, cout is used if it is nullptr

◆ ~wxStreamToTextRedirector()

wxStreamToTextRedirector::~wxStreamToTextRedirector ( )

When a wxStreamToTextRedirector object is destroyed, the redirection is ended and any output sent to the C++ ostream which had been specified at the time of the object construction will go to its original destination.