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