]>
Commit | Line | Data |
---|---|---|
1 | /////////////////////////////////////////////////////////////////////////////// | |
2 | // Name: wx/datectrl.h | |
3 | // Purpose: implements wxDatePickerCtrl | |
4 | // Author: Vadim Zeitlin | |
5 | // Modified by: | |
6 | // Created: 2005-01-09 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) 2005 Vadim Zeitlin <vadim@wxwindows.org> | |
9 | // Licence: wxWindows licence | |
10 | /////////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | #ifndef _WX_DATECTRL_H_ | |
13 | #define _WX_DATECTRL_H_ | |
14 | ||
15 | #include "wx/defs.h" | |
16 | ||
17 | #if wxUSE_DATEPICKCTRL | |
18 | ||
19 | // this is currently defined in wx/msw/setup.h but not for MSW configure builds | |
20 | // and other ports which only have the generic version anyhow, so provide a | |
21 | // fallback definition here for them | |
22 | #ifndef wxUSE_DATEPICKCTRL_GENERIC | |
23 | #define wxUSE_DATEPICKCTRL_GENERIC 0 | |
24 | #endif | |
25 | ||
26 | #include "wx/control.h" // the base class | |
27 | #include "wx/datetime.h" | |
28 | ||
29 | #define wxDatePickerCtrlNameStr _T("datectrl") | |
30 | ||
31 | // wxDatePickerCtrl styles | |
32 | enum | |
33 | { | |
34 | // default style on this platform, either wxDP_SPIN or wxDP_DROPDOWN | |
35 | wxDP_DEFAULT = 0, | |
36 | ||
37 | // a spin control-like date picker (not supported in generic version) | |
38 | wxDP_SPIN = 1, | |
39 | ||
40 | // a combobox-like date picker (not supported in mac version) | |
41 | wxDP_DROPDOWN = 2, | |
42 | ||
43 | // always show century in the default date display (otherwise it depends on | |
44 | // the system date format which may include the century or not) | |
45 | wxDP_SHOWCENTURY = 4, | |
46 | ||
47 | // allow not having any valid date in the control (by default it always has | |
48 | // some date, today initially if no valid date specified in ctor) | |
49 | wxDP_ALLOWNONE = 8 | |
50 | }; | |
51 | ||
52 | // ---------------------------------------------------------------------------- | |
53 | // wxDatePickerCtrl: allow the user to enter the date | |
54 | // ---------------------------------------------------------------------------- | |
55 | ||
56 | class WXDLLIMPEXP_ADV wxDatePickerCtrlBase : public wxControl | |
57 | { | |
58 | public: | |
59 | /* | |
60 | The derived classes should implement ctor and Create() method with the | |
61 | following signature: | |
62 | ||
63 | bool Create(wxWindow *parent, | |
64 | wxWindowID id, | |
65 | const wxDateTime& dt = wxDefaultDateTime, | |
66 | const wxPoint& pos = wxDefaultPosition, | |
67 | const wxSize& size = wxDefaultSize, | |
68 | long style = wxDP_DEFAULT | wxDP_SHOWCENTURY, | |
69 | const wxValidator& validator = wxDefaultValidator, | |
70 | const wxString& name = wxDatePickerCtrlNameStr); | |
71 | */ | |
72 | ||
73 | // set/get the date | |
74 | virtual void SetValue(const wxDateTime& dt) = 0; | |
75 | virtual wxDateTime GetValue() const = 0; | |
76 | ||
77 | // set/get the allowed valid range for the dates, if either/both of them | |
78 | // are invalid, there is no corresponding limit and if neither is set | |
79 | // GetRange() returns false | |
80 | virtual void SetRange(const wxDateTime& dt1, const wxDateTime& dt2) = 0; | |
81 | virtual bool GetRange(wxDateTime *dt1, wxDateTime *dt2) const = 0; | |
82 | }; | |
83 | ||
84 | #if defined(__WXPALMOS__) | |
85 | #include "wx/palmos/datectrl.h" | |
86 | ||
87 | #define wxHAS_NATIVE_DATEPICKCTRL | |
88 | #elif defined(__WXMSW__) && !defined(__WXUNIVERSAL__) | |
89 | #include "wx/msw/datectrl.h" | |
90 | ||
91 | #define wxHAS_NATIVE_DATEPICKCTRL | |
92 | #else | |
93 | #include "wx/generic/datectrl.h" | |
94 | ||
95 | class WXDLLIMPEXP_ADV wxDatePickerCtrl : public wxDatePickerCtrlGeneric | |
96 | { | |
97 | public: | |
98 | wxDatePickerCtrl() { } | |
99 | wxDatePickerCtrl(wxWindow *parent, | |
100 | wxWindowID id, | |
101 | const wxDateTime& date = wxDefaultDateTime, | |
102 | const wxPoint& pos = wxDefaultPosition, | |
103 | const wxSize& size = wxDefaultSize, | |
104 | long style = wxDP_DEFAULT | wxDP_SHOWCENTURY, | |
105 | const wxValidator& validator = wxDefaultValidator, | |
106 | const wxString& name = wxDatePickerCtrlNameStr) | |
107 | : wxDatePickerCtrlGeneric(parent, id, date, pos, size, style, validator, name) | |
108 | { | |
109 | } | |
110 | ||
111 | private: | |
112 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxDatePickerCtrl) | |
113 | }; | |
114 | #endif | |
115 | ||
116 | #endif // wxUSE_DATEPICKCTRL | |
117 | ||
118 | #endif // _WX_DATECTRL_H_ | |
119 |