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