Add support for editing dates (without time) to wxGrid

Add wxGridCellDateRenderer and wxGridCellDateRenderer which can be used
for the grid cells containing only dates, without times.

Also add wxGrid::SetColFormatDate() convenience function.

Refactor wxGridCellDateTimeRenderer slightly to reuse its code.

Closes https://github.com/wxWidgets/wxWidgets/pull/1101
This commit is contained in:
Pavel Kalugin
2018-09-06 05:49:58 +03:00
committed by Vadim Zeitlin
parent ee352d79c8
commit 659ab78c6d
10 changed files with 416 additions and 46 deletions

View File

@@ -373,6 +373,41 @@ public:
wxDECLARE_NO_COPY_CLASS(wxGridCellAutoWrapStringEditor);
};
#if wxUSE_DATEPICKCTRL
class WXDLLIMPEXP_ADV wxGridCellDateEditor : public wxGridCellEditor
{
public:
wxGridCellDateEditor() { }
virtual void Create(wxWindow* parent,
wxWindowID id,
wxEvtHandler* evtHandler) wxOVERRIDE;
virtual void SetSize(const wxRect& rect) wxOVERRIDE;
virtual void BeginEdit(int row, int col, wxGrid* grid) wxOVERRIDE;
virtual bool EndEdit(int row, int col, const wxGrid* grid,
const wxString& oldval, wxString *newval) wxOVERRIDE;
virtual void ApplyEdit(int row, int col, wxGrid* grid) wxOVERRIDE;
virtual void Reset() wxOVERRIDE;
virtual wxGridCellEditor *Clone() const wxOVERRIDE;
virtual wxString GetValue() const wxOVERRIDE;
protected:
wxDatePickerCtrl* DatePicker() const;
private:
wxDateTime m_value;
wxDECLARE_NO_COPY_CLASS(wxGridCellDateEditor);
};
#endif // wxUSE_DATEPICKCTRL
#endif // wxUSE_GRID
#endif // _WX_GENERIC_GRID_EDITORS_H_