]> git.saurik.com Git - wxWidgets.git/blame - include/wx/calctrl.h
Added simplistic makefile/project files for wxWinCE.
[wxWidgets.git] / include / wx / calctrl.h
CommitLineData
9d9b7755
VZ
1///////////////////////////////////////////////////////////////////////////////
2// Name: wx/calctrl.h
3// Purpose: date-picker control
4// Author: Vadim Zeitlin
5// Modified by:
6// Created: 29.12.99
7// RCS-ID: $Id$
8// Copyright: (c) 1999 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
9// Licence: wxWindows license
10///////////////////////////////////////////////////////////////////////////////
11
4f6aed9c
VZ
12/*
13 TODO
14
15 1. implement multiple selections for date ranges
16 2. background bitmap for the calendar?
17 */
18
1e6feb95
VZ
19#ifndef _WX_CALCTRL_H_
20#define _WX_CALCTRL_H_
21
22#include "wx/defs.h"
23
24#if wxUSE_CALENDARCTRL
9d9b7755 25
4f6aed9c
VZ
26#include "wx/datetime.h"
27
37df1f33
VZ
28// ----------------------------------------------------------------------------
29// wxCalendarCtrl flags
30// ----------------------------------------------------------------------------
31
32enum
33{
34 // show Sunday as the first day of the week (default)
35 wxCAL_SUNDAY_FIRST = 0x0000,
36
37 // show Monder as the first day of the week
38 wxCAL_MONDAY_FIRST = 0x0001,
39
40 // highlight holidays
41 wxCAL_SHOW_HOLIDAYS = 0x0002,
42
43 // disable the year change control, show only the month change one
44 wxCAL_NO_YEAR_CHANGE = 0x0004,
45
46 // don't allow changing neither month nor year (implies
47 // wxCAL_NO_YEAR_CHANGE)
48 wxCAL_NO_MONTH_CHANGE = 0x000c,
49
50 // use MS-style month-selection instead of combo-spin combination
51 wxCAL_SEQUENTIAL_MONTH_SELECTION = 0x0010,
52
53 // show the neighbouring weeks in the previous and next month
54 wxCAL_SHOW_SURROUNDING_WEEKS = 0x0020
55};
56
0185cd09
VZ
57// ----------------------------------------------------------------------------
58// constants
59// ----------------------------------------------------------------------------
60
61// return values for the HitTest() method
62enum wxCalendarHitTestResult
63{
64 wxCAL_HITTEST_NOWHERE, // outside of anything
65 wxCAL_HITTEST_HEADER, // on the header (weekdays)
37df1f33
VZ
66 wxCAL_HITTEST_DAY, // on a day in the calendar
67 wxCAL_HITTEST_INCMONTH,
68 wxCAL_HITTEST_DECMONTH,
69 wxCAL_HITTEST_SURROUNDING_WEEK
0185cd09
VZ
70};
71
4f6aed9c
VZ
72// border types for a date
73enum wxCalendarDateBorder
74{
75 wxCAL_BORDER_NONE, // no border (default)
76 wxCAL_BORDER_SQUARE, // a rectangular border
77 wxCAL_BORDER_ROUND // a round border
78};
79
0185cd09 80// ----------------------------------------------------------------------------
4f6aed9c 81// wxCalendarDateAttr: custom attributes for a calendar date
0185cd09
VZ
82// ----------------------------------------------------------------------------
83
4f6aed9c
VZ
84class WXDLLEXPORT wxCalendarDateAttr
85{
006713a2 86#if !defined(__VISAGECPP__)
8caa4ed1
JS
87protected:
88 // This has to be before the use of Init(), for MSVC++ 1.5
006713a2 89 // But dorks up Visualage!
8caa4ed1
JS
90 void Init(wxCalendarDateBorder border = wxCAL_BORDER_NONE)
91 {
92 m_border = border;
93 m_holiday = FALSE;
94 }
006713a2 95#endif
4f6aed9c
VZ
96public:
97 // ctors
98 wxCalendarDateAttr() { Init(); }
99 wxCalendarDateAttr(const wxColour& colText,
100 const wxColour& colBack = wxNullColour,
101 const wxColour& colBorder = wxNullColour,
102 const wxFont& font = wxNullFont,
103 wxCalendarDateBorder border = wxCAL_BORDER_NONE)
104 : m_colText(colText), m_colBack(colBack),
105 m_colBorder(colBorder), m_font(font)
106 {
107 Init(border);
108 }
109 wxCalendarDateAttr(wxCalendarDateBorder border,
110 const wxColour& colBorder = wxNullColour)
111 : m_colBorder(colBorder)
112 {
113 Init(border);
114 }
115
116 // setters
117 void SetTextColour(const wxColour& colText) { m_colText = colText; }
118 void SetBackgroundColour(const wxColour& colBack) { m_colBack = colBack; }
119 void SetBorderColour(const wxColour& col) { m_colBorder = col; }
120 void SetFont(const wxFont& font) { m_font = font; }
121 void SetBorder(wxCalendarDateBorder border) { m_border = border; }
122 void SetHoliday(bool holiday) { m_holiday = holiday; }
123
124 // accessors
125 bool HasTextColour() const { return m_colText.Ok(); }
126 bool HasBackgroundColour() const { return m_colBack.Ok(); }
127 bool HasBorderColour() const { return m_colBorder.Ok(); }
128 bool HasFont() const { return m_font.Ok(); }
129 bool HasBorder() const { return m_border != wxCAL_BORDER_NONE; }
130
131 bool IsHoliday() const { return m_holiday; }
132
133 const wxColour& GetTextColour() const { return m_colText; }
134 const wxColour& GetBackgroundColour() const { return m_colBack; }
135 const wxColour& GetBorderColour() const { return m_colBorder; }
136 const wxFont& GetFont() const { return m_font; }
137 wxCalendarDateBorder GetBorder() const { return m_border; }
006713a2
DW
138#if defined(__VISAGECPP__)
139protected:
140 // This has to be here for VisualAge
141 void Init(wxCalendarDateBorder border = wxCAL_BORDER_NONE)
142 {
143 m_border = border;
144 m_holiday = FALSE;
145 }
146#endif
4f6aed9c
VZ
147private:
148 wxColour m_colText,
149 m_colBack,
150 m_colBorder;
151 wxFont m_font;
152 wxCalendarDateBorder m_border;
153 bool m_holiday;
154};
9d9b7755
VZ
155
156// ----------------------------------------------------------------------------
157// wxCalendarCtrl events
158// ----------------------------------------------------------------------------
159
4f6aed9c
VZ
160class WXDLLEXPORT wxCalendarCtrl;
161
9d9b7755
VZ
162class WXDLLEXPORT wxCalendarEvent : public wxCommandEvent
163{
0185cd09 164friend class wxCalendarCtrl;
9d9b7755 165public:
0185cd09 166 wxCalendarEvent() { Init(); }
9d9b7755
VZ
167 wxCalendarEvent(wxCalendarCtrl *cal, wxEventType type);
168
169 const wxDateTime& GetDate() const { return m_date; }
0185cd09
VZ
170 wxDateTime::WeekDay GetWeekDay() const { return m_wday; }
171
172protected:
173 void Init();
9d9b7755
VZ
174
175private:
176 wxDateTime m_date;
0185cd09 177 wxDateTime::WeekDay m_wday;
f6bcfd97
BP
178
179 DECLARE_DYNAMIC_CLASS(wxCalendarEvent)
9d9b7755
VZ
180};
181
4f6aed9c
VZ
182// ----------------------------------------------------------------------------
183// wxCalendarCtrl
184// ----------------------------------------------------------------------------
185
186// so far we only have a generic version, so keep it simple
187#include "wx/generic/calctrl.h"
188
189// ----------------------------------------------------------------------------
2e4df4bf 190// calendar event types and macros for handling them
4f6aed9c
VZ
191// ----------------------------------------------------------------------------
192
2e4df4bf
VZ
193BEGIN_DECLARE_EVENT_TYPES()
194 DECLARE_EVENT_TYPE(wxEVT_CALENDAR_SEL_CHANGED, 950)
195 DECLARE_EVENT_TYPE(wxEVT_CALENDAR_DAY_CHANGED, 951)
196 DECLARE_EVENT_TYPE(wxEVT_CALENDAR_MONTH_CHANGED, 952)
197 DECLARE_EVENT_TYPE(wxEVT_CALENDAR_YEAR_CHANGED, 953)
198 DECLARE_EVENT_TYPE(wxEVT_CALENDAR_DOUBLECLICKED, 954)
199 DECLARE_EVENT_TYPE(wxEVT_CALENDAR_WEEKDAY_CLICKED, 955)
200END_DECLARE_EVENT_TYPES()
201
457e6c54
JS
202typedef void (wxEvtHandler::*wxCalendarEventFunction)(wxCalendarEvent&);
203
2e4df4bf
VZ
204#define EVT_CALENDAR(id, fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_CALENDAR_DOUBLECLICKED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) (wxCalendarEventFunction) & fn, (wxObject *) NULL),
205#define EVT_CALENDAR_SEL_CHANGED(id, fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_CALENDAR_SEL_CHANGED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) (wxCalendarEventFunction) & fn, (wxObject *) NULL),
206#define EVT_CALENDAR_DAY(id, fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_CALENDAR_DAY_CHANGED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) (wxCalendarEventFunction) & fn, (wxObject *) NULL),
207#define EVT_CALENDAR_MONTH(id, fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_CALENDAR_MONTH_CHANGED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) (wxCalendarEventFunction) & fn, (wxObject *) NULL),
208#define EVT_CALENDAR_YEAR(id, fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_CALENDAR_YEAR_CHANGED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) (wxCalendarEventFunction) & fn, (wxObject *) NULL),
209#define EVT_CALENDAR_WEEKDAY_CLICKED(id, fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_CALENDAR_WEEKDAY_CLICKED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) (wxCalendarEventFunction) & fn, (wxObject *) NULL),
9d9b7755 210
1e6feb95
VZ
211#endif // wxUSE_CALENDARCTRL
212
213#endif // _WX_CALCTRL_H_
214