Make wxPGValidationInfo class instead of struct, re-document it (used at least by derived wxPGProperty::ValidateValue())
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@55949 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
		@@ -346,25 +346,17 @@ wxPG_VFB_UNDEFINED                  = 0x80
 | 
			
		||||
 | 
			
		||||
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.
 | 
			
		||||
@@ -377,6 +369,15 @@ struct wxPGValidationInfo
 | 
			
		||||
    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
 | 
			
		||||
@@ -389,6 +390,19 @@ struct wxPGValidationInfo
 | 
			
		||||
        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;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
// -----------------------------------------------------------------------
 | 
			
		||||
@@ -2017,7 +2031,7 @@ public:
 | 
			
		||||
        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();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
@@ -2026,10 +2040,10 @@ public:
 | 
			
		||||
        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
 | 
			
		||||
@@ -2038,14 +2052,14 @@ public:
 | 
			
		||||
    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; }
 | 
			
		||||
 
 | 
			
		||||
@@ -269,7 +269,7 @@ class wxPropertyGridManager;
 | 
			
		||||
class wxPGOwnerDrawnComboBox;
 | 
			
		||||
class wxPGCustomComboControl;
 | 
			
		||||
class wxPGEditorDialogAdapter;
 | 
			
		||||
struct wxPGValidationInfo;
 | 
			
		||||
class wxPGValidationInfo;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
// -----------------------------------------------------------------------
 | 
			
		||||
 
 | 
			
		||||
@@ -215,6 +215,45 @@ wxPG_VFB_DEFAULT                    = wxPG_VFB_STAY_IN_PROPERTY|wxPG_VFB_BEEP,
 | 
			
		||||
 | 
			
		||||
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);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
// -----------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
@@ -877,7 +916,7 @@ public:
 | 
			
		||||
        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
 | 
			
		||||
 
 | 
			
		||||
@@ -281,7 +281,9 @@ bool wxIntProperty::DoValidation( const wxPGProperty* property, wxLongLong_t& va
 | 
			
		||||
        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
 | 
			
		||||
@@ -295,7 +297,9 @@ bool wxIntProperty::DoValidation( const wxPGProperty* property, wxLongLong_t& va
 | 
			
		||||
        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
 | 
			
		||||
@@ -488,7 +492,9 @@ bool wxUIntProperty::ValidateValue( wxVariant& value, wxPGValidationInfo& valida
 | 
			
		||||
            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;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
@@ -498,7 +504,9 @@ bool wxUIntProperty::ValidateValue( wxVariant& value, wxPGValidationInfo& valida
 | 
			
		||||
            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;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
@@ -672,7 +680,9 @@ bool wxFloatProperty::DoValidation( const wxPGProperty* property, double& value,
 | 
			
		||||
        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
 | 
			
		||||
@@ -687,7 +697,9 @@ bool wxFloatProperty::DoValidation( const wxPGProperty* property, double& value,
 | 
			
		||||
        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
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user