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.
This commit is contained in:
parent
db486eae2e
commit
16473d9b19
1 changed files with 21 additions and 28 deletions
|
|
@ -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"),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue