]> git.saurik.com Git - wxWidgets.git/blame - include/wx/calctrl.h
1. fixed bug with MDI child frames changign state when parent frame was
[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
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
29enum 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
37enum 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
48class WXDLLEXPORT wxCalendarDateAttr
49{
006713a2 50#if !defined(__VISAGECPP__)
8caa4ed1
JS
51protected:
52 // This has to be before the use of Init(), for MSVC++ 1.5
006713a2 53 // But dorks up Visualage!
8caa4ed1
JS
54 void Init(wxCalendarDateBorder border = wxCAL_BORDER_NONE)
55 {
56 m_border = border;
57 m_holiday = FALSE;
58 }
006713a2 59#endif
4f6aed9c
VZ
60public:
61 // ctors
62 wxCalendarDateAttr() { Init(); }
63 wxCalendarDateAttr(const wxColour& colText,
64 const wxColour& colBack = wxNullColour,
65 const wxColour& colBorder = wxNullColour,
66 const wxFont& font = wxNullFont,
67 wxCalendarDateBorder border = wxCAL_BORDER_NONE)
68 : m_colText(colText), m_colBack(colBack),
69 m_colBorder(colBorder), m_font(font)
70 {
71 Init(border);
72 }
73 wxCalendarDateAttr(wxCalendarDateBorder border,
74 const wxColour& colBorder = wxNullColour)
75 : m_colBorder(colBorder)
76 {
77 Init(border);
78 }
79
80 // setters
81 void SetTextColour(const wxColour& colText) { m_colText = colText; }
82 void SetBackgroundColour(const wxColour& colBack) { m_colBack = colBack; }
83 void SetBorderColour(const wxColour& col) { m_colBorder = col; }
84 void SetFont(const wxFont& font) { m_font = font; }
85 void SetBorder(wxCalendarDateBorder border) { m_border = border; }
86 void SetHoliday(bool holiday) { m_holiday = holiday; }
87
88 // accessors
89 bool HasTextColour() const { return m_colText.Ok(); }
90 bool HasBackgroundColour() const { return m_colBack.Ok(); }
91 bool HasBorderColour() const { return m_colBorder.Ok(); }
92 bool HasFont() const { return m_font.Ok(); }
93 bool HasBorder() const { return m_border != wxCAL_BORDER_NONE; }
94
95 bool IsHoliday() const { return m_holiday; }
96
97 const wxColour& GetTextColour() const { return m_colText; }
98 const wxColour& GetBackgroundColour() const { return m_colBack; }
99 const wxColour& GetBorderColour() const { return m_colBorder; }
100 const wxFont& GetFont() const { return m_font; }
101 wxCalendarDateBorder GetBorder() const { return m_border; }
006713a2
DW
102#if defined(__VISAGECPP__)
103protected:
104 // This has to be here for VisualAge
105 void Init(wxCalendarDateBorder border = wxCAL_BORDER_NONE)
106 {
107 m_border = border;
108 m_holiday = FALSE;
109 }
110#endif
4f6aed9c
VZ
111private:
112 wxColour m_colText,
113 m_colBack,
114 m_colBorder;
115 wxFont m_font;
116 wxCalendarDateBorder m_border;
117 bool m_holiday;
118};
9d9b7755
VZ
119
120// ----------------------------------------------------------------------------
121// wxCalendarCtrl events
122// ----------------------------------------------------------------------------
123
4f6aed9c
VZ
124class WXDLLEXPORT wxCalendarCtrl;
125
9d9b7755
VZ
126class WXDLLEXPORT wxCalendarEvent : public wxCommandEvent
127{
0185cd09 128friend class wxCalendarCtrl;
9d9b7755 129public:
0185cd09 130 wxCalendarEvent() { Init(); }
9d9b7755
VZ
131 wxCalendarEvent(wxCalendarCtrl *cal, wxEventType type);
132
133 const wxDateTime& GetDate() const { return m_date; }
0185cd09
VZ
134 wxDateTime::WeekDay GetWeekDay() const { return m_wday; }
135
136protected:
137 void Init();
9d9b7755
VZ
138
139private:
140 wxDateTime m_date;
0185cd09 141 wxDateTime::WeekDay m_wday;
9d9b7755
VZ
142};
143
4f6aed9c
VZ
144// ----------------------------------------------------------------------------
145// wxCalendarCtrl
146// ----------------------------------------------------------------------------
147
148// so far we only have a generic version, so keep it simple
149#include "wx/generic/calctrl.h"
150
151// ----------------------------------------------------------------------------
152// calendar events macros
153// ----------------------------------------------------------------------------
154
457e6c54
JS
155typedef void (wxEvtHandler::*wxCalendarEventFunction)(wxCalendarEvent&);
156
157#define EVT_CALENDAR(id, fn) { wxEVT_CALENDAR_DOUBLECLICKED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) (wxCalendarEventFunction) & fn, (wxObject *) NULL },
158#define EVT_CALENDAR_SEL_CHANGED(id, fn) { wxEVT_CALENDAR_SEL_CHANGED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) (wxCalendarEventFunction) & fn, (wxObject *) NULL },
159#define EVT_CALENDAR_DAY(id, fn) { wxEVT_CALENDAR_DAY_CHANGED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) (wxCalendarEventFunction) & fn, (wxObject *) NULL },
160#define EVT_CALENDAR_MONTH(id, fn) { wxEVT_CALENDAR_MONTH_CHANGED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) (wxCalendarEventFunction) & fn, (wxObject *) NULL },
161#define EVT_CALENDAR_YEAR(id, fn) { wxEVT_CALENDAR_YEAR_CHANGED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) (wxCalendarEventFunction) & fn, (wxObject *) NULL },
162#define EVT_CALENDAR_WEEKDAY_CLICKED(id, fn) { wxEVT_CALENDAR_WEEKDAY_CLICKED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) (wxCalendarEventFunction) & fn, (wxObject *) NULL },
9d9b7755
VZ
163
164#endif // _WX_CALCTRL_H