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