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 // ----------------------------------------------------------------------------
30 // ----------------------------------------------------------------------------
32 // return values for the HitTest() method
33 enum wxCalendarHitTestResult
35 wxCAL_HITTEST_NOWHERE
, // outside of anything
36 wxCAL_HITTEST_HEADER
, // on the header (weekdays)
37 wxCAL_HITTEST_DAY
// on a day in the calendar
40 // border types for a date
41 enum wxCalendarDateBorder
43 wxCAL_BORDER_NONE
, // no border (default)
44 wxCAL_BORDER_SQUARE
, // a rectangular border
45 wxCAL_BORDER_ROUND
// a round border
48 // ----------------------------------------------------------------------------
49 // wxCalendarDateAttr: custom attributes for a calendar date
50 // ----------------------------------------------------------------------------
52 class WXDLLEXPORT wxCalendarDateAttr
54 #if !defined(__VISAGECPP__)
56 // This has to be before the use of Init(), for MSVC++ 1.5
57 // But dorks up Visualage!
58 void Init(wxCalendarDateBorder border
= wxCAL_BORDER_NONE
)
66 wxCalendarDateAttr() { Init(); }
67 wxCalendarDateAttr(const wxColour
& colText
,
68 const wxColour
& colBack
= wxNullColour
,
69 const wxColour
& colBorder
= wxNullColour
,
70 const wxFont
& font
= wxNullFont
,
71 wxCalendarDateBorder border
= wxCAL_BORDER_NONE
)
72 : m_colText(colText
), m_colBack(colBack
),
73 m_colBorder(colBorder
), m_font(font
)
77 wxCalendarDateAttr(wxCalendarDateBorder border
,
78 const wxColour
& colBorder
= wxNullColour
)
79 : m_colBorder(colBorder
)
85 void SetTextColour(const wxColour
& colText
) { m_colText
= colText
; }
86 void SetBackgroundColour(const wxColour
& colBack
) { m_colBack
= colBack
; }
87 void SetBorderColour(const wxColour
& col
) { m_colBorder
= col
; }
88 void SetFont(const wxFont
& font
) { m_font
= font
; }
89 void SetBorder(wxCalendarDateBorder border
) { m_border
= border
; }
90 void SetHoliday(bool holiday
) { m_holiday
= holiday
; }
93 bool HasTextColour() const { return m_colText
.Ok(); }
94 bool HasBackgroundColour() const { return m_colBack
.Ok(); }
95 bool HasBorderColour() const { return m_colBorder
.Ok(); }
96 bool HasFont() const { return m_font
.Ok(); }
97 bool HasBorder() const { return m_border
!= wxCAL_BORDER_NONE
; }
99 bool IsHoliday() const { return m_holiday
; }
101 const wxColour
& GetTextColour() const { return m_colText
; }
102 const wxColour
& GetBackgroundColour() const { return m_colBack
; }
103 const wxColour
& GetBorderColour() const { return m_colBorder
; }
104 const wxFont
& GetFont() const { return m_font
; }
105 wxCalendarDateBorder
GetBorder() const { return m_border
; }
106 #if defined(__VISAGECPP__)
108 // This has to be here for VisualAge
109 void Init(wxCalendarDateBorder border
= wxCAL_BORDER_NONE
)
120 wxCalendarDateBorder m_border
;
124 // ----------------------------------------------------------------------------
125 // wxCalendarCtrl events
126 // ----------------------------------------------------------------------------
128 class WXDLLEXPORT wxCalendarCtrl
;
130 class WXDLLEXPORT wxCalendarEvent
: public wxCommandEvent
132 friend class wxCalendarCtrl
;
134 wxCalendarEvent() { Init(); }
135 wxCalendarEvent(wxCalendarCtrl
*cal
, wxEventType type
);
137 const wxDateTime
& GetDate() const { return m_date
; }
138 wxDateTime::WeekDay
GetWeekDay() const { return m_wday
; }
145 wxDateTime::WeekDay m_wday
;
147 DECLARE_DYNAMIC_CLASS(wxCalendarEvent
)
150 // ----------------------------------------------------------------------------
152 // ----------------------------------------------------------------------------
154 // so far we only have a generic version, so keep it simple
155 #include "wx/generic/calctrl.h"
157 // ----------------------------------------------------------------------------
158 // calendar event types and macros for handling them
159 // ----------------------------------------------------------------------------
161 BEGIN_DECLARE_EVENT_TYPES()
162 DECLARE_EVENT_TYPE(wxEVT_CALENDAR_SEL_CHANGED
, 950)
163 DECLARE_EVENT_TYPE(wxEVT_CALENDAR_DAY_CHANGED
, 951)
164 DECLARE_EVENT_TYPE(wxEVT_CALENDAR_MONTH_CHANGED
, 952)
165 DECLARE_EVENT_TYPE(wxEVT_CALENDAR_YEAR_CHANGED
, 953)
166 DECLARE_EVENT_TYPE(wxEVT_CALENDAR_DOUBLECLICKED
, 954)
167 DECLARE_EVENT_TYPE(wxEVT_CALENDAR_WEEKDAY_CLICKED
, 955)
168 END_DECLARE_EVENT_TYPES()
170 typedef void (wxEvtHandler::*wxCalendarEventFunction
)(wxCalendarEvent
&);
172 #define EVT_CALENDAR(id, fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_CALENDAR_DOUBLECLICKED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) (wxCalendarEventFunction) & fn, (wxObject *) NULL),
173 #define EVT_CALENDAR_SEL_CHANGED(id, fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_CALENDAR_SEL_CHANGED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) (wxCalendarEventFunction) & fn, (wxObject *) NULL),
174 #define EVT_CALENDAR_DAY(id, fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_CALENDAR_DAY_CHANGED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) (wxCalendarEventFunction) & fn, (wxObject *) NULL),
175 #define EVT_CALENDAR_MONTH(id, fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_CALENDAR_MONTH_CHANGED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) (wxCalendarEventFunction) & fn, (wxObject *) NULL),
176 #define EVT_CALENDAR_YEAR(id, fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_CALENDAR_YEAR_CHANGED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) (wxCalendarEventFunction) & fn, (wxObject *) NULL),
177 #define EVT_CALENDAR_WEEKDAY_CLICKED(id, fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_CALENDAR_WEEKDAY_CLICKED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) (wxCalendarEventFunction) & fn, (wxObject *) NULL),
179 #endif // wxUSE_CALENDARCTRL
181 #endif // _WX_CALCTRL_H_