1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: generic/calctrl.h
3 // Purpose: generic implementation of date-picker control
4 // Author: Vadim Zeitlin
8 // Copyright: (c) 1999 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
9 // Licence: wxWindows license
10 ///////////////////////////////////////////////////////////////////////////////
13 #pragma interface "calctrl.h"
16 #ifndef _WX_GENERIC_CALCTRL_H
17 #define _WX_GENERIC_CALCTRL_H
19 #include "wx/control.h" // the base class
21 #include "wx/datetime.h" // for m_date
22 #include "wx/combobox.h" // for m_comboMonth
23 #include "wx/spinctrl.h" // for m_spinYear
25 #define wxCalendarNameStr _T("CalendarCtrl")
27 // ----------------------------------------------------------------------------
28 // wxCalendarCtrl: a control allowing the user to pick a date interactively
29 // ----------------------------------------------------------------------------
31 class WXDLLEXPORT wxCalendarCtrl
: public wxControl
35 wxCalendarCtrl() { Init(); }
36 wxCalendarCtrl(wxWindow
*parent
,
38 const wxDateTime
& date
= wxDefaultDateTime
,
39 const wxPoint
& pos
= wxDefaultPosition
,
40 const wxSize
& size
= wxDefaultSize
,
42 const wxString
& name
= wxCalendarNameStr
)
43 : wxControl(parent
, id
, pos
, size
, style
, wxDefaultValidator
, name
)
47 (void)Create(parent
, id
, date
, pos
, size
, style
, name
);
50 bool Create(wxWindow
*parent
,
52 const wxDateTime
& date
= wxDefaultDateTime
,
53 const wxPoint
& pos
= wxDefaultPosition
,
54 const wxSize
& size
= wxDefaultSize
,
56 const wxString
& name
= wxCalendarNameStr
);
58 // set/get the current date
59 void SetDate(const wxDateTime
& date
);
60 const wxDateTime
& GetDate() const { return m_date
; }
62 // returns TRUE if the given point is on a day and fills date with its
64 bool HitTest(const wxPoint
& pos
, wxDateTime
*date
);
66 // implementation only from now on
67 // -------------------------------
69 void OnPaint(wxPaintEvent
& event
);
70 void OnClick(wxMouseEvent
& event
);
73 // common part of all ctors
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
);
81 // get the date from which we start drawing days
82 wxDateTime
GetStartDate() const;
84 // is this date shown?
85 bool IsDateShown(const wxDateTime
& date
) const;
88 wxComboBox
*m_comboMonth
;
89 wxSpinCtrl
*m_spinYear
;
93 // the width and height of one column/row in the calendar
97 DECLARE_DYNAMIC_CLASS(wxCalendarCtrl
)
101 #endif // _WX_GENERIC_CALCTRL_H