]> git.saurik.com Git - wxWidgets.git/blame - samples/dialogs/dialogs.cpp
Rebake after bakefile changes.
[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
9ad2fe62 25#include "wx/apptrait.h"
fb8a56b7 26#include "wx/datetime.h"
f517634c 27#include "wx/image.h"
5378558e 28#include "wx/bookctrl.h"
cc8bc5aa 29#include "wx/artprov.h"
2b923807 30#include "wx/imaglist.h"
1baa0a9d 31#include "wx/minifram.h"
684883e3 32#include "wx/sysopt.h"
e36a1739 33#include "wx/notifmsg.h"
457814b5 34
13188def
WS
35#if wxUSE_COLOURDLG
36 #include "wx/colordlg.h"
37#endif // wxUSE_COLOURDLG
dfad0599 38
13188def
WS
39#if wxUSE_CHOICEDLG
40 #include "wx/choicdlg.h"
41#endif // wxUSE_CHOICEDLG
457814b5 42
13188def
WS
43#if wxUSE_STARTUP_TIPS
44 #include "wx/tipdlg.h"
45#endif // wxUSE_STARTUP_TIPS
d7d17624 46
13188def 47#if wxUSE_PROGRESSDLG
9b16ffef 48#if wxUSE_STOPWATCH && wxUSE_LONGLONG
b20edf8b 49 #include "wx/datetime.h" // wxDateTime
9b16ffef
VZ
50#endif
51
13188def
WS
52 #include "wx/progdlg.h"
53#endif // wxUSE_PROGRESSDLG
54
ca7adbf8
VZ
55#if wxUSE_ABOUTDLG
56 #include "wx/aboutdlg.h"
453c9e3b
VZ
57
58 // these headers are only needed for custom about dialog
59 #include "wx/statline.h"
60 #include "wx/generic/aboutdlgg.h"
ca7adbf8
VZ
61#endif // wxUSE_ABOUTDLG
62
13188def
WS
63#if wxUSE_BUSYINFO
64 #include "wx/busyinfo.h"
65#endif // wxUSE_BUSYINFO
66
67#if wxUSE_NUMBERDLG
68 #include "wx/numdlg.h"
69#endif // wxUSE_NUMBERDLG
70
71#if wxUSE_FILEDLG
72 #include "wx/filedlg.h"
73#endif // wxUSE_FILEDLG
74
75#if wxUSE_DIRDLG
76 #include "wx/dirdlg.h"
77#endif // wxUSE_DIRDLG
78
79#if wxUSE_FONTDLG
80 #include "wx/fontdlg.h"
81#endif // wxUSE_FONTDLG
82
83#if wxUSE_FINDREPLDLG
84 #include "wx/fdrepdlg.h"
85#endif // wxUSE_FINDREPLDLG
4ad3c82f 86
0f5d8ecf
JS
87#include "wx/spinctrl.h"
88#include "wx/propdlg.h"
89
457814b5
JS
90#include "dialogs.h"
91
13188def
WS
92#if USE_COLOURDLG_GENERIC
93 #include "wx/generic/colrdlgg.h"
94#endif // USE_COLOURDLG_GENERIC
95
13188def
WS
96#if USE_DIRDLG_GENERIC
97 #include "wx/generic/dirdlgg.h"
98#endif // USE_DIRDLG_GENERIC
99
695fe764
WS
100#if USE_FILEDLG_GENERIC
101 #include "wx/generic/filedlgg.h"
102#endif // USE_FILEDLG_GENERIC
103
104#if USE_FONTDLG_GENERIC
105 #include "wx/generic/fontdlgg.h"
106#endif // USE_FONTDLG_GENERIC
107
457814b5
JS
108IMPLEMENT_APP(MyApp)
109
4c45f240
VZ
110BEGIN_EVENT_TABLE(MyCanvas, wxScrolledWindow)
111 EVT_PAINT(MyCanvas::OnPaint)
112END_EVENT_TABLE()
113
13188def
WS
114
115
4c45f240 116BEGIN_EVENT_TABLE(MyFrame, wxFrame)
8cf304f8 117#if wxUSE_MSGDLG
13188def 118 EVT_MENU(DIALOGS_MESSAGE_BOX, MyFrame::MessageBox)
44b25eac 119 EVT_MENU(DIALOGS_MESSAGE_DIALOG, MyFrame::MessageBoxDialog)
8cf304f8
VZ
120 EVT_MENU(DIALOGS_MESSAGE_BOX_WXINFO, MyFrame::MessageBoxInfo)
121#endif // wxUSE_MSGDLG
13188def 122#if wxUSE_COLOURDLG
4c45f240 123 EVT_MENU(DIALOGS_CHOOSE_COLOUR, MyFrame::ChooseColour)
e6ef9ea4 124 EVT_MENU(DIALOGS_GET_COLOUR, MyFrame::GetColour)
13188def
WS
125#endif // wxUSE_COLOURDLG
126
127#if wxUSE_FONTDLG
4c45f240 128 EVT_MENU(DIALOGS_CHOOSE_FONT, MyFrame::ChooseFont)
13188def
WS
129#endif // wxUSE_FONTDLG
130
131#if wxUSE_LOG_DIALOG
4c45f240 132 EVT_MENU(DIALOGS_LOG_DIALOG, MyFrame::LogDialog)
13188def
WS
133#endif // wxUSE_LOG_DIALOG
134
135#if wxUSE_TEXTDLG
4c45f240
VZ
136 EVT_MENU(DIALOGS_TEXT_ENTRY, MyFrame::TextEntry)
137 EVT_MENU(DIALOGS_PASSWORD_ENTRY, MyFrame::PasswordEntry)
13188def
WS
138#endif // wxUSE_TEXTDLG
139
140#if wxUSE_NUMBERDLG
4c45f240 141 EVT_MENU(DIALOGS_NUM_ENTRY, MyFrame::NumericEntry)
13188def
WS
142#endif // wxUSE_NUMBERDLG
143
144#if wxUSE_CHOICEDLG
4c45f240 145 EVT_MENU(DIALOGS_SINGLE_CHOICE, MyFrame::SingleChoice)
d6c9c1b7 146 EVT_MENU(DIALOGS_MULTI_CHOICE, MyFrame::MultiChoice)
13188def
WS
147#endif // wxUSE_CHOICEDLG
148
149#if wxUSE_FILEDLG
4c45f240 150 EVT_MENU(DIALOGS_FILE_OPEN, MyFrame::FileOpen)
35b45b33 151 EVT_MENU(DIALOGS_FILE_OPEN2, MyFrame::FileOpen2)
4c45f240
VZ
152 EVT_MENU(DIALOGS_FILES_OPEN, MyFrame::FilesOpen)
153 EVT_MENU(DIALOGS_FILE_SAVE, MyFrame::FileSave)
13188def
WS
154#endif // wxUSE_FILEDLG
155
695fe764
WS
156#if USE_FILEDLG_GENERIC
157 EVT_MENU(DIALOGS_FILE_OPEN_GENERIC, MyFrame::FileOpenGeneric)
158 EVT_MENU(DIALOGS_FILES_OPEN_GENERIC, MyFrame::FilesOpenGeneric)
159 EVT_MENU(DIALOGS_FILE_SAVE_GENERIC, MyFrame::FileSaveGeneric)
160#endif // USE_FILEDLG_GENERIC
161
13188def 162#if wxUSE_DIRDLG
4c45f240 163 EVT_MENU(DIALOGS_DIR_CHOOSE, MyFrame::DirChoose)
f09c8393 164 EVT_MENU(DIALOGS_DIRNEW_CHOOSE, MyFrame::DirChooseNew)
13188def
WS
165#endif // wxUSE_DIRDLG
166
167#if USE_MODAL_PRESENTATION
f6bcfd97 168 EVT_MENU(DIALOGS_MODAL, MyFrame::ModalDlg)
1baa0a9d 169#endif // USE_MODAL_PRESENTATION
4c45f240 170 EVT_MENU(DIALOGS_MODELESS, MyFrame::ModelessDlg)
cae50e6b
VZ
171 EVT_MENU(DIALOGS_CENTRE_SCREEN, MyFrame::DlgCenteredScreen)
172 EVT_MENU(DIALOGS_CENTRE_PARENT, MyFrame::DlgCenteredParent)
1baa0a9d 173 EVT_MENU(DIALOGS_MINIFRAME, MyFrame::MiniFrame)
8e5dbcdd 174 EVT_MENU(DIALOGS_ONTOP, MyFrame::DlgOnTop)
13188def
WS
175
176#if wxUSE_STARTUP_TIPS
4c45f240 177 EVT_MENU(DIALOGS_TIP, MyFrame::ShowTip)
13188def
WS
178#endif // wxUSE_STARTUP_TIPS
179
180#if USE_FONTDLG_GENERIC
4c45f240 181 EVT_MENU(DIALOGS_CHOOSE_FONT_GENERIC, MyFrame::ChooseFontGeneric)
13188def
WS
182#endif // USE_FONTDLG_GENERIC
183
184#if USE_DIRDLG_GENERIC
185 EVT_MENU(DIALOGS_GENERIC_DIR_CHOOSE, MyFrame::GenericDirChoose)
186#endif // wxMSW || wxMAC
187
188#if USE_COLOURDLG_GENERIC
189 EVT_MENU(DIALOGS_CHOOSE_COLOUR_GENERIC, MyFrame::ChooseColourGeneric)
190#endif // USE_COLOURDLG_GENERIC
a62b0bcc 191
abceee76
VZ
192#if wxUSE_PROGRESSDLG
193 EVT_MENU(DIALOGS_PROGRESS, MyFrame::ShowProgress)
761989ff 194#endif // wxUSE_PROGRESSDLG
a62b0bcc 195
ca7adbf8
VZ
196#if wxUSE_ABOUTDLG
197 EVT_MENU(DIALOGS_ABOUTDLG_SIMPLE, MyFrame::ShowSimpleAboutDialog)
198 EVT_MENU(DIALOGS_ABOUTDLG_FANCY, MyFrame::ShowFancyAboutDialog)
453c9e3b
VZ
199 EVT_MENU(DIALOGS_ABOUTDLG_FULL, MyFrame::ShowFullAboutDialog)
200 EVT_MENU(DIALOGS_ABOUTDLG_CUSTOM, MyFrame::ShowCustomAboutDialog)
ca7adbf8
VZ
201#endif // wxUSE_ABOUTDLG
202
a62b0bcc
VZ
203#if wxUSE_BUSYINFO
204 EVT_MENU(DIALOGS_BUSYINFO, MyFrame::ShowBusyInfo)
205#endif // wxUSE_BUSYINFO
206
761989ff
VZ
207#if wxUSE_FINDREPLDLG
208 EVT_MENU(DIALOGS_FIND, MyFrame::ShowFindDialog)
209 EVT_MENU(DIALOGS_REPLACE, MyFrame::ShowReplaceDialog)
210
13188def
WS
211 EVT_FIND(wxID_ANY, MyFrame::OnFindDialog)
212 EVT_FIND_NEXT(wxID_ANY, MyFrame::OnFindDialog)
213 EVT_FIND_REPLACE(wxID_ANY, MyFrame::OnFindDialog)
214 EVT_FIND_REPLACE_ALL(wxID_ANY, MyFrame::OnFindDialog)
215 EVT_FIND_CLOSE(wxID_ANY, MyFrame::OnFindDialog)
761989ff 216#endif // wxUSE_FINDREPLDLG
13188def 217
532d575b 218#if USE_SETTINGS_DIALOG
0f5d8ecf 219 EVT_MENU(DIALOGS_PROPERTY_SHEET, MyFrame::OnPropertySheet)
64d3ed17
JS
220 EVT_MENU(DIALOGS_PROPERTY_SHEET_TOOLBOOK, MyFrame::OnPropertySheet)
221 EVT_MENU(DIALOGS_PROPERTY_SHEET_BUTTONTOOLBOOK, MyFrame::OnPropertySheet)
e36a1739 222#endif // USE_SETTINGS_DIALOG
532d575b 223
8e1dac82 224 EVT_MENU(DIALOGS_STANDARD_BUTTON_SIZER_DIALOG, MyFrame::OnStandardButtonsSizerDialog)
a625c5b6 225 EVT_MENU(DIALOGS_TEST_DEFAULT_ACTION, MyFrame::OnTestDefaultActionDialog)
e36a1739 226
0f5d8ecf 227 EVT_MENU(DIALOGS_REQUEST, MyFrame::OnRequestUserAttention)
e36a1739
VZ
228#if wxUSE_NOTIFICATION_MESSAGE
229 EVT_MENU(DIALOGS_NOTIFY_AUTO, MyFrame::OnNotifMsgAuto)
230 EVT_MENU(DIALOGS_NOTIFY_SHOW, MyFrame::OnNotifMsgShow)
231 EVT_MENU(DIALOGS_NOTIFY_HIDE, MyFrame::OnNotifMsgHide)
232#endif // wxUSE_NOTIFICATION_MESSAGE
9b16ffef 233
4c45f240 234 EVT_MENU(wxID_EXIT, MyFrame::OnExit)
4c45f240 235END_EVENT_TABLE()
abceee76 236
13188def 237#if USE_MODAL_PRESENTATION
f6bcfd97 238
13188def
WS
239 BEGIN_EVENT_TABLE(MyModalDialog, wxDialog)
240 EVT_BUTTON(wxID_ANY, MyModalDialog::OnButton)
241 END_EVENT_TABLE()
5d987909 242
13188def
WS
243 BEGIN_EVENT_TABLE(MyModelessDialog, wxDialog)
244 EVT_BUTTON(DIALOGS_MODELESS_BTN, MyModelessDialog::OnButton)
245 EVT_CLOSE(MyModelessDialog::OnClose)
246 END_EVENT_TABLE()
247
248#endif // USE_MODAL_PRESENTATION
abceee76 249
8e1dac82
VZ
250BEGIN_EVENT_TABLE(StdButtonSizerDialog, wxDialog)
251 EVT_CHECKBOX(wxID_ANY, StdButtonSizerDialog::OnEvent)
252 EVT_RADIOBUTTON(wxID_ANY, StdButtonSizerDialog::OnEvent)
253END_EVENT_TABLE()
254
c67daf87 255MyCanvas *myCanvas = (MyCanvas *) NULL;
457814b5 256
457814b5 257// `Main program' equivalent, creating windows and returning main app frame
4c45f240 258bool MyApp::OnInit()
457814b5 259{
45e6e6f8
VZ
260 if ( !wxApp::OnInit() )
261 return false;
262
f517634c 263#if wxUSE_IMAGE
013e1fee 264 wxInitAllImageHandlers();
f517634c 265#endif
013e1fee 266
19bc1514 267 m_canvasTextColour = *wxBLACK;
13188def 268 m_canvasFont = *wxNORMAL_FONT;
457814b5 269
13188def
WS
270 // Create the main frame window
271 MyFrame *frame = new MyFrame((wxFrame *) NULL, _T("wxWidgets dialogs example"));
457814b5 272
13188def 273 // Make a menubar
ca7adbf8 274 wxMenu *menuDlg = new wxMenu;
dabbc6a5 275
ca7adbf8 276 menuDlg->Append(DIALOGS_MESSAGE_BOX, _T("&Message box\tCtrl-M"));
44b25eac 277 menuDlg->Append(DIALOGS_MESSAGE_DIALOG, _T("Message dialog\tShift-Ctrl-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
44b25eac 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",
44b25eac
VZ
660 wxVSCROLL | wxCENTER |
661 wxNO_DEFAULT | wxYES_NO | wxCANCEL |
662 wxICON_INFORMATION);
2afb9e16 663
4223fc75
VZ
664 wxString extmsg;
665 if ( dialog.SetYesNoCancelLabels
666 (
667 "Answer &Yes",
668 "Answer &No",
669 "Refuse to answer"
670 ) )
2afb9e16 671 {
4223fc75 672 extmsg = "This platform supports custom button labels,\n"
5150a29a 673 "so you should see the descriptive labels below.";
2afb9e16
VZ
674 }
675 else
676 {
4223fc75
VZ
677 extmsg = "Custom button labels are not supported on this platform,\n"
678 "so the default \"Yes\"/\"No\"/\"Cancel\" buttons are used.";
2afb9e16 679 }
4223fc75 680 dialog.SetExtendedMessage(extmsg);
457814b5 681
13188def
WS
682 switch ( dialog.ShowModal() )
683 {
684 case wxID_YES:
685 wxLogStatus(wxT("You pressed \"Yes\""));
686 break;
49b957be 687
13188def
WS
688 case wxID_NO:
689 wxLogStatus(wxT("You pressed \"No\""));
690 break;
49b957be 691
13188def
WS
692 case wxID_CANCEL:
693 wxLogStatus(wxT("You pressed \"Cancel\""));
694 break;
49b957be 695
13188def
WS
696 default:
697 wxLogError(wxT("Unexpected wxMessageDialog return code!"));
698 }
457814b5
JS
699}
700
44b25eac
VZ
701void MyFrame::MessageBoxDialog(wxCommandEvent& WXUNUSED(event))
702{
703 TestMessageBoxDialog dlg(this);
704 dlg.ShowModal();
705}
706
8cf304f8
VZ
707void MyFrame::MessageBoxInfo(wxCommandEvent& WXUNUSED(event))
708{
709 ::wxInfoMessageBox(this);
710}
711#endif // wxUSE_MSGDLG
712
13188def 713#if wxUSE_NUMBERDLG
8cf304f8 714void MyFrame::NumericEntry(wxCommandEvent& WXUNUSED(event))
c49245f8 715{
78a189c9
VZ
716 long res = wxGetNumberFromUser( _T("This is some text, actually a lot of text.\n")
717 _T("Even two rows of text."),
718 _T("Enter a number:"), _T("Numeric input test"),
e65cc56a 719 50, 0, 100, this );
c49245f8
VZ
720
721 wxString msg;
722 int icon;
723 if ( res == -1 )
724 {
78a189c9 725 msg = _T("Invalid number entered or dialog cancelled.");
c49245f8
VZ
726 icon = wxICON_HAND;
727 }
728 else
d93c719a
VZ
729 {
730 msg.Printf(_T("You've entered %lu"), res );
c49245f8
VZ
731 icon = wxICON_INFORMATION;
732 }
733
78a189c9 734 wxMessageBox(msg, _T("Numeric test result"), wxOK | icon, this);
c49245f8 735}
13188def 736#endif // wxUSE_NUMBERDLG
c49245f8 737
13188def 738#if wxUSE_TEXTDLG
a294c6d5 739void MyFrame::PasswordEntry(wxCommandEvent& WXUNUSED(event))
457814b5 740{
2f1cd905 741 wxString pwd = wxGetPasswordFromUser(_T("Enter password:"),
78a189c9 742 _T("Password entry dialog"),
dabbc6a5 743 wxEmptyString,
a294c6d5 744 this);
ecda9475 745 if ( !pwd.empty() )
a294c6d5 746 {
4693b20c 747 wxMessageBox(wxString::Format(wxT("Your password is '%s'"), pwd.c_str()),
78a189c9 748 _T("Got password"), wxOK | wxICON_INFORMATION, this);
a294c6d5
VZ
749 }
750}
751
752void MyFrame::TextEntry(wxCommandEvent& WXUNUSED(event))
753{
13188def
WS
754 wxTextEntryDialog dialog(this,
755 _T("This is a small sample\n")
756 _T("A long, long string to test out the text entrybox"),
757 _T("Please enter a string"),
758 _T("Default value"),
759 wxOK | wxCANCEL);
457814b5 760
13188def
WS
761 if (dialog.ShowModal() == wxID_OK)
762 {
b4954d19 763 wxMessageBox(dialog.GetValue(), _T("Got string"), wxOK | wxICON_INFORMATION, this);
13188def 764 }
457814b5 765}
13188def 766#endif // wxUSE_TEXTDLG
457814b5 767
13188def 768#if wxUSE_CHOICEDLG
d355d3fe 769void MyFrame::SingleChoice(wxCommandEvent& WXUNUSED(event) )
457814b5 770{
78a189c9 771 const wxString choices[] = { _T("One"), _T("Two"), _T("Three"), _T("Four"), _T("Five") } ;
457814b5 772
5f95bb70 773 wxSingleChoiceDialog dialog(this,
78a189c9
VZ
774 _T("This is a small sample\n")
775 _T("A single-choice convenience dialog"),
776 _T("Please select a value"),
5f95bb70 777 WXSIZEOF(choices), choices);
457814b5 778
ef77f91e
JS
779 dialog.SetSelection(2);
780
781 if (dialog.ShowModal() == wxID_OK)
782 {
78a189c9 783 wxMessageDialog dialog2(this, dialog.GetStringSelection(), _T("Got string"));
ef77f91e
JS
784 dialog2.ShowModal();
785 }
457814b5
JS
786}
787
d6c9c1b7
VZ
788void MyFrame::MultiChoice(wxCommandEvent& WXUNUSED(event) )
789{
5f95bb70
VZ
790 const wxString choices[] =
791 {
78a189c9
VZ
792 _T("One"), _T("Two"), _T("Three"), _T("Four"), _T("Five"),
793 _T("Six"), _T("Seven"), _T("Eight"), _T("Nine"), _T("Ten"),
794 _T("Eleven"), _T("Twelve"), _T("Seventeen"),
5f95bb70 795 };
d6c9c1b7
VZ
796
797 wxArrayInt selections;
798 size_t count = wxGetMultipleChoices(selections,
78a189c9
VZ
799 _T("This is a small sample\n")
800 _T("A multi-choice convenience dialog"),
801 _T("Please select a value"),
5f95bb70 802 WXSIZEOF(choices), choices,
d6c9c1b7
VZ
803 this);
804 if ( count )
805 {
3d49ce44 806 wxString msg;
fba1b53b 807 msg.Printf(wxT("You selected %u items:\n"), (unsigned)count);
d6c9c1b7
VZ
808 for ( size_t n = 0; n < count; n++ )
809 {
fba1b53b
VZ
810 msg += wxString::Format(wxT("\t%u: %u (%s)\n"),
811 (unsigned)n, (unsigned)selections[n],
3d49ce44 812 choices[selections[n]].c_str());
d6c9c1b7 813 }
3d49ce44 814 wxLogMessage(msg);
d6c9c1b7
VZ
815 }
816 //else: cancelled or nothing selected
817}
13188def 818#endif // wxUSE_CHOICEDLG
d6c9c1b7 819
13188def 820#if wxUSE_FILEDLG
8ce68f7f
VZ
821
822// panel with custom controls for file dialog
823class MyExtraPanel : public wxPanel
824{
825public:
826 MyExtraPanel(wxWindow *parent);
827 void OnCheckBox(wxCommandEvent& event) { m_btn->Enable(event.IsChecked()); }
828 wxString GetInfo() const
829 {
830 return wxString::Format("checkbox value = %d", (int) m_cb->GetValue());
831 }
832private:
833 wxButton *m_btn;
834 wxCheckBox *m_cb;
835};
836
837MyExtraPanel::MyExtraPanel(wxWindow *parent)
838 : wxPanel(parent)
839{
840 m_btn = new wxButton(this, -1, _T("Custom Button"));
841 m_btn->Enable(false);
842 m_cb = new wxCheckBox(this, -1, _T("Enable Custom Button"));
843 m_cb->Connect(wxID_ANY, wxEVT_COMMAND_CHECKBOX_CLICKED,
844 wxCommandEventHandler(MyExtraPanel::OnCheckBox), NULL, this);
845 wxBoxSizer *sizerTop = new wxBoxSizer(wxHORIZONTAL);
846 sizerTop->Add(m_cb, wxSizerFlags().Centre().Border());
847 sizerTop->AddStretchSpacer();
848 sizerTop->Add(m_btn, wxSizerFlags().Right().Border());
849 SetSizerAndFit(sizerTop);
850}
851
852// a static method can be used instead of a function with most of compilers
853static wxWindow* createMyExtraPanel(wxWindow *parent)
854{
855 return new MyExtraPanel(parent);
856}
857
d355d3fe 858void MyFrame::FileOpen(wxCommandEvent& WXUNUSED(event) )
457814b5 859{
fbf4eacb
VZ
860 wxFileDialog dialog
861 (
862 this,
863 _T("Testing open file dialog"),
dabbc6a5
DS
864 wxEmptyString,
865 wxEmptyString,
a4e64fb5
MB
866#ifdef __WXMOTIF__
867 _T("C++ files (*.cpp)|*.cpp")
868#else
daf32463 869 _T("C++ files (*.cpp;*.h)|*.cpp;*.h")
a4e64fb5 870#endif
fbf4eacb 871 );
457814b5 872
8ce68f7f 873 dialog.SetExtraControlCreator(&createMyExtraPanel);
3b6c3fc8 874 dialog.CentreOnParent();
cd7afaff 875 dialog.SetDirectory(wxGetHomeDir());
5b636c67 876
c50f1fb9
VZ
877 if (dialog.ShowModal() == wxID_OK)
878 {
5919d76b 879 wxString info;
8ce68f7f
VZ
880 MyExtraPanel *extra_panel
881 = static_cast<MyExtraPanel*>(dialog.GetExtraControl());
13393ab6
RR
882 info.Printf(_T("Full file name: %s\n")
883 _T("Path: %s\n")
8ce68f7f
VZ
884 _T("Name: %s\n")
885 _T("Custom window: %s"),
5919d76b
VZ
886 dialog.GetPath().c_str(),
887 dialog.GetDirectory().c_str(),
8ce68f7f
VZ
888 dialog.GetFilename().c_str(),
889 extra_panel->GetInfo().c_str());
78a189c9 890 wxMessageDialog dialog2(this, info, _T("Selected file"));
c50f1fb9
VZ
891 dialog2.ShowModal();
892 }
457814b5
JS
893}
894
35b45b33
VZ
895// this shows how to take advantage of specifying a default extension in the
896// call to wxFileSelector: it is remembered after each new call and the next
897// one will use it by default
898void MyFrame::FileOpen2(wxCommandEvent& WXUNUSED(event) )
899{
900 static wxString s_extDef;
901 wxString path = wxFileSelector(
902 _T("Select the file to load"),
dabbc6a5 903 wxEmptyString, wxEmptyString,
35b45b33 904 s_extDef,
3601f639
VZ
905 wxString::Format
906 (
907 _T("Waveform (*.wav)|*.wav|Plain text (*.txt)|*.txt|All files (%s)|%s"),
908 wxFileSelectorDefaultWildcardStr,
909 wxFileSelectorDefaultWildcardStr
910 ),
9f057af5 911 wxFD_OPEN|wxFD_CHANGE_DIR|wxFD_PREVIEW,
35b45b33
VZ
912 this
913 );
914
915 if ( !path )
916 return;
917
918 // it is just a sample, would use wxSplitPath in real program
919 s_extDef = path.AfterLast(_T('.'));
920
921 wxLogMessage(_T("You selected the file '%s', remembered extension '%s'"),
a342cb00 922 path, s_extDef);
35b45b33
VZ
923}
924
c61f4f6d
VZ
925void MyFrame::FilesOpen(wxCommandEvent& WXUNUSED(event) )
926{
dabbc6a5 927 wxString wildcards =
f0f43012
JS
928#ifdef __WXMOTIF__
929 _T("C++ files (*.cpp)|*.cpp");
930#else
3601f639
VZ
931 wxString::Format
932 (
933 _T("All files (%s)|%s|C++ files (*.cpp;*.h)|*.cpp;*.h"),
934 wxFileSelectorDefaultWildcardStr,
935 wxFileSelectorDefaultWildcardStr
936 );
f0f43012 937#endif
78a189c9 938 wxFileDialog dialog(this, _T("Testing open multiple file dialog"),
dabbc6a5 939 wxEmptyString, wxEmptyString, wildcards,
ff3e84ff 940 wxFD_OPEN|wxFD_MULTIPLE);
c61f4f6d
VZ
941
942 if (dialog.ShowModal() == wxID_OK)
943 {
944 wxArrayString paths, filenames;
945
946 dialog.GetPaths(paths);
947 dialog.GetFilenames(filenames);
948
949 wxString msg, s;
950 size_t count = paths.GetCount();
951 for ( size_t n = 0; n < count; n++ )
952 {
953 s.Printf(_T("File %d: %s (%s)\n"),
fba1b53b 954 (int)n, paths[n].c_str(), filenames[n].c_str());
c61f4f6d
VZ
955
956 msg += s;
957 }
f0f43012
JS
958 s.Printf(_T("Filter index: %d"), dialog.GetFilterIndex());
959 msg += s;
c61f4f6d 960
78a189c9 961 wxMessageDialog dialog2(this, msg, _T("Selected files"));
c61f4f6d
VZ
962 dialog2.ShowModal();
963 }
964}
965
d355d3fe 966void MyFrame::FileSave(wxCommandEvent& WXUNUSED(event) )
457814b5 967{
2f1cd905
VZ
968 wxFileDialog dialog(this,
969 _T("Testing save file dialog"),
dabbc6a5 970 wxEmptyString,
2b5f62a0 971 _T("myletter.doc"),
3de9120b 972 _T("Text files (*.txt)|*.txt|Document files (*.doc;*.ods)|*.doc;*.ods"),
ff3e84ff 973 wxFD_SAVE|wxFD_OVERWRITE_PROMPT);
c50f1fb9 974
2b5f62a0
VZ
975 dialog.SetFilterIndex(1);
976
c50f1fb9
VZ
977 if (dialog.ShowModal() == wxID_OK)
978 {
2b5f62a0
VZ
979 wxLogMessage(_T("%s, filter %d"),
980 dialog.GetPath().c_str(), dialog.GetFilterIndex());
c50f1fb9 981 }
457814b5 982}
13188def 983#endif // wxUSE_FILEDLG
457814b5 984
695fe764
WS
985#if USE_FILEDLG_GENERIC
986void MyFrame::FileOpenGeneric(wxCommandEvent& WXUNUSED(event) )
987{
988 wxGenericFileDialog dialog
989 (
990 this,
991 _T("Testing open file dialog"),
992 wxEmptyString,
993 wxEmptyString,
daf32463 994 _T("C++ files (*.cpp;*.h)|*.cpp;*.h")
695fe764
WS
995 );
996
8ce68f7f 997 dialog.SetExtraControlCreator(&createMyExtraPanel);
695fe764
WS
998 dialog.SetDirectory(wxGetHomeDir());
999
1000 if (dialog.ShowModal() == wxID_OK)
1001 {
1002 wxString info;
1003 info.Printf(_T("Full file name: %s\n")
1004 _T("Path: %s\n")
1005 _T("Name: %s"),
1006 dialog.GetPath().c_str(),
1007 dialog.GetDirectory().c_str(),
1008 dialog.GetFilename().c_str());
1009 wxMessageDialog dialog2(this, info, _T("Selected file"));
1010 dialog2.ShowModal();
1011 }
1012}
1013
1014void MyFrame::FilesOpenGeneric(wxCommandEvent& WXUNUSED(event) )
1015{
684883e3
WS
1016 // On PocketPC you can disable OK-only dialogs policy using system option
1017 int buttons = wxSystemOptions::GetOptionInt(wxT("wince.dialog.real-ok-cancel"));
1018 wxSystemOptions::SetOption(wxT("wince.dialog.real-ok-cancel"), 1);
1019
daf32463 1020 wxString wildcards = _T("All files (*.*)|*.*|C++ files (*.cpp;*.h)|*.cpp;*.h");
695fe764
WS
1021 wxGenericFileDialog dialog(this, _T("Testing open multiple file dialog"),
1022 wxEmptyString, wxEmptyString, wildcards,
e031f1df 1023 wxFD_MULTIPLE);
695fe764
WS
1024
1025 if (dialog.ShowModal() == wxID_OK)
1026 {
1027 wxArrayString paths, filenames;
1028
1029 dialog.GetPaths(paths);
1030 dialog.GetFilenames(filenames);
1031
1032 wxString msg, s;
1033 size_t count = paths.GetCount();
1034 for ( size_t n = 0; n < count; n++ )
1035 {
1036 s.Printf(_T("File %d: %s (%s)\n"),
1037 (int)n, paths[n].c_str(), filenames[n].c_str());
1038
1039 msg += s;
1040 }
1041 s.Printf(_T("Filter index: %d"), dialog.GetFilterIndex());
1042 msg += s;
1043
1044 wxMessageDialog dialog2(this, msg, _T("Selected files"));
1045 dialog2.ShowModal();
1046 }
684883e3
WS
1047
1048 // restore system option
1049 wxSystemOptions::SetOption(wxT("wince.dialog.real-ok-cancel"), buttons);
695fe764
WS
1050}
1051
1052void MyFrame::FileSaveGeneric(wxCommandEvent& WXUNUSED(event) )
1053{
1054 wxGenericFileDialog dialog(this,
1055 _T("Testing save file dialog"),
1056 wxEmptyString,
1057 _T("myletter.doc"),
3de9120b 1058 _T("Text files (*.txt)|*.txt|Document files (*.doc;*.ods)|*.doc;*.ods"),
e031f1df 1059 wxFD_SAVE|wxFD_OVERWRITE_PROMPT);
695fe764
WS
1060
1061 dialog.SetFilterIndex(1);
1062
1063 if (dialog.ShowModal() == wxID_OK)
1064 {
1065 wxLogMessage(_T("%s, filter %d"),
1066 dialog.GetPath().c_str(), dialog.GetFilterIndex());
1067 }
1068}
1069#endif // USE_FILEDLG_GENERIC
1070
13188def 1071#if wxUSE_DIRDLG
f09c8393 1072void MyFrame::DoDirChoose(int style)
457814b5 1073{
3f2711d5
VZ
1074 // pass some initial dir to wxDirDialog
1075 wxString dirHome;
1076 wxGetHomeDir(&dirHome);
1077
f09c8393 1078 wxDirDialog dialog(this, _T("Testing directory picker"), dirHome, style);
c50f1fb9
VZ
1079
1080 if (dialog.ShowModal() == wxID_OK)
1081 {
2b5f62a0 1082 wxLogMessage(_T("Selected path: %s"), dialog.GetPath().c_str());
c50f1fb9
VZ
1083 }
1084}
1085
f09c8393
VZ
1086void MyFrame::DirChoose(wxCommandEvent& WXUNUSED(event) )
1087{
ff3e84ff 1088 DoDirChoose(wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST);
f09c8393
VZ
1089}
1090
1091void MyFrame::DirChooseNew(wxCommandEvent& WXUNUSED(event) )
1092{
ff3e84ff 1093 DoDirChoose(wxDD_DEFAULT_STYLE & ~wxDD_DIR_MUST_EXIST);
f09c8393 1094}
13188def 1095#endif // wxUSE_DIRDLG
f09c8393 1096
13188def 1097#if USE_DIRDLG_GENERIC
51a58d8b
JS
1098void MyFrame::GenericDirChoose(wxCommandEvent& WXUNUSED(event) )
1099{
1100 // pass some initial dir to wxDirDialog
1101 wxString dirHome;
1102 wxGetHomeDir(&dirHome);
1103
78a189c9 1104 wxGenericDirDialog dialog(this, _T("Testing generic directory picker"), dirHome);
51a58d8b
JS
1105
1106 if (dialog.ShowModal() == wxID_OK)
1107 {
78a189c9 1108 wxMessageDialog dialog2(this, dialog.GetPath(), _T("Selected path"));
51a58d8b
JS
1109 dialog2.ShowModal();
1110 }
1111}
13188def 1112#endif // USE_DIRDLG_GENERIC
51a58d8b 1113
13188def 1114#if USE_MODAL_PRESENTATION
f6bcfd97
BP
1115void MyFrame::ModalDlg(wxCommandEvent& WXUNUSED(event))
1116{
1117 MyModalDialog dlg(this);
1118 dlg.ShowModal();
1119}
1baa0a9d 1120#endif // USE_MODAL_PRESENTATION
f6bcfd97 1121
4c45f240
VZ
1122void MyFrame::ModelessDlg(wxCommandEvent& event)
1123{
2f82899b 1124 bool show = GetMenuBar()->IsChecked(event.GetId());
4c45f240
VZ
1125
1126 if ( show )
1127 {
1128 if ( !m_dialog )
1129 {
1130 m_dialog = new MyModelessDialog(this);
1131 }
1132
13188def 1133 m_dialog->Show(true);
4c45f240
VZ
1134 }
1135 else // hide
1136 {
26a12ab3
JS
1137 // If m_dialog is NULL, then possibly the system
1138 // didn't report the checked menu item status correctly.
1139 // It should be true just after the menu item was selected,
1140 // if there was no modeless dialog yet.
1141
1142 wxASSERT( m_dialog != NULL );
1143 if (m_dialog)
1144 m_dialog->Hide();
4c45f240
VZ
1145 }
1146}
cae50e6b
VZ
1147
1148void MyFrame::DlgCenteredScreen(wxCommandEvent& WXUNUSED(event))
1149{
1150 wxDialog dlg(this, wxID_ANY, _T("Dialog centered on screen"),
1151 wxDefaultPosition, wxSize(200, 100));
cd7afaff 1152 (new wxButton(&dlg, wxID_OK, _T("Close")))->Centre();
cae50e6b
VZ
1153 dlg.CentreOnScreen();
1154 dlg.ShowModal();
1155}
1156
1157void MyFrame::DlgCenteredParent(wxCommandEvent& WXUNUSED(event))
1158{
1159 wxDialog dlg(this, wxID_ANY, _T("Dialog centered on parent"),
1160 wxDefaultPosition, wxSize(200, 100));
cd7afaff 1161 (new wxButton(&dlg, wxID_OK, _T("Close")))->Centre();
cae50e6b
VZ
1162 dlg.CentreOnParent();
1163 dlg.ShowModal();
1164}
1165
1baa0a9d
VZ
1166void MyFrame::MiniFrame(wxCommandEvent& WXUNUSED(event))
1167{
1168 wxFrame *frame = new wxMiniFrame(this, wxID_ANY, _T("Mini frame"),
1169 wxDefaultPosition, wxSize(300, 100),
1170 wxCAPTION | wxCLOSE_BOX);
1171 new wxStaticText(frame,
1172 wxID_ANY,
1173 _T("Mini frames have slightly different appearance"),
1174 wxPoint(5, 5));
1175 new wxStaticText(frame,
1176 wxID_ANY,
1177 _T("from the normal frames but that's the only difference."),
1178 wxPoint(5, 25));
1179
1180 frame->CentreOnParent();
1181 frame->Show();
1182}
4c45f240 1183
8e5dbcdd
VZ
1184void MyFrame::DlgOnTop(wxCommandEvent& WXUNUSED(event))
1185{
1186 wxDialog dlg(this, wxID_ANY, _T("Dialog staying on top of other windows"),
1187 wxDefaultPosition, wxSize(300, 100),
1188 wxDEFAULT_DIALOG_STYLE | wxSTAY_ON_TOP);
1189 (new wxButton(&dlg, wxID_OK, _T("Close")))->Centre();
1190 dlg.ShowModal();
1191}
1192
13188def 1193#if wxUSE_STARTUP_TIPS
87728739 1194void MyFrame::ShowTip(wxCommandEvent& WXUNUSED(event))
c50f1fb9
VZ
1195{
1196 static size_t s_index = (size_t)-1;
1197
1198 if ( s_index == (size_t)-1 )
1199 {
1200 srand(time(NULL));
1201
1202 // this is completely bogus, we don't know how many lines are there
1203 // in the file, but who cares, it's a demo only...
1204 s_index = rand() % 5;
1205 }
1206
2f1cd905 1207 wxTipProvider *tipProvider = wxCreateFileTipProvider(_T("tips.txt"), s_index);
c50f1fb9
VZ
1208
1209 bool showAtStartup = wxShowTip(this, tipProvider);
1210
1211 if ( showAtStartup )
1212 {
2f1cd905 1213 wxMessageBox(_T("Will show tips on startup"), _T("Tips dialog"),
c50f1fb9
VZ
1214 wxOK | wxICON_INFORMATION, this);
1215 }
457814b5 1216
c50f1fb9
VZ
1217 s_index = tipProvider->GetCurrentTip();
1218 delete tipProvider;
457814b5 1219}
13188def 1220#endif // wxUSE_STARTUP_TIPS
457814b5 1221
532d575b 1222#if USE_SETTINGS_DIALOG
64d3ed17 1223void MyFrame::OnPropertySheet(wxCommandEvent& event)
0f5d8ecf 1224{
64d3ed17 1225 SettingsDialog dialog(this, event.GetId());
cc8bc5aa
JS
1226 dialog.ShowModal();
1227}
532d575b 1228#endif // USE_SETTINGS_DIALOG
0f5d8ecf 1229
9b16ffef
VZ
1230void MyFrame::OnRequestUserAttention(wxCommandEvent& WXUNUSED(event))
1231{
1232 wxLogStatus(_T("Sleeping for 3 seconds to allow you to switch to another window"));
1233
1234 wxSleep(3);
1235
1236 RequestUserAttention(wxUSER_ATTENTION_ERROR);
1237}
1238
e36a1739
VZ
1239#if wxUSE_NOTIFICATION_MESSAGE
1240
1241void MyFrame::OnNotifMsgAuto(wxCommandEvent& WXUNUSED(event))
1242{
1243 if ( !wxNotificationMessage
1244 (
1245 "Automatic Notification",
1246 "Nothing important has happened\n"
1247 "this notification will disappear soon."
1248 ).Show() )
1249 {
1250 wxLogStatus("Failed to show notification message");
1251 }
1252}
1253
1254void MyFrame::OnNotifMsgShow(wxCommandEvent& WXUNUSED(event))
1255{
1256 if ( !m_notifMsg )
1257 {
1258 m_notifMsg = new wxNotificationMessage
1259 (
1260 "wxWidgets Manual Notification",
1261 "You can hide this notification from the menu",
1262 this
1263 );
1264 }
1265
1266 if ( !m_notifMsg->Show(wxNotificationMessage::Timeout_Never) )
1267 {
1268 wxLogStatus("Failed to show manual notification message");
1269 }
1270}
1271
1272void MyFrame::OnNotifMsgHide(wxCommandEvent& WXUNUSED(event))
1273{
1274 if ( m_notifMsg )
1275 {
1276 if ( !m_notifMsg->Close() )
1277 wxLogStatus("Failed to hide manual notification message");
1278 }
1279}
1280
1281#endif // wxUSE_NOTIFICATION_MESSAGE
1282
8e1dac82
VZ
1283void MyFrame::OnStandardButtonsSizerDialog(wxCommandEvent& WXUNUSED(event))
1284{
1285 StdButtonSizerDialog dialog(this);
1286 dialog.ShowModal();
1287}
1288
a625c5b6
RR
1289// TestDefaultAction
1290
1291#define ID_CATCH_LISTBOX_DCLICK 100
1292#define ID_LISTBOX 101
1293
1294BEGIN_EVENT_TABLE(TestDefaultActionDialog, wxDialog)
1295 EVT_CHECKBOX(ID_CATCH_LISTBOX_DCLICK, TestDefaultActionDialog::OnCatchListBoxDClick)
1296 EVT_LISTBOX_DCLICK(ID_LISTBOX, TestDefaultActionDialog::OnListBoxDClick)
1297END_EVENT_TABLE()
1298
1299TestDefaultActionDialog::TestDefaultActionDialog( wxWindow *parent ) :
1300 wxDialog( parent, -1, "Test default action" )
1301{
1302 m_catchListBoxDClick = false;
1303
1304 wxBoxSizer *main_sizer = new wxBoxSizer( wxVERTICAL );
44b25eac 1305
a625c5b6 1306 wxFlexGridSizer *grid_sizer = new wxFlexGridSizer( 2, 5, 5 );
44b25eac 1307
a625c5b6
RR
1308 wxListBox *listbox = new wxListBox( this, ID_LISTBOX );
1309 listbox->Append( "String 1" );
1310 listbox->Append( "String 2" );
1311 listbox->Append( "String 3" );
1312 listbox->Append( "String 4" );
1313 grid_sizer->Add( listbox );
44b25eac 1314
a625c5b6 1315 grid_sizer->Add( new wxCheckBox( this, ID_CATCH_LISTBOX_DCLICK, "Catch DoubleClick from wxListBox" ), 0, wxALIGN_CENTRE_VERTICAL );
44b25eac 1316
a625c5b6
RR
1317 grid_sizer->Add( new wxTextCtrl( this, -1, "", wxDefaultPosition, wxSize(80,-1), 0 ), 0, wxALIGN_CENTRE_VERTICAL );
1318 grid_sizer->Add( new wxStaticText( this, -1, "wxTextCtrl without wxTE_PROCESS_ENTER" ), 0, wxALIGN_CENTRE_VERTICAL );
44b25eac 1319
a625c5b6
RR
1320 grid_sizer->Add( new wxTextCtrl( this, -1, "", wxDefaultPosition, wxSize(80,-1), wxTE_PROCESS_ENTER ), 0, wxALIGN_CENTRE_VERTICAL );
1321 grid_sizer->Add( new wxStaticText( this, -1, "wxTextCtrl with wxTE_PROCESS_ENTER" ), 0, wxALIGN_CENTRE_VERTICAL );
44b25eac 1322
a625c5b6 1323 main_sizer->Add( grid_sizer, 0, wxALL, 10 );
44b25eac 1324
a625c5b6
RR
1325 wxSizer *button_sizer = CreateSeparatedButtonSizer( wxOK|wxCANCEL );
1326 if (button_sizer)
1327 main_sizer->Add( button_sizer, 0, wxALL|wxGROW, 5 );
44b25eac 1328
8ce68f7f 1329 SetSizerAndFit( main_sizer );
a625c5b6 1330}
44b25eac 1331
a625c5b6
RR
1332void TestDefaultActionDialog::OnListBoxDClick(wxCommandEvent& event)
1333{
1334 event.Skip( !m_catchListBoxDClick );
1335}
1336
1337void TestDefaultActionDialog::OnCatchListBoxDClick(wxCommandEvent& WXUNUSED(event))
1338{
1339 m_catchListBoxDClick = !m_catchListBoxDClick;
1340}
1341
1342void MyFrame::OnTestDefaultActionDialog(wxCommandEvent& WXUNUSED(event))
1343{
1344 TestDefaultActionDialog dialog( this );
1345 dialog.ShowModal();
1346}
1347
d355d3fe 1348void MyFrame::OnExit(wxCommandEvent& WXUNUSED(event) )
457814b5 1349{
13188def 1350 Close(true);
457814b5
JS
1351}
1352
abceee76
VZ
1353#if wxUSE_PROGRESSDLG
1354
1355void MyFrame::ShowProgress( wxCommandEvent& WXUNUSED(event) )
1356{
b2c782f2 1357 static const int max = 100;
abceee76 1358
2f1cd905 1359 wxProgressDialog dialog(_T("Progress dialog example"),
78a189c9 1360 _T("An informative message"),
abceee76
VZ
1361 max, // range
1362 this, // parent
1363 wxPD_CAN_ABORT |
ecda9475 1364 wxPD_CAN_SKIP |
abceee76 1365 wxPD_APP_MODAL |
df26c4c6 1366 // wxPD_AUTO_HIDE | -- try this as well
abceee76
VZ
1367 wxPD_ELAPSED_TIME |
1368 wxPD_ESTIMATED_TIME |
f4aa7ec3 1369 wxPD_REMAINING_TIME
b2c782f2 1370 | wxPD_SMOOTH // - makes indeterminate mode bar on WinXP very small
f4aa7ec3 1371 );
abceee76 1372
13188def 1373 bool cont = true;
b2c782f2 1374 for ( int i = 0; i <= max; i++ )
abceee76 1375 {
b2c782f2 1376 wxMilliSleep(200);
ecda9475
WS
1377
1378 wxString msg;
1379
b2c782f2
VZ
1380 // test both modes of wxProgressDialog behaviour: start in
1381 // indeterminate mode but switch to the determinate one later
1382 const bool determinate = i > max/2;
f4aa7ec3 1383
abceee76
VZ
1384 if ( i == max )
1385 {
ecda9475 1386 msg = _T("That's all, folks!");
abceee76 1387 }
b2c782f2 1388 else if ( !determinate )
f4aa7ec3 1389 {
b2c782f2 1390 msg = _T("Testing indeterminate mode");
f4aa7ec3 1391 }
b2c782f2 1392 else if ( determinate )
abceee76 1393 {
b2c782f2 1394 msg = _T("Now in standard determinate mode");
abceee76 1395 }
ecda9475 1396
b2c782f2
VZ
1397 // will be set to true if "Skip" button was pressed
1398 bool skip = false;
1399 if ( determinate )
abceee76 1400 {
ecda9475 1401 cont = dialog.Update(i, msg, &skip);
abceee76 1402 }
f4aa7ec3
VZ
1403 else
1404 {
f4aa7ec3 1405 cont = dialog.Pulse(msg, &skip);
f4aa7ec3 1406 }
ecda9475 1407
b2c782f2
VZ
1408 // each skip will move progress about quarter forward
1409 if ( skip )
1410 i += max/4;
1411
d8ddee9c
VZ
1412 if ( !cont )
1413 {
78a189c9
VZ
1414 if ( wxMessageBox(_T("Do you really want to cancel?"),
1415 _T("Progress dialog question"), // caption
1416 wxYES_NO | wxICON_QUESTION) == wxYES )
d8ddee9c
VZ
1417 break;
1418
9b16ffef 1419 cont = true;
d8ddee9c
VZ
1420 dialog.Resume();
1421 }
abceee76
VZ
1422 }
1423
1424 if ( !cont )
1425 {
4693b20c 1426 wxLogStatus(wxT("Progress dialog aborted!"));
abceee76
VZ
1427 }
1428 else
1429 {
4693b20c 1430 wxLogStatus(wxT("Countdown from %d finished"), max);
abceee76
VZ
1431 }
1432}
1433
1434#endif // wxUSE_PROGRESSDLG
1435
ca7adbf8
VZ
1436#if wxUSE_ABOUTDLG
1437
453c9e3b 1438static void InitAboutInfoMinimal(wxAboutDialogInfo& info)
ca7adbf8
VZ
1439{
1440 info.SetName(_T("Dialogs Sample"));
1a1ecce6 1441 info.SetVersion(wxVERSION_NUM_DOT_STRING_T);
ca7adbf8 1442 info.SetDescription(_T("This sample shows different wxWidgets dialogs"));
730654ee 1443 info.SetCopyright(_T("(C) 1998-2006 wxWidgets dev team"));
50671311 1444 info.AddDeveloper(_T("Vadim Zeitlin"));
ca7adbf8
VZ
1445}
1446
453c9e3b
VZ
1447static void InitAboutInfoWebsite(wxAboutDialogInfo& info)
1448{
1449 InitAboutInfoMinimal(info);
1450
1451 info.SetWebSite(_T("http://www.wxwidgets.org/"), _T("wxWidgets web site"));
1452}
1453
1454static void InitAboutInfoAll(wxAboutDialogInfo& info)
1455{
20fe9c5a 1456 InitAboutInfoWebsite(info);
453c9e3b
VZ
1457
1458 // we can add a second developer
1459 info.AddDeveloper(_T("A.N. Other"));
1460
1461 // or we can add several persons at once like this
1462 static const wxChar *docwriters[] =
1463 {
1464 _T("First D. Writer"),
1465 _T("Second One"),
1466 };
1467
1468 info.SetDocWriters(wxArrayString(WXSIZEOF(docwriters), docwriters));
1469 info.SetLicence(wxString::FromAscii(
1470" wxWindows Library Licence, Version 3.1\n"
1471" ======================================\n"
1472"\n"
1473" Copyright (c) 1998-2005 Julian Smart, Robert Roebling et al\n"
1474"\n"
1475" Everyone is permitted to copy and distribute verbatim copies\n"
1476" of this licence document, but changing it is not allowed.\n"
1477"\n"
1478" WXWINDOWS LIBRARY LICENCE\n"
1479" TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION\n"
1480"\n"
1481" ...and so on and so forth...\n"
1482 ));
fb4f85bf
VZ
1483
1484 info.AddTranslator(_T("Wun Ngo Wen (Martian)"));
453c9e3b
VZ
1485}
1486
ca7adbf8
VZ
1487void MyFrame::ShowSimpleAboutDialog(wxCommandEvent& WXUNUSED(event))
1488{
1489 wxAboutDialogInfo info;
453c9e3b 1490 InitAboutInfoMinimal(info);
ca7adbf8
VZ
1491
1492 wxAboutBox(info);
1493}
1494
1495void MyFrame::ShowFancyAboutDialog(wxCommandEvent& WXUNUSED(event))
1496{
1497 wxAboutDialogInfo info;
453c9e3b 1498 InitAboutInfoWebsite(info);
ca7adbf8
VZ
1499
1500 wxAboutBox(info);
1501}
1502
453c9e3b
VZ
1503void MyFrame::ShowFullAboutDialog(wxCommandEvent& WXUNUSED(event))
1504{
1505 wxAboutDialogInfo info;
1506 InitAboutInfoAll(info);
1507
1508 wxAboutBox(info);
1509}
1510
1dcfc333
VZ
1511// a trivial example of a custom dialog class
1512class MyAboutDialog : public wxGenericAboutDialog
453c9e3b 1513{
1dcfc333
VZ
1514public:
1515 MyAboutDialog(const wxAboutDialogInfo& info)
453c9e3b 1516 {
1dcfc333
VZ
1517 Create(info);
1518 }
453c9e3b 1519
1dcfc333
VZ
1520 // add some custom controls
1521 virtual void DoAddCustomControls()
1522 {
1523 AddControl(new wxStaticLine(this), wxSizerFlags().Expand());
1524 AddText(_T("Some custom text"));
1525 AddControl(new wxStaticLine(this), wxSizerFlags().Expand());
1526 }
1527};
453c9e3b 1528
1dcfc333
VZ
1529void MyFrame::ShowCustomAboutDialog(wxCommandEvent& WXUNUSED(event))
1530{
453c9e3b
VZ
1531 wxAboutDialogInfo info;
1532 InitAboutInfoAll(info);
1533
1534 MyAboutDialog dlg(info);
1535 dlg.ShowModal();
1536}
1537
ca7adbf8
VZ
1538#endif // wxUSE_ABOUTDLG
1539
a62b0bcc
VZ
1540#if wxUSE_BUSYINFO
1541
1542void MyFrame::ShowBusyInfo(wxCommandEvent& WXUNUSED(event))
1543{
21977bac
VZ
1544 wxWindowDisabler disableAll;
1545
9f84eccd 1546 wxBusyInfo info(_T("Working, please wait..."), this);
a62b0bcc 1547
5b636c67 1548 for ( int i = 0; i < 18; i++ )
a62b0bcc 1549 {
5b636c67 1550 //wxUsleep(100);
a62b0bcc
VZ
1551 wxTheApp->Yield();
1552 }
5b636c67
VZ
1553
1554 wxSleep(2);
1555 //wxWakeUpIdle();
a62b0bcc
VZ
1556}
1557
1558#endif // wxUSE_BUSYINFO
1559
761989ff
VZ
1560#if wxUSE_FINDREPLDLG
1561
1562void MyFrame::ShowReplaceDialog( wxCommandEvent& WXUNUSED(event) )
1563{
14fca738
VZ
1564 if ( m_dlgReplace )
1565 {
1566 delete m_dlgReplace;
1567 m_dlgReplace = NULL;
1568 }
1569 else
1570 {
1571 m_dlgReplace = new wxFindReplaceDialog
1572 (
1573 this,
1574 &m_findData,
78a189c9 1575 _T("Find and replace dialog"),
14fca738
VZ
1576 wxFR_REPLACEDIALOG
1577 );
1578
13188def 1579 m_dlgReplace->Show(true);
14fca738 1580 }
761989ff
VZ
1581}
1582
1583void MyFrame::ShowFindDialog( wxCommandEvent& WXUNUSED(event) )
1584{
14fca738
VZ
1585 if ( m_dlgFind )
1586 {
1587 delete m_dlgFind;
1588 m_dlgFind = NULL;
1589 }
1590 else
1591 {
1592 m_dlgFind = new wxFindReplaceDialog
1593 (
1594 this,
1595 &m_findData,
78a189c9 1596 _T("Find dialog"),
14fca738
VZ
1597 // just for testing
1598 wxFR_NOWHOLEWORD
1599 );
1600
13188def 1601 m_dlgFind->Show(true);
14fca738 1602 }
761989ff
VZ
1603}
1604
1605static wxString DecodeFindDialogEventFlags(int flags)
1606{
1607 wxString str;
78a189c9 1608 str << (flags & wxFR_DOWN ? _T("down") : _T("up")) << _T(", ")
2f1cd905
VZ
1609 << (flags & wxFR_WHOLEWORD ? _T("whole words only, ") : _T(""))
1610 << (flags & wxFR_MATCHCASE ? _T("") : _T("not "))
78a189c9 1611 << _T("case sensitive");
761989ff
VZ
1612
1613 return str;
1614}
1615
1616void MyFrame::OnFindDialog(wxFindDialogEvent& event)
1617{
1618 wxEventType type = event.GetEventType();
1619
1620 if ( type == wxEVT_COMMAND_FIND || type == wxEVT_COMMAND_FIND_NEXT )
1621 {
4693b20c 1622 wxLogMessage(wxT("Find %s'%s' (flags: %s)"),
eba33006 1623 type == wxEVT_COMMAND_FIND_NEXT ? wxT("next ") : wxT(""),
761989ff
VZ
1624 event.GetFindString().c_str(),
1625 DecodeFindDialogEventFlags(event.GetFlags()).c_str());
1626 }
1627 else if ( type == wxEVT_COMMAND_FIND_REPLACE ||
1628 type == wxEVT_COMMAND_FIND_REPLACE_ALL )
1629 {
4693b20c 1630 wxLogMessage(wxT("Replace %s'%s' with '%s' (flags: %s)"),
eba33006 1631 type == wxEVT_COMMAND_FIND_REPLACE_ALL ? _T("all ") : wxT(""),
761989ff
VZ
1632 event.GetFindString().c_str(),
1633 event.GetReplaceString().c_str(),
1634 DecodeFindDialogEventFlags(event.GetFlags()).c_str());
1635 }
1636 else if ( type == wxEVT_COMMAND_FIND_CLOSE )
1637 {
14fca738
VZ
1638 wxFindReplaceDialog *dlg = event.GetDialog();
1639
df26c4c6 1640 int idMenu;
14fca738
VZ
1641 const wxChar *txt;
1642 if ( dlg == m_dlgFind )
1643 {
1644 txt = _T("Find");
df26c4c6 1645 idMenu = DIALOGS_FIND;
14fca738
VZ
1646 m_dlgFind = NULL;
1647 }
1648 else if ( dlg == m_dlgReplace )
1649 {
1650 txt = _T("Replace");
df26c4c6 1651 idMenu = DIALOGS_REPLACE;
14fca738
VZ
1652 m_dlgReplace = NULL;
1653 }
1654 else
1655 {
1656 txt = _T("Unknown");
13188def 1657 idMenu = wxID_ANY;
14fca738 1658
2f1cd905 1659 wxFAIL_MSG( _T("unexpected event") );
14fca738
VZ
1660 }
1661
df26c4c6
VZ
1662 wxLogMessage(wxT("%s dialog is being closed."), txt);
1663
13188def 1664 if ( idMenu != wxID_ANY )
df26c4c6 1665 {
13188def 1666 GetMenuBar()->Check(idMenu, false);
df26c4c6 1667 }
761989ff 1668
14fca738 1669 dlg->Destroy();
761989ff
VZ
1670 }
1671 else
1672 {
4693b20c 1673 wxLogError(wxT("Unknown find dialog event!"));
761989ff
VZ
1674 }
1675}
1676
1677#endif // wxUSE_FINDREPLDLG
1678
abceee76
VZ
1679// ----------------------------------------------------------------------------
1680// MyCanvas
1681// ----------------------------------------------------------------------------
1682
d355d3fe 1683void MyCanvas::OnPaint(wxPaintEvent& WXUNUSED(event) )
457814b5 1684{
c50f1fb9 1685 wxPaintDC dc(this);
457814b5
JS
1686 dc.SetFont(wxGetApp().m_canvasFont);
1687 dc.SetTextForeground(wxGetApp().m_canvasTextColour);
1688 dc.SetBackgroundMode(wxTRANSPARENT);
dc96b1b6
WS
1689 dc.DrawText(
1690 _T("wxWidgets common dialogs")
1691#if !defined(__SMARTPHONE__)
1692 _T(" test application")
1693#endif
1694 , 10, 10);
457814b5
JS
1695}
1696
b4954d19
WS
1697#if USE_MODAL_PRESENTATION
1698
4c45f240
VZ
1699// ----------------------------------------------------------------------------
1700// MyModelessDialog
1701// ----------------------------------------------------------------------------
457814b5 1702
4c45f240 1703MyModelessDialog::MyModelessDialog(wxWindow *parent)
13188def 1704 : wxDialog(parent, wxID_ANY, wxString(_T("Modeless dialog")))
4c45f240 1705{
cbc66a27
VZ
1706 wxBoxSizer *sizerTop = new wxBoxSizer(wxVERTICAL);
1707
78a189c9 1708 wxButton *btn = new wxButton(this, DIALOGS_MODELESS_BTN, _T("Press me"));
13188def 1709 wxCheckBox *check = new wxCheckBox(this, wxID_ANY, _T("Should be disabled"));
cbc66a27
VZ
1710 check->Disable();
1711
1712 sizerTop->Add(btn, 1, wxEXPAND | wxALL, 5);
1713 sizerTop->Add(check, 1, wxEXPAND | wxALL, 5);
1714
8ce68f7f 1715 SetSizerAndFit(sizerTop);
4c45f240 1716}
abceee76 1717
5d987909
VZ
1718void MyModelessDialog::OnButton(wxCommandEvent& WXUNUSED(event))
1719{
2f1cd905 1720 wxMessageBox(_T("Button pressed in modeless dialog"), _T("Info"),
5d987909
VZ
1721 wxOK | wxICON_INFORMATION, this);
1722}
1723
abceee76
VZ
1724void MyModelessDialog::OnClose(wxCloseEvent& event)
1725{
1726 if ( event.CanVeto() )
1727 {
2f1cd905 1728 wxMessageBox(_T("Use the menu item to close this dialog"),
78a189c9 1729 _T("Modeless dialog"),
abceee76
VZ
1730 wxOK | wxICON_INFORMATION, this);
1731
1732 event.Veto();
1733 }
1734}
1735
f6bcfd97
BP
1736// ----------------------------------------------------------------------------
1737// MyModalDialog
1738// ----------------------------------------------------------------------------
1739
1740MyModalDialog::MyModalDialog(wxWindow *parent)
13188def 1741 : wxDialog(parent, wxID_ANY, wxString(_T("Modal dialog")))
f6bcfd97
BP
1742{
1743 wxBoxSizer *sizerTop = new wxBoxSizer(wxHORIZONTAL);
1744
13188def
WS
1745 m_btnModal = new wxButton(this, wxID_ANY, _T("&Modal dialog..."));
1746 m_btnModeless = new wxButton(this, wxID_ANY, _T("Mode&less dialog"));
1747 m_btnDelete = new wxButton(this, wxID_ANY, _T("&Delete button"));
5315ebfa 1748
78a189c9 1749 wxButton *btnOk = new wxButton(this, wxID_CANCEL, _T("&Close"));
5315ebfa
VZ
1750 sizerTop->Add(m_btnModal, 0, wxALIGN_CENTER | wxALL, 5);
1751 sizerTop->Add(m_btnModeless, 0, wxALIGN_CENTER | wxALL, 5);
f6bcfd97 1752 sizerTop->Add(m_btnDelete, 0, wxALIGN_CENTER | wxALL, 5);
9b70bb91 1753 sizerTop->Add(btnOk, 0, wxALIGN_CENTER | wxALL, 5);
f6bcfd97 1754
8ce68f7f 1755 SetSizerAndFit(sizerTop);
f6bcfd97 1756
5315ebfa
VZ
1757 m_btnModal->SetFocus();
1758 m_btnModal->SetDefault();
f6bcfd97
BP
1759}
1760
1761void MyModalDialog::OnButton(wxCommandEvent& event)
1762{
1763 if ( event.GetEventObject() == m_btnDelete )
1764 {
5315ebfa
VZ
1765 delete m_btnModal;
1766 m_btnModal = NULL;
f6bcfd97
BP
1767
1768 m_btnDelete->Disable();
1769 }
5315ebfa 1770 else if ( event.GetEventObject() == m_btnModal )
f6bcfd97 1771 {
13188def 1772#if wxUSE_TEXTDLG
78a189c9
VZ
1773 wxGetTextFromUser(_T("Dummy prompt"),
1774 _T("Modal dialog called from dialog"),
dabbc6a5 1775 wxEmptyString, this);
13188def
WS
1776#else
1777 wxMessageBox(_T("Modal dialog called from dialog"));
1778#endif // wxUSE_TEXTDLG
f6bcfd97 1779 }
5315ebfa
VZ
1780 else if ( event.GetEventObject() == m_btnModeless )
1781 {
1782 (new MyModelessDialog(this))->Show();
1783 }
f6bcfd97
BP
1784 else
1785 {
1786 event.Skip();
1787 }
1788}
b4954d19
WS
1789
1790#endif // USE_MODAL_PRESENTATION
1791
8e1dac82
VZ
1792// ----------------------------------------------------------------------------
1793// StdButtonSizerDialog
1794// ----------------------------------------------------------------------------
1795
1796StdButtonSizerDialog::StdButtonSizerDialog(wxWindow *parent)
1797 : wxDialog(parent, wxID_ANY, wxString(_T("StdButtonSizer dialog")),
1798 wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER),
1799 m_buttonsSizer(NULL)
1800{
1801 wxBoxSizer *const sizerTop = new wxBoxSizer(wxVERTICAL);
1802
1803 wxBoxSizer *const sizer = new wxBoxSizer(wxHORIZONTAL);
1804 wxBoxSizer *const sizerInside1 = new wxBoxSizer(wxVERTICAL);
1805
1806 m_chkboxAffirmativeButton = new wxCheckBox(this, wxID_ANY, _("Enable Affirmative Button"));
1807
1808 wxStaticBoxSizer *const sizer1 = new wxStaticBoxSizer(wxVERTICAL, this, wxT("Affirmative Button"));
1809
1810 m_radiobtnOk = new wxRadioButton(this, wxID_ANY, _("Ok"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP);
1811 m_radiobtnYes = new wxRadioButton(this, wxID_ANY, _("Yes"));
1812
1813 wxBoxSizer *const sizerInside2 = new wxBoxSizer(wxVERTICAL);
1814
1815 m_chkboxDismissButton = new wxCheckBox(this, wxID_ANY, _("Enable Dismiss Button"));
1816
1817 wxStaticBoxSizer *const sizer2 = new wxStaticBoxSizer(wxVERTICAL, this, wxT("Dismiss Button"));
1818
1819 m_radiobtnCancel = new wxRadioButton(this, wxID_ANY, _("Cancel"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP);
1820 m_radiobtnClose = new wxRadioButton(this, wxID_ANY, _("Close"));
1821
1822 wxBoxSizer *const sizer3 = new wxBoxSizer(wxHORIZONTAL);
1823
1824 m_chkboxNo = new wxCheckBox(this, wxID_ANY, _("No"));
1825 m_chkboxHelp = new wxCheckBox(this, wxID_ANY, _("Help"));
1826 m_chkboxApply = new wxCheckBox(this, wxID_ANY, _("Apply"));
1827
1828 m_chkboxNoDefault = new wxCheckBox(this, wxID_ANY, wxT("No Default"));
1829
1830 sizer1->Add(m_radiobtnOk, 0, wxALL, 5);
1831 sizer1->Add(m_radiobtnYes, 0, wxALL, 5);
1832
1833 sizer->Add(sizerInside1, 0, 0, 0);
1834 sizerInside1->Add(m_chkboxAffirmativeButton, 0, wxALL, 5);
1835 sizerInside1->Add(sizer1, 0, wxALL, 5);
1836 sizerInside1->SetItemMinSize(sizer1, sizer1->GetStaticBox()->GetBestSize()); // to prevent wrapping of static box label
1837
1838 sizer2->Add(m_radiobtnCancel, 0, wxALL, 5);
1839 sizer2->Add(m_radiobtnClose, 0, wxALL, 5);
1840
1841 sizer->Add(sizerInside2, 0, 0, 0);
1842 sizerInside2->Add(m_chkboxDismissButton, 0, wxALL, 5);
1843 sizerInside2->Add(sizer2, 0, wxALL, 5);
1844 sizerInside2->SetItemMinSize(sizer2, sizer2->GetStaticBox()->GetBestSize()); // to prevent wrapping of static box label
1845
1846 sizerTop->Add(sizer, 0, wxALL, 5);
1847
1848 sizer3->Add(m_chkboxNo, 0, wxALL, 5);
1849 sizer3->Add(m_chkboxHelp, 0, wxALL, 5);
1850 sizer3->Add(m_chkboxApply, 0, wxALL, 5);
1851
1852 sizerTop->Add(sizer3, 0, wxALL, 5);
1853
1854 sizerTop->Add(m_chkboxNoDefault, 0, wxLEFT|wxRIGHT, 10);
1855
1856 EnableDisableControls();
1857
8ce68f7f 1858 SetSizerAndFit(sizerTop);
8e1dac82 1859
8e1dac82
VZ
1860 wxCommandEvent ev;
1861 OnEvent(ev);
1862}
1863
1864void StdButtonSizerDialog::OnEvent(wxCommandEvent& WXUNUSED(event))
1865{
1866 if (m_buttonsSizer)
1867 {
1868 m_buttonsSizer->DeleteWindows();
1869 GetSizer()->Remove(m_buttonsSizer);
1870 }
1871
1872 EnableDisableControls();
1873
1874 long flags = 0;
1875 unsigned long numButtons = 0;
1876
1877 if (m_chkboxAffirmativeButton->IsChecked())
1878 {
1879 if (m_radiobtnOk->GetValue())
1880 {
1881 flags |= wxOK;
1882 numButtons ++;
1883 }
1884 else if (m_radiobtnYes->GetValue())
1885 {
1886 flags |= wxYES;
1887 numButtons ++;
1888 }
1889 }
1890
1891 if (m_chkboxDismissButton->IsChecked())
1892 {
1893 if (m_radiobtnCancel->GetValue())
1894 {
1895 flags |= wxCANCEL;
1896 numButtons ++;
1897 }
1898
1899 else if (m_radiobtnClose->GetValue())
1900 {
1901 flags |= wxCLOSE;
1902 numButtons ++;
1903 }
1904
1905 }
1906
1907 if (m_chkboxApply->IsChecked())
1908 {
1909 flags |= wxAPPLY;
1910 numButtons ++;
1911 }
1912
1913 if (m_chkboxNo->IsChecked())
1914 {
1915 flags |= wxNO;
1916 numButtons ++;
1917 }
1918
1919 if (m_chkboxHelp->IsChecked())
1920 {
1921 flags |= wxHELP;
1922 numButtons ++;
1923 }
1924
1925 if (m_chkboxNoDefault->IsChecked())
1926 {
1927 flags |= wxNO_DEFAULT;
1928 }
1929
1930 m_buttonsSizer = CreateStdDialogButtonSizer(flags);
1931 GetSizer()->Add(m_buttonsSizer, 0, wxGROW|wxALL, 5);
1932
1933 Layout();
1934 GetSizer()->SetSizeHints(this);
1935}
1936
1937void StdButtonSizerDialog::EnableDisableControls()
1938{
1939 const bool affButtonEnabled = m_chkboxAffirmativeButton->IsChecked();
1940
1941 m_radiobtnOk->Enable(affButtonEnabled);
1942 m_radiobtnYes->Enable(affButtonEnabled);
1943
1944 const bool dismissButtonEnabled = m_chkboxDismissButton->IsChecked();
1945
1946 m_radiobtnCancel->Enable(dismissButtonEnabled);
1947 m_radiobtnClose->Enable(dismissButtonEnabled);
1948}
1949
532d575b 1950#if USE_SETTINGS_DIALOG
0f5d8ecf
JS
1951// ----------------------------------------------------------------------------
1952// SettingsDialog
1953// ----------------------------------------------------------------------------
1954
1955IMPLEMENT_CLASS(SettingsDialog, wxPropertySheetDialog)
1956
1957BEGIN_EVENT_TABLE(SettingsDialog, wxPropertySheetDialog)
1958END_EVENT_TABLE()
1959
64d3ed17 1960SettingsDialog::SettingsDialog(wxWindow* win, int dialogType)
0f5d8ecf 1961{
0f4991f4 1962 SetExtraStyle(wxDIALOG_EX_CONTEXTHELP|wxWS_EX_VALIDATE_RECURSIVELY);
0f5d8ecf 1963
cc8bc5aa
JS
1964 int tabImage1 = -1;
1965 int tabImage2 = -1;
e031f1df 1966
64d3ed17 1967 bool useToolBook = (dialogType == DIALOGS_PROPERTY_SHEET_TOOLBOOK || dialogType == DIALOGS_PROPERTY_SHEET_BUTTONTOOLBOOK);
77631b1d 1968 int resizeBorder = wxRESIZE_BORDER;
684883e3 1969
cc8bc5aa
JS
1970 if (useToolBook)
1971 {
77631b1d 1972 resizeBorder = 0;
cc8bc5aa
JS
1973 tabImage1 = 0;
1974 tabImage2 = 1;
e031f1df 1975
64d3ed17
JS
1976 int sheetStyle = wxPROPSHEET_SHRINKTOFIT;
1977 if (dialogType == DIALOGS_PROPERTY_SHEET_BUTTONTOOLBOOK)
1978 sheetStyle |= wxPROPSHEET_BUTTONTOOLBOOK;
1979 else
1980 sheetStyle |= wxPROPSHEET_TOOLBOOK;
e031f1df 1981
64d3ed17 1982 SetSheetStyle(sheetStyle);
77631b1d
JS
1983 SetSheetInnerBorder(0);
1984 SetSheetOuterBorder(0);
cc8bc5aa
JS
1985
1986 // create a dummy image list with a few icons
1987 const wxSize imageSize(32, 32);
1988
1989 m_imageList = new wxImageList(imageSize.GetWidth(), imageSize.GetHeight());
1990 m_imageList->
1991 Add(wxArtProvider::GetIcon(wxART_INFORMATION, wxART_OTHER, imageSize));
1992 m_imageList->
1993 Add(wxArtProvider::GetIcon(wxART_QUESTION, wxART_OTHER, imageSize));
1994 m_imageList->
1995 Add(wxArtProvider::GetIcon(wxART_WARNING, wxART_OTHER, imageSize));
1996 m_imageList->
1997 Add(wxArtProvider::GetIcon(wxART_ERROR, wxART_OTHER, imageSize));
1998 }
1999 else
2000 m_imageList = NULL;
2001
532d575b 2002 Create(win, wxID_ANY, _("Preferences"), wxDefaultPosition, wxDefaultSize,
654ffe9f 2003 wxDEFAULT_DIALOG_STYLE| (int)wxPlatform::IfNot(wxOS_WINDOWS_CE, resizeBorder)
3103e8a9 2004 );
cc8bc5aa 2005
684883e3 2006 // If using a toolbook, also follow Mac style and don't create buttons
cc8bc5aa 2007 if (!useToolBook)
654ffe9f
VZ
2008 CreateButtons(wxOK | wxCANCEL |
2009 (int)wxPlatform::IfNot(wxOS_WINDOWS_CE, wxHELP)
897b24cf 2010 );
0f5d8ecf
JS
2011
2012 wxBookCtrlBase* notebook = GetBookCtrl();
cc8bc5aa 2013 notebook->SetImageList(m_imageList);
0f5d8ecf
JS
2014
2015 wxPanel* generalSettings = CreateGeneralSettingsPage(notebook);
2016 wxPanel* aestheticSettings = CreateAestheticSettingsPage(notebook);
2017
cc8bc5aa
JS
2018 notebook->AddPage(generalSettings, _("General"), true, tabImage1);
2019 notebook->AddPage(aestheticSettings, _("Aesthetics"), false, tabImage2);
0f5d8ecf
JS
2020
2021 LayoutDialog();
2022}
2023
cc8bc5aa
JS
2024SettingsDialog::~SettingsDialog()
2025{
2026 delete m_imageList;
2027}
2028
0f5d8ecf
JS
2029wxPanel* SettingsDialog::CreateGeneralSettingsPage(wxWindow* parent)
2030{
2031 wxPanel* panel = new wxPanel(parent, wxID_ANY);
2032
2033 wxBoxSizer *topSizer = new wxBoxSizer( wxVERTICAL );
2034 wxBoxSizer *item0 = new wxBoxSizer( wxVERTICAL );
2035
2036 //// LOAD LAST FILE
2037
2038 wxBoxSizer* itemSizer3 = new wxBoxSizer( wxHORIZONTAL );
2039 wxCheckBox* checkBox3 = new wxCheckBox(panel, ID_LOAD_LAST_PROJECT, _("&Load last project on startup"), wxDefaultPosition, wxDefaultSize);
2040 itemSizer3->Add(checkBox3, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5);
2041 item0->Add(itemSizer3, 0, wxGROW|wxALL, 0);
2042
2043 //// AUTOSAVE
2044
2045 wxString autoSaveLabel = _("&Auto-save every");
2046 wxString minsLabel = _("mins");
2047
2048 wxBoxSizer* itemSizer12 = new wxBoxSizer( wxHORIZONTAL );
2049 wxCheckBox* checkBox12 = new wxCheckBox(panel, ID_AUTO_SAVE, autoSaveLabel, wxDefaultPosition, wxDefaultSize);
62675ef3
JS
2050
2051#if wxUSE_SPINCTRL
0f5d8ecf 2052 wxSpinCtrl* spinCtrl12 = new wxSpinCtrl(panel, ID_AUTO_SAVE_MINS, wxEmptyString,
532d575b 2053 wxDefaultPosition, wxSize(40, wxDefaultCoord), wxSP_ARROW_KEYS, 1, 60, 1);
62675ef3 2054#endif
532d575b 2055
0f5d8ecf 2056 itemSizer12->Add(checkBox12, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5);
62675ef3 2057#if wxUSE_SPINCTRL
0f5d8ecf 2058 itemSizer12->Add(spinCtrl12, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5);
62675ef3 2059#endif
0f5d8ecf
JS
2060 itemSizer12->Add(new wxStaticText(panel, wxID_STATIC, minsLabel), 0, wxALL|wxALIGN_CENTER_VERTICAL, 5);
2061 item0->Add(itemSizer12, 0, wxGROW|wxALL, 0);
2062
2063 //// TOOLTIPS
532d575b 2064
0f5d8ecf
JS
2065 wxBoxSizer* itemSizer8 = new wxBoxSizer( wxHORIZONTAL );
2066 wxCheckBox* checkBox6 = new wxCheckBox(panel, ID_SHOW_TOOLTIPS, _("Show &tooltips"), wxDefaultPosition, wxDefaultSize);
2067 itemSizer8->Add(checkBox6, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5);
2068 item0->Add(itemSizer8, 0, wxGROW|wxALL, 0);
2069
2070 topSizer->Add( item0, 1, wxGROW|wxALIGN_CENTRE|wxALL, 5 );
2071
8ce68f7f 2072 panel->SetSizerAndFit(topSizer);
532d575b 2073
0f5d8ecf
JS
2074 return panel;
2075}
2076
2077wxPanel* SettingsDialog::CreateAestheticSettingsPage(wxWindow* parent)
2078{
2079 wxPanel* panel = new wxPanel(parent, wxID_ANY);
2080
2081 wxBoxSizer *topSizer = new wxBoxSizer( wxVERTICAL );
2082 wxBoxSizer *item0 = new wxBoxSizer( wxVERTICAL );
2083
2084 //// PROJECT OR GLOBAL
2085 wxString globalOrProjectChoices[2];
2086 globalOrProjectChoices[0] = _("&New projects");
2087 globalOrProjectChoices[1] = _("&This project");
2088
2089 wxRadioBox* projectOrGlobal = new wxRadioBox(panel, ID_APPLY_SETTINGS_TO, _("&Apply settings to:"),
2090 wxDefaultPosition, wxDefaultSize, 2, globalOrProjectChoices);
2091 item0->Add(projectOrGlobal, 0, wxGROW|wxALL, 5);
2092
2093 projectOrGlobal->SetSelection(0);
2094
2095 //// BACKGROUND STYLE
2096 wxArrayString backgroundStyleChoices;
2097 backgroundStyleChoices.Add(wxT("Colour"));
2098 backgroundStyleChoices.Add(wxT("Image"));
532d575b 2099 wxStaticBox* staticBox3 = new wxStaticBox(panel, wxID_ANY, _("Background style:"));
0f5d8ecf
JS
2100
2101 wxBoxSizer* styleSizer = new wxStaticBoxSizer( staticBox3, wxVERTICAL );
2102 item0->Add(styleSizer, 0, wxGROW|wxALL, 5);
2103
2104 wxBoxSizer* itemSizer2 = new wxBoxSizer( wxHORIZONTAL );
2105
2106 wxChoice* choice2 = new wxChoice(panel, ID_BACKGROUND_STYLE, wxDefaultPosition, wxDefaultSize, backgroundStyleChoices);
2107
2108 itemSizer2->Add(new wxStaticText(panel, wxID_ANY, _("&Window:")), 0, wxALL|wxALIGN_CENTER_VERTICAL, 5);
2109 itemSizer2->Add(5, 5, 1, wxALL, 0);
2110 itemSizer2->Add(choice2, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5);
2111
2112 styleSizer->Add(itemSizer2, 0, wxGROW|wxALL, 5);
2113
62675ef3 2114#if wxUSE_SPINCTRL
0f5d8ecf
JS
2115 //// FONT SIZE SELECTION
2116
532d575b 2117 wxStaticBox* staticBox1 = new wxStaticBox(panel, wxID_ANY, _("Tile font size:"));
0f5d8ecf
JS
2118 wxBoxSizer* itemSizer5 = new wxStaticBoxSizer( staticBox1, wxHORIZONTAL );
2119
2120 wxSpinCtrl* spinCtrl = new wxSpinCtrl(panel, ID_FONT_SIZE, wxEmptyString, wxDefaultPosition,
532d575b 2121 wxSize(80, wxDefaultCoord));
0f5d8ecf
JS
2122 itemSizer5->Add(spinCtrl, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
2123
2124 item0->Add(itemSizer5, 0, wxGROW|wxLEFT|wxRIGHT, 5);
62675ef3 2125#endif
0f5d8ecf
JS
2126
2127 topSizer->Add( item0, 1, wxGROW|wxALIGN_CENTRE|wxALL, 5 );
0f4991f4 2128 topSizer->AddSpacer(5);
0f5d8ecf 2129
8ce68f7f 2130 panel->SetSizerAndFit(topSizer);
532d575b 2131
0f5d8ecf
JS
2132 return panel;
2133}
2134
44b25eac
VZ
2135// ----------------------------------------------------------------------------
2136// TestMessageBoxDialog
2137// ----------------------------------------------------------------------------
2138
b3ca7c85
VZ
2139/* static */
2140const TestMessageBoxDialog::BtnInfo TestMessageBoxDialog::ms_btnInfo[] =
44b25eac
VZ
2141{
2142 { wxYES, "&Yes" },
2143 { wxNO, "&No" },
2144 { wxOK, "&Ok" },
2145 { wxCANCEL, "&Cancel" },
2146};
2147
2148BEGIN_EVENT_TABLE(TestMessageBoxDialog, wxDialog)
2149 EVT_BUTTON(wxID_APPLY, TestMessageBoxDialog::OnApply)
2150 EVT_BUTTON(wxID_CLOSE, TestMessageBoxDialog::OnClose)
2151END_EVENT_TABLE()
2152
2153TestMessageBoxDialog::TestMessageBoxDialog(wxWindow *parent)
2154 : wxDialog(parent, wxID_ANY, "Message Box Test Dialog",
2155 wxDefaultPosition, wxDefaultSize,
2156 wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
2157{
2158 wxSizer * const sizerTop = new wxBoxSizer(wxVERTICAL);
2159
2160 // this sizer allows to configure the messages shown in the message box
2161 wxSizer * const
2162 sizerMsgs = new wxStaticBoxSizer(wxVERTICAL, this, "&Messages");
2163 sizerMsgs->Add(new wxStaticText(this, wxID_ANY, "&Main message:"));
4e2dc789 2164 m_textMsg = new wxTextCtrl(this, wxID_ANY, "Hello from a box!",
44b25eac
VZ
2165 wxDefaultPosition, wxDefaultSize,
2166 wxTE_MULTILINE);
2167 sizerMsgs->Add(m_textMsg, wxSizerFlags(1).Expand().Border(wxBOTTOM));
2168
2169 sizerMsgs->Add(new wxStaticText(this, wxID_ANY, "&Extended message:"));
2170 m_textExtMsg = new wxTextCtrl(this, wxID_ANY, "",
2171 wxDefaultPosition, wxDefaultSize,
2172 wxTE_MULTILINE);
2173 sizerMsgs->Add(m_textExtMsg, wxSizerFlags(1).Expand());
2174
2175 sizerTop->Add(sizerMsgs, wxSizerFlags(1).Expand().Border());
2176
2177
2178 // this one is for configuring the buttons
2179 wxFlexGridSizer * const sizerBtns = new wxFlexGridSizer(2, 5, 5);
2180 sizerBtns->AddGrowableCol(1);
2181
2182 sizerBtns->Add(new wxStaticText(this, wxID_ANY, "Button(s)"));
2183 sizerBtns->Add(new wxStaticText(this, wxID_ANY, "Custom label"));
2184
2185 for ( int n = 0; n < Btn_Max; n++ )
2186 {
2187 m_buttons[n] = new wxCheckBox(this, wxID_ANY, ms_btnInfo[n].name);
2188 sizerBtns->Add(m_buttons[n], wxSizerFlags().Centre().Left());
2189
2190 m_labels[n] = new wxTextCtrl(this, wxID_ANY);
2191 sizerBtns->Add(m_labels[n], wxSizerFlags(1).Centre().Expand());
2192
2193 m_labels[n]->Connect(wxEVT_UPDATE_UI,
2194 wxUpdateUIEventHandler(
2195 TestMessageBoxDialog::OnUpdateLabelUI),
2196 NULL,
2197 this);
2198 }
2199
2200 wxSizer * const
2201 sizerBtnsBox = new wxStaticBoxSizer(wxVERTICAL, this, "&Buttons");
2202 sizerBtnsBox->Add(sizerBtns, wxSizerFlags(1).Expand());
2203 sizerTop->Add(sizerBtnsBox, wxSizerFlags().Expand().Border());
2204
2205
2206 // icon choice
2207 const wxString icons[] = {
2208 "&Information", "&Question", "&Warning", "&Error"
2209 };
2210
2211 m_icons = new wxRadioBox(this, wxID_ANY, "&Icon:",
2212 wxDefaultPosition, wxDefaultSize,
2213 WXSIZEOF(icons), icons);
2214 sizerTop->Add(m_icons, wxSizerFlags().Expand().Border());
2215
2216
4e2dc789
VZ
2217 // miscellaneous other stuff
2218 wxSizer * const
2219 sizerFlags = new wxStaticBoxSizer(wxHORIZONTAL, this, "&Other flags");
2220
2221 m_chkNoDefault = new wxCheckBox(this, wxID_ANY, "Make \"No\" &default");
2222 m_chkNoDefault->Connect(wxEVT_UPDATE_UI,
2223 wxUpdateUIEventHandler(
2224 TestMessageBoxDialog::OnUpdateNoDefaultUI),
2225 NULL,
2226 this);
2227 sizerFlags->Add(m_chkNoDefault, wxSizerFlags(1).Border());
2228
2229 m_chkCentre = new wxCheckBox(this, wxID_ANY, "Centre on &parent");
2230 sizerFlags->Add(m_chkCentre, wxSizerFlags(1).Border());
2231
2232 sizerTop->Add(sizerFlags, wxSizerFlags().Expand().Border());
2233
44b25eac
VZ
2234 // finally buttons to show the resulting message box and close this dialog
2235 sizerTop->Add(CreateStdDialogButtonSizer(wxAPPLY | wxCLOSE),
2236 wxSizerFlags().Right().Border());
2237
2238 SetSizerAndFit(sizerTop);
4e2dc789
VZ
2239
2240 m_buttons[Btn_Ok]->SetValue(true);
44b25eac
VZ
2241}
2242
2243void TestMessageBoxDialog::OnUpdateLabelUI(wxUpdateUIEvent& event)
2244{
2245 for ( int n = 0; n < Btn_Max; n++ )
2246 {
2247 if ( event.GetEventObject() == m_labels[n] )
2248 {
2249 event.Enable( m_buttons[n]->IsChecked() );
2250 return;
2251 }
2252 }
2253
2254 wxFAIL_MSG( "called for unknown label" );
2255}
2256
4e2dc789
VZ
2257void TestMessageBoxDialog::OnUpdateNoDefaultUI(wxUpdateUIEvent& event)
2258{
2259 event.Enable( m_buttons[Btn_No]->IsChecked() );
2260}
2261
44b25eac
VZ
2262void TestMessageBoxDialog::OnApply(wxCommandEvent& WXUNUSED(event))
2263{
2264 long style = 0;
2265
2266 for ( int n = 0; n < Btn_Max; n++ )
2267 {
2268 if ( m_buttons[n]->IsChecked() )
2269 style |= ms_btnInfo[n].flag;
2270 }
2271
2272 switch ( m_icons->GetSelection() )
2273 {
2274 case 0: style |= wxICON_INFORMATION; break;
2275 case 1: style |= wxICON_QUESTION; break;
2276 case 2: style |= wxICON_WARNING; break;
2277 case 3: style |= wxICON_ERROR; break;
2278 }
2279
4e2dc789
VZ
2280 if ( m_chkCentre->IsChecked() )
2281 style |= wxCENTRE;
2282
2283 if ( m_chkNoDefault->IsEnabled() && m_chkNoDefault->IsChecked() )
2284 style |= wxNO_DEFAULT;
2285
2286
44b25eac
VZ
2287 wxMessageDialog dlg(this, m_textMsg->GetValue(), "Test Message Box",
2288 style);
2289 if ( !m_textExtMsg->IsEmpty() )
2290 dlg.SetExtendedMessage(m_textExtMsg->GetValue());
2291
2292 if ( style & wxYES_NO )
2293 {
2294 if ( style & wxCANCEL )
2295 {
2296 dlg.SetYesNoCancelLabels(m_labels[Btn_Yes]->GetValue(),
2297 m_labels[Btn_No]->GetValue(),
2298 m_labels[Btn_Cancel]->GetValue());
2299 }
2300 else
2301 {
2302 dlg.SetYesNoLabels(m_labels[Btn_Yes]->GetValue(),
2303 m_labels[Btn_No]->GetValue());
2304 }
2305 }
2306 else
2307 {
2308 if ( style & wxCANCEL )
2309 {
2310 dlg.SetOKCancelLabels(m_labels[Btn_Ok]->GetValue(),
2311 m_labels[Btn_Cancel]->GetValue());
2312 }
2313 else
2314 {
2315 dlg.SetOKLabel(m_labels[Btn_Ok]->GetValue());
2316 }
2317 }
2318
2319 dlg.ShowModal();
2320}
2321
2322void TestMessageBoxDialog::OnClose(wxCommandEvent& WXUNUSED(event))
2323{
2324 EndModal(wxID_CANCEL);
2325}
2326
532d575b 2327#endif // USE_SETTINGS_DIALOG
9ad2fe62
VZ
2328
2329#if wxUSE_LOG
2330
2331// ----------------------------------------------------------------------------
2332// custom log target
2333// ----------------------------------------------------------------------------
2334
2335class MyLogGui : public wxLogGui
2336{
2337private:
2338 virtual void DoShowSingleLogMessage(const wxString& message,
2339 const wxString& title,
2340 int style)
2341 {
f0afc953
VZ
2342 wxMessageDialog dlg(NULL, message, title,
2343 wxOK | wxCANCEL | wxCANCEL_DEFAULT | style);
2344 dlg.SetOKCancelLabels(wxID_COPY, wxID_OK);
9ad2fe62
VZ
2345 dlg.SetExtendedMessage("Note that this is a custom log dialog.");
2346 dlg.ShowModal();
2347 }
2348};
2349
2350wxLog *MyAppTraits::CreateLogTarget()
2351{
2352 return new MyLogGui;
2353}
2354
2355#endif // wxUSE_LOG