]> git.saurik.com Git - wxWidgets.git/blob - wxPython/src/calendar.i
xcode 1.2 native targets
[wxWidgets.git] / wxPython / src / calendar.i
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 %pythoncode { __docfilter__ = wx.__docfilter__ }
28
29 %include _calendar_rename.i
30
31 //---------------------------------------------------------------------------
32
33 enum {
34 wxCAL_SUNDAY_FIRST,
35 wxCAL_MONDAY_FIRST,
36 wxCAL_SHOW_HOLIDAYS,
37 wxCAL_NO_YEAR_CHANGE,
38 wxCAL_NO_MONTH_CHANGE,
39 wxCAL_SEQUENTIAL_MONTH_SELECTION,
40 wxCAL_SHOW_SURROUNDING_WEEKS,
41 };
42
43
44 enum wxCalendarHitTestResult
45 {
46 wxCAL_HITTEST_NOWHERE, // outside of anything
47 wxCAL_HITTEST_HEADER, // on the header (weekdays)
48 wxCAL_HITTEST_DAY, // on a day in the calendar
49 wxCAL_HITTEST_INCMONTH,
50 wxCAL_HITTEST_DECMONTH,
51 wxCAL_HITTEST_SURROUNDING_WEEK
52 };
53
54 // border types for a date
55 enum wxCalendarDateBorder
56 {
57 wxCAL_BORDER_NONE, // no border (default)
58 wxCAL_BORDER_SQUARE, // a rectangular border
59 wxCAL_BORDER_ROUND // a round border
60 };
61
62 //---------------------------------------------------------------------------
63
64 DocStr(wxCalendarDateAttr,
65 "A set of customization attributes for a calendar date, which can be used to
66 control the look of the Calendar object.");
67
68 class wxCalendarDateAttr
69 {
70 public:
71 DocStr(wxCalendarDateAttr,
72 "Create a CalendarDateAttr.");
73 wxCalendarDateAttr(const wxColour& colText = wxNullColour,
74 const wxColour& colBack = wxNullColour,
75 const wxColour& colBorder = wxNullColour,
76 const wxFont& font = wxNullFont,
77 wxCalendarDateBorder border = wxCAL_BORDER_NONE);
78
79
80 // setters
81 void SetTextColour(const wxColour& colText);
82 void SetBackgroundColour(const wxColour& colBack);
83 void SetBorderColour(const wxColour& col);
84 void SetFont(const wxFont& font);
85 void SetBorder(wxCalendarDateBorder border);
86 void SetHoliday(bool holiday);
87
88 // accessors
89 bool HasTextColour() const;
90 bool HasBackgroundColour() const;
91 bool HasBorderColour() const;
92 bool HasFont() const;
93 bool HasBorder() const;
94
95 bool IsHoliday() const;
96
97 wxColour GetTextColour() const;
98 wxColour GetBackgroundColour() const;
99 wxColour GetBorderColour() const;
100 wxFont GetFont() const;
101 wxCalendarDateBorder GetBorder() const;
102 };
103
104 //---------------------------------------------------------------------------
105
106 class wxCalendarCtrl;
107
108 class wxCalendarEvent : public wxCommandEvent
109 {
110 public:
111 wxCalendarEvent(wxCalendarCtrl *cal, wxEventType type);
112
113 const wxDateTime GetDate() const;
114 void SetDate(const wxDateTime &date);
115 void SetWeekDay(const wxDateTime::WeekDay wd);
116 wxDateTime::WeekDay GetWeekDay() const;
117
118 };
119
120
121 %constant wxEventType wxEVT_CALENDAR_DOUBLECLICKED;
122 %constant wxEventType wxEVT_CALENDAR_SEL_CHANGED;
123 %constant wxEventType wxEVT_CALENDAR_DAY_CHANGED;
124 %constant wxEventType wxEVT_CALENDAR_MONTH_CHANGED;
125 %constant wxEventType wxEVT_CALENDAR_YEAR_CHANGED;
126 %constant wxEventType wxEVT_CALENDAR_WEEKDAY_CLICKED;
127
128
129 %pythoncode {
130 EVT_CALENDAR = wx.PyEventBinder( wxEVT_CALENDAR_DOUBLECLICKED, 1)
131 EVT_CALENDAR_SEL_CHANGED = wx.PyEventBinder( wxEVT_CALENDAR_SEL_CHANGED, 1)
132 EVT_CALENDAR_DAY = wx.PyEventBinder( wxEVT_CALENDAR_DAY_CHANGED, 1)
133 EVT_CALENDAR_MONTH = wx.PyEventBinder( wxEVT_CALENDAR_MONTH_CHANGED, 1)
134 EVT_CALENDAR_YEAR = wx.PyEventBinder( wxEVT_CALENDAR_YEAR_CHANGED, 1)
135 EVT_CALENDAR_WEEKDAY_CLICKED = wx.PyEventBinder( wxEVT_CALENDAR_WEEKDAY_CLICKED, 1)
136 }
137
138
139 //---------------------------------------------------------------------------
140
141 MAKE_CONST_WXSTRING(CalendarNameStr);
142
143
144 DocStr(wxCalendarCtrl,
145 "The calendar control allows the user to pick a date interactively.");
146
147 RefDoc(wxCalendarCtrl,
148
149 "The CalendarCtrl displays a window containing several parts: the control to
150 pick the month and the year at the top (either or both of them may be
151 disabled) and a month area below them which shows all the days in the
152 month. The user can move the current selection using the keyboard and select
153 the date (generating EVT_CALENDAR event) by pressing <Return> or double
154 clicking it.
155
156 It has advanced possibilities for the customization of its display. All global
157 settings (such as colours and fonts used) can, of course, be changed. But
158 also, the display style for each day in the month can be set independently
159 using CalendarDateAttr class.
160
161 An item without custom attributes is drawn with the default colours and font
162 and without border, but setting custom attributes with SetAttr allows to
163 modify its appearance. Just create a custom attribute object and set it for
164 the day you want to be displayed specially A day may be marked as being a
165 holiday, (even if it is not recognized as one by wx.DateTime) by using the
166 SetHoliday method.
167
168 As the attributes are specified for each day, they may change when the month
169 is changed, so you will often want to update them in an EVT_CALENDAR_MONTH
170 event handler.
171
172 Styles
173 CAL_SUNDAY_FIRST: Show Sunday as the first day in the week
174 CAL_MONDAY_FIRST: Show Monday as the first day in the week
175 CAL_SHOW_HOLIDAYS: Highlight holidays in the calendar
176 CAL_NO_YEAR_CHANGE: Disable the year changing
177 CAL_NO_MONTH_CHANGE: Disable the month (and, implicitly, the year) changing
178 CAL_SHOW_SURROUNDING_WEEKS: Show the neighbouring weeks in the previous and next months
179 CAL_SEQUENTIAL_MONTH_SELECTION: Use alternative, more compact, style for the month and year selection controls.
180
181 The default calendar style is wxCAL_SHOW_HOLIDAYS.
182
183 Events
184 EVT_CALENDAR: A day was double clicked in the calendar.
185 EVT_CALENDAR_SEL_CHANGED: The selected date changed.
186 EVT_CALENDAR_DAY: The selected day changed.
187 EVT_CALENDAR_MONTH: The selected month changed.
188 EVT_CALENDAR_YEAR: The selected year changed.
189 EVT_CALENDAR_WEEKDAY_CLICKED: User clicked on the week day header
190
191 Note that changing the selected date will result in either of
192 EVT_CALENDAR_DAY, MONTH or YEAR events and an EVT_CALENDAR_SEL_CHANGED event.
193
194 ");
195
196
197 class wxCalendarCtrl : public wxControl
198 {
199 public:
200 %pythonAppend wxCalendarCtrl "self._setOORInfo(self)"
201 %pythonAppend wxCalendarCtrl() ""
202
203 DocStr(wxCalendarCtrl, "Create and show a calendar control.");
204 RefDoc(wxCalendarCtrl, ""); // turn it off for the ctors
205
206 wxCalendarCtrl(wxWindow *parent,
207 wxWindowID id=-1,
208 const wxDateTime& date = wxDefaultDateTime,
209 const wxPoint& pos = wxDefaultPosition,
210 const wxSize& size = wxDefaultSize,
211 long style = wxCAL_SHOW_HOLIDAYS | wxWANTS_CHARS,
212 const wxString& name = wxPyCalendarNameStr);
213
214
215 DocStr(wxCalendarCtrl(), "Precreate a CalendarCtrl for 2-phase creation.");
216 %name(PreCalendarCtrl)wxCalendarCtrl();
217
218 DocStr(Create, "Acutally create the GUI portion of the CalendarCtrl for 2-phase creation.");
219 bool Create(wxWindow *parent,
220 wxWindowID id,
221 const wxDateTime& date = wxDefaultDateTime,
222 const wxPoint& pos = wxDefaultPosition,
223 const wxSize& size = wxDefaultSize,
224 long style = wxCAL_SHOW_HOLIDAYS | wxWANTS_CHARS,
225 const wxString& name = wxPyCalendarNameStr);
226
227
228 DocDeclStr(
229 void, SetDate(const wxDateTime& date),
230 "Sets the current date.");
231
232 DocDeclStr(
233 const wxDateTime&, GetDate() const,
234 "Gets the currently selected date.");
235
236
237
238 DocDeclStr(
239 bool, SetLowerDateLimit(const wxDateTime& date = wxDefaultDateTime),
240 "set the range in which selection can occur");
241
242 DocDeclStr(
243 bool, SetUpperDateLimit(const wxDateTime& date = wxDefaultDateTime),
244 "set the range in which selection can occur");
245
246 DocDeclStr(
247 const wxDateTime&, GetLowerDateLimit() const,
248 "get the range in which selection can occur");
249
250 DocDeclStr(
251 const wxDateTime&, GetUpperDateLimit() const,
252 "get the range in which selection can occur");
253
254 DocDeclStr(
255 bool, SetDateRange(const wxDateTime& lowerdate = wxDefaultDateTime,
256 const wxDateTime& upperdate = wxDefaultDateTime),
257 "set the range in which selection can occur");
258
259
260
261
262 DocDeclStr(
263 void, EnableYearChange(bool enable = True),
264 "This function should be used instead of changing CAL_NO_YEAR_CHANGE\n"
265 "style bit directly. It allows or disallows the user to change the year\n"
266 "interactively.");
267
268 DocDeclStr(
269 void, EnableMonthChange(bool enable = True),
270 "This function should be used instead of changing CAL_NO_MONTH_CHANGE style\n"
271 "bit. It allows or disallows the user to change the month interactively. Note\n"
272 "that if the month can not be changed, the year can not be changed either.");
273
274 DocDeclStr(
275 void, EnableHolidayDisplay(bool display = True),
276 "This function should be used instead of changing CAL_SHOW_HOLIDAYS style\n"
277 "bit directly. It enables or disables the special highlighting of the holidays.");
278
279
280
281 DocDeclStr(
282 void, SetHeaderColours(const wxColour& colFg, const wxColour& colBg),
283 "header colours are used for painting the weekdays at the top");
284
285 DocDeclStr(
286 wxColour, GetHeaderColourFg() const,
287 "header colours are used for painting the weekdays at the top");
288
289 DocDeclStr(
290 wxColour, GetHeaderColourBg() const,
291 "header colours are used for painting the weekdays at the top");
292
293
294
295 DocDeclStr(
296 void, SetHighlightColours(const wxColour& colFg, const wxColour& colBg),
297 "highlight colour is used for the currently selected date");
298
299 DocDeclStr(
300 wxColour, GetHighlightColourFg() const,
301 "highlight colour is used for the currently selected date");
302
303 DocDeclStr(
304 wxColour, GetHighlightColourBg() const,
305 "highlight colour is used for the currently selected date");
306
307
308
309 DocDeclStr(
310 void, SetHolidayColours(const wxColour& colFg, const wxColour& colBg),
311 "holiday colour is used for the holidays (if CAL_SHOW_HOLIDAYS style is used)");
312
313 DocDeclStr(
314 wxColour, GetHolidayColourFg() const,
315 "holiday colour is used for the holidays (if CAL_SHOW_HOLIDAYS style is used)");
316
317 DocDeclStr(
318 wxColour, GetHolidayColourBg() const,
319 "holiday colour is used for the holidays (if CAL_SHOW_HOLIDAYS style is used)");
320
321
322
323 DocDeclStr(
324 wxCalendarDateAttr*, GetAttr(size_t day) const,
325 "Returns the attribute for the given date (should be in the range 1...31).\n"
326 "The returned value may be None");
327
328 DocDeclStr(
329 void, SetAttr(size_t day, wxCalendarDateAttr *attr),
330 "Associates the attribute with the specified date (in the range 1...31).\n"
331 "If the attribute passed is None, the items attribute is cleared.");
332
333 DocDeclStr(
334 void, SetHoliday(size_t day),
335 "Marks the specified day as being a holiday in the current month.");
336
337 DocDeclStr(
338 void, ResetAttr(size_t day),
339 "Clears any attributes associated with the given day (in the range 1...31).");
340
341
342
343 DocAStr(HitTest,
344 "HitTest(Point pos) -> (result, date, weekday)",
345 "Returns 3-tuple with information about the given position on the calendar
346 control. The first value of the tuple is a result code and determines the
347 validity of the remaining two values. The result codes are:
348
349 CAL_HITTEST_NOWHERE: hit outside of anything
350 CAL_HITTEST_HEADER: hit on the header, weekday is valid
351 CAL_HITTEST_DAY: hit on a day in the calendar, date is set.
352 ");
353 %extend {
354 PyObject* HitTest(const wxPoint& pos) {
355 wxDateTime* date = new wxDateTime;
356 wxDateTime::WeekDay wd;
357 wxCalendarHitTestResult result = self->HitTest(pos, date, &wd);
358 bool blocked = wxPyBeginBlockThreads();
359 PyObject* tup = PyTuple_New(3);
360 PyTuple_SET_ITEM(tup, 0, PyInt_FromLong(result));
361 PyTuple_SET_ITEM(tup, 1, wxPyConstructObject(date, wxT("wxDateTime"), 1));
362 PyTuple_SET_ITEM(tup, 2, PyInt_FromLong(wd));
363 wxPyEndBlockThreads(blocked);
364 return tup;
365 }
366 }
367
368 DocDeclStr(
369 wxControl*, GetMonthControl() const,
370 "get the currently shown control for month");
371
372 DocDeclStr(
373 wxControl*, GetYearControl() const,
374 "get the currently shown control for year");
375 };
376
377
378 //---------------------------------------------------------------------------
379
380 %init %{
381 %}
382
383 //---------------------------------------------------------------------------
384