void OnChar(wxKeyEvent& event);
void OnMonthChange(wxCommandEvent& event);
void OnYearChange(wxSpinEvent& event);
- void OnCalMonthChange(wxCalendarEvent& event);
// override some base class virtuals
virtual wxSize DoGetBestSize() const;
void OnCalendar(wxCalendarEvent& event);
void OnCalendarWeekDayClick(wxCalendarEvent& event);
void OnCalendarChange(wxCalendarEvent& event);
+ void OnCalMonthChange(wxCalendarEvent& event);
+ void OnCalYearChange(wxCalendarEvent& event);
wxCalendarCtrl *GetCal() const { return m_calendar; }
BEGIN_EVENT_TABLE(MyPanel, wxPanel)
EVT_CALENDAR (Calendar_CalCtrl, MyPanel::OnCalendar)
+ EVT_CALENDAR_MONTH (Calendar_CalCtrl, MyPanel::OnCalMonthChange)
+ EVT_CALENDAR_YEAR (Calendar_CalCtrl, MyPanel::OnCalYearChange)
EVT_CALENDAR_SEL_CHANGED(Calendar_CalCtrl, MyPanel::OnCalendarChange)
EVT_CALENDAR_WEEKDAY_CLICKED(Calendar_CalCtrl, MyPanel::OnCalendarWeekDayClick)
END_EVENT_TABLE()
m_date->SetLabel(s);
}
+void MyPanel::OnCalMonthChange(wxCalendarEvent& WXUNUSED(event))
+{
+ wxLogStatus("Calendar month changed");
+}
+
+void MyPanel::OnCalYearChange(wxCalendarEvent& WXUNUSED(event))
+{
+ wxLogStatus("Calendar year changed");
+}
+
void MyPanel::OnCalendarWeekDayClick(wxCalendarEvent& event)
{
wxLogMessage("Clicked on %s",
}
}
+static void TestTimeHolidays()
+{
+ puts("\n*** testing wxDateTimeHolidayAuthority ***\n");
+
+ wxDateTime::Tm tm = wxDateTime(29, wxDateTime::May, 2000).GetTm();
+ wxDateTime dtStart(1, tm.mon, tm.year),
+ dtEnd = dtStart.GetLastMonthDay();
+
+ wxDateTimeArray hol;
+ wxDateTimeHolidayAuthority::GetHolidaysInRange(dtStart, dtEnd, hol);
+
+ const wxChar *format = "%d-%b-%Y (%a)";
+
+ printf("All holidays between %s and %s:\n",
+ dtStart.Format(format).c_str(), dtEnd.Format(format).c_str());
+
+ size_t count = hol.GetCount();
+ for ( size_t n = 0; n < count; n++ )
+ {
+ printf("\t%s\n", hol[n].Format(format).c_str());
+ }
+
+ puts("");
+}
+
#if 0
// test compatibility with the old wxDate/wxTime classes
fprintf(stderr, "Failed to initialize the wxWindows library, aborting.");
}
+#ifdef TEST_USLEEP
+ puts("Sleeping for 3 seconds... z-z-z-z-z...");
+ wxUsleep(3000);
+#endif // TEST_USLEEP
+
#ifdef TEST_CMDLINE
static const wxCmdLineEntryDesc cmdLineDesc[] =
{
#endif // TEST_MIME
#ifdef TEST_TIME
- if ( 1 )
+ if ( 0 )
{
TestTimeSet();
TestTimeStatic();
TestTimeFormat();
TestTimeArithmetics();
}
+ TestTimeHolidays();
if ( 0 )
TestInteractive();
#endif // TEST_TIME
#ifdef __WXDEBUG__
extern const wxChar *wxDumpDate(const wxDateTime* dt)
{
- static wxChar buf[20];
+ static wxChar buf[128];
wxStrcpy(buf, dt->Format(_T("%Y-%m-%d (%a) %H:%M:%S")));
EVT_LEFT_DOWN(wxCalendarCtrl::OnClick)
EVT_LEFT_DCLICK(wxCalendarCtrl::OnDClick)
-
- EVT_CALENDAR_MONTH(-1, wxCalendarCtrl::OnCalMonthChange)
- EVT_CALENDAR_YEAR(-1, wxCalendarCtrl::OnCalMonthChange)
END_EVENT_TABLE()
BEGIN_EVENT_TABLE(wxMonthComboBox, wxComboBox)
m_spinYear->SetValue(m_date.Format(_T("%Y")));
}
+ // as the month changed, holidays did too
+ SetHolidayAttrs();
+
// update the calendar
Refresh();
}
tm.mday = wxDateTime::GetNumberOfDays(mon, tm.year);
}
- SetDate(wxDateTime(tm.mday, mon, tm.year));
-
- GenerateEvents(wxEVT_CALENDAR_MONTH_CHANGED, wxEVT_CALENDAR_SEL_CHANGED);
+ SetDateAndNotify(wxDateTime(tm.mday, mon, tm.year));
}
void wxCalendarCtrl::OnYearChange(wxSpinEvent& event)
tm.mday = wxDateTime::GetNumberOfDays(tm.mon, year);
}
- SetDate(wxDateTime(tm.mday, tm.mon, year));
-
- GenerateEvents(wxEVT_CALENDAR_YEAR_CHANGED, wxEVT_CALENDAR_SEL_CHANGED);
+ SetDateAndNotify(wxDateTime(tm.mday, tm.mon, year));
}
// ----------------------------------------------------------------------------
// holidays handling
// ----------------------------------------------------------------------------
-void wxCalendarCtrl::OnCalMonthChange(wxCalendarEvent& event)
-{
- SetHolidayAttrs();
-
- event.Skip();
-}
-
void wxCalendarCtrl::EnableHolidayDisplay(bool display)
{
long style = GetWindowStyle();