01: #include <wx/wx.h>
02: 
03: const int ID_SAY_HELLO = 1000;
04: const int ID_SAY_GOODBYE = 1001;
05: 
06: /**
07:    A frame with a simple menu and a text control.
08: */
09: class MenuFrame : public wxFrame
10: {
11: public:
12:    /**
13:       Constructs the menu and text control.
14:    */
15:    MenuFrame();
16: private:
17:    wxTextCtrl* text;
18: };
19: 
20: /**
21:    An application with a frame that has a menu and text control.
22: */
23: class MenuApp : public wxApp
24: {
25: public:
26:    /**
27:       Constructs the frame.
28:    */
29:    MenuApp();
30:    /**
31:       Shows the frame.
32:       @return true
33:    */
34:    virtual bool OnInit();
35: private:
36:    MenuFrame* frame;
37: };
38: 
39: DECLARE_APP(MenuApp)
40: 
41: IMPLEMENT_APP(MenuApp)
42: 
43: MenuFrame::MenuFrame() 
44:    : wxFrame(NULL, -1, "MenuFrame")
45: {
46:    text = new wxTextCtrl(this, -1, "",
47:       wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE);
48: 
49:    // initialize menu
50:    wxMenu* menu = new wxMenu();
51:    menu->Append(ID_SAY_HELLO, "Hello");
52:    menu->Append(ID_SAY_GOODBYE, "Goodbye");
53: 
54:    // add menu to menu bar
55:    wxMenuBar* menu_bar = new wxMenuBar();
56:    SetMenuBar(menu_bar);
57:    menu_bar->Append(menu, "Say");   
58: }
59: 
60: MenuApp::MenuApp()
61: {
62:    frame = new MenuFrame();
63: }
64: 
65: bool MenuApp::OnInit()
66: {
67:    frame->Show(true);
68:    return true;
69: }