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