1 ///////////////////////////////////////////////////////////////////////////////
3 // Purpose: Declaration of wxTimePickerCtrl class.
4 // Author: Vadim Zeitlin
6 // RCS-ID: $Id: wxhead.h,v 1.12 2010-04-22 12:44:51 zeitlin Exp $
7 // Copyright: (c) 2011 Vadim Zeitlin <vadim@wxwidgets.org>
8 // Licence: wxWindows licence
9 ///////////////////////////////////////////////////////////////////////////////
11 #ifndef _WX_TIMECTRL_H_
12 #define _WX_TIMECTRL_H_
16 #if wxUSE_TIMEPICKCTRL
18 #include "wx/datetimectrl.h"
20 #define wxTimePickerCtrlNameStr wxS("timectrl")
22 // No special styles are currently defined for this control but still define a
23 // symbolic constant for the default style for consistency.
29 // ----------------------------------------------------------------------------
30 // wxTimePickerCtrl: Allow the user to enter the time.
31 // ----------------------------------------------------------------------------
33 class WXDLLIMPEXP_ADV wxTimePickerCtrlBase
: public wxDateTimePickerCtrl
37 The derived classes should implement ctor and Create() method with the
40 bool Create(wxWindow *parent,
42 const wxDateTime& dt = wxDefaultDateTime,
43 const wxPoint& pos = wxDefaultPosition,
44 const wxSize& size = wxDefaultSize,
45 long style = wxTP_DEFAULT,
46 const wxValidator& validator = wxDefaultValidator,
47 const wxString& name = wxTimePickerCtrlNameStr);
51 We also inherit Set/GetValue() methods from the base class which define
52 our public API. Notice that the date portion of the date passed as
53 input or received as output is or should be ignored, only the time part
54 of wxDateTime objects is really significant here. Use Set/GetTime()
55 below for possibly simpler interface.
58 // Set the given time.
59 bool SetTime(int hour
, int min
, int sec
)
61 // Notice that we should use a date on which DST doesn't change to
62 // avoid any problems with time discontinuity so use a fixed date (on
63 // which nobody changes DST) instead of e.g. today.
64 wxDateTime
dt(1, wxDateTime::Jan
, 2012, hour
, min
, sec
);
67 // No need to assert here, wxDateTime already does it for us.
76 // Get the current time components. All pointers must be non-NULL.
77 bool GetTime(int* hour
, int* min
, int* sec
) const
79 wxCHECK_MSG( hour
&& min
&& sec
, false,
80 wxS("Time component pointers must be non-NULL") );
82 const wxDateTime::Tm tm
= GetValue().GetTm();
91 #if defined(__WXMSW__) && !defined(__WXUNIVERSAL__)
92 #include "wx/msw/timectrl.h"
94 #define wxHAS_NATIVE_TIMEPICKERCTRL
95 #elif defined(__WXOSX_COCOA__) && !defined(__WXUNIVERSAL__)
96 #include "wx/osx/timectrl.h"
98 #define wxHAS_NATIVE_TIMEPICKERCTRL
100 #include "wx/generic/timectrl.h"
102 class WXDLLIMPEXP_ADV wxTimePickerCtrl
: public wxTimePickerCtrlGeneric
105 wxTimePickerCtrl() { }
106 wxTimePickerCtrl(wxWindow
*parent
,
108 const wxDateTime
& date
= wxDefaultDateTime
,
109 const wxPoint
& pos
= wxDefaultPosition
,
110 const wxSize
& size
= wxDefaultSize
,
111 long style
= wxTP_DEFAULT
,
112 const wxValidator
& validator
= wxDefaultValidator
,
113 const wxString
& name
= wxTimePickerCtrlNameStr
)
114 : wxTimePickerCtrlGeneric(parent
, id
, date
, pos
, size
, style
, validator
, name
)
119 wxDECLARE_DYNAMIC_CLASS_NO_COPY(wxTimePickerCtrl
);
123 #endif // wxUSE_TIMEPICKCTRL
125 #endif // _WX_TIMECTRL_H_