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