Call wxDataViewRenderer::Validate() under OS X too.

Ensure that the custom renderers get a chance to validate (and maybe change)
the value entered by user, as previously it was completely impossible with the
native OS X implementation of wxDataViewCtrl.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@76322 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin 2014-04-12 22:56:10 +00:00
parent 047b18bd65
commit 719f6df326

View File

@ -2658,6 +2658,9 @@ wxDataViewRenderer::OSXOnCellChanged(NSObject *object,
return;
}
if ( !Validate(value) )
return;
wxDataViewModel *model = GetOwner()->GetOwner()->GetModel();
model->ChangeValue(value, item, col);
}
@ -2807,8 +2810,12 @@ wxDataViewTextRenderer::OSXOnCellChanged(NSObject *value,
const wxDataViewItem& item,
unsigned col)
{
wxVariant valueText(ObjectToString(value));
if ( !Validate(valueText) )
return;
wxDataViewModel *model = GetOwner()->GetOwner()->GetModel();
model->ChangeValue(ObjectToString(value), item, col);
model->ChangeValue(valueText, item, col);
}
IMPLEMENT_CLASS(wxDataViewTextRenderer,wxDataViewRenderer)
@ -2888,8 +2895,12 @@ wxDataViewChoiceRenderer::OSXOnCellChanged(NSObject *value,
wxCHECK_RET( choiceIndex >= 0 && (size_t)choiceIndex < GetChoices().size(),
wxS("Choice index out of range.") );
wxVariant valueChoice(GetChoice(choiceIndex));
if ( !Validate(valueChoice) )
return;
wxDataViewModel *model = GetOwner()->GetOwner()->GetModel();
model->ChangeValue(GetChoice(choiceIndex), item, col);
model->ChangeValue(valueChoice, item, col);
}
bool wxDataViewChoiceRenderer::MacRender()
@ -2996,8 +3007,12 @@ wxDataViewDateRenderer::OSXOnCellChanged(NSObject *value,
const wxDataViewItem& item,
unsigned col)
{
wxVariant valueDate(ObjectToDate(value));
if ( !Validate(valueDate) )
return;
wxDataViewModel *model = GetOwner()->GetOwner()->GetModel();
model->ChangeValue(ObjectToDate(value), item, col);
model->ChangeValue(valueDate, item, col);
}
IMPLEMENT_ABSTRACT_CLASS(wxDataViewDateRenderer,wxDataViewRenderer)
@ -3051,6 +3066,9 @@ wxDataViewIconTextRenderer::OSXOnCellChanged(NSObject *value,
wxVariant valueIconText;
valueIconText << wxDataViewIconText(ObjectToString(value));
if ( !Validate(valueIconText) )
return;
wxDataViewModel *model = GetOwner()->GetOwner()->GetModel();
model->ChangeValue(valueIconText, item, col);
}
@ -3095,8 +3113,12 @@ wxDataViewToggleRenderer::OSXOnCellChanged(NSObject *value,
const wxDataViewItem& item,
unsigned col)
{
wxVariant valueToggle(ObjectToBool(value));
if ( !Validate(valueToggle) )
return;
wxDataViewModel *model = GetOwner()->GetOwner()->GetModel();
model->ChangeValue(ObjectToBool(value), item, col);
model->ChangeValue(valueToggle, item, col);
}
IMPLEMENT_ABSTRACT_CLASS(wxDataViewToggleRenderer,wxDataViewRenderer)
@ -3140,8 +3162,12 @@ wxDataViewProgressRenderer::OSXOnCellChanged(NSObject *value,
const wxDataViewItem& item,
unsigned col)
{
wxVariant valueProgress(ObjectToLong(value));
if ( !Validate(valueProgress) )
return;
wxDataViewModel *model = GetOwner()->GetOwner()->GetModel();
model->ChangeValue(ObjectToLong(value), item, col);
model->ChangeValue(valueProgress, item, col);
}
IMPLEMENT_ABSTRACT_CLASS(wxDataViewProgressRenderer,wxDataViewRenderer)