1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: SWIG definitions for the wxCalendarCtrl
7 // Created: 23-May-2000
9 // Copyright: (c) 2000 by Total Control Software
10 // Licence: wxWindows license
11 /////////////////////////////////////////////////////////////////////////////
17 #include "wx/wxPython/wxPython.h"
18 #include "wx/wxPython/pyclasses.h"
20 #include <wx/calctrl.h>
23 //----------------------------------------------------------------------
26 %pythoncode { wx = core }
28 %include _calendar_rename.i
30 //---------------------------------------------------------------------------
37 wxCAL_NO_MONTH_CHANGE,
38 wxCAL_SEQUENTIAL_MONTH_SELECTION,
39 wxCAL_SHOW_SURROUNDING_WEEKS,
43 enum wxCalendarHitTestResult
45 wxCAL_HITTEST_NOWHERE, // outside of anything
46 wxCAL_HITTEST_HEADER, // on the header (weekdays)
47 wxCAL_HITTEST_DAY, // on a day in the calendar
48 wxCAL_HITTEST_INCMONTH,
49 wxCAL_HITTEST_DECMONTH,
50 wxCAL_HITTEST_SURROUNDING_WEEK
53 // border types for a date
54 enum wxCalendarDateBorder
56 wxCAL_BORDER_NONE, // no border (default)
57 wxCAL_BORDER_SQUARE, // a rectangular border
58 wxCAL_BORDER_ROUND // a round border
61 //---------------------------------------------------------------------------
64 class wxCalendarDateAttr
68 wxCalendarDateAttr(const wxColour& colText,
69 const wxColour& colBack = wxNullColour,
70 const wxColour& colBorder = wxNullColour,
71 const wxFont& font = wxNullFont,
72 wxCalendarDateBorder border = wxCAL_BORDER_NONE);
74 %name(CalendarDateAttrBorder)
75 wxCalendarDateAttr(wxCalendarDateBorder border,
76 const wxColour& colBorder = wxNullColour);
79 void SetTextColour(const wxColour& colText);
80 void SetBackgroundColour(const wxColour& colBack);
81 void SetBorderColour(const wxColour& col);
82 void SetFont(const wxFont& font);
83 void SetBorder(wxCalendarDateBorder border);
84 void SetHoliday(bool holiday);
87 bool HasTextColour() const;
88 bool HasBackgroundColour() const;
89 bool HasBorderColour() const;
91 bool HasBorder() const;
93 bool IsHoliday() const;
95 wxColour GetTextColour() const;
96 wxColour GetBackgroundColour() const;
97 wxColour GetBorderColour() const;
98 wxFont GetFont() const;
99 wxCalendarDateBorder GetBorder() const;
102 //---------------------------------------------------------------------------
104 class wxCalendarCtrl;
106 class wxCalendarEvent : public wxCommandEvent
109 wxCalendarEvent(wxCalendarCtrl *cal, wxEventType type);
111 const wxDateTime& GetDate() const;
112 void SetDate(const wxDateTime &date);
113 void SetWeekDay(const wxDateTime::WeekDay wd);
114 wxDateTime::WeekDay GetWeekDay() const;
119 %constant wxEventType wxEVT_CALENDAR_DOUBLECLICKED;
120 %constant wxEventType wxEVT_CALENDAR_SEL_CHANGED;
121 %constant wxEventType wxEVT_CALENDAR_DAY_CHANGED;
122 %constant wxEventType wxEVT_CALENDAR_MONTH_CHANGED;
123 %constant wxEventType wxEVT_CALENDAR_YEAR_CHANGED;
124 %constant wxEventType wxEVT_CALENDAR_WEEKDAY_CLICKED;
128 EVT_CALENDAR = wx.PyEventBinder( wxEVT_CALENDAR_DOUBLECLICKED, 1)
129 EVT_CALENDAR_SEL_CHANGED = wx.PyEventBinder( wxEVT_CALENDAR_SEL_CHANGED, 1)
130 EVT_CALENDAR_DAY = wx.PyEventBinder( wxEVT_CALENDAR_DAY_CHANGED, 1)
131 EVT_CALENDAR_MONTH = wx.PyEventBinder( wxEVT_CALENDAR_MONTH_CHANGED, 1)
132 EVT_CALENDAR_YEAR = wx.PyEventBinder( wxEVT_CALENDAR_YEAR_CHANGED, 1)
133 EVT_CALENDAR_WEEKDAY_CLICKED = wx.PyEventBinder( wxEVT_CALENDAR_WEEKDAY_CLICKED, 1)
137 //---------------------------------------------------------------------------
140 DECLARE_DEF_STRING(CalendarNameStr);
145 class wxCalendarCtrl : public wxControl
148 %addtofunc wxCalendarCtrl "self._setOORInfo(self)"
149 %addtofunc wxCalendarCtrl() ""
151 wxCalendarCtrl(wxWindow *parent,
153 const wxDateTime& date = wxDefaultDateTime,
154 const wxPoint& pos = wxDefaultPosition,
155 const wxSize& size = wxDefaultSize,
156 long style = wxCAL_SHOW_HOLIDAYS | wxWANTS_CHARS,
157 const wxString& name = wxPyCalendarNameStr);
158 %name(PreCalendarCtrl)wxCalendarCtrl();
160 bool Create(wxWindow *parent,
162 const wxDateTime& date = wxDefaultDateTime,
163 const wxPoint& pos = wxDefaultPosition,
164 const wxSize& size = wxDefaultSize,
165 long style = wxCAL_SHOW_HOLIDAYS | wxWANTS_CHARS,
166 const wxString& name = wxPyCalendarNameStr);
169 // set/get the current date
170 // ------------------------
172 void SetDate(const wxDateTime& date);
173 const wxDateTime& GetDate() const;
175 // set/get the range in which selection can occur
176 // ---------------------------------------------
178 bool SetLowerDateLimit(const wxDateTime& date = wxDefaultDateTime);
179 const wxDateTime& GetLowerDateLimit() const;
180 bool SetUpperDateLimit(const wxDateTime& date = wxDefaultDateTime);
181 const wxDateTime& GetUpperDateLimit() const;
183 bool SetDateRange(const wxDateTime& lowerdate = wxDefaultDateTime,
184 const wxDateTime& upperdate = wxDefaultDateTime);
190 // some calendar styles can't be changed after the control creation by
191 // just using SetWindowStyle() and Refresh() and the functions below
192 // should be used instead for them
194 // corresponds to wxCAL_NO_YEAR_CHANGE bit
195 void EnableYearChange(bool enable = True);
197 // corresponds to wxCAL_NO_MONTH_CHANGE bit
198 void EnableMonthChange(bool enable = True);
200 // corresponds to wxCAL_SHOW_HOLIDAYS bit
201 void EnableHolidayDisplay(bool display = True);
206 // header colours are used for painting the weekdays at the top
207 void SetHeaderColours(const wxColour& colFg, const wxColour& colBg);
208 wxColour GetHeaderColourFg() const;
209 wxColour GetHeaderColourBg() const;
211 // highlight colour is used for the currently selected date
212 void SetHighlightColours(const wxColour& colFg, const wxColour& colBg);
213 wxColour GetHighlightColourFg() const;
214 wxColour GetHighlightColourBg() const;
216 // holiday colour is used for the holidays (if style & wxCAL_SHOW_HOLIDAYS)
217 void SetHolidayColours(const wxColour& colFg, const wxColour& colBg);
218 wxColour GetHolidayColourFg() const;
219 wxColour GetHolidayColourBg() const;
221 // an item without custom attributes is drawn with the default colours and
222 // font and without border, setting custom attributes allows to modify this
224 // the day parameter should be in 1..31 range, for days 29, 30, 31 the
225 // corresponding attribute is just unused if there is no such day in the
228 wxCalendarDateAttr *GetAttr(size_t day) const;
229 void SetAttr(size_t day, wxCalendarDateAttr *attr);
231 void SetHoliday(size_t day);
233 void ResetAttr(size_t day);
235 // returns one of wxCAL_HITTEST_XXX constants and fills either date or wd
236 // with the corresponding value (none for NOWHERE, the date for DAY and wd
238 wxCalendarHitTestResult HitTest(const wxPoint& pos,
239 wxDateTime *date = NULL,
240 wxDateTime::WeekDay *wd = NULL);
243 bool Enable(bool enable = True);
244 bool Show(bool show = True);
246 // get the currently shown control for month/year
247 wxControl *GetMonthControl() const;
248 wxControl *GetYearControl() const;
252 //---------------------------------------------------------------------------
257 //---------------------------------------------------------------------------