X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/d7b20621ef1170ed3c505f65d77227cf18c80499..94929e7b60de96bd3b064984ae8995d665329411:/src/generic/calctrlg.cpp?ds=sidebyside diff --git a/src/generic/calctrlg.cpp b/src/generic/calctrlg.cpp index 2370792bd6..40b9f06cd3 100644 --- a/src/generic/calctrlg.cpp +++ b/src/generic/calctrlg.cpp @@ -347,7 +347,7 @@ void wxGenericCalendarCtrl::CreateYearSpinCtrl() NULL, this); m_spinYear->Connect(m_spinYear->GetId(), wxEVT_COMMAND_SPINCTRL_UPDATED, - wxCommandEventHandler(wxGenericCalendarCtrl::OnYearChange), + wxSpinEventHandler(wxGenericCalendarCtrl::OnYearChange), NULL, this); } @@ -785,7 +785,7 @@ size_t wxGenericCalendarCtrl::GetWeek(const wxDateTime& date) const wxSize wxGenericCalendarCtrl::DoGetBestSize() const { // calc the size of the calendar - wx_const_cast(wxGenericCalendarCtrl *, this)->RecalcGeometry(); + const_cast(this)->RecalcGeometry(); wxCoord width = 7*m_widthCol, height = 7*m_heightRow + m_rowOffset; @@ -1607,7 +1607,7 @@ void wxGenericCalendarCtrl::OnMonthChange(wxCommandEvent& event) SetDateAndNotify(target); } -void wxGenericCalendarCtrl::OnYearChange(wxCommandEvent& event) +void wxGenericCalendarCtrl::HandleYearChange(wxCommandEvent& event) { int year = (int)event.GetInt(); if ( year == INT_MIN ) @@ -1637,10 +1637,15 @@ void wxGenericCalendarCtrl::OnYearChange(wxCommandEvent& event) } } +void wxGenericCalendarCtrl::OnYearChange(wxSpinEvent& event) +{ + HandleYearChange( event ); +} + void wxGenericCalendarCtrl::OnYearTextChange(wxCommandEvent& event) { SetUserChangedYear(); - OnYearChange(event); + HandleYearChange(event); } // Responds to colour changes, and passes event on to children. @@ -1760,45 +1765,6 @@ void wxGenericCalendarCtrl::OnChar(wxKeyEvent& event) // holidays handling // ---------------------------------------------------------------------------- -void wxGenericCalendarCtrl::EnableHolidayDisplay(bool display) -{ - long style = GetWindowStyle(); - if ( display ) - style |= wxCAL_SHOW_HOLIDAYS; - else - style &= ~wxCAL_SHOW_HOLIDAYS; - - SetWindowStyle(style); - - if ( display ) - SetHolidayAttrs(); - else - ResetHolidayAttrs(); - - Refresh(); -} - -void wxGenericCalendarCtrl::SetHolidayAttrs() -{ - if ( GetWindowStyle() & wxCAL_SHOW_HOLIDAYS ) - { - ResetHolidayAttrs(); - - wxDateTime::Tm tm = m_date.GetTm(); - wxDateTime dtStart(1, tm.mon, tm.year), - dtEnd = dtStart.GetLastMonthDay(); - - wxDateTimeArray hol; - wxDateTimeHolidayAuthority::GetHolidaysInRange(dtStart, dtEnd, hol); - - size_t count = hol.GetCount(); - for ( size_t n = 0; n < count; n++ ) - { - SetHoliday(hol[n].GetDay()); - } - } -} - void wxGenericCalendarCtrl::SetHoliday(size_t day) { wxCHECK_RET( day > 0 && day < 32, _T("invalid day in SetHoliday") );