]> git.saurik.com Git - wxWidgets.git/blame - wxPython/src/gtk/calendar.py
reSWIGged
[wxWidgets.git] / wxPython / src / gtk / calendar.py
CommitLineData
f6bcfd97 1# This file was created automatically by SWIG.
d14a1e28
RD
2# Don't modify this file, modify the SWIG interface instead.
3
db3e571a
RD
4"""
5Classes for an interactive Calendar control.
6"""
7
d14a1e28
RD
8import _calendar
9
54f9ee45
RD
10import _misc
11import _core
12wx = _core
66c033b4 13__docfilter__ = wx.__DocFilter(globals())
d14a1e28
RD
14CAL_SUNDAY_FIRST = _calendar.CAL_SUNDAY_FIRST
15CAL_MONDAY_FIRST = _calendar.CAL_MONDAY_FIRST
16CAL_SHOW_HOLIDAYS = _calendar.CAL_SHOW_HOLIDAYS
17CAL_NO_YEAR_CHANGE = _calendar.CAL_NO_YEAR_CHANGE
18CAL_NO_MONTH_CHANGE = _calendar.CAL_NO_MONTH_CHANGE
19CAL_SEQUENTIAL_MONTH_SELECTION = _calendar.CAL_SEQUENTIAL_MONTH_SELECTION
20CAL_SHOW_SURROUNDING_WEEKS = _calendar.CAL_SHOW_SURROUNDING_WEEKS
21CAL_HITTEST_NOWHERE = _calendar.CAL_HITTEST_NOWHERE
22CAL_HITTEST_HEADER = _calendar.CAL_HITTEST_HEADER
23CAL_HITTEST_DAY = _calendar.CAL_HITTEST_DAY
24CAL_HITTEST_INCMONTH = _calendar.CAL_HITTEST_INCMONTH
25CAL_HITTEST_DECMONTH = _calendar.CAL_HITTEST_DECMONTH
26CAL_HITTEST_SURROUNDING_WEEK = _calendar.CAL_HITTEST_SURROUNDING_WEEK
27CAL_BORDER_NONE = _calendar.CAL_BORDER_NONE
28CAL_BORDER_SQUARE = _calendar.CAL_BORDER_SQUARE
29CAL_BORDER_ROUND = _calendar.CAL_BORDER_ROUND
30class CalendarDateAttr(object):
98e665d3 31 """
66c033b4
RD
32 A set of customization attributes for a calendar date, which can be
33 used to control the look of the Calendar object.
98e665d3 34 """
e811c8ce
RD
35 def __repr__(self):
36 return "<%s.%s; proxy of C++ wxCalendarDateAttr instance at %s>" % (self.__class__.__module__, self.__class__.__name__, self.this,)
d14a1e28 37 def __init__(self, *args, **kwargs):
0df68c9f 38 """
a95a7133 39 __init__(self, Colour colText=wxNullColour, Colour colBack=wxNullColour,
98e665d3 40 Colour colBorder=wxNullColour, Font font=wxNullFont,
196addbf 41 int border=CAL_BORDER_NONE) -> CalendarDateAttr
98e665d3
RD
42
43 Create a CalendarDateAttr.
0df68c9f 44 """
d14a1e28
RD
45 newobj = _calendar.new_CalendarDateAttr(*args, **kwargs)
46 self.this = newobj.this
f6bcfd97 47 self.thisown = 1
d14a1e28 48 del newobj.thisown
e811c8ce 49 def SetTextColour(*args, **kwargs):
a95a7133 50 """SetTextColour(self, Colour colText)"""
e811c8ce
RD
51 return _calendar.CalendarDateAttr_SetTextColour(*args, **kwargs)
52
53 def SetBackgroundColour(*args, **kwargs):
a95a7133 54 """SetBackgroundColour(self, Colour colBack)"""
e811c8ce
RD
55 return _calendar.CalendarDateAttr_SetBackgroundColour(*args, **kwargs)
56
57 def SetBorderColour(*args, **kwargs):
a95a7133 58 """SetBorderColour(self, Colour col)"""
e811c8ce
RD
59 return _calendar.CalendarDateAttr_SetBorderColour(*args, **kwargs)
60
61 def SetFont(*args, **kwargs):
a95a7133 62 """SetFont(self, Font font)"""
e811c8ce
RD
63 return _calendar.CalendarDateAttr_SetFont(*args, **kwargs)
64
65 def SetBorder(*args, **kwargs):
a95a7133 66 """SetBorder(self, int border)"""
e811c8ce
RD
67 return _calendar.CalendarDateAttr_SetBorder(*args, **kwargs)
68
69 def SetHoliday(*args, **kwargs):
a95a7133 70 """SetHoliday(self, bool holiday)"""
e811c8ce
RD
71 return _calendar.CalendarDateAttr_SetHoliday(*args, **kwargs)
72
73 def HasTextColour(*args, **kwargs):
a95a7133 74 """HasTextColour(self) -> bool"""
e811c8ce
RD
75 return _calendar.CalendarDateAttr_HasTextColour(*args, **kwargs)
76
77 def HasBackgroundColour(*args, **kwargs):
a95a7133 78 """HasBackgroundColour(self) -> bool"""
e811c8ce
RD
79 return _calendar.CalendarDateAttr_HasBackgroundColour(*args, **kwargs)
80
81 def HasBorderColour(*args, **kwargs):
a95a7133 82 """HasBorderColour(self) -> bool"""
e811c8ce
RD
83 return _calendar.CalendarDateAttr_HasBorderColour(*args, **kwargs)
84
85 def HasFont(*args, **kwargs):
a95a7133 86 """HasFont(self) -> bool"""
e811c8ce
RD
87 return _calendar.CalendarDateAttr_HasFont(*args, **kwargs)
88
89 def HasBorder(*args, **kwargs):
a95a7133 90 """HasBorder(self) -> bool"""
e811c8ce
RD
91 return _calendar.CalendarDateAttr_HasBorder(*args, **kwargs)
92
93 def IsHoliday(*args, **kwargs):
a95a7133 94 """IsHoliday(self) -> bool"""
e811c8ce
RD
95 return _calendar.CalendarDateAttr_IsHoliday(*args, **kwargs)
96
97 def GetTextColour(*args, **kwargs):
a95a7133 98 """GetTextColour(self) -> Colour"""
e811c8ce
RD
99 return _calendar.CalendarDateAttr_GetTextColour(*args, **kwargs)
100
101 def GetBackgroundColour(*args, **kwargs):
a95a7133 102 """GetBackgroundColour(self) -> Colour"""
e811c8ce
RD
103 return _calendar.CalendarDateAttr_GetBackgroundColour(*args, **kwargs)
104
105 def GetBorderColour(*args, **kwargs):
a95a7133 106 """GetBorderColour(self) -> Colour"""
e811c8ce
RD
107 return _calendar.CalendarDateAttr_GetBorderColour(*args, **kwargs)
108
109 def GetFont(*args, **kwargs):
a95a7133 110 """GetFont(self) -> Font"""
e811c8ce
RD
111 return _calendar.CalendarDateAttr_GetFont(*args, **kwargs)
112
113 def GetBorder(*args, **kwargs):
a95a7133 114 """GetBorder(self) -> int"""
e811c8ce
RD
115 return _calendar.CalendarDateAttr_GetBorder(*args, **kwargs)
116
f6bcfd97 117
d14a1e28
RD
118class CalendarDateAttrPtr(CalendarDateAttr):
119 def __init__(self, this):
120 self.this = this
121 if not hasattr(self,"thisown"): self.thisown = 0
122 self.__class__ = CalendarDateAttr
123_calendar.CalendarDateAttr_swigregister(CalendarDateAttrPtr)
f6bcfd97 124
54f9ee45 125class CalendarEvent(_core.CommandEvent):
e811c8ce
RD
126 def __repr__(self):
127 return "<%s.%s; proxy of C++ wxCalendarEvent instance at %s>" % (self.__class__.__module__, self.__class__.__name__, self.this,)
d14a1e28 128 def __init__(self, *args, **kwargs):
a95a7133 129 """__init__(self, CalendarCtrl cal, wxEventType type) -> CalendarEvent"""
d14a1e28
RD
130 newobj = _calendar.new_CalendarEvent(*args, **kwargs)
131 self.this = newobj.this
f6bcfd97 132 self.thisown = 1
d14a1e28 133 del newobj.thisown
e811c8ce 134 def GetDate(*args, **kwargs):
a95a7133 135 """GetDate(self) -> DateTime"""
e811c8ce
RD
136 return _calendar.CalendarEvent_GetDate(*args, **kwargs)
137
c9c7117a 138 def SetDate(*args, **kwargs):
a95a7133 139 """SetDate(self, DateTime date)"""
c9c7117a
RD
140 return _calendar.CalendarEvent_SetDate(*args, **kwargs)
141
142 def SetWeekDay(*args, **kwargs):
a95a7133 143 """SetWeekDay(self, int wd)"""
c9c7117a
RD
144 return _calendar.CalendarEvent_SetWeekDay(*args, **kwargs)
145
e811c8ce 146 def GetWeekDay(*args, **kwargs):
a95a7133 147 """GetWeekDay(self) -> int"""
e811c8ce
RD
148 return _calendar.CalendarEvent_GetWeekDay(*args, **kwargs)
149
1fbf26be
RD
150 def PySetDate(self, date):
151 """takes datetime.datetime or datetime.date object"""
7e63a440 152 self.SetDate(_pydate2wxdate(date))
1fbf26be
RD
153
154 def PyGetDate(self):
155 """returns datetime.date object"""
7e63a440 156 return _wxdate2pydate(self.GetDate())
1fbf26be 157
f6bcfd97 158
d14a1e28
RD
159class CalendarEventPtr(CalendarEvent):
160 def __init__(self, this):
f6bcfd97 161 self.this = this
d14a1e28
RD
162 if not hasattr(self,"thisown"): self.thisown = 0
163 self.__class__ = CalendarEvent
164_calendar.CalendarEvent_swigregister(CalendarEventPtr)
165
166wxEVT_CALENDAR_DOUBLECLICKED = _calendar.wxEVT_CALENDAR_DOUBLECLICKED
167wxEVT_CALENDAR_SEL_CHANGED = _calendar.wxEVT_CALENDAR_SEL_CHANGED
168wxEVT_CALENDAR_DAY_CHANGED = _calendar.wxEVT_CALENDAR_DAY_CHANGED
169wxEVT_CALENDAR_MONTH_CHANGED = _calendar.wxEVT_CALENDAR_MONTH_CHANGED
170wxEVT_CALENDAR_YEAR_CHANGED = _calendar.wxEVT_CALENDAR_YEAR_CHANGED
171wxEVT_CALENDAR_WEEKDAY_CLICKED = _calendar.wxEVT_CALENDAR_WEEKDAY_CLICKED
172EVT_CALENDAR = wx.PyEventBinder( wxEVT_CALENDAR_DOUBLECLICKED, 1)
173EVT_CALENDAR_SEL_CHANGED = wx.PyEventBinder( wxEVT_CALENDAR_SEL_CHANGED, 1)
174EVT_CALENDAR_DAY = wx.PyEventBinder( wxEVT_CALENDAR_DAY_CHANGED, 1)
175EVT_CALENDAR_MONTH = wx.PyEventBinder( wxEVT_CALENDAR_MONTH_CHANGED, 1)
176EVT_CALENDAR_YEAR = wx.PyEventBinder( wxEVT_CALENDAR_YEAR_CHANGED, 1)
177EVT_CALENDAR_WEEKDAY_CLICKED = wx.PyEventBinder( wxEVT_CALENDAR_WEEKDAY_CLICKED, 1)
178
54f9ee45 179class CalendarCtrl(_core.Control):
66c033b4
RD
180 """
181 The calendar control allows the user to pick a date interactively.
182
183 The CalendarCtrl displays a window containing several parts: the
184 control to pick the month and the year at the top (either or both of
185 them may be disabled) and a month area below them which shows all the
186 days in the month. The user can move the current selection using the
187 keyboard and select the date (generating EVT_CALENDAR event) by
188 pressing <Return> or double clicking it.
189
190 It has advanced possibilities for the customization of its
191 display. All global settings (such as colours and fonts used) can, of
192 course, be changed. But also, the display style for each day in the
193 month can be set independently using CalendarDateAttr class.
194
195 An item without custom attributes is drawn with the default colours
196 and font and without border, but setting custom attributes with
197 SetAttr allows to modify its appearance. Just create a custom
198 attribute object and set it for the day you want to be displayed
199 specially A day may be marked as being a holiday, (even if it is not
200 recognized as one by wx.DateTime) by using the SetHoliday method.
201
202 As the attributes are specified for each day, they may change when the
203 month is changed, so you will often want to update them in an
204 EVT_CALENDAR_MONTH event handler.
66c033b4 205 """
e811c8ce
RD
206 def __repr__(self):
207 return "<%s.%s; proxy of C++ wxCalendarCtrl instance at %s>" % (self.__class__.__module__, self.__class__.__name__, self.this,)
d14a1e28 208 def __init__(self, *args, **kwargs):
0df68c9f 209 """
a95a7133 210 __init__(self, Window parent, int id=-1, DateTime date=DefaultDateTime,
0df68c9f
RD
211 Point pos=DefaultPosition, Size size=DefaultSize,
212 long style=wxCAL_SHOW_HOLIDAYS|wxWANTS_CHARS,
b2dc1044 213 String name=CalendarNameStr) -> CalendarCtrl
98e665d3
RD
214
215 Create and show a calendar control.
0df68c9f 216 """
d14a1e28
RD
217 newobj = _calendar.new_CalendarCtrl(*args, **kwargs)
218 self.this = newobj.this
f6bcfd97 219 self.thisown = 1
d14a1e28 220 del newobj.thisown
0220cbc1 221 self._setOORInfo(self)
e811c8ce
RD
222
223 def Create(*args, **kwargs):
0df68c9f 224 """
a95a7133 225 Create(self, Window parent, int id, DateTime date=DefaultDateTime,
0df68c9f
RD
226 Point pos=DefaultPosition, Size size=DefaultSize,
227 long style=wxCAL_SHOW_HOLIDAYS|wxWANTS_CHARS,
b2dc1044 228 String name=CalendarNameStr) -> bool
98e665d3 229
66c033b4
RD
230 Acutally create the GUI portion of the CalendarCtrl for 2-phase
231 creation.
0df68c9f 232 """
e811c8ce
RD
233 return _calendar.CalendarCtrl_Create(*args, **kwargs)
234
235 def SetDate(*args, **kwargs):
98e665d3 236 """
a95a7133 237 SetDate(self, DateTime date)
98e665d3
RD
238
239 Sets the current date.
240 """
e811c8ce
RD
241 return _calendar.CalendarCtrl_SetDate(*args, **kwargs)
242
243 def GetDate(*args, **kwargs):
98e665d3 244 """
a95a7133 245 GetDate(self) -> DateTime
98e665d3
RD
246
247 Gets the currently selected date.
248 """
e811c8ce
RD
249 return _calendar.CalendarCtrl_GetDate(*args, **kwargs)
250
251 def SetLowerDateLimit(*args, **kwargs):
98e665d3 252 """
a95a7133 253 SetLowerDateLimit(self, DateTime date=DefaultDateTime) -> bool
e811c8ce 254
98e665d3
RD
255 set the range in which selection can occur
256 """
257 return _calendar.CalendarCtrl_SetLowerDateLimit(*args, **kwargs)
e811c8ce
RD
258
259 def SetUpperDateLimit(*args, **kwargs):
98e665d3 260 """
a95a7133 261 SetUpperDateLimit(self, DateTime date=DefaultDateTime) -> bool
98e665d3
RD
262
263 set the range in which selection can occur
264 """
e811c8ce
RD
265 return _calendar.CalendarCtrl_SetUpperDateLimit(*args, **kwargs)
266
98e665d3
RD
267 def GetLowerDateLimit(*args, **kwargs):
268 """
a95a7133 269 GetLowerDateLimit(self) -> DateTime
98e665d3
RD
270
271 get the range in which selection can occur
272 """
273 return _calendar.CalendarCtrl_GetLowerDateLimit(*args, **kwargs)
274
e811c8ce 275 def GetUpperDateLimit(*args, **kwargs):
98e665d3 276 """
a95a7133 277 GetUpperDateLimit(self) -> DateTime
98e665d3
RD
278
279 get the range in which selection can occur
280 """
e811c8ce
RD
281 return _calendar.CalendarCtrl_GetUpperDateLimit(*args, **kwargs)
282
283 def SetDateRange(*args, **kwargs):
98e665d3 284 """
a95a7133 285 SetDateRange(self, DateTime lowerdate=DefaultDateTime, DateTime upperdate=DefaultDateTime) -> bool
98e665d3
RD
286
287 set the range in which selection can occur
288 """
e811c8ce
RD
289 return _calendar.CalendarCtrl_SetDateRange(*args, **kwargs)
290
291 def EnableYearChange(*args, **kwargs):
98e665d3 292 """
a95a7133 293 EnableYearChange(self, bool enable=True)
98e665d3
RD
294
295 This function should be used instead of changing CAL_NO_YEAR_CHANGE
296 style bit directly. It allows or disallows the user to change the year
297 interactively.
298 """
e811c8ce
RD
299 return _calendar.CalendarCtrl_EnableYearChange(*args, **kwargs)
300
301 def EnableMonthChange(*args, **kwargs):
98e665d3 302 """
a95a7133 303 EnableMonthChange(self, bool enable=True)
98e665d3 304
66c033b4
RD
305 This function should be used instead of changing CAL_NO_MONTH_CHANGE
306 style bit. It allows or disallows the user to change the month
307 interactively. Note that if the month can not be changed, the year can
308 not be changed either.
98e665d3 309 """
e811c8ce
RD
310 return _calendar.CalendarCtrl_EnableMonthChange(*args, **kwargs)
311
312 def EnableHolidayDisplay(*args, **kwargs):
98e665d3 313 """
a95a7133 314 EnableHolidayDisplay(self, bool display=True)
98e665d3 315
66c033b4
RD
316 This function should be used instead of changing CAL_SHOW_HOLIDAYS
317 style bit directly. It enables or disables the special highlighting of
318 the holidays.
98e665d3 319 """
e811c8ce
RD
320 return _calendar.CalendarCtrl_EnableHolidayDisplay(*args, **kwargs)
321
322 def SetHeaderColours(*args, **kwargs):
98e665d3 323 """
a95a7133 324 SetHeaderColours(self, Colour colFg, Colour colBg)
98e665d3 325
66c033b4 326 Header colours are used for painting the weekdays at the top.
98e665d3 327 """
e811c8ce
RD
328 return _calendar.CalendarCtrl_SetHeaderColours(*args, **kwargs)
329
330 def GetHeaderColourFg(*args, **kwargs):
98e665d3 331 """
a95a7133 332 GetHeaderColourFg(self) -> Colour
98e665d3 333
66c033b4 334 Header colours are used for painting the weekdays at the top.
98e665d3 335 """
e811c8ce
RD
336 return _calendar.CalendarCtrl_GetHeaderColourFg(*args, **kwargs)
337
338 def GetHeaderColourBg(*args, **kwargs):
98e665d3 339 """
a95a7133 340 GetHeaderColourBg(self) -> Colour
98e665d3 341
66c033b4 342 Header colours are used for painting the weekdays at the top.
98e665d3 343 """
e811c8ce
RD
344 return _calendar.CalendarCtrl_GetHeaderColourBg(*args, **kwargs)
345
346 def SetHighlightColours(*args, **kwargs):
98e665d3 347 """
a95a7133 348 SetHighlightColours(self, Colour colFg, Colour colBg)
98e665d3 349
66c033b4 350 Highlight colour is used for the currently selected date.
98e665d3 351 """
e811c8ce
RD
352 return _calendar.CalendarCtrl_SetHighlightColours(*args, **kwargs)
353
354 def GetHighlightColourFg(*args, **kwargs):
98e665d3 355 """
a95a7133 356 GetHighlightColourFg(self) -> Colour
98e665d3 357
66c033b4 358 Highlight colour is used for the currently selected date.
98e665d3 359 """
e811c8ce
RD
360 return _calendar.CalendarCtrl_GetHighlightColourFg(*args, **kwargs)
361
362 def GetHighlightColourBg(*args, **kwargs):
98e665d3 363 """
a95a7133 364 GetHighlightColourBg(self) -> Colour
98e665d3 365
66c033b4 366 Highlight colour is used for the currently selected date.
98e665d3 367 """
e811c8ce
RD
368 return _calendar.CalendarCtrl_GetHighlightColourBg(*args, **kwargs)
369
370 def SetHolidayColours(*args, **kwargs):
98e665d3 371 """
a95a7133 372 SetHolidayColours(self, Colour colFg, Colour colBg)
98e665d3 373
66c033b4
RD
374 Holiday colour is used for the holidays (if CAL_SHOW_HOLIDAYS style is
375 used).
98e665d3 376 """
e811c8ce
RD
377 return _calendar.CalendarCtrl_SetHolidayColours(*args, **kwargs)
378
379 def GetHolidayColourFg(*args, **kwargs):
98e665d3 380 """
a95a7133 381 GetHolidayColourFg(self) -> Colour
98e665d3 382
66c033b4
RD
383 Holiday colour is used for the holidays (if CAL_SHOW_HOLIDAYS style is
384 used).
98e665d3 385 """
e811c8ce
RD
386 return _calendar.CalendarCtrl_GetHolidayColourFg(*args, **kwargs)
387
388 def GetHolidayColourBg(*args, **kwargs):
98e665d3 389 """
a95a7133 390 GetHolidayColourBg(self) -> Colour
98e665d3 391
66c033b4
RD
392 Holiday colour is used for the holidays (if CAL_SHOW_HOLIDAYS style is
393 used).
98e665d3 394 """
e811c8ce
RD
395 return _calendar.CalendarCtrl_GetHolidayColourBg(*args, **kwargs)
396
397 def GetAttr(*args, **kwargs):
98e665d3 398 """
a95a7133 399 GetAttr(self, size_t day) -> CalendarDateAttr
98e665d3 400
66c033b4
RD
401 Returns the attribute for the given date (should be in the range
402 1...31). The returned value may be None
98e665d3 403 """
e811c8ce
RD
404 return _calendar.CalendarCtrl_GetAttr(*args, **kwargs)
405
406 def SetAttr(*args, **kwargs):
98e665d3 407 """
a95a7133 408 SetAttr(self, size_t day, CalendarDateAttr attr)
98e665d3 409
66c033b4
RD
410 Associates the attribute with the specified date (in the range
411 1...31). If the attribute passed is None, the items attribute is
412 cleared.
98e665d3 413 """
e811c8ce
RD
414 return _calendar.CalendarCtrl_SetAttr(*args, **kwargs)
415
416 def SetHoliday(*args, **kwargs):
98e665d3 417 """
a95a7133 418 SetHoliday(self, size_t day)
98e665d3
RD
419
420 Marks the specified day as being a holiday in the current month.
421 """
e811c8ce
RD
422 return _calendar.CalendarCtrl_SetHoliday(*args, **kwargs)
423
424 def ResetAttr(*args, **kwargs):
98e665d3 425 """
a95a7133 426 ResetAttr(self, size_t day)
98e665d3 427
66c033b4
RD
428 Clears any attributes associated with the given day (in the range
429 1...31).
98e665d3 430 """
e811c8ce
RD
431 return _calendar.CalendarCtrl_ResetAttr(*args, **kwargs)
432
433 def HitTest(*args, **kwargs):
98e665d3
RD
434 """
435 HitTest(Point pos) -> (result, date, weekday)
436
66c033b4
RD
437 Returns 3-tuple with information about the given position on the
438 calendar control. The first value of the tuple is a result code and
41e2b43e 439 determines the validity of the remaining two values.
98e665d3
RD
440 """
441 return _calendar.CalendarCtrl_HitTest(*args, **kwargs)
e811c8ce 442
c9c7117a 443 def GetMonthControl(*args, **kwargs):
98e665d3 444 """
a95a7133 445 GetMonthControl(self) -> Control
98e665d3 446
66c033b4 447 Get the currently shown control for month.
98e665d3 448 """
c9c7117a
RD
449 return _calendar.CalendarCtrl_GetMonthControl(*args, **kwargs)
450
451 def GetYearControl(*args, **kwargs):
98e665d3 452 """
a95a7133 453 GetYearControl(self) -> Control
98e665d3 454
66c033b4 455 Get the currently shown control for year.
98e665d3 456 """
c9c7117a
RD
457 return _calendar.CalendarCtrl_GetYearControl(*args, **kwargs)
458
22bfe96c 459 def GetClassDefaultAttributes(*args, **kwargs):
110da5b0
RD
460 """
461 GetClassDefaultAttributes(int variant=WINDOW_VARIANT_NORMAL) -> VisualAttributes
462
463 Get the default attributes for this class. This is useful if you want
464 to use the same font or colour in your own control as in a standard
465 control -- which is a much better idea than hard coding specific
466 colours or fonts which might look completely out of place on the
467 user's system, especially if it uses themes.
468
469 The variant parameter is only relevant under Mac currently and is
470 ignore under other platforms. Under Mac, it will change the size of
471 the returned font. See `wx.Window.SetWindowVariant` for more about
472 this.
473 """
22bfe96c
RD
474 return _calendar.CalendarCtrl_GetClassDefaultAttributes(*args, **kwargs)
475
476 GetClassDefaultAttributes = staticmethod(GetClassDefaultAttributes)
1fbf26be
RD
477 def PySetDate(self, date):
478 """takes datetime.datetime or datetime.date object"""
7e63a440 479 self.SetDate(_pydate2wxdate(date))
1fbf26be
RD
480
481 def PyGetDate(self):
482 """returns datetime.date object"""
7e63a440 483 return _wxdate2pydate(self.GetDate())
1fbf26be
RD
484
485 def PySetLowerDateLimit(self, date):
486 """takes datetime.datetime or datetime.date object"""
7e63a440 487 self.SetLowerDateLimit(_pydate2wxdate(date))
1fbf26be
RD
488
489 def PySetUpperDateLimit(self, date):
490 """takes datetime.datetime or datetime.date object"""
7e63a440 491 self.SetUpperDateLimit(_pydate2wxdate(date))
1fbf26be
RD
492
493 def PySetDateRange(self, lowerdate, upperdate):
494 """takes datetime.datetime or datetime.date objects"""
495 self.PySetLowerDateLimit(lowerdate)
496 self.PySetUpperDateLimit(upperdate)
497
498 def PyGetLowerDateLimit(self):
499 """returns datetime.date object"""
7e63a440 500 return _wxdate2pydate(self.GetLowerDateLimit())
1fbf26be
RD
501
502 def PyGetUpperDateLimit(self):
503 """returns datetime.date object"""
7e63a440 504 return _wxdate2pydate(self.GetUpperDateLimit())
1fbf26be 505
f6bcfd97 506
d14a1e28
RD
507class CalendarCtrlPtr(CalendarCtrl):
508 def __init__(self, this):
509 self.this = this
510 if not hasattr(self,"thisown"): self.thisown = 0
511 self.__class__ = CalendarCtrl
512_calendar.CalendarCtrl_swigregister(CalendarCtrlPtr)
b2dc1044
RD
513cvar = _calendar.cvar
514CalendarNameStr = cvar.CalendarNameStr
f6bcfd97 515
d14a1e28 516def PreCalendarCtrl(*args, **kwargs):
98e665d3
RD
517 """
518 PreCalendarCtrl() -> CalendarCtrl
519
520 Precreate a CalendarCtrl for 2-phase creation.
521 """
d14a1e28 522 val = _calendar.new_PreCalendarCtrl(*args, **kwargs)
aa2a5b86
RD
523 val.thisown = 1
524 return val
525
22bfe96c 526def CalendarCtrl_GetClassDefaultAttributes(*args, **kwargs):
110da5b0
RD
527 """
528 CalendarCtrl_GetClassDefaultAttributes(int variant=WINDOW_VARIANT_NORMAL) -> VisualAttributes
529
530 Get the default attributes for this class. This is useful if you want
531 to use the same font or colour in your own control as in a standard
532 control -- which is a much better idea than hard coding specific
533 colours or fonts which might look completely out of place on the
534 user's system, especially if it uses themes.
535
536 The variant parameter is only relevant under Mac currently and is
537 ignore under other platforms. Under Mac, it will change the size of
538 the returned font. See `wx.Window.SetWindowVariant` for more about
539 this.
540 """
22bfe96c
RD
541 return _calendar.CalendarCtrl_GetClassDefaultAttributes(*args, **kwargs)
542
7e63a440 543def _pydate2wxdate(date):
1fbf26be
RD
544 import datetime
545 assert isinstance(date, (datetime.datetime, datetime.date))
546 tt = date.timetuple()
547 dmy = (tt[2], tt[1]-1, tt[0])
548 return wx.DateTimeFromDMY(*dmy)
549
7e63a440 550def _wxdate2pydate(date):
1fbf26be
RD
551 import datetime
552 assert isinstance(date, wx.DateTime)
7e63a440
RD
553 if date.IsValid():
554 ymd = map(int, date.FormatISODate().split('-'))
555 return datetime.date(*ymd)
556 else:
557 return None
1fbf26be 558
f6bcfd97 559