I've been learning wxWidgets and C++ together, and it's been super exciting. I've been consuming all the online tutorials I can find, and have purchased and am reading the book as well. I'm well aware that many of the tutorials (and the book) are outdated, so part of my learning is to bring the examples up to current practice.
I've converted the "Your First App" tutorial on the wxwidgets wiki to use dynamic Bind() instead of the event table, for instance, and have updated references to wxEVT_COMMAND_MENU_SELECTED to the newer and preferred wxEVT_MENU:
Code: Select all
MyFrame::MyFrame(const wxString &title) : wxFrame(nullptr, wxID_ANY, title) {
MainMenu = new wxMenuBar();
wxMenu *FileMenu = new wxMenu;
MainMenu->Append(FileMenu, _T("File"));
SetMenuBar(MainMenu);
CreateStatusBar(1);
FileMenu->Append(MENU_New, _T("&New"), _T("Create a new file"));
FileMenu->Append(MENU_Open, _T("&Open"), _T("Open an existing file"));
FileMenu->Append(MENU_Close, _T("&Close"), _T("Close the current document"));
FileMenu->Append(MENU_Save, _T("&Save"), _T("Save the current document"));
FileMenu->Append(MENU_SaveAs, _T("Save &As"), _T("Save current document with new name"));
FileMenu->Append(MENU_Quit, _T("&Quit"), _T("Quit the editor"));
Bind(wxEVT_MENU, &MyFrame::NewFile, this, MENU_New);
Bind(wxEVT_MENU, &MyFrame::OpenFile, this, MENU_Open);
Bind(wxEVT_MENU, &MyFrame::CloseFile, this, MENU_Close);
Bind(wxEVT_MENU, &MyFrame::SaveFile, this, MENU_Save);
Bind(wxEVT_MENU, &MyFrame::SaveAsFile, this, MENU_SaveAs);
Bind(wxEVT_MENU, &MyFrame::Quit, this, MENU_Quit);
MainEditBox = new wxTextCtrl(this, TEXT_Main, _T("Hi!\n"), wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE | wxTE_RICH | wxNO_BORDER, wxDefaultValidator, wxTextCtrlNameStr);
}
Can anybody offer me a tantalizing tip or two on how I might accomplish this? Thank you in advance.