]>
Commit | Line | Data |
---|---|---|
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 | ||
9d9b7755 VZ |
19 | #ifndef _WX_CALCTRL_H |
20 | #define _WX_CALCTRL_H | |
21 | ||
4f6aed9c VZ |
22 | #include "wx/datetime.h" |
23 | ||
0185cd09 VZ |
24 | // ---------------------------------------------------------------------------- |
25 | // constants | |
26 | // ---------------------------------------------------------------------------- | |
27 | ||
28 | // return values for the HitTest() method | |
29 | enum wxCalendarHitTestResult | |
30 | { | |
31 | wxCAL_HITTEST_NOWHERE, // outside of anything | |
32 | wxCAL_HITTEST_HEADER, // on the header (weekdays) | |
33 | wxCAL_HITTEST_DAY // on a day in the calendar | |
34 | }; | |
35 | ||
4f6aed9c VZ |
36 | // border types for a date |
37 | enum wxCalendarDateBorder | |
38 | { | |
39 | wxCAL_BORDER_NONE, // no border (default) | |
40 | wxCAL_BORDER_SQUARE, // a rectangular border | |
41 | wxCAL_BORDER_ROUND // a round border | |
42 | }; | |
43 | ||
0185cd09 | 44 | // ---------------------------------------------------------------------------- |
4f6aed9c | 45 | // wxCalendarDateAttr: custom attributes for a calendar date |
0185cd09 VZ |
46 | // ---------------------------------------------------------------------------- |
47 | ||
4f6aed9c VZ |
48 | class WXDLLEXPORT wxCalendarDateAttr |
49 | { | |
8caa4ed1 JS |
50 | protected: |
51 | // This has to be before the use of Init(), for MSVC++ 1.5 | |
52 | void Init(wxCalendarDateBorder border = wxCAL_BORDER_NONE) | |
53 | { | |
54 | m_border = border; | |
55 | m_holiday = FALSE; | |
56 | } | |
57 | ||
4f6aed9c VZ |
58 | public: |
59 | // ctors | |
60 | wxCalendarDateAttr() { Init(); } | |
61 | wxCalendarDateAttr(const wxColour& colText, | |
62 | const wxColour& colBack = wxNullColour, | |
63 | const wxColour& colBorder = wxNullColour, | |
64 | const wxFont& font = wxNullFont, | |
65 | wxCalendarDateBorder border = wxCAL_BORDER_NONE) | |
66 | : m_colText(colText), m_colBack(colBack), | |
67 | m_colBorder(colBorder), m_font(font) | |
68 | { | |
69 | Init(border); | |
70 | } | |
71 | wxCalendarDateAttr(wxCalendarDateBorder border, | |
72 | const wxColour& colBorder = wxNullColour) | |
73 | : m_colBorder(colBorder) | |
74 | { | |
75 | Init(border); | |
76 | } | |
77 | ||
78 | // setters | |
79 | void SetTextColour(const wxColour& colText) { m_colText = colText; } | |
80 | void SetBackgroundColour(const wxColour& colBack) { m_colBack = colBack; } | |
81 | void SetBorderColour(const wxColour& col) { m_colBorder = col; } | |
82 | void SetFont(const wxFont& font) { m_font = font; } | |
83 | void SetBorder(wxCalendarDateBorder border) { m_border = border; } | |
84 | void SetHoliday(bool holiday) { m_holiday = holiday; } | |
85 | ||
86 | // accessors | |
87 | bool HasTextColour() const { return m_colText.Ok(); } | |
88 | bool HasBackgroundColour() const { return m_colBack.Ok(); } | |
89 | bool HasBorderColour() const { return m_colBorder.Ok(); } | |
90 | bool HasFont() const { return m_font.Ok(); } | |
91 | bool HasBorder() const { return m_border != wxCAL_BORDER_NONE; } | |
92 | ||
93 | bool IsHoliday() const { return m_holiday; } | |
94 | ||
95 | const wxColour& GetTextColour() const { return m_colText; } | |
96 | const wxColour& GetBackgroundColour() const { return m_colBack; } | |
97 | const wxColour& GetBorderColour() const { return m_colBorder; } | |
98 | const wxFont& GetFont() const { return m_font; } | |
99 | wxCalendarDateBorder GetBorder() const { return m_border; } | |
100 | ||
4f6aed9c VZ |
101 | private: |
102 | wxColour m_colText, | |
103 | m_colBack, | |
104 | m_colBorder; | |
105 | wxFont m_font; | |
106 | wxCalendarDateBorder m_border; | |
107 | bool m_holiday; | |
108 | }; | |
9d9b7755 VZ |
109 | |
110 | // ---------------------------------------------------------------------------- | |
111 | // wxCalendarCtrl events | |
112 | // ---------------------------------------------------------------------------- | |
113 | ||
4f6aed9c VZ |
114 | class WXDLLEXPORT wxCalendarCtrl; |
115 | ||
9d9b7755 VZ |
116 | class WXDLLEXPORT wxCalendarEvent : public wxCommandEvent |
117 | { | |
0185cd09 | 118 | friend class wxCalendarCtrl; |
9d9b7755 | 119 | public: |
0185cd09 | 120 | wxCalendarEvent() { Init(); } |
9d9b7755 VZ |
121 | wxCalendarEvent(wxCalendarCtrl *cal, wxEventType type); |
122 | ||
123 | const wxDateTime& GetDate() const { return m_date; } | |
0185cd09 VZ |
124 | wxDateTime::WeekDay GetWeekDay() const { return m_wday; } |
125 | ||
126 | protected: | |
127 | void Init(); | |
9d9b7755 VZ |
128 | |
129 | private: | |
130 | wxDateTime m_date; | |
0185cd09 | 131 | wxDateTime::WeekDay m_wday; |
9d9b7755 VZ |
132 | }; |
133 | ||
4f6aed9c VZ |
134 | // ---------------------------------------------------------------------------- |
135 | // wxCalendarCtrl | |
136 | // ---------------------------------------------------------------------------- | |
137 | ||
138 | // so far we only have a generic version, so keep it simple | |
139 | #include "wx/generic/calctrl.h" | |
140 | ||
141 | // ---------------------------------------------------------------------------- | |
142 | // calendar events macros | |
143 | // ---------------------------------------------------------------------------- | |
144 | ||
0185cd09 VZ |
145 | #define EVT_CALENDAR(id, fn) { wxEVT_CALENDAR_DOUBLECLICKED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL }, |
146 | #define EVT_CALENDAR_SEL_CHANGED(id, fn) { wxEVT_CALENDAR_SEL_CHANGED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL }, | |
9d9b7755 VZ |
147 | #define EVT_CALENDAR_DAY(id, fn) { wxEVT_CALENDAR_DAY_CHANGED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL }, |
148 | #define EVT_CALENDAR_MONTH(id, fn) { wxEVT_CALENDAR_MONTH_CHANGED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL }, | |
149 | #define EVT_CALENDAR_YEAR(id, fn) { wxEVT_CALENDAR_YEAR_CHANGED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL }, | |
0185cd09 | 150 | #define EVT_CALENDAR_WEEKDAY_CLICKED(id, fn) { wxEVT_CALENDAR_WEEKDAY_CLICKED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL }, |
9d9b7755 VZ |
151 | |
152 | #endif // _WX_CALCTRL_H |