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