]>
Commit | Line | Data |
---|---|---|
457814b5 JS |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: dialogs.cpp | |
3 | // Purpose: Common dialogs demo | |
4 | // Author: Julian Smart | |
695fe764 | 5 | // Modified by: ABX (2004) - adjustements for conditional building + new menu |
457814b5 JS |
6 | // Created: 04/01/98 |
7 | // RCS-ID: $Id$ | |
6aa89a22 | 8 | // Copyright: (c) Julian Smart |
c50f1fb9 | 9 | // Licence: wxWindows license |
457814b5 JS |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
a7166b34 | 12 | #if defined(__GNUG__) && !defined(__APPLE__) |
457814b5 JS |
13 | #pragma implementation |
14 | #pragma interface | |
15 | #endif | |
16 | ||
17 | // For compilers that support precompilation, includes "wx/wx.h". | |
18 | #include "wx/wxprec.h" | |
19 | ||
20 | #ifdef __BORLANDC__ | |
21 | #pragma hdrstop | |
22 | #endif | |
23 | ||
24 | #ifndef WX_PRECOMP | |
25 | #include "wx/wx.h" | |
26 | #endif | |
27 | ||
0f5d8ecf JS |
28 | #include "../sample.xpm" |
29 | ||
fb8a56b7 | 30 | #include "wx/datetime.h" |
f517634c | 31 | #include "wx/image.h" |
457814b5 | 32 | |
13188def WS |
33 | #if wxUSE_COLOURDLG |
34 | #include "wx/colordlg.h" | |
35 | #endif // wxUSE_COLOURDLG | |
dfad0599 | 36 | |
13188def WS |
37 | #if wxUSE_CHOICEDLG |
38 | #include "wx/choicdlg.h" | |
39 | #endif // wxUSE_CHOICEDLG | |
457814b5 | 40 | |
13188def WS |
41 | #if wxUSE_STARTUP_TIPS |
42 | #include "wx/tipdlg.h" | |
43 | #endif // wxUSE_STARTUP_TIPS | |
d7d17624 | 44 | |
13188def | 45 | #if wxUSE_PROGRESSDLG |
9b16ffef VZ |
46 | #if wxUSE_STOPWATCH && wxUSE_LONGLONG |
47 | #include <wx/datetime.h> // wxDateTime | |
48 | #endif | |
49 | ||
13188def WS |
50 | #include "wx/progdlg.h" |
51 | #endif // wxUSE_PROGRESSDLG | |
52 | ||
53 | #if wxUSE_BUSYINFO | |
54 | #include "wx/busyinfo.h" | |
55 | #endif // wxUSE_BUSYINFO | |
56 | ||
57 | #if wxUSE_NUMBERDLG | |
58 | #include "wx/numdlg.h" | |
59 | #endif // wxUSE_NUMBERDLG | |
60 | ||
61 | #if wxUSE_FILEDLG | |
62 | #include "wx/filedlg.h" | |
63 | #endif // wxUSE_FILEDLG | |
64 | ||
65 | #if wxUSE_DIRDLG | |
66 | #include "wx/dirdlg.h" | |
67 | #endif // wxUSE_DIRDLG | |
68 | ||
69 | #if wxUSE_FONTDLG | |
70 | #include "wx/fontdlg.h" | |
71 | #endif // wxUSE_FONTDLG | |
72 | ||
73 | #if wxUSE_FINDREPLDLG | |
74 | #include "wx/fdrepdlg.h" | |
75 | #endif // wxUSE_FINDREPLDLG | |
4ad3c82f | 76 | |
62675ef3 | 77 | #if wxUSE_SPINCTRL |
0f5d8ecf | 78 | #include "wx/spinctrl.h" |
62675ef3 JS |
79 | #endif |
80 | ||
0f5d8ecf JS |
81 | #include "wx/propdlg.h" |
82 | ||
457814b5 JS |
83 | #include "dialogs.h" |
84 | ||
13188def WS |
85 | #if USE_COLOURDLG_GENERIC |
86 | #include "wx/generic/colrdlgg.h" | |
87 | #endif // USE_COLOURDLG_GENERIC | |
88 | ||
13188def WS |
89 | #if USE_DIRDLG_GENERIC |
90 | #include "wx/generic/dirdlgg.h" | |
91 | #endif // USE_DIRDLG_GENERIC | |
92 | ||
695fe764 WS |
93 | #if USE_FILEDLG_GENERIC |
94 | #include "wx/generic/filedlgg.h" | |
95 | #endif // USE_FILEDLG_GENERIC | |
96 | ||
97 | #if USE_FONTDLG_GENERIC | |
98 | #include "wx/generic/fontdlgg.h" | |
99 | #endif // USE_FONTDLG_GENERIC | |
100 | ||
457814b5 JS |
101 | IMPLEMENT_APP(MyApp) |
102 | ||
4c45f240 VZ |
103 | BEGIN_EVENT_TABLE(MyCanvas, wxScrolledWindow) |
104 | EVT_PAINT(MyCanvas::OnPaint) | |
105 | END_EVENT_TABLE() | |
106 | ||
13188def WS |
107 | |
108 | ||
4c45f240 | 109 | BEGIN_EVENT_TABLE(MyFrame, wxFrame) |
13188def WS |
110 | EVT_MENU(DIALOGS_MESSAGE_BOX, MyFrame::MessageBox) |
111 | ||
112 | #if wxUSE_COLOURDLG | |
4c45f240 | 113 | EVT_MENU(DIALOGS_CHOOSE_COLOUR, MyFrame::ChooseColour) |
13188def WS |
114 | #endif // wxUSE_COLOURDLG |
115 | ||
116 | #if wxUSE_FONTDLG | |
4c45f240 | 117 | EVT_MENU(DIALOGS_CHOOSE_FONT, MyFrame::ChooseFont) |
13188def WS |
118 | #endif // wxUSE_FONTDLG |
119 | ||
120 | #if wxUSE_LOG_DIALOG | |
4c45f240 | 121 | EVT_MENU(DIALOGS_LOG_DIALOG, MyFrame::LogDialog) |
13188def WS |
122 | #endif // wxUSE_LOG_DIALOG |
123 | ||
124 | #if wxUSE_TEXTDLG | |
4c45f240 VZ |
125 | EVT_MENU(DIALOGS_TEXT_ENTRY, MyFrame::TextEntry) |
126 | EVT_MENU(DIALOGS_PASSWORD_ENTRY, MyFrame::PasswordEntry) | |
13188def WS |
127 | #endif // wxUSE_TEXTDLG |
128 | ||
129 | #if wxUSE_NUMBERDLG | |
4c45f240 | 130 | EVT_MENU(DIALOGS_NUM_ENTRY, MyFrame::NumericEntry) |
13188def WS |
131 | #endif // wxUSE_NUMBERDLG |
132 | ||
133 | #if wxUSE_CHOICEDLG | |
4c45f240 | 134 | EVT_MENU(DIALOGS_SINGLE_CHOICE, MyFrame::SingleChoice) |
d6c9c1b7 | 135 | EVT_MENU(DIALOGS_MULTI_CHOICE, MyFrame::MultiChoice) |
13188def WS |
136 | #endif // wxUSE_CHOICEDLG |
137 | ||
138 | #if wxUSE_FILEDLG | |
4c45f240 | 139 | EVT_MENU(DIALOGS_FILE_OPEN, MyFrame::FileOpen) |
35b45b33 | 140 | EVT_MENU(DIALOGS_FILE_OPEN2, MyFrame::FileOpen2) |
4c45f240 VZ |
141 | EVT_MENU(DIALOGS_FILES_OPEN, MyFrame::FilesOpen) |
142 | EVT_MENU(DIALOGS_FILE_SAVE, MyFrame::FileSave) | |
13188def WS |
143 | #endif // wxUSE_FILEDLG |
144 | ||
695fe764 WS |
145 | #if USE_FILEDLG_GENERIC |
146 | EVT_MENU(DIALOGS_FILE_OPEN_GENERIC, MyFrame::FileOpenGeneric) | |
147 | EVT_MENU(DIALOGS_FILES_OPEN_GENERIC, MyFrame::FilesOpenGeneric) | |
148 | EVT_MENU(DIALOGS_FILE_SAVE_GENERIC, MyFrame::FileSaveGeneric) | |
149 | #endif // USE_FILEDLG_GENERIC | |
150 | ||
13188def | 151 | #if wxUSE_DIRDLG |
4c45f240 | 152 | EVT_MENU(DIALOGS_DIR_CHOOSE, MyFrame::DirChoose) |
f09c8393 | 153 | EVT_MENU(DIALOGS_DIRNEW_CHOOSE, MyFrame::DirChooseNew) |
13188def WS |
154 | #endif // wxUSE_DIRDLG |
155 | ||
156 | #if USE_MODAL_PRESENTATION | |
f6bcfd97 | 157 | EVT_MENU(DIALOGS_MODAL, MyFrame::ModalDlg) |
4c45f240 | 158 | EVT_MENU(DIALOGS_MODELESS, MyFrame::ModelessDlg) |
13188def WS |
159 | #endif // USE_MODAL |
160 | ||
161 | #if wxUSE_STARTUP_TIPS | |
4c45f240 | 162 | EVT_MENU(DIALOGS_TIP, MyFrame::ShowTip) |
13188def WS |
163 | #endif // wxUSE_STARTUP_TIPS |
164 | ||
165 | #if USE_FONTDLG_GENERIC | |
4c45f240 | 166 | EVT_MENU(DIALOGS_CHOOSE_FONT_GENERIC, MyFrame::ChooseFontGeneric) |
13188def WS |
167 | #endif // USE_FONTDLG_GENERIC |
168 | ||
169 | #if USE_DIRDLG_GENERIC | |
170 | EVT_MENU(DIALOGS_GENERIC_DIR_CHOOSE, MyFrame::GenericDirChoose) | |
171 | #endif // wxMSW || wxMAC | |
172 | ||
173 | #if USE_COLOURDLG_GENERIC | |
174 | EVT_MENU(DIALOGS_CHOOSE_COLOUR_GENERIC, MyFrame::ChooseColourGeneric) | |
175 | #endif // USE_COLOURDLG_GENERIC | |
a62b0bcc | 176 | |
abceee76 VZ |
177 | #if wxUSE_PROGRESSDLG |
178 | EVT_MENU(DIALOGS_PROGRESS, MyFrame::ShowProgress) | |
761989ff | 179 | #endif // wxUSE_PROGRESSDLG |
a62b0bcc VZ |
180 | |
181 | #if wxUSE_BUSYINFO | |
182 | EVT_MENU(DIALOGS_BUSYINFO, MyFrame::ShowBusyInfo) | |
183 | #endif // wxUSE_BUSYINFO | |
184 | ||
761989ff VZ |
185 | #if wxUSE_FINDREPLDLG |
186 | EVT_MENU(DIALOGS_FIND, MyFrame::ShowFindDialog) | |
187 | EVT_MENU(DIALOGS_REPLACE, MyFrame::ShowReplaceDialog) | |
188 | ||
13188def WS |
189 | EVT_FIND(wxID_ANY, MyFrame::OnFindDialog) |
190 | EVT_FIND_NEXT(wxID_ANY, MyFrame::OnFindDialog) | |
191 | EVT_FIND_REPLACE(wxID_ANY, MyFrame::OnFindDialog) | |
192 | EVT_FIND_REPLACE_ALL(wxID_ANY, MyFrame::OnFindDialog) | |
193 | EVT_FIND_CLOSE(wxID_ANY, MyFrame::OnFindDialog) | |
761989ff | 194 | #endif // wxUSE_FINDREPLDLG |
13188def | 195 | |
0f5d8ecf JS |
196 | EVT_MENU(DIALOGS_PROPERTY_SHEET, MyFrame::OnPropertySheet) |
197 | EVT_MENU(DIALOGS_REQUEST, MyFrame::OnRequestUserAttention) | |
9b16ffef | 198 | |
4c45f240 | 199 | EVT_MENU(wxID_EXIT, MyFrame::OnExit) |
4c45f240 | 200 | END_EVENT_TABLE() |
abceee76 | 201 | |
13188def | 202 | #if USE_MODAL_PRESENTATION |
f6bcfd97 | 203 | |
13188def WS |
204 | BEGIN_EVENT_TABLE(MyModalDialog, wxDialog) |
205 | EVT_BUTTON(wxID_ANY, MyModalDialog::OnButton) | |
206 | END_EVENT_TABLE() | |
5d987909 | 207 | |
13188def WS |
208 | BEGIN_EVENT_TABLE(MyModelessDialog, wxDialog) |
209 | EVT_BUTTON(DIALOGS_MODELESS_BTN, MyModelessDialog::OnButton) | |
210 | EVT_CLOSE(MyModelessDialog::OnClose) | |
211 | END_EVENT_TABLE() | |
212 | ||
213 | #endif // USE_MODAL_PRESENTATION | |
abceee76 | 214 | |
c67daf87 | 215 | MyCanvas *myCanvas = (MyCanvas *) NULL; |
457814b5 | 216 | |
457814b5 | 217 | // `Main program' equivalent, creating windows and returning main app frame |
4c45f240 | 218 | bool MyApp::OnInit() |
457814b5 | 219 | { |
f517634c | 220 | #if wxUSE_IMAGE |
013e1fee | 221 | wxInitAllImageHandlers(); |
f517634c | 222 | #endif |
013e1fee | 223 | |
13188def WS |
224 | m_canvasTextColour = wxColour(_T("BLACK")); |
225 | m_canvasFont = *wxNORMAL_FONT; | |
457814b5 | 226 | |
13188def WS |
227 | // Create the main frame window |
228 | MyFrame *frame = new MyFrame((wxFrame *) NULL, _T("wxWidgets dialogs example")); | |
457814b5 | 229 | |
13188def WS |
230 | // Make a menubar |
231 | wxMenu *file_menu = new wxMenu; | |
dabbc6a5 | 232 | |
13188def | 233 | file_menu->Append(DIALOGS_MESSAGE_BOX, _T("&Message box\tCtrl-M")); |
457814b5 | 234 | |
457814b5 | 235 | |
33bcca32 | 236 | #if wxUSE_COLOURDLG || wxUSE_FONTDLG || wxUSE_CHOICEDLG |
f09c8393 | 237 | |
33bcca32 | 238 | wxMenu *choices_menu = new wxMenu; |
f09c8393 | 239 | |
33bcca32 VZ |
240 | #if wxUSE_COLOURDLG |
241 | choices_menu->Append(DIALOGS_CHOOSE_COLOUR, _T("&Choose colour")); | |
242 | #endif // wxUSE_COLOURDLG | |
f09c8393 | 243 | |
33bcca32 VZ |
244 | #if wxUSE_FONTDLG |
245 | choices_menu->Append(DIALOGS_CHOOSE_FONT, _T("Choose &font")); | |
246 | #endif // wxUSE_FONTDLG | |
457814b5 | 247 | |
33bcca32 VZ |
248 | #if wxUSE_CHOICEDLG |
249 | choices_menu->Append(DIALOGS_SINGLE_CHOICE, _T("&Single choice\tCtrl-C")); | |
250 | choices_menu->Append(DIALOGS_MULTI_CHOICE, _T("M&ultiple choice\tCtrl-U")); | |
251 | #endif // wxUSE_CHOICEDLG | |
695fe764 | 252 | |
33bcca32 VZ |
253 | #if USE_COLOURDLG_GENERIC || USE_FONTDLG_GENERIC |
254 | choices_menu->AppendSeparator(); | |
255 | #endif // USE_COLOURDLG_GENERIC || USE_FONTDLG_GENERIC | |
695fe764 | 256 | |
33bcca32 VZ |
257 | #if USE_COLOURDLG_GENERIC |
258 | choices_menu->Append(DIALOGS_CHOOSE_COLOUR_GENERIC, _T("&Choose colour (generic)")); | |
259 | #endif // USE_COLOURDLG_GENERIC | |
695fe764 | 260 | |
33bcca32 VZ |
261 | #if USE_FONTDLG_GENERIC |
262 | choices_menu->Append(DIALOGS_CHOOSE_FONT_GENERIC, _T("Choose &font (generic)")); | |
263 | #endif // USE_FONTDLG_GENERIC | |
d93c719a | 264 | |
33bcca32 VZ |
265 | file_menu->Append(wxID_ANY,_T("&Choices and selectors"),choices_menu); |
266 | #endif // wxUSE_COLOURDLG || wxUSE_FONTDLG || wxUSE_CHOICEDLG | |
457814b5 | 267 | |
457814b5 | 268 | |
33bcca32 | 269 | #if wxUSE_TEXTDLG || wxUSE_NUMBERDLG |
13188def | 270 | |
33bcca32 | 271 | wxMenu *entry_menu = new wxMenu; |
13188def | 272 | |
33bcca32 VZ |
273 | #if wxUSE_TEXTDLG |
274 | entry_menu->Append(DIALOGS_TEXT_ENTRY, _T("Text &entry\tCtrl-E")); | |
275 | entry_menu->Append(DIALOGS_PASSWORD_ENTRY, _T("&Password entry\tCtrl-P")); | |
276 | #endif // wxUSE_TEXTDLG | |
13188def | 277 | |
33bcca32 VZ |
278 | #if wxUSE_NUMBERDLG |
279 | entry_menu->Append(DIALOGS_NUM_ENTRY, _T("&Numeric entry\tCtrl-N")); | |
280 | #endif // wxUSE_NUMBERDLG | |
13188def | 281 | |
33bcca32 | 282 | file_menu->Append(wxID_ANY,_T("&Entry dialogs"),entry_menu); |
13188def | 283 | |
33bcca32 | 284 | #endif // wxUSE_TEXTDLG || wxUSE_NUMBERDLG |
13188def WS |
285 | |
286 | ||
33bcca32 | 287 | #if wxUSE_FILEDLG |
13188def | 288 | |
33bcca32 VZ |
289 | wxMenu *filedlg_menu = new wxMenu; |
290 | filedlg_menu->Append(DIALOGS_FILE_OPEN, _T("&Open file\tCtrl-O")); | |
291 | filedlg_menu->Append(DIALOGS_FILE_OPEN2, _T("&Second open file\tCtrl-2")); | |
292 | filedlg_menu->Append(DIALOGS_FILES_OPEN, _T("Open &files\tCtrl-Q")); | |
293 | filedlg_menu->Append(DIALOGS_FILE_SAVE, _T("Sa&ve file\tCtrl-S")); | |
695fe764 | 294 | |
33bcca32 VZ |
295 | #if USE_FILEDLG_GENERIC |
296 | filedlg_menu->AppendSeparator(); | |
297 | filedlg_menu->Append(DIALOGS_FILE_OPEN_GENERIC, _T("&Open file (generic)")); | |
298 | filedlg_menu->Append(DIALOGS_FILES_OPEN_GENERIC, _T("Open &files (generic)")); | |
299 | filedlg_menu->Append(DIALOGS_FILE_SAVE_GENERIC, _T("Sa&ve file (generic)")); | |
300 | #endif // USE_FILEDLG_GENERIC | |
695fe764 | 301 | |
33bcca32 | 302 | file_menu->Append(wxID_ANY,_T("&File operations"),filedlg_menu); |
13188def | 303 | |
33bcca32 | 304 | #endif // wxUSE_FILEDLG |
13188def | 305 | |
33bcca32 VZ |
306 | #if wxUSE_DIRDLG |
307 | wxMenu *dir_menu = new wxMenu; | |
13188def | 308 | |
33bcca32 VZ |
309 | dir_menu->Append(DIALOGS_DIR_CHOOSE, _T("&Choose a directory\tCtrl-D")); |
310 | dir_menu->Append(DIALOGS_DIRNEW_CHOOSE, _T("Choose a directory (with \"Ne&w\" button)\tShift-Ctrl-D")); | |
311 | file_menu->Append(wxID_ANY,_T("&Directory operations"),dir_menu); | |
13188def | 312 | |
33bcca32 VZ |
313 | #if USE_DIRDLG_GENERIC |
314 | dir_menu->AppendSeparator(); | |
315 | dir_menu->Append(DIALOGS_GENERIC_DIR_CHOOSE, _T("&Choose a directory (generic)")); | |
316 | #endif // USE_DIRDLG_GENERIC | |
13188def | 317 | |
33bcca32 | 318 | #endif // wxUSE_DIRDLG |
13188def WS |
319 | |
320 | ||
33bcca32 | 321 | #if wxUSE_STARTUP_TIPS || wxUSE_PROGRESSDLG || wxUSE_BUSYINFO || wxUSE_LOG_DIALOG |
13188def | 322 | |
33bcca32 | 323 | wxMenu *info_menu = new wxMenu; |
13188def | 324 | |
33bcca32 VZ |
325 | #if wxUSE_STARTUP_TIPS |
326 | info_menu->Append(DIALOGS_TIP, _T("&Tip of the day\tCtrl-T")); | |
327 | #endif // wxUSE_STARTUP_TIPS | |
13188def | 328 | |
33bcca32 VZ |
329 | #if wxUSE_PROGRESSDLG |
330 | info_menu->Append(DIALOGS_PROGRESS, _T("Pro&gress dialog\tCtrl-G")); | |
331 | #endif // wxUSE_PROGRESSDLG | |
13188def | 332 | |
33bcca32 VZ |
333 | #if wxUSE_BUSYINFO |
334 | info_menu->Append(DIALOGS_BUSYINFO, _T("&Busy info dialog\tCtrl-B")); | |
335 | #endif // wxUSE_BUSYINFO | |
13188def | 336 | |
33bcca32 VZ |
337 | #if wxUSE_LOG_DIALOG |
338 | info_menu->Append(DIALOGS_LOG_DIALOG, _T("&Log dialog\tCtrl-L")); | |
339 | #endif // wxUSE_LOG_DIALOG | |
13188def | 340 | |
33bcca32 | 341 | file_menu->Append(wxID_ANY,_T("&Informative dialogs"),info_menu); |
13188def | 342 | |
33bcca32 | 343 | #endif // wxUSE_STARTUP_TIPS || wxUSE_PROGRESSDLG || wxUSE_BUSYINFO || wxUSE_LOG_DIALOG |
13188def WS |
344 | |
345 | ||
33bcca32 VZ |
346 | #if wxUSE_FINDREPLDLG |
347 | wxMenu *find_menu = new wxMenu; | |
348 | find_menu->AppendCheckItem(DIALOGS_FIND, _T("&Find dialog\tCtrl-F")); | |
349 | find_menu->AppendCheckItem(DIALOGS_REPLACE, _T("Find and &replace dialog\tShift-Ctrl-F")); | |
350 | file_menu->Append(wxID_ANY,_T("&Searching"),find_menu); | |
351 | #endif // wxUSE_FINDREPLDLG | |
13188def | 352 | |
33bcca32 VZ |
353 | #if USE_MODAL_PRESENTATION |
354 | wxMenu *modal_menu = new wxMenu; | |
355 | modal_menu->Append(DIALOGS_MODAL, _T("Mo&dal dialog\tCtrl-W")); | |
356 | modal_menu->AppendCheckItem(DIALOGS_MODELESS, _T("Modeless &dialog\tCtrl-Z")); | |
357 | file_menu->Append(wxID_ANY,_T("&Modal/Modeless"),modal_menu); | |
358 | #endif // USE_MODAL_PRESENTATION | |
13188def | 359 | |
0f5d8ecf | 360 | file_menu->Append(DIALOGS_PROPERTY_SHEET, _T("&Property Sheet Dialog\tCtrl-P")); |
9b16ffef VZ |
361 | file_menu->Append(DIALOGS_REQUEST, _T("&Request user attention\tCtrl-R")); |
362 | ||
13188def WS |
363 | file_menu->AppendSeparator(); |
364 | file_menu->Append(wxID_EXIT, _T("E&xit\tAlt-X")); | |
365 | ||
366 | wxMenuBar *menu_bar = new wxMenuBar; | |
367 | menu_bar->Append(file_menu, _T("&File")); | |
368 | frame->SetMenuBar(menu_bar); | |
369 | ||
370 | myCanvas = new MyCanvas(frame); | |
371 | myCanvas->SetBackgroundColour(*wxWHITE); | |
372 | ||
373 | frame->Centre(wxBOTH); | |
374 | ||
375 | // Show the frame | |
376 | frame->Show(true); | |
377 | ||
378 | SetTopWindow(frame); | |
379 | ||
380 | return true; | |
457814b5 JS |
381 | } |
382 | ||
383 | // My frame constructor | |
4c45f240 | 384 | MyFrame::MyFrame(wxWindow *parent, |
13188def WS |
385 | const wxString& title) |
386 | : wxFrame(parent, wxID_ANY, title) | |
4c45f240 | 387 | { |
0f5d8ecf JS |
388 | SetIcon(sample_xpm); |
389 | ||
13188def | 390 | #if USE_MODAL_PRESENTATION |
4c45f240 | 391 | m_dialog = (MyModelessDialog *)NULL; |
13188def | 392 | #endif // USE_MODAL_PRESENTATION |
f1e1ed3b | 393 | |
043dcdaa | 394 | #if wxUSE_FINDREPLDLG |
14fca738 VZ |
395 | m_dlgFind = |
396 | m_dlgReplace = NULL; | |
043dcdaa | 397 | #endif |
dabbc6a5 DS |
398 | |
399 | #if wxUSE_COLOURDLG | |
d33dd9ef VS |
400 | m_clrData.SetChooseFull(true); |
401 | for (int i = 0; i < 16; i++) | |
402 | { | |
8f6eaec9 WS |
403 | m_clrData.SetCustomColour( |
404 | i, | |
405 | wxColour( | |
406 | (unsigned char)(i*16), | |
407 | (unsigned char)(i*16), | |
408 | (unsigned char)(i*16) | |
409 | ) | |
410 | ); | |
d33dd9ef | 411 | } |
13188def | 412 | #endif // wxUSE_COLOURDLG |
4c45f240 | 413 | } |
457814b5 | 414 | |
13188def | 415 | #if wxUSE_COLOURDLG |
d355d3fe | 416 | void MyFrame::ChooseColour(wxCommandEvent& WXUNUSED(event) ) |
457814b5 | 417 | { |
d33dd9ef | 418 | m_clrData.SetColour(myCanvas->GetBackgroundColour()); |
d93c719a | 419 | |
d33dd9ef | 420 | wxColourDialog dialog(this, &m_clrData); |
9f84eccd | 421 | dialog.SetTitle(_T("Choose the background colour")); |
afbd36dd | 422 | if (dialog.ShowModal() == wxID_OK) |
f6bcfd97 | 423 | { |
d33dd9ef VS |
424 | m_clrData = dialog.GetColourData(); |
425 | myCanvas->SetBackgroundColour(m_clrData.GetColour()); | |
1d14c005 | 426 | myCanvas->ClearBackground(); |
457814b5 | 427 | myCanvas->Refresh(); |
f6bcfd97 | 428 | } |
457814b5 | 429 | } |
13188def | 430 | #endif // wxUSE_COLOURDLG |
457814b5 | 431 | |
1e72e3cc RN |
432 | #if USE_COLOURDLG_GENERIC |
433 | void MyFrame::ChooseColourGeneric(wxCommandEvent& WXUNUSED(event)) | |
434 | { | |
435 | m_clrData.SetColour(myCanvas->GetBackgroundColour()); | |
436 | ||
437 | //FIXME:TODO:This has no effect... | |
438 | m_clrData.SetChooseFull(true); | |
439 | ||
440 | for (int i = 0; i < 16; i++) | |
441 | { | |
442 | wxColour colour( | |
443 | (unsigned char)(i*16), | |
444 | (unsigned char)(i*16), | |
445 | (unsigned char)(i*16) | |
446 | ); | |
447 | m_clrData.SetCustomColour(i, colour); | |
448 | } | |
449 | ||
450 | wxGenericColourDialog *dialog = new wxGenericColourDialog(this, &m_clrData); | |
451 | if (dialog->ShowModal() == wxID_OK) | |
452 | { | |
453 | m_clrData = dialog->GetColourData(); | |
454 | myCanvas->SetBackgroundColour(m_clrData.GetColour()); | |
455 | myCanvas->ClearBackground(); | |
456 | myCanvas->Refresh(); | |
457 | } | |
458 | dialog->Destroy(); | |
459 | } | |
460 | #endif // USE_COLOURDLG_GENERIC | |
461 | ||
13188def | 462 | #if wxUSE_FONTDLG |
d355d3fe | 463 | void MyFrame::ChooseFont(wxCommandEvent& WXUNUSED(event) ) |
457814b5 | 464 | { |
dbc65e27 VZ |
465 | wxFontData data; |
466 | data.SetInitialFont(wxGetApp().m_canvasFont); | |
467 | data.SetColour(wxGetApp().m_canvasTextColour); | |
d93c719a | 468 | |
dbc65e27 VZ |
469 | // you might also do this: |
470 | // | |
471 | // wxFontDialog dialog; | |
472 | // if ( !dialog.Create(this, data) { ... error ... } | |
473 | // | |
474 | wxFontDialog dialog(this, data); | |
475 | ||
476 | if (dialog.ShowModal() == wxID_OK) | |
477 | { | |
478 | wxFontData retData = dialog.GetFontData(); | |
457814b5 JS |
479 | wxGetApp().m_canvasFont = retData.GetChosenFont(); |
480 | wxGetApp().m_canvasTextColour = retData.GetColour(); | |
481 | myCanvas->Refresh(); | |
dbc65e27 VZ |
482 | } |
483 | //else: cancelled by the user, don't change the font | |
457814b5 | 484 | } |
13188def | 485 | #endif // wxUSE_FONTDLG |
457814b5 | 486 | |
13188def | 487 | #if USE_FONTDLG_GENERIC |
d355d3fe | 488 | void MyFrame::ChooseFontGeneric(wxCommandEvent& WXUNUSED(event) ) |
457814b5 | 489 | { |
13188def WS |
490 | wxFontData data; |
491 | data.SetInitialFont(wxGetApp().m_canvasFont); | |
492 | data.SetColour(wxGetApp().m_canvasTextColour); | |
457814b5 | 493 | |
13188def WS |
494 | wxGenericFontDialog *dialog = new wxGenericFontDialog(this, &data); |
495 | if (dialog->ShowModal() == wxID_OK) | |
496 | { | |
457814b5 JS |
497 | wxFontData retData = dialog->GetFontData(); |
498 | wxGetApp().m_canvasFont = retData.GetChosenFont(); | |
499 | wxGetApp().m_canvasTextColour = retData.GetColour(); | |
500 | myCanvas->Refresh(); | |
13188def WS |
501 | } |
502 | dialog->Destroy(); | |
457814b5 | 503 | } |
13188def | 504 | #endif // USE_FONTDLG_GENERIC |
d93c719a | 505 | |
b4954d19 | 506 | #if wxUSE_LOG_DIALOG |
87728739 | 507 | void MyFrame::LogDialog(wxCommandEvent& WXUNUSED(event)) |
d93c719a | 508 | { |
2c8e4738 VZ |
509 | // calling wxYield() (as ~wxBusyCursor does) shouldn't result in messages |
510 | // being flushed -- test it | |
511 | { | |
512 | wxBusyCursor bc; | |
4693b20c MB |
513 | wxLogMessage(wxT("This is some message - everything is ok so far.")); |
514 | wxLogMessage(wxT("Another message...\n... this one is on multiple lines")); | |
515 | wxLogWarning(wxT("And then something went wrong!")); | |
9fe52545 VZ |
516 | |
517 | // and if ~wxBusyCursor doesn't do it, then call it manually | |
518 | wxYield(); | |
2c8e4738 VZ |
519 | } |
520 | ||
4693b20c MB |
521 | wxLogError(wxT("Intermediary error handler decided to abort.")); |
522 | wxLogError(wxT("The top level caller detected an unrecoverable error.")); | |
5888ef1e | 523 | |
7923c649 VZ |
524 | wxLog::FlushActive(); |
525 | ||
4693b20c | 526 | wxLogMessage(wxT("And this is the same dialog but with only one message.")); |
d93c719a | 527 | } |
b4954d19 | 528 | #endif // wxUSE_LOG_DIALOG |
457814b5 | 529 | |
d355d3fe | 530 | void MyFrame::MessageBox(wxCommandEvent& WXUNUSED(event) ) |
457814b5 | 531 | { |
13188def WS |
532 | wxMessageDialog dialog( NULL, _T("This is a message box\nA long, long string to test out the message box properly"), |
533 | _T("Message box text"), wxNO_DEFAULT|wxYES_NO|wxCANCEL|wxICON_INFORMATION); | |
457814b5 | 534 | |
13188def WS |
535 | switch ( dialog.ShowModal() ) |
536 | { | |
537 | case wxID_YES: | |
538 | wxLogStatus(wxT("You pressed \"Yes\"")); | |
539 | break; | |
49b957be | 540 | |
13188def WS |
541 | case wxID_NO: |
542 | wxLogStatus(wxT("You pressed \"No\"")); | |
543 | break; | |
49b957be | 544 | |
13188def WS |
545 | case wxID_CANCEL: |
546 | wxLogStatus(wxT("You pressed \"Cancel\"")); | |
547 | break; | |
49b957be | 548 | |
13188def WS |
549 | default: |
550 | wxLogError(wxT("Unexpected wxMessageDialog return code!")); | |
551 | } | |
457814b5 JS |
552 | } |
553 | ||
13188def | 554 | #if wxUSE_NUMBERDLG |
c49245f8 VZ |
555 | void MyFrame::NumericEntry(wxCommandEvent& WXUNUSED(event) ) |
556 | { | |
78a189c9 VZ |
557 | long res = wxGetNumberFromUser( _T("This is some text, actually a lot of text.\n") |
558 | _T("Even two rows of text."), | |
559 | _T("Enter a number:"), _T("Numeric input test"), | |
e65cc56a | 560 | 50, 0, 100, this ); |
c49245f8 VZ |
561 | |
562 | wxString msg; | |
563 | int icon; | |
564 | if ( res == -1 ) | |
565 | { | |
78a189c9 | 566 | msg = _T("Invalid number entered or dialog cancelled."); |
c49245f8 VZ |
567 | icon = wxICON_HAND; |
568 | } | |
569 | else | |
d93c719a VZ |
570 | { |
571 | msg.Printf(_T("You've entered %lu"), res ); | |
c49245f8 VZ |
572 | icon = wxICON_INFORMATION; |
573 | } | |
574 | ||
78a189c9 | 575 | wxMessageBox(msg, _T("Numeric test result"), wxOK | icon, this); |
c49245f8 | 576 | } |
13188def | 577 | #endif // wxUSE_NUMBERDLG |
c49245f8 | 578 | |
13188def | 579 | #if wxUSE_TEXTDLG |
a294c6d5 | 580 | void MyFrame::PasswordEntry(wxCommandEvent& WXUNUSED(event)) |
457814b5 | 581 | { |
2f1cd905 | 582 | wxString pwd = wxGetPasswordFromUser(_T("Enter password:"), |
78a189c9 | 583 | _T("Password entry dialog"), |
dabbc6a5 | 584 | wxEmptyString, |
a294c6d5 | 585 | this); |
ecda9475 | 586 | if ( !pwd.empty() ) |
a294c6d5 | 587 | { |
4693b20c | 588 | wxMessageBox(wxString::Format(wxT("Your password is '%s'"), pwd.c_str()), |
78a189c9 | 589 | _T("Got password"), wxOK | wxICON_INFORMATION, this); |
a294c6d5 VZ |
590 | } |
591 | } | |
592 | ||
593 | void MyFrame::TextEntry(wxCommandEvent& WXUNUSED(event)) | |
594 | { | |
13188def WS |
595 | wxTextEntryDialog dialog(this, |
596 | _T("This is a small sample\n") | |
597 | _T("A long, long string to test out the text entrybox"), | |
598 | _T("Please enter a string"), | |
599 | _T("Default value"), | |
600 | wxOK | wxCANCEL); | |
457814b5 | 601 | |
13188def WS |
602 | if (dialog.ShowModal() == wxID_OK) |
603 | { | |
b4954d19 | 604 | wxMessageBox(dialog.GetValue(), _T("Got string"), wxOK | wxICON_INFORMATION, this); |
13188def | 605 | } |
457814b5 | 606 | } |
13188def | 607 | #endif // wxUSE_TEXTDLG |
457814b5 | 608 | |
13188def | 609 | #if wxUSE_CHOICEDLG |
d355d3fe | 610 | void MyFrame::SingleChoice(wxCommandEvent& WXUNUSED(event) ) |
457814b5 | 611 | { |
78a189c9 | 612 | const wxString choices[] = { _T("One"), _T("Two"), _T("Three"), _T("Four"), _T("Five") } ; |
457814b5 | 613 | |
5f95bb70 | 614 | wxSingleChoiceDialog dialog(this, |
78a189c9 VZ |
615 | _T("This is a small sample\n") |
616 | _T("A single-choice convenience dialog"), | |
617 | _T("Please select a value"), | |
5f95bb70 | 618 | WXSIZEOF(choices), choices); |
457814b5 | 619 | |
ef77f91e JS |
620 | dialog.SetSelection(2); |
621 | ||
622 | if (dialog.ShowModal() == wxID_OK) | |
623 | { | |
78a189c9 | 624 | wxMessageDialog dialog2(this, dialog.GetStringSelection(), _T("Got string")); |
ef77f91e JS |
625 | dialog2.ShowModal(); |
626 | } | |
457814b5 JS |
627 | } |
628 | ||
d6c9c1b7 VZ |
629 | void MyFrame::MultiChoice(wxCommandEvent& WXUNUSED(event) ) |
630 | { | |
5f95bb70 VZ |
631 | const wxString choices[] = |
632 | { | |
78a189c9 VZ |
633 | _T("One"), _T("Two"), _T("Three"), _T("Four"), _T("Five"), |
634 | _T("Six"), _T("Seven"), _T("Eight"), _T("Nine"), _T("Ten"), | |
635 | _T("Eleven"), _T("Twelve"), _T("Seventeen"), | |
5f95bb70 | 636 | }; |
d6c9c1b7 VZ |
637 | |
638 | wxArrayInt selections; | |
639 | size_t count = wxGetMultipleChoices(selections, | |
78a189c9 VZ |
640 | _T("This is a small sample\n") |
641 | _T("A multi-choice convenience dialog"), | |
642 | _T("Please select a value"), | |
5f95bb70 | 643 | WXSIZEOF(choices), choices, |
d6c9c1b7 VZ |
644 | this); |
645 | if ( count ) | |
646 | { | |
3d49ce44 | 647 | wxString msg; |
fba1b53b | 648 | msg.Printf(wxT("You selected %u items:\n"), (unsigned)count); |
d6c9c1b7 VZ |
649 | for ( size_t n = 0; n < count; n++ ) |
650 | { | |
fba1b53b VZ |
651 | msg += wxString::Format(wxT("\t%u: %u (%s)\n"), |
652 | (unsigned)n, (unsigned)selections[n], | |
3d49ce44 | 653 | choices[selections[n]].c_str()); |
d6c9c1b7 | 654 | } |
3d49ce44 | 655 | wxLogMessage(msg); |
d6c9c1b7 VZ |
656 | } |
657 | //else: cancelled or nothing selected | |
658 | } | |
13188def | 659 | #endif // wxUSE_CHOICEDLG |
d6c9c1b7 | 660 | |
13188def | 661 | #if wxUSE_FILEDLG |
d355d3fe | 662 | void MyFrame::FileOpen(wxCommandEvent& WXUNUSED(event) ) |
457814b5 | 663 | { |
fbf4eacb VZ |
664 | wxFileDialog dialog |
665 | ( | |
666 | this, | |
667 | _T("Testing open file dialog"), | |
dabbc6a5 DS |
668 | wxEmptyString, |
669 | wxEmptyString, | |
a4e64fb5 MB |
670 | #ifdef __WXMOTIF__ |
671 | _T("C++ files (*.cpp)|*.cpp") | |
672 | #else | |
daf32463 | 673 | _T("C++ files (*.cpp;*.h)|*.cpp;*.h") |
a4e64fb5 | 674 | #endif |
fbf4eacb | 675 | ); |
457814b5 | 676 | |
5b636c67 VZ |
677 | dialog.SetDirectory(wxGetHomeDir()); |
678 | ||
c50f1fb9 VZ |
679 | if (dialog.ShowModal() == wxID_OK) |
680 | { | |
5919d76b | 681 | wxString info; |
13393ab6 RR |
682 | info.Printf(_T("Full file name: %s\n") |
683 | _T("Path: %s\n") | |
684 | _T("Name: %s"), | |
5919d76b VZ |
685 | dialog.GetPath().c_str(), |
686 | dialog.GetDirectory().c_str(), | |
687 | dialog.GetFilename().c_str()); | |
78a189c9 | 688 | wxMessageDialog dialog2(this, info, _T("Selected file")); |
c50f1fb9 VZ |
689 | dialog2.ShowModal(); |
690 | } | |
457814b5 JS |
691 | } |
692 | ||
35b45b33 VZ |
693 | // this shows how to take advantage of specifying a default extension in the |
694 | // call to wxFileSelector: it is remembered after each new call and the next | |
695 | // one will use it by default | |
696 | void MyFrame::FileOpen2(wxCommandEvent& WXUNUSED(event) ) | |
697 | { | |
698 | static wxString s_extDef; | |
699 | wxString path = wxFileSelector( | |
700 | _T("Select the file to load"), | |
dabbc6a5 | 701 | wxEmptyString, wxEmptyString, |
35b45b33 | 702 | s_extDef, |
3601f639 VZ |
703 | wxString::Format |
704 | ( | |
705 | _T("Waveform (*.wav)|*.wav|Plain text (*.txt)|*.txt|All files (%s)|%s"), | |
706 | wxFileSelectorDefaultWildcardStr, | |
707 | wxFileSelectorDefaultWildcardStr | |
708 | ), | |
fbf4eacb | 709 | wxCHANGE_DIR, |
35b45b33 VZ |
710 | this |
711 | ); | |
712 | ||
713 | if ( !path ) | |
714 | return; | |
715 | ||
716 | // it is just a sample, would use wxSplitPath in real program | |
717 | s_extDef = path.AfterLast(_T('.')); | |
718 | ||
719 | wxLogMessage(_T("You selected the file '%s', remembered extension '%s'"), | |
37d403aa | 720 | (const wxChar*) path, (const wxChar*) s_extDef); |
35b45b33 VZ |
721 | } |
722 | ||
c61f4f6d VZ |
723 | void MyFrame::FilesOpen(wxCommandEvent& WXUNUSED(event) ) |
724 | { | |
dabbc6a5 | 725 | wxString wildcards = |
f0f43012 JS |
726 | #ifdef __WXMOTIF__ |
727 | _T("C++ files (*.cpp)|*.cpp"); | |
728 | #else | |
3601f639 VZ |
729 | wxString::Format |
730 | ( | |
731 | _T("All files (%s)|%s|C++ files (*.cpp;*.h)|*.cpp;*.h"), | |
732 | wxFileSelectorDefaultWildcardStr, | |
733 | wxFileSelectorDefaultWildcardStr | |
734 | ); | |
f0f43012 | 735 | #endif |
78a189c9 | 736 | wxFileDialog dialog(this, _T("Testing open multiple file dialog"), |
dabbc6a5 | 737 | wxEmptyString, wxEmptyString, wildcards, |
470caaf9 | 738 | wxMULTIPLE); |
c61f4f6d VZ |
739 | |
740 | if (dialog.ShowModal() == wxID_OK) | |
741 | { | |
742 | wxArrayString paths, filenames; | |
743 | ||
744 | dialog.GetPaths(paths); | |
745 | dialog.GetFilenames(filenames); | |
746 | ||
747 | wxString msg, s; | |
748 | size_t count = paths.GetCount(); | |
749 | for ( size_t n = 0; n < count; n++ ) | |
750 | { | |
751 | s.Printf(_T("File %d: %s (%s)\n"), | |
fba1b53b | 752 | (int)n, paths[n].c_str(), filenames[n].c_str()); |
c61f4f6d VZ |
753 | |
754 | msg += s; | |
755 | } | |
f0f43012 JS |
756 | s.Printf(_T("Filter index: %d"), dialog.GetFilterIndex()); |
757 | msg += s; | |
c61f4f6d | 758 | |
78a189c9 | 759 | wxMessageDialog dialog2(this, msg, _T("Selected files")); |
c61f4f6d VZ |
760 | dialog2.ShowModal(); |
761 | } | |
762 | } | |
763 | ||
d355d3fe | 764 | void MyFrame::FileSave(wxCommandEvent& WXUNUSED(event) ) |
457814b5 | 765 | { |
2f1cd905 VZ |
766 | wxFileDialog dialog(this, |
767 | _T("Testing save file dialog"), | |
dabbc6a5 | 768 | wxEmptyString, |
2b5f62a0 | 769 | _T("myletter.doc"), |
2f1cd905 VZ |
770 | _T("Text files (*.txt)|*.txt|Document files (*.doc)|*.doc"), |
771 | wxSAVE|wxOVERWRITE_PROMPT); | |
c50f1fb9 | 772 | |
2b5f62a0 VZ |
773 | dialog.SetFilterIndex(1); |
774 | ||
c50f1fb9 VZ |
775 | if (dialog.ShowModal() == wxID_OK) |
776 | { | |
2b5f62a0 VZ |
777 | wxLogMessage(_T("%s, filter %d"), |
778 | dialog.GetPath().c_str(), dialog.GetFilterIndex()); | |
c50f1fb9 | 779 | } |
457814b5 | 780 | } |
13188def | 781 | #endif // wxUSE_FILEDLG |
457814b5 | 782 | |
695fe764 WS |
783 | #if USE_FILEDLG_GENERIC |
784 | void MyFrame::FileOpenGeneric(wxCommandEvent& WXUNUSED(event) ) | |
785 | { | |
786 | wxGenericFileDialog dialog | |
787 | ( | |
788 | this, | |
789 | _T("Testing open file dialog"), | |
790 | wxEmptyString, | |
791 | wxEmptyString, | |
daf32463 | 792 | _T("C++ files (*.cpp;*.h)|*.cpp;*.h") |
695fe764 WS |
793 | ); |
794 | ||
795 | dialog.SetDirectory(wxGetHomeDir()); | |
796 | ||
797 | if (dialog.ShowModal() == wxID_OK) | |
798 | { | |
799 | wxString info; | |
800 | info.Printf(_T("Full file name: %s\n") | |
801 | _T("Path: %s\n") | |
802 | _T("Name: %s"), | |
803 | dialog.GetPath().c_str(), | |
804 | dialog.GetDirectory().c_str(), | |
805 | dialog.GetFilename().c_str()); | |
806 | wxMessageDialog dialog2(this, info, _T("Selected file")); | |
807 | dialog2.ShowModal(); | |
808 | } | |
809 | } | |
810 | ||
811 | void MyFrame::FilesOpenGeneric(wxCommandEvent& WXUNUSED(event) ) | |
812 | { | |
daf32463 | 813 | wxString wildcards = _T("All files (*.*)|*.*|C++ files (*.cpp;*.h)|*.cpp;*.h"); |
695fe764 WS |
814 | wxGenericFileDialog dialog(this, _T("Testing open multiple file dialog"), |
815 | wxEmptyString, wxEmptyString, wildcards, | |
816 | wxMULTIPLE); | |
817 | ||
818 | if (dialog.ShowModal() == wxID_OK) | |
819 | { | |
820 | wxArrayString paths, filenames; | |
821 | ||
822 | dialog.GetPaths(paths); | |
823 | dialog.GetFilenames(filenames); | |
824 | ||
825 | wxString msg, s; | |
826 | size_t count = paths.GetCount(); | |
827 | for ( size_t n = 0; n < count; n++ ) | |
828 | { | |
829 | s.Printf(_T("File %d: %s (%s)\n"), | |
830 | (int)n, paths[n].c_str(), filenames[n].c_str()); | |
831 | ||
832 | msg += s; | |
833 | } | |
834 | s.Printf(_T("Filter index: %d"), dialog.GetFilterIndex()); | |
835 | msg += s; | |
836 | ||
837 | wxMessageDialog dialog2(this, msg, _T("Selected files")); | |
838 | dialog2.ShowModal(); | |
839 | } | |
840 | } | |
841 | ||
842 | void MyFrame::FileSaveGeneric(wxCommandEvent& WXUNUSED(event) ) | |
843 | { | |
844 | wxGenericFileDialog dialog(this, | |
845 | _T("Testing save file dialog"), | |
846 | wxEmptyString, | |
847 | _T("myletter.doc"), | |
848 | _T("Text files (*.txt)|*.txt|Document files (*.doc)|*.doc"), | |
849 | wxSAVE|wxOVERWRITE_PROMPT); | |
850 | ||
851 | dialog.SetFilterIndex(1); | |
852 | ||
853 | if (dialog.ShowModal() == wxID_OK) | |
854 | { | |
855 | wxLogMessage(_T("%s, filter %d"), | |
856 | dialog.GetPath().c_str(), dialog.GetFilterIndex()); | |
857 | } | |
858 | } | |
859 | #endif // USE_FILEDLG_GENERIC | |
860 | ||
13188def | 861 | #if wxUSE_DIRDLG |
f09c8393 | 862 | void MyFrame::DoDirChoose(int style) |
457814b5 | 863 | { |
3f2711d5 VZ |
864 | // pass some initial dir to wxDirDialog |
865 | wxString dirHome; | |
866 | wxGetHomeDir(&dirHome); | |
867 | ||
f09c8393 | 868 | wxDirDialog dialog(this, _T("Testing directory picker"), dirHome, style); |
c50f1fb9 VZ |
869 | |
870 | if (dialog.ShowModal() == wxID_OK) | |
871 | { | |
2b5f62a0 | 872 | wxLogMessage(_T("Selected path: %s"), dialog.GetPath().c_str()); |
c50f1fb9 VZ |
873 | } |
874 | } | |
875 | ||
f09c8393 VZ |
876 | void MyFrame::DirChoose(wxCommandEvent& WXUNUSED(event) ) |
877 | { | |
878 | DoDirChoose(wxDD_DEFAULT_STYLE & ~wxDD_NEW_DIR_BUTTON); | |
879 | } | |
880 | ||
881 | void MyFrame::DirChooseNew(wxCommandEvent& WXUNUSED(event) ) | |
882 | { | |
8768548b | 883 | DoDirChoose(wxDD_DEFAULT_STYLE | wxDD_NEW_DIR_BUTTON); |
f09c8393 | 884 | } |
13188def | 885 | #endif // wxUSE_DIRDLG |
f09c8393 | 886 | |
13188def | 887 | #if USE_DIRDLG_GENERIC |
51a58d8b JS |
888 | void MyFrame::GenericDirChoose(wxCommandEvent& WXUNUSED(event) ) |
889 | { | |
890 | // pass some initial dir to wxDirDialog | |
891 | wxString dirHome; | |
892 | wxGetHomeDir(&dirHome); | |
893 | ||
78a189c9 | 894 | wxGenericDirDialog dialog(this, _T("Testing generic directory picker"), dirHome); |
51a58d8b JS |
895 | |
896 | if (dialog.ShowModal() == wxID_OK) | |
897 | { | |
78a189c9 | 898 | wxMessageDialog dialog2(this, dialog.GetPath(), _T("Selected path")); |
51a58d8b JS |
899 | dialog2.ShowModal(); |
900 | } | |
901 | } | |
13188def | 902 | #endif // USE_DIRDLG_GENERIC |
51a58d8b | 903 | |
13188def | 904 | #if USE_MODAL_PRESENTATION |
f6bcfd97 BP |
905 | void MyFrame::ModalDlg(wxCommandEvent& WXUNUSED(event)) |
906 | { | |
907 | MyModalDialog dlg(this); | |
908 | dlg.ShowModal(); | |
909 | } | |
910 | ||
4c45f240 VZ |
911 | void MyFrame::ModelessDlg(wxCommandEvent& event) |
912 | { | |
2f82899b | 913 | bool show = GetMenuBar()->IsChecked(event.GetId()); |
4c45f240 VZ |
914 | |
915 | if ( show ) | |
916 | { | |
917 | if ( !m_dialog ) | |
918 | { | |
919 | m_dialog = new MyModelessDialog(this); | |
920 | } | |
921 | ||
13188def | 922 | m_dialog->Show(true); |
4c45f240 VZ |
923 | } |
924 | else // hide | |
925 | { | |
26a12ab3 JS |
926 | // If m_dialog is NULL, then possibly the system |
927 | // didn't report the checked menu item status correctly. | |
928 | // It should be true just after the menu item was selected, | |
929 | // if there was no modeless dialog yet. | |
930 | ||
931 | wxASSERT( m_dialog != NULL ); | |
932 | if (m_dialog) | |
933 | m_dialog->Hide(); | |
4c45f240 VZ |
934 | } |
935 | } | |
13188def | 936 | #endif // USE_MODAL_PRESENTATION |
4c45f240 | 937 | |
13188def | 938 | #if wxUSE_STARTUP_TIPS |
87728739 | 939 | void MyFrame::ShowTip(wxCommandEvent& WXUNUSED(event)) |
c50f1fb9 VZ |
940 | { |
941 | static size_t s_index = (size_t)-1; | |
942 | ||
943 | if ( s_index == (size_t)-1 ) | |
944 | { | |
945 | srand(time(NULL)); | |
946 | ||
947 | // this is completely bogus, we don't know how many lines are there | |
948 | // in the file, but who cares, it's a demo only... | |
949 | s_index = rand() % 5; | |
950 | } | |
951 | ||
2f1cd905 | 952 | wxTipProvider *tipProvider = wxCreateFileTipProvider(_T("tips.txt"), s_index); |
c50f1fb9 VZ |
953 | |
954 | bool showAtStartup = wxShowTip(this, tipProvider); | |
955 | ||
956 | if ( showAtStartup ) | |
957 | { | |
2f1cd905 | 958 | wxMessageBox(_T("Will show tips on startup"), _T("Tips dialog"), |
c50f1fb9 VZ |
959 | wxOK | wxICON_INFORMATION, this); |
960 | } | |
457814b5 | 961 | |
c50f1fb9 VZ |
962 | s_index = tipProvider->GetCurrentTip(); |
963 | delete tipProvider; | |
457814b5 | 964 | } |
13188def | 965 | #endif // wxUSE_STARTUP_TIPS |
457814b5 | 966 | |
0f5d8ecf JS |
967 | void MyFrame::OnPropertySheet(wxCommandEvent& WXUNUSED(event)) |
968 | { | |
969 | SettingsDialog dialog(this); | |
970 | dialog.ShowModal(); | |
971 | } | |
972 | ||
9b16ffef VZ |
973 | void MyFrame::OnRequestUserAttention(wxCommandEvent& WXUNUSED(event)) |
974 | { | |
975 | wxLogStatus(_T("Sleeping for 3 seconds to allow you to switch to another window")); | |
976 | ||
977 | wxSleep(3); | |
978 | ||
979 | RequestUserAttention(wxUSER_ATTENTION_ERROR); | |
980 | } | |
981 | ||
d355d3fe | 982 | void MyFrame::OnExit(wxCommandEvent& WXUNUSED(event) ) |
457814b5 | 983 | { |
13188def | 984 | Close(true); |
457814b5 JS |
985 | } |
986 | ||
abceee76 VZ |
987 | #if wxUSE_PROGRESSDLG |
988 | ||
989 | void MyFrame::ShowProgress( wxCommandEvent& WXUNUSED(event) ) | |
990 | { | |
9b16ffef VZ |
991 | #if wxUSE_STOPWATCH && wxUSE_LONGLONG |
992 | // check the performance | |
993 | int countrandomnumbers = 0, count = 0; | |
994 | wxTimeSpan tsTest(0,0,0,250); | |
995 | wxDateTime DT2, DT1 = wxDateTime::UNow(); | |
996 | srand(0); | |
997 | while(1) | |
998 | { | |
999 | rand(); | |
1000 | ++countrandomnumbers; | |
1001 | if ( countrandomnumbers == 1000 ) | |
1002 | { | |
1003 | srand(0); | |
1004 | countrandomnumbers = 0; | |
1005 | ++count; | |
1006 | DT2 = wxDateTime::UNow(); | |
1007 | wxTimeSpan ts = DT2.Subtract( DT1 ); | |
1008 | if ( ts.IsLongerThan( tsTest ) ) | |
1009 | { | |
1010 | break; | |
1011 | } | |
1012 | } | |
1013 | } | |
1014 | const int max = 40 * count; | |
1015 | #else | |
abceee76 | 1016 | static const int max = 10; |
9b16ffef | 1017 | #endif // wxUSE_STOPWATCH && wxUSE_LONGLONG |
abceee76 | 1018 | |
2f1cd905 | 1019 | wxProgressDialog dialog(_T("Progress dialog example"), |
78a189c9 | 1020 | _T("An informative message"), |
abceee76 VZ |
1021 | max, // range |
1022 | this, // parent | |
1023 | wxPD_CAN_ABORT | | |
ecda9475 | 1024 | wxPD_CAN_SKIP | |
abceee76 | 1025 | wxPD_APP_MODAL | |
df26c4c6 | 1026 | // wxPD_AUTO_HIDE | -- try this as well |
abceee76 VZ |
1027 | wxPD_ELAPSED_TIME | |
1028 | wxPD_ESTIMATED_TIME | | |
ecda9475 WS |
1029 | wxPD_REMAINING_TIME | |
1030 | wxPD_SMOOTH); | |
abceee76 | 1031 | |
13188def | 1032 | bool cont = true; |
ecda9475 WS |
1033 | bool skip = false; |
1034 | // each skip will move progress about quarter forward | |
1035 | for ( int i = 0; i <= max; i = wxMin(i+(skip?int(max/4):1), max+1), skip = false ) | |
abceee76 | 1036 | { |
9b16ffef VZ |
1037 | #if wxUSE_STOPWATCH && wxUSE_LONGLONG |
1038 | // do (almost) the same operations as we did for the performance test | |
1039 | srand(0); | |
1040 | for ( int j = 0; j < 1000; j++ ) | |
1041 | { | |
1042 | rand(); | |
1043 | if ( j == 999 ) | |
1044 | { | |
1045 | DT2 = wxDateTime::UNow(); | |
1046 | wxTimeSpan ts = DT2.Subtract( DT1 ); | |
1047 | if ( ts.IsLongerThan( tsTest ) ) | |
1048 | { | |
1049 | // nothing to do | |
1050 | } | |
1051 | } | |
1052 | } | |
1053 | #else | |
abceee76 | 1054 | wxSleep(1); |
9b16ffef | 1055 | #endif |
ecda9475 WS |
1056 | |
1057 | wxString msg; | |
1058 | ||
abceee76 VZ |
1059 | if ( i == max ) |
1060 | { | |
ecda9475 | 1061 | msg = _T("That's all, folks!"); |
abceee76 | 1062 | } |
ecda9475 | 1063 | else if ( i > max / 2 ) |
abceee76 | 1064 | { |
ecda9475 | 1065 | msg = _T("Only a half left (very long message)!"); |
abceee76 | 1066 | } |
ecda9475 WS |
1067 | |
1068 | #if wxUSE_STOPWATCH && wxUSE_LONGLONG | |
1069 | if ( (i % (max/100)) == 0 ) // // only 100 updates, this makes it much faster | |
abceee76 | 1070 | { |
ecda9475 | 1071 | cont = dialog.Update(i, msg, &skip); |
abceee76 | 1072 | } |
ecda9475 WS |
1073 | #else |
1074 | cont = dialog.Update(i, msg, &skip); | |
1075 | #endif | |
1076 | ||
d8ddee9c VZ |
1077 | if ( !cont ) |
1078 | { | |
78a189c9 VZ |
1079 | if ( wxMessageBox(_T("Do you really want to cancel?"), |
1080 | _T("Progress dialog question"), // caption | |
1081 | wxYES_NO | wxICON_QUESTION) == wxYES ) | |
d8ddee9c VZ |
1082 | break; |
1083 | ||
9b16ffef | 1084 | cont = true; |
d8ddee9c VZ |
1085 | dialog.Resume(); |
1086 | } | |
abceee76 VZ |
1087 | } |
1088 | ||
1089 | if ( !cont ) | |
1090 | { | |
4693b20c | 1091 | wxLogStatus(wxT("Progress dialog aborted!")); |
abceee76 VZ |
1092 | } |
1093 | else | |
1094 | { | |
4693b20c | 1095 | wxLogStatus(wxT("Countdown from %d finished"), max); |
abceee76 VZ |
1096 | } |
1097 | } | |
1098 | ||
1099 | #endif // wxUSE_PROGRESSDLG | |
1100 | ||
a62b0bcc VZ |
1101 | #if wxUSE_BUSYINFO |
1102 | ||
1103 | void MyFrame::ShowBusyInfo(wxCommandEvent& WXUNUSED(event)) | |
1104 | { | |
21977bac VZ |
1105 | wxWindowDisabler disableAll; |
1106 | ||
9f84eccd | 1107 | wxBusyInfo info(_T("Working, please wait..."), this); |
a62b0bcc | 1108 | |
5b636c67 | 1109 | for ( int i = 0; i < 18; i++ ) |
a62b0bcc | 1110 | { |
5b636c67 | 1111 | //wxUsleep(100); |
a62b0bcc VZ |
1112 | wxTheApp->Yield(); |
1113 | } | |
5b636c67 VZ |
1114 | |
1115 | wxSleep(2); | |
1116 | //wxWakeUpIdle(); | |
a62b0bcc VZ |
1117 | } |
1118 | ||
1119 | #endif // wxUSE_BUSYINFO | |
1120 | ||
761989ff VZ |
1121 | #if wxUSE_FINDREPLDLG |
1122 | ||
1123 | void MyFrame::ShowReplaceDialog( wxCommandEvent& WXUNUSED(event) ) | |
1124 | { | |
14fca738 VZ |
1125 | if ( m_dlgReplace ) |
1126 | { | |
1127 | delete m_dlgReplace; | |
1128 | m_dlgReplace = NULL; | |
1129 | } | |
1130 | else | |
1131 | { | |
1132 | m_dlgReplace = new wxFindReplaceDialog | |
1133 | ( | |
1134 | this, | |
1135 | &m_findData, | |
78a189c9 | 1136 | _T("Find and replace dialog"), |
14fca738 VZ |
1137 | wxFR_REPLACEDIALOG |
1138 | ); | |
1139 | ||
13188def | 1140 | m_dlgReplace->Show(true); |
14fca738 | 1141 | } |
761989ff VZ |
1142 | } |
1143 | ||
1144 | void MyFrame::ShowFindDialog( wxCommandEvent& WXUNUSED(event) ) | |
1145 | { | |
14fca738 VZ |
1146 | if ( m_dlgFind ) |
1147 | { | |
1148 | delete m_dlgFind; | |
1149 | m_dlgFind = NULL; | |
1150 | } | |
1151 | else | |
1152 | { | |
1153 | m_dlgFind = new wxFindReplaceDialog | |
1154 | ( | |
1155 | this, | |
1156 | &m_findData, | |
78a189c9 | 1157 | _T("Find dialog"), |
14fca738 VZ |
1158 | // just for testing |
1159 | wxFR_NOWHOLEWORD | |
1160 | ); | |
1161 | ||
13188def | 1162 | m_dlgFind->Show(true); |
14fca738 | 1163 | } |
761989ff VZ |
1164 | } |
1165 | ||
1166 | static wxString DecodeFindDialogEventFlags(int flags) | |
1167 | { | |
1168 | wxString str; | |
78a189c9 | 1169 | str << (flags & wxFR_DOWN ? _T("down") : _T("up")) << _T(", ") |
2f1cd905 VZ |
1170 | << (flags & wxFR_WHOLEWORD ? _T("whole words only, ") : _T("")) |
1171 | << (flags & wxFR_MATCHCASE ? _T("") : _T("not ")) | |
78a189c9 | 1172 | << _T("case sensitive"); |
761989ff VZ |
1173 | |
1174 | return str; | |
1175 | } | |
1176 | ||
1177 | void MyFrame::OnFindDialog(wxFindDialogEvent& event) | |
1178 | { | |
1179 | wxEventType type = event.GetEventType(); | |
1180 | ||
1181 | if ( type == wxEVT_COMMAND_FIND || type == wxEVT_COMMAND_FIND_NEXT ) | |
1182 | { | |
4693b20c | 1183 | wxLogMessage(wxT("Find %s'%s' (flags: %s)"), |
eba33006 | 1184 | type == wxEVT_COMMAND_FIND_NEXT ? wxT("next ") : wxT(""), |
761989ff VZ |
1185 | event.GetFindString().c_str(), |
1186 | DecodeFindDialogEventFlags(event.GetFlags()).c_str()); | |
1187 | } | |
1188 | else if ( type == wxEVT_COMMAND_FIND_REPLACE || | |
1189 | type == wxEVT_COMMAND_FIND_REPLACE_ALL ) | |
1190 | { | |
4693b20c | 1191 | wxLogMessage(wxT("Replace %s'%s' with '%s' (flags: %s)"), |
eba33006 | 1192 | type == wxEVT_COMMAND_FIND_REPLACE_ALL ? _T("all ") : wxT(""), |
761989ff VZ |
1193 | event.GetFindString().c_str(), |
1194 | event.GetReplaceString().c_str(), | |
1195 | DecodeFindDialogEventFlags(event.GetFlags()).c_str()); | |
1196 | } | |
1197 | else if ( type == wxEVT_COMMAND_FIND_CLOSE ) | |
1198 | { | |
14fca738 VZ |
1199 | wxFindReplaceDialog *dlg = event.GetDialog(); |
1200 | ||
df26c4c6 | 1201 | int idMenu; |
14fca738 VZ |
1202 | const wxChar *txt; |
1203 | if ( dlg == m_dlgFind ) | |
1204 | { | |
1205 | txt = _T("Find"); | |
df26c4c6 | 1206 | idMenu = DIALOGS_FIND; |
14fca738 VZ |
1207 | m_dlgFind = NULL; |
1208 | } | |
1209 | else if ( dlg == m_dlgReplace ) | |
1210 | { | |
1211 | txt = _T("Replace"); | |
df26c4c6 | 1212 | idMenu = DIALOGS_REPLACE; |
14fca738 VZ |
1213 | m_dlgReplace = NULL; |
1214 | } | |
1215 | else | |
1216 | { | |
1217 | txt = _T("Unknown"); | |
13188def | 1218 | idMenu = wxID_ANY; |
14fca738 | 1219 | |
2f1cd905 | 1220 | wxFAIL_MSG( _T("unexpected event") ); |
14fca738 VZ |
1221 | } |
1222 | ||
df26c4c6 VZ |
1223 | wxLogMessage(wxT("%s dialog is being closed."), txt); |
1224 | ||
13188def | 1225 | if ( idMenu != wxID_ANY ) |
df26c4c6 | 1226 | { |
13188def | 1227 | GetMenuBar()->Check(idMenu, false); |
df26c4c6 | 1228 | } |
761989ff | 1229 | |
14fca738 | 1230 | dlg->Destroy(); |
761989ff VZ |
1231 | } |
1232 | else | |
1233 | { | |
4693b20c | 1234 | wxLogError(wxT("Unknown find dialog event!")); |
761989ff VZ |
1235 | } |
1236 | } | |
1237 | ||
1238 | #endif // wxUSE_FINDREPLDLG | |
1239 | ||
abceee76 VZ |
1240 | // ---------------------------------------------------------------------------- |
1241 | // MyCanvas | |
1242 | // ---------------------------------------------------------------------------- | |
1243 | ||
d355d3fe | 1244 | void MyCanvas::OnPaint(wxPaintEvent& WXUNUSED(event) ) |
457814b5 | 1245 | { |
c50f1fb9 | 1246 | wxPaintDC dc(this); |
457814b5 JS |
1247 | dc.SetFont(wxGetApp().m_canvasFont); |
1248 | dc.SetTextForeground(wxGetApp().m_canvasTextColour); | |
1249 | dc.SetBackgroundMode(wxTRANSPARENT); | |
dc96b1b6 WS |
1250 | dc.DrawText( |
1251 | _T("wxWidgets common dialogs") | |
1252 | #if !defined(__SMARTPHONE__) | |
1253 | _T(" test application") | |
1254 | #endif | |
1255 | , 10, 10); | |
457814b5 JS |
1256 | } |
1257 | ||
b4954d19 WS |
1258 | #if USE_MODAL_PRESENTATION |
1259 | ||
4c45f240 VZ |
1260 | // ---------------------------------------------------------------------------- |
1261 | // MyModelessDialog | |
1262 | // ---------------------------------------------------------------------------- | |
457814b5 | 1263 | |
4c45f240 | 1264 | MyModelessDialog::MyModelessDialog(wxWindow *parent) |
13188def | 1265 | : wxDialog(parent, wxID_ANY, wxString(_T("Modeless dialog"))) |
4c45f240 | 1266 | { |
cbc66a27 VZ |
1267 | wxBoxSizer *sizerTop = new wxBoxSizer(wxVERTICAL); |
1268 | ||
78a189c9 | 1269 | wxButton *btn = new wxButton(this, DIALOGS_MODELESS_BTN, _T("Press me")); |
13188def | 1270 | wxCheckBox *check = new wxCheckBox(this, wxID_ANY, _T("Should be disabled")); |
cbc66a27 VZ |
1271 | check->Disable(); |
1272 | ||
1273 | sizerTop->Add(btn, 1, wxEXPAND | wxALL, 5); | |
1274 | sizerTop->Add(check, 1, wxEXPAND | wxALL, 5); | |
1275 | ||
cbc66a27 VZ |
1276 | SetSizer(sizerTop); |
1277 | ||
1278 | sizerTop->SetSizeHints(this); | |
1279 | sizerTop->Fit(this); | |
4c45f240 | 1280 | } |
abceee76 | 1281 | |
5d987909 VZ |
1282 | void MyModelessDialog::OnButton(wxCommandEvent& WXUNUSED(event)) |
1283 | { | |
2f1cd905 | 1284 | wxMessageBox(_T("Button pressed in modeless dialog"), _T("Info"), |
5d987909 VZ |
1285 | wxOK | wxICON_INFORMATION, this); |
1286 | } | |
1287 | ||
abceee76 VZ |
1288 | void MyModelessDialog::OnClose(wxCloseEvent& event) |
1289 | { | |
1290 | if ( event.CanVeto() ) | |
1291 | { | |
2f1cd905 | 1292 | wxMessageBox(_T("Use the menu item to close this dialog"), |
78a189c9 | 1293 | _T("Modeless dialog"), |
abceee76 VZ |
1294 | wxOK | wxICON_INFORMATION, this); |
1295 | ||
1296 | event.Veto(); | |
1297 | } | |
1298 | } | |
1299 | ||
f6bcfd97 BP |
1300 | // ---------------------------------------------------------------------------- |
1301 | // MyModalDialog | |
1302 | // ---------------------------------------------------------------------------- | |
1303 | ||
1304 | MyModalDialog::MyModalDialog(wxWindow *parent) | |
13188def | 1305 | : wxDialog(parent, wxID_ANY, wxString(_T("Modal dialog"))) |
f6bcfd97 BP |
1306 | { |
1307 | wxBoxSizer *sizerTop = new wxBoxSizer(wxHORIZONTAL); | |
1308 | ||
13188def WS |
1309 | m_btnModal = new wxButton(this, wxID_ANY, _T("&Modal dialog...")); |
1310 | m_btnModeless = new wxButton(this, wxID_ANY, _T("Mode&less dialog")); | |
1311 | m_btnDelete = new wxButton(this, wxID_ANY, _T("&Delete button")); | |
5315ebfa | 1312 | |
78a189c9 | 1313 | wxButton *btnOk = new wxButton(this, wxID_CANCEL, _T("&Close")); |
5315ebfa VZ |
1314 | sizerTop->Add(m_btnModal, 0, wxALIGN_CENTER | wxALL, 5); |
1315 | sizerTop->Add(m_btnModeless, 0, wxALIGN_CENTER | wxALL, 5); | |
f6bcfd97 | 1316 | sizerTop->Add(m_btnDelete, 0, wxALIGN_CENTER | wxALL, 5); |
9b70bb91 | 1317 | sizerTop->Add(btnOk, 0, wxALIGN_CENTER | wxALL, 5); |
f6bcfd97 | 1318 | |
f6bcfd97 BP |
1319 | SetSizer(sizerTop); |
1320 | ||
1321 | sizerTop->SetSizeHints(this); | |
1322 | sizerTop->Fit(this); | |
1323 | ||
5315ebfa VZ |
1324 | m_btnModal->SetFocus(); |
1325 | m_btnModal->SetDefault(); | |
f6bcfd97 BP |
1326 | } |
1327 | ||
1328 | void MyModalDialog::OnButton(wxCommandEvent& event) | |
1329 | { | |
1330 | if ( event.GetEventObject() == m_btnDelete ) | |
1331 | { | |
5315ebfa VZ |
1332 | delete m_btnModal; |
1333 | m_btnModal = NULL; | |
f6bcfd97 BP |
1334 | |
1335 | m_btnDelete->Disable(); | |
1336 | } | |
5315ebfa | 1337 | else if ( event.GetEventObject() == m_btnModal ) |
f6bcfd97 | 1338 | { |
13188def | 1339 | #if wxUSE_TEXTDLG |
78a189c9 VZ |
1340 | wxGetTextFromUser(_T("Dummy prompt"), |
1341 | _T("Modal dialog called from dialog"), | |
dabbc6a5 | 1342 | wxEmptyString, this); |
13188def WS |
1343 | #else |
1344 | wxMessageBox(_T("Modal dialog called from dialog")); | |
1345 | #endif // wxUSE_TEXTDLG | |
f6bcfd97 | 1346 | } |
5315ebfa VZ |
1347 | else if ( event.GetEventObject() == m_btnModeless ) |
1348 | { | |
1349 | (new MyModelessDialog(this))->Show(); | |
1350 | } | |
f6bcfd97 BP |
1351 | else |
1352 | { | |
1353 | event.Skip(); | |
1354 | } | |
1355 | } | |
b4954d19 WS |
1356 | |
1357 | #endif // USE_MODAL_PRESENTATION | |
1358 | ||
0f5d8ecf JS |
1359 | // ---------------------------------------------------------------------------- |
1360 | // SettingsDialog | |
1361 | // ---------------------------------------------------------------------------- | |
1362 | ||
1363 | IMPLEMENT_CLASS(SettingsDialog, wxPropertySheetDialog) | |
1364 | ||
1365 | BEGIN_EVENT_TABLE(SettingsDialog, wxPropertySheetDialog) | |
1366 | END_EVENT_TABLE() | |
1367 | ||
1368 | SettingsDialog::SettingsDialog(wxWindow* win) | |
1369 | { | |
0f4991f4 | 1370 | SetExtraStyle(wxDIALOG_EX_CONTEXTHELP|wxWS_EX_VALIDATE_RECURSIVELY); |
0f5d8ecf | 1371 | |
6dc7c02c | 1372 | Create(win, -1, _("Preferences"), wxDefaultPosition, wxDefaultSize); |
0f5d8ecf JS |
1373 | CreateButtons(wxOK|wxCANCEL|wxHELP); |
1374 | ||
1375 | wxBookCtrlBase* notebook = GetBookCtrl(); | |
1376 | ||
1377 | wxPanel* generalSettings = CreateGeneralSettingsPage(notebook); | |
1378 | wxPanel* aestheticSettings = CreateAestheticSettingsPage(notebook); | |
1379 | ||
1380 | notebook->AddPage(generalSettings, _("General")); | |
1381 | notebook->AddPage(aestheticSettings, _("Aesthetics")); | |
1382 | ||
1383 | LayoutDialog(); | |
1384 | } | |
1385 | ||
1386 | wxPanel* SettingsDialog::CreateGeneralSettingsPage(wxWindow* parent) | |
1387 | { | |
1388 | wxPanel* panel = new wxPanel(parent, wxID_ANY); | |
1389 | ||
1390 | wxBoxSizer *topSizer = new wxBoxSizer( wxVERTICAL ); | |
1391 | wxBoxSizer *item0 = new wxBoxSizer( wxVERTICAL ); | |
1392 | ||
1393 | //// LOAD LAST FILE | |
1394 | ||
1395 | wxBoxSizer* itemSizer3 = new wxBoxSizer( wxHORIZONTAL ); | |
1396 | wxCheckBox* checkBox3 = new wxCheckBox(panel, ID_LOAD_LAST_PROJECT, _("&Load last project on startup"), wxDefaultPosition, wxDefaultSize); | |
1397 | itemSizer3->Add(checkBox3, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5); | |
1398 | item0->Add(itemSizer3, 0, wxGROW|wxALL, 0); | |
1399 | ||
1400 | //// AUTOSAVE | |
1401 | ||
1402 | wxString autoSaveLabel = _("&Auto-save every"); | |
1403 | wxString minsLabel = _("mins"); | |
1404 | ||
1405 | wxBoxSizer* itemSizer12 = new wxBoxSizer( wxHORIZONTAL ); | |
1406 | wxCheckBox* checkBox12 = new wxCheckBox(panel, ID_AUTO_SAVE, autoSaveLabel, wxDefaultPosition, wxDefaultSize); | |
62675ef3 JS |
1407 | |
1408 | #if wxUSE_SPINCTRL | |
0f5d8ecf JS |
1409 | wxSpinCtrl* spinCtrl12 = new wxSpinCtrl(panel, ID_AUTO_SAVE_MINS, wxEmptyString, |
1410 | wxDefaultPosition, wxSize(40, -1), wxSP_ARROW_KEYS, 1, 60, 1); | |
62675ef3 | 1411 | #endif |
0f5d8ecf JS |
1412 | |
1413 | itemSizer12->Add(checkBox12, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5); | |
62675ef3 | 1414 | #if wxUSE_SPINCTRL |
0f5d8ecf | 1415 | itemSizer12->Add(spinCtrl12, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5); |
62675ef3 | 1416 | #endif |
0f5d8ecf JS |
1417 | itemSizer12->Add(new wxStaticText(panel, wxID_STATIC, minsLabel), 0, wxALL|wxALIGN_CENTER_VERTICAL, 5); |
1418 | item0->Add(itemSizer12, 0, wxGROW|wxALL, 0); | |
1419 | ||
1420 | //// TOOLTIPS | |
1421 | ||
1422 | wxBoxSizer* itemSizer8 = new wxBoxSizer( wxHORIZONTAL ); | |
1423 | wxCheckBox* checkBox6 = new wxCheckBox(panel, ID_SHOW_TOOLTIPS, _("Show &tooltips"), wxDefaultPosition, wxDefaultSize); | |
1424 | itemSizer8->Add(checkBox6, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5); | |
1425 | item0->Add(itemSizer8, 0, wxGROW|wxALL, 0); | |
1426 | ||
1427 | topSizer->Add( item0, 1, wxGROW|wxALIGN_CENTRE|wxALL, 5 ); | |
1428 | ||
1429 | panel->SetSizer(topSizer); | |
1430 | topSizer->Fit(panel); | |
1431 | ||
1432 | return panel; | |
1433 | } | |
1434 | ||
1435 | wxPanel* SettingsDialog::CreateAestheticSettingsPage(wxWindow* parent) | |
1436 | { | |
1437 | wxPanel* panel = new wxPanel(parent, wxID_ANY); | |
1438 | ||
1439 | wxBoxSizer *topSizer = new wxBoxSizer( wxVERTICAL ); | |
1440 | wxBoxSizer *item0 = new wxBoxSizer( wxVERTICAL ); | |
1441 | ||
1442 | //// PROJECT OR GLOBAL | |
1443 | wxString globalOrProjectChoices[2]; | |
1444 | globalOrProjectChoices[0] = _("&New projects"); | |
1445 | globalOrProjectChoices[1] = _("&This project"); | |
1446 | ||
1447 | wxRadioBox* projectOrGlobal = new wxRadioBox(panel, ID_APPLY_SETTINGS_TO, _("&Apply settings to:"), | |
1448 | wxDefaultPosition, wxDefaultSize, 2, globalOrProjectChoices); | |
1449 | item0->Add(projectOrGlobal, 0, wxGROW|wxALL, 5); | |
1450 | ||
1451 | projectOrGlobal->SetSelection(0); | |
1452 | ||
1453 | //// BACKGROUND STYLE | |
1454 | wxArrayString backgroundStyleChoices; | |
1455 | backgroundStyleChoices.Add(wxT("Colour")); | |
1456 | backgroundStyleChoices.Add(wxT("Image")); | |
1457 | wxStaticBox* staticBox3 = new wxStaticBox(panel, -1, _("Background style:")); | |
1458 | ||
1459 | wxBoxSizer* styleSizer = new wxStaticBoxSizer( staticBox3, wxVERTICAL ); | |
1460 | item0->Add(styleSizer, 0, wxGROW|wxALL, 5); | |
1461 | ||
1462 | wxBoxSizer* itemSizer2 = new wxBoxSizer( wxHORIZONTAL ); | |
1463 | ||
1464 | wxChoice* choice2 = new wxChoice(panel, ID_BACKGROUND_STYLE, wxDefaultPosition, wxDefaultSize, backgroundStyleChoices); | |
1465 | ||
1466 | itemSizer2->Add(new wxStaticText(panel, wxID_ANY, _("&Window:")), 0, wxALL|wxALIGN_CENTER_VERTICAL, 5); | |
1467 | itemSizer2->Add(5, 5, 1, wxALL, 0); | |
1468 | itemSizer2->Add(choice2, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5); | |
1469 | ||
1470 | styleSizer->Add(itemSizer2, 0, wxGROW|wxALL, 5); | |
1471 | ||
62675ef3 | 1472 | #if wxUSE_SPINCTRL |
0f5d8ecf JS |
1473 | //// FONT SIZE SELECTION |
1474 | ||
1475 | wxStaticBox* staticBox1 = new wxStaticBox(panel, -1, _("Tile font size:")); | |
1476 | wxBoxSizer* itemSizer5 = new wxStaticBoxSizer( staticBox1, wxHORIZONTAL ); | |
1477 | ||
1478 | wxSpinCtrl* spinCtrl = new wxSpinCtrl(panel, ID_FONT_SIZE, wxEmptyString, wxDefaultPosition, | |
1479 | wxSize(80, -1)); | |
1480 | itemSizer5->Add(spinCtrl, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5); | |
1481 | ||
1482 | item0->Add(itemSizer5, 0, wxGROW|wxLEFT|wxRIGHT, 5); | |
62675ef3 | 1483 | #endif |
0f5d8ecf JS |
1484 | |
1485 | topSizer->Add( item0, 1, wxGROW|wxALIGN_CENTRE|wxALL, 5 ); | |
0f4991f4 | 1486 | topSizer->AddSpacer(5); |
0f5d8ecf JS |
1487 | |
1488 | panel->SetSizer(topSizer); | |
1489 | topSizer->Fit(panel); | |
1490 | ||
1491 | return panel; | |
1492 | } | |
1493 |