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