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