Tinderbox build fix (wxCococa).
[wxWidgets.git] / samples / calendar / calendar.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: calendar.cpp
3 // Purpose: wxCalendarCtrl sample
4 // Author: Vadim Zeitlin
5 // Modified by:
6 // Created: 02.01.00
7 // RCS-ID: $Id$
8 // Copyright: (c) Vadim Zeitlin
9 // Licence: wxWindows licence
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 // for all others, include the necessary headers
28 #ifndef WX_PRECOMP
29 #include "wx/app.h"
30 #include "wx/log.h"
31 #include "wx/frame.h"
32 #include "wx/panel.h"
33 #include "wx/stattext.h"
34 #include "wx/menu.h"
35 #include "wx/layout.h"
36 #include "wx/msgdlg.h"
37 #endif
38
39 #include "wx/sizer.h"
40 #include "wx/textctrl.h"
41
42 #include "wx/calctrl.h"
43
44 #if wxUSE_DATEPICKCTRL
45 #include "wx/datectrl.h"
46 #if wxUSE_DATEPICKCTRL_GENERIC
47 #include "wx/generic/datectrl.h"
48 #endif // wxUSE_DATEPICKCTRL_GENERIC
49 #endif // wxUSE_DATEPICKCTRL
50
51 #include "../sample.xpm"
52
53 // ----------------------------------------------------------------------------
54 // private classes
55 // ----------------------------------------------------------------------------
56
57 // Define a new application type, each program should derive a class from wxApp
58 class MyApp : public wxApp
59 {
60 public:
61 // override base class virtuals
62 // ----------------------------
63
64 // this one is called on application startup and is a good place for the app
65 // initialization (doing it here and not in the ctor allows to have an error
66 // return: if OnInit() returns false, the application terminates)
67 virtual bool OnInit();
68 };
69
70 class MyPanel : public wxPanel
71 {
72 public:
73 MyPanel(wxFrame *frame);
74
75 void OnCalendar(wxCalendarEvent& event);
76 void OnCalendarWeekDayClick(wxCalendarEvent& event);
77 void OnCalendarChange(wxCalendarEvent& event);
78 void OnCalMonthChange(wxCalendarEvent& event);
79 void OnCalYearChange(wxCalendarEvent& event);
80
81 wxCalendarCtrl *GetCal() const { return m_calendar; }
82
83 // turn on/off the specified style bit on the calendar control
84 void ToggleCalStyle(bool on, int style);
85
86 void HighlightSpecial(bool on);
87
88 void SetDate();
89 void Today();
90
91 private:
92 wxCalendarCtrl *m_calendar;
93 wxStaticText *m_date;
94
95 DECLARE_EVENT_TABLE()
96 };
97
98 // Define a new frame type: this is going to be our main frame
99 class MyFrame : public wxFrame
100 {
101 public:
102 // ctor(s)
103 MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size);
104
105 // event handlers (these functions should _not_ be virtual)
106 void OnQuit(wxCommandEvent& event);
107 void OnAbout(wxCommandEvent& event);
108
109 #if wxUSE_DATEPICKCTRL
110 void OnAskDate(wxCommandEvent& event);
111 #endif // wxUSE_DATEPICKCTRL
112
113 void OnCalMonday(wxCommandEvent& event);
114 void OnCalHolidays(wxCommandEvent& event);
115 void OnCalSpecial(wxCommandEvent& event);
116
117 void OnCalAllowMonth(wxCommandEvent& event);
118 void OnCalAllowYear(wxCommandEvent& event);
119
120 void OnCalSeqMonth(wxCommandEvent& event);
121 void OnCalShowSurroundingWeeks(wxCommandEvent& event);
122
123 void OnSetDate(wxCommandEvent& event);
124 void OnToday(wxCommandEvent& event);
125
126 void OnAllowYearUpdate(wxUpdateUIEvent& event);
127
128 private:
129 MyPanel *m_panel;
130
131 // any class wishing to process wxWidgets events must use this macro
132 DECLARE_EVENT_TABLE()
133 };
134
135 #if wxUSE_DATEPICKCTRL
136
137 // Define a simple modal dialog which asks the user for a date
138 class MyDialog : public wxDialog
139 {
140 public:
141 MyDialog(wxWindow *parent, const wxDateTime& dt, int dtpStyle);
142
143 wxDateTime GetDate() const { return m_datePicker->GetValue(); }
144
145 private:
146 void OnDateChange(wxDateEvent& event);
147
148
149 wxDatePickerCtrlBase *m_datePicker;
150 wxTextCtrl *m_text;
151
152
153 DECLARE_EVENT_TABLE()
154 };
155
156 #endif // wxUSE_DATEPICKCTRL
157
158 // ----------------------------------------------------------------------------
159 // constants
160 // ----------------------------------------------------------------------------
161
162 // IDs for the controls and the menu commands
163 enum
164 {
165 // menu items
166 Calendar_File_About = wxID_ABOUT,
167 Calendar_File_Quit = wxID_EXIT,
168 Calendar_Cal_Monday = 200,
169 Calendar_Cal_Holidays,
170 Calendar_Cal_Special,
171 Calendar_Cal_Month,
172 Calendar_Cal_Year,
173 Calendar_Cal_SeqMonth,
174 Calendar_Cal_SurroundWeeks,
175 Calendar_Cal_SetDate,
176 Calendar_Cal_Today,
177 #if wxUSE_DATEPICKCTRL
178 Calendar_DatePicker_AskDate = 300,
179 Calendar_DatePicker_ShowCentury,
180 Calendar_DatePicker_DropDown,
181 Calendar_DatePicker_AllowNone,
182 #if wxUSE_DATEPICKCTRL_GENERIC
183 Calendar_DatePicker_Generic,
184 #endif // wxUSE_DATEPICKCTRL_GENERIC
185 #endif // wxUSE_DATEPICKCTRL
186 Calendar_CalCtrl = 1000
187 };
188
189 // ----------------------------------------------------------------------------
190 // event tables and other macros for wxWidgets
191 // ----------------------------------------------------------------------------
192
193 // the event tables connect the wxWidgets events with the functions (event
194 // handlers) which process them. It can be also done at run-time, but for the
195 // simple menu events like this the static method is much simpler.
196 BEGIN_EVENT_TABLE(MyFrame, wxFrame)
197 EVT_MENU(Calendar_File_Quit, MyFrame::OnQuit)
198 EVT_MENU(Calendar_File_About, MyFrame::OnAbout)
199
200 #if wxUSE_DATEPICKCTRL
201 EVT_MENU(Calendar_DatePicker_AskDate, MyFrame::OnAskDate)
202 #endif // wxUSE_DATEPICKCTRL
203
204 EVT_MENU(Calendar_Cal_Monday, MyFrame::OnCalMonday)
205 EVT_MENU(Calendar_Cal_Holidays, MyFrame::OnCalHolidays)
206 EVT_MENU(Calendar_Cal_Special, MyFrame::OnCalSpecial)
207
208 EVT_MENU(Calendar_Cal_Month, MyFrame::OnCalAllowMonth)
209 EVT_MENU(Calendar_Cal_Year, MyFrame::OnCalAllowYear)
210
211 EVT_MENU(Calendar_Cal_SeqMonth, MyFrame::OnCalSeqMonth)
212 EVT_MENU(Calendar_Cal_SurroundWeeks, MyFrame::OnCalShowSurroundingWeeks)
213
214 EVT_MENU(Calendar_Cal_SetDate, MyFrame::OnSetDate)
215 EVT_MENU(Calendar_Cal_Today, MyFrame::OnToday)
216
217
218 EVT_UPDATE_UI(Calendar_Cal_Year, MyFrame::OnAllowYearUpdate)
219 END_EVENT_TABLE()
220
221 BEGIN_EVENT_TABLE(MyPanel, wxPanel)
222 EVT_CALENDAR (Calendar_CalCtrl, MyPanel::OnCalendar)
223 EVT_CALENDAR_MONTH (Calendar_CalCtrl, MyPanel::OnCalMonthChange)
224 EVT_CALENDAR_YEAR (Calendar_CalCtrl, MyPanel::OnCalYearChange)
225 EVT_CALENDAR_SEL_CHANGED(Calendar_CalCtrl, MyPanel::OnCalendarChange)
226 EVT_CALENDAR_WEEKDAY_CLICKED(Calendar_CalCtrl, MyPanel::OnCalendarWeekDayClick)
227 END_EVENT_TABLE()
228
229 #if wxUSE_DATEPICKCTRL
230
231 BEGIN_EVENT_TABLE(MyDialog, wxDialog)
232 EVT_DATE_CHANGED(wxID_ANY, MyDialog::OnDateChange)
233 END_EVENT_TABLE()
234
235 #endif // wxUSE_DATEPICKCTRL
236
237 // Create a new application object: this macro will allow wxWidgets to create
238 // the application object during program execution (it's better than using a
239 // static object for many reasons) and also declares the accessor function
240 // wxGetApp() which will return the reference of the right type (i.e. MyApp and
241 // not wxApp)
242 IMPLEMENT_APP(MyApp)
243
244 // ============================================================================
245 // implementation
246 // ============================================================================
247
248 // ----------------------------------------------------------------------------
249 // the application class
250 // ----------------------------------------------------------------------------
251
252 // `Main program' equivalent: the program execution "starts" here
253 bool MyApp::OnInit()
254 {
255 // Create the main application window
256 MyFrame *frame = new MyFrame(_T("Calendar wxWidgets sample"),
257 wxPoint(50, 50), wxSize(450, 340));
258
259 frame->Show(true);
260
261 // success: wxApp::OnRun() will be called which will enter the main message
262 // loop and the application will run. If we returned false here, the
263 // application would exit immediately.
264 return true;
265 }
266
267 // ----------------------------------------------------------------------------
268 // main frame
269 // ----------------------------------------------------------------------------
270
271 // frame constructor
272 MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size)
273 : wxFrame((wxFrame *)NULL, wxID_ANY, title, pos, size)
274 {
275 // set the frame icon
276 SetIcon(wxIcon(sample_xpm));
277
278 // create a menu bar
279 wxMenu *menuFile = new wxMenu;
280 menuFile->Append(Calendar_File_About, _T("&About...\tCtrl-A"), _T("Show about dialog"));
281 menuFile->AppendSeparator();
282 menuFile->Append(Calendar_File_Quit, _T("E&xit\tAlt-X"), _T("Quit this program"));
283
284 wxMenu *menuCal = new wxMenu;
285 menuCal->Append(Calendar_Cal_Monday,
286 _T("Monday &first weekday\tCtrl-F"),
287 _T("Toggle between Mon and Sun as the first week day"),
288 true);
289 menuCal->Append(Calendar_Cal_Holidays, _T("Show &holidays\tCtrl-H"),
290 _T("Toggle highlighting the holidays"),
291 true);
292 menuCal->Append(Calendar_Cal_Special, _T("Highlight &special dates\tCtrl-S"),
293 _T("Test custom highlighting"),
294 true);
295 menuCal->Append(Calendar_Cal_SurroundWeeks,
296 _T("Show s&urrounding weeks\tCtrl-W"),
297 _T("Show the neighbouring weeks in the prev/next month"),
298 true);
299 menuCal->AppendSeparator();
300 menuCal->Append(Calendar_Cal_SeqMonth,
301 _T("To&ggle month selector style\tCtrl-G"),
302 _T("Use another style for the calendar controls"),
303 true);
304 menuCal->Append(Calendar_Cal_Month, _T("&Month can be changed\tCtrl-M"),
305 _T("Allow changing the month in the calendar"),
306 true);
307 menuCal->Append(Calendar_Cal_Year, _T("&Year can be changed\tCtrl-Y"),
308 _T("Allow changing the year in the calendar"),
309 true);
310 menuCal->AppendSeparator();
311 menuCal->Append(Calendar_Cal_SetDate, _T("SetDate()"), _T("Set date to 2005-12-24."));
312 menuCal->Append(Calendar_Cal_Today, _T("Today()"), _T("Set the current date."));
313
314 #if wxUSE_DATEPICKCTRL
315 wxMenu *menuDate = new wxMenu;
316 menuDate->AppendCheckItem(Calendar_DatePicker_ShowCentury,
317 _T("Al&ways show century"));
318 menuDate->AppendCheckItem(Calendar_DatePicker_DropDown,
319 _T("Use &drop down control"));
320 menuDate->AppendCheckItem(Calendar_DatePicker_AllowNone,
321 _T("Allow &no date"));
322 #if wxUSE_DATEPICKCTRL_GENERIC
323 menuDate->AppendCheckItem(Calendar_DatePicker_Generic,
324 _T("Use &generic version of the control"));
325 #endif // wxUSE_DATEPICKCTRL_GENERIC
326 menuDate->AppendSeparator();
327 menuDate->Append(Calendar_DatePicker_AskDate, _T("&Choose date...\tCtrl-D"), _T("Show dialog with wxDatePickerCtrl"));
328 #endif // wxUSE_DATEPICKCTRL
329
330 // now append the freshly created menu to the menu bar...
331 wxMenuBar *menuBar = new wxMenuBar;
332 menuBar->Append(menuFile, _T("&File"));
333 menuBar->Append(menuCal, _T("&Calendar"));
334 #if wxUSE_DATEPICKCTRL
335 menuBar->Append(menuDate, _T("&Date picker"));
336 #endif // wxUSE_DATEPICKCTRL
337
338 menuBar->Check(Calendar_Cal_Monday, true);
339 menuBar->Check(Calendar_Cal_Holidays, true);
340 menuBar->Check(Calendar_Cal_Month, true);
341 menuBar->Check(Calendar_Cal_Year, true);
342
343 #if wxUSE_DATEPICKCTRL
344 menuBar->Check(Calendar_DatePicker_ShowCentury, true);
345 #endif // wxUSE_DATEPICKCTRL
346
347 // ... and attach this menu bar to the frame
348 SetMenuBar(menuBar);
349
350 m_panel = new MyPanel(this);
351
352 #if wxUSE_STATUSBAR
353 // create a status bar just for fun (by default with 1 pane only)
354 CreateStatusBar(2);
355 SetStatusText(_T("Welcome to wxWidgets!"));
356 #endif // wxUSE_STATUSBAR
357 }
358
359 void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
360 {
361 // true is to force the frame to close
362 Close(true);
363 }
364
365 void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
366 {
367 wxMessageBox(_T("wxCalendarCtrl sample\n(c) 2000 Vadim Zeitlin"),
368 _T("About Calendar"), wxOK | wxICON_INFORMATION, this);
369 }
370
371 void MyFrame::OnCalMonday(wxCommandEvent& event)
372 {
373 bool enable = GetMenuBar()->IsChecked(event.GetId());
374
375 m_panel->ToggleCalStyle(enable, wxCAL_MONDAY_FIRST);
376 }
377
378 void MyFrame::OnCalHolidays(wxCommandEvent& event)
379 {
380 bool enable = GetMenuBar()->IsChecked(event.GetId());
381
382 m_panel->GetCal()->EnableHolidayDisplay(enable);
383 }
384
385 void MyFrame::OnCalSpecial(wxCommandEvent& event)
386 {
387 m_panel->HighlightSpecial(GetMenuBar()->IsChecked(event.GetId()));
388 }
389
390 void MyFrame::OnCalAllowMonth(wxCommandEvent& event)
391 {
392 bool allow = GetMenuBar()->IsChecked(event.GetId());
393
394 m_panel->GetCal()->EnableMonthChange(allow);
395 }
396
397 void MyFrame::OnCalAllowYear(wxCommandEvent& event)
398 {
399 bool allow = GetMenuBar()->IsChecked(event.GetId());
400
401 m_panel->GetCal()->EnableYearChange(allow);
402 }
403
404 void MyFrame::OnCalSeqMonth(wxCommandEvent& event)
405 {
406 bool allow = GetMenuBar()->IsChecked(event.GetId());
407
408 m_panel->ToggleCalStyle(allow, wxCAL_SEQUENTIAL_MONTH_SELECTION);
409 }
410
411 void MyFrame::OnCalShowSurroundingWeeks(wxCommandEvent& event)
412 {
413 bool allow = GetMenuBar()->IsChecked(event.GetId());
414
415 m_panel->ToggleCalStyle(allow, wxCAL_SHOW_SURROUNDING_WEEKS);
416 }
417
418 void MyFrame::OnAllowYearUpdate(wxUpdateUIEvent& event)
419 {
420 event.Enable( GetMenuBar()->IsChecked(Calendar_Cal_Month));
421 }
422
423 void MyFrame::OnSetDate(wxCommandEvent &WXUNUSED(event))
424 {
425 m_panel->SetDate();
426 }
427
428 void MyFrame::OnToday(wxCommandEvent &WXUNUSED(event))
429 {
430 m_panel->Today();
431 }
432
433 #if wxUSE_DATEPICKCTRL
434
435 void MyFrame::OnAskDate(wxCommandEvent& WXUNUSED(event))
436 {
437 int style = wxDP_DEFAULT;
438 if ( GetMenuBar()->IsChecked(Calendar_DatePicker_ShowCentury) )
439 style |= wxDP_SHOWCENTURY;
440 if ( GetMenuBar()->IsChecked(Calendar_DatePicker_DropDown) )
441 style |= wxDP_DROPDOWN;
442 if ( GetMenuBar()->IsChecked(Calendar_DatePicker_AllowNone) )
443 style |= wxDP_ALLOWNONE;
444
445 MyDialog dlg(this, m_panel->GetCal()->GetDate(), style);
446 if ( dlg.ShowModal() == wxID_OK )
447 {
448 const wxDateTime dt = dlg.GetDate();
449 if ( dt.IsValid() )
450 {
451 const wxDateTime today = wxDateTime::Today();
452
453 if ( dt.GetDay() == today.GetDay() &&
454 dt.GetMonth() == today.GetMonth() )
455 {
456 wxMessageBox(_T("Happy birthday!"), _T("Calendar Sample"));
457 }
458
459 m_panel->GetCal()->SetDate(dt);
460
461 wxLogStatus(_T("Changed the date to your input"));
462 }
463 else
464 {
465 wxLogStatus(_T("No date entered"));
466 }
467 }
468 }
469
470 #endif // wxUSE_DATEPICKCTRL
471
472 // ----------------------------------------------------------------------------
473 // MyPanel
474 // ----------------------------------------------------------------------------
475
476 MyPanel::MyPanel(wxFrame *frame)
477 : wxPanel(frame, wxID_ANY)
478 {
479 wxString date;
480 date.Printf(wxT("Selected date: %s"),
481 wxDateTime::Today().FormatISODate().c_str());
482 m_date = new wxStaticText(this, wxID_ANY, date);
483 m_calendar = new wxCalendarCtrl(this, Calendar_CalCtrl,
484 wxDefaultDateTime,
485 wxDefaultPosition,
486 wxDefaultSize,
487 wxCAL_MONDAY_FIRST |
488 wxCAL_SHOW_HOLIDAYS |
489 wxRAISED_BORDER);
490
491 wxBoxSizer *m_sizer = new wxBoxSizer( wxHORIZONTAL );
492
493 m_sizer->Add(m_date, 0, wxALIGN_CENTER | wxALL, 10 );
494 m_sizer->Add(m_calendar, 0, wxALIGN_CENTER | wxALIGN_LEFT);
495
496 SetSizer( m_sizer );
497 m_sizer->SetSizeHints( this );
498 }
499
500 void MyPanel::OnCalendar(wxCalendarEvent& event)
501 {
502 wxLogMessage(wxT("Selected %s from calendar"),
503 event.GetDate().FormatISODate().c_str());
504 }
505
506 void MyPanel::OnCalendarChange(wxCalendarEvent& event)
507 {
508 wxString s;
509 s.Printf(wxT("Selected date: %s"), event.GetDate().FormatISODate().c_str());
510
511 m_date->SetLabel(s);
512 }
513
514 void MyPanel::OnCalMonthChange(wxCalendarEvent& WXUNUSED(event))
515 {
516 wxLogStatus(wxT("Calendar month changed"));
517 }
518
519 void MyPanel::OnCalYearChange(wxCalendarEvent& WXUNUSED(event))
520 {
521 wxLogStatus(wxT("Calendar year changed"));
522 }
523
524 void MyPanel::OnCalendarWeekDayClick(wxCalendarEvent& event)
525 {
526 wxLogMessage(wxT("Clicked on %s"),
527 wxDateTime::GetWeekDayName(event.GetWeekDay()).c_str());
528 }
529
530 void MyPanel::ToggleCalStyle(bool on, int flag)
531 {
532 long style = m_calendar->GetWindowStyle();
533 if ( on )
534 style |= flag;
535 else
536 style &= ~flag;
537
538 m_calendar->SetWindowStyle(style);
539
540 m_calendar->Refresh();
541 }
542
543 void MyPanel::HighlightSpecial(bool on)
544 {
545 if ( on )
546 {
547 wxCalendarDateAttr
548 *attrRedCircle = new wxCalendarDateAttr(wxCAL_BORDER_ROUND, *wxRED),
549 *attrGreenSquare = new wxCalendarDateAttr(wxCAL_BORDER_SQUARE, *wxGREEN),
550 *attrHeaderLike = new wxCalendarDateAttr(*wxBLUE, *wxLIGHT_GREY);
551
552 m_calendar->SetAttr(17, attrRedCircle);
553 m_calendar->SetAttr(29, attrGreenSquare);
554 m_calendar->SetAttr(13, attrHeaderLike);
555 }
556 else // off
557 {
558 m_calendar->ResetAttr(17);
559 m_calendar->ResetAttr(29);
560 m_calendar->ResetAttr(13);
561 }
562
563 m_calendar->Refresh();
564 }
565
566 void MyPanel::SetDate()
567 {
568 wxDateTime date(24, wxDateTime::Dec, 2005, 23, 59, 59);
569 m_calendar->SetDate(date);
570 }
571
572 void MyPanel::Today()
573 {
574 m_calendar->SetDate(wxDateTime::Today());
575 }
576
577 // ----------------------------------------------------------------------------
578 // MyDialog
579 // ----------------------------------------------------------------------------
580
581 #if wxUSE_DATEPICKCTRL
582
583 MyDialog::MyDialog(wxWindow *parent, const wxDateTime& dt, int dtpStyle)
584 : wxDialog(parent, wxID_ANY, wxString(_T("Calendar: Choose a date")))
585 {
586 wxStdDialogButtonSizer *sizerBtns = new wxStdDialogButtonSizer;
587 sizerBtns->AddButton(new wxButton(this, wxID_OK));
588 sizerBtns->AddButton(new wxButton(this, wxID_CANCEL));
589 sizerBtns->Realize();
590
591 wxSizer *sizerText = new wxBoxSizer(wxHORIZONTAL);
592 sizerText->Add(new wxStaticText(this, wxID_ANY, _T("Date in ISO format: ")),
593 wxSizerFlags().Border().Align(wxALIGN_CENTRE_VERTICAL));
594 m_text = new wxTextCtrl(this, wxID_ANY);
595 sizerText->Add(m_text, wxSizerFlags().
596 Expand().Border().Align(wxALIGN_CENTRE_VERTICAL));
597
598 wxSizer *sizerTop = new wxBoxSizer(wxVERTICAL);
599 sizerTop->Add(new wxStaticText
600 (
601 this, wxID_ANY,
602 _T("Enter your birthday date (not before 20th century):")
603 ),
604 wxSizerFlags().Border());
605
606 #if wxUSE_DATEPICKCTRL_GENERIC
607 wxFrame *frame = (wxFrame *)wxGetTopLevelParent(parent);
608 if ( frame && frame->GetMenuBar()->IsChecked(Calendar_DatePicker_Generic) )
609 m_datePicker = new wxDatePickerCtrlGeneric(this, wxID_ANY, dt,
610 wxDefaultPosition,
611 wxDefaultSize,
612 dtpStyle);
613 else
614 #endif // wxUSE_DATEPICKCTRL_GENERIC
615 m_datePicker = new wxDatePickerCtrl(this, wxID_ANY, dt,
616 wxDefaultPosition, wxDefaultSize,
617 dtpStyle);
618 m_datePicker->SetRange(wxDateTime(1, wxDateTime::Jan, 1900),
619 wxDefaultDateTime);
620 sizerTop->Add(m_datePicker, wxSizerFlags().Expand().Border());
621
622 sizerTop->AddStretchSpacer(1);
623 sizerTop->Add(sizerText);
624
625 sizerTop->Add(sizerBtns, wxSizerFlags().Centre().Border());
626
627 SetSizerAndFit(sizerTop);
628 Layout();
629 }
630
631 void MyDialog::OnDateChange(wxDateEvent& event)
632 {
633 const wxDateTime dt = event.GetDate();
634 if(dt.IsValid())
635 m_text->SetValue(dt.FormatISODate());
636 else
637 m_text->SetValue(wxEmptyString);
638 }
639
640 #endif // wxUSE_DATEPICKCTRL
641