]> git.saurik.com Git - wxWidgets.git/blob - interface/wx/timectrl.h
Use wxUIntPtr instead of wxClientData in wxDataViewListCtrl.
[wxWidgets.git] / interface / wx / timectrl.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/timectrl.h
3 // Purpose: interface of wxTimePickerCtrl
4 // Author: Vadim Zeitlin
5 // Created: 2011-09-22
6 // RCS-ID: $Id$
7 // Copyright: (c) 2011 Vadim Zeitlin <vadim@wxwidgets.org>
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
10
11 /**
12 Styles used with wxTimePickerCtrl.
13
14 Currently no special styles are defined for this object.
15
16 @library{wxadv}
17 @category{pickers}
18
19 @since 2.9.3
20 */
21 enum
22 {
23 wxTP_DEFAULT = 0
24 };
25
26 /**
27 @class wxTimePickerCtrl
28
29 This control allows the user to enter time.
30
31 It is similar to wxDatePickerCtrl but is used for time, and not date,
32 selection. While GetValue() and SetValue() still work with values of type
33 wxDateTime (because wxWidgets doesn't provide a time-only class), their
34 date part is ignored by this control.
35
36 It is only available if @c wxUSE_TIMEPICKCTRL is set to 1.
37
38 This control currently doesn't have any specific flags.
39
40 @beginEventEmissionTable{wxDateEvent}
41 @event{EVT_TIME_CHANGED(id, func)}
42 This event fires when the user changes the current selection in the
43 control.
44 @endEventTable
45
46 @library{wxadv}
47 @category{pickers}
48 @appearance{timepickerctrl.png}
49
50 @see wxDatePickerCtrl, wxDateEvent
51
52 @since 2.9.3
53 */
54 class wxTimePickerCtrl : public wxControl
55 {
56 public:
57 /**
58 Initializes the object and calls Create() with all the parameters.
59 */
60 wxTimePickerCtrl(wxWindow* parent, wxWindowID id,
61 const wxDateTime& dt = wxDefaultDateTime,
62 const wxPoint& pos = wxDefaultPosition,
63 const wxSize& size = wxDefaultSize,
64 long style = wxTP_DEFAULT,
65 const wxValidator& validator = wxDefaultValidator,
66 const wxString& name = "timectrl");
67
68 /**
69 Create the control window.
70
71 This method should only be used for objects created using default
72 constructor.
73
74 @param parent
75 Parent window, must not be non-@NULL.
76 @param id
77 The identifier for the control.
78 @param dt
79 The initial value of the control, if an invalid date (such as the
80 default value) is used, the control is set to current time.
81 @param pos
82 Initial position.
83 @param size
84 Initial size. If left at default value, the control chooses its own
85 best size by using the height approximately equal to a text control
86 and width large enough to show the time fully.
87 @param style
88 The window style, should be left at 0 as there are no special
89 styles for this control in this version.
90 @param validator
91 Validator which can be used for additional checks.
92 @param name
93 Control name.
94
95 @return @true if the control was successfully created or @false if
96 creation failed.
97 */
98 bool Create(wxWindow* parent, wxWindowID id,
99 const wxDateTime& dt = wxDefaultDateTime,
100 const wxPoint& pos = wxDefaultPosition,
101 const wxSize& size = wxDefaultSize,
102 long style = wxDP_DEFAULT | wxDP_SHOWCENTURY,
103 const wxValidator& validator = wxDefaultValidator,
104 const wxString& name = "timectrl");
105
106 /**
107 Returns the currently entered time as hours, minutes and seconds.
108
109 All the arguments must be non-@NULL, @false is returned otherwise and
110 none of them is modified.
111
112 @see SetTime()
113
114 @since 2.9.4
115 */
116 bool GetTime(int* hour, int* min, int* sec) const;
117
118 /**
119 Returns the currently entered time.
120
121 The date part of the returned wxDateTime object is always set to today
122 and should be ignored, only the time part is relevant.
123 */
124 virtual wxDateTime GetValue() const = 0;
125
126 /**
127 Changes the current time of the control.
128
129 Calling this method does not result in a time change event.
130
131 @param hour The new hour value in 0..23 interval.
132 @param min The new minute value in 0..59 interval.
133 @param sec The new second value in 0..59 interval.
134 @return @true if the time was changed or @false on failure, e.g. if the
135 time components were invalid.
136
137 @see GetTime()
138
139 @since 2.9.4
140 */
141 bool SetTime(int hour, int min, int sec);
142
143 /**
144 Changes the current value of the control.
145
146 The date part of @a dt is ignored, only the time part is displayed in
147 the control. The @a dt object must however be valid.
148
149 In particular notice that it is a bad idea to use default wxDateTime
150 constructor from hour, minute and second values as it uses the today
151 date for the date part which means that some times can be invalid if
152 today happens to be the day of DST change. For example, when switching
153 to summer time the time 2:00 typically doesn't exist as the clocks jump
154 directly to 3:00. To avoid this problem, use a fixed date on which DST
155 is known not to change (e.g. Jan 1, 2012) for the date part of the
156 argument or use SetTime().
157
158 Calling this method does not result in a time change event.
159 */
160 virtual void SetValue(const wxDateTime& dt) = 0;
161 };