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