]>
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$ | |
6 | // Licence: wxWindows license | |
7 | ///////////////////////////////////////////////////////////////////////////// | |
8 | ||
9 | /** | |
10 | @class wxDatePickerCtrl | |
11 | @wxheader{datectrl.h} | |
7c913512 FM |
12 | |
13 | This control allows the user to select a date. Unlike | |
23324ae1 FM |
14 | wxCalendarCtrl, which is a relatively big control, |
15 | wxDatePickerCtrl is implemented as a small window showing the currently | |
16 | selected date. | |
17 | The control can be edited using the keyboard, and can also display a popup | |
18 | window for more user-friendly date selection, depending on the styles used and | |
19 | the platform, except PalmOS where date is selected using native dialog. | |
7c913512 | 20 | |
23324ae1 | 21 | It is only available if @c wxUSE_DATEPICKCTRL is set to 1. |
7c913512 | 22 | |
23324ae1 | 23 | @beginStyleTable |
8c6791e4 | 24 | @style{wxDP_SPIN} |
23324ae1 FM |
25 | Creates a control without a month calendar drop down but with |
26 | spin-control-like arrows to change individual date components. This | |
27 | style is not supported by the generic version. | |
8c6791e4 | 28 | @style{wxDP_DROPDOWN} |
23324ae1 FM |
29 | Creates a control with a month calendar drop-down part from which |
30 | the user can select a date. | |
8c6791e4 | 31 | @style{wxDP_DEFAULT} |
23324ae1 FM |
32 | Creates a control with the style that is best supported for the |
33 | current platform (currently wxDP_SPIN under Windows and | |
34 | wxDP_DROPDOWN elsewhere). | |
8c6791e4 | 35 | @style{wxDP_ALLOWNONE} |
23324ae1 FM |
36 | With this style, the control allows the user to not enter any valid |
37 | date at all. Without it - the default - the control always has some | |
38 | valid date. | |
8c6791e4 | 39 | @style{wxDP_SHOWCENTURY} |
23324ae1 FM |
40 | Forces display of the century in the default date format. Without |
41 | this style the century could be displayed, or not, depending on the | |
42 | default date representation in the system. | |
43 | @endStyleTable | |
7c913512 | 44 | |
1f1d2182 | 45 | @beginEventTable{wxDateEvent} |
8c6791e4 | 46 | @event{EVT_DATE_CHANGED(id, func)} |
1f1d2182 | 47 | This event fires when the user changes the current selection in the control. |
23324ae1 | 48 | @endEventTable |
7c913512 | 49 | |
23324ae1 | 50 | @library{wxadv} |
d18d9f60 | 51 | @category{pickers} |
23324ae1 | 52 | @appearance{datepickerctrl.png} |
7c913512 | 53 | |
e54c96f1 | 54 | @see wxCalendarCtrl, wxDateEvent |
23324ae1 FM |
55 | */ |
56 | class wxDatePickerCtrl : public wxControl | |
57 | { | |
58 | public: | |
59 | /** | |
60 | Initializes the object and calls Create() with | |
61 | all the parameters. | |
62 | */ | |
4cc4bfaf | 63 | wxDatePickerCtrl(wxWindow* parent, wxWindowID id, |
23324ae1 FM |
64 | const wxDateTime& dt = wxDefaultDateTime, |
65 | const wxPoint& pos = wxDefaultPosition, | |
66 | const wxSize& size = wxDefaultSize, | |
67 | long style = wxDP_DEFAULT | wxDP_SHOWCENTURY, | |
68 | const wxValidator& validator = wxDefaultValidator, | |
69 | const wxString& name = "datectrl"); | |
70 | ||
71 | /** | |
7c913512 | 72 | @param parent |
4cc4bfaf | 73 | Parent window, must not be non-@NULL. |
7c913512 | 74 | @param id |
4cc4bfaf | 75 | The identifier for the control. |
7c913512 | 76 | @param dt |
4cc4bfaf FM |
77 | The initial value of the control, if an invalid date (such as the |
78 | default value) is used, the control is set to today. | |
7c913512 | 79 | @param pos |
4cc4bfaf | 80 | Initial position. |
7c913512 | 81 | @param size |
4cc4bfaf FM |
82 | Initial size. If left at default value, the control chooses its |
83 | own best size by using the height approximately equal to a text control and | |
84 | width large enough to show the date string fully. | |
7c913512 | 85 | @param style |
4cc4bfaf FM |
86 | The window style, should be left at 0 as there are no |
87 | special styles for this control in this version. | |
7c913512 | 88 | @param validator |
4cc4bfaf | 89 | Validator which can be used for additional date checks. |
7c913512 | 90 | @param name |
4cc4bfaf | 91 | Control name. |
3c4f71cc | 92 | |
23324ae1 | 93 | @returns @true if the control was successfully created or @false if |
4cc4bfaf | 94 | creation failed. |
23324ae1 | 95 | */ |
4cc4bfaf | 96 | bool Create(wxWindow* parent, wxWindowID id, |
23324ae1 FM |
97 | const wxDateTime& dt = wxDefaultDateTime, |
98 | const wxPoint& pos = wxDefaultPosition, | |
99 | const wxSize& size = wxDefaultSize, | |
100 | long style = wxDP_DEFAULT | wxDP_SHOWCENTURY, | |
101 | const wxValidator& validator = wxDefaultValidator, | |
102 | const wxString& name = "datectrl"); | |
103 | ||
104 | /** | |
7c913512 | 105 | If the control had been previously limited to a range of dates using |
23324ae1 FM |
106 | SetRange(), returns the lower and upper |
107 | bounds of this range. If no range is set (or only one of the bounds is set), | |
4cc4bfaf | 108 | @a dt1 and/or @a dt2 are set to be invalid. |
3c4f71cc | 109 | |
7c913512 | 110 | @param dt1 |
4cc4bfaf FM |
111 | Pointer to the object which receives the lower range limit or |
112 | becomes invalid if it is not set. May be @NULL if the caller is not | |
113 | interested in lower limit | |
7c913512 | 114 | @param dt2 |
4cc4bfaf | 115 | Same as above but for the upper limit |
3c4f71cc | 116 | |
23324ae1 | 117 | @returns @false if no range limits are currently set, @true if at least one |
4cc4bfaf | 118 | bound is set. |
23324ae1 | 119 | */ |
328f5751 | 120 | bool GetRange(wxDateTime* dt1, wxDateTime dt2) const; |
23324ae1 FM |
121 | |
122 | /** | |
123 | Returns the currently selected. If there is no selection or the selection is | |
124 | outside of the current range, an invalid object is returned. | |
125 | */ | |
328f5751 | 126 | wxDateTime GetValue() const; |
23324ae1 FM |
127 | |
128 | /** | |
129 | Please note that this function is only available in the generic version of this | |
130 | control. The native version always uses the current system locale. | |
23324ae1 FM |
131 | Sets the display format for the date in the control. See wxDateTime for the |
132 | meaning of format strings. | |
3c4f71cc | 133 | |
23324ae1 FM |
134 | @remarks If the format parameter is invalid, the behaviour is undefined. |
135 | */ | |
136 | void SetFormat(const wxChar* format); | |
137 | ||
138 | /** | |
4cc4bfaf FM |
139 | Sets the valid range for the date selection. If @a dt1 is valid, it becomes |
140 | the earliest date (inclusive) accepted by the control. If @a dt2 is valid, | |
23324ae1 | 141 | it becomes the latest possible date. |
3c4f71cc | 142 | |
23324ae1 | 143 | @remarks If the current value of the control is outside of the newly set |
4cc4bfaf | 144 | range bounds, the behaviour is undefined. |
23324ae1 FM |
145 | */ |
146 | void SetRange(const wxDateTime& dt1, const wxDateTime& dt2); | |
147 | ||
148 | /** | |
149 | Changes the current value of the control. The date should be valid and included | |
150 | in the currently selected range, if any. | |
23324ae1 FM |
151 | Calling this method does not result in a date change event. |
152 | */ | |
153 | void SetValue(const wxDateTime& dt); | |
154 | }; | |
e54c96f1 | 155 |