]> git.saurik.com Git - wxWidgets.git/blame - interface/wx/calctrl.h
Move code removing "-psn_xxx" command line arguments to common code.
[wxWidgets.git] / interface / wx / calctrl.h
CommitLineData
23324ae1
FM
1/////////////////////////////////////////////////////////////////////////////
2// Name: calctrl.h
49d37022 3// Purpose: interface of wxCalendarCtrl
23324ae1 4// Author: wxWidgets team
526954c5 5// Licence: wxWindows licence
23324ae1
FM
6/////////////////////////////////////////////////////////////////////////////
7
073b976d
RD
8enum
9{
10 // show Sunday as the first day of the week (default)
11 wxCAL_SUNDAY_FIRST = 0x0000,
12
13 // show Monday as the first day of the week
14 wxCAL_MONDAY_FIRST = 0x0001,
15
16 // highlight holidays
17 wxCAL_SHOW_HOLIDAYS = 0x0002,
18
19 // disable the year change control, show only the month change one
20 // deprecated
21 wxCAL_NO_YEAR_CHANGE = 0x0004,
22
23 // don't allow changing neither month nor year (implies
24 // wxCAL_NO_YEAR_CHANGE)
25 wxCAL_NO_MONTH_CHANGE = 0x000c,
26
27 // use MS-style month-selection instead of combo-spin combination
28 wxCAL_SEQUENTIAL_MONTH_SELECTION = 0x0010,
29
30 // show the neighbouring weeks in the previous and next month
31 wxCAL_SHOW_SURROUNDING_WEEKS = 0x0020,
32
33 // show week numbers on the left side of the calendar.
34 wxCAL_SHOW_WEEK_NUMBERS = 0x0040
35};
36
37
23324ae1
FM
38/**
39 @class wxCalendarEvent
7c913512 40
49d37022 41 The wxCalendarEvent class is used together with wxCalendarCtrl.
7c913512 42
23324ae1
FM
43 @library{wxadv}
44 @category{events}
7c913512 45
e54c96f1 46 @see wxCalendarCtrl
23324ae1
FM
47*/
48class wxCalendarEvent : public wxDateEvent
49{
50public:
073b976d
RD
51 wxCalendarEvent();
52 wxCalendarEvent(wxWindow *win, const wxDateTime& dt, wxEventType type);
53
23324ae1 54 /**
7c913512 55 Returns the week day on which the user clicked in
23324ae1
FM
56 @c EVT_CALENDAR_WEEKDAY_CLICKED handler. It doesn't make sense to call
57 this function in other handlers.
58 */
328f5751 59 wxDateTime::WeekDay GetWeekDay() const;
23324ae1
FM
60
61 /**
49d37022
BP
62 Sets the week day carried by the event, normally only used by the
63 library internally.
23324ae1 64 */
9d9c1c24 65 void SetWeekDay(const wxDateTime::WeekDay day);
23324ae1
FM
66};
67
073b976d
RD
68wxEventType wxEVT_CALENDAR_SEL_CHANGED;
69wxEventType wxEVT_CALENDAR_PAGE_CHANGED;
70wxEventType wxEVT_CALENDAR_DOUBLECLICKED;
71wxEventType wxEVT_CALENDAR_WEEKDAY_CLICKED;
72wxEventType wxEVT_CALENDAR_WEEK_CLICKED;
73
23324ae1 74
e54c96f1 75
49d37022
BP
76/**
77 Possible kinds of borders which may be used to decorate a date using
78 wxCalendarDateAttr.
79*/
80enum wxCalendarDateBorder
81{
82 wxCAL_BORDER_NONE, ///< No Border (Default)
83 wxCAL_BORDER_SQUARE, ///< Rectangular Border
84 wxCAL_BORDER_ROUND ///< Round Border
85};
86
23324ae1
FM
87/**
88 @class wxCalendarDateAttr
7c913512 89
49d37022
BP
90 wxCalendarDateAttr is a custom attributes for a calendar date. The objects
91 of this class are used with wxCalendarCtrl.
7c913512 92
23324ae1 93 @library{wxadv}
3c99e2fd 94 @category{data}
7c913512 95
e54c96f1 96 @see wxCalendarCtrl
23324ae1 97*/
7c913512 98class wxCalendarDateAttr
23324ae1
FM
99{
100public:
49d37022
BP
101 /**
102 Constructor for specifying all wxCalendarDateAttr properties.
103 */
9d9c1c24 104 wxCalendarDateAttr(const wxColour& colText = wxNullColour,
7c913512
FM
105 const wxColour& colBack = wxNullColour,
106 const wxColour& colBorder = wxNullColour,
107 const wxFont& font = wxNullFont,
108 wxCalendarDateBorder border = wxCAL_BORDER_NONE);
49d37022
BP
109
110 /**
111 Constructor using default properties except the given border.
112 */
7c913512
FM
113 wxCalendarDateAttr(wxCalendarDateBorder border,
114 const wxColour& colBorder = wxNullColour);
23324ae1
FM
115
116 /**
49d37022 117 Returns the background colour set for the calendar date.
23324ae1 118 */
9d9c1c24 119 const wxColour& GetBackgroundColour() const;
23324ae1
FM
120
121 /**
49d37022 122 Returns the border set for the calendar date.
23324ae1 123 */
328f5751 124 wxCalendarDateBorder GetBorder() const;
23324ae1
FM
125
126 /**
49d37022 127 Returns the border colour set for the calendar date.
23324ae1 128 */
9d9c1c24 129 const wxColour& GetBorderColour() const;
23324ae1
FM
130
131 /**
49d37022 132 Returns the font set for the calendar date.
23324ae1 133 */
9d9c1c24 134 const wxFont& GetFont() const;
23324ae1
FM
135
136 /**
49d37022 137 Returns the text colour set for the calendar date.
23324ae1 138 */
9d9c1c24 139 const wxColour& GetTextColour() const;
23324ae1
FM
140
141 /**
49d37022 142 Returns @true if a non-default text background colour is set.
23324ae1 143 */
328f5751 144 bool HasBackgroundColour() const;
23324ae1
FM
145
146 /**
0824e369 147 Returns @true if a non-default (i.e.\ any) border is set.
23324ae1 148 */
328f5751 149 bool HasBorder() const;
23324ae1
FM
150
151 /**
49d37022 152 Returns @true if a non-default border colour is set.
23324ae1 153 */
328f5751 154 bool HasBorderColour() const;
23324ae1
FM
155
156 /**
49d37022 157 Returns @true if a non-default font is set.
23324ae1 158 */
328f5751 159 bool HasFont() const;
23324ae1
FM
160
161 /**
49d37022 162 Returns @true if a non-default text foreground colour is set.
23324ae1 163 */
328f5751 164 bool HasTextColour() const;
23324ae1
FM
165
166 /**
49d37022 167 Returns @true if this calendar day is displayed as a holiday.
23324ae1 168 */
328f5751 169 bool IsHoliday() const;
23324ae1
FM
170
171 /**
172 Sets the text background colour to use.
173 */
174 void SetBackgroundColour(const wxColour& colBack);
175
176 /**
49d37022 177 Sets the border to use.
23324ae1
FM
178 */
179 void SetBorder(wxCalendarDateBorder border);
180
181 /**
182 Sets the border colour to use.
183 */
184 void SetBorderColour(const wxColour& col);
185
186 /**
187 Sets the font to use.
188 */
189 void SetFont(const wxFont& font);
190
191 /**
49d37022
BP
192 If @a holiday is @true, this calendar day will be displayed as a
193 holiday.
23324ae1
FM
194 */
195 void SetHoliday(bool holiday);
196
197 /**
198 Sets the text (foreground) colour to use.
199 */
200 void SetTextColour(const wxColour& colText);
628e155d
VZ
201
202 /**
49d37022 203 Used (internally) by the generic wxCalendarCtrl::Mark().
628e155d
VZ
204 */
205 static const wxCalendarDateAttr& GetMark();
206
207 /**
49d37022
BP
208 Set the attributes that will be used to Mark() days on the generic
209 wxCalendarCtrl.
628e155d 210 */
073b976d 211 static void SetMark(const wxCalendarDateAttr& m);
23324ae1
FM
212};
213
214
e54c96f1 215
49d37022
BP
216/**
217 Possible return values from wxCalendarCtrl::HitTest().
218*/
219enum wxCalendarHitTestResult
220{
221 wxCAL_HITTEST_NOWHERE, ///< Hit outside of anything.
222 wxCAL_HITTEST_HEADER, ///< Hit on the header (weekdays).
232b2162
VZ
223 wxCAL_HITTEST_DAY, ///< Hit on a day in the calendar.
224 wxCAL_HITTEST_INCMONTH, ///< Hit on next month arrow (in alternate month selector mode).
225 wxCAL_HITTEST_DECMONTH, ///< Hit on previous month arrow (in alternate month selector mode).
226 wxCAL_HITTEST_SURROUNDING_WEEK, ///< Hit on surrounding week of previous/next month (if shown).
227 wxCAL_HITTEST_WEEK ///< Hit on week of the year number (if shown).
49d37022
BP
228};
229
23324ae1
FM
230/**
231 @class wxCalendarCtrl
7c913512 232
628e155d 233 The calendar control allows the user to pick a date. The user can move the
7c913512 234 current selection using the keyboard and select the date (generating
49d37022 235 @c EVT_CALENDAR event) by pressing @c @<Return@> or double clicking it.
7c913512 236
628e155d 237 Generic calendar has advanced possibilities for the customization of its
49d37022
BP
238 display, described below. If you want to use these possibilities on every
239 platform, use wxGenericCalendarCtrl instead of wxCalendarCtrl.
628e155d 240
49d37022
BP
241 All global settings (such as colours and fonts used) can, of course, be
242 changed. But also, the display style for each day in the month can be set
243 independently using wxCalendarDateAttr class.
7c913512 244
23324ae1 245 An item without custom attributes is drawn with the default colours and
49d37022
BP
246 font and without border, but setting custom attributes with SetAttr()
247 allows to modify its appearance. Just create a custom attribute object and
248 set it for the day you want to be displayed specially (note that the
249 control will take ownership of the pointer, i.e. it will delete it itself).
628e155d 250 A day may be marked as being a holiday, even if it is not recognized as
49d37022 251 one by wxDateTime using the wxCalendarDateAttr::SetHoliday() method.
7c913512 252
49d37022
BP
253 As the attributes are specified for each day, they may change when the
254 month is changed, so you will often want to update them in
628e155d 255 @c EVT_CALENDAR_PAGE_CHANGED event handler.
7c913512 256
23324ae1 257 @beginStyleTable
8c6791e4 258 @style{wxCAL_SUNDAY_FIRST}
db0b0942 259 Show Sunday as the first day in the week (not in wxGTK)
8c6791e4 260 @style{wxCAL_MONDAY_FIRST}
db0b0942 261 Show Monday as the first day in the week (not in wxGTK)
8c6791e4 262 @style{wxCAL_SHOW_HOLIDAYS}
628e155d 263 Highlight holidays in the calendar (only generic)
8c6791e4 264 @style{wxCAL_NO_YEAR_CHANGE}
628e155d 265 Disable the year changing (deprecated, only generic)
8c6791e4 266 @style{wxCAL_NO_MONTH_CHANGE}
23324ae1 267 Disable the month (and, implicitly, the year) changing
8c6791e4 268 @style{wxCAL_SHOW_SURROUNDING_WEEKS}
23324ae1 269 Show the neighbouring weeks in the previous and next months
db0b0942 270 (only generic, always on for the native controls)
8c6791e4 271 @style{wxCAL_SEQUENTIAL_MONTH_SELECTION}
23324ae1 272 Use alternative, more compact, style for the month and year
628e155d 273 selection controls. (only generic)
7b0ccb8a
RR
274 @style{wxCAL_SHOW_WEEK_NUMBERS}
275 Show week numbers on the left side of the calendar. (not in generic)
23324ae1 276 @endStyleTable
7c913512 277
3051a44a 278 @beginEventEmissionTable{wxCalendarEvent}
8c6791e4 279 @event{EVT_CALENDAR(id, func)}
628e155d 280 A day was double clicked in the calendar.
8c6791e4 281 @event{EVT_CALENDAR_SEL_CHANGED(id, func)}
628e155d 282 The selected date changed.
8c6791e4 283 @event{EVT_CALENDAR_PAGE_CHANGED(id, func)}
628e155d 284 The selected month (and/or year) changed.
8c6791e4 285 @event{EVT_CALENDAR_WEEKDAY_CLICKED(id, func)}
628e155d 286 User clicked on the week day header (only generic).
232b2162
VZ
287 @event{EVT_CALENDAR_WEEK_CLICKED(id, func)}
288 User clicked on the week of the year number (only generic).
628e155d
VZ
289 @endEventTable
290
49d37022
BP
291 @note Changing the selected date will trigger an EVT_CALENDAR_DAY, MONTH or
292 YEAR event as well as an EVT_CALENDAR_SEL_CHANGED event.
293
23324ae1
FM
294 @library{wxadv}
295 @category{ctrl}
ce154616 296 @appearance{calendarctrl}
7c913512 297
7b0ccb8a 298 @nativeimpl{wxgtk,wxmsw}
628e155d 299
1f1d2182
FM
300 @see @ref page_samples_calendar, wxCalendarDateAttr, wxCalendarEvent,
301 wxDatePickerCtrl
23324ae1
FM
302*/
303class wxCalendarCtrl : public wxControl
304{
305public:
23324ae1 306 /**
49d37022 307 Default constructor.
23324ae1
FM
308 */
309 wxCalendarCtrl();
49d37022
BP
310
311 /**
312 Does the same as Create() method.
313 */
7c913512
FM
314 wxCalendarCtrl(wxWindow* parent, wxWindowID id,
315 const wxDateTime& date = wxDefaultDateTime,
316 const wxPoint& pos = wxDefaultPosition,
317 const wxSize& size = wxDefaultSize,
318 long style = wxCAL_SHOW_HOLIDAYS,
319 const wxString& name = wxCalendarNameStr);
23324ae1
FM
320
321 /**
322 Destroys the control.
323 */
324 ~wxCalendarCtrl();
325
326 /**
49d37022
BP
327 Creates the control. See wxWindow::wxWindow() for the meaning of the
328 parameters and the control overview for the possible styles.
23324ae1
FM
329 */
330 bool Create(wxWindow* parent, wxWindowID id,
331 const wxDateTime& date = wxDefaultDateTime,
332 const wxPoint& pos = wxDefaultPosition,
333 const wxSize& size = wxDefaultSize,
334 long style = wxCAL_SHOW_HOLIDAYS,
335 const wxString& name = wxCalendarNameStr);
336
337 /**
338 This function should be used instead of changing @c wxCAL_SHOW_HOLIDAYS
49d37022
BP
339 style bit directly. It enables or disables the special highlighting of
340 the holidays.
23324ae1 341 */
98ccd545 342 virtual void EnableHolidayDisplay(bool display = true);
23324ae1
FM
343
344 /**
7c913512 345 This function should be used instead of changing
23324ae1 346 @c wxCAL_NO_MONTH_CHANGE style bit. It allows or disallows the user to
4c51a665
DS
347 change the month interactively. Note that if the month cannot be
348 changed, the year cannot be changed neither.
628e155d 349
49d37022
BP
350 @return @true if the value of this option really changed or @false if
351 it was already set to the requested value.
23324ae1 352 */
98ccd545 353 virtual bool EnableMonthChange(bool enable = true);
23324ae1
FM
354
355 /**
628e155d
VZ
356 @deprecated
357
49d37022
BP
358 This function should be used instead of changing
359 @c wxCAL_NO_YEAR_CHANGE style bit directly. It allows or disallows the
360 user to change the year interactively. Only in generic wxCalendarCtrl.
23324ae1 361 */
98ccd545 362 virtual void EnableYearChange(bool enable = true);
23324ae1
FM
363
364 /**
49d37022
BP
365 Returns the attribute for the given date (should be in the range
366 1...31). The returned pointer may be @NULL. Only in generic
367 wxCalendarCtrl.
23324ae1 368 */
98ccd545 369 virtual wxCalendarDateAttr* GetAttr(size_t day) const;
23324ae1
FM
370
371 /**
372 Gets the currently selected date.
373 */
98ccd545 374 virtual wxDateTime GetDate() const;
23324ae1
FM
375
376 /**
377 Gets the background colour of the header part of the calendar window.
3c4f71cc 378
bf956fac
VZ
379 This method is currently only implemented in generic wxCalendarCtrl and
380 always returns @c wxNullColour in the native versions.
381
4cc4bfaf 382 @see SetHeaderColours()
23324ae1 383 */
98ccd545 384 virtual const wxColour& GetHeaderColourBg() const;
23324ae1
FM
385
386 /**
387 Gets the foreground colour of the header part of the calendar window.
bf956fac
VZ
388
389 This method is currently only implemented in generic wxCalendarCtrl and
390 always returns @c wxNullColour in the native versions.
3c4f71cc 391
4cc4bfaf 392 @see SetHeaderColours()
23324ae1 393 */
98ccd545 394 virtual const wxColour& GetHeaderColourFg() const;
23324ae1
FM
395
396 /**
628e155d 397 Gets the background highlight colour. Only in generic wxCalendarCtrl.
3c4f71cc 398
bf956fac
VZ
399 This method is currently only implemented in generic wxCalendarCtrl and
400 always returns @c wxNullColour in the native versions.
401
4cc4bfaf 402 @see SetHighlightColours()
23324ae1 403 */
98ccd545 404 virtual const wxColour& GetHighlightColourBg() const;
23324ae1
FM
405
406 /**
628e155d 407 Gets the foreground highlight colour. Only in generic wxCalendarCtrl.
3c4f71cc 408
bf956fac
VZ
409 This method is currently only implemented in generic wxCalendarCtrl and
410 always returns @c wxNullColour in the native versions.
411
4cc4bfaf 412 @see SetHighlightColours()
23324ae1 413 */
98ccd545 414 virtual const wxColour& GetHighlightColourFg() const;
23324ae1
FM
415
416 /**
417 Return the background colour currently used for holiday highlighting.
bf956fac
VZ
418
419 Only useful with generic wxCalendarCtrl as native versions currently
49d37022
BP
420 don't support holidays display at all and always return
421 @c wxNullColour.
3c4f71cc 422
4cc4bfaf 423 @see SetHolidayColours()
23324ae1 424 */
98ccd545 425 virtual const wxColour& GetHolidayColourBg() const;
23324ae1
FM
426
427 /**
428 Return the foreground colour currently used for holiday highlighting.
bf956fac
VZ
429
430 Only useful with generic wxCalendarCtrl as native versions currently
49d37022
BP
431 don't support holidays display at all and always return
432 @c wxNullColour.
3c4f71cc 433
4cc4bfaf 434 @see SetHolidayColours()
23324ae1 435 */
98ccd545 436 virtual const wxColour& GetHolidayColourFg() const;
23324ae1
FM
437
438 /**
49d37022
BP
439 Returns one of wxCalendarHitTestResult constants and fills either
440 @a date or @a wd pointer with the corresponding value depending on the
db0b0942 441 hit test code.
98ccd545 442
db0b0942 443 Not implemented in wxGTK currently.
23324ae1 444 */
98ccd545
FM
445 virtual wxCalendarHitTestResult HitTest(const wxPoint& pos,
446 wxDateTime* date = NULL,
447 wxDateTime::WeekDay* wd = NULL);
23324ae1
FM
448
449 /**
450 Clears any attributes associated with the given day (in the range
49d37022 451 1...31). Only in generic wxCalendarCtrl.
23324ae1 452 */
98ccd545 453 virtual void ResetAttr(size_t day);
23324ae1
FM
454
455 /**
456 Associates the attribute with the specified date (in the range 1...31).
49d37022
BP
457 If the pointer is @NULL, the items attribute is cleared. Only in
458 generic wxCalendarCtrl.
23324ae1 459 */
98ccd545 460 virtual void SetAttr(size_t day, wxCalendarDateAttr* attr);
23324ae1
FM
461
462 /**
463 Sets the current date.
db0b0942 464
106f0d98
VZ
465 The @a date parameter must be valid and in the currently valid range as
466 set by SetDateRange(), otherwise the current date is not changed and
467 the function returns @false.
23324ae1 468 */
9d9c1c24 469 virtual bool SetDate(const wxDateTime& date);
23324ae1
FM
470
471 /**
49d37022
BP
472 Set the colours used for painting the weekdays at the top of the
473 control.
bf956fac
VZ
474
475 This method is currently only implemented in generic wxCalendarCtrl and
476 does nothing in the native versions.
23324ae1 477 */
98ccd545
FM
478 virtual void SetHeaderColours(const wxColour& colFg,
479 const wxColour& colBg);
23324ae1
FM
480
481 /**
49d37022
BP
482 Set the colours to be used for highlighting the currently selected
483 date.
bf956fac
VZ
484
485 This method is currently only implemented in generic wxCalendarCtrl and
486 does nothing in the native versions.
23324ae1 487 */
98ccd545
FM
488 virtual void SetHighlightColours(const wxColour& colFg,
489 const wxColour& colBg);
23324ae1
FM
490
491 /**
492 Marks the specified day as being a holiday in the current month.
bf956fac
VZ
493
494 This method is only implemented in the generic version of the control
495 and does nothing in the native ones.
23324ae1 496 */
98ccd545 497 virtual void SetHoliday(size_t day);
23324ae1
FM
498
499 /**
bf956fac 500 Sets the colours to be used for the holidays highlighting.
98ccd545 501
bf956fac
VZ
502 This method is only implemented in the generic version of the control
503 and does nothing in the native ones. It should also only be called if
504 the window style includes @c wxCAL_SHOW_HOLIDAYS flag or
505 EnableHolidayDisplay() had been called.
506
23324ae1 507 */
98ccd545
FM
508 virtual void SetHolidayColours(const wxColour& colFg,
509 const wxColour& colBg);
628e155d
VZ
510
511 /**
49d37022
BP
512 Mark or unmark the day. This day of month will be marked in every
513 month. In generic wxCalendarCtrl,
628e155d 514 */
98ccd545 515 virtual void Mark(size_t day, bool mark);
51317496 516
51317496 517 /**
49d37022 518 @name Date Range Functions
51317496
VZ
519 */
520 //@{
521
522 /**
106f0d98
VZ
523 Restrict the dates that can be selected in the control to the specified
524 range.
51317496
VZ
525
526 If either date is set, the corresponding limit will be enforced and
527 @true returned. If none are set, the existing restrictions are removed
528 and @false is returned.
529
49d37022
BP
530 @see GetDateRange()
531
51317496 532 @param lowerdate
49d37022 533 The low limit for the dates shown by the control or
76e2b570 534 ::wxDefaultDateTime.
792255cc 535 @param upperdate
49d37022 536 The high limit for the dates shown by the control or
76e2b570 537 ::wxDefaultDateTime.
51317496
VZ
538 @return
539 @true if either limit is valid, @false otherwise
540 */
541 virtual bool SetDateRange(const wxDateTime& lowerdate = wxDefaultDateTime,
49d37022 542 const wxDateTime& upperdate = wxDefaultDateTime);
51317496
VZ
543
544 /**
545 Returns the limits currently being used.
546
547 @see SetDateRange()
548
549 @param lowerdate
49d37022 550 If non-@NULL, the value of the low limit for the dates shown by the
76e2b570 551 control is returned (which may be ::wxDefaultDateTime if no limit
49d37022 552 is set).
51317496 553 @param upperdate
49d37022 554 If non-@NULL, the value of the upper limit for the dates shown by
76e2b570 555 the control is returned (which may be ::wxDefaultDateTime if no
49d37022 556 limit is set).
51317496
VZ
557 @return
558 @true if either limit is set, @false otherwise
559 */
49d37022
BP
560 virtual bool GetDateRange(wxDateTime *lowerdate,
561 wxDateTime *upperdate) const;
51317496
VZ
562
563 //@}
23324ae1 564};
e54c96f1 565