typedef wxByte wxPGVFBFlags;
-/** @class wxPGValidationInfo
+/**
+ wxPGValidationInfo
Used to convey validation information to and from functions that
- actually perform validation.
+ actually perform validation. Mostly used in custom property
+ classes.
*/
-struct wxPGValidationInfo
+class wxPGValidationInfo
{
- /** Value to be validated.
- */
- wxVariant* m_pValue;
-
- /** Message displayed on validation failure.
- */
- wxString m_failureMessage;
-
- /** Validation failure behavior. Use wxPG_VFB_XXX flags.
- */
- wxPGVFBFlags m_failureBehavior;
-
+ friend class wxPropertyGrid;
+public:
/**
@return Returns failure behavior which is a combination of
@ref propgrid_vfbflags.
const wxString& GetFailureMessage() const
{ return m_failureMessage; }
+ /**
+ Returns reference to pending value.
+ */
+ const wxVariant& GetValue() const
+ {
+ wxASSERT(m_pValue);
+ return *m_pValue;
+ }
+
/** Set validation failure behavior
@param failureBehavior
Set current failure message.
*/
void SetFailureMessage(const wxString& message);
+
+private:
+ /** Value to be validated.
+ */
+ wxVariant* m_pValue;
+
+ /** Message displayed on validation failure.
+ */
+ wxString m_failureMessage;
+
+ /** Validation failure behavior. Use wxPG_VFB_XXX flags.
+ */
+ wxPGVFBFlags m_failureBehavior;
};
// -----------------------------------------------------------------------
wxASSERT_MSG( m_validationInfo,
"Only call GetValue from a handler "
"of event type that supports it" );
- return *m_validationInfo->m_pValue;
+ return m_validationInfo->GetValue();
}
/**
Only effective if Veto was also called, and only allowed if event type
is wxEVT_PG_CHANGING.
*/
- void SetValidationFailureBehavior( int flags )
+ void SetValidationFailureBehavior( wxPGVFBFlags flags )
{
wxASSERT( GetEventType() == wxEVT_PG_CHANGING );
- m_validationInfo->m_failureBehavior = (wxPGVFBFlags) flags;
+ m_validationInfo->SetFailureBehavior( flags );
}
/** Sets custom failure message for this time only. Only applies if
void SetValidationFailureMessage( const wxString& message )
{
wxASSERT( GetEventType() == wxEVT_PG_CHANGING );
- m_validationInfo->m_failureMessage = message;
+ m_validationInfo->SetFailureMessage( message );
}
#ifndef SWIG
wxPGVFBFlags GetValidationFailureBehavior() const
{
wxASSERT( GetEventType() == wxEVT_PG_CHANGING );
- return m_validationInfo->m_failureBehavior;
+ return m_validationInfo->GetFailureBehavior();
}
void SetCanVeto( bool canVeto ) { m_canVeto = canVeto; }
class wxPGOwnerDrawnComboBox;
class wxPGCustomComboControl;
class wxPGEditorDialogAdapter;
-struct wxPGValidationInfo;
+class wxPGValidationInfo;
// -----------------------------------------------------------------------
typedef wxByte wxPGVFBFlags;
+/**
+ wxPGValidationInfo
+
+ Used to convey validation information to and from functions that
+ actually perform validation. Mostly used in custom property
+ classes.
+*/
+class wxPGValidationInfo
+{
+public:
+ /**
+ @return Returns failure behavior which is a combination of
+ @ref propgrid_vfbflags.
+ */
+ wxPGVFBFlags GetFailureBehavior();
+
+ /**
+ Returns current failure message.
+ */
+ const wxString& GetFailureMessage() const;
+
+ /**
+ Returns reference to pending value.
+ */
+ const wxVariant& GetValue() const;
+
+ /** Set validation failure behavior
+
+ @param failureBehavior
+ Mixture of @ref propgrid_vfbflags.
+ */
+ void SetFailureBehavior(wxPGVFBFlags failureBehavior);
+
+ /**
+ Set current failure message.
+ */
+ void SetFailureMessage(const wxString& message);
+};
+
// -----------------------------------------------------------------------
/**
Set override validation failure behavior. Only effective if Veto() was
also called, and only allowed if event type is wxEVT_PG_CHANGING.
*/
- void SetValidationFailureBehavior( int flags );
+ void SetValidationFailureBehavior( wxPGVFBFlags flags );
/**
Sets custom failure message for this time only. Only applies if
if ( value < min )
{
if ( mode == wxPG_PROPERTY_VALIDATION_ERROR_MESSAGE )
- pValidationInfo->m_failureMessage = wxString::Format(_("Value must be %lld or higher"),min);
+ pValidationInfo->SetFailureMessage(
+ wxString::Format(_("Value must be %lld or higher"),min)
+ );
else if ( mode == wxPG_PROPERTY_VALIDATION_SATURATE )
value = min;
else
if ( value > max )
{
if ( mode == wxPG_PROPERTY_VALIDATION_ERROR_MESSAGE )
- pValidationInfo->m_failureMessage = wxString::Format(_("Value must be %lld or higher"),min);
+ pValidationInfo->SetFailureMessage(
+ wxString::Format(_("Value must be %lld or higher"),min)
+ );
else if ( mode == wxPG_PROPERTY_VALIDATION_SATURATE )
value = max;
else
wxPGVariantToULongLong(variant, &min);
if ( ll < min )
{
- validationInfo.m_failureMessage = wxString::Format(_("Value must be %llu or higher"),min);
+ validationInfo.SetFailureMessage(
+ wxString::Format(_("Value must be %llu or higher"),min)
+ );
return false;
}
}
wxPGVariantToULongLong(variant, &max);
if ( ll > max )
{
- validationInfo.m_failureMessage = wxString::Format(_("Value must be %llu or less"),max);
+ validationInfo.SetFailureMessage(
+ wxString::Format(_("Value must be %llu or less"),max)
+ );
return false;
}
}
if ( value < min )
{
if ( mode == wxPG_PROPERTY_VALIDATION_ERROR_MESSAGE )
- pValidationInfo->m_failureMessage = wxString::Format(_("Value must be %f or higher"),min);
+ pValidationInfo->SetFailureMessage(
+ wxString::Format(_("Value must be %f or higher"),min)
+ );
else if ( mode == wxPG_PROPERTY_VALIDATION_SATURATE )
value = min;
else
if ( value > max )
{
if ( mode == wxPG_PROPERTY_VALIDATION_ERROR_MESSAGE )
- pValidationInfo->m_failureMessage = wxString::Format(_("Value must be %f or less"),max);
+ pValidationInfo->SetFailureMessage(
+ wxString::Format(_("Value must be %f or less"),max)
+ );
else if ( mode == wxPG_PROPERTY_VALIDATION_SATURATE )
value = max;
else