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:
committed by
Vadim Zeitlin
parent
ee352d79c8
commit
659ab78c6d
@@ -7865,6 +7865,16 @@ void wxGrid::SetColFormatFloat(int col, int width, int precision)
|
||||
SetColFormatCustom(col, typeName);
|
||||
}
|
||||
|
||||
void wxGrid::SetColFormatDate(int col, const wxString& format)
|
||||
{
|
||||
wxString typeName = wxGRID_VALUE_DATE;
|
||||
if ( !format.empty() )
|
||||
{
|
||||
typeName << ':' << format;
|
||||
}
|
||||
SetColFormatCustom(col, typeName);
|
||||
}
|
||||
|
||||
void wxGrid::SetColFormatCustom(int col, const wxString& typeName)
|
||||
{
|
||||
wxGridCellAttr *attr = m_table->GetAttr(-1, col, wxGridCellAttr::Col );
|
||||
@@ -9364,6 +9374,15 @@ int wxGridTypeRegistry::FindDataType(const wxString& typeName)
|
||||
}
|
||||
else
|
||||
#endif // wxUSE_COMBOBOX
|
||||
#if wxUSE_DATEPICKCTRL
|
||||
if ( typeName == wxGRID_VALUE_DATE )
|
||||
{
|
||||
RegisterDataType(wxGRID_VALUE_DATE,
|
||||
new wxGridCellDateRenderer,
|
||||
new wxGridCellDateEditor);
|
||||
}
|
||||
else
|
||||
#endif // wxUSE_DATEPICKCTRL
|
||||
{
|
||||
return wxNOT_FOUND;
|
||||
}
|
||||
|
Reference in New Issue
Block a user