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