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