]> git.saurik.com Git - wxWidgets.git/blame - wxPython/src/calendar.i
Added SplitTree sample to the demo
[wxWidgets.git] / wxPython / src / calendar.i
CommitLineData
f6bcfd97
BP
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%{
1e7ecb7b 17#include "export.h"
f6bcfd97
BP
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
38enum {
39 wxCAL_SUNDAY_FIRST,
40 wxCAL_MONDAY_FIRST,
41 wxCAL_SHOW_HOLIDAYS,
42 wxCAL_NO_YEAR_CHANGE,
43 wxCAL_NO_MONTH_CHANGE,
ab11ebfa
RD
44 wxCAL_SEQUENTIAL_MONTH_SELECTION,
45 wxCAL_SHOW_SURROUNDING_WEEKS,
f6bcfd97
BP
46};
47
48
49enum wxCalendarHitTestResult
50{
51 wxCAL_HITTEST_NOWHERE, // outside of anything
52 wxCAL_HITTEST_HEADER, // on the header (weekdays)
b66824a5 53 wxCAL_HITTEST_DAY, // on a day in the calendar
ab11ebfa
RD
54 wxCAL_HITTEST_INCMONTH,
55 wxCAL_HITTEST_DECMONTH,
56 wxCAL_HITTEST_SURROUNDING_WEEK
f6bcfd97
BP
57};
58
59// border types for a date
60enum 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
70class wxCalendarDateAttr
71{
72public:
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
c5943253
RD
101 wxColour GetTextColour() const;
102 wxColour GetBackgroundColour() const;
103 wxColour GetBorderColour() const;
104 wxFont GetFont() const;
f6bcfd97
BP
105 wxCalendarDateBorder GetBorder() const;
106};
107
108//---------------------------------------------------------------------------
109
110class wxCalendarCtrl;
111
112class wxCalendarEvent : public wxCommandEvent
113{
114public:
115 wxCalendarEvent(wxCalendarCtrl *cal, wxEventType type);
116
117 const wxDateTime& GetDate() const;
118 wxDateTime::WeekDay GetWeekDay() const;
119
120};
121
122enum {
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 = "
132def EVT_CALENDAR(win, id, fn):
133 win.Connect(id, -1, wxEVT_CALENDAR_DOUBLECLICKED, fn)
134
135def EVT_CALENDAR_SEL_CHANGED(win, id, fn):
136 win.Connect(id, -1, wxEVT_CALENDAR_SEL_CHANGED, fn)
137
138def EVT_CALENDAR_DAY(win, id, fn):
139 win.Connect(id, -1, wxEVT_CALENDAR_DAY_CHANGED, fn)
140
141def EVT_CALENDAR_MONTH(win, id, fn):
142 win.Connect(id, -1, wxEVT_CALENDAR_MONTH_CHANGED, fn)
143
144def EVT_CALENDAR_YEAR(win, id, fn):
145 win.Connect(id, -1, wxEVT_CALENDAR_YEAR_CHANGED, fn)
146
147def EVT_CALENDAR_WEEKDAY_CLICKED(win, id, fn):
148 win.Connect(id, -1, wxEVT_CALENDAR_WEEKDAY_CLICKED, fn)
149
150"
151
152//---------------------------------------------------------------------------
153
154class wxCalendarCtrl : public wxControl
155{
156public:
157 // construction
158 wxCalendarCtrl(wxWindow *parent,
159 wxWindowID id,
160 const wxDateTime& date = wxDefaultDateTime,
161 const wxPoint& pos = wxDefaultPosition,
162 const wxSize& size = wxDefaultSize,
bae17009 163 long style = wxCAL_SHOW_HOLIDAYS | wxWANTS_CHARS,
f6bcfd97 164 const char* name = "calendar");
09f3d4e6
RD
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,
bae17009 172 long style = wxCAL_SHOW_HOLIDAYS | wxWANTS_CHARS,
09f3d4e6 173 const char* name = "calendar");
f6bcfd97 174
0122b7e3 175 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
17c0e08c 176 %pragma(python) addtomethod = "wxPreCalendarCtrl:val._setOORInfo(val)"
0122b7e3 177
f6bcfd97
BP
178 // set/get the current date
179 // ------------------------
180
181 void SetDate(const wxDateTime& date);
182 const wxDateTime& GetDate() const;
183
ab11ebfa
RD
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
f6bcfd97
BP
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);
c5943253
RD
217 wxColour GetHeaderColourFg() const;
218 wxColour GetHeaderColourBg() const;
f6bcfd97
BP
219
220 // highlight colour is used for the currently selected date
221 void SetHighlightColours(const wxColour& colFg, const wxColour& colBg);
c5943253
RD
222 wxColour GetHighlightColourFg() const;
223 wxColour GetHighlightColourBg() const;
f6bcfd97
BP
224
225 // holiday colour is used for the holidays (if style & wxCAL_SHOW_HOLIDAYS)
226 void SetHolidayColours(const wxColour& colFg, const wxColour& colBg);
c5943253
RD
227 wxColour GetHolidayColourFg() const;
228 wxColour GetHolidayColourBg() const;
f6bcfd97
BP
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
ab11ebfa
RD
251
252 bool Enable(bool enable = TRUE);
253 bool Show(bool show = TRUE);
254
f6bcfd97
BP
255};
256
257
258//---------------------------------------------------------------------------
e508a2b6
RD
259
260%init %{
261 wxClassInfo::CleanUpClasses();
262 wxClassInfo::InitializeClasses();
263%}
264
f6bcfd97
BP
265//---------------------------------------------------------------------------
266
267%pragma(python) include="_calextras.py";
268
269//---------------------------------------------------------------------------
270