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.
|