1 ///////////////////////////////////////////////////////////////////////////////
3 // Purpose: Declaration of wxTimePickerCtrl class.
4 // Author: Vadim Zeitlin
6 // Copyright: (c) 2011 Vadim Zeitlin <vadim@wxwidgets.org>
7 // Licence: wxWindows licence
8 ///////////////////////////////////////////////////////////////////////////////
10 #ifndef _WX_TIMECTRL_H_
11 #define _WX_TIMECTRL_H_
15 #if wxUSE_TIMEPICKCTRL
17 #include "wx/datetimectrl.h"
19 #define wxTimePickerCtrlNameStr wxS("timectrl")
21 // No special styles are currently defined for this control but still define a
22 // symbolic constant for the default style for consistency.
28 // ----------------------------------------------------------------------------
29 // wxTimePickerCtrl: Allow the user to enter the time.
30 // ----------------------------------------------------------------------------
32 class WXDLLIMPEXP_ADV wxTimePickerCtrlBase
: public wxDateTimePickerCtrl
36 The derived classes should implement ctor and Create() method with the
39 bool Create(wxWindow *parent,
41 const wxDateTime& dt = wxDefaultDateTime,
42 const wxPoint& pos = wxDefaultPosition,
43 const wxSize& size = wxDefaultSize,
44 long style = wxTP_DEFAULT,
45 const wxValidator& validator = wxDefaultValidator,
46 const wxString& name = wxTimePickerCtrlNameStr);
50 We also inherit Set/GetValue() methods from the base class which define
51 our public API. Notice that the date portion of the date passed as
52 input or received as output is or should be ignored, only the time part
53 of wxDateTime objects is really significant here. Use Set/GetTime()
54 below for possibly simpler interface.
57 // Set the given time.
58 bool SetTime(int hour
, int min
, int sec
)
60 // Notice that we should use a date on which DST doesn't change to
61 // avoid any problems with time discontinuity so use a fixed date (on
62 // which nobody changes DST) instead of e.g. today.
63 wxDateTime
dt(1, wxDateTime::Jan
, 2012, hour
, min
, sec
);
66 // No need to assert here, wxDateTime already does it for us.
75 // Get the current time components. All pointers must be non-NULL.
76 bool GetTime(int* hour
, int* min
, int* sec
) const
78 wxCHECK_MSG( hour
&& min
&& sec
, false,
79 wxS("Time component pointers must be non-NULL") );
81 const wxDateTime::Tm tm
= GetValue().GetTm();
90 #if defined(__WXMSW__) && !defined(__WXUNIVERSAL__)
91 #include "wx/msw/timectrl.h"
93 #define wxHAS_NATIVE_TIMEPICKERCTRL
94 #elif defined(__WXOSX_COCOA__) && !defined(__WXUNIVERSAL__)
95 #include "wx/osx/timectrl.h"
97 #define wxHAS_NATIVE_TIMEPICKERCTRL
99 #include "wx/generic/timectrl.h"
101 class WXDLLIMPEXP_ADV wxTimePickerCtrl
: public wxTimePickerCtrlGeneric
104 wxTimePickerCtrl() { }
105 wxTimePickerCtrl(wxWindow
*parent
,
107 const wxDateTime
& date
= wxDefaultDateTime
,
108 const wxPoint
& pos
= wxDefaultPosition
,
109 const wxSize
& size
= wxDefaultSize
,
110 long style
= wxTP_DEFAULT
,
111 const wxValidator
& validator
= wxDefaultValidator
,
112 const wxString
& name
= wxTimePickerCtrlNameStr
)
113 : wxTimePickerCtrlGeneric(parent
, id
, date
, pos
, size
, style
, validator
, name
)
118 wxDECLARE_DYNAMIC_CLASS_NO_COPY(wxTimePickerCtrl
);
122 #endif // wxUSE_TIMEPICKCTRL
124 #endif // _WX_TIMECTRL_H_