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