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