]> git.saurik.com Git - wxWidgets.git/blame - docs/latex/wx/calctrl.tex
Adding borders to OS/2 objects
[wxWidgets.git] / docs / latex / wx / calctrl.tex
CommitLineData
4f6aed9c
VZ
1%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2%% Name: calctrl.tex
3%% Purpose: wxCalendarCtrl documentation
4%% Author: Vadim Zeitlin
5%% Modified by:
6%% Created: 03.01.00
7%% RCS-ID: $Id$
8%% Copyright: (c) Vadim Zeitlin
f6bcfd97 9%% License: wxWindows license
4f6aed9c
VZ
10%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
11
12\section{\class{wxCalendarCtrl}}\label{wxcalendarctrl}
13
f6bcfd97
BP
14The calendar control allows the user to pick a date interactively. For this,
15it displays a window containing several parts: the control to pick the month
16and the year at the top (either or both of them may be disabled) and a month
17area below them which shows all the days in the month. The user can move the
18current selection using the keyboard and select the date (generating
19{\tt EVT\_CALENDAR} event) by pressing {\tt <Return>} or double clicking it.
20
21It has advanced possibilities for the customization of its display. All global
22settings (such as colours and fonts used) can, of course, be changed. But
23also, the display style for each day in the month can be set independently
24using \helpref{wxCalendarDateAttr}{wxcalendardateattr} class.
25
26An item without custom attributes is drawn with the default colours and
27font and without border, but setting custom attributes with
28\helpref{SetAttr}{wxcalendarctrlsetattr} allows to modify its appearance. Just
29create a custom attribute object and set it for the day you want to be
30displayed specially (note that the control will take ownership of the pointer,
31i.e. it will delete it itself). A day may be marked as being a holiday, even
32if it is not reckognized as oen by \helpref{wxDateTime}{tdateholidays} using
33\helpref{SetHoliday}{wxcalendardateattrsetholiday} method.
34
35As the attributes are specified for each day, they may change when the month
36is changed, so you will often want to update them in
37{\tt EVT\_CALENDAR\_MONTH} event handler.
38
39\wxheading{Derived from}
40
41\helpref{wxControl}{wxcontrol}\\
42\helpref{wxWindow}{wxwindow}\\
43\helpref{wxEvtHandler}{wxevthandler}\\
44\helpref{wxObject}{wxobject}
4f6aed9c
VZ
45
46\wxheading{Include files}
47
48<wx/calctrl.h>
49
f6bcfd97
BP
50\wxheading{Window styles}
51
52\twocolwidtha{5cm}
53\begin{twocollist}\itemsep=4pt
54\twocolitem{\windowstyle{wxCAL\_SUNDAY\_FIRST}}{Show Sunday as the first day in the week}
55\twocolitem{\windowstyle{wxCAL\_MONDAY\_FIRST}}{Show Monday as the first day in the week}
56\twocolitem{\windowstyle{wxCAL\_SHOW\_HOLIDAYS}}{Highlight holidays in the calendar}
57\twocolitem{\windowstyle{wxCAL\_NO\_YEAR\_CHANGE}}{Disable the year changing}
58\twocolitem{\windowstyle{wxCAL\_NO\_MONTH\_CHANGE}}{Disable the month (and, implicitly, the year) changing}
59\end{twocollist}
60
61The default calendar style is {\tt wxCAL\_SHOW\_HOLIDAYS}.
62
63\wxheading{Event table macros}
64
65To process input from a calendar control, use these event handler macros to
66direct input to member functions that take a
67\helpref{wxCalendarEvent}{wxcalendarevent} argument.
68
69\twocolwidtha{7cm}
70\begin{twocollist}\itemsep=7pt
71\twocolitem{{\bf EVT\_CALENDAR(id, func)}}{A day was double clickedi n the calendar.}
72\twocolitem{{\bf EVT\_CALENDAR\_SEL\_CHANGED(id, func)}}{The selected date changed.}
73\twocolitem{{\bf EVT\_CALENDAR\_DAY(id, func)}}{The selected day changed.}
74\twocolitem{{\bf EVT\_CALENDAR\_MONTH(id, func)}}{The selected month changed.}
75\twocolitem{{\bf EVT\_CALENDAR\_YEAR(id, func)}}{The selected year changed.}
76\twocolitem{{\bf EVT\_CALENDAR\_WEEKDAY\_CLICKED(id, func)}}{User clicked on the week day header}
77\end{twocollist}%
78
79Note that changing the selected date will result in either of
80{\tt EVT\_CALENDAR\_DAY}, {\tt MONTH} or {\tt YEAR} events and
81{\tt EVT\_CALENDAR\_SEL\_CHANGED} one.
82
83\wxheading{Constants}
84
85The following are the possible return values for
86\helpref{HitTest}{wxcalendarctrlhittest} method:
a3dafe87
VZ
87
88\begin{verbatim}
f6bcfd97
BP
89enum wxCalendarHitTestResult
90\{
91 wxCAL_HITTEST_NOWHERE, // outside of anything
92 wxCAL_HITTEST_HEADER, // on the header (weekdays)
93 wxCAL_HITTEST_DAY // on a day in the calendar
94\};
a3dafe87 95\end{verbatim}
f6bcfd97
BP
96
97\wxheading{See also}
98
99\helpref{Calendar sample}{samplecalendar}\\
100\helpref{wxCalendarDateAttr}{wxcalendardateattr}\\
101\helpref{wxCalendarEvent}{wxcalendarevent}
102
103\latexignore{\rtfignore{\wxheading{Members}}}
104
105\membersection{wxCalendarCtrl::wxCalendarCtrl}\label{wxcalendarctrlwxcalendarctrldef}
106
107\func{}{wxCalendarCtrl}{\void}
108
109Default constructor, use \helpref{Create}{wxcalendarctrlcreate} after it.
110
111\membersection{wxCalendarCtrl::wxCalendarCtrl}\label{wxcalendarctrlwxcalendarctrl}
112
113\func{}{wxCalendarCtrl}{\param{wxWindow* }{parent}, \param{wxWindowID }{id}, \param{const wxDateTime\& }{date = wxDefaultDateTime}, \param{const wxPoint\& }{pos = wxDefaultPosition}, \param{const wxSize\& }{size = wxDefaultSize}, \param{long }{style = wxCAL\_SHOW\_HOLIDAYS}, \param{const wxString\& }{name = wxCalendarNameStr}}
114
115Does the same as \helpref{Create}{wxcalendarctrlcreate} method.
116
117\membersection{wxCalendarCtrl::Create}\label{wxcalendarctrlcreate}
118
119\func{bool}{Create}{\param{wxWindow* }{parent}, \param{wxWindowID }{id}, \param{const wxDateTime\& }{date = wxDefaultDateTime}, \param{const wxPoint\& }{pos = wxDefaultPosition}, \param{const wxSize\& }{size = wxDefaultSize}, \param{long }{style = wxCAL\_SHOW\_HOLIDAYS}, \param{const wxString\& }{name = wxCalendarNameStr}}
120
121Creates the control. See \helpref{wxWindow}{wxwindowctor} for the meaning of
122the parameters and the control overview for the possible styles.
123
124\membersection{wxCalendarCtrl::\destruct{wxCalendarCtrl}}\label{wxcalendarctrldtor}
125
126\func{}{\destruct{wxCalendarCtrl}}{\void}
127
128Destroys the control.
129
130\membersection{wxCalendarCtrl::SetDate}\label{wxcalendarctrlsetdate}
131
132\func{void}{SetDate}{\param{const wxDateTime\& }{date}}
133
134Sets the current date.
135
136\membersection{wxCalendarCtrl::GetDate}\label{wxcalendarctrlgetdate}
137
138\constfunc{const wxDateTime\&}{GetDate}{\void}
139
140Gets the currently selected date.
141
142\membersection{wxCalendarCtrl::EnableYearChange}\label{wxcalendarctrlenableyearchange}
143
144\func{void}{EnableYearChange}{\param{bool }{enable = TRUE}}
145
146This function should be used instead of changing {\tt wxCAL\_NO\_YEAR\_CHANGE}
147style bit directly. It allows or disallows the user to chaneg the year
148interactively.
149
150\membersection{wxCalendarCtrl::EnableMonthChange}\label{wxcalendarctrlenablemonthchange}
151
152\func{void}{EnableMonthChange}{\param{bool }{enable = TRUE}}
153
154This function should be used instead of changing
155{\tt wxCAL\_NO\_MONTH\_CHANGE} style bit. It allows or disallows the user to
156change the month interactively. Note that if the month can not be changed, the
157year can not be changed neither.
158
159\membersection{wxCalendarCtrl::EnableHolidayDisplay}\label{wxcalendarctrlenableholidaydisplay}
160
161\func{void}{EnableHolidayDisplay}{\param{bool }{display = TRUE}}
162
163This function should be used instead of changing {\tt wxCAL\_SHOW\_HOLIDAYS}
164style bit directly. It enables or disables the special highlighting of the
165holidays.
166
167\membersection{wxCalendarCtrl::SetHeaderColours}\label{wxcalendarctrlsetheadercolours}
168
169\func{void}{SetHeaderColours}{\param{const wxColour\& }{colFg}, \param{const wxColour\& }{colBg}}
170
171Set the colours used for painting the weekdays at the top of the control.
172
173\membersection{wxCalendarCtrl::GetHeaderColourFg}\label{wxcalendarctrlgetheadercolourfg}
174
175\constfunc{const wxColour\&}{GetHeaderColourFg}{\void}
176
177Gets the foreground colour of the header part of the calendar window.
178
179\wxheading{See also}
180
181\helpref{SetHeaderColours}{wxcalendarctrlsetheadercolours}
182
183\membersection{wxCalendarCtrl::GetHeaderColourBg}\label{wxcalendarctrlgetheadercolourbg}
184
185\constfunc{const wxColour\&}{GetHeaderColourBg}{\void}
186
187Gets the background colour of the header part of the calendar window.
188
189\wxheading{See also}
190
191\helpref{SetHeaderColours}{wxcalendarctrlsetheadercolours}
192
193\membersection{wxCalendarCtrl::SetHighlightColours}\label{wxcalendarctrlsethighlightcolours}
194
195\func{void}{SetHighlightColours}{\param{const wxColour\& }{colFg}, \param{const wxColour\& }{colBg}}
196
197Set the colours to be used for highlighting the currently selected date.
198
199\membersection{wxCalendarCtrl::GetHighlightColourFg}\label{wxcalendarctrlgethighlightcolourfg}
200
201\constfunc{const wxColour\&}{GetHighlightColourFg}{\void}
202
203Gets the foreground highlight colour.
204
205\wxheading{See also}
206
207\helpref{SetHighlightColours}{wxcalendarctrlsethighlightcolours}
208
209\membersection{wxCalendarCtrl::GetHighlightColourBg}\label{wxcalendarctrlgethighlightcolourbg}
210
211\constfunc{const wxColour\&}{GetHighlightColourBg}{\void}
212
213Gets the background highlight colour.
214
215\wxheading{See also}
216
217\helpref{SetHighlightColours}{wxcalendarctrlsethighlightcolours}
218
219\membersection{wxCalendarCtrl::SetHolidayColours}\label{wxcalendarctrlsetholidaycolours}
220
221\func{void}{SetHolidayColours}{\param{const wxColour\& }{colFg}, \param{const wxColour\& }{colBg}}
222
223Sets the colours to be used for the holidays highlighting (only used if the
224window style includes {\tt wxCAL\_SHOW\_HOLIDAYS} flag).
225
226\membersection{wxCalendarCtrl::GetHolidayColourFg}\label{wxcalendarctrlgetholidaycolourfg}
227
228\constfunc{const wxColour\&}{GetHolidayColourFg}{\void}
229
230Return the foregound colour currently used for holiday highlighting.
231
232\wxheading{See also}
233
234\helpref{SetHolidayColours}{wxcalendarctrlsetholidaycolours}
235
236\membersection{wxCalendarCtrl::GetHolidayColourBg}\label{wxcalendarctrlgetholidaycolourbg}
237
238\constfunc{const wxColour\&}{GetHolidayColourBg}{\void}
239
240Return the background colour currently used for holiday highlighting.
241
242\wxheading{See also}
243
244\helpref{SetHolidayColours}{wxcalendarctrlsetholidaycolours}
245
246\membersection{wxCalendarCtrl::GetAttr}\label{wxcalendarctrlgetattr}
247
248\constfunc{wxCalendarDateAttr *}{GetAttr}{\param{size\_t }{day}}
249
250Returns the attribute for the given date (should be in the range $1\ldots31$).
251
252The returned pointer may be {\tt NULL}.
253
254\membersection{wxCalendarCtrl::SetAttr}\label{wxcalendarctrlsetattr}
255
256\func{void}{SetAttr}{\param{size\_t }{day}, \param{wxCalendarDateAttr* }{attr}}
257
258Associates the attribute with the specified date (in the range $1\ldots31$).
259
260If the pointer is {\tt NULL}, the items attribute is cleared.
261
262\membersection{wxCalendarCtrl::SetHoliday}\label{wxcalendarctrlsetholiday}
263
264\func{void}{SetHoliday}{\param{size\_t }{day}}
265
266Marks the specified day as being a holiday in the current month.
267
268\membersection{wxCalendarCtrl::ResetAttr}\label{wxcalendarctrlresetattr}
269
270\func{void}{ResetAttr}{\param{size\_t }{day}}
271
272Clears any attributes associated with the given day (in the range
273$1\ldots31$).
274
275\membersection{wxCalendarCtrl::HitTest}\label{wxcalendarctrlhittest}
276
277\func{wxCalendarHitTestResult}{HitTest}{\param{const wxPoint\& }{pos}, \param{wxDateTime* }{date = NULL}, \param{wxDateTime::WeekDay* }{wd = NULL}}
278
279Returns one of {\tt wxCAL\_HITTEST\_XXX}
280\helpref{constants}{wxcalendarctrl} and fills either {\it date} or
281{\it wd} pointer with the corresponding value depending on the hit test code.
282
283\section{\class{wxCalendarDateAttr}}\label{wxcalendardateattr}
284
285wxCalendarDateAttr is a custom attributes for a calendar date. The objects of
286this class are used with \helpref{wxCalendarCtrl}{wxcalendarctrl}.
287
288\wxheading{Derived from}
289
290No base class
291
292\wxheading{Constants}
293
294Here are the possible kinds of borders which may be used to decorate a date:
295
a3dafe87 296\begin{verbatim}
f6bcfd97
BP
297enum wxCalendarDateBorder
298{
299 wxCAL\_BORDER\_NONE, // no border (default)
300 wxCAL\_BORDER\_SQUARE, // a rectangular border
301 wxCAL\_BORDER\_ROUND // a round border
302}
a3dafe87 303\end{verbatim}
f6bcfd97
BP
304
305\wxheading{See also}
306
307\helpref{wxCalendarCtrl}{wxcalendarctrl}
308
309\latexignore{\rtfignore{\wxheading{Members}}}
310
311\membersection{wxCalendarDateAttr::wxCalendarDateAttr}\label{wxcalendardateattrwxcalendardateattr}
312
313\func{}{wxCalendarDateAttr}{\void}
314
315\func{}{wxCalendarDateAttr}{\param{const wxColour\& }{colText}, \param{const wxColour\& }{colBack = wxNullColour}, \param{const wxColour\& }{colBorder = wxNullColour}, \param{const wxFont\& }{font = wxNullFont}, \param{wxCalendarDateBorder }{border = wxCAL\_BORDER\_NONE}}
316
317\func{}{wxCalendarDateAttr}{\param{wxCalendarDateBorder }{border}, \param{const wxColour\& }{colBorder = wxNullColour}}
318
319The constructors.
320
321\membersection{wxCalendarDateAttr::SetTextColour}\label{wxcalendardateattrsettextcolour}
322
323\func{void}{SetTextColour}{\param{const wxColour\& }{colText}}
324
325Sets the text (foreground) colour to use.
326
327\membersection{wxCalendarDateAttr::SetBackgroundColour}\label{wxcalendardateattrsetbackgroundcolour}
328
329\func{void}{SetBackgroundColour}{\param{const wxColour\& }{colBack}}
330
331Sets the text background colour to use.
332
333\membersection{wxCalendarDateAttr::SetBorderColour}\label{wxcalendardateattrsetbordercolour}
334
335\func{void}{SetBorderColour}{\param{const wxColour\& }{col}}
336
337Sets the border colour to use.
338
339\membersection{wxCalendarDateAttr::SetFont}\label{wxcalendardateattrsetfont}
340
341\func{void}{SetFont}{\param{const wxFont\& }{font}}
342
343Sets the font to use.
344
345\membersection{wxCalendarDateAttr::SetBorder}\label{wxcalendardateattrsetborder}
346
347\func{void}{SetBorder}{\param{wxCalendarDateBorder }{border}}
348
349Sets the \helpref{border kind}{wxcalendardateattr}
350
351\membersection{wxCalendarDateAttr::SetHoliday}\label{wxcalendardateattrsetholiday}
352
353\func{void}{SetHoliday}{\param{bool }{holiday}}
354
355Display the date with this attribute as a holiday.
356
357\membersection{wxCalendarDateAttr::HasTextColour}\label{wxcalendardateattrhastextcolour}
358
359\constfunc{bool}{HasTextColour}{\void}
360
361Returns {\tt TRUE} if this item has a non default text foreground colour.
362
363\membersection{wxCalendarDateAttr::HasBackgroundColour}\label{wxcalendardateattrhasbackgroundcolour}
364
365\constfunc{bool}{HasBackgroundColour}{\void}
366
367Returns {\tt TRUE} if this attribute specifies a non default text background colour.
368
369\membersection{wxCalendarDateAttr::HasBorderColour}\label{wxcalendardateattrhasbordercolour}
370
371\constfunc{bool}{HasBorderColour}{\void}
372
373Returns {\tt TRUE} if this attribute specifies a non default border colour.
374
375\membersection{wxCalendarDateAttr::HasFont}\label{wxcalendardateattrhasfont}
376
377\constfunc{bool}{HasFont}{\void}
378
379Returns {\tt TRUE} if this attribute specifies a non default font.
380
381\membersection{wxCalendarDateAttr::HasBorder}\label{wxcalendardateattrhasborder}
382
383\constfunc{bool}{HasBorder}{\void}
384
385Returns {\tt TRUE} if this attribute specifies a non default (i.e. any) border.
386
387\membersection{wxCalendarDateAttr::IsHoliday}\label{wxcalendardateattrisholiday}
388
389\constfunc{bool}{IsHoliday}{\void}
390
391Returns {\tt TRUE} if this attribute specifies that this item should be
392displayed as a holiday.
393
394\membersection{wxCalendarDateAttr::GetTextColour}\label{wxcalendardateattrgettextcolour}
395
396\constfunc{const wxColour\&}{GetTextColour}{\void}
397
398Returns the text colour to use for the item with this attribute.
399
400\membersection{wxCalendarDateAttr::GetBackgroundColour}\label{wxcalendardateattrgetbackgroundcolour}
401
402\constfunc{const wxColour\&}{GetBackgroundColour}{\void}
403
404Returns the background colour to use for the item with this attribute.
405
406\membersection{wxCalendarDateAttr::GetBorderColour}\label{wxcalendardateattrgetbordercolour}
407
408\constfunc{const wxColour\&}{GetBorderColour}{\void}
409
410Returns the border colour to use for the item with this attribute.
411
412\membersection{wxCalendarDateAttr::GetFont}\label{wxcalendardateattrgetfont}
413
414\constfunc{const wxFont\&}{GetFont}{\void}
415
416Returns the font to use for the item with this attribute.
417
418\membersection{wxCalendarDateAttr::GetBorder}\label{wxcalendardateattrgetborder}
419
420\constfunc{wxCalendarDateBorder}{GetBorder}{\void}
421
422Returns the \helpref{border}{wxcalendardateattr} to use for the item with this attribute.
423
424\section{\class{wxCalendarEvent}}\label{wxcalendarevent}
425
426The wxCalendarEvent class is used together with
427\helpref{wxCalendarCtrl}{wxcalendarctrl}.
428
429\wxheading{See also}
430
431\helpref{wxCalendarCtrl}{wxcalendarctrl}
432
433\latexignore{\rtfignore{\wxheading{Members}}}
434
435\membersection{wxCalendarEvent::GetDate}{wxcalendareventgetdate}
436
437\constfunc{const wxDateTime&}{GetDate}{\void}
438
439Returns the date. This function may be called for all event types except
440{\tt EVT\_CALENDAR\_WEEKDAY\_CLICKED} one for which it doesn't make sense.
441
442\membersection{wxCalendarEvent::GetWeekDay}{wxcalendareventgetweekday}
443
444\constfunc{wxDateTime::WeekDay}{GetWeekDay}{\void}
4f6aed9c 445
f6bcfd97
BP
446Returns the week day on which the user clicked in
447{\tt EVT\_CALENDAR\_WEEKDAY\_CLICKED} handler. It doesn't make sense to call
448this function in other handlers.
457e6c54 449