1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Dynamic events wxWindows sample
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart and Markus Holzem
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "minimal.cpp"
14 #pragma interface "minimal.cpp"
17 // For compilers that support precompilation, includes "wx/wx.h".
18 #include "wx/wxprec.h"
28 // Define a new application type
29 class MyApp
: public wxApp
34 // Define a new frame type
35 class MyFrame
: public wxFrame
37 MyFrame(wxFrame
*frame
, char *title
, int x
, int y
, int w
, int h
);
40 void OnQuit(wxCommandEvent
& event
);
41 void OnAbout(wxCommandEvent
& event
);
42 bool OnClose(void) { return TRUE
; }
45 // ID for the menu commands
46 #define MINIMAL_QUIT 1
47 #define MINIMAL_TEXT 101
48 #define MINIMAL_ABOUT 102
50 // Create a new application object
53 // `Main program' equivalent, creating windows and returning main app frame
54 bool MyApp::OnInit(void)
56 // Create the main frame window
57 MyFrame
*frame
= new MyFrame(NULL
, "Minimal wxWindows App", 50, 50, 450, 340);
59 frame
->Connect( MINIMAL_QUIT
, -1, wxEVT_COMMAND_MENU_SELECTED
, (wxObjectEventFunction
)MyFrame::OnQuit
);
60 frame
->Connect( MINIMAL_ABOUT
, -1, wxEVT_COMMAND_MENU_SELECTED
, (wxObjectEventFunction
)MyFrame::OnAbout
);
64 frame
->SetIcon(wxIcon("mondrian"));
67 frame
->SetIcon(wxIcon("aiai.xbm"));
71 wxMenu
*file_menu
= new wxMenu
;
73 file_menu
->Append(MINIMAL_ABOUT
, "&About");
74 file_menu
->Append(MINIMAL_QUIT
, "E&xit");
75 wxMenuBar
*menu_bar
= new wxMenuBar
;
76 menu_bar
->Append(file_menu
, "&File");
77 frame
->SetMenuBar(menu_bar
);
79 // Make a panel with a message
80 wxPanel
*panel
= new wxPanel(frame
, -1, wxPoint(0, 0), wxSize(400, 200), wxTAB_TRAVERSAL
);
82 wxStaticText
*msg
= new wxStaticText(panel
, 311, "Hello!", wxPoint(10, 10), wxSize(-1, -1),
93 // My frame constructor
94 MyFrame::MyFrame(wxFrame
*frame
, char *title
, int x
, int y
, int w
, int h
):
95 wxFrame(frame
, -1, title
, wxPoint(x
, y
), wxSize(w
, h
))
98 void MyFrame::OnQuit(wxCommandEvent
& event
)
103 void MyFrame::OnAbout(wxCommandEvent
& event
)
105 wxMessageDialog
dialog(this, "This is a minimal sample\nA second line in the message box",
106 "About Minimal", wxYES_NO
|wxCANCEL
);