]> 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 336c55fdc5b31d5e51f67ebc46880a8acb9faf5a..9726f496822b356f5faa8fed4754792ac1a41952 100644 (file)
@@ -632,7 +632,7 @@ wxString wxFloatProperty::ValueToString( wxVariant& value,
                                        value,
                                        m_precision,
                                        !(argFlags & wxPG_FULL_VALUE),
-                                       (wxString*) NULL);
+                                       NULL);
     }
     return text;
 }
@@ -963,7 +963,6 @@ wxEnumProperty::~wxEnumProperty ()
 }
 
 int wxEnumProperty::ms_nextIndex = -2;
-int wxEnumProperty::ms_prevIndex = -1;
 
 void wxEnumProperty::OnSetValue()
 {
@@ -1054,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 )
         {
@@ -1095,7 +1094,7 @@ bool wxEnumProperty::ValueFromInt_( wxVariant& variant, int intVal, int argFlags
     }
     else
     {
-        if ( m_index != intVal )
+        if ( intVal != GetIndex() )
         {
             ms_nextIndex = intVal;
         }
@@ -1118,21 +1117,23 @@ void
 wxEnumProperty::OnValidationFailure( wxVariant& WXUNUSED(pendingValue) )
 {
     // Revert index
-    m_index = ms_prevIndex;
     ResetNextIndex();
 }
 
 void wxEnumProperty::SetIndex( int index )
 {
-    ms_prevIndex = m_index;
     ms_nextIndex = -2;
     m_index = index;
 }
 
 int wxEnumProperty::GetIndex() const
 {
+    if ( m_value.IsNull() )
+        return -1;
+
     if ( ms_nextIndex != -2 )
         return ms_nextIndex;
+
     return m_index;
 }
 
@@ -1262,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 )
     {
@@ -1282,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() )
     {
@@ -1302,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() )
     {
@@ -2128,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));
@@ -2338,7 +2339,7 @@ wxPGArrayStringEditorDialog::wxPGArrayStringEditorDialog()
 
 void wxPGArrayStringEditorDialog::Init()
 {
-    m_pCallingClass = (wxArrayStringProperty*) NULL;
+    m_pCallingClass = NULL;
 }
 
 void wxPGArrayStringEditorDialog::OnCustomEditClick(wxCommandEvent& )