renamed generic version to wxDatePickerCtrlGeneric to allow using it alongside the...
[wxWidgets.git] / include / wx / generic / datectrl.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: generic/datectrl.h
3 // Purpose: generic wxDatePickerCtrl implementation
4 // Author: Andreas Pflug
5 // Modified by:
6 // Created: 2005-01-19
7 // RCS-ID: $Id$
8 // Copyright: (c) 2005 Andreas Pflug <pgadmin@pse-consulting.de>
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_GENERIC_DATECTRL_H_
13 #define _WX_GENERIC_DATECTRL_H_
14
15 class WXDLLIMPEXP_ADV wxCalendarDateAttr;
16 class WXDLLIMPEXP_ADV wxCalendarCtrl;
17 class WXDLLIMPEXP_ADV wxCalendarEvent;
18 class WXDLLIMPEXP_ADV wxPopupWindow;
19
20 class WXDLLIMPEXP_ADV wxDatePickerCtrlGeneric : public wxDatePickerCtrlBase
21 {
22 public:
23 // creating the control
24 wxDatePickerCtrlGeneric() { Init(); }
25 wxDatePickerCtrlGeneric(wxWindow *parent,
26 wxWindowID id,
27 const wxDateTime& date = wxDefaultDateTime,
28 const wxPoint& pos = wxDefaultPosition,
29 const wxSize& size = wxDefaultSize,
30 long style = wxDP_DEFAULT | wxDP_SHOWCENTURY,
31 const wxString& name = wxDatePickerCtrlNameStr)
32 {
33 Init();
34
35 (void)Create(parent, id, date, pos, size, style, name);
36 }
37
38 bool Create(wxWindow *parent,
39 wxWindowID id,
40 const wxDateTime& date = wxDefaultDateTime,
41 const wxPoint& pos = wxDefaultPosition,
42 const wxSize& size = wxDefaultSize,
43 long style = wxDP_DEFAULT | wxDP_SHOWCENTURY,
44 const wxString& name = wxDatePickerCtrlNameStr);
45
46 // wxDatePickerCtrl methods
47 void SetValue(const wxDateTime& date);
48 wxDateTime GetValue() const;
49
50 bool GetRange(wxDateTime *dt1, wxDateTime *dt2) const;
51 void SetRange(const wxDateTime &dt1, const wxDateTime &dt2);
52
53 bool SetDateRange(const wxDateTime& lowerdate = wxDefaultDateTime,
54 const wxDateTime& upperdate = wxDefaultDateTime);
55
56 // extra methods available only in this (generic) implementation
57 bool SetFormat(const wxChar *fmt);
58 wxCalendarCtrl *GetCalendar() const { return m_cal; }
59
60
61 // implementation only from now on
62 // -------------------------------
63
64 // overridden base class methods
65 virtual bool Destroy();
66
67 virtual bool Enable(bool enable = TRUE);
68 virtual bool Show(bool show = TRUE);
69
70 protected:
71 virtual wxSize DoGetBestSize() const;
72 virtual void DoMoveWindow(int x, int y, int width, int height);
73
74 private:
75 wxPopupWindow *m_popup;
76 wxTextCtrl *m_txt;
77 wxCalendarCtrl *m_cal;
78 wxButton *m_btn;
79 wxString m_format;
80
81 bool m_dropped, m_ignoreDrop;
82
83 void Init();
84 void DropDown(bool down=true);
85
86 void OnText(wxCommandEvent &ev);
87 void OnEditKey(wxKeyEvent & event);
88 void OnCalKey(wxKeyEvent & event);
89 void OnClick(wxCommandEvent &ev);
90 void OnSelChange(wxCalendarEvent &ev);
91 void OnSetFocus(wxFocusEvent &ev);
92 void OnKillFocus(wxFocusEvent &ev);
93 void OnChildSetFocus(wxChildFocusEvent &ev);
94
95 DECLARE_EVENT_TABLE()
96 DECLARE_NO_COPY_CLASS(wxDatePickerCtrlGeneric)
97 };
98
99 #endif // _WX_GENERIC_DATECTRL_H_
100