]>
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 | { | |
50 | public: | |
51 | // ctors | |
52 | wxCalendarDateAttr() { Init(); } | |
53 | wxCalendarDateAttr(const wxColour& colText, | |
54 | const wxColour& colBack = wxNullColour, | |
55 | const wxColour& colBorder = wxNullColour, | |
56 | const wxFont& font = wxNullFont, | |
57 | wxCalendarDateBorder border = wxCAL_BORDER_NONE) | |
58 | : m_colText(colText), m_colBack(colBack), | |
59 | m_colBorder(colBorder), m_font(font) | |
60 | { | |
61 | Init(border); | |
62 | } | |
63 | wxCalendarDateAttr(wxCalendarDateBorder border, | |
64 | const wxColour& colBorder = wxNullColour) | |
65 | : m_colBorder(colBorder) | |
66 | { | |
67 | Init(border); | |
68 | } | |
69 | ||
70 | // setters | |
71 | void SetTextColour(const wxColour& colText) { m_colText = colText; } | |
72 | void SetBackgroundColour(const wxColour& colBack) { m_colBack = colBack; } | |
73 | void SetBorderColour(const wxColour& col) { m_colBorder = col; } | |
74 | void SetFont(const wxFont& font) { m_font = font; } | |
75 | void SetBorder(wxCalendarDateBorder border) { m_border = border; } | |
76 | void SetHoliday(bool holiday) { m_holiday = holiday; } | |
77 | ||
78 | // accessors | |
79 | bool HasTextColour() const { return m_colText.Ok(); } | |
80 | bool HasBackgroundColour() const { return m_colBack.Ok(); } | |
81 | bool HasBorderColour() const { return m_colBorder.Ok(); } | |
82 | bool HasFont() const { return m_font.Ok(); } | |
83 | bool HasBorder() const { return m_border != wxCAL_BORDER_NONE; } | |
84 | ||
85 | bool IsHoliday() const { return m_holiday; } | |
86 | ||
87 | const wxColour& GetTextColour() const { return m_colText; } | |
88 | const wxColour& GetBackgroundColour() const { return m_colBack; } | |
89 | const wxColour& GetBorderColour() const { return m_colBorder; } | |
90 | const wxFont& GetFont() const { return m_font; } | |
91 | wxCalendarDateBorder GetBorder() const { return m_border; } | |
92 | ||
93 | protected: | |
94 | void Init(wxCalendarDateBorder border = wxCAL_BORDER_NONE) | |
95 | { | |
96 | m_border = border; | |
97 | m_holiday = FALSE; | |
98 | } | |
99 | ||
100 | private: | |
101 | wxColour m_colText, | |
102 | m_colBack, | |
103 | m_colBorder; | |
104 | wxFont m_font; | |
105 | wxCalendarDateBorder m_border; | |
106 | bool m_holiday; | |
107 | }; | |
9d9b7755 VZ |
108 | |
109 | // ---------------------------------------------------------------------------- | |
110 | // wxCalendarCtrl events | |
111 | // ---------------------------------------------------------------------------- | |
112 | ||
4f6aed9c VZ |
113 | class WXDLLEXPORT wxCalendarCtrl; |
114 | ||
9d9b7755 VZ |
115 | class WXDLLEXPORT wxCalendarEvent : public wxCommandEvent |
116 | { | |
0185cd09 | 117 | friend class wxCalendarCtrl; |
9d9b7755 | 118 | public: |
0185cd09 | 119 | wxCalendarEvent() { Init(); } |
9d9b7755 VZ |
120 | wxCalendarEvent(wxCalendarCtrl *cal, wxEventType type); |
121 | ||
122 | const wxDateTime& GetDate() const { return m_date; } | |
0185cd09 VZ |
123 | wxDateTime::WeekDay GetWeekDay() const { return m_wday; } |
124 | ||
125 | protected: | |
126 | void Init(); | |
9d9b7755 VZ |
127 | |
128 | private: | |
129 | wxDateTime m_date; | |
0185cd09 | 130 | wxDateTime::WeekDay m_wday; |
9d9b7755 VZ |
131 | }; |
132 | ||
4f6aed9c VZ |
133 | // ---------------------------------------------------------------------------- |
134 | // wxCalendarCtrl | |
135 | // ---------------------------------------------------------------------------- | |
136 | ||
137 | // so far we only have a generic version, so keep it simple | |
138 | #include "wx/generic/calctrl.h" | |
139 | ||
140 | // ---------------------------------------------------------------------------- | |
141 | // calendar events macros | |
142 | // ---------------------------------------------------------------------------- | |
143 | ||
0185cd09 VZ |
144 | #define EVT_CALENDAR(id, fn) { wxEVT_CALENDAR_DOUBLECLICKED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL }, |
145 | #define EVT_CALENDAR_SEL_CHANGED(id, fn) { wxEVT_CALENDAR_SEL_CHANGED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL }, | |
9d9b7755 VZ |
146 | #define EVT_CALENDAR_DAY(id, fn) { wxEVT_CALENDAR_DAY_CHANGED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL }, |
147 | #define EVT_CALENDAR_MONTH(id, fn) { wxEVT_CALENDAR_MONTH_CHANGED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL }, | |
148 | #define EVT_CALENDAR_YEAR(id, fn) { wxEVT_CALENDAR_YEAR_CHANGED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL }, | |
0185cd09 | 149 | #define EVT_CALENDAR_WEEKDAY_CLICKED(id, fn) { wxEVT_CALENDAR_WEEKDAY_CLICKED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL }, |
9d9b7755 VZ |
150 | |
151 | #endif // _WX_CALCTRL_H |