]> git.saurik.com Git - wxWidgets.git/blame - samples/nativdlg/nativdlg.cpp
i18n files are installed as part of wxBase (and should be ideally part of separate...
[wxWidgets.git] / samples / nativdlg / nativdlg.cpp
CommitLineData
bbf1f0e5 1/////////////////////////////////////////////////////////////////////////////
cb7d7375 2// Name: samples/nativdlg/nativdlg.cpp
bbf1f0e5
KB
3// Purpose: Native Windows dialog sample
4// Author: Julian Smart
5// Modified by:
6// Created: 04/01/98
7// RCS-ID: $Id$
6aa89a22 8// Copyright: (c) Julian Smart
2f6c54eb 9// Licence: wxWindows license
bbf1f0e5
KB
10/////////////////////////////////////////////////////////////////////////////
11
bbf1f0e5
KB
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
acbd13a3
JS
23#ifndef __WXMSW__
24#error Sorry, this sample is only appropriate under Windows.
25#endif
26
bbf1f0e5
KB
27#include <ctype.h>
28#include "nativdlg.h"
29#include "resource.h"
30
bbf1f0e5
KB
31IMPLEMENT_APP(MyApp)
32
bbf1f0e5
KB
33bool MyApp::OnInit(void)
34{
35 // Create the main frame window
be5a51fb 36 MyFrame *frame = new MyFrame(NULL, wxID_ANY, _T("wxWidgets Native Dialog Sample"), wxPoint(0, 0), wxSize(300, 250));
bbf1f0e5 37
8520f137 38#if wxUSE_STATUSBAR
bbf1f0e5
KB
39 // Give it a status line
40 frame->CreateStatusBar(2);
8520f137 41#endif // wxUSE_STATUSBAR
bbf1f0e5
KB
42
43 // Make a menubar
44 wxMenu *file_menu = new wxMenu;
45
600683ca
MB
46 file_menu->Append(RESOURCE_TEST1, _T("&Dialog box test"), _T("Test dialog box resource"));
47 file_menu->Append(RESOURCE_QUIT, _T("E&xit"), _T("Quit program"));
bbf1f0e5
KB
48
49 wxMenuBar *menu_bar = new wxMenuBar;
50
600683ca 51 menu_bar->Append(file_menu, _T("&File"));
bbf1f0e5
KB
52
53 // Associate the menu bar with the frame
54 frame->SetMenuBar(menu_bar);
55
56 // Make a panel
1e79049d
VZ
57 frame->panel = new wxWindow(frame, wxID_ANY, wxPoint(0, 0), wxSize(400, 400), 0, _T("MyMainFrame"));
58 frame->Show(true);
bbf1f0e5
KB
59
60 // Return the main frame window
61 SetTopWindow(frame);
62
1e79049d 63 return true;
bbf1f0e5
KB
64}
65
66BEGIN_EVENT_TABLE(MyFrame, wxFrame)
2f6c54eb
VZ
67 EVT_MENU(RESOURCE_QUIT, MyFrame::OnQuit)
68 EVT_MENU(RESOURCE_TEST1, MyFrame::OnTest1)
bbf1f0e5
KB
69END_EVENT_TABLE()
70
71// Define my frame constructor
72MyFrame::MyFrame(wxWindow *parent, const wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size):
73 wxFrame(parent, id, title, pos, size)
74{
75 panel = NULL;
76}
77
1e79049d 78void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
bbf1f0e5 79{
1e79049d 80 Close(true);
bbf1f0e5
KB
81}
82
1e79049d 83void MyFrame::OnTest1(wxCommandEvent& WXUNUSED(event))
bbf1f0e5 84{
cb7d7375 85#if ( defined(__WXPM__) || defined(__WXMSW__) ) && !defined(__WXUNIVERSAL__)
a61fea41
WS
86 MyDialog dialog;
87 if (dialog.LoadNativeDialog(this, _T("dialog1")))
88 {
89 dialog.ShowModal();
90 }
1e79049d 91#else
a61fea41 92 wxMessageBox(_T("No native dialog support"),_T("Platform limitation"));
1e79049d 93#endif
bbf1f0e5
KB
94}
95
bbf1f0e5 96BEGIN_EVENT_TABLE(MyDialog, wxDialog)
2f6c54eb
VZ
97 EVT_BUTTON(wxID_OK, MyDialog::OnOk)
98 EVT_BUTTON(wxID_CANCEL, MyDialog::OnCancel)
bbf1f0e5
KB
99END_EVENT_TABLE()
100
101
1e79049d 102void MyDialog::OnOk(wxCommandEvent& WXUNUSED(event))
bbf1f0e5
KB
103{
104 EndModal(wxID_OK);
105}
106
1e79049d 107void MyDialog::OnCancel(wxCommandEvent& WXUNUSED(event))
bbf1f0e5
KB
108{
109 EndModal(wxID_CANCEL);
110}