]> git.saurik.com Git - wxWidgets.git/blobdiff - src/propgrid/props.cpp
don't allow setting readonly combobox value to a string which is not one of the valid...
[wxWidgets.git] / src / propgrid / props.cpp
index df7efa118a6adb652864859a5f6c7b7a7cd2d8cc..9726f496822b356f5faa8fed4754792ac1a41952 100644 (file)
@@ -632,7 +632,7 @@ wxString wxFloatProperty::ValueToString( wxVariant& value,
                                        value,
                                        m_precision,
                                        !(argFlags & wxPG_FULL_VALUE),
-                                       (wxString*) NULL);
+                                       NULL);
     }
     return text;
 }
@@ -1053,7 +1053,7 @@ bool wxEnumProperty::ValueFromString_( wxVariant& value, const wxString& text, i
         setAsNextIndex = -1;
         value = text;
     }
-    else if ( m_index != useIndex )
+    else if ( useIndex != GetIndex() )
     {
         if ( useIndex != -1 )
         {
@@ -1094,7 +1094,7 @@ bool wxEnumProperty::ValueFromInt_( wxVariant& variant, int intVal, int argFlags
     }
     else
     {
-        if ( m_index != intVal )
+        if ( intVal != GetIndex() )
         {
             ms_nextIndex = intVal;
         }
@@ -1113,6 +1113,13 @@ bool wxEnumProperty::ValueFromInt_( wxVariant& variant, int intVal, int argFlags
     return false;
 }
 
+void
+wxEnumProperty::OnValidationFailure( wxVariant& WXUNUSED(pendingValue) )
+{
+    // Revert index
+    ResetNextIndex();
+}
+
 void wxEnumProperty::SetIndex( int index )
 {
     ms_nextIndex = -2;
@@ -1121,8 +1128,12 @@ void wxEnumProperty::SetIndex( int index )
 
 int wxEnumProperty::GetIndex() const
 {
+    if ( m_value.IsNull() )
+        return -1;
+
     if ( ms_nextIndex != -2 )
         return ms_nextIndex;
+
     return m_index;
 }
 
@@ -1252,7 +1263,7 @@ void wxFlagsProperty::Init()
 wxFlagsProperty::wxFlagsProperty( const wxString& label, const wxString& name,
     const wxChar** labels, const long* values, long value ) : wxPGProperty(label,name)
 {
-    m_oldChoicesData = (wxPGChoicesData*) NULL;
+    m_oldChoicesData = NULL;
 
     if ( labels )
     {
@@ -1272,7 +1283,7 @@ wxFlagsProperty::wxFlagsProperty( const wxString& label, const wxString& name,
         const wxArrayString& labels, const wxArrayInt& values, int value )
     : wxPGProperty(label,name)
 {
-    m_oldChoicesData = (wxPGChoicesData*) NULL;
+    m_oldChoicesData = NULL;
 
     if ( &labels && labels.size() )
     {
@@ -1292,7 +1303,7 @@ wxFlagsProperty::wxFlagsProperty( const wxString& label, const wxString& name,
     wxPGChoices& choices, long value )
     : wxPGProperty(label,name)
 {
-    m_oldChoicesData = (wxPGChoicesData*) NULL;
+    m_oldChoicesData = NULL;
 
     if ( choices.IsOk() )
     {
@@ -2118,7 +2129,7 @@ bool wxArrayEditorDialog::Create( wxWindow *parent,
 
     // Manipulator buttons
     wxBoxSizer* colsizer = new wxBoxSizer( wxVERTICAL );
-    m_butCustom = (wxButton*) NULL;
+    m_butCustom = NULL;
     if ( m_custBtText )
     {
         m_butCustom = new wxButton(this,28,::wxGetTranslation(m_custBtText));
@@ -2328,7 +2339,7 @@ wxPGArrayStringEditorDialog::wxPGArrayStringEditorDialog()
 
 void wxPGArrayStringEditorDialog::Init()
 {
-    m_pCallingClass = (wxArrayStringProperty*) NULL;
+    m_pCallingClass = NULL;
 }
 
 void wxPGArrayStringEditorDialog::OnCustomEditClick(wxCommandEvent& )