]> git.saurik.com Git - wxWidgets.git/blob - wxPython/src/calendar.i
Second phase of OOR completed. (Original python object return for
[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 };
45
46
47 enum wxCalendarHitTestResult
48 {
49 wxCAL_HITTEST_NOWHERE, // outside of anything
50 wxCAL_HITTEST_HEADER, // on the header (weekdays)
51 wxCAL_HITTEST_DAY // on a day in the calendar
52 };
53
54 // border types for a date
55 enum wxCalendarDateBorder
56 {
57 wxCAL_BORDER_NONE, // no border (default)
58 wxCAL_BORDER_SQUARE, // a rectangular border
59 wxCAL_BORDER_ROUND // a round border
60 };
61
62 //---------------------------------------------------------------------------
63
64
65 class wxCalendarDateAttr
66 {
67 public:
68 // ctors
69 wxCalendarDateAttr(const wxColour& colText,
70 const wxColour& colBack = wxNullColour,
71 const wxColour& colBorder = wxNullColour,
72 const wxFont& font = wxNullFont,
73 wxCalendarDateBorder border = wxCAL_BORDER_NONE);
74
75 %name(wxCalendarDateAttrBorder)
76 wxCalendarDateAttr(wxCalendarDateBorder border,
77 const wxColour& colBorder = wxNullColour);
78
79 // setters
80 void SetTextColour(const wxColour& colText);
81 void SetBackgroundColour(const wxColour& colBack);
82 void SetBorderColour(const wxColour& col);
83 void SetFont(const wxFont& font);
84 void SetBorder(wxCalendarDateBorder border);
85 void SetHoliday(bool holiday);
86
87 // accessors
88 bool HasTextColour() const;
89 bool HasBackgroundColour() const;
90 bool HasBorderColour() const;
91 bool HasFont() const;
92 bool HasBorder() const;
93
94 bool IsHoliday() const;
95
96 const wxColour& GetTextColour() const;
97 const wxColour& GetBackgroundColour() const;
98 const wxColour& GetBorderColour() const;
99 const wxFont& GetFont() const;
100 wxCalendarDateBorder GetBorder() const;
101 };
102
103 //---------------------------------------------------------------------------
104
105 class wxCalendarCtrl;
106
107 class wxCalendarEvent : public wxCommandEvent
108 {
109 public:
110 wxCalendarEvent(wxCalendarCtrl *cal, wxEventType type);
111
112 const wxDateTime& GetDate() const;
113 wxDateTime::WeekDay GetWeekDay() const;
114
115 };
116
117 enum {
118 wxEVT_CALENDAR_DOUBLECLICKED,
119 wxEVT_CALENDAR_SEL_CHANGED,
120 wxEVT_CALENDAR_DAY_CHANGED,
121 wxEVT_CALENDAR_MONTH_CHANGED,
122 wxEVT_CALENDAR_YEAR_CHANGED,
123 wxEVT_CALENDAR_WEEKDAY_CLICKED,
124 };
125
126 %pragma(python) code = "
127 def EVT_CALENDAR(win, id, fn):
128 win.Connect(id, -1, wxEVT_CALENDAR_DOUBLECLICKED, fn)
129
130 def EVT_CALENDAR_SEL_CHANGED(win, id, fn):
131 win.Connect(id, -1, wxEVT_CALENDAR_SEL_CHANGED, fn)
132
133 def EVT_CALENDAR_DAY(win, id, fn):
134 win.Connect(id, -1, wxEVT_CALENDAR_DAY_CHANGED, fn)
135
136 def EVT_CALENDAR_MONTH(win, id, fn):
137 win.Connect(id, -1, wxEVT_CALENDAR_MONTH_CHANGED, fn)
138
139 def EVT_CALENDAR_YEAR(win, id, fn):
140 win.Connect(id, -1, wxEVT_CALENDAR_YEAR_CHANGED, fn)
141
142 def EVT_CALENDAR_WEEKDAY_CLICKED(win, id, fn):
143 win.Connect(id, -1, wxEVT_CALENDAR_WEEKDAY_CLICKED, fn)
144
145 "
146
147 //---------------------------------------------------------------------------
148
149 class wxCalendarCtrl : public wxControl
150 {
151 public:
152 // construction
153 wxCalendarCtrl(wxWindow *parent,
154 wxWindowID id,
155 const wxDateTime& date = wxDefaultDateTime,
156 const wxPoint& pos = wxDefaultPosition,
157 const wxSize& size = wxDefaultSize,
158 long style = wxCAL_SHOW_HOLIDAYS | wxWANTS_CHARS,
159 const char* name = "calendar");
160 %name(wxPreCalendarCtrl)wxCalendarCtrl();
161
162 bool Create(wxWindow *parent,
163 wxWindowID id,
164 const wxDateTime& date = wxDefaultDateTime,
165 const wxPoint& pos = wxDefaultPosition,
166 const wxSize& size = wxDefaultSize,
167 long style = wxCAL_SHOW_HOLIDAYS | wxWANTS_CHARS,
168 const char* name = "calendar");
169
170 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
171 %pragma(python) addtomethod = "wxPreCalendarCtrl:val._setOORInfo(self)"
172
173 // set/get the current date
174 // ------------------------
175
176 void SetDate(const wxDateTime& date);
177 const wxDateTime& GetDate() const;
178
179 // calendar mode
180 // -------------
181
182 // some calendar styles can't be changed after the control creation by
183 // just using SetWindowStyle() and Refresh() and the functions below
184 // should be used instead for them
185
186 // corresponds to wxCAL_NO_YEAR_CHANGE bit
187 void EnableYearChange(bool enable = TRUE);
188
189 // corresponds to wxCAL_NO_MONTH_CHANGE bit
190 void EnableMonthChange(bool enable = TRUE);
191
192 // corresponds to wxCAL_SHOW_HOLIDAYS bit
193 void EnableHolidayDisplay(bool display = TRUE);
194
195 // customization
196 // -------------
197
198 // header colours are used for painting the weekdays at the top
199 void SetHeaderColours(const wxColour& colFg, const wxColour& colBg);
200 const wxColour& GetHeaderColourFg() const;
201 const wxColour& GetHeaderColourBg() const;
202
203 // highlight colour is used for the currently selected date
204 void SetHighlightColours(const wxColour& colFg, const wxColour& colBg);
205 const wxColour& GetHighlightColourFg() const;
206 const wxColour& GetHighlightColourBg() const;
207
208 // holiday colour is used for the holidays (if style & wxCAL_SHOW_HOLIDAYS)
209 void SetHolidayColours(const wxColour& colFg, const wxColour& colBg);
210 const wxColour& GetHolidayColourFg() const;
211 const wxColour& GetHolidayColourBg() const;
212
213 // an item without custom attributes is drawn with the default colours and
214 // font and without border, setting custom attributes allows to modify this
215 //
216 // the day parameter should be in 1..31 range, for days 29, 30, 31 the
217 // corresponding attribute is just unused if there is no such day in the
218 // current month
219
220 wxCalendarDateAttr *GetAttr(size_t day) const;
221 void SetAttr(size_t day, wxCalendarDateAttr *attr);
222
223 void SetHoliday(size_t day);
224
225 void ResetAttr(size_t day);
226
227 // returns one of wxCAL_HITTEST_XXX constants and fills either date or wd
228 // with the corresponding value (none for NOWHERE, the date for DAY and wd
229 // for HEADER)
230 wxCalendarHitTestResult HitTest(const wxPoint& pos,
231 wxDateTime *date = NULL,
232 wxDateTime::WeekDay *wd = NULL);
233
234 };
235
236
237 //---------------------------------------------------------------------------
238
239 %init %{
240 wxClassInfo::CleanUpClasses();
241 wxClassInfo::InitializeClasses();
242 %}
243
244 //---------------------------------------------------------------------------
245
246 %pragma(python) include="_calextras.py";
247
248 //---------------------------------------------------------------------------
249