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