]> git.saurik.com Git - wxWidgets.git/blob - interface/wx/datectrl.h
Make wxEVT_CHAR_HOOK propagate upwards and send it to the window itself.
[wxWidgets.git] / interface / wx / datectrl.h
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, except
17 PalmOS where date is selected using native dialog.
18
19 It is only available if @c wxUSE_DATEPICKCTRL is set to 1.
20
21 @beginStyleTable
22 @style{wxDP_SPIN}
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.
26 @style{wxDP_DROPDOWN}
27 Creates a control with a month calendar drop-down part from which
28 the user can select a date.
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
32 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.
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.
41 @endStyleTable
42
43 @beginEventEmissionTable{wxDateEvent}
44 @event{EVT_DATE_CHANGED(id, func)}
45 This event fires when the user changes the current selection in the
46 control.
47 @endEventTable
48
49 @library{wxadv}
50 @category{pickers}
51 @appearance{datepickerctrl.png}
52
53 @see wxCalendarCtrl, wxDateEvent
54 */
55 class wxDatePickerCtrl : public wxControl
56 {
57 public:
58 /**
59 Initializes the object and calls Create() with all the parameters.
60 */
61 wxDatePickerCtrl(wxWindow* parent, wxWindowID id,
62 const wxDateTime& dt = wxDefaultDateTime,
63 const wxPoint& pos = wxDefaultPosition,
64 const wxSize& size = wxDefaultSize,
65 long style = wxDP_DEFAULT | wxDP_SHOWCENTURY,
66 const wxValidator& validator = wxDefaultValidator,
67 const wxString& name = "datectrl");
68
69 /**
70 Create the control window.
71
72 This method should only be used for objects created using default
73 constructor.
74
75 @param parent
76 Parent window, must not be non-@NULL.
77 @param id
78 The identifier for the control.
79 @param dt
80 The initial value of the control, if an invalid date (such as the
81 default value) is used, the control is set to today.
82 @param pos
83 Initial position.
84 @param size
85 Initial size. If left at default value, the control chooses its own
86 best size by using the height approximately equal to a text control
87 and width large enough to show the date string fully.
88 @param style
89 The window style, see the description of the styles in the class
90 documentation.
91 @param validator
92 Validator which can be used for additional date checks.
93 @param name
94 Control name.
95
96 @return @true if the control was successfully created or @false if
97 creation failed.
98 */
99 bool Create(wxWindow* parent, wxWindowID id,
100 const wxDateTime& dt = wxDefaultDateTime,
101 const wxPoint& pos = wxDefaultPosition,
102 const wxSize& size = wxDefaultSize,
103 long style = wxDP_DEFAULT | wxDP_SHOWCENTURY,
104 const wxValidator& validator = wxDefaultValidator,
105 const wxString& name = "datectrl");
106
107 /**
108 If the control had been previously limited to a range of dates using
109 SetRange(), returns the lower and upper bounds of this range. If no
110 range is set (or only one of the bounds is set), @a dt1 and/or @a dt2
111 are set to be invalid.
112
113 Notice that when using a native MSW implementation of this control the
114 lower range is always set, even if SetRange() hadn't been called
115 explicitly, as the native control only supports dates later than year
116 1601.
117
118 @param dt1
119 Pointer to the object which receives the lower range limit or
120 becomes invalid if it is not set. May be @NULL if the caller is not
121 interested in lower limit.
122 @param dt2
123 Same as above but for the upper limit.
124
125 @return @false if no range limits are currently set, @true if at least
126 one bound is set.
127 */
128 virtual bool GetRange(wxDateTime* dt1, wxDateTime* dt2) const = 0;
129
130 /**
131 Returns the currently entered date.
132
133 For a control with @c wxDP_ALLOWNONE style the returned value may be
134 invalid if no date is entered, otherwise it is always valid.
135 */
136 virtual wxDateTime GetValue() const = 0;
137
138 /**
139 Sets the valid range for the date selection. If @a dt1 is valid, it
140 becomes the earliest date (inclusive) accepted by the control. If
141 @a dt2 is valid, it becomes the latest possible date.
142
143 @remarks If the current value of the control is outside of the newly
144 set range bounds, the behaviour is undefined.
145 */
146 virtual void SetRange(const wxDateTime& dt1, const wxDateTime& dt2) = 0;
147
148 /**
149 Changes the current value of the control.
150
151 The date should be valid unless the control was created with @c
152 wxDP_ALLOWNONE style and included in the currently selected range, if
153 any.
154
155 Calling this method does not result in a date change event.
156 */
157 virtual void SetValue(const wxDateTime& dt) = 0;
158 };
159