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