]>
Commit | Line | Data |
---|---|---|
f6bcfd97 BP |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: calendar.i | |
3 | // Purpose: SWIG definitions for the wxCalendarCtrl | |
4 | // | |
5 | // Author: Robin Dunn | |
6 | // | |
7 | // Created: 23-May-2000 | |
8 | // RCS-ID: $Id$ | |
9 | // Copyright: (c) 2000 by Total Control Software | |
10 | // Licence: wxWindows license | |
11 | ///////////////////////////////////////////////////////////////////////////// | |
12 | ||
13 | %module calendar | |
14 | ||
15 | ||
16 | %{ | |
6e2129f9 | 17 | #include "wxPython.h" |
f6bcfd97 BP |
18 | #include <wx/calctrl.h> |
19 | %} | |
20 | ||
21 | //---------------------------------------------------------------------- | |
22 | ||
23 | %include typemaps.i | |
24 | %include my_typemaps.i | |
25 | ||
26 | // Import some definitions of other classes, etc. | |
27 | %import _defs.i | |
28 | %import misc.i | |
29 | %import windows.i | |
30 | %import controls.i | |
31 | %import events.i | |
32 | %import utils.i | |
33 | ||
34 | %pragma(python) code = "import wx" | |
35 | ||
36 | //--------------------------------------------------------------------------- | |
37 | ||
38 | enum { | |
39 | wxCAL_SUNDAY_FIRST, | |
40 | wxCAL_MONDAY_FIRST, | |
41 | wxCAL_SHOW_HOLIDAYS, | |
42 | wxCAL_NO_YEAR_CHANGE, | |
43 | wxCAL_NO_MONTH_CHANGE, | |
ab11ebfa RD |
44 | wxCAL_SEQUENTIAL_MONTH_SELECTION, |
45 | wxCAL_SHOW_SURROUNDING_WEEKS, | |
f6bcfd97 BP |
46 | }; |
47 | ||
48 | ||
49 | enum wxCalendarHitTestResult | |
50 | { | |
51 | wxCAL_HITTEST_NOWHERE, // outside of anything | |
52 | wxCAL_HITTEST_HEADER, // on the header (weekdays) | |
b66824a5 | 53 | wxCAL_HITTEST_DAY, // on a day in the calendar |
ab11ebfa RD |
54 | wxCAL_HITTEST_INCMONTH, |
55 | wxCAL_HITTEST_DECMONTH, | |
56 | wxCAL_HITTEST_SURROUNDING_WEEK | |
f6bcfd97 BP |
57 | }; |
58 | ||
59 | // border types for a date | |
60 | enum wxCalendarDateBorder | |
61 | { | |
62 | wxCAL_BORDER_NONE, // no border (default) | |
63 | wxCAL_BORDER_SQUARE, // a rectangular border | |
64 | wxCAL_BORDER_ROUND // a round border | |
65 | }; | |
66 | ||
67 | //--------------------------------------------------------------------------- | |
68 | ||
69 | ||
70 | class wxCalendarDateAttr | |
71 | { | |
72 | public: | |
73 | // ctors | |
74 | wxCalendarDateAttr(const wxColour& colText, | |
75 | const wxColour& colBack = wxNullColour, | |
76 | const wxColour& colBorder = wxNullColour, | |
77 | const wxFont& font = wxNullFont, | |
78 | wxCalendarDateBorder border = wxCAL_BORDER_NONE); | |
79 | ||
80 | %name(wxCalendarDateAttrBorder) | |
81 | wxCalendarDateAttr(wxCalendarDateBorder border, | |
82 | const wxColour& colBorder = wxNullColour); | |
83 | ||
84 | // setters | |
85 | void SetTextColour(const wxColour& colText); | |
86 | void SetBackgroundColour(const wxColour& colBack); | |
87 | void SetBorderColour(const wxColour& col); | |
88 | void SetFont(const wxFont& font); | |
89 | void SetBorder(wxCalendarDateBorder border); | |
90 | void SetHoliday(bool holiday); | |
91 | ||
92 | // accessors | |
93 | bool HasTextColour() const; | |
94 | bool HasBackgroundColour() const; | |
95 | bool HasBorderColour() const; | |
96 | bool HasFont() const; | |
97 | bool HasBorder() const; | |
98 | ||
99 | bool IsHoliday() const; | |
100 | ||
c5943253 RD |
101 | wxColour GetTextColour() const; |
102 | wxColour GetBackgroundColour() const; | |
103 | wxColour GetBorderColour() const; | |
104 | wxFont GetFont() const; | |
f6bcfd97 BP |
105 | wxCalendarDateBorder GetBorder() const; |
106 | }; | |
107 | ||
108 | //--------------------------------------------------------------------------- | |
109 | ||
110 | class wxCalendarCtrl; | |
111 | ||
112 | class wxCalendarEvent : public wxCommandEvent | |
113 | { | |
114 | public: | |
115 | wxCalendarEvent(wxCalendarCtrl *cal, wxEventType type); | |
116 | ||
117 | const wxDateTime& GetDate() const; | |
118 | wxDateTime::WeekDay GetWeekDay() const; | |
119 | ||
120 | }; | |
121 | ||
122 | enum { | |
123 | wxEVT_CALENDAR_DOUBLECLICKED, | |
124 | wxEVT_CALENDAR_SEL_CHANGED, | |
125 | wxEVT_CALENDAR_DAY_CHANGED, | |
126 | wxEVT_CALENDAR_MONTH_CHANGED, | |
127 | wxEVT_CALENDAR_YEAR_CHANGED, | |
128 | wxEVT_CALENDAR_WEEKDAY_CLICKED, | |
129 | }; | |
130 | ||
131 | %pragma(python) code = " | |
132 | def EVT_CALENDAR(win, id, fn): | |
133 | win.Connect(id, -1, wxEVT_CALENDAR_DOUBLECLICKED, fn) | |
134 | ||
135 | def EVT_CALENDAR_SEL_CHANGED(win, id, fn): | |
136 | win.Connect(id, -1, wxEVT_CALENDAR_SEL_CHANGED, fn) | |
137 | ||
138 | def EVT_CALENDAR_DAY(win, id, fn): | |
139 | win.Connect(id, -1, wxEVT_CALENDAR_DAY_CHANGED, fn) | |
140 | ||
141 | def EVT_CALENDAR_MONTH(win, id, fn): | |
142 | win.Connect(id, -1, wxEVT_CALENDAR_MONTH_CHANGED, fn) | |
143 | ||
144 | def EVT_CALENDAR_YEAR(win, id, fn): | |
145 | win.Connect(id, -1, wxEVT_CALENDAR_YEAR_CHANGED, fn) | |
146 | ||
147 | def EVT_CALENDAR_WEEKDAY_CLICKED(win, id, fn): | |
148 | win.Connect(id, -1, wxEVT_CALENDAR_WEEKDAY_CLICKED, fn) | |
149 | ||
150 | " | |
151 | ||
152 | //--------------------------------------------------------------------------- | |
153 | ||
137b5242 RD |
154 | %{ |
155 | // Put some wx default wxChar* values into wxStrings. | |
156 | DECLARE_DEF_STRING(CalendarNameStr); | |
157 | %} | |
158 | ||
f6bcfd97 BP |
159 | class wxCalendarCtrl : public wxControl |
160 | { | |
161 | public: | |
162 | // construction | |
163 | wxCalendarCtrl(wxWindow *parent, | |
164 | wxWindowID id, | |
165 | const wxDateTime& date = wxDefaultDateTime, | |
166 | const wxPoint& pos = wxDefaultPosition, | |
167 | const wxSize& size = wxDefaultSize, | |
bae17009 | 168 | long style = wxCAL_SHOW_HOLIDAYS | wxWANTS_CHARS, |
137b5242 | 169 | const wxString& name = wxPyCalendarNameStr); |
09f3d4e6 RD |
170 | %name(wxPreCalendarCtrl)wxCalendarCtrl(); |
171 | ||
172 | bool Create(wxWindow *parent, | |
173 | wxWindowID id, | |
174 | const wxDateTime& date = wxDefaultDateTime, | |
175 | const wxPoint& pos = wxDefaultPosition, | |
176 | const wxSize& size = wxDefaultSize, | |
bae17009 | 177 | long style = wxCAL_SHOW_HOLIDAYS | wxWANTS_CHARS, |
137b5242 | 178 | const wxString& name = wxPyCalendarNameStr); |
f6bcfd97 | 179 | |
0122b7e3 | 180 | %pragma(python) addtomethod = "__init__:self._setOORInfo(self)" |
17c0e08c | 181 | %pragma(python) addtomethod = "wxPreCalendarCtrl:val._setOORInfo(val)" |
0122b7e3 | 182 | |
f6bcfd97 BP |
183 | // set/get the current date |
184 | // ------------------------ | |
185 | ||
186 | void SetDate(const wxDateTime& date); | |
187 | const wxDateTime& GetDate() const; | |
188 | ||
ab11ebfa RD |
189 | // set/get the range in which selection can occur |
190 | // --------------------------------------------- | |
191 | ||
192 | bool SetLowerDateLimit(const wxDateTime& date = wxDefaultDateTime); | |
193 | const wxDateTime& GetLowerDateLimit() const; | |
194 | bool SetUpperDateLimit(const wxDateTime& date = wxDefaultDateTime); | |
195 | const wxDateTime& GetUpperDateLimit() const; | |
196 | ||
197 | bool SetDateRange(const wxDateTime& lowerdate = wxDefaultDateTime, | |
198 | const wxDateTime& upperdate = wxDefaultDateTime); | |
199 | ||
200 | ||
f6bcfd97 BP |
201 | // calendar mode |
202 | // ------------- | |
203 | ||
204 | // some calendar styles can't be changed after the control creation by | |
205 | // just using SetWindowStyle() and Refresh() and the functions below | |
206 | // should be used instead for them | |
207 | ||
208 | // corresponds to wxCAL_NO_YEAR_CHANGE bit | |
209 | void EnableYearChange(bool enable = TRUE); | |
210 | ||
211 | // corresponds to wxCAL_NO_MONTH_CHANGE bit | |
212 | void EnableMonthChange(bool enable = TRUE); | |
213 | ||
214 | // corresponds to wxCAL_SHOW_HOLIDAYS bit | |
215 | void EnableHolidayDisplay(bool display = TRUE); | |
216 | ||
217 | // customization | |
218 | // ------------- | |
219 | ||
220 | // header colours are used for painting the weekdays at the top | |
221 | void SetHeaderColours(const wxColour& colFg, const wxColour& colBg); | |
c5943253 RD |
222 | wxColour GetHeaderColourFg() const; |
223 | wxColour GetHeaderColourBg() const; | |
f6bcfd97 BP |
224 | |
225 | // highlight colour is used for the currently selected date | |
226 | void SetHighlightColours(const wxColour& colFg, const wxColour& colBg); | |
c5943253 RD |
227 | wxColour GetHighlightColourFg() const; |
228 | wxColour GetHighlightColourBg() const; | |
f6bcfd97 BP |
229 | |
230 | // holiday colour is used for the holidays (if style & wxCAL_SHOW_HOLIDAYS) | |
231 | void SetHolidayColours(const wxColour& colFg, const wxColour& colBg); | |
c5943253 RD |
232 | wxColour GetHolidayColourFg() const; |
233 | wxColour GetHolidayColourBg() const; | |
f6bcfd97 BP |
234 | |
235 | // an item without custom attributes is drawn with the default colours and | |
236 | // font and without border, setting custom attributes allows to modify this | |
237 | // | |
238 | // the day parameter should be in 1..31 range, for days 29, 30, 31 the | |
239 | // corresponding attribute is just unused if there is no such day in the | |
240 | // current month | |
241 | ||
242 | wxCalendarDateAttr *GetAttr(size_t day) const; | |
243 | void SetAttr(size_t day, wxCalendarDateAttr *attr); | |
244 | ||
245 | void SetHoliday(size_t day); | |
246 | ||
247 | void ResetAttr(size_t day); | |
248 | ||
249 | // returns one of wxCAL_HITTEST_XXX constants and fills either date or wd | |
250 | // with the corresponding value (none for NOWHERE, the date for DAY and wd | |
251 | // for HEADER) | |
252 | wxCalendarHitTestResult HitTest(const wxPoint& pos, | |
253 | wxDateTime *date = NULL, | |
254 | wxDateTime::WeekDay *wd = NULL); | |
255 | ||
ab11ebfa RD |
256 | |
257 | bool Enable(bool enable = TRUE); | |
258 | bool Show(bool show = TRUE); | |
259 | ||
f6bcfd97 BP |
260 | }; |
261 | ||
262 | ||
263 | //--------------------------------------------------------------------------- | |
e508a2b6 RD |
264 | |
265 | %init %{ | |
266 | wxClassInfo::CleanUpClasses(); | |
267 | wxClassInfo::InitializeClasses(); | |
268 | %} | |
269 | ||
f6bcfd97 BP |
270 | //--------------------------------------------------------------------------- |
271 | ||
272 | %pragma(python) include="_calextras.py"; | |
273 | ||
274 | //--------------------------------------------------------------------------- | |
275 |