]> git.saurik.com Git - wxWidgets.git/commitdiff
For better support of wxValidators, invoke wxValidator::Validate() directly. Also...
authorJaakko Salli <jaakko.salli@dnainternet.net>
Mon, 29 Mar 2010 18:17:55 +0000 (18:17 +0000)
committerJaakko Salli <jaakko.salli@dnainternet.net>
Mon, 29 Mar 2010 18:17:55 +0000 (18:17 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@63782 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/propgrid/propgrid.h
src/propgrid/propgrid.cpp

index 5af35016f450e7fb81860ae447f21e60ab67dc02..8729f1a92a090ecd71694e0ea804da522e04d208 100644 (file)
@@ -19,6 +19,7 @@
 #include "wx/scrolwin.h"
 #include "wx/tooltip.h"
 #include "wx/datetime.h"
+#include "wx/recguard.h"
 
 #include "wx/propgrid/property.h"
 #include "wx/propgrid/propgridiface.h"
@@ -566,8 +567,6 @@ enum wxPG_SET_SPLITTER_POSITION_SPLITTER_FLAGS
 #define wxPG_FL_IN_SELECT_PROPERTY          0x00100000
 // Set when help string is shown in status bar
 #define wxPG_FL_STRING_IN_STATUSBAR         0x00200000
-// Validation failed. Clear on modify event.
-#define wxPG_FL_VALIDATION_FAILED           0x00800000
 // Auto sort is enabled (for categorized mode)
 #define wxPG_FL_CATMODE_AUTO_SORT           0x01000000
 // Set after page has been inserted to manager
@@ -1856,6 +1855,9 @@ protected:
 
     wxPGVFBFlags        m_permanentValidationFailureBehavior;  // Set by app
 
+    // DoEditorValidate() recursion guard
+    wxRecursionGuardFlag    m_validatingEditor;
+
     /** Internal flags - see wxPG_FL_XXX constants. */
     wxUint32            m_iFlags;
 
@@ -2059,7 +2061,7 @@ protected:
     /** Reloads all non-customized colours from system settings. */
     void RegainColours();
 
-    bool DoEditorValidate();
+    virtual bool DoEditorValidate();
 
     // Similar to DoSelectProperty() but also works on columns
     // other than 1. Does not active editor if column is not
index fbaacd49ac692645c005f9850e769e64f5fe16bb..e98e86097cd35ba115e5825a0bcb43a6b72b7876 100644 (file)
@@ -328,6 +328,7 @@ void wxPropertyGrid::Init1()
     if ( wxPGGlobalVars->m_mapEditorClasses.empty() )
         wxPropertyGrid::RegisterDefaultEditors();
 
+    m_validatingEditor = 0;
     m_iFlags = 0;
     m_pState = NULL;
     m_wndEditor = m_wndEditor2 = NULL;
@@ -3411,6 +3412,25 @@ wxVariant wxPropertyGrid::GetUncommittedPropertyValue()
 // Runs wxValidator for the selected property
 bool wxPropertyGrid::DoEditorValidate()
 {
+#if wxUSE_VALIDATORS
+    wxRecursionGuard guard(m_validatingEditor);
+    if ( guard.IsInside() )
+        return false;
+
+    wxPGProperty* selected = GetSelection();
+    if ( selected )
+    {
+        wxWindow* wnd = GetEditorControl();
+
+        wxValidator* validator = selected->GetValidator();
+        if ( validator && wnd )
+        {
+            validator->SetWindow(wnd);
+            if ( !validator->Validate(this) )
+                return false;
+        }
+    }
+#endif
     return true;
 }
 
@@ -3458,7 +3478,7 @@ void wxPropertyGrid::HandleCustomEditorEvent( wxEvent &event )
 
     m_chgInfo_changedProperty = NULL;
 
-    m_iFlags &= ~(wxPG_FL_VALIDATION_FAILED|wxPG_FL_VALUE_CHANGE_IN_EVENT);
+    m_iFlags &= ~wxPG_FL_VALUE_CHANGE_IN_EVENT;
 
     //
     // Filter out excess wxTextCtrl modified events
@@ -4001,8 +4021,6 @@ bool wxPropertyGrid::DoSelectProperty( wxPGProperty* p, unsigned int flags )
             int splitterX = GetSplitterPosition();
             m_editorFocused = 0;
             m_iFlags |= wxPG_FL_PRIMARY_FILLS_ENTIRE;
-            if ( p != prevFirstSel )
-                m_iFlags &= ~(wxPG_FL_VALIDATION_FAILED);
 
             wxASSERT( m_wndEditor == NULL );