1 ///////////////////////////////////////////////////////////////////////////////
3 // Purpose: date-picker control
4 // Author: Vadim Zeitlin
8 // Copyright: (c) 1999 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
9 // Licence: wxWindows license
10 ///////////////////////////////////////////////////////////////////////////////
15 1. implement multiple selections for date ranges
16 2. background bitmap for the calendar?
19 #ifndef _WX_CALCTRL_H_
20 #define _WX_CALCTRL_H_
24 #if wxUSE_CALENDARCTRL
26 #include "wx/datetime.h"
28 // ----------------------------------------------------------------------------
29 // wxCalendarCtrl flags
30 // ----------------------------------------------------------------------------
34 // show Sunday as the first day of the week (default)
35 wxCAL_SUNDAY_FIRST
= 0x0000,
37 // show Monder as the first day of the week
38 wxCAL_MONDAY_FIRST
= 0x0001,
41 wxCAL_SHOW_HOLIDAYS
= 0x0002,
43 // disable the year change control, show only the month change one
44 wxCAL_NO_YEAR_CHANGE
= 0x0004,
46 // don't allow changing neither month nor year (implies
47 // wxCAL_NO_YEAR_CHANGE)
48 wxCAL_NO_MONTH_CHANGE
= 0x000c,
50 // use MS-style month-selection instead of combo-spin combination
51 wxCAL_SEQUENTIAL_MONTH_SELECTION
= 0x0010,
53 // show the neighbouring weeks in the previous and next month
54 wxCAL_SHOW_SURROUNDING_WEEKS
= 0x0020
57 // ----------------------------------------------------------------------------
59 // ----------------------------------------------------------------------------
61 // return values for the HitTest() method
62 enum wxCalendarHitTestResult
64 wxCAL_HITTEST_NOWHERE
, // outside of anything
65 wxCAL_HITTEST_HEADER
, // on the header (weekdays)
66 wxCAL_HITTEST_DAY
, // on a day in the calendar
67 wxCAL_HITTEST_INCMONTH
,
68 wxCAL_HITTEST_DECMONTH
,
69 wxCAL_HITTEST_SURROUNDING_WEEK
72 // border types for a date
73 enum wxCalendarDateBorder
75 wxCAL_BORDER_NONE
, // no border (default)
76 wxCAL_BORDER_SQUARE
, // a rectangular border
77 wxCAL_BORDER_ROUND
// a round border
80 // ----------------------------------------------------------------------------
81 // wxCalendarDateAttr: custom attributes for a calendar date
82 // ----------------------------------------------------------------------------
84 class WXDLLEXPORT wxCalendarDateAttr
86 #if !defined(__VISAGECPP__)
88 // This has to be before the use of Init(), for MSVC++ 1.5
89 // But dorks up Visualage!
90 void Init(wxCalendarDateBorder border
= wxCAL_BORDER_NONE
)
98 wxCalendarDateAttr() { Init(); }
99 wxCalendarDateAttr(const wxColour
& colText
,
100 const wxColour
& colBack
= wxNullColour
,
101 const wxColour
& colBorder
= wxNullColour
,
102 const wxFont
& font
= wxNullFont
,
103 wxCalendarDateBorder border
= wxCAL_BORDER_NONE
)
104 : m_colText(colText
), m_colBack(colBack
),
105 m_colBorder(colBorder
), m_font(font
)
109 wxCalendarDateAttr(wxCalendarDateBorder border
,
110 const wxColour
& colBorder
= wxNullColour
)
111 : m_colBorder(colBorder
)
117 void SetTextColour(const wxColour
& colText
) { m_colText
= colText
; }
118 void SetBackgroundColour(const wxColour
& colBack
) { m_colBack
= colBack
; }
119 void SetBorderColour(const wxColour
& col
) { m_colBorder
= col
; }
120 void SetFont(const wxFont
& font
) { m_font
= font
; }
121 void SetBorder(wxCalendarDateBorder border
) { m_border
= border
; }
122 void SetHoliday(bool holiday
) { m_holiday
= holiday
; }
125 bool HasTextColour() const { return m_colText
.Ok(); }
126 bool HasBackgroundColour() const { return m_colBack
.Ok(); }
127 bool HasBorderColour() const { return m_colBorder
.Ok(); }
128 bool HasFont() const { return m_font
.Ok(); }
129 bool HasBorder() const { return m_border
!= wxCAL_BORDER_NONE
; }
131 bool IsHoliday() const { return m_holiday
; }
133 const wxColour
& GetTextColour() const { return m_colText
; }
134 const wxColour
& GetBackgroundColour() const { return m_colBack
; }
135 const wxColour
& GetBorderColour() const { return m_colBorder
; }
136 const wxFont
& GetFont() const { return m_font
; }
137 wxCalendarDateBorder
GetBorder() const { return m_border
; }
138 #if defined(__VISAGECPP__)
140 // This has to be here for VisualAge
141 void Init(wxCalendarDateBorder border
= wxCAL_BORDER_NONE
)
152 wxCalendarDateBorder m_border
;
156 // ----------------------------------------------------------------------------
157 // wxCalendarCtrl events
158 // ----------------------------------------------------------------------------
160 class WXDLLEXPORT wxCalendarCtrl
;
162 class WXDLLEXPORT wxCalendarEvent
: public wxCommandEvent
164 friend class wxCalendarCtrl
;
166 wxCalendarEvent() { Init(); }
167 wxCalendarEvent(wxCalendarCtrl
*cal
, wxEventType type
);
169 const wxDateTime
& GetDate() const { return m_date
; }
170 wxDateTime::WeekDay
GetWeekDay() const { return m_wday
; }
177 wxDateTime::WeekDay m_wday
;
179 DECLARE_DYNAMIC_CLASS(wxCalendarEvent
)
182 // ----------------------------------------------------------------------------
184 // ----------------------------------------------------------------------------
186 // so far we only have a generic version, so keep it simple
187 #include "wx/generic/calctrl.h"
189 // ----------------------------------------------------------------------------
190 // calendar event types and macros for handling them
191 // ----------------------------------------------------------------------------
193 BEGIN_DECLARE_EVENT_TYPES()
194 DECLARE_EVENT_TYPE(wxEVT_CALENDAR_SEL_CHANGED
, 950)
195 DECLARE_EVENT_TYPE(wxEVT_CALENDAR_DAY_CHANGED
, 951)
196 DECLARE_EVENT_TYPE(wxEVT_CALENDAR_MONTH_CHANGED
, 952)
197 DECLARE_EVENT_TYPE(wxEVT_CALENDAR_YEAR_CHANGED
, 953)
198 DECLARE_EVENT_TYPE(wxEVT_CALENDAR_DOUBLECLICKED
, 954)
199 DECLARE_EVENT_TYPE(wxEVT_CALENDAR_WEEKDAY_CLICKED
, 955)
200 END_DECLARE_EVENT_TYPES()
202 typedef void (wxEvtHandler::*wxCalendarEventFunction
)(wxCalendarEvent
&);
204 #define EVT_CALENDAR(id, fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_CALENDAR_DOUBLECLICKED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) (wxCalendarEventFunction) & fn, (wxObject *) NULL),
205 #define EVT_CALENDAR_SEL_CHANGED(id, fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_CALENDAR_SEL_CHANGED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) (wxCalendarEventFunction) & fn, (wxObject *) NULL),
206 #define EVT_CALENDAR_DAY(id, fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_CALENDAR_DAY_CHANGED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) (wxCalendarEventFunction) & fn, (wxObject *) NULL),
207 #define EVT_CALENDAR_MONTH(id, fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_CALENDAR_MONTH_CHANGED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) (wxCalendarEventFunction) & fn, (wxObject *) NULL),
208 #define EVT_CALENDAR_YEAR(id, fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_CALENDAR_YEAR_CHANGED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) (wxCalendarEventFunction) & fn, (wxObject *) NULL),
209 #define EVT_CALENDAR_WEEKDAY_CLICKED(id, fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_CALENDAR_WEEKDAY_CLICKED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) (wxCalendarEventFunction) & fn, (wxObject *) NULL),
211 #endif // wxUSE_CALENDARCTRL
213 #endif // _WX_CALCTRL_H_