From 50a2a3553af0449fefad444c04e91dea2589092c Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 13 Mar 2011 13:33:12 +0000 Subject: [PATCH] Document wxTE_MULTILINE support in wxTextEntryDialog. It wasn't immediately obvious that this dialog could be used for multiline text entry too so mention it explicitly in the documentation. Also show this in action in the dialogs sample. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@67179 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- interface/wx/textdlg.h | 9 ++++++++- samples/dialogs/dialogs.cpp | 19 +++++++++++++++++-- samples/dialogs/dialogs.h | 2 ++ 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/interface/wx/textdlg.h b/interface/wx/textdlg.h index 3034d0fa54..ccba11d7d7 100644 --- a/interface/wx/textdlg.h +++ b/interface/wx/textdlg.h @@ -79,7 +79,8 @@ public: @param style A dialog style, specifying the buttons (wxOK, wxCANCEL) and an optional wxCENTRE style. Additionally, wxTextCtrl styles - (such as wxTE_PASSWORD) may be specified here. + (such as @c wxTE_PASSWORD or @c wxTE_MULTILINE) may be specified + here. @param pos Dialog position. */ @@ -129,6 +130,12 @@ public: If @c centre is @true, the message text (which may include new line characters) is centred; if @false, the message is left-justified. + This function is a wrapper around wxTextEntryDialog and while it is usually + more convenient to use, using the dialog directly is more flexible, e.g. it + allows you to specify the @c wxTE_MULTILINE to allow the user enter + multiple lines of text while this function is limited to single line entry + only. + @header{wx/textdlg.h} */ wxString wxGetTextFromUser(const wxString& message, diff --git a/samples/dialogs/dialogs.cpp b/samples/dialogs/dialogs.cpp index 1c70584b91..1c020573f5 100644 --- a/samples/dialogs/dialogs.cpp +++ b/samples/dialogs/dialogs.cpp @@ -152,6 +152,7 @@ BEGIN_EVENT_TABLE(MyFrame, wxFrame) #endif // wxUSE_INFOBAR #if wxUSE_TEXTDLG + EVT_MENU(DIALOGS_LINE_ENTRY, MyFrame::LineEntry) EVT_MENU(DIALOGS_TEXT_ENTRY, MyFrame::TextEntry) EVT_MENU(DIALOGS_PASSWORD_ENTRY, MyFrame::PasswordEntry) #endif // wxUSE_TEXTDLG @@ -395,7 +396,8 @@ bool MyApp::OnInit() wxMenu *entry_menu = new wxMenu; #if wxUSE_TEXTDLG - entry_menu->Append(DIALOGS_TEXT_ENTRY, wxT("Text &entry\tCtrl-E")); + entry_menu->Append(DIALOGS_LINE_ENTRY, wxT("Single line &entry\tCtrl-E")); + entry_menu->Append(DIALOGS_TEXT_ENTRY, wxT("Multi line text &entry\tShift-Ctrl-E")); entry_menu->Append(DIALOGS_PASSWORD_ENTRY, wxT("&Password entry\tCtrl-P")); #endif // wxUSE_TEXTDLG @@ -978,7 +980,7 @@ void MyFrame::PasswordEntry(wxCommandEvent& WXUNUSED(event)) } } -void MyFrame::TextEntry(wxCommandEvent& WXUNUSED(event)) +void MyFrame::LineEntry(wxCommandEvent& WXUNUSED(event)) { wxTextEntryDialog dialog(this, wxT("This is a small sample\n") @@ -992,6 +994,19 @@ void MyFrame::TextEntry(wxCommandEvent& WXUNUSED(event)) wxMessageBox(dialog.GetValue(), wxT("Got string"), wxOK | wxICON_INFORMATION, this); } } + +void MyFrame::TextEntry(wxCommandEvent& WXUNUSED(event)) +{ + wxTextEntryDialog dialog(this, "You can enter a multiline string here.", + "Please enter some text", + "First line\nSecond one\nAnd another one too", + wxOK | wxCANCEL | wxTE_MULTILINE); + + if (dialog.ShowModal() == wxID_OK) + { + wxMessageBox(dialog.GetValue(), wxT("Got text"), wxOK | wxICON_INFORMATION, this); + } +} #endif // wxUSE_TEXTDLG #if wxUSE_CHOICEDLG diff --git a/samples/dialogs/dialogs.h b/samples/dialogs/dialogs.h index 71a1f53b61..f70e173606 100644 --- a/samples/dialogs/dialogs.h +++ b/samples/dialogs/dialogs.h @@ -379,6 +379,7 @@ public: void Rearrange(wxCommandEvent& event); #if wxUSE_TEXTDLG + void LineEntry(wxCommandEvent& event); void TextEntry(wxCommandEvent& event); void PasswordEntry(wxCommandEvent& event); #endif // wxUSE_TEXTDLG @@ -534,6 +535,7 @@ enum DIALOGS_SINGLE_CHOICE, DIALOGS_MULTI_CHOICE, DIALOGS_REARRANGE, + DIALOGS_LINE_ENTRY, DIALOGS_TEXT_ENTRY, DIALOGS_PASSWORD_ENTRY, DIALOGS_FILE_OPEN, -- 2.47.2