]>
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> | |
9 | // Licence: wxWindows license | |
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 | ||
9d9b7755 VZ |
19 | #ifndef _WX_CALCTRL_H |
20 | #define _WX_CALCTRL_H | |
21 | ||
4f6aed9c VZ |
22 | #include "wx/datetime.h" |
23 | ||
0185cd09 VZ |
24 | // ---------------------------------------------------------------------------- |
25 | // constants | |
26 | // ---------------------------------------------------------------------------- | |
27 | ||
28 | // return values for the HitTest() method | |
29 | enum wxCalendarHitTestResult | |
30 | { | |
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 | |
34 | }; | |
35 | ||
4f6aed9c VZ |
36 | // border types for a date |
37 | enum wxCalendarDateBorder | |
38 | { | |
39 | wxCAL_BORDER_NONE, // no border (default) | |
40 | wxCAL_BORDER_SQUARE, // a rectangular border | |
41 | wxCAL_BORDER_ROUND // a round border | |
42 | }; | |
43 | ||
0185cd09 | 44 | // ---------------------------------------------------------------------------- |
4f6aed9c | 45 | // wxCalendarDateAttr: custom attributes for a calendar date |
0185cd09 VZ |
46 | // ---------------------------------------------------------------------------- |
47 | ||
4f6aed9c VZ |
48 | class WXDLLEXPORT wxCalendarDateAttr |
49 | { | |
006713a2 | 50 | #if !defined(__VISAGECPP__) |
8caa4ed1 JS |
51 | protected: |
52 | // This has to be before the use of Init(), for MSVC++ 1.5 | |
006713a2 | 53 | // But dorks up Visualage! |
8caa4ed1 JS |
54 | void Init(wxCalendarDateBorder border = wxCAL_BORDER_NONE) |
55 | { | |
56 | m_border = border; | |
57 | m_holiday = FALSE; | |
58 | } | |
006713a2 | 59 | #endif |
4f6aed9c VZ |
60 | public: |
61 | // ctors | |
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) | |
70 | { | |
71 | Init(border); | |
72 | } | |
73 | wxCalendarDateAttr(wxCalendarDateBorder border, | |
74 | const wxColour& colBorder = wxNullColour) | |
75 | : m_colBorder(colBorder) | |
76 | { | |
77 | Init(border); | |
78 | } | |
79 | ||
80 | // setters | |
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; } | |
87 | ||
88 | // accessors | |
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; } | |
94 | ||
95 | bool IsHoliday() const { return m_holiday; } | |
96 | ||
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; } | |
006713a2 DW |
102 | #if defined(__VISAGECPP__) |
103 | protected: | |
104 | // This has to be here for VisualAge | |
105 | void Init(wxCalendarDateBorder border = wxCAL_BORDER_NONE) | |
106 | { | |
107 | m_border = border; | |
108 | m_holiday = FALSE; | |
109 | } | |
110 | #endif | |
4f6aed9c VZ |
111 | private: |
112 | wxColour m_colText, | |
113 | m_colBack, | |
114 | m_colBorder; | |
115 | wxFont m_font; | |
116 | wxCalendarDateBorder m_border; | |
117 | bool m_holiday; | |
118 | }; | |
9d9b7755 VZ |
119 | |
120 | // ---------------------------------------------------------------------------- | |
121 | // wxCalendarCtrl events | |
122 | // ---------------------------------------------------------------------------- | |
123 | ||
4f6aed9c VZ |
124 | class WXDLLEXPORT wxCalendarCtrl; |
125 | ||
9d9b7755 VZ |
126 | class WXDLLEXPORT wxCalendarEvent : public wxCommandEvent |
127 | { | |
0185cd09 | 128 | friend class wxCalendarCtrl; |
9d9b7755 | 129 | public: |
0185cd09 | 130 | wxCalendarEvent() { Init(); } |
9d9b7755 VZ |
131 | wxCalendarEvent(wxCalendarCtrl *cal, wxEventType type); |
132 | ||
133 | const wxDateTime& GetDate() const { return m_date; } | |
0185cd09 VZ |
134 | wxDateTime::WeekDay GetWeekDay() const { return m_wday; } |
135 | ||
136 | protected: | |
137 | void Init(); | |
9d9b7755 VZ |
138 | |
139 | private: | |
140 | wxDateTime m_date; | |
0185cd09 | 141 | wxDateTime::WeekDay m_wday; |
f6bcfd97 BP |
142 | |
143 | DECLARE_DYNAMIC_CLASS(wxCalendarEvent) | |
9d9b7755 VZ |
144 | }; |
145 | ||
4f6aed9c VZ |
146 | // ---------------------------------------------------------------------------- |
147 | // wxCalendarCtrl | |
148 | // ---------------------------------------------------------------------------- | |
149 | ||
150 | // so far we only have a generic version, so keep it simple | |
151 | #include "wx/generic/calctrl.h" | |
152 | ||
153 | // ---------------------------------------------------------------------------- | |
2e4df4bf | 154 | // calendar event types and macros for handling them |
4f6aed9c VZ |
155 | // ---------------------------------------------------------------------------- |
156 | ||
2e4df4bf VZ |
157 | BEGIN_DECLARE_EVENT_TYPES() |
158 | DECLARE_EVENT_TYPE(wxEVT_CALENDAR_SEL_CHANGED, 950) | |
159 | DECLARE_EVENT_TYPE(wxEVT_CALENDAR_DAY_CHANGED, 951) | |
160 | DECLARE_EVENT_TYPE(wxEVT_CALENDAR_MONTH_CHANGED, 952) | |
161 | DECLARE_EVENT_TYPE(wxEVT_CALENDAR_YEAR_CHANGED, 953) | |
162 | DECLARE_EVENT_TYPE(wxEVT_CALENDAR_DOUBLECLICKED, 954) | |
163 | DECLARE_EVENT_TYPE(wxEVT_CALENDAR_WEEKDAY_CLICKED, 955) | |
164 | END_DECLARE_EVENT_TYPES() | |
165 | ||
457e6c54 JS |
166 | typedef void (wxEvtHandler::*wxCalendarEventFunction)(wxCalendarEvent&); |
167 | ||
2e4df4bf VZ |
168 | #define EVT_CALENDAR(id, fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_CALENDAR_DOUBLECLICKED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) (wxCalendarEventFunction) & fn, (wxObject *) NULL), |
169 | #define EVT_CALENDAR_SEL_CHANGED(id, fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_CALENDAR_SEL_CHANGED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) (wxCalendarEventFunction) & fn, (wxObject *) NULL), | |
170 | #define EVT_CALENDAR_DAY(id, fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_CALENDAR_DAY_CHANGED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) (wxCalendarEventFunction) & fn, (wxObject *) NULL), | |
171 | #define EVT_CALENDAR_MONTH(id, fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_CALENDAR_MONTH_CHANGED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) (wxCalendarEventFunction) & fn, (wxObject *) NULL), | |
172 | #define EVT_CALENDAR_YEAR(id, fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_CALENDAR_YEAR_CHANGED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) (wxCalendarEventFunction) & fn, (wxObject *) NULL), | |
173 | #define EVT_CALENDAR_WEEKDAY_CLICKED(id, fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_CALENDAR_WEEKDAY_CLICKED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) (wxCalendarEventFunction) & fn, (wxObject *) NULL), | |
9d9b7755 VZ |
174 | |
175 | #endif // _WX_CALCTRL_H |