From 16473d9b1990c741b2f94f2d54c792ded1ab1171 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 11 Nov 2022 00:34:40 +0100 Subject: [PATCH] Make class used as template parameter local now that we can Address a minor TODO-C++11 comment in the dialogs sample by moving the class declaration into the function using it, now that we don't have to keep it outside it. This commit is best viewed with Git --color-moved option. --- samples/dialogs/dialogs.cpp | 49 ++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 28 deletions(-) diff --git a/samples/dialogs/dialogs.cpp b/samples/dialogs/dialogs.cpp index 8a69f341e6..8caebd18e3 100644 --- a/samples/dialogs/dialogs.cpp +++ b/samples/dialogs/dialogs.cpp @@ -3062,34 +3062,6 @@ wxBEGIN_EVENT_TABLE(TestDefaultActionDialog, wxDialog) EVT_TEXT_ENTER(wxID_ANY, TestDefaultActionDialog::OnTextEnter) wxEND_EVENT_TABLE() -// TODO-C++11: We can't declare this class inside TestDefaultActionDialog -// itself when using C++98, so we have to do it here instead. -namespace -{ - -// We have to define a new class in order to actually handle pressing -// Enter, if we didn't do it, pressing it would still close the dialog. -class EnterHandlingTextCtrl : public wxTextCtrl -{ -public: - EnterHandlingTextCtrl(wxWindow* parent, int id, const wxString& value) - : wxTextCtrl(parent, id, value, - wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER) - { - Bind(wxEVT_TEXT_ENTER, &EnterHandlingTextCtrl::OnEnter, this); - - SetInitialSize(GetSizeFromTextSize(GetTextExtent(value).x)); - } - -private: - void OnEnter(wxCommandEvent& WXUNUSED(event)) - { - wxLogMessage("Enter pressed"); - } -}; - -} // anonymous namespace - TestDefaultActionDialog::TestDefaultActionDialog( wxWindow *parent ) : wxDialog( parent, -1, "Test default action" ) { @@ -3117,6 +3089,27 @@ TestDefaultActionDialog::TestDefaultActionDialog( wxWindow *parent ) : grid_sizer->Add(new wxStaticText(this, wxID_ANY, "wxTextCtrl without wxTE_PROCESS_ENTER"), wxSizerFlags().CentreVertical()); + // We have to define a new class in order to actually handle pressing + // Enter, if we didn't do it, pressing it would still close the dialog. + class EnterHandlingTextCtrl : public wxTextCtrl + { + public: + EnterHandlingTextCtrl(wxWindow* parent, int id, const wxString& value) + : wxTextCtrl(parent, id, value, + wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER) + { + Bind(wxEVT_TEXT_ENTER, &EnterHandlingTextCtrl::OnEnter, this); + + SetInitialSize(GetSizeFromTextSize(GetTextExtent(value).x)); + } + + private: + void OnEnter(wxCommandEvent& WXUNUSED(event)) + { + wxLogMessage("Enter pressed"); + } + }; + grid_sizer->Add(new EnterHandlingTextCtrl(this, wxID_ANY, "Enter here is handled by the application"), wxSizerFlags().CentreVertical()); grid_sizer->Add(new wxStaticText(this, wxID_ANY, "wxTextCtrl with wxTE_PROCESS_ENTER"),