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"
29 #include "mondrian.xpm"
32 // Define a new application type
33 class MyApp
: public wxApp
38 // Define a new frame type
39 class MyFrame
: public wxFrame
41 MyFrame(wxFrame
*frame
, char *title
, int x
, int y
, int w
, int h
);
44 void OnQuit(wxCommandEvent
& event
);
45 void OnAbout(wxCommandEvent
& event
);
46 bool OnClose(void) { return TRUE
; }
49 // ID for the menu commands
50 #define MINIMAL_QUIT 1
51 #define MINIMAL_TEXT 101
52 #define MINIMAL_ABOUT 102
54 // Create a new application object
57 // `Main program' equivalent, creating windows and returning main app frame
58 bool MyApp::OnInit(void)
60 // Create the main frame window
61 MyFrame
*frame
= new MyFrame(NULL
, "Minimal wxWindows App", 50, 50, 450, 340);
63 frame
->Connect( MINIMAL_QUIT
, -1, wxEVT_COMMAND_MENU_SELECTED
, (wxObjectEventFunction
)MyFrame::OnQuit
);
64 frame
->Connect( MINIMAL_ABOUT
, -1, wxEVT_COMMAND_MENU_SELECTED
, (wxObjectEventFunction
)MyFrame::OnAbout
);
68 frame
->SetIcon(wxIcon("mondrian"));
70 frame
->SetIcon(wxIcon(mondrian_xpm
));
74 wxMenu
*file_menu
= new wxMenu
;
76 file_menu
->Append(MINIMAL_ABOUT
, "&About");
77 file_menu
->Append(MINIMAL_QUIT
, "E&xit");
78 wxMenuBar
*menu_bar
= new wxMenuBar
;
79 menu_bar
->Append(file_menu
, "&File");
80 frame
->SetMenuBar(menu_bar
);
82 // Make a panel with a message
83 wxPanel
*panel
= new wxPanel(frame
, -1, wxPoint(0, 0), wxSize(400, 200), wxTAB_TRAVERSAL
);
85 (void)new wxStaticText(panel
, 311, "Hello!", wxPoint(10, 10), wxSize(-1, -1), 0);
95 // My frame constructor
96 MyFrame::MyFrame(wxFrame
*frame
, char *title
, int x
, int y
, int w
, int h
):
97 wxFrame(frame
, -1, title
, wxPoint(x
, y
), wxSize(w
, h
))
100 void MyFrame::OnQuit(wxCommandEvent
& WXUNUSED(event
) )
105 void MyFrame::OnAbout(wxCommandEvent
& WXUNUSED(event
) )
107 wxMessageDialog
dialog(this, "This is a minimal sample\nA second line in the message box",
108 "About Minimal", wxYES_NO
|wxCANCEL
);