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 //---------------------------------------------------------------------------
139 MAKE_CONST_WXSTRING(CalendarNameStr);
143 class wxCalendarCtrl : public wxControl
146 %pythonAppend wxCalendarCtrl "self._setOORInfo(self)"
147 %pythonAppend wxCalendarCtrl() ""
149 wxCalendarCtrl(wxWindow *parent,
151 const wxDateTime& date = wxDefaultDateTime,
152 const wxPoint& pos = wxDefaultPosition,
153 const wxSize& size = wxDefaultSize,
154 long style = wxCAL_SHOW_HOLIDAYS | wxWANTS_CHARS,
155 const wxString& name = wxPyCalendarNameStr);
156 %name(PreCalendarCtrl)wxCalendarCtrl();
158 bool Create(wxWindow *parent,
160 const wxDateTime& date = wxDefaultDateTime,
161 const wxPoint& pos = wxDefaultPosition,
162 const wxSize& size = wxDefaultSize,
163 long style = wxCAL_SHOW_HOLIDAYS | wxWANTS_CHARS,
164 const wxString& name = wxPyCalendarNameStr);
167 // set/get the current date
168 // ------------------------
170 void SetDate(const wxDateTime& date);
171 const wxDateTime& GetDate() const;
173 // set/get the range in which selection can occur
174 // ---------------------------------------------
176 bool SetLowerDateLimit(const wxDateTime& date = wxDefaultDateTime);
177 const wxDateTime& GetLowerDateLimit() const;
178 bool SetUpperDateLimit(const wxDateTime& date = wxDefaultDateTime);
179 const wxDateTime& GetUpperDateLimit() const;
181 bool SetDateRange(const wxDateTime& lowerdate = wxDefaultDateTime,
182 const wxDateTime& upperdate = wxDefaultDateTime);
188 // some calendar styles can't be changed after the control creation by
189 // just using SetWindowStyle() and Refresh() and the functions below
190 // should be used instead for them
192 // corresponds to wxCAL_NO_YEAR_CHANGE bit
193 void EnableYearChange(bool enable = True);
195 // corresponds to wxCAL_NO_MONTH_CHANGE bit
196 void EnableMonthChange(bool enable = True);
198 // corresponds to wxCAL_SHOW_HOLIDAYS bit
199 void EnableHolidayDisplay(bool display = True);
204 // header colours are used for painting the weekdays at the top
205 void SetHeaderColours(const wxColour& colFg, const wxColour& colBg);
206 wxColour GetHeaderColourFg() const;
207 wxColour GetHeaderColourBg() const;
209 // highlight colour is used for the currently selected date
210 void SetHighlightColours(const wxColour& colFg, const wxColour& colBg);
211 wxColour GetHighlightColourFg() const;
212 wxColour GetHighlightColourBg() const;
214 // holiday colour is used for the holidays (if style & wxCAL_SHOW_HOLIDAYS)
215 void SetHolidayColours(const wxColour& colFg, const wxColour& colBg);
216 wxColour GetHolidayColourFg() const;
217 wxColour GetHolidayColourBg() const;
219 // an item without custom attributes is drawn with the default colours and
220 // font and without border, setting custom attributes allows to modify this
222 // the day parameter should be in 1..31 range, for days 29, 30, 31 the
223 // corresponding attribute is just unused if there is no such day in the
226 wxCalendarDateAttr *GetAttr(size_t day) const;
227 void SetAttr(size_t day, wxCalendarDateAttr *attr);
229 void SetHoliday(size_t day);
231 void ResetAttr(size_t day);
233 // returns one of wxCAL_HITTEST_XXX constants and fills either date or wd
234 // with the corresponding value (none for NOWHERE, the date for DAY and wd
236 wxCalendarHitTestResult HitTest(const wxPoint& pos,
237 wxDateTime *date = NULL,
238 wxDateTime::WeekDay *wd = NULL);
241 bool Enable(bool enable = True);
242 bool Show(bool show = True);
244 // get the currently shown control for month/year
245 wxControl *GetMonthControl() const;
246 wxControl *GetYearControl() const;
250 //---------------------------------------------------------------------------
255 //---------------------------------------------------------------------------