]>
Commit | Line | Data |
---|---|---|
457814b5 JS |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: dialogs.cpp | |
3 | // Purpose: Common dialogs demo | |
4 | // Author: Julian Smart | |
695fe764 | 5 | // Modified by: ABX (2004) - adjustements for conditional building + new menu |
457814b5 JS |
6 | // Created: 04/01/98 |
7 | // RCS-ID: $Id$ | |
6aa89a22 | 8 | // Copyright: (c) Julian Smart |
c50f1fb9 | 9 | // Licence: wxWindows license |
457814b5 JS |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
457814b5 JS |
12 | // For compilers that support precompilation, includes "wx/wx.h". |
13 | #include "wx/wxprec.h" | |
14 | ||
15 | #ifdef __BORLANDC__ | |
16 | #pragma hdrstop | |
17 | #endif | |
18 | ||
19 | #ifndef WX_PRECOMP | |
20 | #include "wx/wx.h" | |
21 | #endif | |
22 | ||
0f5d8ecf JS |
23 | #include "../sample.xpm" |
24 | ||
fb8a56b7 | 25 | #include "wx/datetime.h" |
f517634c | 26 | #include "wx/image.h" |
5378558e | 27 | #include "wx/bookctrl.h" |
cc8bc5aa | 28 | #include "wx/artprov.h" |
2b923807 | 29 | #include "wx/imaglist.h" |
1baa0a9d | 30 | #include "wx/minifram.h" |
684883e3 | 31 | #include "wx/sysopt.h" |
457814b5 | 32 | |
13188def WS |
33 | #if wxUSE_COLOURDLG |
34 | #include "wx/colordlg.h" | |
35 | #endif // wxUSE_COLOURDLG | |
dfad0599 | 36 | |
13188def WS |
37 | #if wxUSE_CHOICEDLG |
38 | #include "wx/choicdlg.h" | |
39 | #endif // wxUSE_CHOICEDLG | |
457814b5 | 40 | |
13188def WS |
41 | #if wxUSE_STARTUP_TIPS |
42 | #include "wx/tipdlg.h" | |
43 | #endif // wxUSE_STARTUP_TIPS | |
d7d17624 | 44 | |
13188def | 45 | #if wxUSE_PROGRESSDLG |
9b16ffef | 46 | #if wxUSE_STOPWATCH && wxUSE_LONGLONG |
b20edf8b | 47 | #include "wx/datetime.h" // wxDateTime |
9b16ffef VZ |
48 | #endif |
49 | ||
13188def WS |
50 | #include "wx/progdlg.h" |
51 | #endif // wxUSE_PROGRESSDLG | |
52 | ||
ca7adbf8 VZ |
53 | #if wxUSE_ABOUTDLG |
54 | #include "wx/aboutdlg.h" | |
453c9e3b VZ |
55 | |
56 | // these headers are only needed for custom about dialog | |
57 | #include "wx/statline.h" | |
58 | #include "wx/generic/aboutdlgg.h" | |
ca7adbf8 VZ |
59 | #endif // wxUSE_ABOUTDLG |
60 | ||
13188def WS |
61 | #if wxUSE_BUSYINFO |
62 | #include "wx/busyinfo.h" | |
63 | #endif // wxUSE_BUSYINFO | |
64 | ||
65 | #if wxUSE_NUMBERDLG | |
66 | #include "wx/numdlg.h" | |
67 | #endif // wxUSE_NUMBERDLG | |
68 | ||
69 | #if wxUSE_FILEDLG | |
70 | #include "wx/filedlg.h" | |
71 | #endif // wxUSE_FILEDLG | |
72 | ||
73 | #if wxUSE_DIRDLG | |
74 | #include "wx/dirdlg.h" | |
75 | #endif // wxUSE_DIRDLG | |
76 | ||
77 | #if wxUSE_FONTDLG | |
78 | #include "wx/fontdlg.h" | |
79 | #endif // wxUSE_FONTDLG | |
80 | ||
81 | #if wxUSE_FINDREPLDLG | |
82 | #include "wx/fdrepdlg.h" | |
83 | #endif // wxUSE_FINDREPLDLG | |
4ad3c82f | 84 | |
62675ef3 | 85 | #if wxUSE_SPINCTRL |
0f5d8ecf | 86 | #include "wx/spinctrl.h" |
62675ef3 JS |
87 | #endif |
88 | ||
0f5d8ecf JS |
89 | #include "wx/propdlg.h" |
90 | ||
457814b5 JS |
91 | #include "dialogs.h" |
92 | ||
13188def WS |
93 | #if USE_COLOURDLG_GENERIC |
94 | #include "wx/generic/colrdlgg.h" | |
95 | #endif // USE_COLOURDLG_GENERIC | |
96 | ||
13188def WS |
97 | #if USE_DIRDLG_GENERIC |
98 | #include "wx/generic/dirdlgg.h" | |
99 | #endif // USE_DIRDLG_GENERIC | |
100 | ||
695fe764 WS |
101 | #if USE_FILEDLG_GENERIC |
102 | #include "wx/generic/filedlgg.h" | |
103 | #endif // USE_FILEDLG_GENERIC | |
104 | ||
105 | #if USE_FONTDLG_GENERIC | |
106 | #include "wx/generic/fontdlgg.h" | |
107 | #endif // USE_FONTDLG_GENERIC | |
108 | ||
457814b5 JS |
109 | IMPLEMENT_APP(MyApp) |
110 | ||
4c45f240 VZ |
111 | BEGIN_EVENT_TABLE(MyCanvas, wxScrolledWindow) |
112 | EVT_PAINT(MyCanvas::OnPaint) | |
113 | END_EVENT_TABLE() | |
114 | ||
13188def WS |
115 | |
116 | ||
4c45f240 | 117 | BEGIN_EVENT_TABLE(MyFrame, wxFrame) |
13188def WS |
118 | EVT_MENU(DIALOGS_MESSAGE_BOX, MyFrame::MessageBox) |
119 | ||
120 | #if wxUSE_COLOURDLG | |
4c45f240 | 121 | EVT_MENU(DIALOGS_CHOOSE_COLOUR, MyFrame::ChooseColour) |
13188def WS |
122 | #endif // wxUSE_COLOURDLG |
123 | ||
124 | #if wxUSE_FONTDLG | |
4c45f240 | 125 | EVT_MENU(DIALOGS_CHOOSE_FONT, MyFrame::ChooseFont) |
13188def WS |
126 | #endif // wxUSE_FONTDLG |
127 | ||
128 | #if wxUSE_LOG_DIALOG | |
4c45f240 | 129 | EVT_MENU(DIALOGS_LOG_DIALOG, MyFrame::LogDialog) |
13188def WS |
130 | #endif // wxUSE_LOG_DIALOG |
131 | ||
132 | #if wxUSE_TEXTDLG | |
4c45f240 VZ |
133 | EVT_MENU(DIALOGS_TEXT_ENTRY, MyFrame::TextEntry) |
134 | EVT_MENU(DIALOGS_PASSWORD_ENTRY, MyFrame::PasswordEntry) | |
13188def WS |
135 | #endif // wxUSE_TEXTDLG |
136 | ||
137 | #if wxUSE_NUMBERDLG | |
4c45f240 | 138 | EVT_MENU(DIALOGS_NUM_ENTRY, MyFrame::NumericEntry) |
13188def WS |
139 | #endif // wxUSE_NUMBERDLG |
140 | ||
141 | #if wxUSE_CHOICEDLG | |
4c45f240 | 142 | EVT_MENU(DIALOGS_SINGLE_CHOICE, MyFrame::SingleChoice) |
d6c9c1b7 | 143 | EVT_MENU(DIALOGS_MULTI_CHOICE, MyFrame::MultiChoice) |
13188def WS |
144 | #endif // wxUSE_CHOICEDLG |
145 | ||
146 | #if wxUSE_FILEDLG | |
4c45f240 | 147 | EVT_MENU(DIALOGS_FILE_OPEN, MyFrame::FileOpen) |
35b45b33 | 148 | EVT_MENU(DIALOGS_FILE_OPEN2, MyFrame::FileOpen2) |
4c45f240 VZ |
149 | EVT_MENU(DIALOGS_FILES_OPEN, MyFrame::FilesOpen) |
150 | EVT_MENU(DIALOGS_FILE_SAVE, MyFrame::FileSave) | |
13188def WS |
151 | #endif // wxUSE_FILEDLG |
152 | ||
695fe764 WS |
153 | #if USE_FILEDLG_GENERIC |
154 | EVT_MENU(DIALOGS_FILE_OPEN_GENERIC, MyFrame::FileOpenGeneric) | |
155 | EVT_MENU(DIALOGS_FILES_OPEN_GENERIC, MyFrame::FilesOpenGeneric) | |
156 | EVT_MENU(DIALOGS_FILE_SAVE_GENERIC, MyFrame::FileSaveGeneric) | |
157 | #endif // USE_FILEDLG_GENERIC | |
158 | ||
13188def | 159 | #if wxUSE_DIRDLG |
4c45f240 | 160 | EVT_MENU(DIALOGS_DIR_CHOOSE, MyFrame::DirChoose) |
f09c8393 | 161 | EVT_MENU(DIALOGS_DIRNEW_CHOOSE, MyFrame::DirChooseNew) |
13188def WS |
162 | #endif // wxUSE_DIRDLG |
163 | ||
164 | #if USE_MODAL_PRESENTATION | |
f6bcfd97 | 165 | EVT_MENU(DIALOGS_MODAL, MyFrame::ModalDlg) |
1baa0a9d | 166 | #endif // USE_MODAL_PRESENTATION |
4c45f240 | 167 | EVT_MENU(DIALOGS_MODELESS, MyFrame::ModelessDlg) |
cae50e6b VZ |
168 | EVT_MENU(DIALOGS_CENTRE_SCREEN, MyFrame::DlgCenteredScreen) |
169 | EVT_MENU(DIALOGS_CENTRE_PARENT, MyFrame::DlgCenteredParent) | |
1baa0a9d | 170 | EVT_MENU(DIALOGS_MINIFRAME, MyFrame::MiniFrame) |
8e5dbcdd | 171 | EVT_MENU(DIALOGS_ONTOP, MyFrame::DlgOnTop) |
13188def WS |
172 | |
173 | #if wxUSE_STARTUP_TIPS | |
4c45f240 | 174 | EVT_MENU(DIALOGS_TIP, MyFrame::ShowTip) |
13188def WS |
175 | #endif // wxUSE_STARTUP_TIPS |
176 | ||
177 | #if USE_FONTDLG_GENERIC | |
4c45f240 | 178 | EVT_MENU(DIALOGS_CHOOSE_FONT_GENERIC, MyFrame::ChooseFontGeneric) |
13188def WS |
179 | #endif // USE_FONTDLG_GENERIC |
180 | ||
181 | #if USE_DIRDLG_GENERIC | |
182 | EVT_MENU(DIALOGS_GENERIC_DIR_CHOOSE, MyFrame::GenericDirChoose) | |
183 | #endif // wxMSW || wxMAC | |
184 | ||
185 | #if USE_COLOURDLG_GENERIC | |
186 | EVT_MENU(DIALOGS_CHOOSE_COLOUR_GENERIC, MyFrame::ChooseColourGeneric) | |
187 | #endif // USE_COLOURDLG_GENERIC | |
a62b0bcc | 188 | |
abceee76 VZ |
189 | #if wxUSE_PROGRESSDLG |
190 | EVT_MENU(DIALOGS_PROGRESS, MyFrame::ShowProgress) | |
761989ff | 191 | #endif // wxUSE_PROGRESSDLG |
a62b0bcc | 192 | |
ca7adbf8 VZ |
193 | #if wxUSE_ABOUTDLG |
194 | EVT_MENU(DIALOGS_ABOUTDLG_SIMPLE, MyFrame::ShowSimpleAboutDialog) | |
195 | EVT_MENU(DIALOGS_ABOUTDLG_FANCY, MyFrame::ShowFancyAboutDialog) | |
453c9e3b VZ |
196 | EVT_MENU(DIALOGS_ABOUTDLG_FULL, MyFrame::ShowFullAboutDialog) |
197 | EVT_MENU(DIALOGS_ABOUTDLG_CUSTOM, MyFrame::ShowCustomAboutDialog) | |
ca7adbf8 VZ |
198 | #endif // wxUSE_ABOUTDLG |
199 | ||
a62b0bcc VZ |
200 | #if wxUSE_BUSYINFO |
201 | EVT_MENU(DIALOGS_BUSYINFO, MyFrame::ShowBusyInfo) | |
202 | #endif // wxUSE_BUSYINFO | |
203 | ||
761989ff VZ |
204 | #if wxUSE_FINDREPLDLG |
205 | EVT_MENU(DIALOGS_FIND, MyFrame::ShowFindDialog) | |
206 | EVT_MENU(DIALOGS_REPLACE, MyFrame::ShowReplaceDialog) | |
207 | ||
13188def WS |
208 | EVT_FIND(wxID_ANY, MyFrame::OnFindDialog) |
209 | EVT_FIND_NEXT(wxID_ANY, MyFrame::OnFindDialog) | |
210 | EVT_FIND_REPLACE(wxID_ANY, MyFrame::OnFindDialog) | |
211 | EVT_FIND_REPLACE_ALL(wxID_ANY, MyFrame::OnFindDialog) | |
212 | EVT_FIND_CLOSE(wxID_ANY, MyFrame::OnFindDialog) | |
761989ff | 213 | #endif // wxUSE_FINDREPLDLG |
13188def | 214 | |
532d575b | 215 | #if USE_SETTINGS_DIALOG |
0f5d8ecf | 216 | EVT_MENU(DIALOGS_PROPERTY_SHEET, MyFrame::OnPropertySheet) |
64d3ed17 JS |
217 | EVT_MENU(DIALOGS_PROPERTY_SHEET_TOOLBOOK, MyFrame::OnPropertySheet) |
218 | EVT_MENU(DIALOGS_PROPERTY_SHEET_BUTTONTOOLBOOK, MyFrame::OnPropertySheet) | |
532d575b WS |
219 | #endif |
220 | ||
8e1dac82 | 221 | EVT_MENU(DIALOGS_STANDARD_BUTTON_SIZER_DIALOG, MyFrame::OnStandardButtonsSizerDialog) |
0f5d8ecf | 222 | EVT_MENU(DIALOGS_REQUEST, MyFrame::OnRequestUserAttention) |
9b16ffef | 223 | |
4c45f240 | 224 | EVT_MENU(wxID_EXIT, MyFrame::OnExit) |
4c45f240 | 225 | END_EVENT_TABLE() |
abceee76 | 226 | |
13188def | 227 | #if USE_MODAL_PRESENTATION |
f6bcfd97 | 228 | |
13188def WS |
229 | BEGIN_EVENT_TABLE(MyModalDialog, wxDialog) |
230 | EVT_BUTTON(wxID_ANY, MyModalDialog::OnButton) | |
231 | END_EVENT_TABLE() | |
5d987909 | 232 | |
13188def WS |
233 | BEGIN_EVENT_TABLE(MyModelessDialog, wxDialog) |
234 | EVT_BUTTON(DIALOGS_MODELESS_BTN, MyModelessDialog::OnButton) | |
235 | EVT_CLOSE(MyModelessDialog::OnClose) | |
236 | END_EVENT_TABLE() | |
237 | ||
238 | #endif // USE_MODAL_PRESENTATION | |
abceee76 | 239 | |
8e1dac82 VZ |
240 | BEGIN_EVENT_TABLE(StdButtonSizerDialog, wxDialog) |
241 | EVT_CHECKBOX(wxID_ANY, StdButtonSizerDialog::OnEvent) | |
242 | EVT_RADIOBUTTON(wxID_ANY, StdButtonSizerDialog::OnEvent) | |
243 | END_EVENT_TABLE() | |
244 | ||
c67daf87 | 245 | MyCanvas *myCanvas = (MyCanvas *) NULL; |
457814b5 | 246 | |
457814b5 | 247 | // `Main program' equivalent, creating windows and returning main app frame |
4c45f240 | 248 | bool MyApp::OnInit() |
457814b5 | 249 | { |
45e6e6f8 VZ |
250 | if ( !wxApp::OnInit() ) |
251 | return false; | |
252 | ||
f517634c | 253 | #if wxUSE_IMAGE |
013e1fee | 254 | wxInitAllImageHandlers(); |
f517634c | 255 | #endif |
013e1fee | 256 | |
19bc1514 | 257 | m_canvasTextColour = *wxBLACK; |
13188def | 258 | m_canvasFont = *wxNORMAL_FONT; |
457814b5 | 259 | |
13188def WS |
260 | // Create the main frame window |
261 | MyFrame *frame = new MyFrame((wxFrame *) NULL, _T("wxWidgets dialogs example")); | |
457814b5 | 262 | |
13188def | 263 | // Make a menubar |
ca7adbf8 | 264 | wxMenu *menuDlg = new wxMenu; |
dabbc6a5 | 265 | |
ca7adbf8 | 266 | menuDlg->Append(DIALOGS_MESSAGE_BOX, _T("&Message box\tCtrl-M")); |
457814b5 | 267 | |
457814b5 | 268 | |
33bcca32 | 269 | #if wxUSE_COLOURDLG || wxUSE_FONTDLG || wxUSE_CHOICEDLG |
f09c8393 | 270 | |
33bcca32 | 271 | wxMenu *choices_menu = new wxMenu; |
f09c8393 | 272 | |
33bcca32 VZ |
273 | #if wxUSE_COLOURDLG |
274 | choices_menu->Append(DIALOGS_CHOOSE_COLOUR, _T("&Choose colour")); | |
275 | #endif // wxUSE_COLOURDLG | |
f09c8393 | 276 | |
33bcca32 VZ |
277 | #if wxUSE_FONTDLG |
278 | choices_menu->Append(DIALOGS_CHOOSE_FONT, _T("Choose &font")); | |
279 | #endif // wxUSE_FONTDLG | |
457814b5 | 280 | |
33bcca32 VZ |
281 | #if wxUSE_CHOICEDLG |
282 | choices_menu->Append(DIALOGS_SINGLE_CHOICE, _T("&Single choice\tCtrl-C")); | |
283 | choices_menu->Append(DIALOGS_MULTI_CHOICE, _T("M&ultiple choice\tCtrl-U")); | |
284 | #endif // wxUSE_CHOICEDLG | |
695fe764 | 285 | |
33bcca32 VZ |
286 | #if USE_COLOURDLG_GENERIC || USE_FONTDLG_GENERIC |
287 | choices_menu->AppendSeparator(); | |
288 | #endif // USE_COLOURDLG_GENERIC || USE_FONTDLG_GENERIC | |
695fe764 | 289 | |
33bcca32 VZ |
290 | #if USE_COLOURDLG_GENERIC |
291 | choices_menu->Append(DIALOGS_CHOOSE_COLOUR_GENERIC, _T("&Choose colour (generic)")); | |
292 | #endif // USE_COLOURDLG_GENERIC | |
695fe764 | 293 | |
33bcca32 VZ |
294 | #if USE_FONTDLG_GENERIC |
295 | choices_menu->Append(DIALOGS_CHOOSE_FONT_GENERIC, _T("Choose &font (generic)")); | |
296 | #endif // USE_FONTDLG_GENERIC | |
d93c719a | 297 | |
ca7adbf8 | 298 | menuDlg->Append(wxID_ANY,_T("&Choices and selectors"),choices_menu); |
33bcca32 | 299 | #endif // wxUSE_COLOURDLG || wxUSE_FONTDLG || wxUSE_CHOICEDLG |
457814b5 | 300 | |
457814b5 | 301 | |
33bcca32 | 302 | #if wxUSE_TEXTDLG || wxUSE_NUMBERDLG |
13188def | 303 | |
33bcca32 | 304 | wxMenu *entry_menu = new wxMenu; |
13188def | 305 | |
33bcca32 VZ |
306 | #if wxUSE_TEXTDLG |
307 | entry_menu->Append(DIALOGS_TEXT_ENTRY, _T("Text &entry\tCtrl-E")); | |
308 | entry_menu->Append(DIALOGS_PASSWORD_ENTRY, _T("&Password entry\tCtrl-P")); | |
309 | #endif // wxUSE_TEXTDLG | |
13188def | 310 | |
33bcca32 VZ |
311 | #if wxUSE_NUMBERDLG |
312 | entry_menu->Append(DIALOGS_NUM_ENTRY, _T("&Numeric entry\tCtrl-N")); | |
313 | #endif // wxUSE_NUMBERDLG | |
13188def | 314 | |
ca7adbf8 | 315 | menuDlg->Append(wxID_ANY,_T("&Entry dialogs"),entry_menu); |
13188def | 316 | |
33bcca32 | 317 | #endif // wxUSE_TEXTDLG || wxUSE_NUMBERDLG |
13188def WS |
318 | |
319 | ||
33bcca32 | 320 | #if wxUSE_FILEDLG |
13188def | 321 | |
33bcca32 VZ |
322 | wxMenu *filedlg_menu = new wxMenu; |
323 | filedlg_menu->Append(DIALOGS_FILE_OPEN, _T("&Open file\tCtrl-O")); | |
324 | filedlg_menu->Append(DIALOGS_FILE_OPEN2, _T("&Second open file\tCtrl-2")); | |
325 | filedlg_menu->Append(DIALOGS_FILES_OPEN, _T("Open &files\tCtrl-Q")); | |
326 | filedlg_menu->Append(DIALOGS_FILE_SAVE, _T("Sa&ve file\tCtrl-S")); | |
695fe764 | 327 | |
33bcca32 VZ |
328 | #if USE_FILEDLG_GENERIC |
329 | filedlg_menu->AppendSeparator(); | |
330 | filedlg_menu->Append(DIALOGS_FILE_OPEN_GENERIC, _T("&Open file (generic)")); | |
331 | filedlg_menu->Append(DIALOGS_FILES_OPEN_GENERIC, _T("Open &files (generic)")); | |
332 | filedlg_menu->Append(DIALOGS_FILE_SAVE_GENERIC, _T("Sa&ve file (generic)")); | |
333 | #endif // USE_FILEDLG_GENERIC | |
695fe764 | 334 | |
ca7adbf8 | 335 | menuDlg->Append(wxID_ANY,_T("&File operations"),filedlg_menu); |
13188def | 336 | |
33bcca32 | 337 | #endif // wxUSE_FILEDLG |
13188def | 338 | |
33bcca32 VZ |
339 | #if wxUSE_DIRDLG |
340 | wxMenu *dir_menu = new wxMenu; | |
13188def | 341 | |
33bcca32 VZ |
342 | dir_menu->Append(DIALOGS_DIR_CHOOSE, _T("&Choose a directory\tCtrl-D")); |
343 | dir_menu->Append(DIALOGS_DIRNEW_CHOOSE, _T("Choose a directory (with \"Ne&w\" button)\tShift-Ctrl-D")); | |
ca7adbf8 | 344 | menuDlg->Append(wxID_ANY,_T("&Directory operations"),dir_menu); |
13188def | 345 | |
33bcca32 VZ |
346 | #if USE_DIRDLG_GENERIC |
347 | dir_menu->AppendSeparator(); | |
348 | dir_menu->Append(DIALOGS_GENERIC_DIR_CHOOSE, _T("&Choose a directory (generic)")); | |
349 | #endif // USE_DIRDLG_GENERIC | |
13188def | 350 | |
33bcca32 | 351 | #endif // wxUSE_DIRDLG |
13188def WS |
352 | |
353 | ||
33bcca32 | 354 | #if wxUSE_STARTUP_TIPS || wxUSE_PROGRESSDLG || wxUSE_BUSYINFO || wxUSE_LOG_DIALOG |
13188def | 355 | |
33bcca32 | 356 | wxMenu *info_menu = new wxMenu; |
13188def | 357 | |
33bcca32 VZ |
358 | #if wxUSE_STARTUP_TIPS |
359 | info_menu->Append(DIALOGS_TIP, _T("&Tip of the day\tCtrl-T")); | |
360 | #endif // wxUSE_STARTUP_TIPS | |
13188def | 361 | |
33bcca32 VZ |
362 | #if wxUSE_PROGRESSDLG |
363 | info_menu->Append(DIALOGS_PROGRESS, _T("Pro&gress dialog\tCtrl-G")); | |
364 | #endif // wxUSE_PROGRESSDLG | |
13188def | 365 | |
33bcca32 VZ |
366 | #if wxUSE_BUSYINFO |
367 | info_menu->Append(DIALOGS_BUSYINFO, _T("&Busy info dialog\tCtrl-B")); | |
368 | #endif // wxUSE_BUSYINFO | |
13188def | 369 | |
33bcca32 VZ |
370 | #if wxUSE_LOG_DIALOG |
371 | info_menu->Append(DIALOGS_LOG_DIALOG, _T("&Log dialog\tCtrl-L")); | |
372 | #endif // wxUSE_LOG_DIALOG | |
13188def | 373 | |
ca7adbf8 | 374 | menuDlg->Append(wxID_ANY,_T("&Informative dialogs"),info_menu); |
13188def | 375 | |
33bcca32 | 376 | #endif // wxUSE_STARTUP_TIPS || wxUSE_PROGRESSDLG || wxUSE_BUSYINFO || wxUSE_LOG_DIALOG |
13188def WS |
377 | |
378 | ||
33bcca32 VZ |
379 | #if wxUSE_FINDREPLDLG |
380 | wxMenu *find_menu = new wxMenu; | |
381 | find_menu->AppendCheckItem(DIALOGS_FIND, _T("&Find dialog\tCtrl-F")); | |
382 | find_menu->AppendCheckItem(DIALOGS_REPLACE, _T("Find and &replace dialog\tShift-Ctrl-F")); | |
ca7adbf8 | 383 | menuDlg->Append(wxID_ANY,_T("&Searching"),find_menu); |
33bcca32 | 384 | #endif // wxUSE_FINDREPLDLG |
13188def | 385 | |
cae50e6b | 386 | wxMenu *dialogs_menu = new wxMenu; |
1baa0a9d | 387 | #if USE_MODAL_PRESENTATION |
cae50e6b | 388 | dialogs_menu->Append(DIALOGS_MODAL, _T("&Modal dialog\tCtrl-W")); |
1baa0a9d | 389 | #endif // USE_MODAL_PRESENTATION |
cae50e6b | 390 | dialogs_menu->AppendCheckItem(DIALOGS_MODELESS, _T("Mode&less dialog\tCtrl-Z")); |
a8eb5f88 VZ |
391 | dialogs_menu->Append(DIALOGS_CENTRE_SCREEN, _T("Centered on &screen\tShift-Ctrl-1")); |
392 | dialogs_menu->Append(DIALOGS_CENTRE_PARENT, _T("Centered on &parent\tShift-Ctrl-2")); | |
1baa0a9d | 393 | dialogs_menu->Append(DIALOGS_MINIFRAME, _T("&Mini frame")); |
8e5dbcdd | 394 | dialogs_menu->Append(DIALOGS_ONTOP, _T("Dialog staying on &top")); |
ca7adbf8 | 395 | menuDlg->Append(wxID_ANY, _T("&Generic dialogs"), dialogs_menu); |
13188def | 396 | |
532d575b | 397 | #if USE_SETTINGS_DIALOG |
b40bb73e VZ |
398 | wxMenu *sheet_menu = new wxMenu; |
399 | sheet_menu->Append(DIALOGS_PROPERTY_SHEET, _T("&Standard property sheet\tShift-Ctrl-P")); | |
400 | sheet_menu->Append(DIALOGS_PROPERTY_SHEET_TOOLBOOK, _T("&Toolbook sheet\tShift-Ctrl-T")); | |
e031f1df | 401 | |
5c351979 | 402 | if (wxPlatformIs(wxPORT_MAC)) |
230c9077 JS |
403 | sheet_menu->Append(DIALOGS_PROPERTY_SHEET_BUTTONTOOLBOOK, _T("Button &Toolbook sheet\tShift-Ctrl-U")); |
404 | /* | |
b887dc7b | 405 | #ifdef __WXMAC__ |
64d3ed17 | 406 | sheet_menu->Append(DIALOGS_PROPERTY_SHEET_BUTTONTOOLBOOK, _T("Button &Toolbook sheet\tShift-Ctrl-U")); |
b887dc7b | 407 | #endif |
230c9077 | 408 | */ |
ca7adbf8 | 409 | menuDlg->Append(wxID_ANY, _T("&Property sheets"), sheet_menu); |
b40bb73e | 410 | #endif // USE_SETTINGS_DIALOG |
532d575b | 411 | |
8e1dac82 VZ |
412 | menuDlg->Append(DIALOGS_STANDARD_BUTTON_SIZER_DIALOG, _T("&Standard Buttons Sizer Dialog")); |
413 | ||
ca7adbf8 VZ |
414 | menuDlg->Append(DIALOGS_REQUEST, _T("&Request user attention\tCtrl-R")); |
415 | ||
416 | menuDlg->AppendSeparator(); | |
417 | menuDlg->Append(wxID_EXIT, _T("E&xit\tAlt-X")); | |
9b16ffef | 418 | |
ca7adbf8 VZ |
419 | #if wxUSE_ABOUTDLG |
420 | wxMenu *menuHelp = new wxMenu; | |
453c9e3b VZ |
421 | menuHelp->Append(DIALOGS_ABOUTDLG_SIMPLE, _T("&About (simple)...\tF1")); |
422 | menuHelp->Append(DIALOGS_ABOUTDLG_FANCY, _T("About (&fancy)...\tShift-F1")); | |
423 | menuHelp->Append(DIALOGS_ABOUTDLG_FULL, _T("About (f&ull)...\tCtrl-F1")); | |
424 | menuHelp->Append(DIALOGS_ABOUTDLG_CUSTOM, _T("About (&custom)...\tCtrl-Shift-F1")); | |
ca7adbf8 | 425 | #endif // wxUSE_ABOUTDLG |
13188def | 426 | |
ca7adbf8 VZ |
427 | wxMenuBar *menubar = new wxMenuBar; |
428 | menubar->Append(menuDlg, _T("&Dialogs")); | |
429 | #if wxUSE_ABOUTDLG | |
430 | menubar->Append(menuHelp, _T("&Help")); | |
431 | #endif // wxUSE_ABOUTDLG | |
432 | ||
433 | frame->SetMenuBar(menubar); | |
13188def WS |
434 | |
435 | myCanvas = new MyCanvas(frame); | |
436 | myCanvas->SetBackgroundColour(*wxWHITE); | |
437 | ||
438 | frame->Centre(wxBOTH); | |
439 | ||
440 | // Show the frame | |
441 | frame->Show(true); | |
442 | ||
443 | SetTopWindow(frame); | |
444 | ||
445 | return true; | |
457814b5 JS |
446 | } |
447 | ||
448 | // My frame constructor | |
4c45f240 | 449 | MyFrame::MyFrame(wxWindow *parent, |
13188def WS |
450 | const wxString& title) |
451 | : wxFrame(parent, wxID_ANY, title) | |
4c45f240 | 452 | { |
0f5d8ecf | 453 | SetIcon(sample_xpm); |
532d575b | 454 | |
13188def | 455 | #if USE_MODAL_PRESENTATION |
4c45f240 | 456 | m_dialog = (MyModelessDialog *)NULL; |
13188def | 457 | #endif // USE_MODAL_PRESENTATION |
f1e1ed3b | 458 | |
043dcdaa | 459 | #if wxUSE_FINDREPLDLG |
14fca738 VZ |
460 | m_dlgFind = |
461 | m_dlgReplace = NULL; | |
043dcdaa | 462 | #endif |
dabbc6a5 DS |
463 | |
464 | #if wxUSE_COLOURDLG | |
d33dd9ef VS |
465 | m_clrData.SetChooseFull(true); |
466 | for (int i = 0; i < 16; i++) | |
467 | { | |
8f6eaec9 WS |
468 | m_clrData.SetCustomColour( |
469 | i, | |
470 | wxColour( | |
471 | (unsigned char)(i*16), | |
472 | (unsigned char)(i*16), | |
473 | (unsigned char)(i*16) | |
474 | ) | |
475 | ); | |
d33dd9ef | 476 | } |
13188def | 477 | #endif // wxUSE_COLOURDLG |
f9d0e439 VZ |
478 | |
479 | #if wxUSE_STATUSBAR | |
480 | CreateStatusBar(); | |
481 | #endif // wxUSE_STATUSBAR | |
4c45f240 | 482 | } |
457814b5 | 483 | |
13188def | 484 | #if wxUSE_COLOURDLG |
d355d3fe | 485 | void MyFrame::ChooseColour(wxCommandEvent& WXUNUSED(event) ) |
457814b5 | 486 | { |
d33dd9ef | 487 | m_clrData.SetColour(myCanvas->GetBackgroundColour()); |
d93c719a | 488 | |
d33dd9ef | 489 | wxColourDialog dialog(this, &m_clrData); |
9f84eccd | 490 | dialog.SetTitle(_T("Choose the background colour")); |
afbd36dd | 491 | if (dialog.ShowModal() == wxID_OK) |
f6bcfd97 | 492 | { |
d33dd9ef VS |
493 | m_clrData = dialog.GetColourData(); |
494 | myCanvas->SetBackgroundColour(m_clrData.GetColour()); | |
1d14c005 | 495 | myCanvas->ClearBackground(); |
457814b5 | 496 | myCanvas->Refresh(); |
f6bcfd97 | 497 | } |
457814b5 | 498 | } |
13188def | 499 | #endif // wxUSE_COLOURDLG |
457814b5 | 500 | |
1e72e3cc RN |
501 | #if USE_COLOURDLG_GENERIC |
502 | void MyFrame::ChooseColourGeneric(wxCommandEvent& WXUNUSED(event)) | |
503 | { | |
504 | m_clrData.SetColour(myCanvas->GetBackgroundColour()); | |
505 | ||
506 | //FIXME:TODO:This has no effect... | |
507 | m_clrData.SetChooseFull(true); | |
508 | ||
509 | for (int i = 0; i < 16; i++) | |
510 | { | |
511 | wxColour colour( | |
512 | (unsigned char)(i*16), | |
513 | (unsigned char)(i*16), | |
514 | (unsigned char)(i*16) | |
515 | ); | |
516 | m_clrData.SetCustomColour(i, colour); | |
517 | } | |
518 | ||
519 | wxGenericColourDialog *dialog = new wxGenericColourDialog(this, &m_clrData); | |
520 | if (dialog->ShowModal() == wxID_OK) | |
521 | { | |
522 | m_clrData = dialog->GetColourData(); | |
523 | myCanvas->SetBackgroundColour(m_clrData.GetColour()); | |
524 | myCanvas->ClearBackground(); | |
525 | myCanvas->Refresh(); | |
526 | } | |
527 | dialog->Destroy(); | |
528 | } | |
529 | #endif // USE_COLOURDLG_GENERIC | |
530 | ||
13188def | 531 | #if wxUSE_FONTDLG |
d355d3fe | 532 | void MyFrame::ChooseFont(wxCommandEvent& WXUNUSED(event) ) |
457814b5 | 533 | { |
dbc65e27 VZ |
534 | wxFontData data; |
535 | data.SetInitialFont(wxGetApp().m_canvasFont); | |
536 | data.SetColour(wxGetApp().m_canvasTextColour); | |
d93c719a | 537 | |
dbc65e27 VZ |
538 | // you might also do this: |
539 | // | |
540 | // wxFontDialog dialog; | |
541 | // if ( !dialog.Create(this, data) { ... error ... } | |
542 | // | |
543 | wxFontDialog dialog(this, data); | |
544 | ||
545 | if (dialog.ShowModal() == wxID_OK) | |
546 | { | |
547 | wxFontData retData = dialog.GetFontData(); | |
457814b5 JS |
548 | wxGetApp().m_canvasFont = retData.GetChosenFont(); |
549 | wxGetApp().m_canvasTextColour = retData.GetColour(); | |
550 | myCanvas->Refresh(); | |
dbc65e27 VZ |
551 | } |
552 | //else: cancelled by the user, don't change the font | |
457814b5 | 553 | } |
13188def | 554 | #endif // wxUSE_FONTDLG |
457814b5 | 555 | |
13188def | 556 | #if USE_FONTDLG_GENERIC |
d355d3fe | 557 | void MyFrame::ChooseFontGeneric(wxCommandEvent& WXUNUSED(event) ) |
457814b5 | 558 | { |
13188def WS |
559 | wxFontData data; |
560 | data.SetInitialFont(wxGetApp().m_canvasFont); | |
561 | data.SetColour(wxGetApp().m_canvasTextColour); | |
457814b5 | 562 | |
ca3e85cf | 563 | wxGenericFontDialog *dialog = new wxGenericFontDialog(this, data); |
13188def WS |
564 | if (dialog->ShowModal() == wxID_OK) |
565 | { | |
457814b5 JS |
566 | wxFontData retData = dialog->GetFontData(); |
567 | wxGetApp().m_canvasFont = retData.GetChosenFont(); | |
568 | wxGetApp().m_canvasTextColour = retData.GetColour(); | |
569 | myCanvas->Refresh(); | |
13188def WS |
570 | } |
571 | dialog->Destroy(); | |
457814b5 | 572 | } |
13188def | 573 | #endif // USE_FONTDLG_GENERIC |
d93c719a | 574 | |
b4954d19 | 575 | #if wxUSE_LOG_DIALOG |
87728739 | 576 | void MyFrame::LogDialog(wxCommandEvent& WXUNUSED(event)) |
d93c719a | 577 | { |
2c8e4738 VZ |
578 | // calling wxYield() (as ~wxBusyCursor does) shouldn't result in messages |
579 | // being flushed -- test it | |
580 | { | |
581 | wxBusyCursor bc; | |
4693b20c MB |
582 | wxLogMessage(wxT("This is some message - everything is ok so far.")); |
583 | wxLogMessage(wxT("Another message...\n... this one is on multiple lines")); | |
584 | wxLogWarning(wxT("And then something went wrong!")); | |
9fe52545 VZ |
585 | |
586 | // and if ~wxBusyCursor doesn't do it, then call it manually | |
587 | wxYield(); | |
2c8e4738 VZ |
588 | } |
589 | ||
4693b20c MB |
590 | wxLogError(wxT("Intermediary error handler decided to abort.")); |
591 | wxLogError(wxT("The top level caller detected an unrecoverable error.")); | |
5888ef1e | 592 | |
7923c649 VZ |
593 | wxLog::FlushActive(); |
594 | ||
4693b20c | 595 | wxLogMessage(wxT("And this is the same dialog but with only one message.")); |
d93c719a | 596 | } |
b4954d19 | 597 | #endif // wxUSE_LOG_DIALOG |
457814b5 | 598 | |
d355d3fe | 599 | void MyFrame::MessageBox(wxCommandEvent& WXUNUSED(event) ) |
457814b5 | 600 | { |
2afb9e16 VZ |
601 | wxMessageDialog dialog(NULL, |
602 | _T("This is a message box\nA long, long string to test out the message box properly"), | |
603 | _T("Message box text"), | |
604 | wxNO_DEFAULT | wxYES_NO | wxCANCEL | wxICON_INFORMATION); | |
605 | ||
606 | if ( dialog.SetYesNoLabels(_T("Answer &Yes"),_T("Answer &No")) ) | |
607 | { | |
608 | dialog.SetExtendedMessage(_T("This platform supports custom button labels")); | |
609 | } | |
610 | else | |
611 | { | |
612 | dialog.SetExtendedMessage(_T("Custom button labels are not supported.")); | |
613 | } | |
457814b5 | 614 | |
13188def WS |
615 | switch ( dialog.ShowModal() ) |
616 | { | |
617 | case wxID_YES: | |
618 | wxLogStatus(wxT("You pressed \"Yes\"")); | |
619 | break; | |
49b957be | 620 | |
13188def WS |
621 | case wxID_NO: |
622 | wxLogStatus(wxT("You pressed \"No\"")); | |
623 | break; | |
49b957be | 624 | |
13188def WS |
625 | case wxID_CANCEL: |
626 | wxLogStatus(wxT("You pressed \"Cancel\"")); | |
627 | break; | |
49b957be | 628 | |
13188def WS |
629 | default: |
630 | wxLogError(wxT("Unexpected wxMessageDialog return code!")); | |
631 | } | |
457814b5 JS |
632 | } |
633 | ||
13188def | 634 | #if wxUSE_NUMBERDLG |
c49245f8 VZ |
635 | void MyFrame::NumericEntry(wxCommandEvent& WXUNUSED(event) ) |
636 | { | |
78a189c9 VZ |
637 | long res = wxGetNumberFromUser( _T("This is some text, actually a lot of text.\n") |
638 | _T("Even two rows of text."), | |
639 | _T("Enter a number:"), _T("Numeric input test"), | |
e65cc56a | 640 | 50, 0, 100, this ); |
c49245f8 VZ |
641 | |
642 | wxString msg; | |
643 | int icon; | |
644 | if ( res == -1 ) | |
645 | { | |
78a189c9 | 646 | msg = _T("Invalid number entered or dialog cancelled."); |
c49245f8 VZ |
647 | icon = wxICON_HAND; |
648 | } | |
649 | else | |
d93c719a VZ |
650 | { |
651 | msg.Printf(_T("You've entered %lu"), res ); | |
c49245f8 VZ |
652 | icon = wxICON_INFORMATION; |
653 | } | |
654 | ||
78a189c9 | 655 | wxMessageBox(msg, _T("Numeric test result"), wxOK | icon, this); |
c49245f8 | 656 | } |
13188def | 657 | #endif // wxUSE_NUMBERDLG |
c49245f8 | 658 | |
13188def | 659 | #if wxUSE_TEXTDLG |
a294c6d5 | 660 | void MyFrame::PasswordEntry(wxCommandEvent& WXUNUSED(event)) |
457814b5 | 661 | { |
2f1cd905 | 662 | wxString pwd = wxGetPasswordFromUser(_T("Enter password:"), |
78a189c9 | 663 | _T("Password entry dialog"), |
dabbc6a5 | 664 | wxEmptyString, |
a294c6d5 | 665 | this); |
ecda9475 | 666 | if ( !pwd.empty() ) |
a294c6d5 | 667 | { |
4693b20c | 668 | wxMessageBox(wxString::Format(wxT("Your password is '%s'"), pwd.c_str()), |
78a189c9 | 669 | _T("Got password"), wxOK | wxICON_INFORMATION, this); |
a294c6d5 VZ |
670 | } |
671 | } | |
672 | ||
673 | void MyFrame::TextEntry(wxCommandEvent& WXUNUSED(event)) | |
674 | { | |
13188def WS |
675 | wxTextEntryDialog dialog(this, |
676 | _T("This is a small sample\n") | |
677 | _T("A long, long string to test out the text entrybox"), | |
678 | _T("Please enter a string"), | |
679 | _T("Default value"), | |
680 | wxOK | wxCANCEL); | |
457814b5 | 681 | |
13188def WS |
682 | if (dialog.ShowModal() == wxID_OK) |
683 | { | |
b4954d19 | 684 | wxMessageBox(dialog.GetValue(), _T("Got string"), wxOK | wxICON_INFORMATION, this); |
13188def | 685 | } |
457814b5 | 686 | } |
13188def | 687 | #endif // wxUSE_TEXTDLG |
457814b5 | 688 | |
13188def | 689 | #if wxUSE_CHOICEDLG |
d355d3fe | 690 | void MyFrame::SingleChoice(wxCommandEvent& WXUNUSED(event) ) |
457814b5 | 691 | { |
78a189c9 | 692 | const wxString choices[] = { _T("One"), _T("Two"), _T("Three"), _T("Four"), _T("Five") } ; |
457814b5 | 693 | |
5f95bb70 | 694 | wxSingleChoiceDialog dialog(this, |
78a189c9 VZ |
695 | _T("This is a small sample\n") |
696 | _T("A single-choice convenience dialog"), | |
697 | _T("Please select a value"), | |
5f95bb70 | 698 | WXSIZEOF(choices), choices); |
457814b5 | 699 | |
ef77f91e JS |
700 | dialog.SetSelection(2); |
701 | ||
702 | if (dialog.ShowModal() == wxID_OK) | |
703 | { | |
78a189c9 | 704 | wxMessageDialog dialog2(this, dialog.GetStringSelection(), _T("Got string")); |
ef77f91e JS |
705 | dialog2.ShowModal(); |
706 | } | |
457814b5 JS |
707 | } |
708 | ||
d6c9c1b7 VZ |
709 | void MyFrame::MultiChoice(wxCommandEvent& WXUNUSED(event) ) |
710 | { | |
5f95bb70 VZ |
711 | const wxString choices[] = |
712 | { | |
78a189c9 VZ |
713 | _T("One"), _T("Two"), _T("Three"), _T("Four"), _T("Five"), |
714 | _T("Six"), _T("Seven"), _T("Eight"), _T("Nine"), _T("Ten"), | |
715 | _T("Eleven"), _T("Twelve"), _T("Seventeen"), | |
5f95bb70 | 716 | }; |
d6c9c1b7 VZ |
717 | |
718 | wxArrayInt selections; | |
719 | size_t count = wxGetMultipleChoices(selections, | |
78a189c9 VZ |
720 | _T("This is a small sample\n") |
721 | _T("A multi-choice convenience dialog"), | |
722 | _T("Please select a value"), | |
5f95bb70 | 723 | WXSIZEOF(choices), choices, |
d6c9c1b7 VZ |
724 | this); |
725 | if ( count ) | |
726 | { | |
3d49ce44 | 727 | wxString msg; |
fba1b53b | 728 | msg.Printf(wxT("You selected %u items:\n"), (unsigned)count); |
d6c9c1b7 VZ |
729 | for ( size_t n = 0; n < count; n++ ) |
730 | { | |
fba1b53b VZ |
731 | msg += wxString::Format(wxT("\t%u: %u (%s)\n"), |
732 | (unsigned)n, (unsigned)selections[n], | |
3d49ce44 | 733 | choices[selections[n]].c_str()); |
d6c9c1b7 | 734 | } |
3d49ce44 | 735 | wxLogMessage(msg); |
d6c9c1b7 VZ |
736 | } |
737 | //else: cancelled or nothing selected | |
738 | } | |
13188def | 739 | #endif // wxUSE_CHOICEDLG |
d6c9c1b7 | 740 | |
13188def | 741 | #if wxUSE_FILEDLG |
d355d3fe | 742 | void MyFrame::FileOpen(wxCommandEvent& WXUNUSED(event) ) |
457814b5 | 743 | { |
fbf4eacb VZ |
744 | wxFileDialog dialog |
745 | ( | |
746 | this, | |
747 | _T("Testing open file dialog"), | |
dabbc6a5 DS |
748 | wxEmptyString, |
749 | wxEmptyString, | |
a4e64fb5 MB |
750 | #ifdef __WXMOTIF__ |
751 | _T("C++ files (*.cpp)|*.cpp") | |
752 | #else | |
daf32463 | 753 | _T("C++ files (*.cpp;*.h)|*.cpp;*.h") |
a4e64fb5 | 754 | #endif |
fbf4eacb | 755 | ); |
457814b5 | 756 | |
3b6c3fc8 | 757 | dialog.CentreOnParent(); |
cd7afaff | 758 | dialog.SetDirectory(wxGetHomeDir()); |
5b636c67 | 759 | |
c50f1fb9 VZ |
760 | if (dialog.ShowModal() == wxID_OK) |
761 | { | |
5919d76b | 762 | wxString info; |
13393ab6 RR |
763 | info.Printf(_T("Full file name: %s\n") |
764 | _T("Path: %s\n") | |
765 | _T("Name: %s"), | |
5919d76b VZ |
766 | dialog.GetPath().c_str(), |
767 | dialog.GetDirectory().c_str(), | |
768 | dialog.GetFilename().c_str()); | |
78a189c9 | 769 | wxMessageDialog dialog2(this, info, _T("Selected file")); |
c50f1fb9 VZ |
770 | dialog2.ShowModal(); |
771 | } | |
457814b5 JS |
772 | } |
773 | ||
35b45b33 VZ |
774 | // this shows how to take advantage of specifying a default extension in the |
775 | // call to wxFileSelector: it is remembered after each new call and the next | |
776 | // one will use it by default | |
777 | void MyFrame::FileOpen2(wxCommandEvent& WXUNUSED(event) ) | |
778 | { | |
779 | static wxString s_extDef; | |
780 | wxString path = wxFileSelector( | |
781 | _T("Select the file to load"), | |
dabbc6a5 | 782 | wxEmptyString, wxEmptyString, |
35b45b33 | 783 | s_extDef, |
3601f639 VZ |
784 | wxString::Format |
785 | ( | |
786 | _T("Waveform (*.wav)|*.wav|Plain text (*.txt)|*.txt|All files (%s)|%s"), | |
787 | wxFileSelectorDefaultWildcardStr, | |
788 | wxFileSelectorDefaultWildcardStr | |
789 | ), | |
9f057af5 | 790 | wxFD_OPEN|wxFD_CHANGE_DIR|wxFD_PREVIEW, |
35b45b33 VZ |
791 | this |
792 | ); | |
793 | ||
794 | if ( !path ) | |
795 | return; | |
796 | ||
797 | // it is just a sample, would use wxSplitPath in real program | |
798 | s_extDef = path.AfterLast(_T('.')); | |
799 | ||
800 | wxLogMessage(_T("You selected the file '%s', remembered extension '%s'"), | |
a342cb00 | 801 | path, s_extDef); |
35b45b33 VZ |
802 | } |
803 | ||
c61f4f6d VZ |
804 | void MyFrame::FilesOpen(wxCommandEvent& WXUNUSED(event) ) |
805 | { | |
dabbc6a5 | 806 | wxString wildcards = |
f0f43012 JS |
807 | #ifdef __WXMOTIF__ |
808 | _T("C++ files (*.cpp)|*.cpp"); | |
809 | #else | |
3601f639 VZ |
810 | wxString::Format |
811 | ( | |
812 | _T("All files (%s)|%s|C++ files (*.cpp;*.h)|*.cpp;*.h"), | |
813 | wxFileSelectorDefaultWildcardStr, | |
814 | wxFileSelectorDefaultWildcardStr | |
815 | ); | |
f0f43012 | 816 | #endif |
78a189c9 | 817 | wxFileDialog dialog(this, _T("Testing open multiple file dialog"), |
dabbc6a5 | 818 | wxEmptyString, wxEmptyString, wildcards, |
ff3e84ff | 819 | wxFD_OPEN|wxFD_MULTIPLE); |
c61f4f6d VZ |
820 | |
821 | if (dialog.ShowModal() == wxID_OK) | |
822 | { | |
823 | wxArrayString paths, filenames; | |
824 | ||
825 | dialog.GetPaths(paths); | |
826 | dialog.GetFilenames(filenames); | |
827 | ||
828 | wxString msg, s; | |
829 | size_t count = paths.GetCount(); | |
830 | for ( size_t n = 0; n < count; n++ ) | |
831 | { | |
832 | s.Printf(_T("File %d: %s (%s)\n"), | |
fba1b53b | 833 | (int)n, paths[n].c_str(), filenames[n].c_str()); |
c61f4f6d VZ |
834 | |
835 | msg += s; | |
836 | } | |
f0f43012 JS |
837 | s.Printf(_T("Filter index: %d"), dialog.GetFilterIndex()); |
838 | msg += s; | |
c61f4f6d | 839 | |
78a189c9 | 840 | wxMessageDialog dialog2(this, msg, _T("Selected files")); |
c61f4f6d VZ |
841 | dialog2.ShowModal(); |
842 | } | |
843 | } | |
844 | ||
d355d3fe | 845 | void MyFrame::FileSave(wxCommandEvent& WXUNUSED(event) ) |
457814b5 | 846 | { |
2f1cd905 VZ |
847 | wxFileDialog dialog(this, |
848 | _T("Testing save file dialog"), | |
dabbc6a5 | 849 | wxEmptyString, |
2b5f62a0 | 850 | _T("myletter.doc"), |
3de9120b | 851 | _T("Text files (*.txt)|*.txt|Document files (*.doc;*.ods)|*.doc;*.ods"), |
ff3e84ff | 852 | wxFD_SAVE|wxFD_OVERWRITE_PROMPT); |
c50f1fb9 | 853 | |
2b5f62a0 VZ |
854 | dialog.SetFilterIndex(1); |
855 | ||
c50f1fb9 VZ |
856 | if (dialog.ShowModal() == wxID_OK) |
857 | { | |
2b5f62a0 VZ |
858 | wxLogMessage(_T("%s, filter %d"), |
859 | dialog.GetPath().c_str(), dialog.GetFilterIndex()); | |
c50f1fb9 | 860 | } |
457814b5 | 861 | } |
13188def | 862 | #endif // wxUSE_FILEDLG |
457814b5 | 863 | |
695fe764 WS |
864 | #if USE_FILEDLG_GENERIC |
865 | void MyFrame::FileOpenGeneric(wxCommandEvent& WXUNUSED(event) ) | |
866 | { | |
867 | wxGenericFileDialog dialog | |
868 | ( | |
869 | this, | |
870 | _T("Testing open file dialog"), | |
871 | wxEmptyString, | |
872 | wxEmptyString, | |
daf32463 | 873 | _T("C++ files (*.cpp;*.h)|*.cpp;*.h") |
695fe764 WS |
874 | ); |
875 | ||
876 | dialog.SetDirectory(wxGetHomeDir()); | |
877 | ||
878 | if (dialog.ShowModal() == wxID_OK) | |
879 | { | |
880 | wxString info; | |
881 | info.Printf(_T("Full file name: %s\n") | |
882 | _T("Path: %s\n") | |
883 | _T("Name: %s"), | |
884 | dialog.GetPath().c_str(), | |
885 | dialog.GetDirectory().c_str(), | |
886 | dialog.GetFilename().c_str()); | |
887 | wxMessageDialog dialog2(this, info, _T("Selected file")); | |
888 | dialog2.ShowModal(); | |
889 | } | |
890 | } | |
891 | ||
892 | void MyFrame::FilesOpenGeneric(wxCommandEvent& WXUNUSED(event) ) | |
893 | { | |
684883e3 WS |
894 | // On PocketPC you can disable OK-only dialogs policy using system option |
895 | int buttons = wxSystemOptions::GetOptionInt(wxT("wince.dialog.real-ok-cancel")); | |
896 | wxSystemOptions::SetOption(wxT("wince.dialog.real-ok-cancel"), 1); | |
897 | ||
daf32463 | 898 | wxString wildcards = _T("All files (*.*)|*.*|C++ files (*.cpp;*.h)|*.cpp;*.h"); |
695fe764 WS |
899 | wxGenericFileDialog dialog(this, _T("Testing open multiple file dialog"), |
900 | wxEmptyString, wxEmptyString, wildcards, | |
e031f1df | 901 | wxFD_MULTIPLE); |
695fe764 WS |
902 | |
903 | if (dialog.ShowModal() == wxID_OK) | |
904 | { | |
905 | wxArrayString paths, filenames; | |
906 | ||
907 | dialog.GetPaths(paths); | |
908 | dialog.GetFilenames(filenames); | |
909 | ||
910 | wxString msg, s; | |
911 | size_t count = paths.GetCount(); | |
912 | for ( size_t n = 0; n < count; n++ ) | |
913 | { | |
914 | s.Printf(_T("File %d: %s (%s)\n"), | |
915 | (int)n, paths[n].c_str(), filenames[n].c_str()); | |
916 | ||
917 | msg += s; | |
918 | } | |
919 | s.Printf(_T("Filter index: %d"), dialog.GetFilterIndex()); | |
920 | msg += s; | |
921 | ||
922 | wxMessageDialog dialog2(this, msg, _T("Selected files")); | |
923 | dialog2.ShowModal(); | |
924 | } | |
684883e3 WS |
925 | |
926 | // restore system option | |
927 | wxSystemOptions::SetOption(wxT("wince.dialog.real-ok-cancel"), buttons); | |
695fe764 WS |
928 | } |
929 | ||
930 | void MyFrame::FileSaveGeneric(wxCommandEvent& WXUNUSED(event) ) | |
931 | { | |
932 | wxGenericFileDialog dialog(this, | |
933 | _T("Testing save file dialog"), | |
934 | wxEmptyString, | |
935 | _T("myletter.doc"), | |
3de9120b | 936 | _T("Text files (*.txt)|*.txt|Document files (*.doc;*.ods)|*.doc;*.ods"), |
e031f1df | 937 | wxFD_SAVE|wxFD_OVERWRITE_PROMPT); |
695fe764 WS |
938 | |
939 | dialog.SetFilterIndex(1); | |
940 | ||
941 | if (dialog.ShowModal() == wxID_OK) | |
942 | { | |
943 | wxLogMessage(_T("%s, filter %d"), | |
944 | dialog.GetPath().c_str(), dialog.GetFilterIndex()); | |
945 | } | |
946 | } | |
947 | #endif // USE_FILEDLG_GENERIC | |
948 | ||
13188def | 949 | #if wxUSE_DIRDLG |
f09c8393 | 950 | void MyFrame::DoDirChoose(int style) |
457814b5 | 951 | { |
3f2711d5 VZ |
952 | // pass some initial dir to wxDirDialog |
953 | wxString dirHome; | |
954 | wxGetHomeDir(&dirHome); | |
955 | ||
f09c8393 | 956 | wxDirDialog dialog(this, _T("Testing directory picker"), dirHome, style); |
c50f1fb9 VZ |
957 | |
958 | if (dialog.ShowModal() == wxID_OK) | |
959 | { | |
2b5f62a0 | 960 | wxLogMessage(_T("Selected path: %s"), dialog.GetPath().c_str()); |
c50f1fb9 VZ |
961 | } |
962 | } | |
963 | ||
f09c8393 VZ |
964 | void MyFrame::DirChoose(wxCommandEvent& WXUNUSED(event) ) |
965 | { | |
ff3e84ff | 966 | DoDirChoose(wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST); |
f09c8393 VZ |
967 | } |
968 | ||
969 | void MyFrame::DirChooseNew(wxCommandEvent& WXUNUSED(event) ) | |
970 | { | |
ff3e84ff | 971 | DoDirChoose(wxDD_DEFAULT_STYLE & ~wxDD_DIR_MUST_EXIST); |
f09c8393 | 972 | } |
13188def | 973 | #endif // wxUSE_DIRDLG |
f09c8393 | 974 | |
13188def | 975 | #if USE_DIRDLG_GENERIC |
51a58d8b JS |
976 | void MyFrame::GenericDirChoose(wxCommandEvent& WXUNUSED(event) ) |
977 | { | |
978 | // pass some initial dir to wxDirDialog | |
979 | wxString dirHome; | |
980 | wxGetHomeDir(&dirHome); | |
981 | ||
78a189c9 | 982 | wxGenericDirDialog dialog(this, _T("Testing generic directory picker"), dirHome); |
51a58d8b JS |
983 | |
984 | if (dialog.ShowModal() == wxID_OK) | |
985 | { | |
78a189c9 | 986 | wxMessageDialog dialog2(this, dialog.GetPath(), _T("Selected path")); |
51a58d8b JS |
987 | dialog2.ShowModal(); |
988 | } | |
989 | } | |
13188def | 990 | #endif // USE_DIRDLG_GENERIC |
51a58d8b | 991 | |
13188def | 992 | #if USE_MODAL_PRESENTATION |
f6bcfd97 BP |
993 | void MyFrame::ModalDlg(wxCommandEvent& WXUNUSED(event)) |
994 | { | |
995 | MyModalDialog dlg(this); | |
996 | dlg.ShowModal(); | |
997 | } | |
1baa0a9d | 998 | #endif // USE_MODAL_PRESENTATION |
f6bcfd97 | 999 | |
4c45f240 VZ |
1000 | void MyFrame::ModelessDlg(wxCommandEvent& event) |
1001 | { | |
2f82899b | 1002 | bool show = GetMenuBar()->IsChecked(event.GetId()); |
4c45f240 VZ |
1003 | |
1004 | if ( show ) | |
1005 | { | |
1006 | if ( !m_dialog ) | |
1007 | { | |
1008 | m_dialog = new MyModelessDialog(this); | |
1009 | } | |
1010 | ||
13188def | 1011 | m_dialog->Show(true); |
4c45f240 VZ |
1012 | } |
1013 | else // hide | |
1014 | { | |
26a12ab3 JS |
1015 | // If m_dialog is NULL, then possibly the system |
1016 | // didn't report the checked menu item status correctly. | |
1017 | // It should be true just after the menu item was selected, | |
1018 | // if there was no modeless dialog yet. | |
1019 | ||
1020 | wxASSERT( m_dialog != NULL ); | |
1021 | if (m_dialog) | |
1022 | m_dialog->Hide(); | |
4c45f240 VZ |
1023 | } |
1024 | } | |
cae50e6b VZ |
1025 | |
1026 | void MyFrame::DlgCenteredScreen(wxCommandEvent& WXUNUSED(event)) | |
1027 | { | |
1028 | wxDialog dlg(this, wxID_ANY, _T("Dialog centered on screen"), | |
1029 | wxDefaultPosition, wxSize(200, 100)); | |
cd7afaff | 1030 | (new wxButton(&dlg, wxID_OK, _T("Close")))->Centre(); |
cae50e6b VZ |
1031 | dlg.CentreOnScreen(); |
1032 | dlg.ShowModal(); | |
1033 | } | |
1034 | ||
1035 | void MyFrame::DlgCenteredParent(wxCommandEvent& WXUNUSED(event)) | |
1036 | { | |
1037 | wxDialog dlg(this, wxID_ANY, _T("Dialog centered on parent"), | |
1038 | wxDefaultPosition, wxSize(200, 100)); | |
cd7afaff | 1039 | (new wxButton(&dlg, wxID_OK, _T("Close")))->Centre(); |
cae50e6b VZ |
1040 | dlg.CentreOnParent(); |
1041 | dlg.ShowModal(); | |
1042 | } | |
1043 | ||
1baa0a9d VZ |
1044 | void MyFrame::MiniFrame(wxCommandEvent& WXUNUSED(event)) |
1045 | { | |
1046 | wxFrame *frame = new wxMiniFrame(this, wxID_ANY, _T("Mini frame"), | |
1047 | wxDefaultPosition, wxSize(300, 100), | |
1048 | wxCAPTION | wxCLOSE_BOX); | |
1049 | new wxStaticText(frame, | |
1050 | wxID_ANY, | |
1051 | _T("Mini frames have slightly different appearance"), | |
1052 | wxPoint(5, 5)); | |
1053 | new wxStaticText(frame, | |
1054 | wxID_ANY, | |
1055 | _T("from the normal frames but that's the only difference."), | |
1056 | wxPoint(5, 25)); | |
1057 | ||
1058 | frame->CentreOnParent(); | |
1059 | frame->Show(); | |
1060 | } | |
4c45f240 | 1061 | |
8e5dbcdd VZ |
1062 | void MyFrame::DlgOnTop(wxCommandEvent& WXUNUSED(event)) |
1063 | { | |
1064 | wxDialog dlg(this, wxID_ANY, _T("Dialog staying on top of other windows"), | |
1065 | wxDefaultPosition, wxSize(300, 100), | |
1066 | wxDEFAULT_DIALOG_STYLE | wxSTAY_ON_TOP); | |
1067 | (new wxButton(&dlg, wxID_OK, _T("Close")))->Centre(); | |
1068 | dlg.ShowModal(); | |
1069 | } | |
1070 | ||
13188def | 1071 | #if wxUSE_STARTUP_TIPS |
87728739 | 1072 | void MyFrame::ShowTip(wxCommandEvent& WXUNUSED(event)) |
c50f1fb9 VZ |
1073 | { |
1074 | static size_t s_index = (size_t)-1; | |
1075 | ||
1076 | if ( s_index == (size_t)-1 ) | |
1077 | { | |
1078 | srand(time(NULL)); | |
1079 | ||
1080 | // this is completely bogus, we don't know how many lines are there | |
1081 | // in the file, but who cares, it's a demo only... | |
1082 | s_index = rand() % 5; | |
1083 | } | |
1084 | ||
2f1cd905 | 1085 | wxTipProvider *tipProvider = wxCreateFileTipProvider(_T("tips.txt"), s_index); |
c50f1fb9 VZ |
1086 | |
1087 | bool showAtStartup = wxShowTip(this, tipProvider); | |
1088 | ||
1089 | if ( showAtStartup ) | |
1090 | { | |
2f1cd905 | 1091 | wxMessageBox(_T("Will show tips on startup"), _T("Tips dialog"), |
c50f1fb9 VZ |
1092 | wxOK | wxICON_INFORMATION, this); |
1093 | } | |
457814b5 | 1094 | |
c50f1fb9 VZ |
1095 | s_index = tipProvider->GetCurrentTip(); |
1096 | delete tipProvider; | |
457814b5 | 1097 | } |
13188def | 1098 | #endif // wxUSE_STARTUP_TIPS |
457814b5 | 1099 | |
532d575b | 1100 | #if USE_SETTINGS_DIALOG |
64d3ed17 | 1101 | void MyFrame::OnPropertySheet(wxCommandEvent& event) |
0f5d8ecf | 1102 | { |
64d3ed17 | 1103 | SettingsDialog dialog(this, event.GetId()); |
cc8bc5aa JS |
1104 | dialog.ShowModal(); |
1105 | } | |
532d575b | 1106 | #endif // USE_SETTINGS_DIALOG |
0f5d8ecf | 1107 | |
9b16ffef VZ |
1108 | void MyFrame::OnRequestUserAttention(wxCommandEvent& WXUNUSED(event)) |
1109 | { | |
1110 | wxLogStatus(_T("Sleeping for 3 seconds to allow you to switch to another window")); | |
1111 | ||
1112 | wxSleep(3); | |
1113 | ||
1114 | RequestUserAttention(wxUSER_ATTENTION_ERROR); | |
1115 | } | |
1116 | ||
8e1dac82 VZ |
1117 | void MyFrame::OnStandardButtonsSizerDialog(wxCommandEvent& WXUNUSED(event)) |
1118 | { | |
1119 | StdButtonSizerDialog dialog(this); | |
1120 | dialog.ShowModal(); | |
1121 | } | |
1122 | ||
d355d3fe | 1123 | void MyFrame::OnExit(wxCommandEvent& WXUNUSED(event) ) |
457814b5 | 1124 | { |
13188def | 1125 | Close(true); |
457814b5 JS |
1126 | } |
1127 | ||
abceee76 VZ |
1128 | #if wxUSE_PROGRESSDLG |
1129 | ||
1130 | void MyFrame::ShowProgress( wxCommandEvent& WXUNUSED(event) ) | |
1131 | { | |
b2c782f2 | 1132 | static const int max = 100; |
abceee76 | 1133 | |
2f1cd905 | 1134 | wxProgressDialog dialog(_T("Progress dialog example"), |
78a189c9 | 1135 | _T("An informative message"), |
abceee76 VZ |
1136 | max, // range |
1137 | this, // parent | |
1138 | wxPD_CAN_ABORT | | |
ecda9475 | 1139 | wxPD_CAN_SKIP | |
abceee76 | 1140 | wxPD_APP_MODAL | |
df26c4c6 | 1141 | // wxPD_AUTO_HIDE | -- try this as well |
abceee76 VZ |
1142 | wxPD_ELAPSED_TIME | |
1143 | wxPD_ESTIMATED_TIME | | |
f4aa7ec3 | 1144 | wxPD_REMAINING_TIME |
b2c782f2 | 1145 | | wxPD_SMOOTH // - makes indeterminate mode bar on WinXP very small |
f4aa7ec3 | 1146 | ); |
abceee76 | 1147 | |
13188def | 1148 | bool cont = true; |
b2c782f2 | 1149 | for ( int i = 0; i <= max; i++ ) |
abceee76 | 1150 | { |
b2c782f2 | 1151 | wxMilliSleep(200); |
ecda9475 WS |
1152 | |
1153 | wxString msg; | |
1154 | ||
b2c782f2 VZ |
1155 | // test both modes of wxProgressDialog behaviour: start in |
1156 | // indeterminate mode but switch to the determinate one later | |
1157 | const bool determinate = i > max/2; | |
f4aa7ec3 | 1158 | |
abceee76 VZ |
1159 | if ( i == max ) |
1160 | { | |
ecda9475 | 1161 | msg = _T("That's all, folks!"); |
abceee76 | 1162 | } |
b2c782f2 | 1163 | else if ( !determinate ) |
f4aa7ec3 | 1164 | { |
b2c782f2 | 1165 | msg = _T("Testing indeterminate mode"); |
f4aa7ec3 | 1166 | } |
b2c782f2 | 1167 | else if ( determinate ) |
abceee76 | 1168 | { |
b2c782f2 | 1169 | msg = _T("Now in standard determinate mode"); |
abceee76 | 1170 | } |
ecda9475 | 1171 | |
b2c782f2 VZ |
1172 | // will be set to true if "Skip" button was pressed |
1173 | bool skip = false; | |
1174 | if ( determinate ) | |
abceee76 | 1175 | { |
ecda9475 | 1176 | cont = dialog.Update(i, msg, &skip); |
abceee76 | 1177 | } |
f4aa7ec3 VZ |
1178 | else |
1179 | { | |
f4aa7ec3 | 1180 | cont = dialog.Pulse(msg, &skip); |
f4aa7ec3 | 1181 | } |
ecda9475 | 1182 | |
b2c782f2 VZ |
1183 | // each skip will move progress about quarter forward |
1184 | if ( skip ) | |
1185 | i += max/4; | |
1186 | ||
d8ddee9c VZ |
1187 | if ( !cont ) |
1188 | { | |
78a189c9 VZ |
1189 | if ( wxMessageBox(_T("Do you really want to cancel?"), |
1190 | _T("Progress dialog question"), // caption | |
1191 | wxYES_NO | wxICON_QUESTION) == wxYES ) | |
d8ddee9c VZ |
1192 | break; |
1193 | ||
9b16ffef | 1194 | cont = true; |
d8ddee9c VZ |
1195 | dialog.Resume(); |
1196 | } | |
abceee76 VZ |
1197 | } |
1198 | ||
1199 | if ( !cont ) | |
1200 | { | |
4693b20c | 1201 | wxLogStatus(wxT("Progress dialog aborted!")); |
abceee76 VZ |
1202 | } |
1203 | else | |
1204 | { | |
4693b20c | 1205 | wxLogStatus(wxT("Countdown from %d finished"), max); |
abceee76 VZ |
1206 | } |
1207 | } | |
1208 | ||
1209 | #endif // wxUSE_PROGRESSDLG | |
1210 | ||
ca7adbf8 VZ |
1211 | #if wxUSE_ABOUTDLG |
1212 | ||
453c9e3b | 1213 | static void InitAboutInfoMinimal(wxAboutDialogInfo& info) |
ca7adbf8 VZ |
1214 | { |
1215 | info.SetName(_T("Dialogs Sample")); | |
1a1ecce6 | 1216 | info.SetVersion(wxVERSION_NUM_DOT_STRING_T); |
ca7adbf8 | 1217 | info.SetDescription(_T("This sample shows different wxWidgets dialogs")); |
730654ee | 1218 | info.SetCopyright(_T("(C) 1998-2006 wxWidgets dev team")); |
50671311 | 1219 | info.AddDeveloper(_T("Vadim Zeitlin")); |
ca7adbf8 VZ |
1220 | } |
1221 | ||
453c9e3b VZ |
1222 | static void InitAboutInfoWebsite(wxAboutDialogInfo& info) |
1223 | { | |
1224 | InitAboutInfoMinimal(info); | |
1225 | ||
1226 | info.SetWebSite(_T("http://www.wxwidgets.org/"), _T("wxWidgets web site")); | |
1227 | } | |
1228 | ||
1229 | static void InitAboutInfoAll(wxAboutDialogInfo& info) | |
1230 | { | |
1231 | InitAboutInfoMinimal(info); | |
1232 | ||
1233 | // we can add a second developer | |
1234 | info.AddDeveloper(_T("A.N. Other")); | |
1235 | ||
1236 | // or we can add several persons at once like this | |
1237 | static const wxChar *docwriters[] = | |
1238 | { | |
1239 | _T("First D. Writer"), | |
1240 | _T("Second One"), | |
1241 | }; | |
1242 | ||
1243 | info.SetDocWriters(wxArrayString(WXSIZEOF(docwriters), docwriters)); | |
1244 | info.SetLicence(wxString::FromAscii( | |
1245 | " wxWindows Library Licence, Version 3.1\n" | |
1246 | " ======================================\n" | |
1247 | "\n" | |
1248 | " Copyright (c) 1998-2005 Julian Smart, Robert Roebling et al\n" | |
1249 | "\n" | |
1250 | " Everyone is permitted to copy and distribute verbatim copies\n" | |
1251 | " of this licence document, but changing it is not allowed.\n" | |
1252 | "\n" | |
1253 | " WXWINDOWS LIBRARY LICENCE\n" | |
1254 | " TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION\n" | |
1255 | "\n" | |
1256 | " ...and so on and so forth...\n" | |
1257 | )); | |
fb4f85bf VZ |
1258 | |
1259 | info.AddTranslator(_T("Wun Ngo Wen (Martian)")); | |
453c9e3b VZ |
1260 | } |
1261 | ||
ca7adbf8 VZ |
1262 | void MyFrame::ShowSimpleAboutDialog(wxCommandEvent& WXUNUSED(event)) |
1263 | { | |
1264 | wxAboutDialogInfo info; | |
453c9e3b | 1265 | InitAboutInfoMinimal(info); |
ca7adbf8 VZ |
1266 | |
1267 | wxAboutBox(info); | |
1268 | } | |
1269 | ||
1270 | void MyFrame::ShowFancyAboutDialog(wxCommandEvent& WXUNUSED(event)) | |
1271 | { | |
1272 | wxAboutDialogInfo info; | |
453c9e3b | 1273 | InitAboutInfoWebsite(info); |
ca7adbf8 VZ |
1274 | |
1275 | wxAboutBox(info); | |
1276 | } | |
1277 | ||
453c9e3b VZ |
1278 | void MyFrame::ShowFullAboutDialog(wxCommandEvent& WXUNUSED(event)) |
1279 | { | |
1280 | wxAboutDialogInfo info; | |
1281 | InitAboutInfoAll(info); | |
1282 | ||
1283 | wxAboutBox(info); | |
1284 | } | |
1285 | ||
1dcfc333 VZ |
1286 | // a trivial example of a custom dialog class |
1287 | class MyAboutDialog : public wxGenericAboutDialog | |
453c9e3b | 1288 | { |
1dcfc333 VZ |
1289 | public: |
1290 | MyAboutDialog(const wxAboutDialogInfo& info) | |
453c9e3b | 1291 | { |
1dcfc333 VZ |
1292 | Create(info); |
1293 | } | |
453c9e3b | 1294 | |
1dcfc333 VZ |
1295 | // add some custom controls |
1296 | virtual void DoAddCustomControls() | |
1297 | { | |
1298 | AddControl(new wxStaticLine(this), wxSizerFlags().Expand()); | |
1299 | AddText(_T("Some custom text")); | |
1300 | AddControl(new wxStaticLine(this), wxSizerFlags().Expand()); | |
1301 | } | |
1302 | }; | |
453c9e3b | 1303 | |
1dcfc333 VZ |
1304 | void MyFrame::ShowCustomAboutDialog(wxCommandEvent& WXUNUSED(event)) |
1305 | { | |
453c9e3b VZ |
1306 | wxAboutDialogInfo info; |
1307 | InitAboutInfoAll(info); | |
1308 | ||
1309 | MyAboutDialog dlg(info); | |
1310 | dlg.ShowModal(); | |
1311 | } | |
1312 | ||
ca7adbf8 VZ |
1313 | #endif // wxUSE_ABOUTDLG |
1314 | ||
a62b0bcc VZ |
1315 | #if wxUSE_BUSYINFO |
1316 | ||
1317 | void MyFrame::ShowBusyInfo(wxCommandEvent& WXUNUSED(event)) | |
1318 | { | |
21977bac VZ |
1319 | wxWindowDisabler disableAll; |
1320 | ||
9f84eccd | 1321 | wxBusyInfo info(_T("Working, please wait..."), this); |
a62b0bcc | 1322 | |
5b636c67 | 1323 | for ( int i = 0; i < 18; i++ ) |
a62b0bcc | 1324 | { |
5b636c67 | 1325 | //wxUsleep(100); |
a62b0bcc VZ |
1326 | wxTheApp->Yield(); |
1327 | } | |
5b636c67 VZ |
1328 | |
1329 | wxSleep(2); | |
1330 | //wxWakeUpIdle(); | |
a62b0bcc VZ |
1331 | } |
1332 | ||
1333 | #endif // wxUSE_BUSYINFO | |
1334 | ||
761989ff VZ |
1335 | #if wxUSE_FINDREPLDLG |
1336 | ||
1337 | void MyFrame::ShowReplaceDialog( wxCommandEvent& WXUNUSED(event) ) | |
1338 | { | |
14fca738 VZ |
1339 | if ( m_dlgReplace ) |
1340 | { | |
1341 | delete m_dlgReplace; | |
1342 | m_dlgReplace = NULL; | |
1343 | } | |
1344 | else | |
1345 | { | |
1346 | m_dlgReplace = new wxFindReplaceDialog | |
1347 | ( | |
1348 | this, | |
1349 | &m_findData, | |
78a189c9 | 1350 | _T("Find and replace dialog"), |
14fca738 VZ |
1351 | wxFR_REPLACEDIALOG |
1352 | ); | |
1353 | ||
13188def | 1354 | m_dlgReplace->Show(true); |
14fca738 | 1355 | } |
761989ff VZ |
1356 | } |
1357 | ||
1358 | void MyFrame::ShowFindDialog( wxCommandEvent& WXUNUSED(event) ) | |
1359 | { | |
14fca738 VZ |
1360 | if ( m_dlgFind ) |
1361 | { | |
1362 | delete m_dlgFind; | |
1363 | m_dlgFind = NULL; | |
1364 | } | |
1365 | else | |
1366 | { | |
1367 | m_dlgFind = new wxFindReplaceDialog | |
1368 | ( | |
1369 | this, | |
1370 | &m_findData, | |
78a189c9 | 1371 | _T("Find dialog"), |
14fca738 VZ |
1372 | // just for testing |
1373 | wxFR_NOWHOLEWORD | |
1374 | ); | |
1375 | ||
13188def | 1376 | m_dlgFind->Show(true); |
14fca738 | 1377 | } |
761989ff VZ |
1378 | } |
1379 | ||
1380 | static wxString DecodeFindDialogEventFlags(int flags) | |
1381 | { | |
1382 | wxString str; | |
78a189c9 | 1383 | str << (flags & wxFR_DOWN ? _T("down") : _T("up")) << _T(", ") |
2f1cd905 VZ |
1384 | << (flags & wxFR_WHOLEWORD ? _T("whole words only, ") : _T("")) |
1385 | << (flags & wxFR_MATCHCASE ? _T("") : _T("not ")) | |
78a189c9 | 1386 | << _T("case sensitive"); |
761989ff VZ |
1387 | |
1388 | return str; | |
1389 | } | |
1390 | ||
1391 | void MyFrame::OnFindDialog(wxFindDialogEvent& event) | |
1392 | { | |
1393 | wxEventType type = event.GetEventType(); | |
1394 | ||
1395 | if ( type == wxEVT_COMMAND_FIND || type == wxEVT_COMMAND_FIND_NEXT ) | |
1396 | { | |
4693b20c | 1397 | wxLogMessage(wxT("Find %s'%s' (flags: %s)"), |
eba33006 | 1398 | type == wxEVT_COMMAND_FIND_NEXT ? wxT("next ") : wxT(""), |
761989ff VZ |
1399 | event.GetFindString().c_str(), |
1400 | DecodeFindDialogEventFlags(event.GetFlags()).c_str()); | |
1401 | } | |
1402 | else if ( type == wxEVT_COMMAND_FIND_REPLACE || | |
1403 | type == wxEVT_COMMAND_FIND_REPLACE_ALL ) | |
1404 | { | |
4693b20c | 1405 | wxLogMessage(wxT("Replace %s'%s' with '%s' (flags: %s)"), |
eba33006 | 1406 | type == wxEVT_COMMAND_FIND_REPLACE_ALL ? _T("all ") : wxT(""), |
761989ff VZ |
1407 | event.GetFindString().c_str(), |
1408 | event.GetReplaceString().c_str(), | |
1409 | DecodeFindDialogEventFlags(event.GetFlags()).c_str()); | |
1410 | } | |
1411 | else if ( type == wxEVT_COMMAND_FIND_CLOSE ) | |
1412 | { | |
14fca738 VZ |
1413 | wxFindReplaceDialog *dlg = event.GetDialog(); |
1414 | ||
df26c4c6 | 1415 | int idMenu; |
14fca738 VZ |
1416 | const wxChar *txt; |
1417 | if ( dlg == m_dlgFind ) | |
1418 | { | |
1419 | txt = _T("Find"); | |
df26c4c6 | 1420 | idMenu = DIALOGS_FIND; |
14fca738 VZ |
1421 | m_dlgFind = NULL; |
1422 | } | |
1423 | else if ( dlg == m_dlgReplace ) | |
1424 | { | |
1425 | txt = _T("Replace"); | |
df26c4c6 | 1426 | idMenu = DIALOGS_REPLACE; |
14fca738 VZ |
1427 | m_dlgReplace = NULL; |
1428 | } | |
1429 | else | |
1430 | { | |
1431 | txt = _T("Unknown"); | |
13188def | 1432 | idMenu = wxID_ANY; |
14fca738 | 1433 | |
2f1cd905 | 1434 | wxFAIL_MSG( _T("unexpected event") ); |
14fca738 VZ |
1435 | } |
1436 | ||
df26c4c6 VZ |
1437 | wxLogMessage(wxT("%s dialog is being closed."), txt); |
1438 | ||
13188def | 1439 | if ( idMenu != wxID_ANY ) |
df26c4c6 | 1440 | { |
13188def | 1441 | GetMenuBar()->Check(idMenu, false); |
df26c4c6 | 1442 | } |
761989ff | 1443 | |
14fca738 | 1444 | dlg->Destroy(); |
761989ff VZ |
1445 | } |
1446 | else | |
1447 | { | |
4693b20c | 1448 | wxLogError(wxT("Unknown find dialog event!")); |
761989ff VZ |
1449 | } |
1450 | } | |
1451 | ||
1452 | #endif // wxUSE_FINDREPLDLG | |
1453 | ||
abceee76 VZ |
1454 | // ---------------------------------------------------------------------------- |
1455 | // MyCanvas | |
1456 | // ---------------------------------------------------------------------------- | |
1457 | ||
d355d3fe | 1458 | void MyCanvas::OnPaint(wxPaintEvent& WXUNUSED(event) ) |
457814b5 | 1459 | { |
c50f1fb9 | 1460 | wxPaintDC dc(this); |
457814b5 JS |
1461 | dc.SetFont(wxGetApp().m_canvasFont); |
1462 | dc.SetTextForeground(wxGetApp().m_canvasTextColour); | |
1463 | dc.SetBackgroundMode(wxTRANSPARENT); | |
dc96b1b6 WS |
1464 | dc.DrawText( |
1465 | _T("wxWidgets common dialogs") | |
1466 | #if !defined(__SMARTPHONE__) | |
1467 | _T(" test application") | |
1468 | #endif | |
1469 | , 10, 10); | |
457814b5 JS |
1470 | } |
1471 | ||
b4954d19 WS |
1472 | #if USE_MODAL_PRESENTATION |
1473 | ||
4c45f240 VZ |
1474 | // ---------------------------------------------------------------------------- |
1475 | // MyModelessDialog | |
1476 | // ---------------------------------------------------------------------------- | |
457814b5 | 1477 | |
4c45f240 | 1478 | MyModelessDialog::MyModelessDialog(wxWindow *parent) |
13188def | 1479 | : wxDialog(parent, wxID_ANY, wxString(_T("Modeless dialog"))) |
4c45f240 | 1480 | { |
cbc66a27 VZ |
1481 | wxBoxSizer *sizerTop = new wxBoxSizer(wxVERTICAL); |
1482 | ||
78a189c9 | 1483 | wxButton *btn = new wxButton(this, DIALOGS_MODELESS_BTN, _T("Press me")); |
13188def | 1484 | wxCheckBox *check = new wxCheckBox(this, wxID_ANY, _T("Should be disabled")); |
cbc66a27 VZ |
1485 | check->Disable(); |
1486 | ||
1487 | sizerTop->Add(btn, 1, wxEXPAND | wxALL, 5); | |
1488 | sizerTop->Add(check, 1, wxEXPAND | wxALL, 5); | |
1489 | ||
cbc66a27 VZ |
1490 | SetSizer(sizerTop); |
1491 | ||
1492 | sizerTop->SetSizeHints(this); | |
1493 | sizerTop->Fit(this); | |
4c45f240 | 1494 | } |
abceee76 | 1495 | |
5d987909 VZ |
1496 | void MyModelessDialog::OnButton(wxCommandEvent& WXUNUSED(event)) |
1497 | { | |
2f1cd905 | 1498 | wxMessageBox(_T("Button pressed in modeless dialog"), _T("Info"), |
5d987909 VZ |
1499 | wxOK | wxICON_INFORMATION, this); |
1500 | } | |
1501 | ||
abceee76 VZ |
1502 | void MyModelessDialog::OnClose(wxCloseEvent& event) |
1503 | { | |
1504 | if ( event.CanVeto() ) | |
1505 | { | |
2f1cd905 | 1506 | wxMessageBox(_T("Use the menu item to close this dialog"), |
78a189c9 | 1507 | _T("Modeless dialog"), |
abceee76 VZ |
1508 | wxOK | wxICON_INFORMATION, this); |
1509 | ||
1510 | event.Veto(); | |
1511 | } | |
1512 | } | |
1513 | ||
f6bcfd97 BP |
1514 | // ---------------------------------------------------------------------------- |
1515 | // MyModalDialog | |
1516 | // ---------------------------------------------------------------------------- | |
1517 | ||
1518 | MyModalDialog::MyModalDialog(wxWindow *parent) | |
13188def | 1519 | : wxDialog(parent, wxID_ANY, wxString(_T("Modal dialog"))) |
f6bcfd97 BP |
1520 | { |
1521 | wxBoxSizer *sizerTop = new wxBoxSizer(wxHORIZONTAL); | |
1522 | ||
13188def WS |
1523 | m_btnModal = new wxButton(this, wxID_ANY, _T("&Modal dialog...")); |
1524 | m_btnModeless = new wxButton(this, wxID_ANY, _T("Mode&less dialog")); | |
1525 | m_btnDelete = new wxButton(this, wxID_ANY, _T("&Delete button")); | |
5315ebfa | 1526 | |
78a189c9 | 1527 | wxButton *btnOk = new wxButton(this, wxID_CANCEL, _T("&Close")); |
5315ebfa VZ |
1528 | sizerTop->Add(m_btnModal, 0, wxALIGN_CENTER | wxALL, 5); |
1529 | sizerTop->Add(m_btnModeless, 0, wxALIGN_CENTER | wxALL, 5); | |
f6bcfd97 | 1530 | sizerTop->Add(m_btnDelete, 0, wxALIGN_CENTER | wxALL, 5); |
9b70bb91 | 1531 | sizerTop->Add(btnOk, 0, wxALIGN_CENTER | wxALL, 5); |
f6bcfd97 | 1532 | |
f6bcfd97 BP |
1533 | SetSizer(sizerTop); |
1534 | ||
1535 | sizerTop->SetSizeHints(this); | |
1536 | sizerTop->Fit(this); | |
1537 | ||
5315ebfa VZ |
1538 | m_btnModal->SetFocus(); |
1539 | m_btnModal->SetDefault(); | |
f6bcfd97 BP |
1540 | } |
1541 | ||
1542 | void MyModalDialog::OnButton(wxCommandEvent& event) | |
1543 | { | |
1544 | if ( event.GetEventObject() == m_btnDelete ) | |
1545 | { | |
5315ebfa VZ |
1546 | delete m_btnModal; |
1547 | m_btnModal = NULL; | |
f6bcfd97 BP |
1548 | |
1549 | m_btnDelete->Disable(); | |
1550 | } | |
5315ebfa | 1551 | else if ( event.GetEventObject() == m_btnModal ) |
f6bcfd97 | 1552 | { |
13188def | 1553 | #if wxUSE_TEXTDLG |
78a189c9 VZ |
1554 | wxGetTextFromUser(_T("Dummy prompt"), |
1555 | _T("Modal dialog called from dialog"), | |
dabbc6a5 | 1556 | wxEmptyString, this); |
13188def WS |
1557 | #else |
1558 | wxMessageBox(_T("Modal dialog called from dialog")); | |
1559 | #endif // wxUSE_TEXTDLG | |
f6bcfd97 | 1560 | } |
5315ebfa VZ |
1561 | else if ( event.GetEventObject() == m_btnModeless ) |
1562 | { | |
1563 | (new MyModelessDialog(this))->Show(); | |
1564 | } | |
f6bcfd97 BP |
1565 | else |
1566 | { | |
1567 | event.Skip(); | |
1568 | } | |
1569 | } | |
b4954d19 WS |
1570 | |
1571 | #endif // USE_MODAL_PRESENTATION | |
1572 | ||
8e1dac82 VZ |
1573 | // ---------------------------------------------------------------------------- |
1574 | // StdButtonSizerDialog | |
1575 | // ---------------------------------------------------------------------------- | |
1576 | ||
1577 | StdButtonSizerDialog::StdButtonSizerDialog(wxWindow *parent) | |
1578 | : wxDialog(parent, wxID_ANY, wxString(_T("StdButtonSizer dialog")), | |
1579 | wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER), | |
1580 | m_buttonsSizer(NULL) | |
1581 | { | |
1582 | wxBoxSizer *const sizerTop = new wxBoxSizer(wxVERTICAL); | |
1583 | ||
1584 | wxBoxSizer *const sizer = new wxBoxSizer(wxHORIZONTAL); | |
1585 | wxBoxSizer *const sizerInside1 = new wxBoxSizer(wxVERTICAL); | |
1586 | ||
1587 | m_chkboxAffirmativeButton = new wxCheckBox(this, wxID_ANY, _("Enable Affirmative Button")); | |
1588 | ||
1589 | wxStaticBoxSizer *const sizer1 = new wxStaticBoxSizer(wxVERTICAL, this, wxT("Affirmative Button")); | |
1590 | ||
1591 | m_radiobtnOk = new wxRadioButton(this, wxID_ANY, _("Ok"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP); | |
1592 | m_radiobtnYes = new wxRadioButton(this, wxID_ANY, _("Yes")); | |
1593 | ||
1594 | wxBoxSizer *const sizerInside2 = new wxBoxSizer(wxVERTICAL); | |
1595 | ||
1596 | m_chkboxDismissButton = new wxCheckBox(this, wxID_ANY, _("Enable Dismiss Button")); | |
1597 | ||
1598 | wxStaticBoxSizer *const sizer2 = new wxStaticBoxSizer(wxVERTICAL, this, wxT("Dismiss Button")); | |
1599 | ||
1600 | m_radiobtnCancel = new wxRadioButton(this, wxID_ANY, _("Cancel"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP); | |
1601 | m_radiobtnClose = new wxRadioButton(this, wxID_ANY, _("Close")); | |
1602 | ||
1603 | wxBoxSizer *const sizer3 = new wxBoxSizer(wxHORIZONTAL); | |
1604 | ||
1605 | m_chkboxNo = new wxCheckBox(this, wxID_ANY, _("No")); | |
1606 | m_chkboxHelp = new wxCheckBox(this, wxID_ANY, _("Help")); | |
1607 | m_chkboxApply = new wxCheckBox(this, wxID_ANY, _("Apply")); | |
1608 | ||
1609 | m_chkboxNoDefault = new wxCheckBox(this, wxID_ANY, wxT("No Default")); | |
1610 | ||
1611 | sizer1->Add(m_radiobtnOk, 0, wxALL, 5); | |
1612 | sizer1->Add(m_radiobtnYes, 0, wxALL, 5); | |
1613 | ||
1614 | sizer->Add(sizerInside1, 0, 0, 0); | |
1615 | sizerInside1->Add(m_chkboxAffirmativeButton, 0, wxALL, 5); | |
1616 | sizerInside1->Add(sizer1, 0, wxALL, 5); | |
1617 | sizerInside1->SetItemMinSize(sizer1, sizer1->GetStaticBox()->GetBestSize()); // to prevent wrapping of static box label | |
1618 | ||
1619 | sizer2->Add(m_radiobtnCancel, 0, wxALL, 5); | |
1620 | sizer2->Add(m_radiobtnClose, 0, wxALL, 5); | |
1621 | ||
1622 | sizer->Add(sizerInside2, 0, 0, 0); | |
1623 | sizerInside2->Add(m_chkboxDismissButton, 0, wxALL, 5); | |
1624 | sizerInside2->Add(sizer2, 0, wxALL, 5); | |
1625 | sizerInside2->SetItemMinSize(sizer2, sizer2->GetStaticBox()->GetBestSize()); // to prevent wrapping of static box label | |
1626 | ||
1627 | sizerTop->Add(sizer, 0, wxALL, 5); | |
1628 | ||
1629 | sizer3->Add(m_chkboxNo, 0, wxALL, 5); | |
1630 | sizer3->Add(m_chkboxHelp, 0, wxALL, 5); | |
1631 | sizer3->Add(m_chkboxApply, 0, wxALL, 5); | |
1632 | ||
1633 | sizerTop->Add(sizer3, 0, wxALL, 5); | |
1634 | ||
1635 | sizerTop->Add(m_chkboxNoDefault, 0, wxLEFT|wxRIGHT, 10); | |
1636 | ||
1637 | EnableDisableControls(); | |
1638 | ||
1639 | SetSizer(sizerTop); | |
1640 | ||
1641 | sizerTop->SetSizeHints(this); | |
1642 | wxCommandEvent ev; | |
1643 | OnEvent(ev); | |
1644 | } | |
1645 | ||
1646 | void StdButtonSizerDialog::OnEvent(wxCommandEvent& WXUNUSED(event)) | |
1647 | { | |
1648 | if (m_buttonsSizer) | |
1649 | { | |
1650 | m_buttonsSizer->DeleteWindows(); | |
1651 | GetSizer()->Remove(m_buttonsSizer); | |
1652 | } | |
1653 | ||
1654 | EnableDisableControls(); | |
1655 | ||
1656 | long flags = 0; | |
1657 | unsigned long numButtons = 0; | |
1658 | ||
1659 | if (m_chkboxAffirmativeButton->IsChecked()) | |
1660 | { | |
1661 | if (m_radiobtnOk->GetValue()) | |
1662 | { | |
1663 | flags |= wxOK; | |
1664 | numButtons ++; | |
1665 | } | |
1666 | else if (m_radiobtnYes->GetValue()) | |
1667 | { | |
1668 | flags |= wxYES; | |
1669 | numButtons ++; | |
1670 | } | |
1671 | } | |
1672 | ||
1673 | if (m_chkboxDismissButton->IsChecked()) | |
1674 | { | |
1675 | if (m_radiobtnCancel->GetValue()) | |
1676 | { | |
1677 | flags |= wxCANCEL; | |
1678 | numButtons ++; | |
1679 | } | |
1680 | ||
1681 | else if (m_radiobtnClose->GetValue()) | |
1682 | { | |
1683 | flags |= wxCLOSE; | |
1684 | numButtons ++; | |
1685 | } | |
1686 | ||
1687 | } | |
1688 | ||
1689 | if (m_chkboxApply->IsChecked()) | |
1690 | { | |
1691 | flags |= wxAPPLY; | |
1692 | numButtons ++; | |
1693 | } | |
1694 | ||
1695 | if (m_chkboxNo->IsChecked()) | |
1696 | { | |
1697 | flags |= wxNO; | |
1698 | numButtons ++; | |
1699 | } | |
1700 | ||
1701 | if (m_chkboxHelp->IsChecked()) | |
1702 | { | |
1703 | flags |= wxHELP; | |
1704 | numButtons ++; | |
1705 | } | |
1706 | ||
1707 | if (m_chkboxNoDefault->IsChecked()) | |
1708 | { | |
1709 | flags |= wxNO_DEFAULT; | |
1710 | } | |
1711 | ||
1712 | m_buttonsSizer = CreateStdDialogButtonSizer(flags); | |
1713 | GetSizer()->Add(m_buttonsSizer, 0, wxGROW|wxALL, 5); | |
1714 | ||
1715 | Layout(); | |
1716 | GetSizer()->SetSizeHints(this); | |
1717 | } | |
1718 | ||
1719 | void StdButtonSizerDialog::EnableDisableControls() | |
1720 | { | |
1721 | const bool affButtonEnabled = m_chkboxAffirmativeButton->IsChecked(); | |
1722 | ||
1723 | m_radiobtnOk->Enable(affButtonEnabled); | |
1724 | m_radiobtnYes->Enable(affButtonEnabled); | |
1725 | ||
1726 | const bool dismissButtonEnabled = m_chkboxDismissButton->IsChecked(); | |
1727 | ||
1728 | m_radiobtnCancel->Enable(dismissButtonEnabled); | |
1729 | m_radiobtnClose->Enable(dismissButtonEnabled); | |
1730 | } | |
1731 | ||
532d575b | 1732 | #if USE_SETTINGS_DIALOG |
0f5d8ecf JS |
1733 | // ---------------------------------------------------------------------------- |
1734 | // SettingsDialog | |
1735 | // ---------------------------------------------------------------------------- | |
1736 | ||
1737 | IMPLEMENT_CLASS(SettingsDialog, wxPropertySheetDialog) | |
1738 | ||
1739 | BEGIN_EVENT_TABLE(SettingsDialog, wxPropertySheetDialog) | |
1740 | END_EVENT_TABLE() | |
1741 | ||
64d3ed17 | 1742 | SettingsDialog::SettingsDialog(wxWindow* win, int dialogType) |
0f5d8ecf | 1743 | { |
0f4991f4 | 1744 | SetExtraStyle(wxDIALOG_EX_CONTEXTHELP|wxWS_EX_VALIDATE_RECURSIVELY); |
0f5d8ecf | 1745 | |
cc8bc5aa JS |
1746 | int tabImage1 = -1; |
1747 | int tabImage2 = -1; | |
e031f1df | 1748 | |
64d3ed17 | 1749 | bool useToolBook = (dialogType == DIALOGS_PROPERTY_SHEET_TOOLBOOK || dialogType == DIALOGS_PROPERTY_SHEET_BUTTONTOOLBOOK); |
77631b1d | 1750 | int resizeBorder = wxRESIZE_BORDER; |
684883e3 | 1751 | |
cc8bc5aa JS |
1752 | if (useToolBook) |
1753 | { | |
77631b1d | 1754 | resizeBorder = 0; |
cc8bc5aa JS |
1755 | tabImage1 = 0; |
1756 | tabImage2 = 1; | |
e031f1df | 1757 | |
64d3ed17 JS |
1758 | int sheetStyle = wxPROPSHEET_SHRINKTOFIT; |
1759 | if (dialogType == DIALOGS_PROPERTY_SHEET_BUTTONTOOLBOOK) | |
1760 | sheetStyle |= wxPROPSHEET_BUTTONTOOLBOOK; | |
1761 | else | |
1762 | sheetStyle |= wxPROPSHEET_TOOLBOOK; | |
e031f1df | 1763 | |
64d3ed17 | 1764 | SetSheetStyle(sheetStyle); |
77631b1d JS |
1765 | SetSheetInnerBorder(0); |
1766 | SetSheetOuterBorder(0); | |
cc8bc5aa JS |
1767 | |
1768 | // create a dummy image list with a few icons | |
1769 | const wxSize imageSize(32, 32); | |
1770 | ||
1771 | m_imageList = new wxImageList(imageSize.GetWidth(), imageSize.GetHeight()); | |
1772 | m_imageList-> | |
1773 | Add(wxArtProvider::GetIcon(wxART_INFORMATION, wxART_OTHER, imageSize)); | |
1774 | m_imageList-> | |
1775 | Add(wxArtProvider::GetIcon(wxART_QUESTION, wxART_OTHER, imageSize)); | |
1776 | m_imageList-> | |
1777 | Add(wxArtProvider::GetIcon(wxART_WARNING, wxART_OTHER, imageSize)); | |
1778 | m_imageList-> | |
1779 | Add(wxArtProvider::GetIcon(wxART_ERROR, wxART_OTHER, imageSize)); | |
1780 | } | |
1781 | else | |
1782 | m_imageList = NULL; | |
1783 | ||
532d575b | 1784 | Create(win, wxID_ANY, _("Preferences"), wxDefaultPosition, wxDefaultSize, |
654ffe9f | 1785 | wxDEFAULT_DIALOG_STYLE| (int)wxPlatform::IfNot(wxOS_WINDOWS_CE, resizeBorder) |
3103e8a9 | 1786 | ); |
cc8bc5aa | 1787 | |
684883e3 | 1788 | // If using a toolbook, also follow Mac style and don't create buttons |
cc8bc5aa | 1789 | if (!useToolBook) |
654ffe9f VZ |
1790 | CreateButtons(wxOK | wxCANCEL | |
1791 | (int)wxPlatform::IfNot(wxOS_WINDOWS_CE, wxHELP) | |
897b24cf | 1792 | ); |
0f5d8ecf JS |
1793 | |
1794 | wxBookCtrlBase* notebook = GetBookCtrl(); | |
cc8bc5aa | 1795 | notebook->SetImageList(m_imageList); |
0f5d8ecf JS |
1796 | |
1797 | wxPanel* generalSettings = CreateGeneralSettingsPage(notebook); | |
1798 | wxPanel* aestheticSettings = CreateAestheticSettingsPage(notebook); | |
1799 | ||
cc8bc5aa JS |
1800 | notebook->AddPage(generalSettings, _("General"), true, tabImage1); |
1801 | notebook->AddPage(aestheticSettings, _("Aesthetics"), false, tabImage2); | |
0f5d8ecf JS |
1802 | |
1803 | LayoutDialog(); | |
1804 | } | |
1805 | ||
cc8bc5aa JS |
1806 | SettingsDialog::~SettingsDialog() |
1807 | { | |
1808 | delete m_imageList; | |
1809 | } | |
1810 | ||
0f5d8ecf JS |
1811 | wxPanel* SettingsDialog::CreateGeneralSettingsPage(wxWindow* parent) |
1812 | { | |
1813 | wxPanel* panel = new wxPanel(parent, wxID_ANY); | |
1814 | ||
1815 | wxBoxSizer *topSizer = new wxBoxSizer( wxVERTICAL ); | |
1816 | wxBoxSizer *item0 = new wxBoxSizer( wxVERTICAL ); | |
1817 | ||
1818 | //// LOAD LAST FILE | |
1819 | ||
1820 | wxBoxSizer* itemSizer3 = new wxBoxSizer( wxHORIZONTAL ); | |
1821 | wxCheckBox* checkBox3 = new wxCheckBox(panel, ID_LOAD_LAST_PROJECT, _("&Load last project on startup"), wxDefaultPosition, wxDefaultSize); | |
1822 | itemSizer3->Add(checkBox3, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5); | |
1823 | item0->Add(itemSizer3, 0, wxGROW|wxALL, 0); | |
1824 | ||
1825 | //// AUTOSAVE | |
1826 | ||
1827 | wxString autoSaveLabel = _("&Auto-save every"); | |
1828 | wxString minsLabel = _("mins"); | |
1829 | ||
1830 | wxBoxSizer* itemSizer12 = new wxBoxSizer( wxHORIZONTAL ); | |
1831 | wxCheckBox* checkBox12 = new wxCheckBox(panel, ID_AUTO_SAVE, autoSaveLabel, wxDefaultPosition, wxDefaultSize); | |
62675ef3 JS |
1832 | |
1833 | #if wxUSE_SPINCTRL | |
0f5d8ecf | 1834 | wxSpinCtrl* spinCtrl12 = new wxSpinCtrl(panel, ID_AUTO_SAVE_MINS, wxEmptyString, |
532d575b | 1835 | wxDefaultPosition, wxSize(40, wxDefaultCoord), wxSP_ARROW_KEYS, 1, 60, 1); |
62675ef3 | 1836 | #endif |
532d575b | 1837 | |
0f5d8ecf | 1838 | itemSizer12->Add(checkBox12, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5); |
62675ef3 | 1839 | #if wxUSE_SPINCTRL |
0f5d8ecf | 1840 | itemSizer12->Add(spinCtrl12, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5); |
62675ef3 | 1841 | #endif |
0f5d8ecf JS |
1842 | itemSizer12->Add(new wxStaticText(panel, wxID_STATIC, minsLabel), 0, wxALL|wxALIGN_CENTER_VERTICAL, 5); |
1843 | item0->Add(itemSizer12, 0, wxGROW|wxALL, 0); | |
1844 | ||
1845 | //// TOOLTIPS | |
532d575b | 1846 | |
0f5d8ecf JS |
1847 | wxBoxSizer* itemSizer8 = new wxBoxSizer( wxHORIZONTAL ); |
1848 | wxCheckBox* checkBox6 = new wxCheckBox(panel, ID_SHOW_TOOLTIPS, _("Show &tooltips"), wxDefaultPosition, wxDefaultSize); | |
1849 | itemSizer8->Add(checkBox6, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5); | |
1850 | item0->Add(itemSizer8, 0, wxGROW|wxALL, 0); | |
1851 | ||
1852 | topSizer->Add( item0, 1, wxGROW|wxALIGN_CENTRE|wxALL, 5 ); | |
1853 | ||
1854 | panel->SetSizer(topSizer); | |
1855 | topSizer->Fit(panel); | |
532d575b | 1856 | |
0f5d8ecf JS |
1857 | return panel; |
1858 | } | |
1859 | ||
1860 | wxPanel* SettingsDialog::CreateAestheticSettingsPage(wxWindow* parent) | |
1861 | { | |
1862 | wxPanel* panel = new wxPanel(parent, wxID_ANY); | |
1863 | ||
1864 | wxBoxSizer *topSizer = new wxBoxSizer( wxVERTICAL ); | |
1865 | wxBoxSizer *item0 = new wxBoxSizer( wxVERTICAL ); | |
1866 | ||
1867 | //// PROJECT OR GLOBAL | |
1868 | wxString globalOrProjectChoices[2]; | |
1869 | globalOrProjectChoices[0] = _("&New projects"); | |
1870 | globalOrProjectChoices[1] = _("&This project"); | |
1871 | ||
1872 | wxRadioBox* projectOrGlobal = new wxRadioBox(panel, ID_APPLY_SETTINGS_TO, _("&Apply settings to:"), | |
1873 | wxDefaultPosition, wxDefaultSize, 2, globalOrProjectChoices); | |
1874 | item0->Add(projectOrGlobal, 0, wxGROW|wxALL, 5); | |
1875 | ||
1876 | projectOrGlobal->SetSelection(0); | |
1877 | ||
1878 | //// BACKGROUND STYLE | |
1879 | wxArrayString backgroundStyleChoices; | |
1880 | backgroundStyleChoices.Add(wxT("Colour")); | |
1881 | backgroundStyleChoices.Add(wxT("Image")); | |
532d575b | 1882 | wxStaticBox* staticBox3 = new wxStaticBox(panel, wxID_ANY, _("Background style:")); |
0f5d8ecf JS |
1883 | |
1884 | wxBoxSizer* styleSizer = new wxStaticBoxSizer( staticBox3, wxVERTICAL ); | |
1885 | item0->Add(styleSizer, 0, wxGROW|wxALL, 5); | |
1886 | ||
1887 | wxBoxSizer* itemSizer2 = new wxBoxSizer( wxHORIZONTAL ); | |
1888 | ||
1889 | wxChoice* choice2 = new wxChoice(panel, ID_BACKGROUND_STYLE, wxDefaultPosition, wxDefaultSize, backgroundStyleChoices); | |
1890 | ||
1891 | itemSizer2->Add(new wxStaticText(panel, wxID_ANY, _("&Window:")), 0, wxALL|wxALIGN_CENTER_VERTICAL, 5); | |
1892 | itemSizer2->Add(5, 5, 1, wxALL, 0); | |
1893 | itemSizer2->Add(choice2, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5); | |
1894 | ||
1895 | styleSizer->Add(itemSizer2, 0, wxGROW|wxALL, 5); | |
1896 | ||
62675ef3 | 1897 | #if wxUSE_SPINCTRL |
0f5d8ecf JS |
1898 | //// FONT SIZE SELECTION |
1899 | ||
532d575b | 1900 | wxStaticBox* staticBox1 = new wxStaticBox(panel, wxID_ANY, _("Tile font size:")); |
0f5d8ecf JS |
1901 | wxBoxSizer* itemSizer5 = new wxStaticBoxSizer( staticBox1, wxHORIZONTAL ); |
1902 | ||
1903 | wxSpinCtrl* spinCtrl = new wxSpinCtrl(panel, ID_FONT_SIZE, wxEmptyString, wxDefaultPosition, | |
532d575b | 1904 | wxSize(80, wxDefaultCoord)); |
0f5d8ecf JS |
1905 | itemSizer5->Add(spinCtrl, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5); |
1906 | ||
1907 | item0->Add(itemSizer5, 0, wxGROW|wxLEFT|wxRIGHT, 5); | |
62675ef3 | 1908 | #endif |
0f5d8ecf JS |
1909 | |
1910 | topSizer->Add( item0, 1, wxGROW|wxALIGN_CENTRE|wxALL, 5 ); | |
0f4991f4 | 1911 | topSizer->AddSpacer(5); |
0f5d8ecf JS |
1912 | |
1913 | panel->SetSizer(topSizer); | |
1914 | topSizer->Fit(panel); | |
532d575b | 1915 | |
0f5d8ecf JS |
1916 | return panel; |
1917 | } | |
1918 | ||
532d575b | 1919 | #endif // USE_SETTINGS_DIALOG |