]> git.saurik.com Git - wxWidgets.git/blame_incremental - include/wx/calctrl.h
1. more warnings fixes in gtk/region.cpp and common/tbarsmpl.cpp
[wxWidgets.git] / include / wx / calctrl.h
... / ...
CommitLineData
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
12/*
13 TODO
14
15 1. implement multiple selections for date ranges
16 2. background bitmap for the calendar?
17 */
18
19#ifndef _WX_CALCTRL_H
20#define _WX_CALCTRL_H
21
22#include "wx/datetime.h"
23
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
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
44// ----------------------------------------------------------------------------
45// wxCalendarDateAttr: custom attributes for a calendar date
46// ----------------------------------------------------------------------------
47
48class WXDLLEXPORT wxCalendarDateAttr
49{
50public:
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
93protected:
94 void Init(wxCalendarDateBorder border = wxCAL_BORDER_NONE)
95 {
96 m_border = border;
97 m_holiday = FALSE;
98 }
99
100private:
101 wxColour m_colText,
102 m_colBack,
103 m_colBorder;
104 wxFont m_font;
105 wxCalendarDateBorder m_border;
106 bool m_holiday;
107};
108
109// ----------------------------------------------------------------------------
110// wxCalendarCtrl events
111// ----------------------------------------------------------------------------
112
113class WXDLLEXPORT wxCalendarCtrl;
114
115class WXDLLEXPORT wxCalendarEvent : public wxCommandEvent
116{
117friend class wxCalendarCtrl;
118public:
119 wxCalendarEvent() { Init(); }
120 wxCalendarEvent(wxCalendarCtrl *cal, wxEventType type);
121
122 const wxDateTime& GetDate() const { return m_date; }
123 wxDateTime::WeekDay GetWeekDay() const { return m_wday; }
124
125protected:
126 void Init();
127
128private:
129 wxDateTime m_date;
130 wxDateTime::WeekDay m_wday;
131};
132
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
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 },
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 },
149#define EVT_CALENDAR_WEEKDAY_CLICKED(id, fn) { wxEVT_CALENDAR_WEEKDAY_CLICKED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL },
150
151#endif // _WX_CALCTRL_H