1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: documentation for wxCalendarEvent class
4 // Author: wxWidgets team
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
10 @class wxCalendarEvent
13 The wxCalendarEvent class is used together with
22 class wxCalendarEvent
: public wxDateEvent
26 Returns the week day on which the user clicked in
27 @c EVT_CALENDAR_WEEKDAY_CLICKED handler. It doesn't make sense to call
28 this function in other handlers.
30 wxDateTime::WeekDay
GetWeekDay();
33 Sets the week day carried by the event, normally only used by the library
36 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.
53 class wxCalendarDateAttr
61 wxCalendarDateAttr(const wxColour
& colText
,
62 const wxColour
& colBack
= wxNullColour
,
63 const wxColour
& colBorder
= wxNullColour
,
64 const wxFont
& font
= wxNullFont
,
65 wxCalendarDateBorder border
= wxCAL_BORDER_NONE
);
66 wxCalendarDateAttr(wxCalendarDateBorder border
,
67 const wxColour
& colBorder
= wxNullColour
);
71 Returns the background colour to use for the item with this attribute.
73 const wxColour
GetBackgroundColour();
76 Returns the border to use for the item with this attribute.
78 wxCalendarDateBorder
GetBorder();
81 Returns the border colour to use for the item with this attribute.
83 const wxColour
GetBorderColour();
86 Returns the font to use for the item with this attribute.
88 const wxFont
GetFont();
91 Returns the text colour to use for the item with this attribute.
93 const wxColour
GetTextColour();
96 Returns @true if this attribute specifies a non-default text background
99 bool HasBackgroundColour();
102 Returns @true if this attribute specifies a non-default (i.e. any) border.
107 Returns @true if this attribute specifies a non-default border colour.
109 bool HasBorderColour();
112 Returns @true if this attribute specifies a non-default font.
117 Returns @true if this item has a non-default text foreground colour.
119 bool HasTextColour();
122 Returns @true if this attribute specifies that this item should be
123 displayed as a holiday.
128 Sets the text background colour to use.
130 void SetBackgroundColour(const wxColour
& colBack
);
133 Sets the @ref overview_wxcalendardateattr "border kind"
135 void SetBorder(wxCalendarDateBorder border
);
138 Sets the border colour to use.
140 void SetBorderColour(const wxColour
& col
);
143 Sets the font to use.
145 void SetFont(const wxFont
& font
);
148 Display the date with this attribute as a holiday.
150 void SetHoliday(bool holiday
);
153 Sets the text (foreground) colour to use.
155 void SetTextColour(const wxColour
& colText
);
160 @class wxCalendarCtrl
163 The calendar control allows the user to pick a date. For this,
164 it displays a window containing several parts: a control at the top to pick the
166 and the year (either or both of them may be disabled), and a month
167 area below them which shows all the days in the month. The user can move the
168 current selection using the keyboard and select the date (generating
169 @c EVT_CALENDAR event) by pressing @c Return or double clicking it.
171 It has advanced possibilities for the customization of its display. All global
172 settings (such as colours and fonts used) can, of course, be changed. But
173 also, the display style for each day in the month can be set independently
174 using wxCalendarDateAttr class.
176 An item without custom attributes is drawn with the default colours and
177 font and without border, but setting custom attributes with
178 wxCalendarCtrl::SetAttr allows to modify its appearance. Just
179 create a custom attribute object and set it for the day you want to be
180 displayed specially (note that the control will take ownership of the pointer,
181 i.e. it will delete it itself). A day may be marked as being a holiday, even
182 if it is not recognized as one by wxDateTime using
183 wxCalendarDateAttr::SetHoliday method.
185 As the attributes are specified for each day, they may change when the month
186 is changed, so you will often want to update them in
187 @c EVT_CALENDAR_MONTH event handler.
190 @style{wxCAL_SUNDAY_FIRST}:
191 Show Sunday as the first day in the week
192 @style{wxCAL_MONDAY_FIRST}:
193 Show Monday as the first day in the week
194 @style{wxCAL_SHOW_HOLIDAYS}:
195 Highlight holidays in the calendar
196 @style{wxCAL_NO_YEAR_CHANGE}:
197 Disable the year changing
198 @style{wxCAL_NO_MONTH_CHANGE}:
199 Disable the month (and, implicitly, the year) changing
200 @style{wxCAL_SHOW_SURROUNDING_WEEKS}:
201 Show the neighbouring weeks in the previous and next months
202 @style{wxCAL_SEQUENTIAL_MONTH_SELECTION}:
203 Use alternative, more compact, style for the month and year
209 @appearance{calendarctrl.png}
212 @ref overview_samplecalendar "Calendar sample", wxCalendarDateAttr,
215 class wxCalendarCtrl
: public wxControl
220 Does the same as Create() method.
223 wxCalendarCtrl(wxWindow
* parent
, wxWindowID id
,
224 const wxDateTime
& date
= wxDefaultDateTime
,
225 const wxPoint
& pos
= wxDefaultPosition
,
226 const wxSize
& size
= wxDefaultSize
,
227 long style
= wxCAL_SHOW_HOLIDAYS
,
228 const wxString
& name
= wxCalendarNameStr
);
232 Destroys the control.
237 Creates the control. See @ref wxWindow::ctor wxWindow for the meaning of
238 the parameters and the control overview for the possible styles.
240 bool Create(wxWindow
* parent
, wxWindowID id
,
241 const wxDateTime
& date
= wxDefaultDateTime
,
242 const wxPoint
& pos
= wxDefaultPosition
,
243 const wxSize
& size
= wxDefaultSize
,
244 long style
= wxCAL_SHOW_HOLIDAYS
,
245 const wxString
& name
= wxCalendarNameStr
);
248 This function should be used instead of changing @c wxCAL_SHOW_HOLIDAYS
249 style bit directly. It enables or disables the special highlighting of the
252 void EnableHolidayDisplay(bool display
= @
true);
255 This function should be used instead of changing
256 @c wxCAL_NO_MONTH_CHANGE style bit. It allows or disallows the user to
257 change the month interactively. Note that if the month can not be changed, the
258 year can not be changed neither.
260 void EnableMonthChange(bool enable
= @
true);
263 This function should be used instead of changing @c wxCAL_NO_YEAR_CHANGE
264 style bit directly. It allows or disallows the user to change the year
267 void EnableYearChange(bool enable
= @
true);
270 Returns the attribute for the given date (should be in the range 1...31).
272 The returned pointer may be @NULL.
274 wxCalendarDateAttr
* GetAttr(size_t day
);
277 Gets the currently selected date.
279 const wxDateTime
GetDate();
282 Gets the background colour of the header part of the calendar window.
284 @sa SetHeaderColours()
286 const wxColour
GetHeaderColourBg();
289 Gets the foreground colour of the header part of the calendar window.
291 @sa SetHeaderColours()
293 const wxColour
GetHeaderColourFg();
296 Gets the background highlight colour.
298 @sa SetHighlightColours()
300 const wxColour
GetHighlightColourBg();
303 Gets the foreground highlight colour.
305 @sa SetHighlightColours()
307 const wxColour
GetHighlightColourFg();
310 Return the background colour currently used for holiday highlighting.
312 @sa SetHolidayColours()
314 const wxColour
GetHolidayColourBg();
317 Return the foreground colour currently used for holiday highlighting.
319 @sa SetHolidayColours()
321 const wxColour
GetHolidayColourFg();
324 Returns one of @c wxCAL_HITTEST_XXX
325 constants and fills either @e date or
326 @e wd pointer with the corresponding value depending on the hit test code.
328 wxCalendarHitTestResult
HitTest(const wxPoint
& pos
,
329 wxDateTime
* date
= @NULL
,
330 wxDateTime::WeekDay
* wd
= @NULL
);
333 Clears any attributes associated with the given day (in the range
336 void ResetAttr(size_t day
);
339 Associates the attribute with the specified date (in the range 1...31).
341 If the pointer is @NULL, the items attribute is cleared.
343 void SetAttr(size_t day
, wxCalendarDateAttr
* attr
);
346 Sets the current date.
348 void SetDate(const wxDateTime
& date
);
351 Set the colours used for painting the weekdays at the top of the control.
353 void SetHeaderColours(const wxColour
& colFg
,
354 const wxColour
& colBg
);
357 Set the colours to be used for highlighting the currently selected date.
359 void SetHighlightColours(const wxColour
& colFg
,
360 const wxColour
& colBg
);
363 Marks the specified day as being a holiday in the current month.
365 void SetHoliday(size_t day
);
368 Sets the colours to be used for the holidays highlighting (only used if the
369 window style includes @c wxCAL_SHOW_HOLIDAYS flag).
371 void SetHolidayColours(const wxColour
& colFg
,
372 const wxColour
& colBg
);