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
52 wxCalendarDateAttr() { Init(); }
53 wxCalendarDateAttr(const wxColour
& colText
,
54 const wxColour
& colBack
= wxNullColour
,
55 const wxColour
& colBorder
= wxNullColour
,
56 const wxFont
& font
= wxNullFont
,
57 wxCalendarDateBorder border
= wxCAL_BORDER_NONE
)
58 : m_colText(colText
), m_colBack(colBack
),
59 m_colBorder(colBorder
), m_font(font
)
63 wxCalendarDateAttr(wxCalendarDateBorder border
,
64 const wxColour
& colBorder
= wxNullColour
)
65 : m_colBorder(colBorder
)
71 void SetTextColour(const wxColour
& colText
) { m_colText
= colText
; }
72 void SetBackgroundColour(const wxColour
& colBack
) { m_colBack
= colBack
; }
73 void SetBorderColour(const wxColour
& col
) { m_colBorder
= col
; }
74 void SetFont(const wxFont
& font
) { m_font
= font
; }
75 void SetBorder(wxCalendarDateBorder border
) { m_border
= border
; }
76 void SetHoliday(bool holiday
) { m_holiday
= holiday
; }
79 bool HasTextColour() const { return m_colText
.Ok(); }
80 bool HasBackgroundColour() const { return m_colBack
.Ok(); }
81 bool HasBorderColour() const { return m_colBorder
.Ok(); }
82 bool HasFont() const { return m_font
.Ok(); }
83 bool HasBorder() const { return m_border
!= wxCAL_BORDER_NONE
; }
85 bool IsHoliday() const { return m_holiday
; }
87 const wxColour
& GetTextColour() const { return m_colText
; }
88 const wxColour
& GetBackgroundColour() const { return m_colBack
; }
89 const wxColour
& GetBorderColour() const { return m_colBorder
; }
90 const wxFont
& GetFont() const { return m_font
; }
91 wxCalendarDateBorder
GetBorder() const { return m_border
; }
94 void Init(wxCalendarDateBorder border
= wxCAL_BORDER_NONE
)
105 wxCalendarDateBorder m_border
;
109 // ----------------------------------------------------------------------------
110 // wxCalendarCtrl events
111 // ----------------------------------------------------------------------------
113 class WXDLLEXPORT wxCalendarCtrl
;
115 class WXDLLEXPORT wxCalendarEvent
: public wxCommandEvent
117 friend class wxCalendarCtrl
;
119 wxCalendarEvent() { Init(); }
120 wxCalendarEvent(wxCalendarCtrl
*cal
, wxEventType type
);
122 const wxDateTime
& GetDate() const { return m_date
; }
123 wxDateTime::WeekDay
GetWeekDay() const { return m_wday
; }
130 wxDateTime::WeekDay m_wday
;
133 // ----------------------------------------------------------------------------
135 // ----------------------------------------------------------------------------
137 // so far we only have a generic version, so keep it simple
138 #include "wx/generic/calctrl.h"
140 // ----------------------------------------------------------------------------
141 // calendar events macros
142 // ----------------------------------------------------------------------------
144 #define EVT_CALENDAR(id, fn) { wxEVT_CALENDAR_DOUBLECLICKED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL },
145 #define EVT_CALENDAR_SEL_CHANGED(id, fn) { wxEVT_CALENDAR_SEL_CHANGED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL },
146 #define EVT_CALENDAR_DAY(id, fn) { wxEVT_CALENDAR_DAY_CHANGED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL },
147 #define EVT_CALENDAR_MONTH(id, fn) { wxEVT_CALENDAR_MONTH_CHANGED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL },
148 #define EVT_CALENDAR_YEAR(id, fn) { wxEVT_CALENDAR_YEAR_CHANGED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL },
149 #define EVT_CALENDAR_WEEKDAY_CLICKED(id, fn) { wxEVT_CALENDAR_WEEKDAY_CLICKED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL },
151 #endif // _WX_CALCTRL_H