Fix inheritance hierarchy of wxDatePickerCtrlGeneric too
This is very similar to 8a64b6acea
(Fix inheritance hierarchy of
wxTimePickerCtrlGeneric, 2020-11-04) and is done for the same reasons
(avoid having to somehow implement MSW-specific virtual methods of the
native controls base class in the generic version) and suffers from the
same drawback (there is no common base class for the native and generic
version any more).
See https://github.com/wxWidgets/wxWidgets/pull/2109
This commit is contained in:
@@ -44,7 +44,10 @@ enum
|
||||
// wxDatePickerCtrl: allow the user to enter the date
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLIMPEXP_ADV wxDatePickerCtrlBase : 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 WXDLLIMPEXP_ADV wxDatePickerCtrlCommonBase : public Base
|
||||
{
|
||||
public:
|
||||
/*
|
||||
@@ -75,6 +78,10 @@ public:
|
||||
virtual bool GetRange(wxDateTime *dt1, wxDateTime *dt2) const = 0;
|
||||
};
|
||||
|
||||
// This class is defined mostly for compatibility and is used as the base class
|
||||
// by native wxDatePickerCtrl implementations.
|
||||
typedef wxDatePickerCtrlCommonBase<wxDateTimePickerCtrl> wxDatePickerCtrlBase;
|
||||
|
||||
#if defined(__WXMSW__) && !defined(__WXUNIVERSAL__)
|
||||
#include "wx/msw/datectrl.h"
|
||||
|
||||
|
@@ -19,8 +19,10 @@ class WXDLLIMPEXP_FWD_CORE wxComboCtrl;
|
||||
class WXDLLIMPEXP_FWD_CORE wxCalendarCtrl;
|
||||
class WXDLLIMPEXP_FWD_CORE wxCalendarComboPopup;
|
||||
|
||||
typedef wxDatePickerCtrlCommonBase<wxDateTimePickerCtrlBase> wxDatePickerCtrlGenericBase;
|
||||
|
||||
class WXDLLIMPEXP_CORE wxDatePickerCtrlGeneric
|
||||
: public wxCompositeWindow< wxNavigationEnabled<wxDatePickerCtrlBase> >
|
||||
: public wxCompositeWindow< wxNavigationEnabled<wxDatePickerCtrlGenericBase> >
|
||||
{
|
||||
public:
|
||||
// creating the control
|
||||
|
@@ -195,13 +195,25 @@ class MyDateDialog : public wxDialog
|
||||
public:
|
||||
MyDateDialog(wxWindow *parent, const wxDateTime& dt, int dtpStyle);
|
||||
|
||||
wxDateTime GetDate() const { return m_datePicker->GetValue(); }
|
||||
wxDateTime GetDate() const
|
||||
{
|
||||
#if wxUSE_DATEPICKCTRL_GENERIC
|
||||
if ( m_datePickerGeneric )
|
||||
return m_datePickerGeneric->GetValue();
|
||||
#endif // wxUSE_DATEPICKCTRL_GENERIC
|
||||
|
||||
return m_datePicker->GetValue();
|
||||
}
|
||||
|
||||
private:
|
||||
void OnDateChange(wxDateEvent& event);
|
||||
|
||||
|
||||
wxDatePickerCtrlBase *m_datePicker;
|
||||
wxDatePickerCtrl *m_datePicker;
|
||||
#if wxUSE_DATEPICKCTRL_GENERIC
|
||||
wxDatePickerCtrlGeneric *m_datePickerGeneric;
|
||||
#endif // wxUSE_DATEPICKCTRL_GENERIC
|
||||
|
||||
wxStaticText *m_dateText;
|
||||
|
||||
|
||||
@@ -941,20 +953,36 @@ wxEND_EVENT_TABLE()
|
||||
MyDateDialog::MyDateDialog(wxWindow *parent, const wxDateTime& dt, int dtpStyle)
|
||||
: wxDialog(parent, wxID_ANY, wxString("Calendar: Choose a date"))
|
||||
{
|
||||
wxWindow* datePickerWindow = NULL;
|
||||
|
||||
#if wxUSE_DATEPICKCTRL_GENERIC
|
||||
m_datePickerGeneric = NULL;
|
||||
m_datePicker = NULL;
|
||||
|
||||
wxFrame *frame = (wxFrame *)wxGetTopLevelParent(parent);
|
||||
if ( frame && frame->GetMenuBar()->IsChecked(Calendar_DatePicker_Generic) )
|
||||
m_datePicker = new wxDatePickerCtrlGeneric(this, wxID_ANY, dt,
|
||||
{
|
||||
m_datePickerGeneric = new wxDatePickerCtrlGeneric(this, wxID_ANY, dt,
|
||||
wxDefaultPosition,
|
||||
wxDefaultSize,
|
||||
dtpStyle);
|
||||
m_datePickerGeneric->SetRange(wxDateTime(1, wxDateTime::Jan, 1900),
|
||||
wxDefaultDateTime);
|
||||
|
||||
datePickerWindow = m_datePickerGeneric;
|
||||
}
|
||||
else
|
||||
#endif // wxUSE_DATEPICKCTRL_GENERIC
|
||||
{
|
||||
m_datePicker = new wxDatePickerCtrl(this, wxID_ANY, dt,
|
||||
wxDefaultPosition, wxDefaultSize,
|
||||
dtpStyle);
|
||||
m_datePicker->SetRange(wxDateTime(1, wxDateTime::Jan, 1900),
|
||||
wxDefaultDateTime);
|
||||
|
||||
datePickerWindow = m_datePicker;
|
||||
}
|
||||
|
||||
m_dateText = new wxStaticText(this, wxID_ANY,
|
||||
dt.IsValid() ? dt.FormatISODate()
|
||||
: wxString());
|
||||
@@ -962,7 +990,7 @@ MyDateDialog::MyDateDialog(wxWindow *parent, const wxDateTime& dt, int dtpStyle)
|
||||
const wxSizerFlags flags = wxSizerFlags().Centre().Border();
|
||||
wxFlexGridSizer* const sizerMain = new wxFlexGridSizer(2);
|
||||
sizerMain->Add(new wxStaticText(this, wxID_ANY, "Enter &date:"), flags);
|
||||
sizerMain->Add(m_datePicker, flags);
|
||||
sizerMain->Add(datePickerWindow, flags);
|
||||
|
||||
sizerMain->Add(new wxStaticText(this, wxID_ANY, "Date in ISO format:"),
|
||||
flags);
|
||||
|
Reference in New Issue
Block a user