]> git.saurik.com Git - wxWidgets.git/blob - src/osx/datetimectrl_osx.cpp
wiring OnInit on osx to a later point in event processing
[wxWidgets.git] / src / osx / datetimectrl_osx.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: src/osx/datetimectrl_osx.cpp
3 // Purpose: Implementation of wxDateTimePickerCtrl for OS X.
4 // Author: Vadim Zeitlin
5 // Created: 2011-12-18
6 // RCS-ID: $Id$
7 // Copyright: (c) 2011 Vadim Zeitlin <vadim@wxwidgets.org>
8 // Licence: wxWindows licence
9 ///////////////////////////////////////////////////////////////////////////////
10
11 // ============================================================================
12 // declarations
13 // ============================================================================
14
15 // ----------------------------------------------------------------------------
16 // headers
17 // ----------------------------------------------------------------------------
18
19 // for compilers that support precompilation, includes "wx.h".
20 #include "wx/wxprec.h"
21
22 #ifdef __BORLANDC__
23 #pragma hdrstop
24 #endif
25
26 #if wxUSE_DATEPICKCTRL || wxUSE_TIMEPICKCTRL
27
28 #ifndef WX_PRECOMP
29 #endif // WX_PRECOMP
30
31 #include "wx/datectrl.h"
32 #include "wx/datetimectrl.h"
33
34 #include "wx/osx/core/private/datetimectrl.h"
35
36 // ============================================================================
37 // wxDateTimePickerCtrl implementation
38 // ============================================================================
39
40 wxDateTimeWidgetImpl* wxDateTimePickerCtrl::GetDateTimePeer() const
41 {
42 return static_cast<wxDateTimeWidgetImpl*>(GetPeer());
43 }
44
45 void wxDateTimePickerCtrl::SetValue(const wxDateTime& dt)
46 {
47 if ( dt.IsValid() )
48 {
49 GetDateTimePeer()->SetDateTime(dt);
50 }
51 else // invalid date
52 {
53 wxASSERT_MSG( HasFlag(wxDP_ALLOWNONE),
54 wxT("this control must have a valid date") );
55
56 // TODO setting to an invalid date is not natively supported
57 // so we must implement a UI for that ourselves
58 GetDateTimePeer()->SetDateTime(dt);
59 }
60 }
61
62 wxDateTime wxDateTimePickerCtrl::GetValue() const
63 {
64 return GetDateTimePeer()->GetDateTime();
65 }
66
67
68 #endif // wxUSE_DATEPICKCTRL || wxUSE_TIMEPICKCTRL