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