]>
Commit | Line | Data |
---|---|---|
23324ae1 FM |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: datectrl.h | |
e54c96f1 | 3 | // Purpose: interface of wxDatePickerCtrl |
23324ae1 | 4 | // Author: wxWidgets team |
526954c5 | 5 | // Licence: wxWindows licence |
23324ae1 FM |
6 | ///////////////////////////////////////////////////////////////////////////// |
7 | ||
073b976d RD |
8 | /// wxDatePickerCtrl styles |
9 | enum | |
10 | { | |
11 | /// default style on this platform, either wxDP_SPIN or wxDP_DROPDOWN | |
12 | wxDP_DEFAULT = 0, | |
13 | ||
14 | /// a spin control-like date picker (not supported in generic version) | |
15 | wxDP_SPIN = 1, | |
16 | ||
17 | /// a combobox-like date picker (not supported in mac version) | |
18 | wxDP_DROPDOWN = 2, | |
19 | ||
20 | /// always show century in the default date display (otherwise it depends on | |
21 | /// the system date format which may include the century or not) | |
22 | wxDP_SHOWCENTURY = 4, | |
23 | ||
24 | /// allow not having any valid date in the control (by default it always has | |
25 | /// some date, today initially if no valid date specified in ctor) | |
26 | wxDP_ALLOWNONE = 8 | |
27 | }; | |
28 | ||
29 | ||
23324ae1 FM |
30 | /** |
31 | @class wxDatePickerCtrl | |
7c913512 | 32 | |
b9da294f BP |
33 | This control allows the user to select a date. Unlike wxCalendarCtrl, which |
34 | is a relatively big control, wxDatePickerCtrl is implemented as a small | |
35 | window showing the currently selected date. The control can be edited using | |
36 | the keyboard, and can also display a popup window for more user-friendly | |
bd362275 | 37 | date selection, depending on the styles used and the platform. |
7c913512 | 38 | |
23324ae1 | 39 | It is only available if @c wxUSE_DATEPICKCTRL is set to 1. |
7c913512 | 40 | |
23324ae1 | 41 | @beginStyleTable |
8c6791e4 | 42 | @style{wxDP_SPIN} |
23324ae1 FM |
43 | Creates a control without a month calendar drop down but with |
44 | spin-control-like arrows to change individual date components. This | |
45 | style is not supported by the generic version. | |
8c6791e4 | 46 | @style{wxDP_DROPDOWN} |
23324ae1 | 47 | Creates a control with a month calendar drop-down part from which |
fceac6bb VZ |
48 | the user can select a date. This style is not supported in OSX/Cocoa |
49 | native version. | |
8c6791e4 | 50 | @style{wxDP_DEFAULT} |
23324ae1 | 51 | Creates a control with the style that is best supported for the |
fceac6bb VZ |
52 | current platform (currently wxDP_SPIN under Windows and OSX/Cocoa |
53 | and wxDP_DROPDOWN elsewhere). | |
8c6791e4 | 54 | @style{wxDP_ALLOWNONE} |
23324ae1 FM |
55 | With this style, the control allows the user to not enter any valid |
56 | date at all. Without it - the default - the control always has some | |
fceac6bb | 57 | valid date. This style is not supported in OSX/Cocoa native version. |
8c6791e4 | 58 | @style{wxDP_SHOWCENTURY} |
23324ae1 FM |
59 | Forces display of the century in the default date format. Without |
60 | this style the century could be displayed, or not, depending on the | |
fceac6bb VZ |
61 | default date representation in the system. This style is not |
62 | supported in OSX/Cocoa native version currently. | |
23324ae1 | 63 | @endStyleTable |
7c913512 | 64 | |
fceac6bb VZ |
65 | As can be seen from the remarks above, most of the control style are only |
66 | supported in the native MSW implementation. In portable code it's | |
67 | recommended to use @c wxDP_DEFAULT style only, possibly combined with @c | |
68 | wxDP_SHOWCENTURY (this is also the style used by default if none is | |
69 | specified). | |
70 | ||
3051a44a | 71 | @beginEventEmissionTable{wxDateEvent} |
8c6791e4 | 72 | @event{EVT_DATE_CHANGED(id, func)} |
b9da294f BP |
73 | This event fires when the user changes the current selection in the |
74 | control. | |
23324ae1 | 75 | @endEventTable |
7c913512 | 76 | |
23324ae1 | 77 | @library{wxadv} |
d18d9f60 | 78 | @category{pickers} |
ce154616 | 79 | @appearance{datepickerctrl} |
7c913512 | 80 | |
e54c96f1 | 81 | @see wxCalendarCtrl, wxDateEvent |
23324ae1 FM |
82 | */ |
83 | class wxDatePickerCtrl : public wxControl | |
84 | { | |
85 | public: | |
073b976d RD |
86 | /** |
87 | Default constructor. | |
88 | */ | |
89 | wxDatePickerCtrl(); | |
90 | ||
23324ae1 | 91 | /** |
b9da294f | 92 | Initializes the object and calls Create() with all the parameters. |
23324ae1 | 93 | */ |
4cc4bfaf | 94 | wxDatePickerCtrl(wxWindow* parent, wxWindowID id, |
23324ae1 FM |
95 | const wxDateTime& dt = wxDefaultDateTime, |
96 | const wxPoint& pos = wxDefaultPosition, | |
97 | const wxSize& size = wxDefaultSize, | |
98 | long style = wxDP_DEFAULT | wxDP_SHOWCENTURY, | |
99 | const wxValidator& validator = wxDefaultValidator, | |
100 | const wxString& name = "datectrl"); | |
101 | ||
102 | /** | |
1319b268 VZ |
103 | Create the control window. |
104 | ||
105 | This method should only be used for objects created using default | |
106 | constructor. | |
107 | ||
7c913512 | 108 | @param parent |
4cc4bfaf | 109 | Parent window, must not be non-@NULL. |
7c913512 | 110 | @param id |
4cc4bfaf | 111 | The identifier for the control. |
7c913512 | 112 | @param dt |
4cc4bfaf FM |
113 | The initial value of the control, if an invalid date (such as the |
114 | default value) is used, the control is set to today. | |
7c913512 | 115 | @param pos |
4cc4bfaf | 116 | Initial position. |
7c913512 | 117 | @param size |
b9da294f BP |
118 | Initial size. If left at default value, the control chooses its own |
119 | best size by using the height approximately equal to a text control | |
120 | and width large enough to show the date string fully. | |
7c913512 | 121 | @param style |
1319b268 VZ |
122 | The window style, see the description of the styles in the class |
123 | documentation. | |
7c913512 | 124 | @param validator |
4cc4bfaf | 125 | Validator which can be used for additional date checks. |
7c913512 | 126 | @param name |
4cc4bfaf | 127 | Control name. |
3c4f71cc | 128 | |
d29a9a8a | 129 | @return @true if the control was successfully created or @false if |
4cc4bfaf | 130 | creation failed. |
23324ae1 | 131 | */ |
4cc4bfaf | 132 | bool Create(wxWindow* parent, wxWindowID id, |
23324ae1 FM |
133 | const wxDateTime& dt = wxDefaultDateTime, |
134 | const wxPoint& pos = wxDefaultPosition, | |
135 | const wxSize& size = wxDefaultSize, | |
136 | long style = wxDP_DEFAULT | wxDP_SHOWCENTURY, | |
137 | const wxValidator& validator = wxDefaultValidator, | |
138 | const wxString& name = "datectrl"); | |
139 | ||
140 | /** | |
7c913512 | 141 | If the control had been previously limited to a range of dates using |
b9da294f BP |
142 | SetRange(), returns the lower and upper bounds of this range. If no |
143 | range is set (or only one of the bounds is set), @a dt1 and/or @a dt2 | |
144 | are set to be invalid. | |
3c4f71cc | 145 | |
58daa7b2 VZ |
146 | Notice that when using a native MSW implementation of this control the |
147 | lower range is always set, even if SetRange() hadn't been called | |
148 | explicitly, as the native control only supports dates later than year | |
149 | 1601. | |
150 | ||
7c913512 | 151 | @param dt1 |
4cc4bfaf FM |
152 | Pointer to the object which receives the lower range limit or |
153 | becomes invalid if it is not set. May be @NULL if the caller is not | |
b9da294f | 154 | interested in lower limit. |
7c913512 | 155 | @param dt2 |
b9da294f | 156 | Same as above but for the upper limit. |
3c4f71cc | 157 | |
d29a9a8a | 158 | @return @false if no range limits are currently set, @true if at least |
b9da294f | 159 | one bound is set. |
23324ae1 | 160 | */ |
073b976d | 161 | virtual bool GetRange(wxDateTime* dt1, wxDateTime* dt2) const; |
23324ae1 FM |
162 | |
163 | /** | |
1319b268 VZ |
164 | Returns the currently entered date. |
165 | ||
166 | For a control with @c wxDP_ALLOWNONE style the returned value may be | |
167 | invalid if no date is entered, otherwise it is always valid. | |
23324ae1 | 168 | */ |
073b976d | 169 | virtual wxDateTime GetValue() const; |
23324ae1 | 170 | |
23324ae1 | 171 | /** |
b9da294f BP |
172 | Sets the valid range for the date selection. If @a dt1 is valid, it |
173 | becomes the earliest date (inclusive) accepted by the control. If | |
174 | @a dt2 is valid, it becomes the latest possible date. | |
3c4f71cc | 175 | |
b9da294f BP |
176 | @remarks If the current value of the control is outside of the newly |
177 | set range bounds, the behaviour is undefined. | |
23324ae1 | 178 | */ |
073b976d | 179 | virtual void SetRange(const wxDateTime& dt1, const wxDateTime& dt2); |
23324ae1 FM |
180 | |
181 | /** | |
597b64c2 VZ |
182 | Changes the current value of the control. |
183 | ||
184 | The date should be valid unless the control was created with @c | |
185 | wxDP_ALLOWNONE style and included in the currently selected range, if | |
186 | any. | |
b9da294f | 187 | |
23324ae1 FM |
188 | Calling this method does not result in a date change event. |
189 | */ | |
073b976d | 190 | virtual void SetValue(const wxDateTime& dt); |
23324ae1 | 191 | }; |
e54c96f1 | 192 |