]> git.saurik.com Git - wxWidgets.git/blob - samples/nativdlg/nativdlg.cpp
Removed unneeded FixUpMouse() method, some more GTK prefixing
[wxWidgets.git] / samples / nativdlg / nativdlg.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: samples/nativdlg/nativdlg.cpp
3 // Purpose: Native Windows dialog sample
4 // Author: Julian Smart
5 // Modified by:
6 // Created: 04/01/98
7 // RCS-ID: $Id$
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
11
12 // For compilers that support precompilation, includes "wx/wx.h".
13 #include "wx/wxprec.h"
14
15 #ifdef __BORLANDC__
16 #pragma hdrstop
17 #endif
18
19 #ifndef WX_PRECOMP
20 #include "wx/wx.h"
21 #endif
22
23 #ifndef __WXMSW__
24 #error Sorry, this sample is only appropriate under Windows.
25 #endif
26
27 #ifndef __WXMSW__
28 #include "../sample.xpm"
29 #endif
30
31 #include <ctype.h>
32 #include "nativdlg.h"
33 #include "resource.h"
34
35
36
37
38 IMPLEMENT_APP(MyApp)
39
40 bool MyApp::OnInit(void)
41 {
42 if ( !wxApp::OnInit() )
43 return false;
44
45 // Create the main frame window
46 MyFrame *frame = new MyFrame(NULL, wxID_ANY, _T("wxWidgets Native Dialog Sample"), wxPoint(0, 0), wxSize(300, 250));
47
48 #if wxUSE_STATUSBAR
49 // Give it a status line
50 frame->CreateStatusBar(2);
51 #endif // wxUSE_STATUSBAR
52
53 // Make a menubar
54 wxMenu *file_menu = new wxMenu;
55
56 file_menu->Append(RESOURCE_TEST1, _T("&Dialog box test"), _T("Test dialog box resource"));
57 file_menu->Append(RESOURCE_QUIT, _T("E&xit"), _T("Quit program"));
58
59 wxMenuBar *menu_bar = new wxMenuBar;
60
61 menu_bar->Append(file_menu, _T("&File"));
62
63 // Associate the menu bar with the frame
64 frame->SetMenuBar(menu_bar);
65
66 // Make a panel
67 frame->panel = new wxWindow(frame, wxID_ANY, wxPoint(0, 0), wxSize(400, 400), 0, _T("MyMainFrame"));
68 frame->Show(true);
69
70 // Return the main frame window
71 SetTopWindow(frame);
72
73 return true;
74 }
75
76 BEGIN_EVENT_TABLE(MyFrame, wxFrame)
77 EVT_MENU(RESOURCE_QUIT, MyFrame::OnQuit)
78 EVT_MENU(RESOURCE_TEST1, MyFrame::OnTest1)
79 END_EVENT_TABLE()
80
81 // Define my frame constructor
82 MyFrame::MyFrame(wxWindow *parent, const wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size):
83 wxFrame(parent, id, title, pos, size)
84 {
85 SetIcon(wxICON(sample));
86
87 panel = NULL;
88 }
89
90 void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
91 {
92 Close(true);
93 }
94
95 void MyFrame::OnTest1(wxCommandEvent& WXUNUSED(event))
96 {
97 #if ( defined(__WXPM__) || defined(__WXMSW__) ) && !defined(__WXUNIVERSAL__)
98 MyDialog dialog;
99 if (dialog.LoadNativeDialog(this, _T("dialog1")))
100 {
101 dialog.ShowModal();
102 }
103 #else
104 wxMessageBox(_T("No native dialog support"),_T("Platform limitation"));
105 #endif
106 }
107
108 BEGIN_EVENT_TABLE(MyDialog, wxDialog)
109 EVT_BUTTON(wxID_OK, MyDialog::OnOk)
110 EVT_BUTTON(wxID_CANCEL, MyDialog::OnCancel)
111 END_EVENT_TABLE()
112
113
114 void MyDialog::OnOk(wxCommandEvent& WXUNUSED(event))
115 {
116 EndModal(wxID_OK);
117 }
118
119 void MyDialog::OnCancel(wxCommandEvent& WXUNUSED(event))
120 {
121 EndModal(wxID_CANCEL);
122 }