]> git.saurik.com Git - wxWidgets.git/blame - samples/dialogs/dialogs.cpp
Fixed Cmd+Back, Cmd+Del word deletion behaviour in wxRichTextCtrl.
[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"
1baa0a9d 30#include "wx/minifram.h"
684883e3 31#include "wx/sysopt.h"
e36a1739 32#include "wx/notifmsg.h"
457814b5 33
13188def
WS
34#if wxUSE_COLOURDLG
35 #include "wx/colordlg.h"
36#endif // wxUSE_COLOURDLG
dfad0599 37
13188def
WS
38#if wxUSE_CHOICEDLG
39 #include "wx/choicdlg.h"
40#endif // wxUSE_CHOICEDLG
457814b5 41
13188def
WS
42#if wxUSE_STARTUP_TIPS
43 #include "wx/tipdlg.h"
44#endif // wxUSE_STARTUP_TIPS
d7d17624 45
13188def 46#if wxUSE_PROGRESSDLG
9b16ffef 47#if wxUSE_STOPWATCH && wxUSE_LONGLONG
b20edf8b 48 #include "wx/datetime.h" // wxDateTime
9b16ffef
VZ
49#endif
50
13188def
WS
51 #include "wx/progdlg.h"
52#endif // wxUSE_PROGRESSDLG
53
ca7adbf8
VZ
54#if wxUSE_ABOUTDLG
55 #include "wx/aboutdlg.h"
453c9e3b
VZ
56
57 // these headers are only needed for custom about dialog
58 #include "wx/statline.h"
59 #include "wx/generic/aboutdlgg.h"
ca7adbf8
VZ
60#endif // wxUSE_ABOUTDLG
61
13188def
WS
62#if wxUSE_BUSYINFO
63 #include "wx/busyinfo.h"
64#endif // wxUSE_BUSYINFO
65
66#if wxUSE_NUMBERDLG
67 #include "wx/numdlg.h"
68#endif // wxUSE_NUMBERDLG
69
70#if wxUSE_FILEDLG
71 #include "wx/filedlg.h"
72#endif // wxUSE_FILEDLG
73
74#if wxUSE_DIRDLG
75 #include "wx/dirdlg.h"
76#endif // wxUSE_DIRDLG
77
78#if wxUSE_FONTDLG
79 #include "wx/fontdlg.h"
80#endif // wxUSE_FONTDLG
81
82#if wxUSE_FINDREPLDLG
83 #include "wx/fdrepdlg.h"
84#endif // wxUSE_FINDREPLDLG
4ad3c82f 85
62675ef3 86#if wxUSE_SPINCTRL
0f5d8ecf 87#include "wx/spinctrl.h"
62675ef3
JS
88#endif
89
0f5d8ecf
JS
90#include "wx/propdlg.h"
91
457814b5
JS
92#include "dialogs.h"
93
13188def
WS
94#if USE_COLOURDLG_GENERIC
95 #include "wx/generic/colrdlgg.h"
96#endif // USE_COLOURDLG_GENERIC
97
13188def
WS
98#if USE_DIRDLG_GENERIC
99 #include "wx/generic/dirdlgg.h"
100#endif // USE_DIRDLG_GENERIC
101
695fe764
WS
102#if USE_FILEDLG_GENERIC
103 #include "wx/generic/filedlgg.h"
104#endif // USE_FILEDLG_GENERIC
105
106#if USE_FONTDLG_GENERIC
107 #include "wx/generic/fontdlgg.h"
108#endif // USE_FONTDLG_GENERIC
109
457814b5
JS
110IMPLEMENT_APP(MyApp)
111
4c45f240
VZ
112BEGIN_EVENT_TABLE(MyCanvas, wxScrolledWindow)
113 EVT_PAINT(MyCanvas::OnPaint)
114END_EVENT_TABLE()
115
13188def
WS
116
117
4c45f240 118BEGIN_EVENT_TABLE(MyFrame, wxFrame)
8cf304f8 119#if wxUSE_MSGDLG
13188def 120 EVT_MENU(DIALOGS_MESSAGE_BOX, MyFrame::MessageBox)
8cf304f8
VZ
121 EVT_MENU(DIALOGS_MESSAGE_BOX_WXINFO, MyFrame::MessageBoxInfo)
122#endif // wxUSE_MSGDLG
13188def 123#if wxUSE_COLOURDLG
4c45f240 124 EVT_MENU(DIALOGS_CHOOSE_COLOUR, MyFrame::ChooseColour)
e6ef9ea4 125 EVT_MENU(DIALOGS_GET_COLOUR, MyFrame::GetColour)
13188def
WS
126#endif // wxUSE_COLOURDLG
127
128#if wxUSE_FONTDLG
4c45f240 129 EVT_MENU(DIALOGS_CHOOSE_FONT, MyFrame::ChooseFont)
13188def
WS
130#endif // wxUSE_FONTDLG
131
132#if wxUSE_LOG_DIALOG
4c45f240 133 EVT_MENU(DIALOGS_LOG_DIALOG, MyFrame::LogDialog)
13188def
WS
134#endif // wxUSE_LOG_DIALOG
135
136#if wxUSE_TEXTDLG
4c45f240
VZ
137 EVT_MENU(DIALOGS_TEXT_ENTRY, MyFrame::TextEntry)
138 EVT_MENU(DIALOGS_PASSWORD_ENTRY, MyFrame::PasswordEntry)
13188def
WS
139#endif // wxUSE_TEXTDLG
140
141#if wxUSE_NUMBERDLG
4c45f240 142 EVT_MENU(DIALOGS_NUM_ENTRY, MyFrame::NumericEntry)
13188def
WS
143#endif // wxUSE_NUMBERDLG
144
145#if wxUSE_CHOICEDLG
4c45f240 146 EVT_MENU(DIALOGS_SINGLE_CHOICE, MyFrame::SingleChoice)
d6c9c1b7 147 EVT_MENU(DIALOGS_MULTI_CHOICE, MyFrame::MultiChoice)
13188def
WS
148#endif // wxUSE_CHOICEDLG
149
150#if wxUSE_FILEDLG
4c45f240 151 EVT_MENU(DIALOGS_FILE_OPEN, MyFrame::FileOpen)
35b45b33 152 EVT_MENU(DIALOGS_FILE_OPEN2, MyFrame::FileOpen2)
4c45f240
VZ
153 EVT_MENU(DIALOGS_FILES_OPEN, MyFrame::FilesOpen)
154 EVT_MENU(DIALOGS_FILE_SAVE, MyFrame::FileSave)
13188def
WS
155#endif // wxUSE_FILEDLG
156
695fe764
WS
157#if USE_FILEDLG_GENERIC
158 EVT_MENU(DIALOGS_FILE_OPEN_GENERIC, MyFrame::FileOpenGeneric)
159 EVT_MENU(DIALOGS_FILES_OPEN_GENERIC, MyFrame::FilesOpenGeneric)
160 EVT_MENU(DIALOGS_FILE_SAVE_GENERIC, MyFrame::FileSaveGeneric)
161#endif // USE_FILEDLG_GENERIC
162
13188def 163#if wxUSE_DIRDLG
4c45f240 164 EVT_MENU(DIALOGS_DIR_CHOOSE, MyFrame::DirChoose)
f09c8393 165 EVT_MENU(DIALOGS_DIRNEW_CHOOSE, MyFrame::DirChooseNew)
13188def
WS
166#endif // wxUSE_DIRDLG
167
168#if USE_MODAL_PRESENTATION
f6bcfd97 169 EVT_MENU(DIALOGS_MODAL, MyFrame::ModalDlg)
1baa0a9d 170#endif // USE_MODAL_PRESENTATION
4c45f240 171 EVT_MENU(DIALOGS_MODELESS, MyFrame::ModelessDlg)
cae50e6b
VZ
172 EVT_MENU(DIALOGS_CENTRE_SCREEN, MyFrame::DlgCenteredScreen)
173 EVT_MENU(DIALOGS_CENTRE_PARENT, MyFrame::DlgCenteredParent)
1baa0a9d 174 EVT_MENU(DIALOGS_MINIFRAME, MyFrame::MiniFrame)
8e5dbcdd 175 EVT_MENU(DIALOGS_ONTOP, MyFrame::DlgOnTop)
13188def
WS
176
177#if wxUSE_STARTUP_TIPS
4c45f240 178 EVT_MENU(DIALOGS_TIP, MyFrame::ShowTip)
13188def
WS
179#endif // wxUSE_STARTUP_TIPS
180
181#if USE_FONTDLG_GENERIC
4c45f240 182 EVT_MENU(DIALOGS_CHOOSE_FONT_GENERIC, MyFrame::ChooseFontGeneric)
13188def
WS
183#endif // USE_FONTDLG_GENERIC
184
185#if USE_DIRDLG_GENERIC
186 EVT_MENU(DIALOGS_GENERIC_DIR_CHOOSE, MyFrame::GenericDirChoose)
187#endif // wxMSW || wxMAC
188
189#if USE_COLOURDLG_GENERIC
190 EVT_MENU(DIALOGS_CHOOSE_COLOUR_GENERIC, MyFrame::ChooseColourGeneric)
191#endif // USE_COLOURDLG_GENERIC
a62b0bcc 192
abceee76
VZ
193#if wxUSE_PROGRESSDLG
194 EVT_MENU(DIALOGS_PROGRESS, MyFrame::ShowProgress)
761989ff 195#endif // wxUSE_PROGRESSDLG
a62b0bcc 196
ca7adbf8
VZ
197#if wxUSE_ABOUTDLG
198 EVT_MENU(DIALOGS_ABOUTDLG_SIMPLE, MyFrame::ShowSimpleAboutDialog)
199 EVT_MENU(DIALOGS_ABOUTDLG_FANCY, MyFrame::ShowFancyAboutDialog)
453c9e3b
VZ
200 EVT_MENU(DIALOGS_ABOUTDLG_FULL, MyFrame::ShowFullAboutDialog)
201 EVT_MENU(DIALOGS_ABOUTDLG_CUSTOM, MyFrame::ShowCustomAboutDialog)
ca7adbf8
VZ
202#endif // wxUSE_ABOUTDLG
203
a62b0bcc
VZ
204#if wxUSE_BUSYINFO
205 EVT_MENU(DIALOGS_BUSYINFO, MyFrame::ShowBusyInfo)
206#endif // wxUSE_BUSYINFO
207
761989ff
VZ
208#if wxUSE_FINDREPLDLG
209 EVT_MENU(DIALOGS_FIND, MyFrame::ShowFindDialog)
210 EVT_MENU(DIALOGS_REPLACE, MyFrame::ShowReplaceDialog)
211
13188def
WS
212 EVT_FIND(wxID_ANY, MyFrame::OnFindDialog)
213 EVT_FIND_NEXT(wxID_ANY, MyFrame::OnFindDialog)
214 EVT_FIND_REPLACE(wxID_ANY, MyFrame::OnFindDialog)
215 EVT_FIND_REPLACE_ALL(wxID_ANY, MyFrame::OnFindDialog)
216 EVT_FIND_CLOSE(wxID_ANY, MyFrame::OnFindDialog)
761989ff 217#endif // wxUSE_FINDREPLDLG
13188def 218
532d575b 219#if USE_SETTINGS_DIALOG
0f5d8ecf 220 EVT_MENU(DIALOGS_PROPERTY_SHEET, MyFrame::OnPropertySheet)
64d3ed17
JS
221 EVT_MENU(DIALOGS_PROPERTY_SHEET_TOOLBOOK, MyFrame::OnPropertySheet)
222 EVT_MENU(DIALOGS_PROPERTY_SHEET_BUTTONTOOLBOOK, MyFrame::OnPropertySheet)
e36a1739 223#endif // USE_SETTINGS_DIALOG
532d575b 224
8e1dac82 225 EVT_MENU(DIALOGS_STANDARD_BUTTON_SIZER_DIALOG, MyFrame::OnStandardButtonsSizerDialog)
a625c5b6 226 EVT_MENU(DIALOGS_TEST_DEFAULT_ACTION, MyFrame::OnTestDefaultActionDialog)
e36a1739 227
0f5d8ecf 228 EVT_MENU(DIALOGS_REQUEST, MyFrame::OnRequestUserAttention)
e36a1739
VZ
229#if wxUSE_NOTIFICATION_MESSAGE
230 EVT_MENU(DIALOGS_NOTIFY_AUTO, MyFrame::OnNotifMsgAuto)
231 EVT_MENU(DIALOGS_NOTIFY_SHOW, MyFrame::OnNotifMsgShow)
232 EVT_MENU(DIALOGS_NOTIFY_HIDE, MyFrame::OnNotifMsgHide)
233#endif // wxUSE_NOTIFICATION_MESSAGE
9b16ffef 234
4c45f240 235 EVT_MENU(wxID_EXIT, MyFrame::OnExit)
4c45f240 236END_EVENT_TABLE()
abceee76 237
13188def 238#if USE_MODAL_PRESENTATION
f6bcfd97 239
13188def
WS
240 BEGIN_EVENT_TABLE(MyModalDialog, wxDialog)
241 EVT_BUTTON(wxID_ANY, MyModalDialog::OnButton)
242 END_EVENT_TABLE()
5d987909 243
13188def
WS
244 BEGIN_EVENT_TABLE(MyModelessDialog, wxDialog)
245 EVT_BUTTON(DIALOGS_MODELESS_BTN, MyModelessDialog::OnButton)
246 EVT_CLOSE(MyModelessDialog::OnClose)
247 END_EVENT_TABLE()
248
249#endif // USE_MODAL_PRESENTATION
abceee76 250
8e1dac82
VZ
251BEGIN_EVENT_TABLE(StdButtonSizerDialog, wxDialog)
252 EVT_CHECKBOX(wxID_ANY, StdButtonSizerDialog::OnEvent)
253 EVT_RADIOBUTTON(wxID_ANY, StdButtonSizerDialog::OnEvent)
254END_EVENT_TABLE()
255
c67daf87 256MyCanvas *myCanvas = (MyCanvas *) NULL;
457814b5 257
457814b5 258// `Main program' equivalent, creating windows and returning main app frame
4c45f240 259bool MyApp::OnInit()
457814b5 260{
45e6e6f8
VZ
261 if ( !wxApp::OnInit() )
262 return false;
263
f517634c 264#if wxUSE_IMAGE
013e1fee 265 wxInitAllImageHandlers();
f517634c 266#endif
013e1fee 267
19bc1514 268 m_canvasTextColour = *wxBLACK;
13188def 269 m_canvasFont = *wxNORMAL_FONT;
457814b5 270
13188def
WS
271 // Create the main frame window
272 MyFrame *frame = new MyFrame((wxFrame *) NULL, _T("wxWidgets dialogs example"));
457814b5 273
13188def 274 // Make a menubar
ca7adbf8 275 wxMenu *menuDlg = new wxMenu;
dabbc6a5 276
ca7adbf8 277 menuDlg->Append(DIALOGS_MESSAGE_BOX, _T("&Message box\tCtrl-M"));
457814b5 278
457814b5 279
33bcca32 280#if wxUSE_COLOURDLG || wxUSE_FONTDLG || wxUSE_CHOICEDLG
f09c8393 281
33bcca32 282 wxMenu *choices_menu = new wxMenu;
f09c8393 283
33bcca32 284 #if wxUSE_COLOURDLG
e6ef9ea4
VZ
285 choices_menu->Append(DIALOGS_CHOOSE_COLOUR, _T("&Choose bg colour"));
286 choices_menu->Append(DIALOGS_GET_COLOUR, _T("&Choose fg colour"));
33bcca32 287 #endif // wxUSE_COLOURDLG
f09c8393 288
33bcca32
VZ
289 #if wxUSE_FONTDLG
290 choices_menu->Append(DIALOGS_CHOOSE_FONT, _T("Choose &font"));
291 #endif // wxUSE_FONTDLG
457814b5 292
33bcca32
VZ
293 #if wxUSE_CHOICEDLG
294 choices_menu->Append(DIALOGS_SINGLE_CHOICE, _T("&Single choice\tCtrl-C"));
295 choices_menu->Append(DIALOGS_MULTI_CHOICE, _T("M&ultiple choice\tCtrl-U"));
296 #endif // wxUSE_CHOICEDLG
695fe764 297
33bcca32
VZ
298 #if USE_COLOURDLG_GENERIC || USE_FONTDLG_GENERIC
299 choices_menu->AppendSeparator();
300 #endif // USE_COLOURDLG_GENERIC || USE_FONTDLG_GENERIC
695fe764 301
33bcca32
VZ
302 #if USE_COLOURDLG_GENERIC
303 choices_menu->Append(DIALOGS_CHOOSE_COLOUR_GENERIC, _T("&Choose colour (generic)"));
304 #endif // USE_COLOURDLG_GENERIC
695fe764 305
33bcca32
VZ
306 #if USE_FONTDLG_GENERIC
307 choices_menu->Append(DIALOGS_CHOOSE_FONT_GENERIC, _T("Choose &font (generic)"));
308 #endif // USE_FONTDLG_GENERIC
d93c719a 309
ca7adbf8 310 menuDlg->Append(wxID_ANY,_T("&Choices and selectors"),choices_menu);
33bcca32 311#endif // wxUSE_COLOURDLG || wxUSE_FONTDLG || wxUSE_CHOICEDLG
457814b5 312
457814b5 313
33bcca32 314#if wxUSE_TEXTDLG || wxUSE_NUMBERDLG
13188def 315
33bcca32 316 wxMenu *entry_menu = new wxMenu;
13188def 317
33bcca32
VZ
318 #if wxUSE_TEXTDLG
319 entry_menu->Append(DIALOGS_TEXT_ENTRY, _T("Text &entry\tCtrl-E"));
320 entry_menu->Append(DIALOGS_PASSWORD_ENTRY, _T("&Password entry\tCtrl-P"));
321 #endif // wxUSE_TEXTDLG
13188def 322
33bcca32
VZ
323 #if wxUSE_NUMBERDLG
324 entry_menu->Append(DIALOGS_NUM_ENTRY, _T("&Numeric entry\tCtrl-N"));
325 #endif // wxUSE_NUMBERDLG
13188def 326
ca7adbf8 327 menuDlg->Append(wxID_ANY,_T("&Entry dialogs"),entry_menu);
13188def 328
33bcca32 329#endif // wxUSE_TEXTDLG || wxUSE_NUMBERDLG
13188def
WS
330
331
33bcca32 332#if wxUSE_FILEDLG
13188def 333
33bcca32
VZ
334 wxMenu *filedlg_menu = new wxMenu;
335 filedlg_menu->Append(DIALOGS_FILE_OPEN, _T("&Open file\tCtrl-O"));
336 filedlg_menu->Append(DIALOGS_FILE_OPEN2, _T("&Second open file\tCtrl-2"));
337 filedlg_menu->Append(DIALOGS_FILES_OPEN, _T("Open &files\tCtrl-Q"));
338 filedlg_menu->Append(DIALOGS_FILE_SAVE, _T("Sa&ve file\tCtrl-S"));
695fe764 339
8ce68f7f
VZ
340#if USE_FILEDLG_GENERIC
341 filedlg_menu->AppendSeparator();
342 filedlg_menu->Append(DIALOGS_FILE_OPEN_GENERIC, _T("&Open file (generic)"));
343 filedlg_menu->Append(DIALOGS_FILES_OPEN_GENERIC, _T("Open &files (generic)"));
344 filedlg_menu->Append(DIALOGS_FILE_SAVE_GENERIC, _T("Sa&ve file (generic)"));
345#endif // USE_FILEDLG_GENERIC
695fe764 346
ca7adbf8 347 menuDlg->Append(wxID_ANY,_T("&File operations"),filedlg_menu);
13188def 348
33bcca32 349#endif // wxUSE_FILEDLG
13188def 350
33bcca32
VZ
351#if wxUSE_DIRDLG
352 wxMenu *dir_menu = new wxMenu;
13188def 353
33bcca32
VZ
354 dir_menu->Append(DIALOGS_DIR_CHOOSE, _T("&Choose a directory\tCtrl-D"));
355 dir_menu->Append(DIALOGS_DIRNEW_CHOOSE, _T("Choose a directory (with \"Ne&w\" button)\tShift-Ctrl-D"));
ca7adbf8 356 menuDlg->Append(wxID_ANY,_T("&Directory operations"),dir_menu);
13188def 357
33bcca32
VZ
358 #if USE_DIRDLG_GENERIC
359 dir_menu->AppendSeparator();
360 dir_menu->Append(DIALOGS_GENERIC_DIR_CHOOSE, _T("&Choose a directory (generic)"));
361 #endif // USE_DIRDLG_GENERIC
13188def 362
33bcca32 363#endif // wxUSE_DIRDLG
13188def
WS
364
365
8cf304f8
VZ
366#if wxUSE_STARTUP_TIPS || \
367 wxUSE_PROGRESSDLG || \
368 wxUSE_BUSYINFO || \
369 wxUSE_LOG_DIALOG || \
370 wxUSE_MSGDLG
13188def 371
33bcca32 372 wxMenu *info_menu = new wxMenu;
13188def 373
33bcca32
VZ
374 #if wxUSE_STARTUP_TIPS
375 info_menu->Append(DIALOGS_TIP, _T("&Tip of the day\tCtrl-T"));
376 #endif // wxUSE_STARTUP_TIPS
13188def 377
33bcca32
VZ
378 #if wxUSE_PROGRESSDLG
379 info_menu->Append(DIALOGS_PROGRESS, _T("Pro&gress dialog\tCtrl-G"));
380 #endif // wxUSE_PROGRESSDLG
13188def 381
33bcca32
VZ
382 #if wxUSE_BUSYINFO
383 info_menu->Append(DIALOGS_BUSYINFO, _T("&Busy info dialog\tCtrl-B"));
384 #endif // wxUSE_BUSYINFO
13188def 385
33bcca32
VZ
386 #if wxUSE_LOG_DIALOG
387 info_menu->Append(DIALOGS_LOG_DIALOG, _T("&Log dialog\tCtrl-L"));
388 #endif // wxUSE_LOG_DIALOG
13188def 389
8cf304f8
VZ
390 #if wxUSE_MSGDLG
391 info_menu->Append(DIALOGS_MESSAGE_BOX_WXINFO,
392 _T("&wxWidgets information\tCtrl-I"));
393 #endif // wxUSE_MSGDLG
394
ca7adbf8 395 menuDlg->Append(wxID_ANY,_T("&Informative dialogs"),info_menu);
13188def 396
33bcca32 397#endif // wxUSE_STARTUP_TIPS || wxUSE_PROGRESSDLG || wxUSE_BUSYINFO || wxUSE_LOG_DIALOG
13188def
WS
398
399
33bcca32
VZ
400#if wxUSE_FINDREPLDLG
401 wxMenu *find_menu = new wxMenu;
402 find_menu->AppendCheckItem(DIALOGS_FIND, _T("&Find dialog\tCtrl-F"));
403 find_menu->AppendCheckItem(DIALOGS_REPLACE, _T("Find and &replace dialog\tShift-Ctrl-F"));
ca7adbf8 404 menuDlg->Append(wxID_ANY,_T("&Searching"),find_menu);
33bcca32 405#endif // wxUSE_FINDREPLDLG
13188def 406
cae50e6b 407 wxMenu *dialogs_menu = new wxMenu;
1baa0a9d 408#if USE_MODAL_PRESENTATION
cae50e6b 409 dialogs_menu->Append(DIALOGS_MODAL, _T("&Modal dialog\tCtrl-W"));
1baa0a9d 410#endif // USE_MODAL_PRESENTATION
cae50e6b 411 dialogs_menu->AppendCheckItem(DIALOGS_MODELESS, _T("Mode&less dialog\tCtrl-Z"));
a8eb5f88
VZ
412 dialogs_menu->Append(DIALOGS_CENTRE_SCREEN, _T("Centered on &screen\tShift-Ctrl-1"));
413 dialogs_menu->Append(DIALOGS_CENTRE_PARENT, _T("Centered on &parent\tShift-Ctrl-2"));
1baa0a9d 414 dialogs_menu->Append(DIALOGS_MINIFRAME, _T("&Mini frame"));
8e5dbcdd 415 dialogs_menu->Append(DIALOGS_ONTOP, _T("Dialog staying on &top"));
ca7adbf8 416 menuDlg->Append(wxID_ANY, _T("&Generic dialogs"), dialogs_menu);
13188def 417
532d575b 418#if USE_SETTINGS_DIALOG
b40bb73e
VZ
419 wxMenu *sheet_menu = new wxMenu;
420 sheet_menu->Append(DIALOGS_PROPERTY_SHEET, _T("&Standard property sheet\tShift-Ctrl-P"));
421 sheet_menu->Append(DIALOGS_PROPERTY_SHEET_TOOLBOOK, _T("&Toolbook sheet\tShift-Ctrl-T"));
e031f1df 422
5c351979 423 if (wxPlatformIs(wxPORT_MAC))
230c9077
JS
424 sheet_menu->Append(DIALOGS_PROPERTY_SHEET_BUTTONTOOLBOOK, _T("Button &Toolbook sheet\tShift-Ctrl-U"));
425/*
b887dc7b 426#ifdef __WXMAC__
64d3ed17 427 sheet_menu->Append(DIALOGS_PROPERTY_SHEET_BUTTONTOOLBOOK, _T("Button &Toolbook sheet\tShift-Ctrl-U"));
b887dc7b 428#endif
230c9077 429*/
ca7adbf8 430 menuDlg->Append(wxID_ANY, _T("&Property sheets"), sheet_menu);
b40bb73e 431#endif // USE_SETTINGS_DIALOG
532d575b 432
e36a1739
VZ
433 wxMenu *menuNotif = new wxMenu;
434 menuNotif->Append(DIALOGS_REQUEST, _T("&Request user attention\tCtrl-R"));
435#if wxUSE_NOTIFICATION_MESSAGE
436 menuNotif->Append(DIALOGS_NOTIFY_AUTO, "&Automatically hidden notification");
437 menuNotif->Append(DIALOGS_NOTIFY_SHOW, "&Show manual notification");
438 menuNotif->Append(DIALOGS_NOTIFY_HIDE, "&Hide manual notification");
439#endif // wxUSE_NOTIFICATION_MESSAGE
440 menuDlg->AppendSubMenu(menuNotif, "&User notifications");
8e1dac82 441
e36a1739 442 menuDlg->Append(DIALOGS_STANDARD_BUTTON_SIZER_DIALOG, _T("&Standard Buttons Sizer Dialog"));
a625c5b6 443 menuDlg->Append(DIALOGS_TEST_DEFAULT_ACTION, _T("&Test dialog default action"));
ca7adbf8
VZ
444
445 menuDlg->AppendSeparator();
446 menuDlg->Append(wxID_EXIT, _T("E&xit\tAlt-X"));
9b16ffef 447
ca7adbf8
VZ
448#if wxUSE_ABOUTDLG
449 wxMenu *menuHelp = new wxMenu;
453c9e3b
VZ
450 menuHelp->Append(DIALOGS_ABOUTDLG_SIMPLE, _T("&About (simple)...\tF1"));
451 menuHelp->Append(DIALOGS_ABOUTDLG_FANCY, _T("About (&fancy)...\tShift-F1"));
452 menuHelp->Append(DIALOGS_ABOUTDLG_FULL, _T("About (f&ull)...\tCtrl-F1"));
453 menuHelp->Append(DIALOGS_ABOUTDLG_CUSTOM, _T("About (&custom)...\tCtrl-Shift-F1"));
ca7adbf8 454#endif // wxUSE_ABOUTDLG
13188def 455
ca7adbf8
VZ
456 wxMenuBar *menubar = new wxMenuBar;
457 menubar->Append(menuDlg, _T("&Dialogs"));
458#if wxUSE_ABOUTDLG
459 menubar->Append(menuHelp, _T("&Help"));
460#endif // wxUSE_ABOUTDLG
461
462 frame->SetMenuBar(menubar);
13188def
WS
463
464 myCanvas = new MyCanvas(frame);
465 myCanvas->SetBackgroundColour(*wxWHITE);
466
467 frame->Centre(wxBOTH);
468
469 // Show the frame
470 frame->Show(true);
471
472 SetTopWindow(frame);
473
474 return true;
457814b5
JS
475}
476
477// My frame constructor
4c45f240 478MyFrame::MyFrame(wxWindow *parent,
13188def
WS
479 const wxString& title)
480 : wxFrame(parent, wxID_ANY, title)
4c45f240 481{
0f5d8ecf 482 SetIcon(sample_xpm);
532d575b 483
13188def 484#if USE_MODAL_PRESENTATION
4c45f240 485 m_dialog = (MyModelessDialog *)NULL;
13188def 486#endif // USE_MODAL_PRESENTATION
f1e1ed3b 487
043dcdaa 488#if wxUSE_FINDREPLDLG
14fca738
VZ
489 m_dlgFind =
490 m_dlgReplace = NULL;
043dcdaa 491#endif
dabbc6a5
DS
492
493#if wxUSE_COLOURDLG
d33dd9ef 494 m_clrData.SetChooseFull(true);
e6ef9ea4 495 for (int i = 0; i < wxColourData::NUM_CUSTOM; i++)
d33dd9ef 496 {
e6ef9ea4
VZ
497 unsigned char n = i*16;
498 m_clrData.SetCustomColour(i, wxColour(n, n, n));
d33dd9ef 499 }
13188def 500#endif // wxUSE_COLOURDLG
f9d0e439 501
e36a1739
VZ
502#if wxUSE_NOTIFICATION_MESSAGE
503 m_notifMsg = NULL;
504#endif // wxUSE_NOTIFICATION_MESSAGE
505
f9d0e439
VZ
506#if wxUSE_STATUSBAR
507 CreateStatusBar();
508#endif // wxUSE_STATUSBAR
4c45f240 509}
457814b5 510
e36a1739
VZ
511MyFrame::~MyFrame()
512{
513#if wxUSE_NOTIFICATION_MESSAGE
514 delete m_notifMsg;
515#endif // wxUSE_NOTIFICATION_MESSAGE
516}
517
13188def 518#if wxUSE_COLOURDLG
e6ef9ea4
VZ
519
520void MyFrame::ChooseColour(wxCommandEvent& WXUNUSED(event))
457814b5 521{
d33dd9ef 522 m_clrData.SetColour(myCanvas->GetBackgroundColour());
d93c719a 523
d33dd9ef 524 wxColourDialog dialog(this, &m_clrData);
e6ef9ea4
VZ
525 dialog.SetTitle(_("Please choose the background colour"));
526 if ( dialog.ShowModal() == wxID_OK )
f6bcfd97 527 {
d33dd9ef
VS
528 m_clrData = dialog.GetColourData();
529 myCanvas->SetBackgroundColour(m_clrData.GetColour());
1d14c005 530 myCanvas->ClearBackground();
457814b5 531 myCanvas->Refresh();
f6bcfd97 532 }
457814b5 533}
e6ef9ea4
VZ
534
535void MyFrame::GetColour(wxCommandEvent& WXUNUSED(event))
536{
537 wxColour clr = wxGetColourFromUser
538 (
539 this,
540 wxGetApp().m_canvasTextColour,
541 "Please choose the foreground colour"
542 );
543 if ( clr.IsOk() )
544 {
545 wxGetApp().m_canvasTextColour = clr;
546 myCanvas->Refresh();
547 }
548 //else: dialog cancelled by user
549}
550
13188def 551#endif // wxUSE_COLOURDLG
457814b5 552
e6ef9ea4 553
1e72e3cc
RN
554#if USE_COLOURDLG_GENERIC
555void MyFrame::ChooseColourGeneric(wxCommandEvent& WXUNUSED(event))
556{
557 m_clrData.SetColour(myCanvas->GetBackgroundColour());
558
559 //FIXME:TODO:This has no effect...
560 m_clrData.SetChooseFull(true);
561
562 for (int i = 0; i < 16; i++)
563 {
564 wxColour colour(
565 (unsigned char)(i*16),
566 (unsigned char)(i*16),
567 (unsigned char)(i*16)
568 );
569 m_clrData.SetCustomColour(i, colour);
570 }
571
572 wxGenericColourDialog *dialog = new wxGenericColourDialog(this, &m_clrData);
573 if (dialog->ShowModal() == wxID_OK)
574 {
575 m_clrData = dialog->GetColourData();
576 myCanvas->SetBackgroundColour(m_clrData.GetColour());
577 myCanvas->ClearBackground();
578 myCanvas->Refresh();
579 }
580 dialog->Destroy();
581}
582#endif // USE_COLOURDLG_GENERIC
583
13188def 584#if wxUSE_FONTDLG
d355d3fe 585void MyFrame::ChooseFont(wxCommandEvent& WXUNUSED(event) )
457814b5 586{
dbc65e27
VZ
587 wxFontData data;
588 data.SetInitialFont(wxGetApp().m_canvasFont);
589 data.SetColour(wxGetApp().m_canvasTextColour);
d93c719a 590
dbc65e27
VZ
591 // you might also do this:
592 //
593 // wxFontDialog dialog;
594 // if ( !dialog.Create(this, data) { ... error ... }
595 //
596 wxFontDialog dialog(this, data);
597
598 if (dialog.ShowModal() == wxID_OK)
599 {
600 wxFontData retData = dialog.GetFontData();
457814b5
JS
601 wxGetApp().m_canvasFont = retData.GetChosenFont();
602 wxGetApp().m_canvasTextColour = retData.GetColour();
603 myCanvas->Refresh();
dbc65e27
VZ
604 }
605 //else: cancelled by the user, don't change the font
457814b5 606}
13188def 607#endif // wxUSE_FONTDLG
457814b5 608
13188def 609#if USE_FONTDLG_GENERIC
d355d3fe 610void MyFrame::ChooseFontGeneric(wxCommandEvent& WXUNUSED(event) )
457814b5 611{
13188def
WS
612 wxFontData data;
613 data.SetInitialFont(wxGetApp().m_canvasFont);
614 data.SetColour(wxGetApp().m_canvasTextColour);
457814b5 615
ca3e85cf 616 wxGenericFontDialog *dialog = new wxGenericFontDialog(this, data);
13188def
WS
617 if (dialog->ShowModal() == wxID_OK)
618 {
457814b5
JS
619 wxFontData retData = dialog->GetFontData();
620 wxGetApp().m_canvasFont = retData.GetChosenFont();
621 wxGetApp().m_canvasTextColour = retData.GetColour();
622 myCanvas->Refresh();
13188def
WS
623 }
624 dialog->Destroy();
457814b5 625}
13188def 626#endif // USE_FONTDLG_GENERIC
d93c719a 627
b4954d19 628#if wxUSE_LOG_DIALOG
87728739 629void MyFrame::LogDialog(wxCommandEvent& WXUNUSED(event))
d93c719a 630{
2c8e4738
VZ
631 // calling wxYield() (as ~wxBusyCursor does) shouldn't result in messages
632 // being flushed -- test it
633 {
634 wxBusyCursor bc;
4693b20c
MB
635 wxLogMessage(wxT("This is some message - everything is ok so far."));
636 wxLogMessage(wxT("Another message...\n... this one is on multiple lines"));
637 wxLogWarning(wxT("And then something went wrong!"));
9fe52545
VZ
638
639 // and if ~wxBusyCursor doesn't do it, then call it manually
640 wxYield();
2c8e4738
VZ
641 }
642
4693b20c
MB
643 wxLogError(wxT("Intermediary error handler decided to abort."));
644 wxLogError(wxT("The top level caller detected an unrecoverable error."));
5888ef1e 645
7923c649
VZ
646 wxLog::FlushActive();
647
4693b20c 648 wxLogMessage(wxT("And this is the same dialog but with only one message."));
d93c719a 649}
b4954d19 650#endif // wxUSE_LOG_DIALOG
457814b5 651
8cf304f8 652#if wxUSE_MSGDLG
d355d3fe 653void MyFrame::MessageBox(wxCommandEvent& WXUNUSED(event) )
457814b5 654{
1d89da8a 655 wxMessageDialog dialog(this,
4223fc75
VZ
656 "This is a message box\n"
657 "A long, long string to test out the message box "
658 "layout properly.",
659 "Message box text",
1d89da8a 660 wxCENTER | wxNO_DEFAULT | wxYES_NO | wxCANCEL | wxICON_INFORMATION);
2afb9e16 661
4223fc75
VZ
662 wxString extmsg;
663 if ( dialog.SetYesNoCancelLabels
664 (
665 "Answer &Yes",
666 "Answer &No",
667 "Refuse to answer"
668 ) )
2afb9e16 669 {
4223fc75 670 extmsg = "This platform supports custom button labels,\n"
5150a29a 671 "so you should see the descriptive labels below.";
2afb9e16
VZ
672 }
673 else
674 {
4223fc75
VZ
675 extmsg = "Custom button labels are not supported on this platform,\n"
676 "so the default \"Yes\"/\"No\"/\"Cancel\" buttons are used.";
2afb9e16 677 }
4223fc75 678 dialog.SetExtendedMessage(extmsg);
457814b5 679
13188def
WS
680 switch ( dialog.ShowModal() )
681 {
682 case wxID_YES:
683 wxLogStatus(wxT("You pressed \"Yes\""));
684 break;
49b957be 685
13188def
WS
686 case wxID_NO:
687 wxLogStatus(wxT("You pressed \"No\""));
688 break;
49b957be 689
13188def
WS
690 case wxID_CANCEL:
691 wxLogStatus(wxT("You pressed \"Cancel\""));
692 break;
49b957be 693
13188def
WS
694 default:
695 wxLogError(wxT("Unexpected wxMessageDialog return code!"));
696 }
457814b5
JS
697}
698
8cf304f8
VZ
699void MyFrame::MessageBoxInfo(wxCommandEvent& WXUNUSED(event))
700{
701 ::wxInfoMessageBox(this);
702}
703#endif // wxUSE_MSGDLG
704
13188def 705#if wxUSE_NUMBERDLG
8cf304f8 706void MyFrame::NumericEntry(wxCommandEvent& WXUNUSED(event))
c49245f8 707{
78a189c9
VZ
708 long res = wxGetNumberFromUser( _T("This is some text, actually a lot of text.\n")
709 _T("Even two rows of text."),
710 _T("Enter a number:"), _T("Numeric input test"),
e65cc56a 711 50, 0, 100, this );
c49245f8
VZ
712
713 wxString msg;
714 int icon;
715 if ( res == -1 )
716 {
78a189c9 717 msg = _T("Invalid number entered or dialog cancelled.");
c49245f8
VZ
718 icon = wxICON_HAND;
719 }
720 else
d93c719a
VZ
721 {
722 msg.Printf(_T("You've entered %lu"), res );
c49245f8
VZ
723 icon = wxICON_INFORMATION;
724 }
725
78a189c9 726 wxMessageBox(msg, _T("Numeric test result"), wxOK | icon, this);
c49245f8 727}
13188def 728#endif // wxUSE_NUMBERDLG
c49245f8 729
13188def 730#if wxUSE_TEXTDLG
a294c6d5 731void MyFrame::PasswordEntry(wxCommandEvent& WXUNUSED(event))
457814b5 732{
2f1cd905 733 wxString pwd = wxGetPasswordFromUser(_T("Enter password:"),
78a189c9 734 _T("Password entry dialog"),
dabbc6a5 735 wxEmptyString,
a294c6d5 736 this);
ecda9475 737 if ( !pwd.empty() )
a294c6d5 738 {
4693b20c 739 wxMessageBox(wxString::Format(wxT("Your password is '%s'"), pwd.c_str()),
78a189c9 740 _T("Got password"), wxOK | wxICON_INFORMATION, this);
a294c6d5
VZ
741 }
742}
743
744void MyFrame::TextEntry(wxCommandEvent& WXUNUSED(event))
745{
13188def
WS
746 wxTextEntryDialog dialog(this,
747 _T("This is a small sample\n")
748 _T("A long, long string to test out the text entrybox"),
749 _T("Please enter a string"),
750 _T("Default value"),
751 wxOK | wxCANCEL);
457814b5 752
13188def
WS
753 if (dialog.ShowModal() == wxID_OK)
754 {
b4954d19 755 wxMessageBox(dialog.GetValue(), _T("Got string"), wxOK | wxICON_INFORMATION, this);
13188def 756 }
457814b5 757}
13188def 758#endif // wxUSE_TEXTDLG
457814b5 759
13188def 760#if wxUSE_CHOICEDLG
d355d3fe 761void MyFrame::SingleChoice(wxCommandEvent& WXUNUSED(event) )
457814b5 762{
78a189c9 763 const wxString choices[] = { _T("One"), _T("Two"), _T("Three"), _T("Four"), _T("Five") } ;
457814b5 764
5f95bb70 765 wxSingleChoiceDialog dialog(this,
78a189c9
VZ
766 _T("This is a small sample\n")
767 _T("A single-choice convenience dialog"),
768 _T("Please select a value"),
5f95bb70 769 WXSIZEOF(choices), choices);
457814b5 770
ef77f91e
JS
771 dialog.SetSelection(2);
772
773 if (dialog.ShowModal() == wxID_OK)
774 {
78a189c9 775 wxMessageDialog dialog2(this, dialog.GetStringSelection(), _T("Got string"));
ef77f91e
JS
776 dialog2.ShowModal();
777 }
457814b5
JS
778}
779
d6c9c1b7
VZ
780void MyFrame::MultiChoice(wxCommandEvent& WXUNUSED(event) )
781{
5f95bb70
VZ
782 const wxString choices[] =
783 {
78a189c9
VZ
784 _T("One"), _T("Two"), _T("Three"), _T("Four"), _T("Five"),
785 _T("Six"), _T("Seven"), _T("Eight"), _T("Nine"), _T("Ten"),
786 _T("Eleven"), _T("Twelve"), _T("Seventeen"),
5f95bb70 787 };
d6c9c1b7
VZ
788
789 wxArrayInt selections;
790 size_t count = wxGetMultipleChoices(selections,
78a189c9
VZ
791 _T("This is a small sample\n")
792 _T("A multi-choice convenience dialog"),
793 _T("Please select a value"),
5f95bb70 794 WXSIZEOF(choices), choices,
d6c9c1b7
VZ
795 this);
796 if ( count )
797 {
3d49ce44 798 wxString msg;
fba1b53b 799 msg.Printf(wxT("You selected %u items:\n"), (unsigned)count);
d6c9c1b7
VZ
800 for ( size_t n = 0; n < count; n++ )
801 {
fba1b53b
VZ
802 msg += wxString::Format(wxT("\t%u: %u (%s)\n"),
803 (unsigned)n, (unsigned)selections[n],
3d49ce44 804 choices[selections[n]].c_str());
d6c9c1b7 805 }
3d49ce44 806 wxLogMessage(msg);
d6c9c1b7
VZ
807 }
808 //else: cancelled or nothing selected
809}
13188def 810#endif // wxUSE_CHOICEDLG
d6c9c1b7 811
13188def 812#if wxUSE_FILEDLG
8ce68f7f
VZ
813
814// panel with custom controls for file dialog
815class MyExtraPanel : public wxPanel
816{
817public:
818 MyExtraPanel(wxWindow *parent);
819 void OnCheckBox(wxCommandEvent& event) { m_btn->Enable(event.IsChecked()); }
820 wxString GetInfo() const
821 {
822 return wxString::Format("checkbox value = %d", (int) m_cb->GetValue());
823 }
824private:
825 wxButton *m_btn;
826 wxCheckBox *m_cb;
827};
828
829MyExtraPanel::MyExtraPanel(wxWindow *parent)
830 : wxPanel(parent)
831{
832 m_btn = new wxButton(this, -1, _T("Custom Button"));
833 m_btn->Enable(false);
834 m_cb = new wxCheckBox(this, -1, _T("Enable Custom Button"));
835 m_cb->Connect(wxID_ANY, wxEVT_COMMAND_CHECKBOX_CLICKED,
836 wxCommandEventHandler(MyExtraPanel::OnCheckBox), NULL, this);
837 wxBoxSizer *sizerTop = new wxBoxSizer(wxHORIZONTAL);
838 sizerTop->Add(m_cb, wxSizerFlags().Centre().Border());
839 sizerTop->AddStretchSpacer();
840 sizerTop->Add(m_btn, wxSizerFlags().Right().Border());
841 SetSizerAndFit(sizerTop);
842}
843
844// a static method can be used instead of a function with most of compilers
845static wxWindow* createMyExtraPanel(wxWindow *parent)
846{
847 return new MyExtraPanel(parent);
848}
849
d355d3fe 850void MyFrame::FileOpen(wxCommandEvent& WXUNUSED(event) )
457814b5 851{
fbf4eacb
VZ
852 wxFileDialog dialog
853 (
854 this,
855 _T("Testing open file dialog"),
dabbc6a5
DS
856 wxEmptyString,
857 wxEmptyString,
a4e64fb5
MB
858#ifdef __WXMOTIF__
859 _T("C++ files (*.cpp)|*.cpp")
860#else
daf32463 861 _T("C++ files (*.cpp;*.h)|*.cpp;*.h")
a4e64fb5 862#endif
fbf4eacb 863 );
457814b5 864
8ce68f7f 865 dialog.SetExtraControlCreator(&createMyExtraPanel);
3b6c3fc8 866 dialog.CentreOnParent();
cd7afaff 867 dialog.SetDirectory(wxGetHomeDir());
5b636c67 868
c50f1fb9
VZ
869 if (dialog.ShowModal() == wxID_OK)
870 {
5919d76b 871 wxString info;
8ce68f7f
VZ
872 MyExtraPanel *extra_panel
873 = static_cast<MyExtraPanel*>(dialog.GetExtraControl());
13393ab6
RR
874 info.Printf(_T("Full file name: %s\n")
875 _T("Path: %s\n")
8ce68f7f
VZ
876 _T("Name: %s\n")
877 _T("Custom window: %s"),
5919d76b
VZ
878 dialog.GetPath().c_str(),
879 dialog.GetDirectory().c_str(),
8ce68f7f
VZ
880 dialog.GetFilename().c_str(),
881 extra_panel->GetInfo().c_str());
78a189c9 882 wxMessageDialog dialog2(this, info, _T("Selected file"));
c50f1fb9
VZ
883 dialog2.ShowModal();
884 }
457814b5
JS
885}
886
35b45b33
VZ
887// this shows how to take advantage of specifying a default extension in the
888// call to wxFileSelector: it is remembered after each new call and the next
889// one will use it by default
890void MyFrame::FileOpen2(wxCommandEvent& WXUNUSED(event) )
891{
892 static wxString s_extDef;
893 wxString path = wxFileSelector(
894 _T("Select the file to load"),
dabbc6a5 895 wxEmptyString, wxEmptyString,
35b45b33 896 s_extDef,
3601f639
VZ
897 wxString::Format
898 (
899 _T("Waveform (*.wav)|*.wav|Plain text (*.txt)|*.txt|All files (%s)|%s"),
900 wxFileSelectorDefaultWildcardStr,
901 wxFileSelectorDefaultWildcardStr
902 ),
9f057af5 903 wxFD_OPEN|wxFD_CHANGE_DIR|wxFD_PREVIEW,
35b45b33
VZ
904 this
905 );
906
907 if ( !path )
908 return;
909
910 // it is just a sample, would use wxSplitPath in real program
911 s_extDef = path.AfterLast(_T('.'));
912
913 wxLogMessage(_T("You selected the file '%s', remembered extension '%s'"),
a342cb00 914 path, s_extDef);
35b45b33
VZ
915}
916
c61f4f6d
VZ
917void MyFrame::FilesOpen(wxCommandEvent& WXUNUSED(event) )
918{
dabbc6a5 919 wxString wildcards =
f0f43012
JS
920#ifdef __WXMOTIF__
921 _T("C++ files (*.cpp)|*.cpp");
922#else
3601f639
VZ
923 wxString::Format
924 (
925 _T("All files (%s)|%s|C++ files (*.cpp;*.h)|*.cpp;*.h"),
926 wxFileSelectorDefaultWildcardStr,
927 wxFileSelectorDefaultWildcardStr
928 );
f0f43012 929#endif
78a189c9 930 wxFileDialog dialog(this, _T("Testing open multiple file dialog"),
dabbc6a5 931 wxEmptyString, wxEmptyString, wildcards,
ff3e84ff 932 wxFD_OPEN|wxFD_MULTIPLE);
c61f4f6d
VZ
933
934 if (dialog.ShowModal() == wxID_OK)
935 {
936 wxArrayString paths, filenames;
937
938 dialog.GetPaths(paths);
939 dialog.GetFilenames(filenames);
940
941 wxString msg, s;
942 size_t count = paths.GetCount();
943 for ( size_t n = 0; n < count; n++ )
944 {
945 s.Printf(_T("File %d: %s (%s)\n"),
fba1b53b 946 (int)n, paths[n].c_str(), filenames[n].c_str());
c61f4f6d
VZ
947
948 msg += s;
949 }
f0f43012
JS
950 s.Printf(_T("Filter index: %d"), dialog.GetFilterIndex());
951 msg += s;
c61f4f6d 952
78a189c9 953 wxMessageDialog dialog2(this, msg, _T("Selected files"));
c61f4f6d
VZ
954 dialog2.ShowModal();
955 }
956}
957
d355d3fe 958void MyFrame::FileSave(wxCommandEvent& WXUNUSED(event) )
457814b5 959{
2f1cd905
VZ
960 wxFileDialog dialog(this,
961 _T("Testing save file dialog"),
dabbc6a5 962 wxEmptyString,
2b5f62a0 963 _T("myletter.doc"),
3de9120b 964 _T("Text files (*.txt)|*.txt|Document files (*.doc;*.ods)|*.doc;*.ods"),
ff3e84ff 965 wxFD_SAVE|wxFD_OVERWRITE_PROMPT);
c50f1fb9 966
2b5f62a0
VZ
967 dialog.SetFilterIndex(1);
968
c50f1fb9
VZ
969 if (dialog.ShowModal() == wxID_OK)
970 {
2b5f62a0
VZ
971 wxLogMessage(_T("%s, filter %d"),
972 dialog.GetPath().c_str(), dialog.GetFilterIndex());
c50f1fb9 973 }
457814b5 974}
13188def 975#endif // wxUSE_FILEDLG
457814b5 976
695fe764
WS
977#if USE_FILEDLG_GENERIC
978void MyFrame::FileOpenGeneric(wxCommandEvent& WXUNUSED(event) )
979{
980 wxGenericFileDialog dialog
981 (
982 this,
983 _T("Testing open file dialog"),
984 wxEmptyString,
985 wxEmptyString,
daf32463 986 _T("C++ files (*.cpp;*.h)|*.cpp;*.h")
695fe764
WS
987 );
988
8ce68f7f 989 dialog.SetExtraControlCreator(&createMyExtraPanel);
695fe764
WS
990 dialog.SetDirectory(wxGetHomeDir());
991
992 if (dialog.ShowModal() == wxID_OK)
993 {
994 wxString info;
995 info.Printf(_T("Full file name: %s\n")
996 _T("Path: %s\n")
997 _T("Name: %s"),
998 dialog.GetPath().c_str(),
999 dialog.GetDirectory().c_str(),
1000 dialog.GetFilename().c_str());
1001 wxMessageDialog dialog2(this, info, _T("Selected file"));
1002 dialog2.ShowModal();
1003 }
1004}
1005
1006void MyFrame::FilesOpenGeneric(wxCommandEvent& WXUNUSED(event) )
1007{
684883e3
WS
1008 // On PocketPC you can disable OK-only dialogs policy using system option
1009 int buttons = wxSystemOptions::GetOptionInt(wxT("wince.dialog.real-ok-cancel"));
1010 wxSystemOptions::SetOption(wxT("wince.dialog.real-ok-cancel"), 1);
1011
daf32463 1012 wxString wildcards = _T("All files (*.*)|*.*|C++ files (*.cpp;*.h)|*.cpp;*.h");
695fe764
WS
1013 wxGenericFileDialog dialog(this, _T("Testing open multiple file dialog"),
1014 wxEmptyString, wxEmptyString, wildcards,
e031f1df 1015 wxFD_MULTIPLE);
695fe764
WS
1016
1017 if (dialog.ShowModal() == wxID_OK)
1018 {
1019 wxArrayString paths, filenames;
1020
1021 dialog.GetPaths(paths);
1022 dialog.GetFilenames(filenames);
1023
1024 wxString msg, s;
1025 size_t count = paths.GetCount();
1026 for ( size_t n = 0; n < count; n++ )
1027 {
1028 s.Printf(_T("File %d: %s (%s)\n"),
1029 (int)n, paths[n].c_str(), filenames[n].c_str());
1030
1031 msg += s;
1032 }
1033 s.Printf(_T("Filter index: %d"), dialog.GetFilterIndex());
1034 msg += s;
1035
1036 wxMessageDialog dialog2(this, msg, _T("Selected files"));
1037 dialog2.ShowModal();
1038 }
684883e3
WS
1039
1040 // restore system option
1041 wxSystemOptions::SetOption(wxT("wince.dialog.real-ok-cancel"), buttons);
695fe764
WS
1042}
1043
1044void MyFrame::FileSaveGeneric(wxCommandEvent& WXUNUSED(event) )
1045{
1046 wxGenericFileDialog dialog(this,
1047 _T("Testing save file dialog"),
1048 wxEmptyString,
1049 _T("myletter.doc"),
3de9120b 1050 _T("Text files (*.txt)|*.txt|Document files (*.doc;*.ods)|*.doc;*.ods"),
e031f1df 1051 wxFD_SAVE|wxFD_OVERWRITE_PROMPT);
695fe764
WS
1052
1053 dialog.SetFilterIndex(1);
1054
1055 if (dialog.ShowModal() == wxID_OK)
1056 {
1057 wxLogMessage(_T("%s, filter %d"),
1058 dialog.GetPath().c_str(), dialog.GetFilterIndex());
1059 }
1060}
1061#endif // USE_FILEDLG_GENERIC
1062
13188def 1063#if wxUSE_DIRDLG
f09c8393 1064void MyFrame::DoDirChoose(int style)
457814b5 1065{
3f2711d5
VZ
1066 // pass some initial dir to wxDirDialog
1067 wxString dirHome;
1068 wxGetHomeDir(&dirHome);
1069
f09c8393 1070 wxDirDialog dialog(this, _T("Testing directory picker"), dirHome, style);
c50f1fb9
VZ
1071
1072 if (dialog.ShowModal() == wxID_OK)
1073 {
2b5f62a0 1074 wxLogMessage(_T("Selected path: %s"), dialog.GetPath().c_str());
c50f1fb9
VZ
1075 }
1076}
1077
f09c8393
VZ
1078void MyFrame::DirChoose(wxCommandEvent& WXUNUSED(event) )
1079{
ff3e84ff 1080 DoDirChoose(wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST);
f09c8393
VZ
1081}
1082
1083void MyFrame::DirChooseNew(wxCommandEvent& WXUNUSED(event) )
1084{
ff3e84ff 1085 DoDirChoose(wxDD_DEFAULT_STYLE & ~wxDD_DIR_MUST_EXIST);
f09c8393 1086}
13188def 1087#endif // wxUSE_DIRDLG
f09c8393 1088
13188def 1089#if USE_DIRDLG_GENERIC
51a58d8b
JS
1090void MyFrame::GenericDirChoose(wxCommandEvent& WXUNUSED(event) )
1091{
1092 // pass some initial dir to wxDirDialog
1093 wxString dirHome;
1094 wxGetHomeDir(&dirHome);
1095
78a189c9 1096 wxGenericDirDialog dialog(this, _T("Testing generic directory picker"), dirHome);
51a58d8b
JS
1097
1098 if (dialog.ShowModal() == wxID_OK)
1099 {
78a189c9 1100 wxMessageDialog dialog2(this, dialog.GetPath(), _T("Selected path"));
51a58d8b
JS
1101 dialog2.ShowModal();
1102 }
1103}
13188def 1104#endif // USE_DIRDLG_GENERIC
51a58d8b 1105
13188def 1106#if USE_MODAL_PRESENTATION
f6bcfd97
BP
1107void MyFrame::ModalDlg(wxCommandEvent& WXUNUSED(event))
1108{
1109 MyModalDialog dlg(this);
1110 dlg.ShowModal();
1111}
1baa0a9d 1112#endif // USE_MODAL_PRESENTATION
f6bcfd97 1113
4c45f240
VZ
1114void MyFrame::ModelessDlg(wxCommandEvent& event)
1115{
2f82899b 1116 bool show = GetMenuBar()->IsChecked(event.GetId());
4c45f240
VZ
1117
1118 if ( show )
1119 {
1120 if ( !m_dialog )
1121 {
1122 m_dialog = new MyModelessDialog(this);
1123 }
1124
13188def 1125 m_dialog->Show(true);
4c45f240
VZ
1126 }
1127 else // hide
1128 {
26a12ab3
JS
1129 // If m_dialog is NULL, then possibly the system
1130 // didn't report the checked menu item status correctly.
1131 // It should be true just after the menu item was selected,
1132 // if there was no modeless dialog yet.
1133
1134 wxASSERT( m_dialog != NULL );
1135 if (m_dialog)
1136 m_dialog->Hide();
4c45f240
VZ
1137 }
1138}
cae50e6b
VZ
1139
1140void MyFrame::DlgCenteredScreen(wxCommandEvent& WXUNUSED(event))
1141{
1142 wxDialog dlg(this, wxID_ANY, _T("Dialog centered on screen"),
1143 wxDefaultPosition, wxSize(200, 100));
cd7afaff 1144 (new wxButton(&dlg, wxID_OK, _T("Close")))->Centre();
cae50e6b
VZ
1145 dlg.CentreOnScreen();
1146 dlg.ShowModal();
1147}
1148
1149void MyFrame::DlgCenteredParent(wxCommandEvent& WXUNUSED(event))
1150{
1151 wxDialog dlg(this, wxID_ANY, _T("Dialog centered on parent"),
1152 wxDefaultPosition, wxSize(200, 100));
cd7afaff 1153 (new wxButton(&dlg, wxID_OK, _T("Close")))->Centre();
cae50e6b
VZ
1154 dlg.CentreOnParent();
1155 dlg.ShowModal();
1156}
1157
1baa0a9d
VZ
1158void MyFrame::MiniFrame(wxCommandEvent& WXUNUSED(event))
1159{
1160 wxFrame *frame = new wxMiniFrame(this, wxID_ANY, _T("Mini frame"),
1161 wxDefaultPosition, wxSize(300, 100),
1162 wxCAPTION | wxCLOSE_BOX);
1163 new wxStaticText(frame,
1164 wxID_ANY,
1165 _T("Mini frames have slightly different appearance"),
1166 wxPoint(5, 5));
1167 new wxStaticText(frame,
1168 wxID_ANY,
1169 _T("from the normal frames but that's the only difference."),
1170 wxPoint(5, 25));
1171
1172 frame->CentreOnParent();
1173 frame->Show();
1174}
4c45f240 1175
8e5dbcdd
VZ
1176void MyFrame::DlgOnTop(wxCommandEvent& WXUNUSED(event))
1177{
1178 wxDialog dlg(this, wxID_ANY, _T("Dialog staying on top of other windows"),
1179 wxDefaultPosition, wxSize(300, 100),
1180 wxDEFAULT_DIALOG_STYLE | wxSTAY_ON_TOP);
1181 (new wxButton(&dlg, wxID_OK, _T("Close")))->Centre();
1182 dlg.ShowModal();
1183}
1184
13188def 1185#if wxUSE_STARTUP_TIPS
87728739 1186void MyFrame::ShowTip(wxCommandEvent& WXUNUSED(event))
c50f1fb9
VZ
1187{
1188 static size_t s_index = (size_t)-1;
1189
1190 if ( s_index == (size_t)-1 )
1191 {
1192 srand(time(NULL));
1193
1194 // this is completely bogus, we don't know how many lines are there
1195 // in the file, but who cares, it's a demo only...
1196 s_index = rand() % 5;
1197 }
1198
2f1cd905 1199 wxTipProvider *tipProvider = wxCreateFileTipProvider(_T("tips.txt"), s_index);
c50f1fb9
VZ
1200
1201 bool showAtStartup = wxShowTip(this, tipProvider);
1202
1203 if ( showAtStartup )
1204 {
2f1cd905 1205 wxMessageBox(_T("Will show tips on startup"), _T("Tips dialog"),
c50f1fb9
VZ
1206 wxOK | wxICON_INFORMATION, this);
1207 }
457814b5 1208
c50f1fb9
VZ
1209 s_index = tipProvider->GetCurrentTip();
1210 delete tipProvider;
457814b5 1211}
13188def 1212#endif // wxUSE_STARTUP_TIPS
457814b5 1213
532d575b 1214#if USE_SETTINGS_DIALOG
64d3ed17 1215void MyFrame::OnPropertySheet(wxCommandEvent& event)
0f5d8ecf 1216{
64d3ed17 1217 SettingsDialog dialog(this, event.GetId());
cc8bc5aa
JS
1218 dialog.ShowModal();
1219}
532d575b 1220#endif // USE_SETTINGS_DIALOG
0f5d8ecf 1221
9b16ffef
VZ
1222void MyFrame::OnRequestUserAttention(wxCommandEvent& WXUNUSED(event))
1223{
1224 wxLogStatus(_T("Sleeping for 3 seconds to allow you to switch to another window"));
1225
1226 wxSleep(3);
1227
1228 RequestUserAttention(wxUSER_ATTENTION_ERROR);
1229}
1230
e36a1739
VZ
1231#if wxUSE_NOTIFICATION_MESSAGE
1232
1233void MyFrame::OnNotifMsgAuto(wxCommandEvent& WXUNUSED(event))
1234{
1235 if ( !wxNotificationMessage
1236 (
1237 "Automatic Notification",
1238 "Nothing important has happened\n"
1239 "this notification will disappear soon."
1240 ).Show() )
1241 {
1242 wxLogStatus("Failed to show notification message");
1243 }
1244}
1245
1246void MyFrame::OnNotifMsgShow(wxCommandEvent& WXUNUSED(event))
1247{
1248 if ( !m_notifMsg )
1249 {
1250 m_notifMsg = new wxNotificationMessage
1251 (
1252 "wxWidgets Manual Notification",
1253 "You can hide this notification from the menu",
1254 this
1255 );
1256 }
1257
1258 if ( !m_notifMsg->Show(wxNotificationMessage::Timeout_Never) )
1259 {
1260 wxLogStatus("Failed to show manual notification message");
1261 }
1262}
1263
1264void MyFrame::OnNotifMsgHide(wxCommandEvent& WXUNUSED(event))
1265{
1266 if ( m_notifMsg )
1267 {
1268 if ( !m_notifMsg->Close() )
1269 wxLogStatus("Failed to hide manual notification message");
1270 }
1271}
1272
1273#endif // wxUSE_NOTIFICATION_MESSAGE
1274
8e1dac82
VZ
1275void MyFrame::OnStandardButtonsSizerDialog(wxCommandEvent& WXUNUSED(event))
1276{
1277 StdButtonSizerDialog dialog(this);
1278 dialog.ShowModal();
1279}
1280
a625c5b6
RR
1281// TestDefaultAction
1282
1283#define ID_CATCH_LISTBOX_DCLICK 100
1284#define ID_LISTBOX 101
1285
1286BEGIN_EVENT_TABLE(TestDefaultActionDialog, wxDialog)
1287 EVT_CHECKBOX(ID_CATCH_LISTBOX_DCLICK, TestDefaultActionDialog::OnCatchListBoxDClick)
1288 EVT_LISTBOX_DCLICK(ID_LISTBOX, TestDefaultActionDialog::OnListBoxDClick)
1289END_EVENT_TABLE()
1290
1291TestDefaultActionDialog::TestDefaultActionDialog( wxWindow *parent ) :
1292 wxDialog( parent, -1, "Test default action" )
1293{
1294 m_catchListBoxDClick = false;
1295
1296 wxBoxSizer *main_sizer = new wxBoxSizer( wxVERTICAL );
1297
1298 wxFlexGridSizer *grid_sizer = new wxFlexGridSizer( 2, 5, 5 );
1299
1300 wxListBox *listbox = new wxListBox( this, ID_LISTBOX );
1301 listbox->Append( "String 1" );
1302 listbox->Append( "String 2" );
1303 listbox->Append( "String 3" );
1304 listbox->Append( "String 4" );
1305 grid_sizer->Add( listbox );
1306
1307 grid_sizer->Add( new wxCheckBox( this, ID_CATCH_LISTBOX_DCLICK, "Catch DoubleClick from wxListBox" ), 0, wxALIGN_CENTRE_VERTICAL );
1308
1309 grid_sizer->Add( new wxTextCtrl( this, -1, "", wxDefaultPosition, wxSize(80,-1), 0 ), 0, wxALIGN_CENTRE_VERTICAL );
1310 grid_sizer->Add( new wxStaticText( this, -1, "wxTextCtrl without wxTE_PROCESS_ENTER" ), 0, wxALIGN_CENTRE_VERTICAL );
1311
1312 grid_sizer->Add( new wxTextCtrl( this, -1, "", wxDefaultPosition, wxSize(80,-1), wxTE_PROCESS_ENTER ), 0, wxALIGN_CENTRE_VERTICAL );
1313 grid_sizer->Add( new wxStaticText( this, -1, "wxTextCtrl with wxTE_PROCESS_ENTER" ), 0, wxALIGN_CENTRE_VERTICAL );
1314
1315 main_sizer->Add( grid_sizer, 0, wxALL, 10 );
1316
1317 wxSizer *button_sizer = CreateSeparatedButtonSizer( wxOK|wxCANCEL );
1318 if (button_sizer)
1319 main_sizer->Add( button_sizer, 0, wxALL|wxGROW, 5 );
1320
8ce68f7f 1321 SetSizerAndFit( main_sizer );
a625c5b6
RR
1322}
1323
1324void TestDefaultActionDialog::OnListBoxDClick(wxCommandEvent& event)
1325{
1326 event.Skip( !m_catchListBoxDClick );
1327}
1328
1329void TestDefaultActionDialog::OnCatchListBoxDClick(wxCommandEvent& WXUNUSED(event))
1330{
1331 m_catchListBoxDClick = !m_catchListBoxDClick;
1332}
1333
1334void MyFrame::OnTestDefaultActionDialog(wxCommandEvent& WXUNUSED(event))
1335{
1336 TestDefaultActionDialog dialog( this );
1337 dialog.ShowModal();
1338}
1339
d355d3fe 1340void MyFrame::OnExit(wxCommandEvent& WXUNUSED(event) )
457814b5 1341{
13188def 1342 Close(true);
457814b5
JS
1343}
1344
abceee76
VZ
1345#if wxUSE_PROGRESSDLG
1346
1347void MyFrame::ShowProgress( wxCommandEvent& WXUNUSED(event) )
1348{
b2c782f2 1349 static const int max = 100;
abceee76 1350
2f1cd905 1351 wxProgressDialog dialog(_T("Progress dialog example"),
78a189c9 1352 _T("An informative message"),
abceee76
VZ
1353 max, // range
1354 this, // parent
1355 wxPD_CAN_ABORT |
ecda9475 1356 wxPD_CAN_SKIP |
abceee76 1357 wxPD_APP_MODAL |
df26c4c6 1358 // wxPD_AUTO_HIDE | -- try this as well
abceee76
VZ
1359 wxPD_ELAPSED_TIME |
1360 wxPD_ESTIMATED_TIME |
f4aa7ec3 1361 wxPD_REMAINING_TIME
b2c782f2 1362 | wxPD_SMOOTH // - makes indeterminate mode bar on WinXP very small
f4aa7ec3 1363 );
abceee76 1364
13188def 1365 bool cont = true;
b2c782f2 1366 for ( int i = 0; i <= max; i++ )
abceee76 1367 {
b2c782f2 1368 wxMilliSleep(200);
ecda9475
WS
1369
1370 wxString msg;
1371
b2c782f2
VZ
1372 // test both modes of wxProgressDialog behaviour: start in
1373 // indeterminate mode but switch to the determinate one later
1374 const bool determinate = i > max/2;
f4aa7ec3 1375
abceee76
VZ
1376 if ( i == max )
1377 {
ecda9475 1378 msg = _T("That's all, folks!");
abceee76 1379 }
b2c782f2 1380 else if ( !determinate )
f4aa7ec3 1381 {
b2c782f2 1382 msg = _T("Testing indeterminate mode");
f4aa7ec3 1383 }
b2c782f2 1384 else if ( determinate )
abceee76 1385 {
b2c782f2 1386 msg = _T("Now in standard determinate mode");
abceee76 1387 }
ecda9475 1388
b2c782f2
VZ
1389 // will be set to true if "Skip" button was pressed
1390 bool skip = false;
1391 if ( determinate )
abceee76 1392 {
ecda9475 1393 cont = dialog.Update(i, msg, &skip);
abceee76 1394 }
f4aa7ec3
VZ
1395 else
1396 {
f4aa7ec3 1397 cont = dialog.Pulse(msg, &skip);
f4aa7ec3 1398 }
ecda9475 1399
b2c782f2
VZ
1400 // each skip will move progress about quarter forward
1401 if ( skip )
1402 i += max/4;
1403
d8ddee9c
VZ
1404 if ( !cont )
1405 {
78a189c9
VZ
1406 if ( wxMessageBox(_T("Do you really want to cancel?"),
1407 _T("Progress dialog question"), // caption
1408 wxYES_NO | wxICON_QUESTION) == wxYES )
d8ddee9c
VZ
1409 break;
1410
9b16ffef 1411 cont = true;
d8ddee9c
VZ
1412 dialog.Resume();
1413 }
abceee76
VZ
1414 }
1415
1416 if ( !cont )
1417 {
4693b20c 1418 wxLogStatus(wxT("Progress dialog aborted!"));
abceee76
VZ
1419 }
1420 else
1421 {
4693b20c 1422 wxLogStatus(wxT("Countdown from %d finished"), max);
abceee76
VZ
1423 }
1424}
1425
1426#endif // wxUSE_PROGRESSDLG
1427
ca7adbf8
VZ
1428#if wxUSE_ABOUTDLG
1429
453c9e3b 1430static void InitAboutInfoMinimal(wxAboutDialogInfo& info)
ca7adbf8
VZ
1431{
1432 info.SetName(_T("Dialogs Sample"));
1a1ecce6 1433 info.SetVersion(wxVERSION_NUM_DOT_STRING_T);
ca7adbf8 1434 info.SetDescription(_T("This sample shows different wxWidgets dialogs"));
730654ee 1435 info.SetCopyright(_T("(C) 1998-2006 wxWidgets dev team"));
50671311 1436 info.AddDeveloper(_T("Vadim Zeitlin"));
ca7adbf8
VZ
1437}
1438
453c9e3b
VZ
1439static void InitAboutInfoWebsite(wxAboutDialogInfo& info)
1440{
1441 InitAboutInfoMinimal(info);
1442
1443 info.SetWebSite(_T("http://www.wxwidgets.org/"), _T("wxWidgets web site"));
1444}
1445
1446static void InitAboutInfoAll(wxAboutDialogInfo& info)
1447{
20fe9c5a 1448 InitAboutInfoWebsite(info);
453c9e3b
VZ
1449
1450 // we can add a second developer
1451 info.AddDeveloper(_T("A.N. Other"));
1452
1453 // or we can add several persons at once like this
1454 static const wxChar *docwriters[] =
1455 {
1456 _T("First D. Writer"),
1457 _T("Second One"),
1458 };
1459
1460 info.SetDocWriters(wxArrayString(WXSIZEOF(docwriters), docwriters));
1461 info.SetLicence(wxString::FromAscii(
1462" wxWindows Library Licence, Version 3.1\n"
1463" ======================================\n"
1464"\n"
1465" Copyright (c) 1998-2005 Julian Smart, Robert Roebling et al\n"
1466"\n"
1467" Everyone is permitted to copy and distribute verbatim copies\n"
1468" of this licence document, but changing it is not allowed.\n"
1469"\n"
1470" WXWINDOWS LIBRARY LICENCE\n"
1471" TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION\n"
1472"\n"
1473" ...and so on and so forth...\n"
1474 ));
fb4f85bf
VZ
1475
1476 info.AddTranslator(_T("Wun Ngo Wen (Martian)"));
453c9e3b
VZ
1477}
1478
ca7adbf8
VZ
1479void MyFrame::ShowSimpleAboutDialog(wxCommandEvent& WXUNUSED(event))
1480{
1481 wxAboutDialogInfo info;
453c9e3b 1482 InitAboutInfoMinimal(info);
ca7adbf8
VZ
1483
1484 wxAboutBox(info);
1485}
1486
1487void MyFrame::ShowFancyAboutDialog(wxCommandEvent& WXUNUSED(event))
1488{
1489 wxAboutDialogInfo info;
453c9e3b 1490 InitAboutInfoWebsite(info);
ca7adbf8
VZ
1491
1492 wxAboutBox(info);
1493}
1494
453c9e3b
VZ
1495void MyFrame::ShowFullAboutDialog(wxCommandEvent& WXUNUSED(event))
1496{
1497 wxAboutDialogInfo info;
1498 InitAboutInfoAll(info);
1499
1500 wxAboutBox(info);
1501}
1502
1dcfc333
VZ
1503// a trivial example of a custom dialog class
1504class MyAboutDialog : public wxGenericAboutDialog
453c9e3b 1505{
1dcfc333
VZ
1506public:
1507 MyAboutDialog(const wxAboutDialogInfo& info)
453c9e3b 1508 {
1dcfc333
VZ
1509 Create(info);
1510 }
453c9e3b 1511
1dcfc333
VZ
1512 // add some custom controls
1513 virtual void DoAddCustomControls()
1514 {
1515 AddControl(new wxStaticLine(this), wxSizerFlags().Expand());
1516 AddText(_T("Some custom text"));
1517 AddControl(new wxStaticLine(this), wxSizerFlags().Expand());
1518 }
1519};
453c9e3b 1520
1dcfc333
VZ
1521void MyFrame::ShowCustomAboutDialog(wxCommandEvent& WXUNUSED(event))
1522{
453c9e3b
VZ
1523 wxAboutDialogInfo info;
1524 InitAboutInfoAll(info);
1525
1526 MyAboutDialog dlg(info);
1527 dlg.ShowModal();
1528}
1529
ca7adbf8
VZ
1530#endif // wxUSE_ABOUTDLG
1531
a62b0bcc
VZ
1532#if wxUSE_BUSYINFO
1533
1534void MyFrame::ShowBusyInfo(wxCommandEvent& WXUNUSED(event))
1535{
21977bac
VZ
1536 wxWindowDisabler disableAll;
1537
9f84eccd 1538 wxBusyInfo info(_T("Working, please wait..."), this);
a62b0bcc 1539
5b636c67 1540 for ( int i = 0; i < 18; i++ )
a62b0bcc 1541 {
5b636c67 1542 //wxUsleep(100);
a62b0bcc
VZ
1543 wxTheApp->Yield();
1544 }
5b636c67
VZ
1545
1546 wxSleep(2);
1547 //wxWakeUpIdle();
a62b0bcc
VZ
1548}
1549
1550#endif // wxUSE_BUSYINFO
1551
761989ff
VZ
1552#if wxUSE_FINDREPLDLG
1553
1554void MyFrame::ShowReplaceDialog( wxCommandEvent& WXUNUSED(event) )
1555{
14fca738
VZ
1556 if ( m_dlgReplace )
1557 {
1558 delete m_dlgReplace;
1559 m_dlgReplace = NULL;
1560 }
1561 else
1562 {
1563 m_dlgReplace = new wxFindReplaceDialog
1564 (
1565 this,
1566 &m_findData,
78a189c9 1567 _T("Find and replace dialog"),
14fca738
VZ
1568 wxFR_REPLACEDIALOG
1569 );
1570
13188def 1571 m_dlgReplace->Show(true);
14fca738 1572 }
761989ff
VZ
1573}
1574
1575void MyFrame::ShowFindDialog( wxCommandEvent& WXUNUSED(event) )
1576{
14fca738
VZ
1577 if ( m_dlgFind )
1578 {
1579 delete m_dlgFind;
1580 m_dlgFind = NULL;
1581 }
1582 else
1583 {
1584 m_dlgFind = new wxFindReplaceDialog
1585 (
1586 this,
1587 &m_findData,
78a189c9 1588 _T("Find dialog"),
14fca738
VZ
1589 // just for testing
1590 wxFR_NOWHOLEWORD
1591 );
1592
13188def 1593 m_dlgFind->Show(true);
14fca738 1594 }
761989ff
VZ
1595}
1596
1597static wxString DecodeFindDialogEventFlags(int flags)
1598{
1599 wxString str;
78a189c9 1600 str << (flags & wxFR_DOWN ? _T("down") : _T("up")) << _T(", ")
2f1cd905
VZ
1601 << (flags & wxFR_WHOLEWORD ? _T("whole words only, ") : _T(""))
1602 << (flags & wxFR_MATCHCASE ? _T("") : _T("not "))
78a189c9 1603 << _T("case sensitive");
761989ff
VZ
1604
1605 return str;
1606}
1607
1608void MyFrame::OnFindDialog(wxFindDialogEvent& event)
1609{
1610 wxEventType type = event.GetEventType();
1611
1612 if ( type == wxEVT_COMMAND_FIND || type == wxEVT_COMMAND_FIND_NEXT )
1613 {
4693b20c 1614 wxLogMessage(wxT("Find %s'%s' (flags: %s)"),
eba33006 1615 type == wxEVT_COMMAND_FIND_NEXT ? wxT("next ") : wxT(""),
761989ff
VZ
1616 event.GetFindString().c_str(),
1617 DecodeFindDialogEventFlags(event.GetFlags()).c_str());
1618 }
1619 else if ( type == wxEVT_COMMAND_FIND_REPLACE ||
1620 type == wxEVT_COMMAND_FIND_REPLACE_ALL )
1621 {
4693b20c 1622 wxLogMessage(wxT("Replace %s'%s' with '%s' (flags: %s)"),
eba33006 1623 type == wxEVT_COMMAND_FIND_REPLACE_ALL ? _T("all ") : wxT(""),
761989ff
VZ
1624 event.GetFindString().c_str(),
1625 event.GetReplaceString().c_str(),
1626 DecodeFindDialogEventFlags(event.GetFlags()).c_str());
1627 }
1628 else if ( type == wxEVT_COMMAND_FIND_CLOSE )
1629 {
14fca738
VZ
1630 wxFindReplaceDialog *dlg = event.GetDialog();
1631
df26c4c6 1632 int idMenu;
14fca738
VZ
1633 const wxChar *txt;
1634 if ( dlg == m_dlgFind )
1635 {
1636 txt = _T("Find");
df26c4c6 1637 idMenu = DIALOGS_FIND;
14fca738
VZ
1638 m_dlgFind = NULL;
1639 }
1640 else if ( dlg == m_dlgReplace )
1641 {
1642 txt = _T("Replace");
df26c4c6 1643 idMenu = DIALOGS_REPLACE;
14fca738
VZ
1644 m_dlgReplace = NULL;
1645 }
1646 else
1647 {
1648 txt = _T("Unknown");
13188def 1649 idMenu = wxID_ANY;
14fca738 1650
2f1cd905 1651 wxFAIL_MSG( _T("unexpected event") );
14fca738
VZ
1652 }
1653
df26c4c6
VZ
1654 wxLogMessage(wxT("%s dialog is being closed."), txt);
1655
13188def 1656 if ( idMenu != wxID_ANY )
df26c4c6 1657 {
13188def 1658 GetMenuBar()->Check(idMenu, false);
df26c4c6 1659 }
761989ff 1660
14fca738 1661 dlg->Destroy();
761989ff
VZ
1662 }
1663 else
1664 {
4693b20c 1665 wxLogError(wxT("Unknown find dialog event!"));
761989ff
VZ
1666 }
1667}
1668
1669#endif // wxUSE_FINDREPLDLG
1670
abceee76
VZ
1671// ----------------------------------------------------------------------------
1672// MyCanvas
1673// ----------------------------------------------------------------------------
1674
d355d3fe 1675void MyCanvas::OnPaint(wxPaintEvent& WXUNUSED(event) )
457814b5 1676{
c50f1fb9 1677 wxPaintDC dc(this);
457814b5
JS
1678 dc.SetFont(wxGetApp().m_canvasFont);
1679 dc.SetTextForeground(wxGetApp().m_canvasTextColour);
1680 dc.SetBackgroundMode(wxTRANSPARENT);
dc96b1b6
WS
1681 dc.DrawText(
1682 _T("wxWidgets common dialogs")
1683#if !defined(__SMARTPHONE__)
1684 _T(" test application")
1685#endif
1686 , 10, 10);
457814b5
JS
1687}
1688
b4954d19
WS
1689#if USE_MODAL_PRESENTATION
1690
4c45f240
VZ
1691// ----------------------------------------------------------------------------
1692// MyModelessDialog
1693// ----------------------------------------------------------------------------
457814b5 1694
4c45f240 1695MyModelessDialog::MyModelessDialog(wxWindow *parent)
13188def 1696 : wxDialog(parent, wxID_ANY, wxString(_T("Modeless dialog")))
4c45f240 1697{
cbc66a27
VZ
1698 wxBoxSizer *sizerTop = new wxBoxSizer(wxVERTICAL);
1699
78a189c9 1700 wxButton *btn = new wxButton(this, DIALOGS_MODELESS_BTN, _T("Press me"));
13188def 1701 wxCheckBox *check = new wxCheckBox(this, wxID_ANY, _T("Should be disabled"));
cbc66a27
VZ
1702 check->Disable();
1703
1704 sizerTop->Add(btn, 1, wxEXPAND | wxALL, 5);
1705 sizerTop->Add(check, 1, wxEXPAND | wxALL, 5);
1706
8ce68f7f 1707 SetSizerAndFit(sizerTop);
4c45f240 1708}
abceee76 1709
5d987909
VZ
1710void MyModelessDialog::OnButton(wxCommandEvent& WXUNUSED(event))
1711{
2f1cd905 1712 wxMessageBox(_T("Button pressed in modeless dialog"), _T("Info"),
5d987909
VZ
1713 wxOK | wxICON_INFORMATION, this);
1714}
1715
abceee76
VZ
1716void MyModelessDialog::OnClose(wxCloseEvent& event)
1717{
1718 if ( event.CanVeto() )
1719 {
2f1cd905 1720 wxMessageBox(_T("Use the menu item to close this dialog"),
78a189c9 1721 _T("Modeless dialog"),
abceee76
VZ
1722 wxOK | wxICON_INFORMATION, this);
1723
1724 event.Veto();
1725 }
1726}
1727
f6bcfd97
BP
1728// ----------------------------------------------------------------------------
1729// MyModalDialog
1730// ----------------------------------------------------------------------------
1731
1732MyModalDialog::MyModalDialog(wxWindow *parent)
13188def 1733 : wxDialog(parent, wxID_ANY, wxString(_T("Modal dialog")))
f6bcfd97
BP
1734{
1735 wxBoxSizer *sizerTop = new wxBoxSizer(wxHORIZONTAL);
1736
13188def
WS
1737 m_btnModal = new wxButton(this, wxID_ANY, _T("&Modal dialog..."));
1738 m_btnModeless = new wxButton(this, wxID_ANY, _T("Mode&less dialog"));
1739 m_btnDelete = new wxButton(this, wxID_ANY, _T("&Delete button"));
5315ebfa 1740
78a189c9 1741 wxButton *btnOk = new wxButton(this, wxID_CANCEL, _T("&Close"));
5315ebfa
VZ
1742 sizerTop->Add(m_btnModal, 0, wxALIGN_CENTER | wxALL, 5);
1743 sizerTop->Add(m_btnModeless, 0, wxALIGN_CENTER | wxALL, 5);
f6bcfd97 1744 sizerTop->Add(m_btnDelete, 0, wxALIGN_CENTER | wxALL, 5);
9b70bb91 1745 sizerTop->Add(btnOk, 0, wxALIGN_CENTER | wxALL, 5);
f6bcfd97 1746
8ce68f7f 1747 SetSizerAndFit(sizerTop);
f6bcfd97 1748
5315ebfa
VZ
1749 m_btnModal->SetFocus();
1750 m_btnModal->SetDefault();
f6bcfd97
BP
1751}
1752
1753void MyModalDialog::OnButton(wxCommandEvent& event)
1754{
1755 if ( event.GetEventObject() == m_btnDelete )
1756 {
5315ebfa
VZ
1757 delete m_btnModal;
1758 m_btnModal = NULL;
f6bcfd97
BP
1759
1760 m_btnDelete->Disable();
1761 }
5315ebfa 1762 else if ( event.GetEventObject() == m_btnModal )
f6bcfd97 1763 {
13188def 1764#if wxUSE_TEXTDLG
78a189c9
VZ
1765 wxGetTextFromUser(_T("Dummy prompt"),
1766 _T("Modal dialog called from dialog"),
dabbc6a5 1767 wxEmptyString, this);
13188def
WS
1768#else
1769 wxMessageBox(_T("Modal dialog called from dialog"));
1770#endif // wxUSE_TEXTDLG
f6bcfd97 1771 }
5315ebfa
VZ
1772 else if ( event.GetEventObject() == m_btnModeless )
1773 {
1774 (new MyModelessDialog(this))->Show();
1775 }
f6bcfd97
BP
1776 else
1777 {
1778 event.Skip();
1779 }
1780}
b4954d19
WS
1781
1782#endif // USE_MODAL_PRESENTATION
1783
8e1dac82
VZ
1784// ----------------------------------------------------------------------------
1785// StdButtonSizerDialog
1786// ----------------------------------------------------------------------------
1787
1788StdButtonSizerDialog::StdButtonSizerDialog(wxWindow *parent)
1789 : wxDialog(parent, wxID_ANY, wxString(_T("StdButtonSizer dialog")),
1790 wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER),
1791 m_buttonsSizer(NULL)
1792{
1793 wxBoxSizer *const sizerTop = new wxBoxSizer(wxVERTICAL);
1794
1795 wxBoxSizer *const sizer = new wxBoxSizer(wxHORIZONTAL);
1796 wxBoxSizer *const sizerInside1 = new wxBoxSizer(wxVERTICAL);
1797
1798 m_chkboxAffirmativeButton = new wxCheckBox(this, wxID_ANY, _("Enable Affirmative Button"));
1799
1800 wxStaticBoxSizer *const sizer1 = new wxStaticBoxSizer(wxVERTICAL, this, wxT("Affirmative Button"));
1801
1802 m_radiobtnOk = new wxRadioButton(this, wxID_ANY, _("Ok"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP);
1803 m_radiobtnYes = new wxRadioButton(this, wxID_ANY, _("Yes"));
1804
1805 wxBoxSizer *const sizerInside2 = new wxBoxSizer(wxVERTICAL);
1806
1807 m_chkboxDismissButton = new wxCheckBox(this, wxID_ANY, _("Enable Dismiss Button"));
1808
1809 wxStaticBoxSizer *const sizer2 = new wxStaticBoxSizer(wxVERTICAL, this, wxT("Dismiss Button"));
1810
1811 m_radiobtnCancel = new wxRadioButton(this, wxID_ANY, _("Cancel"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP);
1812 m_radiobtnClose = new wxRadioButton(this, wxID_ANY, _("Close"));
1813
1814 wxBoxSizer *const sizer3 = new wxBoxSizer(wxHORIZONTAL);
1815
1816 m_chkboxNo = new wxCheckBox(this, wxID_ANY, _("No"));
1817 m_chkboxHelp = new wxCheckBox(this, wxID_ANY, _("Help"));
1818 m_chkboxApply = new wxCheckBox(this, wxID_ANY, _("Apply"));
1819
1820 m_chkboxNoDefault = new wxCheckBox(this, wxID_ANY, wxT("No Default"));
1821
1822 sizer1->Add(m_radiobtnOk, 0, wxALL, 5);
1823 sizer1->Add(m_radiobtnYes, 0, wxALL, 5);
1824
1825 sizer->Add(sizerInside1, 0, 0, 0);
1826 sizerInside1->Add(m_chkboxAffirmativeButton, 0, wxALL, 5);
1827 sizerInside1->Add(sizer1, 0, wxALL, 5);
1828 sizerInside1->SetItemMinSize(sizer1, sizer1->GetStaticBox()->GetBestSize()); // to prevent wrapping of static box label
1829
1830 sizer2->Add(m_radiobtnCancel, 0, wxALL, 5);
1831 sizer2->Add(m_radiobtnClose, 0, wxALL, 5);
1832
1833 sizer->Add(sizerInside2, 0, 0, 0);
1834 sizerInside2->Add(m_chkboxDismissButton, 0, wxALL, 5);
1835 sizerInside2->Add(sizer2, 0, wxALL, 5);
1836 sizerInside2->SetItemMinSize(sizer2, sizer2->GetStaticBox()->GetBestSize()); // to prevent wrapping of static box label
1837
1838 sizerTop->Add(sizer, 0, wxALL, 5);
1839
1840 sizer3->Add(m_chkboxNo, 0, wxALL, 5);
1841 sizer3->Add(m_chkboxHelp, 0, wxALL, 5);
1842 sizer3->Add(m_chkboxApply, 0, wxALL, 5);
1843
1844 sizerTop->Add(sizer3, 0, wxALL, 5);
1845
1846 sizerTop->Add(m_chkboxNoDefault, 0, wxLEFT|wxRIGHT, 10);
1847
1848 EnableDisableControls();
1849
8ce68f7f 1850 SetSizerAndFit(sizerTop);
8e1dac82 1851
8e1dac82
VZ
1852 wxCommandEvent ev;
1853 OnEvent(ev);
1854}
1855
1856void StdButtonSizerDialog::OnEvent(wxCommandEvent& WXUNUSED(event))
1857{
1858 if (m_buttonsSizer)
1859 {
1860 m_buttonsSizer->DeleteWindows();
1861 GetSizer()->Remove(m_buttonsSizer);
1862 }
1863
1864 EnableDisableControls();
1865
1866 long flags = 0;
1867 unsigned long numButtons = 0;
1868
1869 if (m_chkboxAffirmativeButton->IsChecked())
1870 {
1871 if (m_radiobtnOk->GetValue())
1872 {
1873 flags |= wxOK;
1874 numButtons ++;
1875 }
1876 else if (m_radiobtnYes->GetValue())
1877 {
1878 flags |= wxYES;
1879 numButtons ++;
1880 }
1881 }
1882
1883 if (m_chkboxDismissButton->IsChecked())
1884 {
1885 if (m_radiobtnCancel->GetValue())
1886 {
1887 flags |= wxCANCEL;
1888 numButtons ++;
1889 }
1890
1891 else if (m_radiobtnClose->GetValue())
1892 {
1893 flags |= wxCLOSE;
1894 numButtons ++;
1895 }
1896
1897 }
1898
1899 if (m_chkboxApply->IsChecked())
1900 {
1901 flags |= wxAPPLY;
1902 numButtons ++;
1903 }
1904
1905 if (m_chkboxNo->IsChecked())
1906 {
1907 flags |= wxNO;
1908 numButtons ++;
1909 }
1910
1911 if (m_chkboxHelp->IsChecked())
1912 {
1913 flags |= wxHELP;
1914 numButtons ++;
1915 }
1916
1917 if (m_chkboxNoDefault->IsChecked())
1918 {
1919 flags |= wxNO_DEFAULT;
1920 }
1921
1922 m_buttonsSizer = CreateStdDialogButtonSizer(flags);
1923 GetSizer()->Add(m_buttonsSizer, 0, wxGROW|wxALL, 5);
1924
1925 Layout();
1926 GetSizer()->SetSizeHints(this);
1927}
1928
1929void StdButtonSizerDialog::EnableDisableControls()
1930{
1931 const bool affButtonEnabled = m_chkboxAffirmativeButton->IsChecked();
1932
1933 m_radiobtnOk->Enable(affButtonEnabled);
1934 m_radiobtnYes->Enable(affButtonEnabled);
1935
1936 const bool dismissButtonEnabled = m_chkboxDismissButton->IsChecked();
1937
1938 m_radiobtnCancel->Enable(dismissButtonEnabled);
1939 m_radiobtnClose->Enable(dismissButtonEnabled);
1940}
1941
532d575b 1942#if USE_SETTINGS_DIALOG
0f5d8ecf
JS
1943// ----------------------------------------------------------------------------
1944// SettingsDialog
1945// ----------------------------------------------------------------------------
1946
1947IMPLEMENT_CLASS(SettingsDialog, wxPropertySheetDialog)
1948
1949BEGIN_EVENT_TABLE(SettingsDialog, wxPropertySheetDialog)
1950END_EVENT_TABLE()
1951
64d3ed17 1952SettingsDialog::SettingsDialog(wxWindow* win, int dialogType)
0f5d8ecf 1953{
0f4991f4 1954 SetExtraStyle(wxDIALOG_EX_CONTEXTHELP|wxWS_EX_VALIDATE_RECURSIVELY);
0f5d8ecf 1955
cc8bc5aa
JS
1956 int tabImage1 = -1;
1957 int tabImage2 = -1;
e031f1df 1958
64d3ed17 1959 bool useToolBook = (dialogType == DIALOGS_PROPERTY_SHEET_TOOLBOOK || dialogType == DIALOGS_PROPERTY_SHEET_BUTTONTOOLBOOK);
77631b1d 1960 int resizeBorder = wxRESIZE_BORDER;
684883e3 1961
cc8bc5aa
JS
1962 if (useToolBook)
1963 {
77631b1d 1964 resizeBorder = 0;
cc8bc5aa
JS
1965 tabImage1 = 0;
1966 tabImage2 = 1;
e031f1df 1967
64d3ed17
JS
1968 int sheetStyle = wxPROPSHEET_SHRINKTOFIT;
1969 if (dialogType == DIALOGS_PROPERTY_SHEET_BUTTONTOOLBOOK)
1970 sheetStyle |= wxPROPSHEET_BUTTONTOOLBOOK;
1971 else
1972 sheetStyle |= wxPROPSHEET_TOOLBOOK;
e031f1df 1973
64d3ed17 1974 SetSheetStyle(sheetStyle);
77631b1d
JS
1975 SetSheetInnerBorder(0);
1976 SetSheetOuterBorder(0);
cc8bc5aa
JS
1977
1978 // create a dummy image list with a few icons
1979 const wxSize imageSize(32, 32);
1980
1981 m_imageList = new wxImageList(imageSize.GetWidth(), imageSize.GetHeight());
1982 m_imageList->
1983 Add(wxArtProvider::GetIcon(wxART_INFORMATION, wxART_OTHER, imageSize));
1984 m_imageList->
1985 Add(wxArtProvider::GetIcon(wxART_QUESTION, wxART_OTHER, imageSize));
1986 m_imageList->
1987 Add(wxArtProvider::GetIcon(wxART_WARNING, wxART_OTHER, imageSize));
1988 m_imageList->
1989 Add(wxArtProvider::GetIcon(wxART_ERROR, wxART_OTHER, imageSize));
1990 }
1991 else
1992 m_imageList = NULL;
1993
532d575b 1994 Create(win, wxID_ANY, _("Preferences"), wxDefaultPosition, wxDefaultSize,
654ffe9f 1995 wxDEFAULT_DIALOG_STYLE| (int)wxPlatform::IfNot(wxOS_WINDOWS_CE, resizeBorder)
3103e8a9 1996 );
cc8bc5aa 1997
684883e3 1998 // If using a toolbook, also follow Mac style and don't create buttons
cc8bc5aa 1999 if (!useToolBook)
654ffe9f
VZ
2000 CreateButtons(wxOK | wxCANCEL |
2001 (int)wxPlatform::IfNot(wxOS_WINDOWS_CE, wxHELP)
897b24cf 2002 );
0f5d8ecf
JS
2003
2004 wxBookCtrlBase* notebook = GetBookCtrl();
cc8bc5aa 2005 notebook->SetImageList(m_imageList);
0f5d8ecf
JS
2006
2007 wxPanel* generalSettings = CreateGeneralSettingsPage(notebook);
2008 wxPanel* aestheticSettings = CreateAestheticSettingsPage(notebook);
2009
cc8bc5aa
JS
2010 notebook->AddPage(generalSettings, _("General"), true, tabImage1);
2011 notebook->AddPage(aestheticSettings, _("Aesthetics"), false, tabImage2);
0f5d8ecf
JS
2012
2013 LayoutDialog();
2014}
2015
cc8bc5aa
JS
2016SettingsDialog::~SettingsDialog()
2017{
2018 delete m_imageList;
2019}
2020
0f5d8ecf
JS
2021wxPanel* SettingsDialog::CreateGeneralSettingsPage(wxWindow* parent)
2022{
2023 wxPanel* panel = new wxPanel(parent, wxID_ANY);
2024
2025 wxBoxSizer *topSizer = new wxBoxSizer( wxVERTICAL );
2026 wxBoxSizer *item0 = new wxBoxSizer( wxVERTICAL );
2027
2028 //// LOAD LAST FILE
2029
2030 wxBoxSizer* itemSizer3 = new wxBoxSizer( wxHORIZONTAL );
2031 wxCheckBox* checkBox3 = new wxCheckBox(panel, ID_LOAD_LAST_PROJECT, _("&Load last project on startup"), wxDefaultPosition, wxDefaultSize);
2032 itemSizer3->Add(checkBox3, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5);
2033 item0->Add(itemSizer3, 0, wxGROW|wxALL, 0);
2034
2035 //// AUTOSAVE
2036
2037 wxString autoSaveLabel = _("&Auto-save every");
2038 wxString minsLabel = _("mins");
2039
2040 wxBoxSizer* itemSizer12 = new wxBoxSizer( wxHORIZONTAL );
2041 wxCheckBox* checkBox12 = new wxCheckBox(panel, ID_AUTO_SAVE, autoSaveLabel, wxDefaultPosition, wxDefaultSize);
62675ef3
JS
2042
2043#if wxUSE_SPINCTRL
0f5d8ecf 2044 wxSpinCtrl* spinCtrl12 = new wxSpinCtrl(panel, ID_AUTO_SAVE_MINS, wxEmptyString,
532d575b 2045 wxDefaultPosition, wxSize(40, wxDefaultCoord), wxSP_ARROW_KEYS, 1, 60, 1);
62675ef3 2046#endif
532d575b 2047
0f5d8ecf 2048 itemSizer12->Add(checkBox12, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5);
62675ef3 2049#if wxUSE_SPINCTRL
0f5d8ecf 2050 itemSizer12->Add(spinCtrl12, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5);
62675ef3 2051#endif
0f5d8ecf
JS
2052 itemSizer12->Add(new wxStaticText(panel, wxID_STATIC, minsLabel), 0, wxALL|wxALIGN_CENTER_VERTICAL, 5);
2053 item0->Add(itemSizer12, 0, wxGROW|wxALL, 0);
2054
2055 //// TOOLTIPS
532d575b 2056
0f5d8ecf
JS
2057 wxBoxSizer* itemSizer8 = new wxBoxSizer( wxHORIZONTAL );
2058 wxCheckBox* checkBox6 = new wxCheckBox(panel, ID_SHOW_TOOLTIPS, _("Show &tooltips"), wxDefaultPosition, wxDefaultSize);
2059 itemSizer8->Add(checkBox6, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5);
2060 item0->Add(itemSizer8, 0, wxGROW|wxALL, 0);
2061
2062 topSizer->Add( item0, 1, wxGROW|wxALIGN_CENTRE|wxALL, 5 );
2063
8ce68f7f 2064 panel->SetSizerAndFit(topSizer);
532d575b 2065
0f5d8ecf
JS
2066 return panel;
2067}
2068
2069wxPanel* SettingsDialog::CreateAestheticSettingsPage(wxWindow* parent)
2070{
2071 wxPanel* panel = new wxPanel(parent, wxID_ANY);
2072
2073 wxBoxSizer *topSizer = new wxBoxSizer( wxVERTICAL );
2074 wxBoxSizer *item0 = new wxBoxSizer( wxVERTICAL );
2075
2076 //// PROJECT OR GLOBAL
2077 wxString globalOrProjectChoices[2];
2078 globalOrProjectChoices[0] = _("&New projects");
2079 globalOrProjectChoices[1] = _("&This project");
2080
2081 wxRadioBox* projectOrGlobal = new wxRadioBox(panel, ID_APPLY_SETTINGS_TO, _("&Apply settings to:"),
2082 wxDefaultPosition, wxDefaultSize, 2, globalOrProjectChoices);
2083 item0->Add(projectOrGlobal, 0, wxGROW|wxALL, 5);
2084
2085 projectOrGlobal->SetSelection(0);
2086
2087 //// BACKGROUND STYLE
2088 wxArrayString backgroundStyleChoices;
2089 backgroundStyleChoices.Add(wxT("Colour"));
2090 backgroundStyleChoices.Add(wxT("Image"));
532d575b 2091 wxStaticBox* staticBox3 = new wxStaticBox(panel, wxID_ANY, _("Background style:"));
0f5d8ecf
JS
2092
2093 wxBoxSizer* styleSizer = new wxStaticBoxSizer( staticBox3, wxVERTICAL );
2094 item0->Add(styleSizer, 0, wxGROW|wxALL, 5);
2095
2096 wxBoxSizer* itemSizer2 = new wxBoxSizer( wxHORIZONTAL );
2097
2098 wxChoice* choice2 = new wxChoice(panel, ID_BACKGROUND_STYLE, wxDefaultPosition, wxDefaultSize, backgroundStyleChoices);
2099
2100 itemSizer2->Add(new wxStaticText(panel, wxID_ANY, _("&Window:")), 0, wxALL|wxALIGN_CENTER_VERTICAL, 5);
2101 itemSizer2->Add(5, 5, 1, wxALL, 0);
2102 itemSizer2->Add(choice2, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5);
2103
2104 styleSizer->Add(itemSizer2, 0, wxGROW|wxALL, 5);
2105
62675ef3 2106#if wxUSE_SPINCTRL
0f5d8ecf
JS
2107 //// FONT SIZE SELECTION
2108
532d575b 2109 wxStaticBox* staticBox1 = new wxStaticBox(panel, wxID_ANY, _("Tile font size:"));
0f5d8ecf
JS
2110 wxBoxSizer* itemSizer5 = new wxStaticBoxSizer( staticBox1, wxHORIZONTAL );
2111
2112 wxSpinCtrl* spinCtrl = new wxSpinCtrl(panel, ID_FONT_SIZE, wxEmptyString, wxDefaultPosition,
532d575b 2113 wxSize(80, wxDefaultCoord));
0f5d8ecf
JS
2114 itemSizer5->Add(spinCtrl, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
2115
2116 item0->Add(itemSizer5, 0, wxGROW|wxLEFT|wxRIGHT, 5);
62675ef3 2117#endif
0f5d8ecf
JS
2118
2119 topSizer->Add( item0, 1, wxGROW|wxALIGN_CENTRE|wxALL, 5 );
0f4991f4 2120 topSizer->AddSpacer(5);
0f5d8ecf 2121
8ce68f7f 2122 panel->SetSizerAndFit(topSizer);
532d575b 2123
0f5d8ecf
JS
2124 return panel;
2125}
2126
532d575b 2127#endif // USE_SETTINGS_DIALOG