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?
22 #include "wx/datetime.h"
24 // ----------------------------------------------------------------------------
26 // ----------------------------------------------------------------------------
28 // return values for the HitTest() method
29 enum wxCalendarHitTestResult
31 wxCAL_HITTEST_NOWHERE
, // outside of anything
32 wxCAL_HITTEST_HEADER
, // on the header (weekdays)
33 wxCAL_HITTEST_DAY
// on a day in the calendar
36 // border types for a date
37 enum wxCalendarDateBorder
39 wxCAL_BORDER_NONE
, // no border (default)
40 wxCAL_BORDER_SQUARE
, // a rectangular border
41 wxCAL_BORDER_ROUND
// a round border
44 // ----------------------------------------------------------------------------
45 // wxCalendarDateAttr: custom attributes for a calendar date
46 // ----------------------------------------------------------------------------
48 class WXDLLEXPORT wxCalendarDateAttr
51 // This has to be before the use of Init(), for MSVC++ 1.5
52 void Init(wxCalendarDateBorder border
= wxCAL_BORDER_NONE
)
60 wxCalendarDateAttr() { Init(); }
61 wxCalendarDateAttr(const wxColour
& colText
,
62 const wxColour
& colBack
= wxNullColour
,
63 const wxColour
& colBorder
= wxNullColour
,
64 const wxFont
& font
= wxNullFont
,
65 wxCalendarDateBorder border
= wxCAL_BORDER_NONE
)
66 : m_colText(colText
), m_colBack(colBack
),
67 m_colBorder(colBorder
), m_font(font
)
71 wxCalendarDateAttr(wxCalendarDateBorder border
,
72 const wxColour
& colBorder
= wxNullColour
)
73 : m_colBorder(colBorder
)
79 void SetTextColour(const wxColour
& colText
) { m_colText
= colText
; }
80 void SetBackgroundColour(const wxColour
& colBack
) { m_colBack
= colBack
; }
81 void SetBorderColour(const wxColour
& col
) { m_colBorder
= col
; }
82 void SetFont(const wxFont
& font
) { m_font
= font
; }
83 void SetBorder(wxCalendarDateBorder border
) { m_border
= border
; }
84 void SetHoliday(bool holiday
) { m_holiday
= holiday
; }
87 bool HasTextColour() const { return m_colText
.Ok(); }
88 bool HasBackgroundColour() const { return m_colBack
.Ok(); }
89 bool HasBorderColour() const { return m_colBorder
.Ok(); }
90 bool HasFont() const { return m_font
.Ok(); }
91 bool HasBorder() const { return m_border
!= wxCAL_BORDER_NONE
; }
93 bool IsHoliday() const { return m_holiday
; }
95 const wxColour
& GetTextColour() const { return m_colText
; }
96 const wxColour
& GetBackgroundColour() const { return m_colBack
; }
97 const wxColour
& GetBorderColour() const { return m_colBorder
; }
98 const wxFont
& GetFont() const { return m_font
; }
99 wxCalendarDateBorder
GetBorder() const { return m_border
; }
106 wxCalendarDateBorder m_border
;
110 // ----------------------------------------------------------------------------
111 // wxCalendarCtrl events
112 // ----------------------------------------------------------------------------
114 class WXDLLEXPORT wxCalendarCtrl
;
116 class WXDLLEXPORT wxCalendarEvent
: public wxCommandEvent
118 friend class wxCalendarCtrl
;
120 wxCalendarEvent() { Init(); }
121 wxCalendarEvent(wxCalendarCtrl
*cal
, wxEventType type
);
123 const wxDateTime
& GetDate() const { return m_date
; }
124 wxDateTime::WeekDay
GetWeekDay() const { return m_wday
; }
131 wxDateTime::WeekDay m_wday
;
134 // ----------------------------------------------------------------------------
136 // ----------------------------------------------------------------------------
138 // so far we only have a generic version, so keep it simple
139 #include "wx/generic/calctrl.h"
141 // ----------------------------------------------------------------------------
142 // calendar events macros
143 // ----------------------------------------------------------------------------
145 #define EVT_CALENDAR(id, fn) { wxEVT_CALENDAR_DOUBLECLICKED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL },
146 #define EVT_CALENDAR_SEL_CHANGED(id, fn) { wxEVT_CALENDAR_SEL_CHANGED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL },
147 #define EVT_CALENDAR_DAY(id, fn) { wxEVT_CALENDAR_DAY_CHANGED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL },
148 #define EVT_CALENDAR_MONTH(id, fn) { wxEVT_CALENDAR_MONTH_CHANGED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL },
149 #define EVT_CALENDAR_YEAR(id, fn) { wxEVT_CALENDAR_YEAR_CHANGED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL },
150 #define EVT_CALENDAR_WEEKDAY_CLICKED(id, fn) { wxEVT_CALENDAR_WEEKDAY_CLICKED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL },
152 #endif // _WX_CALCTRL_H