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