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