]> git.saurik.com Git - wxWidgets.git/blob - include/wx/generic/calctrl.h
c781064441372db27bb2a9072ff7e46fd55fafdb
[wxWidgets.git] / include / wx / generic / calctrl.h
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: generic/calctrl.h
3 // Purpose: generic implementation of 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 #ifdef __GNUG__
13 #pragma interface "calctrl.h"
14 #endif
15
16 #ifndef _WX_GENERIC_CALCTRL_H
17 #define _WX_GENERIC_CALCTRL_H
18
19 #include "wx/control.h" // the base class
20
21 #include "wx/datetime.h" // for m_date
22 #include "wx/combobox.h" // for m_comboMonth
23 #include "wx/spinctrl.h" // for m_spinYear
24
25 #define wxCalendarNameStr _T("CalendarCtrl")
26
27 // ----------------------------------------------------------------------------
28 // wxCalendarCtrl: a control allowing the user to pick a date interactively
29 // ----------------------------------------------------------------------------
30
31 class WXDLLEXPORT wxCalendarCtrl : public wxControl
32 {
33 public:
34 // construction
35 wxCalendarCtrl() { Init(); }
36 wxCalendarCtrl(wxWindow *parent,
37 wxWindowID id,
38 const wxDateTime& date = wxDefaultDateTime,
39 const wxPoint& pos = wxDefaultPosition,
40 const wxSize& size = wxDefaultSize,
41 long style = 0,
42 const wxString& name = wxCalendarNameStr)
43 : wxControl(parent, id, pos, size, style, wxDefaultValidator, name)
44 {
45 Init();
46
47 (void)Create(parent, id, date, pos, size, style, name);
48 }
49
50 bool Create(wxWindow *parent,
51 wxWindowID id,
52 const wxDateTime& date = wxDefaultDateTime,
53 const wxPoint& pos = wxDefaultPosition,
54 const wxSize& size = wxDefaultSize,
55 long style = 0,
56 const wxString& name = wxCalendarNameStr);
57
58 // set/get the current date
59 void SetDate(const wxDateTime& date);
60 const wxDateTime& GetDate() const { return m_date; }
61
62 // returns TRUE if the given point is on a day and fills date with its
63 // value
64 bool HitTest(const wxPoint& pos, wxDateTime *date);
65
66 // implementation only from now on
67 // -------------------------------
68
69 void OnPaint(wxPaintEvent& event);
70 void OnClick(wxMouseEvent& event);
71
72 private:
73 // common part of all ctors
74 void Init();
75
76 // override some base class virtuals
77 virtual wxSize DoGetBestSize() const;
78 virtual void DoSetSize(int x, int y, int width, int height, int sizeFlags);
79 virtual void DoMoveWindow(int x, int y, int width, int height);
80
81 // get the date from which we start drawing days
82 wxDateTime GetStartDate() const;
83
84 // is this date shown?
85 bool IsDateShown(const wxDateTime& date) const;
86
87 // the subcontrols
88 wxComboBox *m_comboMonth;
89 wxSpinCtrl *m_spinYear;
90
91 wxDateTime m_date;
92
93 // the width and height of one column/row in the calendar
94 wxCoord m_widthCol,
95 m_heightRow;
96
97 DECLARE_DYNAMIC_CLASS(wxCalendarCtrl)
98 DECLARE_EVENT_TABLE()
99 };
100
101 #endif // _WX_GENERIC_CALCTRL_H