]> git.saurik.com Git - wxWidgets.git/blob - wxPython/src/calendar.i
Reworked how stock objects are initialized. They now have an
[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 "wx/wxPython/wxPython.h"
18 #include "wx/wxPython/pyclasses.h"
19
20 #include <wx/calctrl.h>
21 %}
22
23 //----------------------------------------------------------------------
24
25 %import misc.i
26 %pythoncode { wx = core }
27
28 %include _calendar_rename.i
29
30 //---------------------------------------------------------------------------
31
32 enum {
33 wxCAL_SUNDAY_FIRST,
34 wxCAL_MONDAY_FIRST,
35 wxCAL_SHOW_HOLIDAYS,
36 wxCAL_NO_YEAR_CHANGE,
37 wxCAL_NO_MONTH_CHANGE,
38 wxCAL_SEQUENTIAL_MONTH_SELECTION,
39 wxCAL_SHOW_SURROUNDING_WEEKS,
40 };
41
42
43 enum wxCalendarHitTestResult
44 {
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
51 };
52
53 // border types for a date
54 enum wxCalendarDateBorder
55 {
56 wxCAL_BORDER_NONE, // no border (default)
57 wxCAL_BORDER_SQUARE, // a rectangular border
58 wxCAL_BORDER_ROUND // a round border
59 };
60
61 //---------------------------------------------------------------------------
62
63
64 class wxCalendarDateAttr
65 {
66 public:
67 // ctors
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);
73
74 %name(CalendarDateAttrBorder)
75 wxCalendarDateAttr(wxCalendarDateBorder border,
76 const wxColour& colBorder = wxNullColour);
77
78 // setters
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);
85
86 // accessors
87 bool HasTextColour() const;
88 bool HasBackgroundColour() const;
89 bool HasBorderColour() const;
90 bool HasFont() const;
91 bool HasBorder() const;
92
93 bool IsHoliday() const;
94
95 wxColour GetTextColour() const;
96 wxColour GetBackgroundColour() const;
97 wxColour GetBorderColour() const;
98 wxFont GetFont() const;
99 wxCalendarDateBorder GetBorder() const;
100 };
101
102 //---------------------------------------------------------------------------
103
104 class wxCalendarCtrl;
105
106 class wxCalendarEvent : public wxCommandEvent
107 {
108 public:
109 wxCalendarEvent(wxCalendarCtrl *cal, wxEventType type);
110
111 const wxDateTime& GetDate() const;
112 void SetDate(const wxDateTime &date);
113 void SetWeekDay(const wxDateTime::WeekDay wd);
114 wxDateTime::WeekDay GetWeekDay() const;
115
116 };
117
118
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;
125
126
127 %pythoncode {
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)
134 }
135
136
137 //---------------------------------------------------------------------------
138
139 %{
140 DECLARE_DEF_STRING(CalendarNameStr);
141 %}
142
143
144
145 class wxCalendarCtrl : public wxControl
146 {
147 public:
148 %addtofunc wxCalendarCtrl "self._setOORInfo(self)"
149 %addtofunc wxCalendarCtrl() ""
150
151 wxCalendarCtrl(wxWindow *parent,
152 wxWindowID id,
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();
159
160 bool Create(wxWindow *parent,
161 wxWindowID id,
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);
167
168
169 // set/get the current date
170 // ------------------------
171
172 void SetDate(const wxDateTime& date);
173 const wxDateTime& GetDate() const;
174
175 // set/get the range in which selection can occur
176 // ---------------------------------------------
177
178 bool SetLowerDateLimit(const wxDateTime& date = wxDefaultDateTime);
179 const wxDateTime& GetLowerDateLimit() const;
180 bool SetUpperDateLimit(const wxDateTime& date = wxDefaultDateTime);
181 const wxDateTime& GetUpperDateLimit() const;
182
183 bool SetDateRange(const wxDateTime& lowerdate = wxDefaultDateTime,
184 const wxDateTime& upperdate = wxDefaultDateTime);
185
186
187 // calendar mode
188 // -------------
189
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
193
194 // corresponds to wxCAL_NO_YEAR_CHANGE bit
195 void EnableYearChange(bool enable = True);
196
197 // corresponds to wxCAL_NO_MONTH_CHANGE bit
198 void EnableMonthChange(bool enable = True);
199
200 // corresponds to wxCAL_SHOW_HOLIDAYS bit
201 void EnableHolidayDisplay(bool display = True);
202
203 // customization
204 // -------------
205
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;
210
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;
215
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;
220
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
223 //
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
226 // current month
227
228 wxCalendarDateAttr *GetAttr(size_t day) const;
229 void SetAttr(size_t day, wxCalendarDateAttr *attr);
230
231 void SetHoliday(size_t day);
232
233 void ResetAttr(size_t day);
234
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
237 // for HEADER)
238 wxCalendarHitTestResult HitTest(const wxPoint& pos,
239 wxDateTime *date = NULL,
240 wxDateTime::WeekDay *wd = NULL);
241
242
243 bool Enable(bool enable = True);
244 bool Show(bool show = True);
245
246 // get the currently shown control for month/year
247 wxControl *GetMonthControl() const;
248 wxControl *GetYearControl() const;
249 };
250
251
252 //---------------------------------------------------------------------------
253
254 %init %{
255 %}
256
257 //---------------------------------------------------------------------------
258