]>
Commit | Line | Data |
---|---|---|
9d9b7755 VZ |
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> | |
65571936 | 9 | // Licence: wxWindows licence |
9d9b7755 VZ |
10 | /////////////////////////////////////////////////////////////////////////////// |
11 | ||
4f6aed9c VZ |
12 | /* |
13 | TODO | |
14 | ||
15 | 1. implement multiple selections for date ranges | |
16 | 2. background bitmap for the calendar? | |
17 | */ | |
18 | ||
1e6feb95 VZ |
19 | #ifndef _WX_CALCTRL_H_ |
20 | #define _WX_CALCTRL_H_ | |
21 | ||
22 | #include "wx/defs.h" | |
23 | ||
24 | #if wxUSE_CALENDARCTRL | |
9d9b7755 | 25 | |
4f6aed9c | 26 | #include "wx/datetime.h" |
b1ef887a VS |
27 | #include "wx/colour.h" |
28 | #include "wx/font.h" | |
4f6aed9c | 29 | |
37df1f33 VZ |
30 | // ---------------------------------------------------------------------------- |
31 | // wxCalendarCtrl flags | |
32 | // ---------------------------------------------------------------------------- | |
33 | ||
34 | enum | |
35 | { | |
36 | // show Sunday as the first day of the week (default) | |
37 | wxCAL_SUNDAY_FIRST = 0x0000, | |
38 | ||
39 | // show Monder as the first day of the week | |
40 | wxCAL_MONDAY_FIRST = 0x0001, | |
41 | ||
42 | // highlight holidays | |
43 | wxCAL_SHOW_HOLIDAYS = 0x0002, | |
44 | ||
45 | // disable the year change control, show only the month change one | |
46 | wxCAL_NO_YEAR_CHANGE = 0x0004, | |
47 | ||
48 | // don't allow changing neither month nor year (implies | |
49 | // wxCAL_NO_YEAR_CHANGE) | |
50 | wxCAL_NO_MONTH_CHANGE = 0x000c, | |
51 | ||
52 | // use MS-style month-selection instead of combo-spin combination | |
53 | wxCAL_SEQUENTIAL_MONTH_SELECTION = 0x0010, | |
54 | ||
55 | // show the neighbouring weeks in the previous and next month | |
56 | wxCAL_SHOW_SURROUNDING_WEEKS = 0x0020 | |
57 | }; | |
58 | ||
0185cd09 VZ |
59 | // ---------------------------------------------------------------------------- |
60 | // constants | |
61 | // ---------------------------------------------------------------------------- | |
62 | ||
63 | // return values for the HitTest() method | |
64 | enum wxCalendarHitTestResult | |
65 | { | |
66 | wxCAL_HITTEST_NOWHERE, // outside of anything | |
67 | wxCAL_HITTEST_HEADER, // on the header (weekdays) | |
37df1f33 VZ |
68 | wxCAL_HITTEST_DAY, // on a day in the calendar |
69 | wxCAL_HITTEST_INCMONTH, | |
70 | wxCAL_HITTEST_DECMONTH, | |
71 | wxCAL_HITTEST_SURROUNDING_WEEK | |
0185cd09 VZ |
72 | }; |
73 | ||
4f6aed9c VZ |
74 | // border types for a date |
75 | enum wxCalendarDateBorder | |
76 | { | |
77 | wxCAL_BORDER_NONE, // no border (default) | |
78 | wxCAL_BORDER_SQUARE, // a rectangular border | |
79 | wxCAL_BORDER_ROUND // a round border | |
80 | }; | |
81 | ||
0185cd09 | 82 | // ---------------------------------------------------------------------------- |
4f6aed9c | 83 | // wxCalendarDateAttr: custom attributes for a calendar date |
0185cd09 VZ |
84 | // ---------------------------------------------------------------------------- |
85 | ||
12f190b0 | 86 | class WXDLLIMPEXP_ADV wxCalendarDateAttr |
4f6aed9c | 87 | { |
006713a2 | 88 | #if !defined(__VISAGECPP__) |
8caa4ed1 JS |
89 | protected: |
90 | // This has to be before the use of Init(), for MSVC++ 1.5 | |
006713a2 | 91 | // But dorks up Visualage! |
8caa4ed1 JS |
92 | void Init(wxCalendarDateBorder border = wxCAL_BORDER_NONE) |
93 | { | |
94 | m_border = border; | |
95 | m_holiday = FALSE; | |
96 | } | |
006713a2 | 97 | #endif |
4f6aed9c VZ |
98 | public: |
99 | // ctors | |
100 | wxCalendarDateAttr() { Init(); } | |
101 | wxCalendarDateAttr(const wxColour& colText, | |
102 | const wxColour& colBack = wxNullColour, | |
103 | const wxColour& colBorder = wxNullColour, | |
104 | const wxFont& font = wxNullFont, | |
105 | wxCalendarDateBorder border = wxCAL_BORDER_NONE) | |
106 | : m_colText(colText), m_colBack(colBack), | |
107 | m_colBorder(colBorder), m_font(font) | |
108 | { | |
109 | Init(border); | |
110 | } | |
111 | wxCalendarDateAttr(wxCalendarDateBorder border, | |
112 | const wxColour& colBorder = wxNullColour) | |
113 | : m_colBorder(colBorder) | |
114 | { | |
115 | Init(border); | |
116 | } | |
117 | ||
118 | // setters | |
119 | void SetTextColour(const wxColour& colText) { m_colText = colText; } | |
120 | void SetBackgroundColour(const wxColour& colBack) { m_colBack = colBack; } | |
121 | void SetBorderColour(const wxColour& col) { m_colBorder = col; } | |
122 | void SetFont(const wxFont& font) { m_font = font; } | |
123 | void SetBorder(wxCalendarDateBorder border) { m_border = border; } | |
124 | void SetHoliday(bool holiday) { m_holiday = holiday; } | |
125 | ||
126 | // accessors | |
127 | bool HasTextColour() const { return m_colText.Ok(); } | |
128 | bool HasBackgroundColour() const { return m_colBack.Ok(); } | |
129 | bool HasBorderColour() const { return m_colBorder.Ok(); } | |
130 | bool HasFont() const { return m_font.Ok(); } | |
131 | bool HasBorder() const { return m_border != wxCAL_BORDER_NONE; } | |
132 | ||
133 | bool IsHoliday() const { return m_holiday; } | |
134 | ||
135 | const wxColour& GetTextColour() const { return m_colText; } | |
136 | const wxColour& GetBackgroundColour() const { return m_colBack; } | |
137 | const wxColour& GetBorderColour() const { return m_colBorder; } | |
138 | const wxFont& GetFont() const { return m_font; } | |
139 | wxCalendarDateBorder GetBorder() const { return m_border; } | |
006713a2 DW |
140 | #if defined(__VISAGECPP__) |
141 | protected: | |
142 | // This has to be here for VisualAge | |
143 | void Init(wxCalendarDateBorder border = wxCAL_BORDER_NONE) | |
144 | { | |
145 | m_border = border; | |
146 | m_holiday = FALSE; | |
147 | } | |
148 | #endif | |
4f6aed9c VZ |
149 | private: |
150 | wxColour m_colText, | |
151 | m_colBack, | |
152 | m_colBorder; | |
153 | wxFont m_font; | |
154 | wxCalendarDateBorder m_border; | |
155 | bool m_holiday; | |
156 | }; | |
9d9b7755 VZ |
157 | |
158 | // ---------------------------------------------------------------------------- | |
159 | // wxCalendarCtrl events | |
160 | // ---------------------------------------------------------------------------- | |
161 | ||
12f190b0 | 162 | class WXDLLIMPEXP_ADV wxCalendarCtrl; |
4f6aed9c | 163 | |
12f190b0 | 164 | class WXDLLIMPEXP_ADV wxCalendarEvent : public wxCommandEvent |
9d9b7755 | 165 | { |
0185cd09 | 166 | friend class wxCalendarCtrl; |
9d9b7755 | 167 | public: |
0185cd09 | 168 | wxCalendarEvent() { Init(); } |
9d9b7755 VZ |
169 | wxCalendarEvent(wxCalendarCtrl *cal, wxEventType type); |
170 | ||
171 | const wxDateTime& GetDate() const { return m_date; } | |
12ac619f JS |
172 | void SetDate(const wxDateTime &date) { m_date = date; } |
173 | void SetWeekDay(const wxDateTime::WeekDay wd) { m_wday = wd; } | |
0185cd09 VZ |
174 | wxDateTime::WeekDay GetWeekDay() const { return m_wday; } |
175 | ||
176 | protected: | |
177 | void Init(); | |
9d9b7755 VZ |
178 | |
179 | private: | |
180 | wxDateTime m_date; | |
0185cd09 | 181 | wxDateTime::WeekDay m_wday; |
f6bcfd97 | 182 | |
fc7a2a60 | 183 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxCalendarEvent) |
9d9b7755 VZ |
184 | }; |
185 | ||
4f6aed9c VZ |
186 | // ---------------------------------------------------------------------------- |
187 | // wxCalendarCtrl | |
188 | // ---------------------------------------------------------------------------- | |
189 | ||
190 | // so far we only have a generic version, so keep it simple | |
191 | #include "wx/generic/calctrl.h" | |
192 | ||
193 | // ---------------------------------------------------------------------------- | |
2e4df4bf | 194 | // calendar event types and macros for handling them |
4f6aed9c VZ |
195 | // ---------------------------------------------------------------------------- |
196 | ||
2e4df4bf | 197 | BEGIN_DECLARE_EVENT_TYPES() |
3f2c3839 MB |
198 | DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_CALENDAR_SEL_CHANGED, 950) |
199 | DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_CALENDAR_DAY_CHANGED, 951) | |
200 | DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_CALENDAR_MONTH_CHANGED, 952) | |
201 | DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_CALENDAR_YEAR_CHANGED, 953) | |
202 | DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_CALENDAR_DOUBLECLICKED, 954) | |
203 | DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_CALENDAR_WEEKDAY_CLICKED, 955) | |
2e4df4bf VZ |
204 | END_DECLARE_EVENT_TYPES() |
205 | ||
457e6c54 JS |
206 | typedef void (wxEvtHandler::*wxCalendarEventFunction)(wxCalendarEvent&); |
207 | ||
3a818b15 VZ |
208 | #define EVT_CALENDAR(id, fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_CALENDAR_DOUBLECLICKED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) wxStaticCastEvent( wxCalendarEventFunction, & fn ), (wxObject *) NULL), |
209 | #define EVT_CALENDAR_SEL_CHANGED(id, fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_CALENDAR_SEL_CHANGED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) wxStaticCastEvent( wxCalendarEventFunction, & fn ), (wxObject *) NULL), | |
210 | #define EVT_CALENDAR_DAY(id, fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_CALENDAR_DAY_CHANGED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) wxStaticCastEvent( wxCalendarEventFunction, & fn ), (wxObject *) NULL), | |
211 | #define EVT_CALENDAR_MONTH(id, fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_CALENDAR_MONTH_CHANGED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) wxStaticCastEvent( wxCalendarEventFunction, & fn ), (wxObject *) NULL), | |
212 | #define EVT_CALENDAR_YEAR(id, fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_CALENDAR_YEAR_CHANGED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) wxStaticCastEvent( wxCalendarEventFunction, & fn ), (wxObject *) NULL), | |
213 | #define EVT_CALENDAR_WEEKDAY_CLICKED(id, fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_CALENDAR_WEEKDAY_CLICKED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) wxStaticCastEvent( wxCalendarEventFunction, & fn ), (wxObject *) NULL), | |
9d9b7755 | 214 | |
1e6feb95 VZ |
215 | #endif // wxUSE_CALENDARCTRL |
216 | ||
217 | #endif // _WX_CALCTRL_H_ | |
218 |