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