]> git.saurik.com Git - wxWidgets.git/blame - interface/calctrl.h
several g++ 4 warning fixes
[wxWidgets.git] / interface / calctrl.h
CommitLineData
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*/
21class wxCalendarEvent : public wxDateEvent
22{
23public:
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 /**
32 Sets the week day carried by the event, normally only used by the library
33 internally.
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 52class wxCalendarDateAttr
23324ae1
FM
53{
54public:
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);
155};
156
157
e54c96f1 158
23324ae1
FM
159/**
160 @class wxCalendarCtrl
161 @wxheader{calctrl.h}
7c913512 162
23324ae1
FM
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
165 month
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
7c913512 168 current selection using the keyboard and select the date (generating
23324ae1 169 @c EVT_CALENDAR event) by pressing @c Return or double clicking it.
7c913512 170
23324ae1
FM
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.
7c913512 175
23324ae1 176 An item without custom attributes is drawn with the default colours and
7c913512 177 font and without border, but setting custom attributes with
23324ae1
FM
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
7c913512 182 if it is not recognized as one by wxDateTime using
23324ae1 183 wxCalendarDateAttr::SetHoliday method.
7c913512 184
23324ae1 185 As the attributes are specified for each day, they may change when the month
7c913512 186 is changed, so you will often want to update them in
23324ae1 187 @c EVT_CALENDAR_MONTH event handler.
7c913512 188
23324ae1
FM
189 @beginStyleTable
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
204 selection controls.
205 @endStyleTable
7c913512 206
23324ae1
FM
207 @library{wxadv}
208 @category{ctrl}
209 @appearance{calendarctrl.png}
7c913512 210
e54c96f1 211 @see @ref overview_samplecalendar "Calendar sample", wxCalendarDateAttr,
23324ae1
FM
212 wxCalendarEvent
213*/
214class wxCalendarCtrl : public wxControl
215{
216public:
217 //@{
218 /**
219 Does the same as Create() method.
220 */
221 wxCalendarCtrl();
7c913512
FM
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);
23324ae1
FM
228 //@}
229
230 /**
231 Destroys the control.
232 */
233 ~wxCalendarCtrl();
234
235 /**
236 Creates the control. See @ref wxWindow::ctor wxWindow for the meaning of
237 the parameters and the control overview for the possible styles.
238 */
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);
245
246 /**
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
249 holidays.
250 */
4cc4bfaf 251 void EnableHolidayDisplay(bool display = true);
23324ae1
FM
252
253 /**
7c913512 254 This function should be used instead of changing
23324ae1
FM
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.
258 */
4cc4bfaf 259 void EnableMonthChange(bool enable = true);
23324ae1
FM
260
261 /**
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
264 interactively.
265 */
4cc4bfaf 266 void EnableYearChange(bool enable = true);
23324ae1
FM
267
268 /**
269 Returns the attribute for the given date (should be in the range 1...31).
23324ae1
FM
270 The returned pointer may be @NULL.
271 */
328f5751 272 wxCalendarDateAttr* GetAttr(size_t day) const;
23324ae1
FM
273
274 /**
275 Gets the currently selected date.
276 */
328f5751 277 const wxDateTime GetDate() const;
23324ae1
FM
278
279 /**
280 Gets the background colour of the header part of the calendar window.
3c4f71cc 281
4cc4bfaf 282 @see SetHeaderColours()
23324ae1 283 */
328f5751 284 const wxColour GetHeaderColourBg() const;
23324ae1
FM
285
286 /**
287 Gets the foreground colour of the header part of the calendar window.
3c4f71cc 288
4cc4bfaf 289 @see SetHeaderColours()
23324ae1 290 */
328f5751 291 const wxColour GetHeaderColourFg() const;
23324ae1
FM
292
293 /**
294 Gets the background highlight colour.
3c4f71cc 295
4cc4bfaf 296 @see SetHighlightColours()
23324ae1 297 */
328f5751 298 const wxColour GetHighlightColourBg() const;
23324ae1
FM
299
300 /**
301 Gets the foreground highlight colour.
3c4f71cc 302
4cc4bfaf 303 @see SetHighlightColours()
23324ae1 304 */
328f5751 305 const wxColour GetHighlightColourFg() const;
23324ae1
FM
306
307 /**
308 Return the background colour currently used for holiday highlighting.
3c4f71cc 309
4cc4bfaf 310 @see SetHolidayColours()
23324ae1 311 */
328f5751 312 const wxColour GetHolidayColourBg() const;
23324ae1
FM
313
314 /**
315 Return the foreground colour currently used for holiday highlighting.
3c4f71cc 316
4cc4bfaf 317 @see SetHolidayColours()
23324ae1 318 */
328f5751 319 const wxColour GetHolidayColourFg() const;
23324ae1
FM
320
321 /**
7c913512 322 Returns one of @c wxCAL_HITTEST_XXX
e54c96f1 323 constants() and fills either @a date or
4cc4bfaf 324 @a wd pointer with the corresponding value depending on the hit test code.
23324ae1
FM
325 */
326 wxCalendarHitTestResult HitTest(const wxPoint& pos,
4cc4bfaf
FM
327 wxDateTime* date = NULL,
328 wxDateTime::WeekDay* wd = NULL);
23324ae1
FM
329
330 /**
331 Clears any attributes associated with the given day (in the range
332 1...31).
333 */
334 void ResetAttr(size_t day);
335
336 /**
337 Associates the attribute with the specified date (in the range 1...31).
23324ae1
FM
338 If the pointer is @NULL, the items attribute is cleared.
339 */
340 void SetAttr(size_t day, wxCalendarDateAttr* attr);
341
342 /**
343 Sets the current date.
344 */
345 void SetDate(const wxDateTime& date);
346
347 /**
348 Set the colours used for painting the weekdays at the top of the control.
349 */
350 void SetHeaderColours(const wxColour& colFg,
351 const wxColour& colBg);
352
353 /**
354 Set the colours to be used for highlighting the currently selected date.
355 */
356 void SetHighlightColours(const wxColour& colFg,
357 const wxColour& colBg);
358
359 /**
360 Marks the specified day as being a holiday in the current month.
361 */
362 void SetHoliday(size_t day);
363
364 /**
365 Sets the colours to be used for the holidays highlighting (only used if the
366 window style includes @c wxCAL_SHOW_HOLIDAYS flag).
367 */
368 void SetHolidayColours(const wxColour& colFg,
369 const wxColour& colBg);
370};
e54c96f1 371