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