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