Add wxDateTimePickerCtrl::SetNullText()

This allows to customize the string shown when there is no valid date
under MSW (only, for now) and can be notably used to suppress the
unused date completely, which can be useful to lighten up the display
when there are many controls.

Add UI elements to the widgets sample allowing to test the new function.
This commit is contained in:
Vadim Zeitlin
2020-11-05 01:21:26 +01:00
parent 6d4ce92c20
commit 02f1ee3987
5 changed files with 120 additions and 1 deletions

View File

@@ -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; }
@@ -61,6 +63,19 @@ protected:
// 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_