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