wxCalendarCtrlThe calendar control allows the user to pick a date. For this, it displays a window containing several parts: a control at the top to pick the month and the year (either or both of them may be disabled), and a month area below them which shows all the days in the month. 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. It has advanced possibilities for the customization of its display. 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 allows to modify 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 wxDateTime using SetHoliday 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_MONTH event handler. Derived from
wxControl Include files <wx/calctrl.h> Window styles
The default calendar style is wxCAL_SHOW_HOLIDAYS. Event table macros To process input from a calendar control, use these event handler macros to direct input to member functions that take a wxCalendarEvent argument.
Constants The following are the possible return values for HitTest method:
See also
Calendar sample Members
wxCalendarCtrl::wxCalendarCtrl
wxCalendarCtrl::wxCalendarCtrlwxCalendarCtrl() Default constructor, use Create after it. wxCalendarCtrl(wxWindow* parent, wxWindowID id, const wxDateTime& date = wxDefaultDateTime, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxCAL_SHOW_HOLIDAYS, const wxString& name = wxCalendarNameStr) Does the same as Create method.
wxCalendarCtrl::Createbool Create(wxWindow* parent, wxWindowID id, const wxDateTime& date = wxDefaultDateTime, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxCAL_SHOW_HOLIDAYS, const wxString& name = wxCalendarNameStr) Creates the control. See wxWindow for the meaning of the parameters and the control overview for the possible styles.
wxCalendarCtrl::~wxCalendarCtrl~wxCalendarCtrl() Destroys the control.
wxCalendarCtrl::SetDatevoid SetDate(const wxDateTime& date) Sets the current date.
wxCalendarCtrl::GetDateconst wxDateTime& GetDate() const Gets the currently selected date.
wxCalendarCtrl::EnableYearChangevoid EnableYearChange(bool enable = true) 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.
wxCalendarCtrl::EnableMonthChangevoid EnableMonthChange(bool enable = true) 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 can not be changed, the year can not be changed neither.
wxCalendarCtrl::EnableHolidayDisplayvoid EnableHolidayDisplay(bool display = true) This function should be used instead of changing wxCAL_SHOW_HOLIDAYS style bit directly. It enables or disables the special highlighting of the holidays.
wxCalendarCtrl::SetHeaderColoursvoid SetHeaderColours(const wxColour& colFg, const wxColour& colBg) Set the colours used for painting the weekdays at the top of the control.
wxCalendarCtrl::GetHeaderColourFgconst wxColour& GetHeaderColourFg() const Gets the foreground colour of the header part of the calendar window. See also
wxCalendarCtrl::GetHeaderColourBgconst wxColour& GetHeaderColourBg() const Gets the background colour of the header part of the calendar window. See also
wxCalendarCtrl::SetHighlightColoursvoid SetHighlightColours(const wxColour& colFg, const wxColour& colBg) Set the colours to be used for highlighting the currently selected date.
wxCalendarCtrl::GetHighlightColourFgconst wxColour& GetHighlightColourFg() const Gets the foreground highlight colour. See also
wxCalendarCtrl::GetHighlightColourBgconst wxColour& GetHighlightColourBg() const Gets the background highlight colour. See also
wxCalendarCtrl::SetHolidayColoursvoid SetHolidayColours(const wxColour& colFg, const wxColour& colBg) Sets the colours to be used for the holidays highlighting (only used if the window style includes wxCAL_SHOW_HOLIDAYS flag).
wxCalendarCtrl::GetHolidayColourFgconst wxColour& GetHolidayColourFg() const Return the foreground colour currently used for holiday highlighting. See also
wxCalendarCtrl::GetHolidayColourBgconst wxColour& GetHolidayColourBg() const Return the background colour currently used for holiday highlighting. See also
wxCalendarCtrl::GetAttrwxCalendarDateAttr * GetAttr(size_t day) const Returns the attribute for the given date (should be in the range 1...31). The returned pointer may be NULL.
wxCalendarCtrl::SetAttrvoid SetAttr(size_t day, wxCalendarDateAttr* attr) Associates the attribute with the specified date (in the range 1...31). If the pointer is NULL, the items attribute is cleared.
wxCalendarCtrl::SetHolidayvoid SetHoliday(size_t day) Marks the specified day as being a holiday in the current month.
wxCalendarCtrl::ResetAttrvoid ResetAttr(size_t day) Clears any attributes associated with the given day (in the range 1...31).
wxCalendarCtrl::HitTestwxCalendarHitTestResult HitTest(const wxPoint& pos, wxDateTime* date = NULL, wxDateTime::WeekDay* wd = NULL) Returns one of wxCAL_HITTEST_XXX constants and fills either date or wd pointer with the corresponding value depending on the hit test code.
|