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