1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxCalendarEvent
4 // Author: wxWidgets team
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
10 @class wxCalendarEvent
13 The wxCalendarEvent class is used together with
21 class wxCalendarEvent
: public wxDateEvent
25 Returns the week day on which the user clicked in
26 @c EVT_CALENDAR_WEEKDAY_CLICKED handler. It doesn't make sense to call
27 this function in other handlers.
29 wxDateTime::WeekDay
GetWeekDay() const;
32 Sets the week day carried by the event,
33 normally only used by the library internally.
35 void SetWeekDay(wxDateTime::WeekDay day
);
41 @class wxCalendarDateAttr
44 wxCalendarDateAttr is a custom attributes for a calendar date. The objects of
45 this class are used with wxCalendarCtrl.
52 class wxCalendarDateAttr
60 wxCalendarDateAttr(const wxColour
& colText
,
61 const wxColour
& colBack
= wxNullColour
,
62 const wxColour
& colBorder
= wxNullColour
,
63 const wxFont
& font
= wxNullFont
,
64 wxCalendarDateBorder border
= wxCAL_BORDER_NONE
);
65 wxCalendarDateAttr(wxCalendarDateBorder border
,
66 const wxColour
& colBorder
= wxNullColour
);
70 Returns the background colour to use for the item with this attribute.
72 const wxColour
GetBackgroundColour() const;
75 Returns the border() to use for the item with this attribute.
77 wxCalendarDateBorder
GetBorder() const;
80 Returns the border colour to use for the item with this attribute.
82 const wxColour
GetBorderColour() const;
85 Returns the font to use for the item with this attribute.
87 const wxFont
GetFont() const;
90 Returns the text colour to use for the item with this attribute.
92 const wxColour
GetTextColour() const;
95 Returns @true if this attribute specifies a non-default text background
98 bool HasBackgroundColour() const;
101 Returns @true if this attribute specifies a non-default (i.e. any) border.
103 bool HasBorder() const;
106 Returns @true if this attribute specifies a non-default border colour.
108 bool HasBorderColour() const;
111 Returns @true if this attribute specifies a non-default font.
113 bool HasFont() const;
116 Returns @true if this item has a non-default text foreground colour.
118 bool HasTextColour() const;
121 Returns @true if this attribute specifies that this item should be
122 displayed as a holiday.
124 bool IsHoliday() const;
127 Sets the text background colour to use.
129 void SetBackgroundColour(const wxColour
& colBack
);
132 Sets the @ref overview_wxcalendardateattr "border kind"
134 void SetBorder(wxCalendarDateBorder border
);
137 Sets the border colour to use.
139 void SetBorderColour(const wxColour
& col
);
142 Sets the font to use.
144 void SetFont(const wxFont
& font
);
147 Display the date with this attribute as a holiday.
149 void SetHoliday(bool holiday
);
152 Sets the text (foreground) colour to use.
154 void SetTextColour(const wxColour
& colText
);
157 Used (internally) by generic wxCalendarCtrl::Mark()
159 static const wxCalendarDateAttr
& GetMark();
162 Set the attribute that will be used to Mark() days
163 on generic wxCalendarCtrl
165 static void SetMark(wxCalendarDateAttr
const& m
);
171 @class wxCalendarCtrl
174 The calendar control allows the user to pick a date. The user can move the
175 current selection using the keyboard and select the date (generating
176 @c EVT_CALENDAR event) by pressing @c Return or double clicking it.
178 Generic calendar has advanced possibilities for the customization of its
179 display, described below. If you want to use these possibilities on
180 every platform, use wxGenericCalendarCtrl instead of wxCalendarCtrl.
182 All global settings (such as colours and fonts used) can, of course,
183 be changed. But also, the display style for each day in the month can
184 be set independently using wxCalendarDateAttr class.
186 An item without custom attributes is drawn with the default colours and
187 font and without border, but setting custom attributes with
188 wxCalendarCtrl::SetAttr allows to modify its appearance. Just
189 create a custom attribute object and set it for the day you want to be
190 displayed specially (note that the control will take ownership of
191 the pointer, i.e. it will delete it itself).
192 A day may be marked as being a holiday, even if it is not recognized as
193 one by wxDateTime using wxCalendarDateAttr::SetHoliday method.
195 As the attributes are specified for each day, they may change when the month
196 is changed, so you will often want to update them in
197 @c EVT_CALENDAR_PAGE_CHANGED event handler.
200 @style{wxCAL_SUNDAY_FIRST}:
201 Show Sunday as the first day in the week (only generic)
202 @style{wxCAL_MONDAY_FIRST}:
203 Show Monday as the first day in the week (only generic)
204 @style{wxCAL_SHOW_HOLIDAYS}:
205 Highlight holidays in the calendar (only generic)
206 @style{wxCAL_NO_YEAR_CHANGE}:
207 Disable the year changing (deprecated, only generic)
208 @style{wxCAL_NO_MONTH_CHANGE}:
209 Disable the month (and, implicitly, the year) changing
210 @style{wxCAL_SHOW_SURROUNDING_WEEKS}:
211 Show the neighbouring weeks in the previous and next months
213 @style{wxCAL_SEQUENTIAL_MONTH_SELECTION}:
214 Use alternative, more compact, style for the month and year
215 selection controls. (only generic)
218 @beginEventTable{wxCalendarEvent}
219 @event{EVT_CALENDAR(id, func)}:
220 A day was double clicked in the calendar.
221 @event{EVT_CALENDAR_SEL_CHANGED(id, func)}:
222 The selected date changed.
223 @event{EVT_CALENDAR_PAGE_CHANGED(id, func)}:
224 The selected month (and/or year) changed.
225 @event{EVT_CALENDAR_WEEKDAY_CLICKED(id, func)}:
226 User clicked on the week day header (only generic).
231 @appearance{calendarctrl.png}
235 @see @ref page_samples_calendar, wxCalendarDateAttr, wxCalendarEvent,
238 class wxCalendarCtrl
: public wxControl
243 Does the same as Create() method.
246 wxCalendarCtrl(wxWindow
* parent
, wxWindowID id
,
247 const wxDateTime
& date
= wxDefaultDateTime
,
248 const wxPoint
& pos
= wxDefaultPosition
,
249 const wxSize
& size
= wxDefaultSize
,
250 long style
= wxCAL_SHOW_HOLIDAYS
,
251 const wxString
& name
= wxCalendarNameStr
);
255 Destroys the control.
260 Creates the control. See @ref wxWindow::ctor wxWindow for the meaning of
261 the parameters and the control overview for the possible styles.
263 bool Create(wxWindow
* parent
, wxWindowID id
,
264 const wxDateTime
& date
= wxDefaultDateTime
,
265 const wxPoint
& pos
= wxDefaultPosition
,
266 const wxSize
& size
= wxDefaultSize
,
267 long style
= wxCAL_SHOW_HOLIDAYS
,
268 const wxString
& name
= wxCalendarNameStr
);
271 This function should be used instead of changing @c wxCAL_SHOW_HOLIDAYS
272 style bit directly. It enables or disables the special highlighting of the
275 void EnableHolidayDisplay(bool display
= true);
278 This function should be used instead of changing
279 @c wxCAL_NO_MONTH_CHANGE style bit. It allows or disallows the user to
280 change the month interactively. Note that if the month can not
281 be changed, the year can not be changed neither.
283 @return @true if the value of this option really changed or @false
284 if it was already set to the requested value.
286 bool EnableMonthChange(bool enable
= true);
291 This function should be used instead of changing @c wxCAL_NO_YEAR_CHANGE
292 style bit directly. It allows or disallows the user to change the year
293 interactively. Only in generic wxCalendarCtrl.
295 void EnableYearChange(bool enable
= true);
298 Returns the attribute for the given date (should be in the range 1...31).
299 The returned pointer may be @NULL. Only in generic wxCalendarCtrl.
301 wxCalendarDateAttr
* GetAttr(size_t day
) const;
304 Gets the currently selected date.
306 const wxDateTime
GetDate() const;
309 Gets the background colour of the header part of the calendar window.
311 This method is currently only implemented in generic wxCalendarCtrl and
312 always returns @c wxNullColour in the native versions.
314 @see SetHeaderColours()
316 const wxColour
GetHeaderColourBg() const;
319 Gets the foreground colour of the header part of the calendar window.
321 This method is currently only implemented in generic wxCalendarCtrl and
322 always returns @c wxNullColour in the native versions.
324 @see SetHeaderColours()
326 const wxColour
GetHeaderColourFg() const;
329 Gets the background highlight colour. Only in generic wxCalendarCtrl.
331 This method is currently only implemented in generic wxCalendarCtrl and
332 always returns @c wxNullColour in the native versions.
334 @see SetHighlightColours()
336 const wxColour
GetHighlightColourBg() const;
339 Gets the foreground highlight colour. Only in generic wxCalendarCtrl.
341 This method is currently only implemented in generic wxCalendarCtrl and
342 always returns @c wxNullColour in the native versions.
344 @see SetHighlightColours()
346 const wxColour
GetHighlightColourFg() const;
349 Return the background colour currently used for holiday highlighting.
351 Only useful with generic wxCalendarCtrl as native versions currently
352 don't support holidays display at all and always return @c wxNullColour.
354 @see SetHolidayColours()
356 const wxColour
GetHolidayColourBg() const;
359 Return the foreground colour currently used for holiday highlighting.
361 Only useful with generic wxCalendarCtrl as native versions currently
362 don't support holidays display at all and always return @c wxNullColour.
364 @see SetHolidayColours()
366 const wxColour
GetHolidayColourFg() const;
369 Returns one of @c wxCAL_HITTEST_XXX
370 constants() and fills either @a date or @a wd pointer with
371 the corresponding value depending on the hit test code.
372 Only in generic wxCalendarCtrl.
374 wxCalendarHitTestResult
HitTest(const wxPoint
& pos
,
375 wxDateTime
* date
= NULL
,
376 wxDateTime::WeekDay
* wd
= NULL
);
379 Clears any attributes associated with the given day (in the range
381 Only in generic wxCalendarCtrl.
383 void ResetAttr(size_t day
);
386 Associates the attribute with the specified date (in the range 1...31).
387 If the pointer is @NULL, the items attribute is cleared.
388 Only in generic wxCalendarCtrl.
390 void SetAttr(size_t day
, wxCalendarDateAttr
* attr
);
393 Sets the current date.
395 void SetDate(const wxDateTime
& date
);
398 Set the colours used for painting the weekdays at the top of the control.
400 This method is currently only implemented in generic wxCalendarCtrl and
401 does nothing in the native versions.
403 void SetHeaderColours(const wxColour
& colFg
,
404 const wxColour
& colBg
);
407 Set the colours to be used for highlighting the currently selected date.
409 This method is currently only implemented in generic wxCalendarCtrl and
410 does nothing in the native versions.
412 void SetHighlightColours(const wxColour
& colFg
,
413 const wxColour
& colBg
);
416 Marks the specified day as being a holiday in the current month.
418 This method is only implemented in the generic version of the control
419 and does nothing in the native ones.
421 void SetHoliday(size_t day
);
424 Sets the colours to be used for the holidays highlighting.
426 This method is only implemented in the generic version of the control
427 and does nothing in the native ones. It should also only be called if
428 the window style includes @c wxCAL_SHOW_HOLIDAYS flag or
429 EnableHolidayDisplay() had been called.
432 void SetHolidayColours(const wxColour
& colFg
,
433 const wxColour
& colBg
);
436 Mark or unmark the day.
437 This day of month will be marked in every month.
438 In generic wxCalendarCtrl,
440 void Mark(size_t day
, bool mark
);