+// Toggle a restricted date range to the six months centered on today's date.
+void MyPanel::LimitDateRange(bool on)
+{
+ if ( on )
+ {
+ // limit the choice of date to 3 months around today
+ const wxDateSpan diff = wxDateSpan::Months(3);
+ const wxDateTime today = wxDateTime::Today();
+
+ // Set the restricted date range.
+ if ( m_calendar->SetDateRange(today - diff, today + diff) )
+ {
+ wxLogStatus("Date range limited to 3 months around today.");
+ }
+ else
+ {
+ wxLogWarning("Date range not supported.");
+ }
+ }
+ else // off
+ {
+ // Remove the date restrictions.
+ if ( m_calendar->SetDateRange() )
+ {
+ wxLogStatus("Date choice is unlimited now.");
+ }
+ else
+ {
+ wxLogWarning("Date range not supported.");
+ }
+ }
+
+ m_calendar->Refresh();
+}