Exploring zetcode wxwidget tutorial on Menus and Toolbars:Submenus

The I’m exploring here I got from the most excellent zetcode tutorial here.
This is actually starting to move faster now… I went through the example titled submenus..
The after going through the tutorial I had this question: Can you go beyond 3 levels. I messed around a little with menu.cpp/menu.h and found you can..

#include “menu.h”

SubMenu::SubMenu(const wxString& title)
: wxFrame(NULL, wxID_ANY, title, wxDefaultPosition, wxSize(280, 180))
{

menubar = new wxMenuBar;
file = new wxMenu;

//  file->Append(wxID_ANY, wxT(“&New”));
//  file->Append(wxID_ANY, wxT(“&Open”));
//  file->Append(wxID_ANY, wxT(“&Save”));

file->Append(wxID_NEW );
file->Append(wxID_OPEN);
file->Append(wxID_SAVE);

file->AppendSeparator();

imp = new wxMenu;
imp->Append(wxID_ANY, wxT(“Import newsfeed list…”));
imp->Append(wxID_ANY, wxT(“Import bookmarks…”));
imp->Append(wxID_ANY, wxT(“Import mail…”));

file->AppendSubMenu(imp, wxT(“I&mport”));

//See if we can keep going deeper
keepgoingtest = new wxMenu;
keepgoingtest->Append(ID_TESTTHIS,wxT(“Keep going”));
keepgoingtest->Append(wxID_ANY,wxT(“More Keep going”));
keepgoingtest->AppendSeparator();
keepgoingtest->Append(wxID_ANY,wxT(“Even More Keep going”));
keepgoingtest->Append(wxID_ANY,wxT(“Blah Blah and more Blah”));

imp->AppendSubMenu(keepgoingtest,wxT(“See if this works”));

//ID_TESTTHIS

quit = new wxMenuItem(file, wxID_EXIT, wxT(“&Quit\tCtrl+W”));
file->Append(quit);

menubar->Append(file, wxT(“&File”));
SetMenuBar(menubar);

Connect(wxID_EXIT, wxEVT_COMMAND_MENU_SELECTED,
wxCommandEventHandler(SubMenu::OnQuit));
Centre();

}

void SubMenu::OnQuit(wxCommandEvent& WXUNUSED(event))
{
Close(true);
}

This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *