]> git.saurik.com Git - wxWidgets.git/blob - src/common/calctrlcmn.cpp
fix bugs introduced in wxCmdLineParser::ConvertStringToArgs() during Unicode transiti...
[wxWidgets.git] / src / common / calctrlcmn.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: common/calctrlcmn.cpp
3 // Author: Marcin Wojdyr
4 // Created: 2008-03-26
5 // RCS-ID: $Id$
6 // Copyright: (C) Marcin Wojdyr
7 // Licence: wxWindows licence
8 ///////////////////////////////////////////////////////////////////////////////
9
10 #include "wx/wxprec.h"
11
12 #ifdef __BORLANDC__
13 #pragma hdrstop
14 #endif
15
16 #ifndef WX_PRECOMP
17 #endif //WX_PRECOMP
18
19 #if wxUSE_CALENDARCTRL || wxUSE_DATEPICKCTRL
20
21 #include "wx/dateevt.h"
22 IMPLEMENT_DYNAMIC_CLASS(wxDateEvent, wxCommandEvent)
23 DEFINE_EVENT_TYPE(wxEVT_DATE_CHANGED)
24
25 #endif // wxUSE_CALENDARCTRL || wxUSE_DATEPICKCTRL
26
27
28 #if wxUSE_CALENDARCTRL
29
30 #include "wx/calctrl.h"
31
32 // ----------------------------------------------------------------------------
33 // events
34 // ----------------------------------------------------------------------------
35 IMPLEMENT_DYNAMIC_CLASS(wxCalendarEvent, wxDateEvent)
36
37 DEFINE_EVENT_TYPE(wxEVT_CALENDAR_SEL_CHANGED)
38 DEFINE_EVENT_TYPE(wxEVT_CALENDAR_PAGE_CHANGED)
39 DEFINE_EVENT_TYPE(wxEVT_CALENDAR_DOUBLECLICKED)
40 DEFINE_EVENT_TYPE(wxEVT_CALENDAR_WEEKDAY_CLICKED)
41
42 // deprecated events
43 DEFINE_EVENT_TYPE(wxEVT_CALENDAR_DAY_CHANGED)
44 DEFINE_EVENT_TYPE(wxEVT_CALENDAR_MONTH_CHANGED)
45 DEFINE_EVENT_TYPE(wxEVT_CALENDAR_YEAR_CHANGED)
46
47
48 wxCalendarDateAttr wxCalendarDateAttr::m_mark(wxCAL_BORDER_SQUARE);
49
50 bool wxCalendarCtrlBase::EnableMonthChange(bool enable)
51 {
52 const long styleOrig = GetWindowStyle();
53 long style = enable ? styleOrig & ~wxCAL_NO_MONTH_CHANGE
54 : styleOrig | wxCAL_NO_MONTH_CHANGE;
55 if ( style == styleOrig )
56 return false;
57
58 SetWindowStyle(style);
59
60 return true;
61 }
62
63 void wxCalendarCtrlBase::GenerateAllChangeEvents(const wxDateTime& dateOld)
64 {
65 const wxDateTime::Tm tm1 = dateOld.GetTm(),
66 tm2 = GetDate().GetTm();
67
68 GenerateEvent(wxEVT_CALENDAR_SEL_CHANGED);
69 if ( tm1.year != tm2.year || tm1.mon != tm2.mon )
70 GenerateEvent(wxEVT_CALENDAR_PAGE_CHANGED);
71
72 // send also one of the deprecated events
73 if ( tm1.year != tm2.year )
74 GenerateEvent(wxEVT_CALENDAR_YEAR_CHANGED);
75 else if ( tm1.mon != tm2.mon )
76 GenerateEvent(wxEVT_CALENDAR_MONTH_CHANGED);
77 else
78 GenerateEvent(wxEVT_CALENDAR_DAY_CHANGED);
79 }
80
81 #endif // wxUSE_CALENDARCTRL
82