+void wxGtkCalendarCtrl::GTKGenerateEvent(wxEventType type)
+{
+ // First check if the new date is in the specified range.
+ wxDateTime dt = GetDate();
+ if ( !IsInValidRange(dt) )
+ {
+ if ( m_validStart.IsValid() && dt < m_validStart )
+ dt = m_validStart;
+ else
+ dt = m_validEnd;
+
+ SetDate(dt);
+
+ return;
+ }
+
+ if ( type == wxEVT_CALENDAR_SEL_CHANGED )
+ {
+ // Don't generate this event if the new date is the same as the old
+ // one.
+ if ( m_selectedDate == dt )
+ return;
+
+ m_selectedDate = dt;
+
+ GenerateEvent(type);
+
+ // Also send the deprecated event together with the new one.
+ GenerateEvent(wxEVT_CALENDAR_DAY_CHANGED);
+ }
+ else
+ {
+ GenerateEvent(type);
+ }
+}
+
+bool wxGtkCalendarCtrl::IsInValidRange(const wxDateTime& dt) const
+{
+ return (!m_validStart.IsValid() || m_validStart <= dt) &&
+ (!m_validEnd.IsValid() || dt <= m_validEnd);
+}
+
+bool
+wxGtkCalendarCtrl::SetDateRange(const wxDateTime& lowerdate,
+ const wxDateTime& upperdate)
+{
+ if ( lowerdate.IsValid() && upperdate.IsValid() && lowerdate >= upperdate )
+ return false;
+
+ m_validStart = lowerdate;
+ m_validEnd = upperdate;
+
+ return true;
+}
+
+bool
+wxGtkCalendarCtrl::GetDateRange(wxDateTime *lowerdate,
+ wxDateTime *upperdate) const
+{
+ if ( lowerdate )
+ *lowerdate = m_validStart;
+ if ( upperdate )
+ *upperdate = m_validEnd;
+
+ return m_validStart.IsValid() || m_validEnd.IsValid();
+}
+
+