]> git.saurik.com Git - wxWidgets.git/blob - samples/dynamic/minimal.cpp
Removed warnings mesgs
[wxWidgets.git] / samples / dynamic / minimal.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: minimal.cpp
3 // Purpose: Dynamic events wxWindows sample
4 // Author: Julian Smart
5 // Modified by:
6 // Created: 04/01/98
7 // RCS-ID: $Id$
8 // Copyright: (c) Julian Smart and Markus Holzem
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifdef __GNUG__
13 #pragma implementation "minimal.cpp"
14 #pragma interface "minimal.cpp"
15 #endif
16
17 // For compilers that support precompilation, includes "wx/wx.h".
18 #include "wx/wxprec.h"
19
20 #ifdef __BORLANDC__
21 #pragma hdrstop
22 #endif
23
24 #ifndef WX_PRECOMP
25 #include "wx/wx.h"
26 #endif
27
28 // Define a new application type
29 class MyApp: public wxApp
30 { public:
31 bool OnInit(void);
32 };
33
34 // Define a new frame type
35 class MyFrame: public wxFrame
36 { public:
37 MyFrame(wxFrame *frame, char *title, int x, int y, int w, int h);
38
39 public:
40 void OnQuit(wxCommandEvent& event);
41 void OnAbout(wxCommandEvent& event);
42 bool OnClose(void) { return TRUE; }
43 };
44
45 // ID for the menu commands
46 #define MINIMAL_QUIT 1
47 #define MINIMAL_TEXT 101
48 #define MINIMAL_ABOUT 102
49
50 // Create a new application object
51 IMPLEMENT_APP (MyApp)
52
53 // `Main program' equivalent, creating windows and returning main app frame
54 bool MyApp::OnInit(void)
55 {
56 // Create the main frame window
57 MyFrame *frame = new MyFrame(NULL, "Minimal wxWindows App", 50, 50, 450, 340);
58
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 );
61
62 // Give it an icon
63 #ifdef __WXMSW__
64 frame->SetIcon(wxIcon("mondrian"));
65 #endif
66 #ifdef __X__
67 frame->SetIcon(wxIcon("aiai.xbm"));
68 #endif
69
70 // Make a menubar
71 wxMenu *file_menu = new wxMenu;
72
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);
78
79 // Make a panel with a message
80 wxPanel *panel = new wxPanel(frame, -1, wxPoint(0, 0), wxSize(400, 200), wxTAB_TRAVERSAL);
81
82 wxStaticText *msg = new wxStaticText(panel, 311, "Hello!", wxPoint(10, 10), wxSize(-1, -1),
83 0);
84
85 // Show the frame
86 frame->Show(TRUE);
87
88 SetTopWindow(frame);
89
90 return TRUE;
91 }
92
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))
96 {}
97
98 void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event) )
99 {
100 Close(TRUE);
101 }
102
103 void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event) )
104 {
105 wxMessageDialog dialog(this, "This is a minimal sample\nA second line in the message box",
106 "About Minimal", wxYES_NO|wxCANCEL);
107
108 dialog.ShowModal();
109 }
110
111