]> git.saurik.com Git - wxWidgets.git/blob - include/wx/calctrl.h
added wx/defs.h include to correct compilation issues under Mac OS X
[wxWidgets.git] / include / wx / calctrl.h
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/calctrl.h
3 // Purpose: date-picker control
4 // Author: Vadim Zeitlin
5 // Modified by:
6 // Created: 29.12.99
7 // RCS-ID: $Id$
8 // Copyright: (c) 1999 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
9 // Licence: wxWindows license
10 ///////////////////////////////////////////////////////////////////////////////
11
12 /*
13 TODO
14
15 1. implement multiple selections for date ranges
16 2. background bitmap for the calendar?
17 */
18
19 #ifndef _WX_CALCTRL_H_
20 #define _WX_CALCTRL_H_
21
22 #include "wx/defs.h"
23
24 #if wxUSE_CALENDARCTRL
25
26 #include "wx/datetime.h"
27
28 // ----------------------------------------------------------------------------
29 // constants
30 // ----------------------------------------------------------------------------
31
32 // return values for the HitTest() method
33 enum wxCalendarHitTestResult
34 {
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
38 };
39
40 // border types for a date
41 enum wxCalendarDateBorder
42 {
43 wxCAL_BORDER_NONE, // no border (default)
44 wxCAL_BORDER_SQUARE, // a rectangular border
45 wxCAL_BORDER_ROUND // a round border
46 };
47
48 // ----------------------------------------------------------------------------
49 // wxCalendarDateAttr: custom attributes for a calendar date
50 // ----------------------------------------------------------------------------
51
52 class WXDLLEXPORT wxCalendarDateAttr
53 {
54 #if !defined(__VISAGECPP__)
55 protected:
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)
59 {
60 m_border = border;
61 m_holiday = FALSE;
62 }
63 #endif
64 public:
65 // ctors
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)
74 {
75 Init(border);
76 }
77 wxCalendarDateAttr(wxCalendarDateBorder border,
78 const wxColour& colBorder = wxNullColour)
79 : m_colBorder(colBorder)
80 {
81 Init(border);
82 }
83
84 // setters
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; }
91
92 // accessors
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; }
98
99 bool IsHoliday() const { return m_holiday; }
100
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__)
107 protected:
108 // This has to be here for VisualAge
109 void Init(wxCalendarDateBorder border = wxCAL_BORDER_NONE)
110 {
111 m_border = border;
112 m_holiday = FALSE;
113 }
114 #endif
115 private:
116 wxColour m_colText,
117 m_colBack,
118 m_colBorder;
119 wxFont m_font;
120 wxCalendarDateBorder m_border;
121 bool m_holiday;
122 };
123
124 // ----------------------------------------------------------------------------
125 // wxCalendarCtrl events
126 // ----------------------------------------------------------------------------
127
128 class WXDLLEXPORT wxCalendarCtrl;
129
130 class WXDLLEXPORT wxCalendarEvent : public wxCommandEvent
131 {
132 friend class wxCalendarCtrl;
133 public:
134 wxCalendarEvent() { Init(); }
135 wxCalendarEvent(wxCalendarCtrl *cal, wxEventType type);
136
137 const wxDateTime& GetDate() const { return m_date; }
138 wxDateTime::WeekDay GetWeekDay() const { return m_wday; }
139
140 protected:
141 void Init();
142
143 private:
144 wxDateTime m_date;
145 wxDateTime::WeekDay m_wday;
146
147 DECLARE_DYNAMIC_CLASS(wxCalendarEvent)
148 };
149
150 // ----------------------------------------------------------------------------
151 // wxCalendarCtrl
152 // ----------------------------------------------------------------------------
153
154 // so far we only have a generic version, so keep it simple
155 #include "wx/generic/calctrl.h"
156
157 // ----------------------------------------------------------------------------
158 // calendar event types and macros for handling them
159 // ----------------------------------------------------------------------------
160
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()
169
170 typedef void (wxEvtHandler::*wxCalendarEventFunction)(wxCalendarEvent&);
171
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),
178
179 #endif // wxUSE_CALENDARCTRL
180
181 #endif // _WX_CALCTRL_H_
182