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