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