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