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