]>
Commit | Line | Data |
---|---|---|
23324ae1 FM |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: calctrl.h | |
e54c96f1 | 3 | // Purpose: interface of wxCalendarEvent |
23324ae1 FM |
4 | // Author: wxWidgets team |
5 | // RCS-ID: $Id$ | |
6 | // Licence: wxWindows license | |
7 | ///////////////////////////////////////////////////////////////////////////// | |
8 | ||
9 | /** | |
10 | @class wxCalendarEvent | |
11 | @wxheader{calctrl.h} | |
7c913512 FM |
12 | |
13 | The wxCalendarEvent class is used together with | |
23324ae1 | 14 | wxCalendarCtrl. |
7c913512 | 15 | |
23324ae1 FM |
16 | @library{wxadv} |
17 | @category{events} | |
7c913512 | 18 | |
e54c96f1 | 19 | @see wxCalendarCtrl |
23324ae1 FM |
20 | */ |
21 | class wxCalendarEvent : public wxDateEvent | |
22 | { | |
23 | public: | |
24 | /** | |
7c913512 | 25 | Returns the week day on which the user clicked in |
23324ae1 FM |
26 | @c EVT_CALENDAR_WEEKDAY_CLICKED handler. It doesn't make sense to call |
27 | this function in other handlers. | |
28 | */ | |
328f5751 | 29 | wxDateTime::WeekDay GetWeekDay() const; |
23324ae1 FM |
30 | |
31 | /** | |
628e155d VZ |
32 | Sets the week day carried by the event, |
33 | normally only used by the library internally. | |
23324ae1 FM |
34 | */ |
35 | void SetWeekDay(wxDateTime::WeekDay day); | |
36 | }; | |
37 | ||
38 | ||
e54c96f1 | 39 | |
23324ae1 FM |
40 | /** |
41 | @class wxCalendarDateAttr | |
42 | @wxheader{calctrl.h} | |
7c913512 | 43 | |
23324ae1 FM |
44 | wxCalendarDateAttr is a custom attributes for a calendar date. The objects of |
45 | this class are used with wxCalendarCtrl. | |
7c913512 | 46 | |
23324ae1 FM |
47 | @library{wxadv} |
48 | @category{misc} | |
7c913512 | 49 | |
e54c96f1 | 50 | @see wxCalendarCtrl |
23324ae1 | 51 | */ |
7c913512 | 52 | class wxCalendarDateAttr |
23324ae1 FM |
53 | { |
54 | public: | |
55 | //@{ | |
56 | /** | |
57 | The constructors. | |
58 | */ | |
59 | wxCalendarDateAttr(); | |
7c913512 FM |
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); | |
23324ae1 FM |
67 | //@} |
68 | ||
69 | /** | |
70 | Returns the background colour to use for the item with this attribute. | |
71 | */ | |
328f5751 | 72 | const wxColour GetBackgroundColour() const; |
23324ae1 FM |
73 | |
74 | /** | |
e54c96f1 | 75 | Returns the border() to use for the item with this attribute. |
23324ae1 | 76 | */ |
328f5751 | 77 | wxCalendarDateBorder GetBorder() const; |
23324ae1 FM |
78 | |
79 | /** | |
80 | Returns the border colour to use for the item with this attribute. | |
81 | */ | |
328f5751 | 82 | const wxColour GetBorderColour() const; |
23324ae1 FM |
83 | |
84 | /** | |
85 | Returns the font to use for the item with this attribute. | |
86 | */ | |
328f5751 | 87 | const wxFont GetFont() const; |
23324ae1 FM |
88 | |
89 | /** | |
90 | Returns the text colour to use for the item with this attribute. | |
91 | */ | |
328f5751 | 92 | const wxColour GetTextColour() const; |
23324ae1 FM |
93 | |
94 | /** | |
95 | Returns @true if this attribute specifies a non-default text background | |
96 | colour. | |
97 | */ | |
328f5751 | 98 | bool HasBackgroundColour() const; |
23324ae1 FM |
99 | |
100 | /** | |
101 | Returns @true if this attribute specifies a non-default (i.e. any) border. | |
102 | */ | |
328f5751 | 103 | bool HasBorder() const; |
23324ae1 FM |
104 | |
105 | /** | |
106 | Returns @true if this attribute specifies a non-default border colour. | |
107 | */ | |
328f5751 | 108 | bool HasBorderColour() const; |
23324ae1 FM |
109 | |
110 | /** | |
111 | Returns @true if this attribute specifies a non-default font. | |
112 | */ | |
328f5751 | 113 | bool HasFont() const; |
23324ae1 FM |
114 | |
115 | /** | |
116 | Returns @true if this item has a non-default text foreground colour. | |
117 | */ | |
328f5751 | 118 | bool HasTextColour() const; |
23324ae1 FM |
119 | |
120 | /** | |
121 | Returns @true if this attribute specifies that this item should be | |
122 | displayed as a holiday. | |
123 | */ | |
328f5751 | 124 | bool IsHoliday() const; |
23324ae1 FM |
125 | |
126 | /** | |
127 | Sets the text background colour to use. | |
128 | */ | |
129 | void SetBackgroundColour(const wxColour& colBack); | |
130 | ||
131 | /** | |
132 | Sets the @ref overview_wxcalendardateattr "border kind" | |
133 | */ | |
134 | void SetBorder(wxCalendarDateBorder border); | |
135 | ||
136 | /** | |
137 | Sets the border colour to use. | |
138 | */ | |
139 | void SetBorderColour(const wxColour& col); | |
140 | ||
141 | /** | |
142 | Sets the font to use. | |
143 | */ | |
144 | void SetFont(const wxFont& font); | |
145 | ||
146 | /** | |
147 | Display the date with this attribute as a holiday. | |
148 | */ | |
149 | void SetHoliday(bool holiday); | |
150 | ||
151 | /** | |
152 | Sets the text (foreground) colour to use. | |
153 | */ | |
154 | void SetTextColour(const wxColour& colText); | |
628e155d VZ |
155 | |
156 | /** | |
157 | Used (internally) by generic wxCalendarCtrl::Mark() | |
158 | */ | |
159 | static const wxCalendarDateAttr& GetMark(); | |
160 | ||
161 | /** | |
162 | Set the attribute that will be used to Mark() days | |
163 | on generic wxCalendarCtrl | |
164 | */ | |
165 | static void SetMark(wxCalendarDateAttr const& m); | |
23324ae1 FM |
166 | }; |
167 | ||
168 | ||
e54c96f1 | 169 | |
23324ae1 FM |
170 | /** |
171 | @class wxCalendarCtrl | |
172 | @wxheader{calctrl.h} | |
7c913512 | 173 | |
628e155d | 174 | The calendar control allows the user to pick a date. The user can move the |
7c913512 | 175 | current selection using the keyboard and select the date (generating |
23324ae1 | 176 | @c EVT_CALENDAR event) by pressing @c Return or double clicking it. |
7c913512 | 177 | |
628e155d VZ |
178 | Generic calendar has advanced possibilities for the customization of its |
179 | display, described below. If you want to use these possibilities on | |
180 | every platform, use wxGenericCalendarCtrl instead of wxCalendarCtrl. | |
181 | ||
182 | All global settings (such as colours and fonts used) can, of course, | |
183 | be changed. But also, the display style for each day in the month can | |
184 | be set independently using wxCalendarDateAttr class. | |
7c913512 | 185 | |
23324ae1 | 186 | An item without custom attributes is drawn with the default colours and |
7c913512 | 187 | font and without border, but setting custom attributes with |
23324ae1 FM |
188 | wxCalendarCtrl::SetAttr allows to modify its appearance. Just |
189 | create a custom attribute object and set it for the day you want to be | |
628e155d VZ |
190 | displayed specially (note that the control will take ownership of |
191 | the pointer, i.e. it will delete it itself). | |
192 | A day may be marked as being a holiday, even if it is not recognized as | |
193 | one by wxDateTime using wxCalendarDateAttr::SetHoliday method. | |
7c913512 | 194 | |
23324ae1 | 195 | As the attributes are specified for each day, they may change when the month |
7c913512 | 196 | is changed, so you will often want to update them in |
628e155d | 197 | @c EVT_CALENDAR_PAGE_CHANGED event handler. |
7c913512 | 198 | |
23324ae1 FM |
199 | @beginStyleTable |
200 | @style{wxCAL_SUNDAY_FIRST}: | |
628e155d | 201 | Show Sunday as the first day in the week (only generic) |
23324ae1 | 202 | @style{wxCAL_MONDAY_FIRST}: |
628e155d | 203 | Show Monday as the first day in the week (only generic) |
23324ae1 | 204 | @style{wxCAL_SHOW_HOLIDAYS}: |
628e155d | 205 | Highlight holidays in the calendar (only generic) |
23324ae1 | 206 | @style{wxCAL_NO_YEAR_CHANGE}: |
628e155d | 207 | Disable the year changing (deprecated, only generic) |
23324ae1 FM |
208 | @style{wxCAL_NO_MONTH_CHANGE}: |
209 | Disable the month (and, implicitly, the year) changing | |
210 | @style{wxCAL_SHOW_SURROUNDING_WEEKS}: | |
211 | Show the neighbouring weeks in the previous and next months | |
628e155d | 212 | (only generic) |
23324ae1 FM |
213 | @style{wxCAL_SEQUENTIAL_MONTH_SELECTION}: |
214 | Use alternative, more compact, style for the month and year | |
628e155d | 215 | selection controls. (only generic) |
23324ae1 | 216 | @endStyleTable |
7c913512 | 217 | |
1f1d2182 | 218 | @beginEventTable{wxCalendarEvent} |
628e155d VZ |
219 | @event{EVT_CALENDAR(id, func)}: |
220 | A day was double clicked in the calendar. | |
221 | @event{EVT_CALENDAR_SEL_CHANGED(id, func)}: | |
222 | The selected date changed. | |
223 | @event{EVT_CALENDAR_PAGE_CHANGED(id, func)}: | |
224 | The selected month (and/or year) changed. | |
225 | @event{EVT_CALENDAR_WEEKDAY_CLICKED(id, func)}: | |
226 | User clicked on the week day header (only generic). | |
227 | @endEventTable | |
228 | ||
23324ae1 FM |
229 | @library{wxadv} |
230 | @category{ctrl} | |
231 | @appearance{calendarctrl.png} | |
7c913512 | 232 | |
628e155d VZ |
233 | @nativeimpl{wxgtk} |
234 | ||
1f1d2182 FM |
235 | @see @ref page_samples_calendar, wxCalendarDateAttr, wxCalendarEvent, |
236 | wxDatePickerCtrl | |
23324ae1 FM |
237 | */ |
238 | class wxCalendarCtrl : public wxControl | |
239 | { | |
240 | public: | |
241 | //@{ | |
242 | /** | |
243 | Does the same as Create() method. | |
244 | */ | |
245 | wxCalendarCtrl(); | |
7c913512 FM |
246 | wxCalendarCtrl(wxWindow* parent, wxWindowID id, |
247 | const wxDateTime& date = wxDefaultDateTime, | |
248 | const wxPoint& pos = wxDefaultPosition, | |
249 | const wxSize& size = wxDefaultSize, | |
250 | long style = wxCAL_SHOW_HOLIDAYS, | |
251 | const wxString& name = wxCalendarNameStr); | |
23324ae1 FM |
252 | //@} |
253 | ||
254 | /** | |
255 | Destroys the control. | |
256 | */ | |
257 | ~wxCalendarCtrl(); | |
258 | ||
259 | /** | |
260 | Creates the control. See @ref wxWindow::ctor wxWindow for the meaning of | |
261 | the parameters and the control overview for the possible styles. | |
262 | */ | |
263 | bool Create(wxWindow* parent, wxWindowID id, | |
264 | const wxDateTime& date = wxDefaultDateTime, | |
265 | const wxPoint& pos = wxDefaultPosition, | |
266 | const wxSize& size = wxDefaultSize, | |
267 | long style = wxCAL_SHOW_HOLIDAYS, | |
268 | const wxString& name = wxCalendarNameStr); | |
269 | ||
270 | /** | |
271 | This function should be used instead of changing @c wxCAL_SHOW_HOLIDAYS | |
272 | style bit directly. It enables or disables the special highlighting of the | |
273 | holidays. | |
274 | */ | |
4cc4bfaf | 275 | void EnableHolidayDisplay(bool display = true); |
23324ae1 FM |
276 | |
277 | /** | |
7c913512 | 278 | This function should be used instead of changing |
23324ae1 | 279 | @c wxCAL_NO_MONTH_CHANGE style bit. It allows or disallows the user to |
628e155d VZ |
280 | change the month interactively. Note that if the month can not |
281 | be changed, the year can not be changed neither. | |
282 | ||
283 | @return @true if the value of this option really changed or @false | |
284 | if it was already set to the requested value. | |
23324ae1 | 285 | */ |
628e155d | 286 | bool EnableMonthChange(bool enable = true); |
23324ae1 FM |
287 | |
288 | /** | |
628e155d VZ |
289 | @deprecated |
290 | ||
23324ae1 FM |
291 | This function should be used instead of changing @c wxCAL_NO_YEAR_CHANGE |
292 | style bit directly. It allows or disallows the user to change the year | |
628e155d | 293 | interactively. Only in generic wxCalendarCtrl. |
23324ae1 | 294 | */ |
4cc4bfaf | 295 | void EnableYearChange(bool enable = true); |
23324ae1 FM |
296 | |
297 | /** | |
298 | Returns the attribute for the given date (should be in the range 1...31). | |
628e155d | 299 | The returned pointer may be @NULL. Only in generic wxCalendarCtrl. |
23324ae1 | 300 | */ |
328f5751 | 301 | wxCalendarDateAttr* GetAttr(size_t day) const; |
23324ae1 FM |
302 | |
303 | /** | |
304 | Gets the currently selected date. | |
305 | */ | |
328f5751 | 306 | const wxDateTime GetDate() const; |
23324ae1 FM |
307 | |
308 | /** | |
309 | Gets the background colour of the header part of the calendar window. | |
3c4f71cc | 310 | |
4cc4bfaf | 311 | @see SetHeaderColours() |
23324ae1 | 312 | */ |
328f5751 | 313 | const wxColour GetHeaderColourBg() const; |
23324ae1 FM |
314 | |
315 | /** | |
316 | Gets the foreground colour of the header part of the calendar window. | |
628e155d | 317 | Only in generic wxCalendarCtrl. |
3c4f71cc | 318 | |
4cc4bfaf | 319 | @see SetHeaderColours() |
23324ae1 | 320 | */ |
328f5751 | 321 | const wxColour GetHeaderColourFg() const; |
23324ae1 FM |
322 | |
323 | /** | |
628e155d | 324 | Gets the background highlight colour. Only in generic wxCalendarCtrl. |
3c4f71cc | 325 | |
4cc4bfaf | 326 | @see SetHighlightColours() |
23324ae1 | 327 | */ |
328f5751 | 328 | const wxColour GetHighlightColourBg() const; |
23324ae1 FM |
329 | |
330 | /** | |
628e155d | 331 | Gets the foreground highlight colour. Only in generic wxCalendarCtrl. |
3c4f71cc | 332 | |
4cc4bfaf | 333 | @see SetHighlightColours() |
23324ae1 | 334 | */ |
328f5751 | 335 | const wxColour GetHighlightColourFg() const; |
23324ae1 FM |
336 | |
337 | /** | |
338 | Return the background colour currently used for holiday highlighting. | |
628e155d | 339 | Only in generic wxCalendarCtrl. |
3c4f71cc | 340 | |
4cc4bfaf | 341 | @see SetHolidayColours() |
23324ae1 | 342 | */ |
328f5751 | 343 | const wxColour GetHolidayColourBg() const; |
23324ae1 FM |
344 | |
345 | /** | |
346 | Return the foreground colour currently used for holiday highlighting. | |
628e155d | 347 | Only in generic wxCalendarCtrl. |
3c4f71cc | 348 | |
4cc4bfaf | 349 | @see SetHolidayColours() |
23324ae1 | 350 | */ |
328f5751 | 351 | const wxColour GetHolidayColourFg() const; |
23324ae1 FM |
352 | |
353 | /** | |
7c913512 | 354 | Returns one of @c wxCAL_HITTEST_XXX |
628e155d VZ |
355 | constants() and fills either @a date or @a wd pointer with |
356 | the corresponding value depending on the hit test code. | |
357 | Only in generic wxCalendarCtrl. | |
23324ae1 FM |
358 | */ |
359 | wxCalendarHitTestResult HitTest(const wxPoint& pos, | |
4cc4bfaf FM |
360 | wxDateTime* date = NULL, |
361 | wxDateTime::WeekDay* wd = NULL); | |
23324ae1 FM |
362 | |
363 | /** | |
364 | Clears any attributes associated with the given day (in the range | |
365 | 1...31). | |
628e155d | 366 | Only in generic wxCalendarCtrl. |
23324ae1 FM |
367 | */ |
368 | void ResetAttr(size_t day); | |
369 | ||
370 | /** | |
371 | Associates the attribute with the specified date (in the range 1...31). | |
23324ae1 | 372 | If the pointer is @NULL, the items attribute is cleared. |
628e155d | 373 | Only in generic wxCalendarCtrl. |
23324ae1 FM |
374 | */ |
375 | void SetAttr(size_t day, wxCalendarDateAttr* attr); | |
376 | ||
377 | /** | |
378 | Sets the current date. | |
379 | */ | |
380 | void SetDate(const wxDateTime& date); | |
381 | ||
382 | /** | |
383 | Set the colours used for painting the weekdays at the top of the control. | |
628e155d | 384 | Only in generic wxCalendarCtrl. |
23324ae1 FM |
385 | */ |
386 | void SetHeaderColours(const wxColour& colFg, | |
387 | const wxColour& colBg); | |
388 | ||
389 | /** | |
390 | Set the colours to be used for highlighting the currently selected date. | |
628e155d | 391 | Only in generic wxCalendarCtrl. |
23324ae1 FM |
392 | */ |
393 | void SetHighlightColours(const wxColour& colFg, | |
394 | const wxColour& colBg); | |
395 | ||
396 | /** | |
397 | Marks the specified day as being a holiday in the current month. | |
398 | */ | |
399 | void SetHoliday(size_t day); | |
400 | ||
401 | /** | |
402 | Sets the colours to be used for the holidays highlighting (only used if the | |
403 | window style includes @c wxCAL_SHOW_HOLIDAYS flag). | |
628e155d | 404 | Only in generic wxCalendarCtrl. |
23324ae1 FM |
405 | */ |
406 | void SetHolidayColours(const wxColour& colFg, | |
407 | const wxColour& colBg); | |
628e155d VZ |
408 | |
409 | /** | |
410 | Mark or unmark the day. | |
411 | This day of month will be marked in every month. | |
412 | In generic wxCalendarCtrl, | |
413 | */ | |
414 | void Mark(size_t day, bool mark); | |
23324ae1 | 415 | }; |
e54c96f1 | 416 |