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 /////////////////////////////////////////////////////////////////////////////
18 #include <wx/calctrl.h>
21 //----------------------------------------------------------------------
24 %include my_typemaps.i
26 // Import some definitions of other classes, etc.
34 %pragma(python) code = "import wx"
36 //---------------------------------------------------------------------------
43 wxCAL_NO_MONTH_CHANGE,
44 wxCAL_SEQUENTIAL_MONTH_SELECTION,
45 wxCAL_SHOW_SURROUNDING_WEEKS,
49 enum wxCalendarHitTestResult
51 wxCAL_HITTEST_NOWHERE, // outside of anything
52 wxCAL_HITTEST_HEADER, // on the header (weekdays)
53 wxCAL_HITTEST_DAY, // on a day in the calendar
54 wxCAL_HITTEST_INCMONTH,
55 wxCAL_HITTEST_DECMONTH,
56 wxCAL_HITTEST_SURROUNDING_WEEK
59 // border types for a date
60 enum wxCalendarDateBorder
62 wxCAL_BORDER_NONE, // no border (default)
63 wxCAL_BORDER_SQUARE, // a rectangular border
64 wxCAL_BORDER_ROUND // a round border
67 //---------------------------------------------------------------------------
70 class wxCalendarDateAttr
74 wxCalendarDateAttr(const wxColour& colText,
75 const wxColour& colBack = wxNullColour,
76 const wxColour& colBorder = wxNullColour,
77 const wxFont& font = wxNullFont,
78 wxCalendarDateBorder border = wxCAL_BORDER_NONE);
80 %name(wxCalendarDateAttrBorder)
81 wxCalendarDateAttr(wxCalendarDateBorder border,
82 const wxColour& colBorder = wxNullColour);
85 void SetTextColour(const wxColour& colText);
86 void SetBackgroundColour(const wxColour& colBack);
87 void SetBorderColour(const wxColour& col);
88 void SetFont(const wxFont& font);
89 void SetBorder(wxCalendarDateBorder border);
90 void SetHoliday(bool holiday);
93 bool HasTextColour() const;
94 bool HasBackgroundColour() const;
95 bool HasBorderColour() const;
97 bool HasBorder() const;
99 bool IsHoliday() const;
101 wxColour GetTextColour() const;
102 wxColour GetBackgroundColour() const;
103 wxColour GetBorderColour() const;
104 wxFont GetFont() const;
105 wxCalendarDateBorder GetBorder() const;
108 //---------------------------------------------------------------------------
110 class wxCalendarCtrl;
112 class wxCalendarEvent : public wxCommandEvent
115 wxCalendarEvent(wxCalendarCtrl *cal, wxEventType type);
117 const wxDateTime& GetDate() const;
118 wxDateTime::WeekDay GetWeekDay() const;
123 wxEVT_CALENDAR_DOUBLECLICKED,
124 wxEVT_CALENDAR_SEL_CHANGED,
125 wxEVT_CALENDAR_DAY_CHANGED,
126 wxEVT_CALENDAR_MONTH_CHANGED,
127 wxEVT_CALENDAR_YEAR_CHANGED,
128 wxEVT_CALENDAR_WEEKDAY_CLICKED,
131 %pragma(python) code = "
132 def EVT_CALENDAR(win, id, fn):
133 win.Connect(id, -1, wxEVT_CALENDAR_DOUBLECLICKED, fn)
135 def EVT_CALENDAR_SEL_CHANGED(win, id, fn):
136 win.Connect(id, -1, wxEVT_CALENDAR_SEL_CHANGED, fn)
138 def EVT_CALENDAR_DAY(win, id, fn):
139 win.Connect(id, -1, wxEVT_CALENDAR_DAY_CHANGED, fn)
141 def EVT_CALENDAR_MONTH(win, id, fn):
142 win.Connect(id, -1, wxEVT_CALENDAR_MONTH_CHANGED, fn)
144 def EVT_CALENDAR_YEAR(win, id, fn):
145 win.Connect(id, -1, wxEVT_CALENDAR_YEAR_CHANGED, fn)
147 def EVT_CALENDAR_WEEKDAY_CLICKED(win, id, fn):
148 win.Connect(id, -1, wxEVT_CALENDAR_WEEKDAY_CLICKED, fn)
152 //---------------------------------------------------------------------------
154 class wxCalendarCtrl : public wxControl
158 wxCalendarCtrl(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 char* name = "calendar");
165 %name(wxPreCalendarCtrl)wxCalendarCtrl();
167 bool Create(wxWindow *parent,
169 const wxDateTime& date = wxDefaultDateTime,
170 const wxPoint& pos = wxDefaultPosition,
171 const wxSize& size = wxDefaultSize,
172 long style = wxCAL_SHOW_HOLIDAYS | wxWANTS_CHARS,
173 const char* name = "calendar");
175 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
176 %pragma(python) addtomethod = "wxPreCalendarCtrl:val._setOORInfo(val)"
178 // set/get the current date
179 // ------------------------
181 void SetDate(const wxDateTime& date);
182 const wxDateTime& GetDate() const;
184 // set/get the range in which selection can occur
185 // ---------------------------------------------
187 bool SetLowerDateLimit(const wxDateTime& date = wxDefaultDateTime);
188 const wxDateTime& GetLowerDateLimit() const;
189 bool SetUpperDateLimit(const wxDateTime& date = wxDefaultDateTime);
190 const wxDateTime& GetUpperDateLimit() const;
192 bool SetDateRange(const wxDateTime& lowerdate = wxDefaultDateTime,
193 const wxDateTime& upperdate = wxDefaultDateTime);
199 // some calendar styles can't be changed after the control creation by
200 // just using SetWindowStyle() and Refresh() and the functions below
201 // should be used instead for them
203 // corresponds to wxCAL_NO_YEAR_CHANGE bit
204 void EnableYearChange(bool enable = TRUE);
206 // corresponds to wxCAL_NO_MONTH_CHANGE bit
207 void EnableMonthChange(bool enable = TRUE);
209 // corresponds to wxCAL_SHOW_HOLIDAYS bit
210 void EnableHolidayDisplay(bool display = TRUE);
215 // header colours are used for painting the weekdays at the top
216 void SetHeaderColours(const wxColour& colFg, const wxColour& colBg);
217 wxColour GetHeaderColourFg() const;
218 wxColour GetHeaderColourBg() const;
220 // highlight colour is used for the currently selected date
221 void SetHighlightColours(const wxColour& colFg, const wxColour& colBg);
222 wxColour GetHighlightColourFg() const;
223 wxColour GetHighlightColourBg() const;
225 // holiday colour is used for the holidays (if style & wxCAL_SHOW_HOLIDAYS)
226 void SetHolidayColours(const wxColour& colFg, const wxColour& colBg);
227 wxColour GetHolidayColourFg() const;
228 wxColour GetHolidayColourBg() const;
230 // an item without custom attributes is drawn with the default colours and
231 // font and without border, setting custom attributes allows to modify this
233 // the day parameter should be in 1..31 range, for days 29, 30, 31 the
234 // corresponding attribute is just unused if there is no such day in the
237 wxCalendarDateAttr *GetAttr(size_t day) const;
238 void SetAttr(size_t day, wxCalendarDateAttr *attr);
240 void SetHoliday(size_t day);
242 void ResetAttr(size_t day);
244 // returns one of wxCAL_HITTEST_XXX constants and fills either date or wd
245 // with the corresponding value (none for NOWHERE, the date for DAY and wd
247 wxCalendarHitTestResult HitTest(const wxPoint& pos,
248 wxDateTime *date = NULL,
249 wxDateTime::WeekDay *wd = NULL);
252 bool Enable(bool enable = TRUE);
253 bool Show(bool show = TRUE);
258 //---------------------------------------------------------------------------
261 wxClassInfo::CleanUpClasses();
262 wxClassInfo::InitializeClasses();
265 //---------------------------------------------------------------------------
267 %pragma(python) include="_calextras.py";
269 //---------------------------------------------------------------------------