Refactor wxDatePickerCtrl to derive from wxDateTimePickerCtrl.
No real changes, just refactor wxMSW wxDatePickerCtrl to allow sharing code with the upcoming wxTimePickerCtrl class. Even less changes for the other platforms where wxDateTimePickerCtrl is trivial. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@69222 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -16,8 +16,7 @@
|
||||
|
||||
#if wxUSE_DATEPICKCTRL
|
||||
|
||||
#include "wx/control.h" // the base class
|
||||
#include "wx/datetime.h"
|
||||
#include "wx/datetimectrl.h" // the base class
|
||||
|
||||
#define wxDatePickerCtrlNameStr wxT("datectrl")
|
||||
|
||||
@@ -46,7 +45,7 @@ enum
|
||||
// wxDatePickerCtrl: allow the user to enter the date
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLIMPEXP_ADV wxDatePickerCtrlBase : public wxControl
|
||||
class WXDLLIMPEXP_ADV wxDatePickerCtrlBase : public wxDateTimePickerCtrl
|
||||
{
|
||||
public:
|
||||
/*
|
||||
@@ -63,13 +62,16 @@ public:
|
||||
const wxString& name = wxDatePickerCtrlNameStr);
|
||||
*/
|
||||
|
||||
// set/get the date
|
||||
virtual void SetValue(const wxDateTime& dt) = 0;
|
||||
virtual wxDateTime GetValue() const = 0;
|
||||
/*
|
||||
We inherit the methods to set/get the date from the base class.
|
||||
|
||||
// set/get the allowed valid range for the dates, if either/both of them
|
||||
// are invalid, there is no corresponding limit and if neither is set
|
||||
// GetRange() returns false
|
||||
virtual void SetValue(const wxDateTime& dt) = 0;
|
||||
virtual wxDateTime GetValue() const = 0;
|
||||
*/
|
||||
|
||||
// And add methods to set/get the allowed valid range for the dates. If
|
||||
// either/both of them are invalid, there is no corresponding limit and if
|
||||
// neither is set, GetRange() returns false.
|
||||
virtual void SetRange(const wxDateTime& dt1, const wxDateTime& dt2) = 0;
|
||||
virtual bool GetRange(wxDateTime *dt1, wxDateTime *dt2) const = 0;
|
||||
};
|
||||
|
48
include/wx/datetimectrl.h
Normal file
48
include/wx/datetimectrl.h
Normal file
@@ -0,0 +1,48 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/timectrl.h
|
||||
// Purpose: Declaration of wxDateTimePickerCtrl 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 <vadim@wxwidgets.org>
|
||||
// Licence: wxWindows licence
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_DATETIME_CTRL_H_
|
||||
#define _WX_DATETIME_CTRL_H_
|
||||
|
||||
#include "wx/defs.h"
|
||||
|
||||
#if wxUSE_DATEPICKCTRL
|
||||
|
||||
#define wxNEEDS_DATETIMEPICKCTRL
|
||||
|
||||
#include "wx/control.h" // the base class
|
||||
|
||||
#include "wx/datetime.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxDateTimePickerCtrl: Private common base class of wx{Date,Time}PickerCtrl.
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// This class is an implementation detail and should not be used directly, only
|
||||
// use the documented API of wxDateTimePickerCtrl and wxTimePickerCtrl.
|
||||
class WXDLLIMPEXP_ADV wxDateTimePickerCtrlBase : public wxControl
|
||||
{
|
||||
public:
|
||||
// Set/get the date or time (in the latter case, time part is ignored).
|
||||
virtual void SetValue(const wxDateTime& dt) = 0;
|
||||
virtual wxDateTime GetValue() const = 0;
|
||||
};
|
||||
|
||||
// Only MSW currently has any code to share between wxDatePickerCtrl and
|
||||
// wxTimePickerCtrl, under the other platforms this class is trivial.
|
||||
#if defined(__WXMSW__) && !defined(__WXUNIVERSAL__)
|
||||
#include "wx/msw/datetimectrl.h"
|
||||
#else
|
||||
typedef wxDateTimePickerCtrlBase wxDateTimePickerCtrl;
|
||||
#endif
|
||||
|
||||
#endif // wxUSE_DATEPICKCTRL
|
||||
|
||||
#endif // _WX_DATETIME_CTRL_H_
|
@@ -43,30 +43,21 @@ public:
|
||||
const wxValidator& validator = wxDefaultValidator,
|
||||
const wxString& name = wxDatePickerCtrlNameStr);
|
||||
|
||||
// set/get the date
|
||||
// Override this one to add date-specific (and time-ignoring) checks.
|
||||
virtual void SetValue(const wxDateTime& dt);
|
||||
virtual wxDateTime GetValue() const;
|
||||
|
||||
// set/get the allowed valid range for the dates, if either/both of them
|
||||
// are invalid, there is no corresponding limit and if neither is set
|
||||
// GetRange() returns false
|
||||
// Implement the base class pure virtuals.
|
||||
virtual void SetRange(const wxDateTime& dt1, const wxDateTime& dt2);
|
||||
virtual bool GetRange(wxDateTime *dt1, wxDateTime *dt2) const;
|
||||
|
||||
// Override MSW-specific functions used during control creation.
|
||||
virtual WXDWORD MSWGetStyle(long style, WXDWORD *exstyle) const;
|
||||
|
||||
virtual bool MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result);
|
||||
|
||||
// returns true if the platform should explicitly apply a theme border
|
||||
virtual bool CanApplyThemeBorder() const { return false; }
|
||||
|
||||
protected:
|
||||
virtual wxBorder GetDefaultBorder() const { return wxBORDER_NONE; }
|
||||
virtual wxSize DoGetBestSize() const;
|
||||
|
||||
// the date currently shown by the control, may be invalid
|
||||
wxDateTime m_date;
|
||||
|
||||
virtual wxLocaleInfo MSWGetFormat() const;
|
||||
virtual bool MSWAllowsNone() const { return HasFlag(wxDP_ALLOWNONE); }
|
||||
virtual bool MSWOnDateTimeChange(const tagNMDATETIMECHANGE& dtch);
|
||||
|
||||
DECLARE_DYNAMIC_CLASS_NO_COPY(wxDatePickerCtrl)
|
||||
};
|
||||
|
65
include/wx/msw/datetimectrl.h
Normal file
65
include/wx/msw/datetimectrl.h
Normal file
@@ -0,0 +1,65 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/msw/datetimectrl.h
|
||||
// Purpose: wxDateTimePickerCtrl for Windows.
|
||||
// Author: Vadim Zeitlin
|
||||
// Created: 2011-09-22 (extracted from wx/msw/datectrl.h).
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 2005-2011 Vadim Zeitlin <vadim@wxwindows.org>
|
||||
// Licence: wxWindows licence
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_MSW_DATETIMECTRL_H_
|
||||
#define _WX_MSW_DATETIMECTRL_H_
|
||||
|
||||
#include "wx/intl.h"
|
||||
|
||||
// Forward declare a struct from Platform SDK.
|
||||
struct tagNMDATETIMECHANGE;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxDateTimePickerCtrl
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLIMPEXP_ADV wxDateTimePickerCtrl : public wxDateTimePickerCtrlBase
|
||||
{
|
||||
public:
|
||||
// set/get the date
|
||||
virtual void SetValue(const wxDateTime& dt);
|
||||
virtual wxDateTime GetValue() const;
|
||||
|
||||
// returns true if the platform should explicitly apply a theme border
|
||||
virtual bool CanApplyThemeBorder() const { return false; }
|
||||
|
||||
virtual bool MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result);
|
||||
|
||||
protected:
|
||||
virtual wxBorder GetDefaultBorder() const { return wxBORDER_NONE; }
|
||||
virtual wxSize DoGetBestSize() const;
|
||||
|
||||
// Helper for the derived classes Create(): creates a native control with
|
||||
// the specified attributes.
|
||||
bool MSWCreateDateTimePicker(wxWindow *parent,
|
||||
wxWindowID id,
|
||||
const wxDateTime& dt,
|
||||
const wxPoint& pos,
|
||||
const wxSize& size,
|
||||
long style,
|
||||
const wxValidator& validator,
|
||||
const wxString& name);
|
||||
|
||||
// Override to return the date/time format used by this control.
|
||||
virtual wxLocaleInfo MSWGetFormat() const = 0;
|
||||
|
||||
// Override to indicate whether we can have no date at all.
|
||||
virtual bool MSWAllowsNone() const = 0;
|
||||
|
||||
// Override to update m_date and send the event when the control contents
|
||||
// changes, return true if the event was handled.
|
||||
virtual bool MSWOnDateTimeChange(const tagNMDATETIMECHANGE& dtch) = 0;
|
||||
|
||||
|
||||
// the date currently shown by the control, may be invalid
|
||||
wxDateTime m_date;
|
||||
};
|
||||
|
||||
#endif // _WX_MSW_DATETIMECTRL_H_
|
Reference in New Issue
Block a user