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