]>
git.saurik.com Git - wxWidgets.git/blob - samples/minimal/minimal.cpp
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Minimal 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
*parent
, const wxString
& title
,
42 const wxPoint
& pos
, const wxSize
& size
);
45 void OnQuit(wxCommandEvent
& event
);
46 void OnAbout(wxCommandEvent
& event
);
47 bool OnClose(void) { return TRUE
; }
53 // ID for the menu commands
54 #define MINIMAL_QUIT 1
55 #define MINIMAL_TEXT 101
56 #define MINIMAL_ABOUT 102
58 BEGIN_EVENT_TABLE(MyFrame
, wxFrame
)
59 EVT_MENU(MINIMAL_QUIT
, MyFrame::OnQuit
)
60 EVT_MENU(MINIMAL_ABOUT
, MyFrame::OnAbout
)
63 // Create a new application object
66 // `Main program' equivalent
67 bool MyApp::OnInit(void)
69 // Create the main frame window
70 MyFrame
*frame
= new MyFrame((wxFrame
*) NULL
, "Minimal wxWindows App",
71 wxPoint(50, 50), wxSize(450, 340));
74 frame
->SetIcon(wxICON(mondrian
));
77 wxMenu
*file_menu
= new wxMenu
;
79 file_menu
->Append(MINIMAL_ABOUT
, "&About");
80 file_menu
->Append(MINIMAL_QUIT
, "E&xit");
81 wxMenuBar
*menu_bar
= new wxMenuBar
;
82 menu_bar
->Append(file_menu
, "&File");
83 frame
->SetMenuBar(menu_bar
);
85 // Make a panel with a message
86 wxPanel
*panel
= new wxPanel(frame
, -1, wxPoint(0, 0), wxSize(400, 200), wxTAB_TRAVERSAL
);
88 (void)new wxStaticText(panel
, 311, "Hello!", wxPoint(10, 10), wxSize(-1, -1), 0);
98 // My frame constructor
99 MyFrame::MyFrame(wxFrame
*parent
, const wxString
& title
,
100 const wxPoint
& pos
, const wxSize
& size
):
101 wxFrame(parent
, -1, title
, pos
, size
)
104 void MyFrame::OnQuit(wxCommandEvent
& WXUNUSED(event
) )
109 void MyFrame::OnAbout(wxCommandEvent
& WXUNUSED(event
) )
111 wxMessageDialog
dialog(this, "This is a minimal sample\nA second line in the message box",
112 "About Minimal", wxYES_NO
|wxCANCEL
);