]>
Commit | Line | Data |
---|---|---|
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 | %{ | |
17 | #include "wx/wxPython/wxPython.h" | |
18 | #include "wx/wxPython/pyclasses.h" | |
19 | ||
20 | #include <wx/calctrl.h> | |
21 | %} | |
22 | ||
23 | //---------------------------------------------------------------------- | |
24 | ||
25 | %import misc.i | |
26 | %pythoncode { wx = core } | |
27 | ||
28 | %include _calendar_rename.i | |
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, | |
38 | wxCAL_SEQUENTIAL_MONTH_SELECTION, | |
39 | wxCAL_SHOW_SURROUNDING_WEEKS, | |
40 | }; | |
41 | ||
42 | ||
43 | enum wxCalendarHitTestResult | |
44 | { | |
45 | wxCAL_HITTEST_NOWHERE, // outside of anything | |
46 | wxCAL_HITTEST_HEADER, // on the header (weekdays) | |
47 | wxCAL_HITTEST_DAY, // on a day in the calendar | |
48 | wxCAL_HITTEST_INCMONTH, | |
49 | wxCAL_HITTEST_DECMONTH, | |
50 | wxCAL_HITTEST_SURROUNDING_WEEK | |
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 | ||
74 | %name(CalendarDateAttrBorder) | |
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 | ||
95 | wxColour GetTextColour() const; | |
96 | wxColour GetBackgroundColour() const; | |
97 | wxColour GetBorderColour() const; | |
98 | wxFont GetFont() const; | |
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 | void SetDate(const wxDateTime &date); | |
113 | void SetWeekDay(const wxDateTime::WeekDay wd); | |
114 | wxDateTime::WeekDay GetWeekDay() const; | |
115 | ||
116 | }; | |
117 | ||
118 | ||
119 | %constant wxEventType wxEVT_CALENDAR_DOUBLECLICKED; | |
120 | %constant wxEventType wxEVT_CALENDAR_SEL_CHANGED; | |
121 | %constant wxEventType wxEVT_CALENDAR_DAY_CHANGED; | |
122 | %constant wxEventType wxEVT_CALENDAR_MONTH_CHANGED; | |
123 | %constant wxEventType wxEVT_CALENDAR_YEAR_CHANGED; | |
124 | %constant wxEventType wxEVT_CALENDAR_WEEKDAY_CLICKED; | |
125 | ||
126 | ||
127 | %pythoncode { | |
128 | EVT_CALENDAR = wx.PyEventBinder( wxEVT_CALENDAR_DOUBLECLICKED, 1) | |
129 | EVT_CALENDAR_SEL_CHANGED = wx.PyEventBinder( wxEVT_CALENDAR_SEL_CHANGED, 1) | |
130 | EVT_CALENDAR_DAY = wx.PyEventBinder( wxEVT_CALENDAR_DAY_CHANGED, 1) | |
131 | EVT_CALENDAR_MONTH = wx.PyEventBinder( wxEVT_CALENDAR_MONTH_CHANGED, 1) | |
132 | EVT_CALENDAR_YEAR = wx.PyEventBinder( wxEVT_CALENDAR_YEAR_CHANGED, 1) | |
133 | EVT_CALENDAR_WEEKDAY_CLICKED = wx.PyEventBinder( wxEVT_CALENDAR_WEEKDAY_CLICKED, 1) | |
134 | } | |
135 | ||
136 | ||
137 | //--------------------------------------------------------------------------- | |
138 | ||
139 | MAKE_CONST_WXSTRING(CalendarNameStr); | |
140 | ||
141 | ||
142 | ||
143 | class wxCalendarCtrl : public wxControl | |
144 | { | |
145 | public: | |
146 | %pythonAppend wxCalendarCtrl "self._setOORInfo(self)" | |
147 | %pythonAppend wxCalendarCtrl() "" | |
148 | ||
149 | wxCalendarCtrl(wxWindow *parent, | |
150 | wxWindowID id, | |
151 | const wxDateTime& date = wxDefaultDateTime, | |
152 | const wxPoint& pos = wxDefaultPosition, | |
153 | const wxSize& size = wxDefaultSize, | |
154 | long style = wxCAL_SHOW_HOLIDAYS | wxWANTS_CHARS, | |
155 | const wxString& name = wxPyCalendarNameStr); | |
156 | %name(PreCalendarCtrl)wxCalendarCtrl(); | |
157 | ||
158 | bool Create(wxWindow *parent, | |
159 | wxWindowID id, | |
160 | const wxDateTime& date = wxDefaultDateTime, | |
161 | const wxPoint& pos = wxDefaultPosition, | |
162 | const wxSize& size = wxDefaultSize, | |
163 | long style = wxCAL_SHOW_HOLIDAYS | wxWANTS_CHARS, | |
164 | const wxString& name = wxPyCalendarNameStr); | |
165 | ||
166 | ||
167 | // set/get the current date | |
168 | // ------------------------ | |
169 | ||
170 | void SetDate(const wxDateTime& date); | |
171 | const wxDateTime& GetDate() const; | |
172 | ||
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 | ||
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); | |
206 | wxColour GetHeaderColourFg() const; | |
207 | wxColour GetHeaderColourBg() const; | |
208 | ||
209 | // highlight colour is used for the currently selected date | |
210 | void SetHighlightColours(const wxColour& colFg, const wxColour& colBg); | |
211 | wxColour GetHighlightColourFg() const; | |
212 | wxColour GetHighlightColourBg() const; | |
213 | ||
214 | // holiday colour is used for the holidays (if style & wxCAL_SHOW_HOLIDAYS) | |
215 | void SetHolidayColours(const wxColour& colFg, const wxColour& colBg); | |
216 | wxColour GetHolidayColourFg() const; | |
217 | wxColour GetHolidayColourBg() const; | |
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 | ||
240 | ||
241 | bool Enable(bool enable = True); | |
242 | bool Show(bool show = True); | |
243 | ||
244 | // get the currently shown control for month/year | |
245 | wxControl *GetMonthControl() const; | |
246 | wxControl *GetYearControl() const; | |
247 | }; | |
248 | ||
249 | ||
250 | //--------------------------------------------------------------------------- | |
251 | ||
252 | %init %{ | |
253 | %} | |
254 | ||
255 | //--------------------------------------------------------------------------- | |
256 |