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

@@ -555,6 +555,16 @@ GridFrame::GridFrame()
grid->SetCellAlignment(3, 9, wxALIGN_CENTRE, wxALIGN_TOP);
grid->SetCellValue(3, 10, "<- This numeric cell should be centred");
grid->SetColFormatDate(13); // Localized by default.
grid->SetColFormatDate(14, "%Y-%m-%d"); // ISO 8601 date format.
grid->SetCellValue(7, 0, "Today");
grid->SetCellRenderer(7, 0, new wxGridCellDateRenderer);
grid->SetCellEditor(7, 0, new wxGridCellDateEditor);
grid->SetCellValue(8, 0, "Tomorrow");
grid->SetCellRenderer(8, 0, new wxGridCellDateRenderer("%Y-%m-%d"));
grid->SetCellEditor(8, 0, new wxGridCellDateEditor);
const wxString choices[] =
{
"Please select a choice",