]> git.saurik.com Git - wxWidgets.git/blame - include/wx/calctrl.h
test for wxLog interaction with wxYield better
[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
0185cd09
VZ
28// ----------------------------------------------------------------------------
29// constants
30// ----------------------------------------------------------------------------
31
32// return values for the HitTest() method
33enum wxCalendarHitTestResult
34{
35 wxCAL_HITTEST_NOWHERE, // outside of anything
36 wxCAL_HITTEST_HEADER, // on the header (weekdays)
37 wxCAL_HITTEST_DAY // on a day in the calendar
38};
39
4f6aed9c
VZ
40// border types for a date
41enum wxCalendarDateBorder
42{
43 wxCAL_BORDER_NONE, // no border (default)
44 wxCAL_BORDER_SQUARE, // a rectangular border
45 wxCAL_BORDER_ROUND // a round border
46};
47
0185cd09 48// ----------------------------------------------------------------------------
4f6aed9c 49// wxCalendarDateAttr: custom attributes for a calendar date
0185cd09
VZ
50// ----------------------------------------------------------------------------
51
4f6aed9c
VZ
52class WXDLLEXPORT wxCalendarDateAttr
53{
006713a2 54#if !defined(__VISAGECPP__)
8caa4ed1
JS
55protected:
56 // This has to be before the use of Init(), for MSVC++ 1.5
006713a2 57 // But dorks up Visualage!
8caa4ed1
JS
58 void Init(wxCalendarDateBorder border = wxCAL_BORDER_NONE)
59 {
60 m_border = border;
61 m_holiday = FALSE;
62 }
006713a2 63#endif
4f6aed9c
VZ
64public:
65 // ctors
66 wxCalendarDateAttr() { Init(); }
67 wxCalendarDateAttr(const wxColour& colText,
68 const wxColour& colBack = wxNullColour,
69 const wxColour& colBorder = wxNullColour,
70 const wxFont& font = wxNullFont,
71 wxCalendarDateBorder border = wxCAL_BORDER_NONE)
72 : m_colText(colText), m_colBack(colBack),
73 m_colBorder(colBorder), m_font(font)
74 {
75 Init(border);
76 }
77 wxCalendarDateAttr(wxCalendarDateBorder border,
78 const wxColour& colBorder = wxNullColour)
79 : m_colBorder(colBorder)
80 {
81 Init(border);
82 }
83
84 // setters
85 void SetTextColour(const wxColour& colText) { m_colText = colText; }
86 void SetBackgroundColour(const wxColour& colBack) { m_colBack = colBack; }
87 void SetBorderColour(const wxColour& col) { m_colBorder = col; }
88 void SetFont(const wxFont& font) { m_font = font; }
89 void SetBorder(wxCalendarDateBorder border) { m_border = border; }
90 void SetHoliday(bool holiday) { m_holiday = holiday; }
91
92 // accessors
93 bool HasTextColour() const { return m_colText.Ok(); }
94 bool HasBackgroundColour() const { return m_colBack.Ok(); }
95 bool HasBorderColour() const { return m_colBorder.Ok(); }
96 bool HasFont() const { return m_font.Ok(); }
97 bool HasBorder() const { return m_border != wxCAL_BORDER_NONE; }
98
99 bool IsHoliday() const { return m_holiday; }
100
101 const wxColour& GetTextColour() const { return m_colText; }
102 const wxColour& GetBackgroundColour() const { return m_colBack; }
103 const wxColour& GetBorderColour() const { return m_colBorder; }
104 const wxFont& GetFont() const { return m_font; }
105 wxCalendarDateBorder GetBorder() const { return m_border; }
006713a2
DW
106#if defined(__VISAGECPP__)
107protected:
108 // This has to be here for VisualAge
109 void Init(wxCalendarDateBorder border = wxCAL_BORDER_NONE)
110 {
111 m_border = border;
112 m_holiday = FALSE;
113 }
114#endif
4f6aed9c
VZ
115private:
116 wxColour m_colText,
117 m_colBack,
118 m_colBorder;
119 wxFont m_font;
120 wxCalendarDateBorder m_border;
121 bool m_holiday;
122};
9d9b7755
VZ
123
124// ----------------------------------------------------------------------------
125// wxCalendarCtrl events
126// ----------------------------------------------------------------------------
127
4f6aed9c
VZ
128class WXDLLEXPORT wxCalendarCtrl;
129
9d9b7755
VZ
130class WXDLLEXPORT wxCalendarEvent : public wxCommandEvent
131{
0185cd09 132friend class wxCalendarCtrl;
9d9b7755 133public:
0185cd09 134 wxCalendarEvent() { Init(); }
9d9b7755
VZ
135 wxCalendarEvent(wxCalendarCtrl *cal, wxEventType type);
136
137 const wxDateTime& GetDate() const { return m_date; }
0185cd09
VZ
138 wxDateTime::WeekDay GetWeekDay() const { return m_wday; }
139
140protected:
141 void Init();
9d9b7755
VZ
142
143private:
144 wxDateTime m_date;
0185cd09 145 wxDateTime::WeekDay m_wday;
f6bcfd97
BP
146
147 DECLARE_DYNAMIC_CLASS(wxCalendarEvent)
9d9b7755
VZ
148};
149
4f6aed9c
VZ
150// ----------------------------------------------------------------------------
151// wxCalendarCtrl
152// ----------------------------------------------------------------------------
153
154// so far we only have a generic version, so keep it simple
155#include "wx/generic/calctrl.h"
156
157// ----------------------------------------------------------------------------
2e4df4bf 158// calendar event types and macros for handling them
4f6aed9c
VZ
159// ----------------------------------------------------------------------------
160
2e4df4bf
VZ
161BEGIN_DECLARE_EVENT_TYPES()
162 DECLARE_EVENT_TYPE(wxEVT_CALENDAR_SEL_CHANGED, 950)
163 DECLARE_EVENT_TYPE(wxEVT_CALENDAR_DAY_CHANGED, 951)
164 DECLARE_EVENT_TYPE(wxEVT_CALENDAR_MONTH_CHANGED, 952)
165 DECLARE_EVENT_TYPE(wxEVT_CALENDAR_YEAR_CHANGED, 953)
166 DECLARE_EVENT_TYPE(wxEVT_CALENDAR_DOUBLECLICKED, 954)
167 DECLARE_EVENT_TYPE(wxEVT_CALENDAR_WEEKDAY_CLICKED, 955)
168END_DECLARE_EVENT_TYPES()
169
457e6c54
JS
170typedef void (wxEvtHandler::*wxCalendarEventFunction)(wxCalendarEvent&);
171
2e4df4bf
VZ
172#define EVT_CALENDAR(id, fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_CALENDAR_DOUBLECLICKED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) (wxCalendarEventFunction) & fn, (wxObject *) NULL),
173#define EVT_CALENDAR_SEL_CHANGED(id, fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_CALENDAR_SEL_CHANGED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) (wxCalendarEventFunction) & fn, (wxObject *) NULL),
174#define EVT_CALENDAR_DAY(id, fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_CALENDAR_DAY_CHANGED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) (wxCalendarEventFunction) & fn, (wxObject *) NULL),
175#define EVT_CALENDAR_MONTH(id, fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_CALENDAR_MONTH_CHANGED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) (wxCalendarEventFunction) & fn, (wxObject *) NULL),
176#define EVT_CALENDAR_YEAR(id, fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_CALENDAR_YEAR_CHANGED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) (wxCalendarEventFunction) & fn, (wxObject *) NULL),
177#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 178
1e6feb95
VZ
179#endif // wxUSE_CALENDARCTRL
180
181#endif // _WX_CALCTRL_H_
182