1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 %% Purpose: wxCalendarCtrl documentation
4 %% Author: Vadim Zeitlin
8 %% Copyright: (c) Vadim Zeitlin
9 %% License: wxWidgets license
10 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
12 \section{\class{wxCalendarCtrl
}}\label{wxcalendarctrl
}
14 The calendar control allows the user to pick a date. For this,
15 it displays a window containing several parts: a control at the top to pick the month
16 and the year (either or both of them may be disabled), and a month
17 area below them which shows all the days in the month. The user can move the
18 current selection using the keyboard and select the date (generating
19 {\tt EVT
\_CALENDAR} event) by pressing
{\tt <Return>
} or double clicking it.
21 It has advanced possibilities for the customization of its display. All global
22 settings (such as colours and fonts used) can, of course, be changed. But
23 also, the display style for each day in the month can be set independently
24 using
\helpref{wxCalendarDateAttr
}{wxcalendardateattr
} class.
26 An item without custom attributes is drawn with the default colours and
27 font and without border, but setting custom attributes with
28 \helpref{SetAttr
}{wxcalendarctrlsetattr
} allows to modify its appearance. Just
29 create a custom attribute object and set it for the day you want to be
30 displayed specially (note that the control will take ownership of the pointer,
31 i.e. it will delete it itself). A day may be marked as being a holiday, even
32 if it is not recognized as one by
\helpref{wxDateTime
}{tdateholidays
} using
33 \helpref{SetHoliday
}{wxcalendardateattrsetholiday
} method.
35 As the attributes are specified for each day, they may change when the month
36 is changed, so you will often want to update them in
37 {\tt EVT
\_CALENDAR\_MONTH} event handler.
39 \wxheading{Derived from
}
41 \helpref{wxControl
}{wxcontrol
}\\
42 \helpref{wxWindow
}{wxwindow
}\\
43 \helpref{wxEvtHandler
}{wxevthandler
}\\
44 \helpref{wxObject
}{wxobject
}
46 \wxheading{Include files
}
50 \wxheading{Window styles
}
53 \begin{twocollist
}\itemsep=
4pt
54 \twocolitem{\windowstyle{wxCAL
\_SUNDAY\_FIRST}}{Show Sunday as the first day in the week
}
55 \twocolitem{\windowstyle{wxCAL
\_MONDAY\_FIRST}}{Show Monday as the first day in the week
}
56 \twocolitem{\windowstyle{wxCAL
\_SHOW\_HOLIDAYS}}{Highlight holidays in the calendar
}
57 \twocolitem{\windowstyle{wxCAL
\_NO\_YEAR\_CHANGE}}{Disable the year changing
}
58 \twocolitem{\windowstyle{wxCAL
\_NO\_MONTH\_CHANGE}}{Disable the month (and, implicitly, the year) changing
}
59 \twocolitem{\windowstyle{wxCAL
\_SHOW\_SURROUNDING\_WEEKS}}{Show the neighbouring weeks in the previous and next months
}
60 \twocolitem{\windowstyle{wxCAL
\_SEQUENTIAL\_MONTH\_SELECTION}}{Use alternative, more compact, style for the month and year selection controls.
}
63 The default calendar style is
{\tt wxCAL
\_SHOW\_HOLIDAYS}.
65 \wxheading{Event table macros
}
67 To process input from a calendar control, use these event handler macros to
68 direct input to member functions that take a
69 \helpref{wxCalendarEvent
}{wxcalendarevent
} argument.
72 \begin{twocollist
}\itemsep=
7pt
73 \twocolitem{{\bf EVT
\_CALENDAR(id, func)
}}{A day was double clicked in the calendar.
}
74 \twocolitem{{\bf EVT
\_CALENDAR\_SEL\_CHANGED(id, func)
}}{The selected date changed.
}
75 \twocolitem{{\bf EVT
\_CALENDAR\_DAY(id, func)
}}{The selected day changed.
}
76 \twocolitem{{\bf EVT
\_CALENDAR\_MONTH(id, func)
}}{The selected month changed.
}
77 \twocolitem{{\bf EVT
\_CALENDAR\_YEAR(id, func)
}}{The selected year changed.
}
78 \twocolitem{{\bf EVT
\_CALENDAR\_WEEKDAY\_CLICKED(id, func)
}}{User clicked on the week day header
}
81 Note that changing the selected date will result in either of
82 {\tt EVT
\_CALENDAR\_DAY},
{\tt MONTH
} or
{\tt YEAR
} events and
83 {\tt EVT
\_CALENDAR\_SEL\_CHANGED} one.
87 The following are the possible return values for
88 \helpref{HitTest
}{wxcalendarctrlhittest
} method:
92 enum wxCalendarHitTestResult
94 wxCAL_HITTEST_NOWHERE, // outside of anything
95 wxCAL_HITTEST_HEADER, // on the header (weekdays)
96 wxCAL_HITTEST_DAY // on a day in the calendar
103 \helpref{Calendar sample
}{samplecalendar
}\\
104 \helpref{wxCalendarDateAttr
}{wxcalendardateattr
}\\
105 \helpref{wxCalendarEvent
}{wxcalendarevent
}
107 \latexignore{\rtfignore{\wxheading{Members
}}}
110 \membersection{wxCalendarCtrl::wxCalendarCtrl
}\label{wxcalendarctrlwxcalendarctrldef
}
112 \func{}{wxCalendarCtrl
}{\void}
114 Default constructor, use
\helpref{Create
}{wxcalendarctrlcreate
} after it.
116 \func{}{wxCalendarCtrl
}{\param{wxWindow*
}{parent
},
\param{wxWindowID
}{id
},
\param{const wxDateTime\&
}{date = wxDefaultDateTime
},
\param{const wxPoint\&
}{pos = wxDefaultPosition
},
\param{const wxSize\&
}{size = wxDefaultSize
},
\param{long
}{style = wxCAL
\_SHOW\_HOLIDAYS},
\param{const wxString\&
}{name = wxCalendarNameStr
}}
118 Does the same as
\helpref{Create
}{wxcalendarctrlcreate
} method.
121 \membersection{wxCalendarCtrl::Create
}\label{wxcalendarctrlcreate
}
123 \func{bool
}{Create
}{\param{wxWindow*
}{parent
},
\param{wxWindowID
}{id
},
\param{const wxDateTime\&
}{date = wxDefaultDateTime
},
\param{const wxPoint\&
}{pos = wxDefaultPosition
},
\param{const wxSize\&
}{size = wxDefaultSize
},
\param{long
}{style = wxCAL
\_SHOW\_HOLIDAYS},
\param{const wxString\&
}{name = wxCalendarNameStr
}}
125 Creates the control. See
\helpref{wxWindow
}{wxwindowctor
} for the meaning of
126 the parameters and the control overview for the possible styles.
129 \membersection{wxCalendarCtrl::
\destruct{wxCalendarCtrl
}}\label{wxcalendarctrldtor
}
131 \func{}{\destruct{wxCalendarCtrl
}}{\void}
133 Destroys the control.
136 \membersection{wxCalendarCtrl::SetDate
}\label{wxcalendarctrlsetdate
}
138 \func{void
}{SetDate
}{\param{const wxDateTime\&
}{date
}}
140 Sets the current date.
143 \membersection{wxCalendarCtrl::GetDate
}\label{wxcalendarctrlgetdate
}
145 \constfunc{const wxDateTime\&
}{GetDate
}{\void}
147 Gets the currently selected date.
150 \membersection{wxCalendarCtrl::EnableYearChange
}\label{wxcalendarctrlenableyearchange
}
152 \func{void
}{EnableYearChange
}{\param{bool
}{enable = true
}}
154 This function should be used instead of changing
{\tt wxCAL
\_NO\_YEAR\_CHANGE}
155 style bit directly. It allows or disallows the user to change the year
159 \membersection{wxCalendarCtrl::EnableMonthChange
}\label{wxcalendarctrlenablemonthchange
}
161 \func{void
}{EnableMonthChange
}{\param{bool
}{enable = true
}}
163 This function should be used instead of changing
164 {\tt wxCAL
\_NO\_MONTH\_CHANGE} style bit. It allows or disallows the user to
165 change the month interactively. Note that if the month can not be changed, the
166 year can not be changed neither.
169 \membersection{wxCalendarCtrl::EnableHolidayDisplay
}\label{wxcalendarctrlenableholidaydisplay
}
171 \func{void
}{EnableHolidayDisplay
}{\param{bool
}{display = true
}}
173 This function should be used instead of changing
{\tt wxCAL
\_SHOW\_HOLIDAYS}
174 style bit directly. It enables or disables the special highlighting of the
178 \membersection{wxCalendarCtrl::SetHeaderColours
}\label{wxcalendarctrlsetheadercolours
}
180 \func{void
}{SetHeaderColours
}{\param{const wxColour\&
}{colFg
},
\param{const wxColour\&
}{colBg
}}
182 Set the colours used for painting the weekdays at the top of the control.
185 \membersection{wxCalendarCtrl::GetHeaderColourFg
}\label{wxcalendarctrlgetheadercolourfg
}
187 \constfunc{const wxColour\&
}{GetHeaderColourFg
}{\void}
189 Gets the foreground colour of the header part of the calendar window.
193 \helpref{SetHeaderColours
}{wxcalendarctrlsetheadercolours
}
196 \membersection{wxCalendarCtrl::GetHeaderColourBg
}\label{wxcalendarctrlgetheadercolourbg
}
198 \constfunc{const wxColour\&
}{GetHeaderColourBg
}{\void}
200 Gets the background colour of the header part of the calendar window.
204 \helpref{SetHeaderColours
}{wxcalendarctrlsetheadercolours
}
207 \membersection{wxCalendarCtrl::SetHighlightColours
}\label{wxcalendarctrlsethighlightcolours
}
209 \func{void
}{SetHighlightColours
}{\param{const wxColour\&
}{colFg
},
\param{const wxColour\&
}{colBg
}}
211 Set the colours to be used for highlighting the currently selected date.
214 \membersection{wxCalendarCtrl::GetHighlightColourFg
}\label{wxcalendarctrlgethighlightcolourfg
}
216 \constfunc{const wxColour\&
}{GetHighlightColourFg
}{\void}
218 Gets the foreground highlight colour.
222 \helpref{SetHighlightColours
}{wxcalendarctrlsethighlightcolours
}
225 \membersection{wxCalendarCtrl::GetHighlightColourBg
}\label{wxcalendarctrlgethighlightcolourbg
}
227 \constfunc{const wxColour\&
}{GetHighlightColourBg
}{\void}
229 Gets the background highlight colour.
233 \helpref{SetHighlightColours
}{wxcalendarctrlsethighlightcolours
}
236 \membersection{wxCalendarCtrl::SetHolidayColours
}\label{wxcalendarctrlsetholidaycolours
}
238 \func{void
}{SetHolidayColours
}{\param{const wxColour\&
}{colFg
},
\param{const wxColour\&
}{colBg
}}
240 Sets the colours to be used for the holidays highlighting (only used if the
241 window style includes
{\tt wxCAL
\_SHOW\_HOLIDAYS} flag).
244 \membersection{wxCalendarCtrl::GetHolidayColourFg
}\label{wxcalendarctrlgetholidaycolourfg
}
246 \constfunc{const wxColour\&
}{GetHolidayColourFg
}{\void}
248 Return the foreground colour currently used for holiday highlighting.
252 \helpref{SetHolidayColours
}{wxcalendarctrlsetholidaycolours
}
255 \membersection{wxCalendarCtrl::GetHolidayColourBg
}\label{wxcalendarctrlgetholidaycolourbg
}
257 \constfunc{const wxColour\&
}{GetHolidayColourBg
}{\void}
259 Return the background colour currently used for holiday highlighting.
263 \helpref{SetHolidayColours
}{wxcalendarctrlsetholidaycolours
}
266 \membersection{wxCalendarCtrl::GetAttr
}\label{wxcalendarctrlgetattr
}
268 \constfunc{wxCalendarDateAttr *
}{GetAttr
}{\param{size
\_t }{day
}}
270 Returns the attribute for the given date (should be in the range $
1\ldots31$).
272 The returned pointer may be
{\tt NULL
}.
275 \membersection{wxCalendarCtrl::SetAttr
}\label{wxcalendarctrlsetattr
}
277 \func{void
}{SetAttr
}{\param{size
\_t }{day
},
\param{wxCalendarDateAttr*
}{attr
}}
279 Associates the attribute with the specified date (in the range $
1\ldots31$).
281 If the pointer is
{\tt NULL
}, the items attribute is cleared.
284 \membersection{wxCalendarCtrl::SetHoliday
}\label{wxcalendarctrlsetholiday
}
286 \func{void
}{SetHoliday
}{\param{size
\_t }{day
}}
288 Marks the specified day as being a holiday in the current month.
291 \membersection{wxCalendarCtrl::ResetAttr
}\label{wxcalendarctrlresetattr
}
293 \func{void
}{ResetAttr
}{\param{size
\_t }{day
}}
295 Clears any attributes associated with the given day (in the range
299 \membersection{wxCalendarCtrl::HitTest
}\label{wxcalendarctrlhittest
}
301 \func{wxCalendarHitTestResult
}{HitTest
}{\param{const wxPoint\&
}{pos
},
\param{wxDateTime*
}{date = NULL
},
\param{wxDateTime::WeekDay*
}{wd = NULL
}}
303 Returns one of
{\tt wxCAL
\_HITTEST\_XXX}
304 \helpref{constants
}{wxcalendarctrl
} and fills either
{\it date
} or
305 {\it wd
} pointer with the corresponding value depending on the hit test code.
307 \section{\class{wxCalendarDateAttr
}}\label{wxcalendardateattr
}
309 wxCalendarDateAttr is a custom attributes for a calendar date. The objects of
310 this class are used with
\helpref{wxCalendarCtrl
}{wxcalendarctrl
}.
312 \wxheading{Derived from
}
316 \wxheading{Constants
}
318 Here are the possible kinds of borders which may be used to decorate a date:
321 enum wxCalendarDateBorder
323 wxCAL_BORDER_NONE, // no border (default)
324 wxCAL_BORDER_SQUARE, // a rectangular border
325 wxCAL_BORDER_ROUND // a round border
331 \helpref{wxCalendarCtrl
}{wxcalendarctrl
}
333 \wxheading{Include files
}
337 \latexignore{\rtfignore{\wxheading{Members
}}}
340 \membersection{wxCalendarDateAttr::wxCalendarDateAttr
}\label{wxcalendardateattrwxcalendardateattr
}
342 \func{}{wxCalendarDateAttr
}{\void}
344 \func{}{wxCalendarDateAttr
}{\param{const wxColour\&
}{colText
},
\param{const wxColour\&
}{colBack = wxNullColour
},
\param{const wxColour\&
}{colBorder = wxNullColour
},
\param{const wxFont\&
}{font = wxNullFont
},
\param{wxCalendarDateBorder
}{border = wxCAL
\_BORDER\_NONE}}
346 \func{}{wxCalendarDateAttr
}{\param{wxCalendarDateBorder
}{border
},
\param{const wxColour\&
}{colBorder = wxNullColour
}}
351 \membersection{wxCalendarDateAttr::SetTextColour
}\label{wxcalendardateattrsettextcolour
}
353 \func{void
}{SetTextColour
}{\param{const wxColour\&
}{colText
}}
355 Sets the text (foreground) colour to use.
358 \membersection{wxCalendarDateAttr::SetBackgroundColour
}\label{wxcalendardateattrsetbackgroundcolour
}
360 \func{void
}{SetBackgroundColour
}{\param{const wxColour\&
}{colBack
}}
362 Sets the text background colour to use.
365 \membersection{wxCalendarDateAttr::SetBorderColour
}\label{wxcalendardateattrsetbordercolour
}
367 \func{void
}{SetBorderColour
}{\param{const wxColour\&
}{col
}}
369 Sets the border colour to use.
372 \membersection{wxCalendarDateAttr::SetFont
}\label{wxcalendardateattrsetfont
}
374 \func{void
}{SetFont
}{\param{const wxFont\&
}{font
}}
376 Sets the font to use.
379 \membersection{wxCalendarDateAttr::SetBorder
}\label{wxcalendardateattrsetborder
}
381 \func{void
}{SetBorder
}{\param{wxCalendarDateBorder
}{border
}}
383 Sets the
\helpref{border kind
}{wxcalendardateattr
}
386 \membersection{wxCalendarDateAttr::SetHoliday
}\label{wxcalendardateattrsetholiday
}
388 \func{void
}{SetHoliday
}{\param{bool
}{holiday
}}
390 Display the date with this attribute as a holiday.
393 \membersection{wxCalendarDateAttr::HasTextColour
}\label{wxcalendardateattrhastextcolour
}
395 \constfunc{bool
}{HasTextColour
}{\void}
397 Returns
{\tt true
} if this item has a non default text foreground colour.
400 \membersection{wxCalendarDateAttr::HasBackgroundColour
}\label{wxcalendardateattrhasbackgroundcolour
}
402 \constfunc{bool
}{HasBackgroundColour
}{\void}
404 Returns
{\tt true
} if this attribute specifies a non default text background colour.
407 \membersection{wxCalendarDateAttr::HasBorderColour
}\label{wxcalendardateattrhasbordercolour
}
409 \constfunc{bool
}{HasBorderColour
}{\void}
411 Returns
{\tt true
} if this attribute specifies a non default border colour.
414 \membersection{wxCalendarDateAttr::HasFont
}\label{wxcalendardateattrhasfont
}
416 \constfunc{bool
}{HasFont
}{\void}
418 Returns
{\tt true
} if this attribute specifies a non default font.
421 \membersection{wxCalendarDateAttr::HasBorder
}\label{wxcalendardateattrhasborder
}
423 \constfunc{bool
}{HasBorder
}{\void}
425 Returns
{\tt true
} if this attribute specifies a non default (i.e. any) border.
428 \membersection{wxCalendarDateAttr::IsHoliday
}\label{wxcalendardateattrisholiday
}
430 \constfunc{bool
}{IsHoliday
}{\void}
432 Returns
{\tt true
} if this attribute specifies that this item should be
433 displayed as a holiday.
436 \membersection{wxCalendarDateAttr::GetTextColour
}\label{wxcalendardateattrgettextcolour
}
438 \constfunc{const wxColour\&
}{GetTextColour
}{\void}
440 Returns the text colour to use for the item with this attribute.
443 \membersection{wxCalendarDateAttr::GetBackgroundColour
}\label{wxcalendardateattrgetbackgroundcolour
}
445 \constfunc{const wxColour\&
}{GetBackgroundColour
}{\void}
447 Returns the background colour to use for the item with this attribute.
450 \membersection{wxCalendarDateAttr::GetBorderColour
}\label{wxcalendardateattrgetbordercolour
}
452 \constfunc{const wxColour\&
}{GetBorderColour
}{\void}
454 Returns the border colour to use for the item with this attribute.
457 \membersection{wxCalendarDateAttr::GetFont
}\label{wxcalendardateattrgetfont
}
459 \constfunc{const wxFont\&
}{GetFont
}{\void}
461 Returns the font to use for the item with this attribute.
464 \membersection{wxCalendarDateAttr::GetBorder
}\label{wxcalendardateattrgetborder
}
466 \constfunc{wxCalendarDateBorder
}{GetBorder
}{\void}
468 Returns the
\helpref{border
}{wxcalendardateattr
} to use for the item with this attribute.
471 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
473 \section{\class{wxCalendarEvent
}}\label{wxcalendarevent
}
475 The wxCalendarEvent class is used together with
476 \helpref{wxCalendarCtrl
}{wxcalendarctrl
}.
478 \wxheading{Derived from
}
480 \helpref{wxDateEvent
}{wxdateevent
}\\
481 \helpref{wxCommandEvent
}{wxcommandevent
}\\
482 \helpref{wxEvent
}{wxevent
}\\
483 \helpref{wxObject
}{wxobject
}
485 \wxheading{Include files
}
491 \helpref{wxCalendarCtrl
}{wxcalendarctrl
}
493 \latexignore{\rtfignore{\wxheading{Members
}}}
496 \membersection{wxCalendarEvent::GetWeekDay
}\label{wxcalendareventgetweekday
}
498 \constfunc{wxDateTime::WeekDay
}{GetWeekDay
}{\void}
500 Returns the week day on which the user clicked in
501 {\tt EVT
\_CALENDAR\_WEEKDAY\_CLICKED} handler. It doesn't make sense to call
502 this function in other handlers.
505 \membersection{wxCalendarEvent::SetWeekDay
}\label{wxcalendareventsetweekday
}
507 \func{void
}{SetWeekDay
}{\param{wxDateTime::WeekDay
}{ day
}}
509 Sets the week day carried by the event, normally only used by the library