]> git.saurik.com Git - wxWidgets.git/blob - samples/nativdlg/nativdlg.cpp
wxFrame::CreateToolBar() stuff
[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 and Markus Holzem
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 #include "wx/resource.h"
28
29 #include <ctype.h>
30 #include "nativdlg.h"
31 #include "resource.h"
32
33 // Declare two frames
34 MyFrame *frame = NULL;
35
36 IMPLEMENT_APP(MyApp)
37
38 // Testing of ressources
39 MyApp::MyApp()
40 {
41 }
42
43 bool MyApp::OnInit(void)
44 {
45 // Create the main frame window
46 frame = new MyFrame(NULL, -1, "wxWindows Native Dialog Sample", wxPoint(0, 0), wxSize(300, 250));
47
48 // Give it a status line
49 frame->CreateStatusBar(2);
50
51 // Make a menubar
52 wxMenu *file_menu = new wxMenu;
53
54 file_menu->Append(RESOURCE_TEST1, "&Dialog box test", "Test dialog box resource");
55 file_menu->Append(RESOURCE_QUIT, "E&xit", "Quit program");
56
57 wxMenuBar *menu_bar = new wxMenuBar;
58
59 menu_bar->Append(file_menu, "&File");
60
61 // Associate the menu bar with the frame
62 frame->SetMenuBar(menu_bar);
63
64 // Make a panel
65 frame->panel = new wxWindow(frame, -1, wxPoint(0, 0), wxSize(400, 400), 0, "MyMainFrame");
66 frame->Show(TRUE);
67
68 // Return the main frame window
69 SetTopWindow(frame);
70
71 return TRUE;
72 }
73
74 BEGIN_EVENT_TABLE(MyFrame, wxFrame)
75 EVT_MENU(RESOURCE_QUIT, MyFrame::OnQuit)
76 EVT_MENU(RESOURCE_TEST1, MyFrame::OnTest1)
77 END_EVENT_TABLE()
78
79 // Define my frame constructor
80 MyFrame::MyFrame(wxWindow *parent, const wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size):
81 wxFrame(parent, id, title, pos, size)
82 {
83 panel = NULL;
84 }
85
86 void MyFrame::OnQuit(wxCommandEvent& event)
87 {
88 Close(TRUE);
89 }
90
91 void MyFrame::OnTest1(wxCommandEvent& event)
92 {
93 MyDialog *dialog = new MyDialog;
94 if (dialog->LoadNativeDialog(this, dialog1))
95 {
96 /*
97 wxTextCtrl *text = (wxTextCtrl *)wxFindWindowByName("multitext3", dialog);
98 if (text)
99 text->SetValue("wxWindows resource demo");
100 */
101 dialog->SetModal(TRUE);
102 dialog->ShowModal();
103 }
104 dialog->Close(TRUE);
105 }
106
107 bool MyFrame::OnClose(void)
108 {
109 Show(FALSE);
110
111 return TRUE;
112 }
113
114 BEGIN_EVENT_TABLE(MyDialog, wxDialog)
115 EVT_BUTTON(wxID_OK, MyDialog::OnOk)
116 EVT_BUTTON(wxID_CANCEL, MyDialog::OnCancel)
117 END_EVENT_TABLE()
118
119
120 void MyDialog::OnOk(wxCommandEvent& event)
121 {
122 EndModal(wxID_OK);
123 }
124
125 void MyDialog::OnCancel(wxCommandEvent& event)
126 {
127 EndModal(wxID_CANCEL);
128 }
129
130