Fix inheritance hierarchy of wxTimePickerCtrlGeneric
This class must not derive from the native wxDatePickerCtrl, as it doesn't make much sense and resulted in the need for an ugly hack with either overriding unused and inapplicable pure virtual methods in this class itself, as was originally done in569c7d8ccb
(Add wxTimePickerCtrl class., 2011-09-29) when it was introduced, or not making these methods pure virtual in the first place, as was done ind0da5061ce
(Dirty hack to allow generic wxDatePickerCtrl to compile under MSW., 2011-10-20), but didn't really fix the problem. Do fix it now by using different hierarchies for the native and generic classes. The main disadvantage of doing it is that there is no common base class for wxTimePickerCtrl and wxTimePickerCtrlGeneric providing SetTime() and GetTime() methods any more, but this seems like a relatively small price to pay because real applications won't be using these two classes simultaneously, as the calendar sample does, anyhow.
This commit is contained in:
@@ -29,7 +29,10 @@ enum
|
||||
// wxTimePickerCtrl: Allow the user to enter the time.
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLIMPEXP_ADV wxTimePickerCtrlBase : public wxDateTimePickerCtrl
|
||||
// The template argument must be a class deriving from wxDateTimePickerCtrlBase
|
||||
// (i.e. in practice either this class itself or wxDateTimePickerCtrl).
|
||||
template <typename Base>
|
||||
class wxTimePickerCtrlCommonBase : public Base
|
||||
{
|
||||
public:
|
||||
/*
|
||||
@@ -67,7 +70,7 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
SetValue(dt);
|
||||
this->SetValue(dt);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -78,7 +81,7 @@ public:
|
||||
wxCHECK_MSG( hour && min && sec, false,
|
||||
wxS("Time component pointers must be non-NULL") );
|
||||
|
||||
const wxDateTime::Tm tm = GetValue().GetTm();
|
||||
const wxDateTime::Tm tm = this->GetValue().GetTm();
|
||||
*hour = tm.hour;
|
||||
*min = tm.min;
|
||||
*sec = tm.sec;
|
||||
@@ -87,6 +90,10 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
// This class is defined mostly for compatibility and is used as the base class
|
||||
// by native wxTimePickerCtrl implementations.
|
||||
typedef wxTimePickerCtrlCommonBase<wxDateTimePickerCtrl> wxTimePickerCtrlBase;
|
||||
|
||||
#if defined(__WXMSW__) && !defined(__WXUNIVERSAL__)
|
||||
#include "wx/msw/timectrl.h"
|
||||
|
||||
|
Reference in New Issue
Block a user