]> git.saurik.com Git - wxWidgets.git/blame - interface/wx/timectrl.h
Convert wxFSW_EVENT_{WARNING,ERROR} to string correctly.
[wxWidgets.git] / interface / wx / timectrl.h
CommitLineData
569c7d8c
VZ
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
50cbca27
VZ
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 */
21enum
22{
23 wxTP_DEFAULT = 0
24};
25
569c7d8c
VZ
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}
ce154616 48 @appearance{timepickerctrl}
569c7d8c
VZ
49
50 @see wxDatePickerCtrl, wxDateEvent
51
52 @since 2.9.3
53*/
54class wxTimePickerCtrl : public wxControl
55{
56public:
08f639f1
RD
57 /**
58 Default constructor.
59 */
60 wxTimePickerCtrl();
61
569c7d8c
VZ
62 /**
63 Initializes the object and calls Create() with all the parameters.
64 */
65 wxTimePickerCtrl(wxWindow* parent, wxWindowID id,
66 const wxDateTime& dt = wxDefaultDateTime,
67 const wxPoint& pos = wxDefaultPosition,
68 const wxSize& size = wxDefaultSize,
69 long style = wxTP_DEFAULT,
70 const wxValidator& validator = wxDefaultValidator,
71 const wxString& name = "timectrl");
72
73 /**
74 Create the control window.
75
76 This method should only be used for objects created using default
77 constructor.
78
79 @param parent
80 Parent window, must not be non-@NULL.
81 @param id
82 The identifier for the control.
83 @param dt
84 The initial value of the control, if an invalid date (such as the
85 default value) is used, the control is set to current time.
86 @param pos
87 Initial position.
88 @param size
89 Initial size. If left at default value, the control chooses its own
90 best size by using the height approximately equal to a text control
91 and width large enough to show the time fully.
92 @param style
93 The window style, should be left at 0 as there are no special
94 styles for this control in this version.
95 @param validator
96 Validator which can be used for additional checks.
97 @param name
98 Control name.
99
100 @return @true if the control was successfully created or @false if
101 creation failed.
102 */
103 bool Create(wxWindow* parent, wxWindowID id,
104 const wxDateTime& dt = wxDefaultDateTime,
105 const wxPoint& pos = wxDefaultPosition,
106 const wxSize& size = wxDefaultSize,
107 long style = wxDP_DEFAULT | wxDP_SHOWCENTURY,
108 const wxValidator& validator = wxDefaultValidator,
109 const wxString& name = "timectrl");
110
c0795ce8
VZ
111 /**
112 Returns the currently entered time as hours, minutes and seconds.
113
114 All the arguments must be non-@NULL, @false is returned otherwise and
115 none of them is modified.
116
117 @see SetTime()
118
119 @since 2.9.4
120 */
121 bool GetTime(int* hour, int* min, int* sec) const;
122
569c7d8c
VZ
123 /**
124 Returns the currently entered time.
125
126 The date part of the returned wxDateTime object is always set to today
127 and should be ignored, only the time part is relevant.
128 */
08f639f1 129 virtual wxDateTime GetValue() const;
569c7d8c 130
c0795ce8
VZ
131 /**
132 Changes the current time of the control.
133
134 Calling this method does not result in a time change event.
135
136 @param hour The new hour value in 0..23 interval.
137 @param min The new minute value in 0..59 interval.
138 @param sec The new second value in 0..59 interval.
139 @return @true if the time was changed or @false on failure, e.g. if the
140 time components were invalid.
141
142 @see GetTime()
143
144 @since 2.9.4
145 */
146 bool SetTime(int hour, int min, int sec);
147
569c7d8c
VZ
148 /**
149 Changes the current value of the control.
150
151 The date part of @a dt is ignored, only the time part is displayed in
152 the control. The @a dt object must however be valid.
153
c0795ce8
VZ
154 In particular notice that it is a bad idea to use default wxDateTime
155 constructor from hour, minute and second values as it uses the today
156 date for the date part which means that some times can be invalid if
157 today happens to be the day of DST change. For example, when switching
158 to summer time the time 2:00 typically doesn't exist as the clocks jump
159 directly to 3:00. To avoid this problem, use a fixed date on which DST
160 is known not to change (e.g. Jan 1, 2012) for the date part of the
161 argument or use SetTime().
162
569c7d8c
VZ
163 Calling this method does not result in a time change event.
164 */
08f639f1 165 virtual void SetValue(const wxDateTime& dt);
569c7d8c 166};