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
50 #if !defined(__VISAGECPP__)
52 // This has to be before the use of Init(), for MSVC++ 1.5
53 // But dorks up Visualage!
54 void Init(wxCalendarDateBorder border
= wxCAL_BORDER_NONE
)
62 wxCalendarDateAttr() { Init(); }
63 wxCalendarDateAttr(const wxColour
& colText
,
64 const wxColour
& colBack
= wxNullColour
,
65 const wxColour
& colBorder
= wxNullColour
,
66 const wxFont
& font
= wxNullFont
,
67 wxCalendarDateBorder border
= wxCAL_BORDER_NONE
)
68 : m_colText(colText
), m_colBack(colBack
),
69 m_colBorder(colBorder
), m_font(font
)
73 wxCalendarDateAttr(wxCalendarDateBorder border
,
74 const wxColour
& colBorder
= wxNullColour
)
75 : m_colBorder(colBorder
)
81 void SetTextColour(const wxColour
& colText
) { m_colText
= colText
; }
82 void SetBackgroundColour(const wxColour
& colBack
) { m_colBack
= colBack
; }
83 void SetBorderColour(const wxColour
& col
) { m_colBorder
= col
; }
84 void SetFont(const wxFont
& font
) { m_font
= font
; }
85 void SetBorder(wxCalendarDateBorder border
) { m_border
= border
; }
86 void SetHoliday(bool holiday
) { m_holiday
= holiday
; }
89 bool HasTextColour() const { return m_colText
.Ok(); }
90 bool HasBackgroundColour() const { return m_colBack
.Ok(); }
91 bool HasBorderColour() const { return m_colBorder
.Ok(); }
92 bool HasFont() const { return m_font
.Ok(); }
93 bool HasBorder() const { return m_border
!= wxCAL_BORDER_NONE
; }
95 bool IsHoliday() const { return m_holiday
; }
97 const wxColour
& GetTextColour() const { return m_colText
; }
98 const wxColour
& GetBackgroundColour() const { return m_colBack
; }
99 const wxColour
& GetBorderColour() const { return m_colBorder
; }
100 const wxFont
& GetFont() const { return m_font
; }
101 wxCalendarDateBorder
GetBorder() const { return m_border
; }
102 #if defined(__VISAGECPP__)
104 // This has to be here for VisualAge
105 void Init(wxCalendarDateBorder border
= wxCAL_BORDER_NONE
)
116 wxCalendarDateBorder m_border
;
120 // ----------------------------------------------------------------------------
121 // wxCalendarCtrl events
122 // ----------------------------------------------------------------------------
124 class WXDLLEXPORT wxCalendarCtrl
;
126 class WXDLLEXPORT wxCalendarEvent
: public wxCommandEvent
128 friend class wxCalendarCtrl
;
130 wxCalendarEvent() { Init(); }
131 wxCalendarEvent(wxCalendarCtrl
*cal
, wxEventType type
);
133 const wxDateTime
& GetDate() const { return m_date
; }
134 wxDateTime::WeekDay
GetWeekDay() const { return m_wday
; }
141 wxDateTime::WeekDay m_wday
;
144 // ----------------------------------------------------------------------------
146 // ----------------------------------------------------------------------------
148 // so far we only have a generic version, so keep it simple
149 #include "wx/generic/calctrl.h"
151 // ----------------------------------------------------------------------------
152 // calendar events macros
153 // ----------------------------------------------------------------------------
155 #define EVT_CALENDAR(id, fn) { wxEVT_CALENDAR_DOUBLECLICKED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL },
156 #define EVT_CALENDAR_SEL_CHANGED(id, fn) { wxEVT_CALENDAR_SEL_CHANGED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL },
157 #define EVT_CALENDAR_DAY(id, fn) { wxEVT_CALENDAR_DAY_CHANGED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL },
158 #define EVT_CALENDAR_MONTH(id, fn) { wxEVT_CALENDAR_MONTH_CHANGED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL },
159 #define EVT_CALENDAR_YEAR(id, fn) { wxEVT_CALENDAR_YEAR_CHANGED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL },
160 #define EVT_CALENDAR_WEEKDAY_CLICKED(id, fn) { wxEVT_CALENDAR_WEEKDAY_CLICKED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL },
162 #endif // _WX_CALCTRL_H