1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxCalendarEvent
4 // Author: wxWidgets team
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
10 @class wxCalendarEvent
13 The wxCalendarEvent class is used together with
21 class wxCalendarEvent
: public wxDateEvent
25 Returns the week day on which the user clicked in
26 @c EVT_CALENDAR_WEEKDAY_CLICKED handler. It doesn't make sense to call
27 this function in other handlers.
29 wxDateTime::WeekDay
GetWeekDay() const;
32 Sets the week day carried by the event, normally only used by the library
35 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.
52 class wxCalendarDateAttr
60 wxCalendarDateAttr(const wxColour
& colText
,
61 const wxColour
& colBack
= wxNullColour
,
62 const wxColour
& colBorder
= wxNullColour
,
63 const wxFont
& font
= wxNullFont
,
64 wxCalendarDateBorder border
= wxCAL_BORDER_NONE
);
65 wxCalendarDateAttr(wxCalendarDateBorder border
,
66 const wxColour
& colBorder
= wxNullColour
);
70 Returns the background colour to use for the item with this attribute.
72 const wxColour
GetBackgroundColour() const;
75 Returns the border() to use for the item with this attribute.
77 wxCalendarDateBorder
GetBorder() const;
80 Returns the border colour to use for the item with this attribute.
82 const wxColour
GetBorderColour() const;
85 Returns the font to use for the item with this attribute.
87 const wxFont
GetFont() const;
90 Returns the text colour to use for the item with this attribute.
92 const wxColour
GetTextColour() const;
95 Returns @true if this attribute specifies a non-default text background
98 bool HasBackgroundColour() const;
101 Returns @true if this attribute specifies a non-default (i.e. any) border.
103 bool HasBorder() const;
106 Returns @true if this attribute specifies a non-default border colour.
108 bool HasBorderColour() const;
111 Returns @true if this attribute specifies a non-default font.
113 bool HasFont() const;
116 Returns @true if this item has a non-default text foreground colour.
118 bool HasTextColour() const;
121 Returns @true if this attribute specifies that this item should be
122 displayed as a holiday.
124 bool IsHoliday() const;
127 Sets the text background colour to use.
129 void SetBackgroundColour(const wxColour
& colBack
);
132 Sets the @ref overview_wxcalendardateattr "border kind"
134 void SetBorder(wxCalendarDateBorder border
);
137 Sets the border colour to use.
139 void SetBorderColour(const wxColour
& col
);
142 Sets the font to use.
144 void SetFont(const wxFont
& font
);
147 Display the date with this attribute as a holiday.
149 void SetHoliday(bool holiday
);
152 Sets the text (foreground) colour to use.
154 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}
211 @see @ref overview_samplecalendar "Calendar sample", wxCalendarDateAttr,
214 class wxCalendarCtrl
: public wxControl
219 Does the same as Create() method.
222 wxCalendarCtrl(wxWindow
* parent
, wxWindowID id
,
223 const wxDateTime
& date
= wxDefaultDateTime
,
224 const wxPoint
& pos
= wxDefaultPosition
,
225 const wxSize
& size
= wxDefaultSize
,
226 long style
= wxCAL_SHOW_HOLIDAYS
,
227 const wxString
& name
= wxCalendarNameStr
);
231 Destroys the control.
236 Creates the control. See @ref wxWindow::ctor wxWindow for the meaning of
237 the parameters and the control overview for the possible styles.
239 bool Create(wxWindow
* parent
, wxWindowID id
,
240 const wxDateTime
& date
= wxDefaultDateTime
,
241 const wxPoint
& pos
= wxDefaultPosition
,
242 const wxSize
& size
= wxDefaultSize
,
243 long style
= wxCAL_SHOW_HOLIDAYS
,
244 const wxString
& name
= wxCalendarNameStr
);
247 This function should be used instead of changing @c wxCAL_SHOW_HOLIDAYS
248 style bit directly. It enables or disables the special highlighting of the
251 void EnableHolidayDisplay(bool display
= true);
254 This function should be used instead of changing
255 @c wxCAL_NO_MONTH_CHANGE style bit. It allows or disallows the user to
256 change the month interactively. Note that if the month can not be changed, the
257 year can not be changed neither.
259 void EnableMonthChange(bool enable
= true);
262 This function should be used instead of changing @c wxCAL_NO_YEAR_CHANGE
263 style bit directly. It allows or disallows the user to change the year
266 void EnableYearChange(bool enable
= true);
269 Returns the attribute for the given date (should be in the range 1...31).
270 The returned pointer may be @NULL.
272 wxCalendarDateAttr
* GetAttr(size_t day
) const;
275 Gets the currently selected date.
277 const wxDateTime
GetDate() const;
280 Gets the background colour of the header part of the calendar window.
282 @see SetHeaderColours()
284 const wxColour
GetHeaderColourBg() const;
287 Gets the foreground colour of the header part of the calendar window.
289 @see SetHeaderColours()
291 const wxColour
GetHeaderColourFg() const;
294 Gets the background highlight colour.
296 @see SetHighlightColours()
298 const wxColour
GetHighlightColourBg() const;
301 Gets the foreground highlight colour.
303 @see SetHighlightColours()
305 const wxColour
GetHighlightColourFg() const;
308 Return the background colour currently used for holiday highlighting.
310 @see SetHolidayColours()
312 const wxColour
GetHolidayColourBg() const;
315 Return the foreground colour currently used for holiday highlighting.
317 @see SetHolidayColours()
319 const wxColour
GetHolidayColourFg() const;
322 Returns one of @c wxCAL_HITTEST_XXX
323 constants() and fills either @a date or
324 @a wd pointer with the corresponding value depending on the hit test code.
326 wxCalendarHitTestResult
HitTest(const wxPoint
& pos
,
327 wxDateTime
* date
= NULL
,
328 wxDateTime::WeekDay
* wd
= NULL
);
331 Clears any attributes associated with the given day (in the range
334 void ResetAttr(size_t day
);
337 Associates the attribute with the specified date (in the range 1...31).
338 If the pointer is @NULL, the items attribute is cleared.
340 void SetAttr(size_t day
, wxCalendarDateAttr
* attr
);
343 Sets the current date.
345 void SetDate(const wxDateTime
& date
);
348 Set the colours used for painting the weekdays at the top of the control.
350 void SetHeaderColours(const wxColour
& colFg
,
351 const wxColour
& colBg
);
354 Set the colours to be used for highlighting the currently selected date.
356 void SetHighlightColours(const wxColour
& colFg
,
357 const wxColour
& colBg
);
360 Marks the specified day as being a holiday in the current month.
362 void SetHoliday(size_t day
);
365 Sets the colours to be used for the holidays highlighting (only used if the
366 window style includes @c wxCAL_SHOW_HOLIDAYS flag).
368 void SetHolidayColours(const wxColour
& colFg
,
369 const wxColour
& colBg
);