]> git.saurik.com Git - wxWidgets.git/blob - wxPython/src/calendar.i
Better wrapper for wxListCtrl.GetColumn, and some other cleanup
[wxWidgets.git] / wxPython / src / calendar.i
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 %{
17 #include "export.h"
18 #include <wx/calctrl.h>
19 %}
20
21 //----------------------------------------------------------------------
22
23 %include typemaps.i
24 %include my_typemaps.i
25
26 // Import some definitions of other classes, etc.
27 %import _defs.i
28 %import misc.i
29 %import windows.i
30 %import controls.i
31 %import events.i
32 %import utils.i
33
34 %pragma(python) code = "import wx"
35
36 //---------------------------------------------------------------------------
37
38 enum {
39 wxCAL_SUNDAY_FIRST,
40 wxCAL_MONDAY_FIRST,
41 wxCAL_SHOW_HOLIDAYS,
42 wxCAL_NO_YEAR_CHANGE,
43 wxCAL_NO_MONTH_CHANGE,
44 wxCAL_SEQUENTIAL_MONTH_SELECTION,
45 wxCAL_SHOW_SURROUNDING_WEEKS,
46 };
47
48
49 enum wxCalendarHitTestResult
50 {
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
57 };
58
59 // border types for a date
60 enum wxCalendarDateBorder
61 {
62 wxCAL_BORDER_NONE, // no border (default)
63 wxCAL_BORDER_SQUARE, // a rectangular border
64 wxCAL_BORDER_ROUND // a round border
65 };
66
67 //---------------------------------------------------------------------------
68
69
70 class wxCalendarDateAttr
71 {
72 public:
73 // ctors
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);
79
80 %name(wxCalendarDateAttrBorder)
81 wxCalendarDateAttr(wxCalendarDateBorder border,
82 const wxColour& colBorder = wxNullColour);
83
84 // setters
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);
91
92 // accessors
93 bool HasTextColour() const;
94 bool HasBackgroundColour() const;
95 bool HasBorderColour() const;
96 bool HasFont() const;
97 bool HasBorder() const;
98
99 bool IsHoliday() const;
100
101 wxColour GetTextColour() const;
102 wxColour GetBackgroundColour() const;
103 wxColour GetBorderColour() const;
104 wxFont GetFont() const;
105 wxCalendarDateBorder GetBorder() const;
106 };
107
108 //---------------------------------------------------------------------------
109
110 class wxCalendarCtrl;
111
112 class wxCalendarEvent : public wxCommandEvent
113 {
114 public:
115 wxCalendarEvent(wxCalendarCtrl *cal, wxEventType type);
116
117 const wxDateTime& GetDate() const;
118 wxDateTime::WeekDay GetWeekDay() const;
119
120 };
121
122 enum {
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,
129 };
130
131 %pragma(python) code = "
132 def EVT_CALENDAR(win, id, fn):
133 win.Connect(id, -1, wxEVT_CALENDAR_DOUBLECLICKED, fn)
134
135 def EVT_CALENDAR_SEL_CHANGED(win, id, fn):
136 win.Connect(id, -1, wxEVT_CALENDAR_SEL_CHANGED, fn)
137
138 def EVT_CALENDAR_DAY(win, id, fn):
139 win.Connect(id, -1, wxEVT_CALENDAR_DAY_CHANGED, fn)
140
141 def EVT_CALENDAR_MONTH(win, id, fn):
142 win.Connect(id, -1, wxEVT_CALENDAR_MONTH_CHANGED, fn)
143
144 def EVT_CALENDAR_YEAR(win, id, fn):
145 win.Connect(id, -1, wxEVT_CALENDAR_YEAR_CHANGED, fn)
146
147 def EVT_CALENDAR_WEEKDAY_CLICKED(win, id, fn):
148 win.Connect(id, -1, wxEVT_CALENDAR_WEEKDAY_CLICKED, fn)
149
150 "
151
152 //---------------------------------------------------------------------------
153
154 class wxCalendarCtrl : public wxControl
155 {
156 public:
157 // construction
158 wxCalendarCtrl(wxWindow *parent,
159 wxWindowID id,
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();
166
167 bool Create(wxWindow *parent,
168 wxWindowID id,
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");
174
175 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
176 %pragma(python) addtomethod = "wxPreCalendarCtrl:val._setOORInfo(val)"
177
178 // set/get the current date
179 // ------------------------
180
181 void SetDate(const wxDateTime& date);
182 const wxDateTime& GetDate() const;
183
184 // set/get the range in which selection can occur
185 // ---------------------------------------------
186
187 bool SetLowerDateLimit(const wxDateTime& date = wxDefaultDateTime);
188 const wxDateTime& GetLowerDateLimit() const;
189 bool SetUpperDateLimit(const wxDateTime& date = wxDefaultDateTime);
190 const wxDateTime& GetUpperDateLimit() const;
191
192 bool SetDateRange(const wxDateTime& lowerdate = wxDefaultDateTime,
193 const wxDateTime& upperdate = wxDefaultDateTime);
194
195
196 // calendar mode
197 // -------------
198
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
202
203 // corresponds to wxCAL_NO_YEAR_CHANGE bit
204 void EnableYearChange(bool enable = TRUE);
205
206 // corresponds to wxCAL_NO_MONTH_CHANGE bit
207 void EnableMonthChange(bool enable = TRUE);
208
209 // corresponds to wxCAL_SHOW_HOLIDAYS bit
210 void EnableHolidayDisplay(bool display = TRUE);
211
212 // customization
213 // -------------
214
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;
219
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;
224
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;
229
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
232 //
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
235 // current month
236
237 wxCalendarDateAttr *GetAttr(size_t day) const;
238 void SetAttr(size_t day, wxCalendarDateAttr *attr);
239
240 void SetHoliday(size_t day);
241
242 void ResetAttr(size_t day);
243
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
246 // for HEADER)
247 wxCalendarHitTestResult HitTest(const wxPoint& pos,
248 wxDateTime *date = NULL,
249 wxDateTime::WeekDay *wd = NULL);
250
251
252 bool Enable(bool enable = TRUE);
253 bool Show(bool show = TRUE);
254
255 };
256
257
258 //---------------------------------------------------------------------------
259
260 %init %{
261 wxClassInfo::CleanUpClasses();
262 wxClassInfo::InitializeClasses();
263 %}
264
265 //---------------------------------------------------------------------------
266
267 %pragma(python) include="_calextras.py";
268
269 //---------------------------------------------------------------------------
270