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