wxCalendarCtrl

wxCalendarCtrl

wxCalendarCtrl
Functions for wxCalendarCtrl class

The calendar control allows the user to pick a date. The user can move the current selection using the keyboard and select the date (generating EVT_CALENDAR event) by pressing <Return> or double clicking it.

Generic calendar has advanced possibilities for the customization of its display, described below. If you want to use these possibilities on every platform, use wxGenericCalendarCtrl instead of wxCalendarCtrl.

All global settings (such as colours and fonts used) can, of course, be changed. But also, the display style for each day in the month can be set independently using wxCalendarDateAttr class.

An item without custom attributes is drawn with the default colours and font and without border, but setting custom attributes with setAttr/3 allows modifying its appearance. Just create a custom attribute object and set it for the day you want to be displayed specially (note that the control will take ownership of the pointer, i.e. it will delete it itself). A day may be marked as being a holiday, even if it is not recognized as one by wx_datetime() using the wxCalendarDateAttr:setHoliday/2 method.

As the attributes are specified for each day, they may change when the month is changed, so you will often want to update them in EVT_CALENDAR_PAGE_CHANGED event handler.

If neither the wxCAL_SUNDAY_FIRST or wxCAL_MONDAY_FIRST style is given, the first day of the week is determined from operating system's settings, if possible. The native wxGTK calendar chooses the first weekday based on locale, and these styles have no effect on it.

Styles

This class supports the following styles:

Note: Changing the selected date will trigger an EVT_CALENDAR_DAY, MONTH or YEAR event as well as an EVT_CALENDAR_SEL_CHANGED event.

See: Examples, wxCalendarDateAttr, wxCalendarEvent, wxDatePickerCtrl

This class is derived (and can use functions) from: wxControl wxWindow wxEvtHandler

wxWidgets docs: wxCalendarCtrl

Event types emitted from this class: calendar_sel_changed, calendar_weekday_clicked

Types

Sets the current date.

The date parameter must be valid and in the currently valid range as set by SetDateRange() (not implemented in wx), otherwise the current date is not changed and the function returns false and, additionally, triggers an assertion failure if the date is invalid.

Types

Option = {enable, boolean()}

Deprecated:

This function should be used instead of changing wxCAL_NO_YEAR_CHANGE style bit directly. It allows or disallows the user to change the year interactively. Only in generic wxCalendarCtrl.

Types

Option = {enable, boolean()}

This function should be used instead of changing wxCAL_NO_MONTH_CHANGE style bit.

It allows or disallows the user to change the month interactively. Note that if the month cannot be changed, the year cannot be changed neither.

Return: true if the value of this option really changed or false if it was already set to the requested value.

Types

Option = {display, boolean()}

This function should be used instead of changing wxCAL_SHOW_HOLIDAYS style bit directly.

It enables or disables the special highlighting of the holidays.

Types

ColFg = ColBg = wx:wx_colour()

Set the colours used for painting the weekdays at the top of the control.

This method is currently only implemented in generic wxCalendarCtrl and does nothing in the native versions.

Types

ColFg = ColBg = wx:wx_colour()

Set the colours to be used for highlighting the currently selected date.

This method is currently only implemented in generic wxCalendarCtrl and does nothing in the native versions.

Types

ColFg = ColBg = wx:wx_colour()

Sets the colours to be used for the holidays highlighting.

This method is only implemented in the generic version of the control and does nothing in the native ones. It should also only be called if the window style includes wxCAL_SHOW_HOLIDAYS flag or enableHolidayDisplay/2 had been called.

Types

Day = integer()

Marks the specified day as being a holiday in the current month.

This method is only implemented in the generic version of the control and does nothing in the native ones.

Types

Result =
    {Res :: wx:wx_enum(),
     Date :: wx:wx_datetime(),
     Wd :: wx:wx_enum()}
Pos = {X :: integer(), Y :: integer()}

Returns one of wxCalendarHitTestResult constants and fills either date or wd pointer with the corresponding value depending on the hit test code.

Not implemented in wxGTK currently.