X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/569c7d8ccb0c3f350b50f0f8435b6c6ac3d78cc8..66c2bf7b1d9326fb650acfaae22ec50528cfbf7c:/include/wx/timectrl.h diff --git a/include/wx/timectrl.h b/include/wx/timectrl.h index 0bc9db79ca..928d9aedf3 100644 --- a/include/wx/timectrl.h +++ b/include/wx/timectrl.h @@ -3,7 +3,6 @@ // Purpose: Declaration of wxTimePickerCtrl class. // Author: Vadim Zeitlin // Created: 2011-09-22 -// RCS-ID: $Id: wxhead.h,v 1.12 2010-04-22 12:44:51 zeitlin Exp $ // Copyright: (c) 2011 Vadim Zeitlin // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -50,14 +49,51 @@ public: /* We also inherit Set/GetValue() methods from the base class which define our public API. Notice that the date portion of the date passed as - input is ignored and for the result date it's always today, but only - the time part of wxDateTime objects is really significant here. + input or received as output is or should be ignored, only the time part + of wxDateTime objects is really significant here. Use Set/GetTime() + below for possibly simpler interface. */ + + // Set the given time. + bool SetTime(int hour, int min, int sec) + { + // Notice that we should use a date on which DST doesn't change to + // avoid any problems with time discontinuity so use a fixed date (on + // which nobody changes DST) instead of e.g. today. + wxDateTime dt(1, wxDateTime::Jan, 2012, hour, min, sec); + if ( !dt.IsValid() ) + { + // No need to assert here, wxDateTime already does it for us. + return false; + } + + SetValue(dt); + + return true; + } + + // Get the current time components. All pointers must be non-NULL. + bool GetTime(int* hour, int* min, int* sec) const + { + wxCHECK_MSG( hour && min && sec, false, + wxS("Time component pointers must be non-NULL") ); + + const wxDateTime::Tm tm = GetValue().GetTm(); + *hour = tm.hour; + *min = tm.min; + *sec = tm.sec; + + return true; + } }; #if defined(__WXMSW__) && !defined(__WXUNIVERSAL__) #include "wx/msw/timectrl.h" + #define wxHAS_NATIVE_TIMEPICKERCTRL +#elif defined(__WXOSX_COCOA__) && !defined(__WXUNIVERSAL__) + #include "wx/osx/timectrl.h" + #define wxHAS_NATIVE_TIMEPICKERCTRL #else #include "wx/generic/timectrl.h"