+void MyFrame::OnToday(wxCommandEvent &WXUNUSED(event))
+{
+ m_panel->SetDate(wxDateTime::Today());
+}
+
+void MyFrame::OnBeginDST(wxCommandEvent &WXUNUSED(event))
+{
+ m_panel->SetDate(wxDateTime::GetBeginDST(m_panel->GetDate().GetYear()));
+}
+
+void MyFrame::OnCalToggleResizable(wxCommandEvent& event)
+{
+ wxSizer * const sizer = m_panel->GetSizer();
+ wxSizerItem * const item = sizer->GetItem(m_panel->GetCal());
+ if ( event.IsChecked() )
+ {
+ item->SetProportion(1);
+ item->SetFlag(wxEXPAND);
+ }
+ else // not resizable
+ {
+ item->SetProportion(0);
+ item->SetFlag(wxALIGN_CENTER);
+ }
+
+ sizer->Layout();
+}
+
+void MyFrame::OnCalRClick(wxMouseEvent& event)
+{
+ wxDateTime dt;
+ wxDateTime::WeekDay wd;
+
+ const wxPoint pt = event.GetPosition();
+ wxString msg = wxString::Format("Point (%d, %d) is ", pt.x, pt.y);
+
+ switch ( m_panel->GetCal()->HitTest(pt, &dt, &wd) )
+ {
+ default:
+ wxFAIL_MSG( "unexpected" );
+ // fall through
+
+ case wxCAL_HITTEST_NOWHERE:
+ msg += "nowhere";
+ break;
+
+ case wxCAL_HITTEST_HEADER:
+ msg += wxString::Format("over %s", wxDateTime::GetWeekDayName(wd));
+ break;
+
+ case wxCAL_HITTEST_DAY:
+ msg += wxString::Format("over %s", dt.FormatISODate());
+ break;
+
+ case wxCAL_HITTEST_INCMONTH:
+ msg += "over next month button";
+ break;
+
+ case wxCAL_HITTEST_DECMONTH:
+ msg += "over previous month button";
+ break;
+
+ case wxCAL_HITTEST_SURROUNDING_WEEK:
+ msg += "over a day from another month";
+ break;
+ }
+
+ wxLogMessage("%s", msg);
+}
+
+#if wxUSE_DATEPICKCTRL
+
+void MyFrame::OnUpdateUIStartWithNone(wxUpdateUIEvent& event)
+{
+ // it only makes sense to start with invalid date if we can have no date
+ event.Enable( GetMenuBar()->IsChecked(Calendar_DatePicker_AllowNone) );
+}
+
+void MyFrame::OnAskDate(wxCommandEvent& WXUNUSED(event))
+{
+ wxDateTime dt = m_panel->GetCal()->GetDate();
+
+ int style = wxDP_DEFAULT;
+ if ( GetMenuBar()->IsChecked(Calendar_DatePicker_ShowCentury) )
+ style |= wxDP_SHOWCENTURY;
+ if ( GetMenuBar()->IsChecked(Calendar_DatePicker_DropDown) )
+ style |= wxDP_DROPDOWN;
+ if ( GetMenuBar()->IsChecked(Calendar_DatePicker_AllowNone) )
+ {
+ style |= wxDP_ALLOWNONE;
+
+ if ( GetMenuBar()->IsChecked(Calendar_DatePicker_StartWithNone) )
+ dt = wxDefaultDateTime;
+ }
+
+ MyDialog dlg(this, dt, style);
+ if ( dlg.ShowModal() == wxID_OK )
+ {
+ dt = dlg.GetDate();
+ if ( dt.IsValid() )
+ {
+ const wxDateTime today = wxDateTime::Today();
+
+ if ( dt.GetDay() == today.GetDay() &&
+ dt.GetMonth() == today.GetMonth() )
+ {
+ wxMessageBox(_T("Happy birthday!"), _T("Calendar Sample"));
+ }
+
+ m_panel->SetDate(dt);
+
+ wxLogStatus(_T("Changed the date to your input"));
+ }
+ else
+ {
+ wxLogStatus(_T("No date entered"));
+ }
+ }
+}
+
+#endif // wxUSE_DATEPICKCTRL
+