]> git.saurik.com Git - wxWidgets.git/commitdiff
Make wxPGValidationInfo class instead of struct, re-document it (used at least by...
authorJaakko Salli <jaakko.salli@dnainternet.net>
Mon, 29 Sep 2008 16:23:38 +0000 (16:23 +0000)
committerJaakko Salli <jaakko.salli@dnainternet.net>
Mon, 29 Sep 2008 16:23:38 +0000 (16:23 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@55949 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/propgrid/propgrid.h
include/wx/propgrid/propgriddefs.h
interface/wx/propgrid/propgrid.h
src/propgrid/props.cpp

index 0dcc0b3a06a4fe5739f91438543afc37f9c0186e..40025f01caef9b4f58f5968eedfdb91c4529c6d0 100644 (file)
@@ -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; }
index 0cafff69341fba86dead815fe86d9e990de772db..50937ec0f4fe2da612a0ec5280960f13c0cd6144 100644 (file)
@@ -269,7 +269,7 @@ class wxPropertyGridManager;
 class wxPGOwnerDrawnComboBox;
 class wxPGCustomComboControl;
 class wxPGEditorDialogAdapter;
-struct wxPGValidationInfo;
+class wxPGValidationInfo;
 
 
 // -----------------------------------------------------------------------
index 7ceeee2101208da59bcd59e351cc79db411d877b..70dd99174cafd029824ffe513c08aceb3823254d 100644 (file)
@@ -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
index e74e099e8fbc25f2262b45bd9a84fa5720bac48c..281f38488bf8a86b93aa6c0db995144e4bfdb5dd 100644 (file)
@@ -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