]> git.saurik.com Git - wxWidgets.git/blob - samples/widgets/picker.cpp
8ed727ab7f32cda0c53ef00bbaba0535102d532d
[wxWidgets.git] / samples / widgets / picker.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Program: wxWidgets Widgets Sample
3 // Name: picker.cpp
4 // Purpose: Part of the widgets sample showing wx*PickerCtrl
5 // Author: Francesco Montorsi
6 // Created: 22/4/2006
7 // Id: $Id$
8 // Copyright: (c) 2006 Francesco Montorsi
9 // License: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
11
12 // ============================================================================
13 // declarations
14 // ============================================================================
15
16 // ----------------------------------------------------------------------------
17 // headers
18 // ----------------------------------------------------------------------------
19
20 // for compilers that support precompilation, includes "wx/wx.h".
21 #include "wx/wxprec.h"
22
23 #ifdef __BORLANDC__
24 #pragma hdrstop
25 #endif
26
27 #if wxUSE_COLOURPICKERCTRL || wxUSE_FILEPICKERCTRL || wxUSE_DIRPICKERCTRL || wxUSE_FONTPICKERCTRL
28
29 // for all others, include the necessary headers
30 #ifndef WX_PRECOMP
31 #include "wx/app.h"
32 #include "wx/log.h"
33 #include "wx/radiobox.h"
34 #endif
35
36 #include "wx/artprov.h"
37 #include "wx/sizer.h"
38 #include "wx/stattext.h"
39 #include "wx/checkbox.h"
40 #include "wx/imaglist.h"
41
42 #include "wx/clrpicker.h"
43 #include "wx/filepicker.h"
44 #include "wx/fontpicker.h"
45
46 #include "widgets.h"
47
48 #include "icons/picker.xpm"
49
50 // ----------------------------------------------------------------------------
51 // constants
52 // ----------------------------------------------------------------------------
53
54 enum
55 {
56 FilePickerMode_Open = 0,
57 FilePickerMode_Save
58 };
59
60 // control ids
61 enum
62 {
63 PickerPage_Reset = wxID_HIGHEST,
64
65 #if wxUSE_COLOURPICKERCTRL
66 PickerPage_Colour,
67 #endif
68 #if wxUSE_FILEPICKERCTRL
69 PickerPage_File,
70 #endif
71 #if wxUSE_DIRPICKERCTRL
72 PickerPage_Dir,
73 #endif
74 #if wxUSE_FONTPICKERCTRL
75 PickerPage_Font
76 #endif
77 };
78
79
80 // ----------------------------------------------------------------------------
81 // PickerWidgetsPage
82 // ----------------------------------------------------------------------------
83
84 class PickerWidgetsPage : public WidgetsPage
85 {
86 public:
87 PickerWidgetsPage(WidgetsBookCtrl *book, wxImageList *imaglist);
88 virtual ~PickerWidgetsPage(){};
89
90 virtual wxControl *GetWidget() const { return m_filePicker; }
91 virtual void RecreateWidget() { RecreateAllPickers(); }
92
93 // lazy creation of the content
94 virtual void CreateContent();
95
96 protected:
97 enum PickerKind
98 {
99 Picker_None = -1,
100 Picker_Colour,
101 Picker_File,
102 Picker_Dir,
103 Picker_Font
104 };
105
106 // called only once at first construction
107 void CreatePickers(PickerKind picker);
108
109 // called to recreate an existing control
110 void RecreatePicker(PickerKind picker);
111
112 // recreate all existing picker controls
113 void RecreateAllPickers();
114
115 // restore the checkboxes state to the initial values
116 void Reset();
117
118 // get the initial style for the picker of the given kind
119 long GetPickerStyle(PickerKind kind);
120
121 // update filepicker radiobox
122 void UpdateFilePickerMode();
123
124 // the pickers and the relative event handlers
125 #if wxUSE_COLOURPICKERCTRL
126 wxColourPickerCtrl *m_clrPicker;
127 void OnColourChange(wxColourPickerEvent &ev);
128 #endif
129 #if wxUSE_FILEPICKERCTRL
130 wxFilePickerCtrl *m_filePicker;
131 void OnFileChange(wxFileDirPickerEvent &ev);
132 #endif
133 #if wxUSE_DIRPICKERCTRL
134 wxDirPickerCtrl *m_dirPicker;
135 void OnDirChange(wxFileDirPickerEvent &ev);
136 #endif
137 #if wxUSE_FONTPICKERCTRL
138 wxFontPickerCtrl *m_fontPicker;
139 void OnFontChange(wxFontPickerEvent &ev);
140 #endif
141 void OnCheckBox(wxCommandEvent &ev);
142 void OnButtonReset(wxCommandEvent &ev);
143
144
145 // other controls
146 // --------------
147
148 wxCheckBox *m_chkColourTextCtrl,
149 *m_chkColourShowLabel;
150
151 wxCheckBox *m_chkFileTextCtrl,
152 *m_chkFileOverwritePrompt,
153 *m_chkFileMustExist,
154 *m_chkFileChangeDir;
155 wxRadioBox *m_radioFilePickerMode;
156
157 wxCheckBox *m_chkDirTextCtrl,
158 *m_chkDirChangeDir,
159 *m_chkDirMustExist;
160
161 wxCheckBox *m_chkFontTextCtrl,
162 *m_chkFontDescAsLabel,
163 *m_chkFontUseFontForLabel;
164
165 wxFlexGridSizer *m_sizerPicker;
166
167 private:
168 DECLARE_EVENT_TABLE()
169 DECLARE_WIDGETS_PAGE(PickerWidgetsPage)
170 };
171
172 // ----------------------------------------------------------------------------
173 // event tables
174 // ----------------------------------------------------------------------------
175
176 BEGIN_EVENT_TABLE(PickerWidgetsPage, WidgetsPage)
177 EVT_BUTTON(PickerPage_Reset, PickerWidgetsPage::OnButtonReset)
178
179 #if wxUSE_COLOURPICKERCTRL
180 EVT_COLOURPICKER_CHANGED(PickerPage_Colour, PickerWidgetsPage::OnColourChange)
181 #endif
182 #if wxUSE_FILEPICKERCTRL
183 EVT_FILEPICKER_CHANGED(PickerPage_File, PickerWidgetsPage::OnFileChange)
184 #endif
185 #if wxUSE_DIRPICKERCTRL
186 EVT_DIRPICKER_CHANGED(PickerPage_Dir, PickerWidgetsPage::OnDirChange)
187 #endif
188 #if wxUSE_FONTPICKERCTRL
189 EVT_FONTPICKER_CHANGED(PickerPage_Font, PickerWidgetsPage::OnFontChange)
190 #endif
191
192 EVT_CHECKBOX(wxID_ANY, PickerWidgetsPage::OnCheckBox)
193 EVT_RADIOBOX(wxID_ANY, PickerWidgetsPage::OnCheckBox)
194 END_EVENT_TABLE()
195
196 // ============================================================================
197 // implementation
198 // ============================================================================
199
200 #if defined(__WXGTK24__)
201 #define FAMILY_CTRLS NATIVE_CTRLS
202 #else
203 #define FAMILY_CTRLS GENERIC_CTRLS
204 #endif
205
206 IMPLEMENT_WIDGETS_PAGE(PickerWidgetsPage, _T("Pickers"),
207 PICKER_CTRLS | FAMILY_CTRLS);
208
209 PickerWidgetsPage::PickerWidgetsPage(WidgetsBookCtrl *book,
210 wxImageList *imaglist)
211 : WidgetsPage(book, imaglist, picker_xpm)
212 {
213 }
214
215 void PickerWidgetsPage::CreateContent()
216 {
217 // left pane
218 wxSizer *boxleft = new wxBoxSizer(wxVERTICAL);
219
220 #if wxUSE_COLOURPICKERCTRL
221 wxStaticBoxSizer *clrbox = new wxStaticBoxSizer(wxVERTICAL, this, _T("&ColourPicker style"));
222 m_chkColourTextCtrl = CreateCheckBoxAndAddToSizer(clrbox, _T("With textctrl"), false);
223 m_chkColourShowLabel = CreateCheckBoxAndAddToSizer(clrbox, _T("With label"), false);
224 boxleft->Add(clrbox, 0, wxALL|wxGROW, 5);
225 boxleft->Add(1, 1, 1, wxGROW | wxALL, 5); // spacer
226 #endif // wxUSE_COLOURPICKERCTRL
227
228 #if wxUSE_FILEPICKERCTRL
229 static const wxString mode[] = { _T("open"), _T("save") };
230 m_radioFilePickerMode = new wxRadioBox(this, wxID_ANY, _T("wxFilePicker mode"),
231 wxDefaultPosition, wxDefaultSize,
232 WXSIZEOF(mode), mode);
233 boxleft->Add(m_radioFilePickerMode, 0, wxALL|wxGROW, 5);
234
235 wxStaticBoxSizer *filebox = new wxStaticBoxSizer(wxVERTICAL, this, _T("&FilePicker style"));
236 m_chkFileTextCtrl = CreateCheckBoxAndAddToSizer(filebox, _T("With textctrl"), false);
237 m_chkFileOverwritePrompt = CreateCheckBoxAndAddToSizer(filebox, _T("Overwrite prompt"), false);
238 m_chkFileMustExist = CreateCheckBoxAndAddToSizer(filebox, _T("File must exist"), false);
239 m_chkFileChangeDir = CreateCheckBoxAndAddToSizer(filebox, _T("Change working dir"), false);
240 boxleft->Add(filebox, 0, wxALL|wxGROW, 5);
241 boxleft->Add(1, 1, 1, wxGROW | wxALL, 5); // spacer
242 #endif // wxUSE_FILEPICKERCTRL
243
244 #if wxUSE_DIRPICKERCTRL
245 wxStaticBoxSizer *dirbox = new wxStaticBoxSizer(wxVERTICAL, this, _T("&DirPicker style"));
246 m_chkDirTextCtrl = CreateCheckBoxAndAddToSizer(dirbox, _T("With textctrl"), false);
247 m_chkDirMustExist = CreateCheckBoxAndAddToSizer(dirbox, _T("Dir must exist"), false);
248 m_chkDirChangeDir = CreateCheckBoxAndAddToSizer(dirbox, _T("Change working dir"), false);
249 boxleft->Add(dirbox, 0, wxALL|wxGROW, 5);
250 boxleft->Add(1, 1, 1, wxGROW | wxALL, 5); // spacer
251 #endif // wxUSE_DIRPICKERCTRL
252
253 #if wxUSE_FONTPICKERCTRL
254 wxStaticBoxSizer *fontbox = new wxStaticBoxSizer(wxVERTICAL, this, _T("&FontPicker style"));
255 m_chkFontTextCtrl = CreateCheckBoxAndAddToSizer(fontbox, _T("With textctrl"));
256 m_chkFontDescAsLabel = CreateCheckBoxAndAddToSizer(fontbox, _T("Font desc as btn label"));
257 m_chkFontUseFontForLabel = CreateCheckBoxAndAddToSizer(fontbox, _T("Use font for label"), false);
258 boxleft->Add(fontbox, 0, wxALL|wxGROW, 5);
259 #endif // wxUSE_FONTPICKERCTRL
260
261 boxleft->Add(new wxButton(this, PickerPage_Reset, _T("&Reset")),
262 0, wxALIGN_CENTRE_HORIZONTAL | wxALL, 15);
263
264 Reset(); // set checkboxes state
265
266 // create pickers
267 m_clrPicker = NULL;
268 m_filePicker = NULL;
269 m_fontPicker = NULL;
270 m_dirPicker = NULL;
271
272 int nrows = 0;
273 #if wxUSE_COLOURPICKERCTRL
274 CreatePickers(Picker_Colour);
275 nrows++;
276 #endif // wxUSE_COLOURPICKERCTRL
277
278 #if wxUSE_FILEPICKERCTRL
279 CreatePickers(Picker_File);
280 nrows++;
281 #endif // wxUSE_FILEPICKERCTRL
282
283 #if wxUSE_DIRPICKERCTRL
284 CreatePickers(Picker_Dir);
285 nrows++;
286 #endif // wxUSE_DIRPICKERCTRL
287
288 #if wxUSE_FONTPICKERCTRL
289 CreatePickers(Picker_Font);
290 nrows++;
291 #endif // wxUSE_FONTPICKERCTRL
292
293 m_sizerPicker = new wxFlexGridSizer(nrows, 2, 0, 0); // 4 rows x 2 columns
294 #if wxUSE_COLOURPICKERCTRL
295 m_sizerPicker->Add(new wxStaticText(this, wxID_ANY, wxT("wxColourPickerCtrl:")),
296 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT | wxALL, 5);
297 m_sizerPicker->Add(m_clrPicker, 1, wxGROW | wxALL, 5);
298 #endif
299 #if wxUSE_FILEPICKERCTRL
300 m_sizerPicker->Add(new wxStaticText(this, wxID_ANY, wxT("wxFilePickerCtrl:")),
301 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT | wxALL, 5);
302 m_sizerPicker->Add(m_filePicker, 1, wxGROW | wxALL, 5);
303 #endif
304 #if wxUSE_DIRPICKERCTRL
305 m_sizerPicker->Add(new wxStaticText(this, wxID_ANY, wxT("wxDirPickerCtrl:")),
306 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT | wxALL, 5);
307 m_sizerPicker->Add(m_dirPicker, 1, wxGROW | wxALL, 5);
308 #endif
309 #if wxUSE_FONTPICKERCTRL
310 m_sizerPicker->Add(new wxStaticText(this, wxID_ANY, wxT("wxFontPickerCtrl:")),
311 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT | wxALL, 5);
312 m_sizerPicker->Add(m_fontPicker, 1, wxGROW | wxALL, 5);
313 #endif
314
315 m_sizerPicker->AddGrowableCol(1, 3);
316
317 // right pane
318 wxStaticBoxSizer *
319 boxright = new wxStaticBoxSizer(wxVERTICAL, this, _T("Pickers"));
320 boxright->Add(m_sizerPicker, 1, wxGROW | wxALL, 5);
321
322 // global pane
323 wxSizer *sz = new wxBoxSizer(wxHORIZONTAL);
324 sz->Add(boxleft, 0, wxGROW|wxALL, 5);
325 sz->Add(boxright, 1, wxGROW|wxALL, 5);
326
327 SetSizerAndFit(sz);
328 }
329
330 void PickerWidgetsPage::CreatePickers(PickerKind picker)
331 {
332 switch ( picker )
333 {
334 #if wxUSE_COLOURPICKERCTRL
335 case Picker_Colour:
336 delete m_clrPicker;
337
338 m_clrPicker = new wxColourPickerCtrl(this, PickerPage_Colour, *wxRED,
339 wxDefaultPosition, wxDefaultSize,
340 GetPickerStyle(Picker_Colour));
341 break;
342 #endif // wxUSE_COLOURPICKERCTRL
343
344 #if wxUSE_FILEPICKERCTRL
345 case Picker_File:
346 delete m_filePicker;
347
348 // pass an empty string as initial file
349 m_filePicker = new wxFilePickerCtrl(this, PickerPage_File,
350 wxEmptyString,
351 wxT("Hello!"), wxT("*"),
352 wxDefaultPosition, wxDefaultSize,
353 GetPickerStyle(Picker_File));
354 break;
355 #endif // wxUSE_FILEPICKERCTRL
356
357 #if wxUSE_DIRPICKERCTRL
358 case Picker_Dir:
359 delete m_dirPicker;
360
361 m_dirPicker = new wxDirPickerCtrl(this, PickerPage_Dir,
362 wxGetHomeDir(), wxT("Hello!"),
363 wxDefaultPosition, wxDefaultSize,
364 GetPickerStyle(Picker_Dir));
365 break;
366 #endif // wxUSE_DIRPICKERCTRL
367
368 #if wxUSE_FONTPICKERCTRL
369 case Picker_Font:
370 delete m_fontPicker;
371
372 m_fontPicker = new wxFontPickerCtrl(this, PickerPage_Font,
373 *wxSWISS_FONT,
374 wxDefaultPosition, wxDefaultSize,
375 GetPickerStyle(Picker_Font));
376 break;
377 #endif // wxUSE_FONTPICKERCTRL
378
379 default:
380 wxFAIL_MSG( _T("unknown picker kind") );
381 }
382 }
383
384 long PickerWidgetsPage::GetPickerStyle(PickerKind picker)
385 {
386 long style = 0;
387
388 switch (picker)
389 {
390 #if wxUSE_COLOURPICKERCTRL
391 case Picker_Colour:
392 if ( m_chkColourTextCtrl->GetValue() )
393 style |= wxCLRP_USE_TEXTCTRL;
394
395 if ( m_chkColourShowLabel->GetValue() )
396 style |= wxCLRP_SHOW_LABEL;
397
398 break;
399 #endif // wxUSE_COLOURPICKERCTRL
400
401 #if wxUSE_FILEPICKERCTRL
402 case Picker_File:
403 if ( m_chkFileTextCtrl->GetValue() )
404 style |= wxFLP_USE_TEXTCTRL;
405
406 if ( m_chkFileOverwritePrompt->GetValue() )
407 style |= wxFLP_OVERWRITE_PROMPT;
408
409 if ( m_chkFileMustExist->GetValue() )
410 style |= wxFLP_FILE_MUST_EXIST;
411
412 if ( m_chkFileChangeDir->GetValue() )
413 style |= wxFLP_CHANGE_DIR;
414
415 if (m_radioFilePickerMode->GetSelection() == FilePickerMode_Open)
416 style |= wxFLP_OPEN;
417 else
418 style |= wxFLP_SAVE;
419
420 break;
421 #endif // wxUSE_FILEPICKERCTRL
422
423 #if wxUSE_DIRPICKERCTRL
424 case Picker_Dir:
425 if ( m_chkDirTextCtrl->GetValue() )
426 style |= wxDIRP_USE_TEXTCTRL;
427
428 if ( m_chkDirMustExist->GetValue() )
429 style |= wxDIRP_DIR_MUST_EXIST;
430
431 if ( m_chkDirChangeDir->GetValue() )
432 style |= wxDIRP_CHANGE_DIR;
433
434 break;
435 #endif // wxUSE_DIRPICKERCTRL
436
437 #if wxUSE_FONTPICKERCTRL
438 case Picker_Font:
439 if ( m_chkFontTextCtrl->GetValue() )
440 style |= wxFNTP_USE_TEXTCTRL;
441
442 if ( m_chkFontUseFontForLabel->GetValue() )
443 style |= wxFNTP_USEFONT_FOR_LABEL;
444
445 if ( m_chkFontDescAsLabel->GetValue() )
446 style |= wxFNTP_FONTDESC_AS_LABEL;
447
448 break;
449 #endif // wxUSE_FONTPICKERCTRL
450
451 default:
452 wxFAIL_MSG( _T("unknown picker kind") );
453 }
454
455 return style;
456 }
457
458 void PickerWidgetsPage::RecreatePicker(PickerKind picker)
459 {
460 switch ( picker )
461 {
462 #if wxUSE_COLOURPICKERCTRL
463 case Picker_Colour:
464 m_sizerPicker->Remove(1);
465 CreatePickers(Picker_Colour);
466 m_sizerPicker->Insert(1, m_clrPicker, 1, wxGROW|wxALL, 5);
467 break;
468 #endif // wxUSE_COLOURPICKERCTRL
469
470 #if wxUSE_FILEPICKERCTRL
471 case Picker_File:
472 m_sizerPicker->Remove(3);
473 CreatePickers(Picker_File);
474 m_sizerPicker->Insert(3, m_filePicker, 1, wxGROW|wxALL, 5);
475 break;
476 #endif // wxUSE_FILEPICKERCTRL
477
478 #if wxUSE_DIRPICKERCTRL
479 case Picker_Dir:
480 m_sizerPicker->Remove(5);
481 CreatePickers(Picker_Dir);
482 m_sizerPicker->Insert(5, m_dirPicker, 1, wxGROW|wxALL, 5);
483 break;
484 #endif // wxUSE_DIRPICKERCTRL
485
486 #if wxUSE_FONTPICKERCTRL
487 case Picker_Font:
488 wxASSERT(m_sizerPicker->Remove(7));
489 CreatePickers(Picker_Font);
490 m_sizerPicker->Insert(7, m_fontPicker, 1, wxGROW|wxALL, 5);
491 break;
492 #endif // wxUSE_FONTPICKERCTRL
493
494 default:
495 wxFAIL_MSG( _T("unknown picker kind") );
496 }
497
498 m_sizerPicker->Layout();
499 }
500
501 void PickerWidgetsPage::RecreateAllPickers()
502 {
503 #if wxUSE_COLOURPICKERCTRL
504 RecreatePicker(Picker_Colour);
505 #endif // wxUSE_COLOURPICKERCTRL
506
507 #if wxUSE_FILEPICKERCTRL
508 RecreatePicker(Picker_File);
509 #endif // wxUSE_FILEPICKERCTRL
510
511 #if wxUSE_DIRPICKERCTRL
512 RecreatePicker(Picker_Dir);
513 #endif // wxUSE_DIRPICKERCTRL
514
515 #if wxUSE_FONTPICKERCTRL
516 RecreatePicker(Picker_Font);
517 #endif // wxUSE_FONTPICKERCTRL
518 }
519
520 void PickerWidgetsPage::Reset()
521 {
522 #if wxUSE_COLOURPICKERCTRL
523 m_chkColourTextCtrl->SetValue((wxCLRP_DEFAULT_STYLE & wxCLRP_USE_TEXTCTRL) != 0);
524 m_chkColourShowLabel->SetValue((wxCLRP_DEFAULT_STYLE & wxCLRP_SHOW_LABEL) != 0);
525 #endif
526
527 #if wxUSE_FILEPICKERCTRL
528 m_radioFilePickerMode->SetSelection((wxFLP_DEFAULT_STYLE & wxFLP_OPEN) ?
529 FilePickerMode_Open : FilePickerMode_Save);
530 m_chkFileTextCtrl->SetValue((wxFLP_DEFAULT_STYLE & wxFLP_USE_TEXTCTRL) != 0);
531 m_chkFileOverwritePrompt->SetValue((wxFLP_DEFAULT_STYLE & wxFLP_OVERWRITE_PROMPT) != 0);
532 m_chkFileMustExist->SetValue((wxFLP_DEFAULT_STYLE & wxFLP_FILE_MUST_EXIST) != 0);
533 m_chkFileChangeDir->SetValue((wxFLP_DEFAULT_STYLE & wxFLP_CHANGE_DIR) != 0);
534
535 UpdateFilePickerMode();
536 #endif
537
538 #if wxUSE_DIRPICKERCTRL
539 m_chkDirTextCtrl->SetValue((wxDIRP_DEFAULT_STYLE & wxDIRP_USE_TEXTCTRL) != 0);
540 m_chkDirMustExist->SetValue((wxDIRP_DEFAULT_STYLE & wxDIRP_DIR_MUST_EXIST) != 0);
541 m_chkDirChangeDir->SetValue((wxDIRP_DEFAULT_STYLE & wxDIRP_CHANGE_DIR) != 0);
542 #endif
543
544 #if wxUSE_FONTPICKERCTRL
545 m_chkFontTextCtrl->SetValue((wxFNTP_DEFAULT_STYLE & wxFNTP_USE_TEXTCTRL) != 0);
546 m_chkFontUseFontForLabel->SetValue((wxFNTP_DEFAULT_STYLE & wxFNTP_USEFONT_FOR_LABEL) != 0);
547 m_chkFontDescAsLabel->SetValue((wxFNTP_DEFAULT_STYLE & wxFNTP_FONTDESC_AS_LABEL) != 0);
548 #endif
549 }
550
551 void PickerWidgetsPage::UpdateFilePickerMode()
552 {
553 switch (m_radioFilePickerMode->GetSelection())
554 {
555 case FilePickerMode_Open:
556 m_chkFileOverwritePrompt->SetValue(false);
557 m_chkFileOverwritePrompt->Disable();
558 m_chkFileMustExist->Enable();
559 break;
560 case FilePickerMode_Save:
561 m_chkFileMustExist->SetValue(false);
562 m_chkFileMustExist->Disable();
563 m_chkFileOverwritePrompt->Enable();
564 break;
565 }
566 }
567
568
569 // ----------------------------------------------------------------------------
570 // event handlers
571 // ----------------------------------------------------------------------------
572
573 void PickerWidgetsPage::OnButtonReset(wxCommandEvent& WXUNUSED(event))
574 {
575 Reset();
576
577 RecreateAllPickers();
578 }
579
580 #if wxUSE_COLOURPICKERCTRL
581 void PickerWidgetsPage::OnColourChange(wxColourPickerEvent& event)
582 {
583 wxLogMessage(wxT("The colour changed to '%s' !"),
584 event.GetColour().GetAsString(wxC2S_CSS_SYNTAX).c_str());
585 }
586 #endif
587 #if wxUSE_FILEPICKERCTRL
588 void PickerWidgetsPage::OnFileChange(wxFileDirPickerEvent& event)
589 {
590 wxLogMessage(wxT("The file changed to '%s' ! The current working directory is '%s'"),
591 event.GetPath().c_str(), wxGetCwd().c_str());
592 }
593 #endif
594 #if wxUSE_DIRPICKERCTRL
595 void PickerWidgetsPage::OnDirChange(wxFileDirPickerEvent& event)
596 {
597 wxLogMessage(wxT("The directory changed to '%s' ! The current working directory is '%s'"),
598 event.GetPath().c_str(), wxGetCwd().c_str());
599 }
600 #endif
601 #if wxUSE_FONTPICKERCTRL
602 void PickerWidgetsPage::OnFontChange(wxFontPickerEvent& event)
603 {
604 wxLogMessage(wxT("The font changed to '%s' with size %d !"),
605 event.GetFont().GetFaceName().c_str(), event.GetFont().GetPointSize());
606 }
607 #endif
608
609 void PickerWidgetsPage::OnCheckBox(wxCommandEvent &event)
610 {
611 if (event.GetEventObject() == m_chkColourTextCtrl ||
612 event.GetEventObject() == m_chkColourShowLabel)
613 RecreatePicker(Picker_Colour);
614
615 if (event.GetEventObject() == m_chkFileTextCtrl ||
616 event.GetEventObject() == m_chkFileOverwritePrompt ||
617 event.GetEventObject() == m_chkFileMustExist ||
618 event.GetEventObject() == m_chkFileChangeDir)
619 RecreatePicker(Picker_File);
620
621 if (event.GetEventObject() == m_chkDirTextCtrl ||
622 event.GetEventObject() == m_chkDirChangeDir ||
623 event.GetEventObject() == m_chkDirMustExist)
624 RecreatePicker(Picker_Dir);
625
626 if (event.GetEventObject() == m_chkFontTextCtrl ||
627 event.GetEventObject() == m_chkFontDescAsLabel ||
628 event.GetEventObject() == m_chkFontUseFontForLabel)
629 RecreatePicker(Picker_Font);
630
631 if (event.GetEventObject() == m_radioFilePickerMode)
632 {
633 UpdateFilePickerMode();
634 RecreatePicker(Picker_File);
635 }
636 }
637
638 #endif // wxUSE_COLOURPICKERCTRL || wxUSE_FILEPICKERCTRL || wxUSE_DIRPICKERCTRL || wxUSE_FONTPICKERCTRL