Merge branch 'date-picker-blank'
Allow customizing text displayed in wxDatePickerCtrl without valid value, notably not displaying anything in it in this case. See https://github.com/wxWidgets/wxWidgets/pull/2109
This commit is contained in:
@@ -32,6 +32,13 @@ 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;
|
||||
|
||||
// For the controls with wxDP_ALLOWNONE style, set the string displayed
|
||||
// when the control doesn't have any valid value. Currently this is only
|
||||
// actually used under MSW, where it can be used to override the previous
|
||||
// value which is still displayed by the control in this case, and ignored
|
||||
// elsewhere.
|
||||
virtual void SetNullText(const wxString& WXUNUSED(text)) { }
|
||||
};
|
||||
|
||||
#if defined(__WXMSW__) && !defined(__WXUNIVERSAL__)
|
||||
|
@@ -13,11 +13,13 @@
|
||||
#include "wx/containr.h"
|
||||
#include "wx/compositewin.h"
|
||||
|
||||
typedef wxTimePickerCtrlCommonBase<wxDateTimePickerCtrlBase> wxTimePickerCtrlGenericBase;
|
||||
|
||||
class WXDLLIMPEXP_ADV wxTimePickerCtrlGeneric
|
||||
: public wxCompositeWindow< wxNavigationEnabled<wxTimePickerCtrlBase> >
|
||||
: public wxCompositeWindow< wxNavigationEnabled<wxTimePickerCtrlGenericBase> >
|
||||
{
|
||||
public:
|
||||
typedef wxCompositeWindow< wxNavigationEnabled<wxTimePickerCtrlBase> > Base;
|
||||
typedef wxCompositeWindow< wxNavigationEnabled<wxTimePickerCtrlGenericBase> > Base;
|
||||
|
||||
// Creating the control.
|
||||
wxTimePickerCtrlGeneric() { Init(); }
|
||||
|
@@ -26,6 +26,8 @@ public:
|
||||
virtual void SetValue(const wxDateTime& dt) wxOVERRIDE;
|
||||
virtual wxDateTime GetValue() const wxOVERRIDE;
|
||||
|
||||
virtual void SetNullText(const wxString& text) wxOVERRIDE;
|
||||
|
||||
// returns true if the platform should explicitly apply a theme border
|
||||
virtual bool CanApplyThemeBorder() const wxOVERRIDE { return false; }
|
||||
|
||||
@@ -46,43 +48,34 @@ protected:
|
||||
const wxValidator& validator,
|
||||
const wxString& name);
|
||||
|
||||
// Notice that the methods below must be overridden in all native MSW
|
||||
// classes inheriting from this one but they can't be pure virtual because
|
||||
// the generic implementations, not needing nor able to implement them, is
|
||||
// also derived from this class currently. The real problem is, of course,
|
||||
// this wrong class structure because the generic classes also inherit the
|
||||
// wrong implementations of Set/GetValue() and DoGetBestSize() but as they
|
||||
// override these methods anyhow, it does work -- but is definitely ugly
|
||||
// and need to be changed (but how?) in the future.
|
||||
|
||||
#if wxUSE_INTL
|
||||
// Override to return the date/time format used by this control.
|
||||
virtual wxLocaleInfo MSWGetFormat() const /* = 0 */
|
||||
{
|
||||
wxFAIL_MSG( "Unreachable" );
|
||||
return wxLOCALE_TIME_FMT;
|
||||
}
|
||||
virtual wxLocaleInfo MSWGetFormat() const = 0;
|
||||
#endif // wxUSE_INTL
|
||||
|
||||
// Override to indicate whether we can have no date at all.
|
||||
virtual bool MSWAllowsNone() const /* = 0 */
|
||||
{
|
||||
wxFAIL_MSG( "Unreachable" );
|
||||
return false;
|
||||
}
|
||||
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 */
|
||||
{
|
||||
wxUnusedVar(dtch);
|
||||
wxFAIL_MSG( "Unreachable" );
|
||||
return false;
|
||||
}
|
||||
virtual bool MSWOnDateTimeChange(const tagNMDATETIMECHANGE& dtch) = 0;
|
||||
|
||||
|
||||
// the date currently shown by the control, may be invalid
|
||||
wxDateTime m_date;
|
||||
|
||||
private:
|
||||
// Helper setting the appropriate format depending on the passed in state.
|
||||
void MSWUpdateFormat(bool valid);
|
||||
|
||||
// Same thing, but only doing if the validity differs from the date
|
||||
// validity, i.e. avoiding useless work if nothing needs to be done.
|
||||
void MSWUpdateFormatIfNeeded(bool valid);
|
||||
|
||||
|
||||
// shown when there is no valid value (so only used with wxDP_ALLOWNONE),
|
||||
// always non-empty if SetNullText() was called, see the comments there
|
||||
wxString m_nullText;
|
||||
};
|
||||
|
||||
#endif // _WX_MSW_DATETIMECTRL_H_
|
||||
|
@@ -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