X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/fb4888a650065c9a24572d6867345f34adafaa37..ffb4a474d3b1b1adce9d461b3ef0babd11b1028d:/samples/widgets/textctrl.cpp diff --git a/samples/widgets/textctrl.cpp b/samples/widgets/textctrl.cpp index e7fbc25718..c3b4392181 100644 --- a/samples/widgets/textctrl.cpp +++ b/samples/widgets/textctrl.cpp @@ -36,9 +36,11 @@ #include "wx/statbox.h" #include "wx/stattext.h" #include "wx/textctrl.h" + #include "wx/msgdlg.h" #endif #include "wx/sizer.h" +#include "wx/ioswrap.h" #include "widgets.h" @@ -59,6 +61,8 @@ enum TextPage_Clear, TextPage_Load, + TextPage_StreamRedirector, + TextPage_Password, TextPage_WrapLines, TextPage_Textctrl @@ -128,7 +132,7 @@ class TextWidgetsPage : public WidgetsPage { public: // ctor(s) and dtor - TextWidgetsPage(wxBookCtrl *book, wxImageList *imaglist); + TextWidgetsPage(wxBookCtrlBase *book, wxImageList *imaglist); virtual ~TextWidgetsPage(){}; virtual wxControl *GetWidget() const { return m_text; } @@ -153,6 +157,7 @@ protected: void OnButtonClear(wxCommandEvent& event); void OnButtonLoad(wxCommandEvent& event); + void OnStreamRedirector(wxCommandEvent& event); void OnButtonQuit(wxCommandEvent& event); void OnText(wxCommandEvent& event); @@ -293,6 +298,8 @@ BEGIN_EVENT_TABLE(TextWidgetsPage, WidgetsPage) EVT_BUTTON(TextPage_Reset, TextWidgetsPage::OnButtonReset) + EVT_BUTTON(TextPage_StreamRedirector, TextWidgetsPage::OnStreamRedirector) + EVT_BUTTON(TextPage_Clear, TextWidgetsPage::OnButtonClear) EVT_BUTTON(TextPage_Set, TextWidgetsPage::OnButtonSet) EVT_BUTTON(TextPage_Add, TextWidgetsPage::OnButtonAdd) @@ -327,7 +334,7 @@ IMPLEMENT_WIDGETS_PAGE(TextWidgetsPage, _T("Text")); // TextWidgetsPage creation // ---------------------------------------------------------------------------- -TextWidgetsPage::TextWidgetsPage(wxBookCtrl *book, wxImageList *imaglist) +TextWidgetsPage::TextWidgetsPage(wxBookCtrlBase *book, wxImageList *imaglist) : WidgetsPage(book) { imaglist->Add(wxBitmap(text_xpm)); @@ -439,6 +446,9 @@ TextWidgetsPage::TextWidgetsPage(wxBookCtrl *book, wxImageList *imaglist) btn = new wxButton(this, TextPage_Clear, _T("&Clear")); sizerMiddleUp->Add(btn, 0, wxALL | wxGROW, 1); + btn = new wxButton(this, TextPage_StreamRedirector, _T("St&ream redirection")); + sizerMiddleUp->Add(btn, 0, wxALL | wxGROW, 1); + wxStaticBox *box4 = new wxStaticBox(this, wxID_ANY, _T("&Info:")); wxSizer *sizerMiddleDown = new wxStaticBoxSizer(box4, wxVERTICAL); @@ -545,7 +555,7 @@ wxTextCtrl *TextWidgetsPage::CreateInfoText() wxTextCtrl *text = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, - wxSize(s_maxWidth, -1), + wxSize(s_maxWidth, wxDefaultCoord), wxTE_READONLY); return text; } @@ -876,3 +886,13 @@ void TextWidgetsPage::OnCheckOrRadioBox(wxCommandEvent& WXUNUSED(event)) CreateText(); } +void TextWidgetsPage::OnStreamRedirector(wxCommandEvent& WXUNUSED(event)) +{ +#if wxHAS_TEXT_WINDOW_STREAM + wxStreamToTextRedirector redirect(m_text); + wxString str( _T("Outputed to cout, appears in wxTextCtrl!") ); + wxSTD cout << str << wxSTD endl; +#else + wxMessageBox(_T("This wxWidgets build does not support wxStreamToTextRedirector")); +#endif +}