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