]> git.saurik.com Git - wxWidgets.git/blob - samples/wxtest/test.cpp
os2 distribution response file
[wxWidgets.git] / samples / wxtest / test.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: test.cpp
3 // Author: XX
4 // Created: XX/XX/XX
5 // Copyright:
6 /////////////////////////////////////////////////////////////////////////////
7
8 #ifdef __GNUG__
9 #pragma implementation "test.cpp"
10 #endif
11
12 // For compilers that support precompilation
13 #include "wx/wxprec.h"
14
15 #ifdef __BORLANDC__
16 #pragma hdrstop
17 #endif
18
19 // Include private headers
20 #include "test.h"
21
22 // WDR: class implementations
23
24 //----------------------------------------------------------------------------
25 // MyDialog
26 //----------------------------------------------------------------------------
27
28 // WDR: event table for MyDialog
29
30 BEGIN_EVENT_TABLE(MyDialog,wxDialog)
31 END_EVENT_TABLE()
32
33 MyDialog::MyDialog( wxWindow *parent, wxWindowID id, const wxString &title,
34 const wxPoint &position, const wxSize& size, long style ) :
35 wxDialog( parent, id, title, position, size, style|wxRESIZE_BORDER )
36 {
37 MyDialogFunc( this, TRUE );
38
39 CentreOnParent();
40 }
41
42 bool MyDialog::Validate()
43 {
44 return TRUE;
45 }
46
47 bool MyDialog::TransferDataToWindow()
48 {
49 return TRUE;
50 }
51
52 bool MyDialog::TransferDataFromWindow()
53 {
54 return TRUE;
55 }
56
57 // WDR: handler implementations for MyDialog
58
59
60 //------------------------------------------------------------------------------
61 // MyFrame
62 //------------------------------------------------------------------------------
63
64 // WDR: event table for MyFrame
65
66 BEGIN_EVENT_TABLE(MyFrame,wxFrame)
67 EVT_MENU(ID_ABOUT, MyFrame::OnAbout)
68 EVT_MENU(ID_QUIT, MyFrame::OnQuit)
69 EVT_CLOSE(MyFrame::OnCloseWindow)
70 EVT_MENU( ID_TEST, MyFrame::OnTest )
71 END_EVENT_TABLE()
72
73 MyFrame::MyFrame( wxWindow *parent, wxWindowID id, const wxString &title,
74 const wxPoint &position, const wxSize& size, long style ) :
75 wxFrame( parent, id, title, position, size, style )
76 {
77 CreateMyMenuBar();
78
79 CreateStatusBar(1);
80 SetStatusText( "Welcome!" );
81
82 // insert main window here
83 }
84
85 void MyFrame::CreateMyMenuBar()
86 {
87 #ifdef __WXMAC__
88 wxApp::s_macAboutMenuItemId = ID_ABOUT;
89 #endif
90
91 SetMenuBar( MyMenuBarFunc() );
92 }
93
94 // WDR: handler implementations for MyFrame
95
96 void MyFrame::OnTest( wxCommandEvent &event )
97 {
98 MyDialog dialog( this, -1, "Test" );
99 dialog.ShowModal();
100 }
101
102 void MyFrame::OnAbout( wxCommandEvent &event )
103 {
104 wxMessageDialog dialog( this, "Welcome to SuperApp 1.0\n(C)opyright Joe Hacker",
105 "About SuperApp", wxOK|wxICON_INFORMATION );
106 dialog.ShowModal();
107 }
108
109 void MyFrame::OnQuit( wxCommandEvent &event )
110 {
111 Close( TRUE );
112 }
113
114 void MyFrame::OnCloseWindow( wxCloseEvent &event )
115 {
116 // if ! saved changes -> return
117
118 Destroy();
119 }
120
121 //------------------------------------------------------------------------------
122 // MyApp
123 //------------------------------------------------------------------------------
124
125 IMPLEMENT_APP(MyApp)
126
127 MyApp::MyApp()
128 {
129 }
130
131 bool MyApp::OnInit()
132 {
133 MyFrame *frame = new MyFrame( NULL, -1, "SuperApp", wxPoint(20,20), wxSize(500,340) );
134 frame->Show( TRUE );
135
136 return TRUE;
137 }
138
139 int MyApp::OnExit()
140 {
141 return 0;
142 }
143