]>
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
*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
; }
52 // ID for the menu commands
53 #define MINIMAL_QUIT 1
54 #define MINIMAL_TEXT 101
55 #define MINIMAL_ABOUT 102
57 BEGIN_EVENT_TABLE(MyFrame
, wxFrame
)
58 EVT_MENU(MINIMAL_QUIT
, MyFrame::OnQuit
)
59 EVT_MENU(MINIMAL_ABOUT
, MyFrame::OnAbout
)
62 // Create a new application object
65 // `Main program' equivalent, creating windows and returning main app frame
66 bool MyApp::OnInit(void)
68 // Create the main frame window
69 MyFrame
*frame
= new MyFrame(NULL
, "Minimal wxWindows App", 50, 50, 450, 340);
73 frame
->SetIcon(wxIcon("mondrian"));
76 frame
->SetIcon(wxIcon( mondrian_xpm
));
80 wxMenu
*file_menu
= new wxMenu
;
82 file_menu
->Append(MINIMAL_ABOUT
, "&About");
83 file_menu
->Append(MINIMAL_QUIT
, "E&xit");
84 wxMenuBar
*menu_bar
= new wxMenuBar
;
85 menu_bar
->Append(file_menu
, "&File");
86 frame
->SetMenuBar(menu_bar
);
88 // Make a panel with a message
89 wxPanel
*panel
= new wxPanel(frame
, -1, wxPoint(0, 0), wxSize(400, 200), wxTAB_TRAVERSAL
);
91 (void)new wxStaticText(panel
, 311, "Hello!", wxPoint(10, 10), wxSize(-1, -1), 0);
101 // My frame constructor
102 MyFrame::MyFrame(wxFrame
*frame
, char *title
, int x
, int y
, int w
, int h
):
103 wxFrame(frame
, -1, title
, wxPoint(x
, y
), wxSize(w
, h
))
106 void MyFrame::OnQuit(wxCommandEvent
& WXUNUSED(event
) )
111 void MyFrame::OnAbout(wxCommandEvent
& WXUNUSED(event
) )
113 wxMessageDialog
dialog(this, "This is a minimal sample\nA second line in the message box",
114 "About Minimal", wxYES_NO
|wxCANCEL
);