]> git.saurik.com Git - wxWidgets.git/blobdiff - src/propgrid/propgrid.cpp
Source changes needed to get MDI support compiling on OS X Cocoa, and a explicit...
[wxWidgets.git] / src / propgrid / propgrid.cpp
index 4575d4e49fa1fcaee5737d8ec2cbd26d420d4162..fc40bcf90b45c9ac200577d573b116d19a4a5d75 100644 (file)
@@ -16,6 +16,8 @@
     #pragma hdrstop
 #endif
 
+#if wxUSE_PROPGRID
+
 #ifndef WX_PRECOMP
     #include "wx/defs.h"
     #include "wx/object.h"
@@ -199,37 +201,6 @@ wxPGGlobalVarsClass::wxPGGlobalVarsClass()
 
     wxVariant v;
 
-    v = (long)0;
-    wxVariantClassInfo_long = wxPGVariantDataGetClassInfo(v.GetData());
-
-    v = wxString();
-    wxVariantClassInfo_string = wxPGVariantDataGetClassInfo(v.GetData());
-
-    v = (double)0.0;
-    wxVariantClassInfo_double = wxPGVariantDataGetClassInfo(v.GetData());
-
-    v = (bool)false;
-    wxVariantClassInfo_bool = wxPGVariantDataGetClassInfo(v.GetData());
-
-    v = wxArrayString();
-    wxVariantClassInfo_arrstring = wxPGVariantDataGetClassInfo(v.GetData());
-
-    wxColour col;
-    wxVariant v2((wxObject*)&col);
-    wxVariantClassInfo_wxobject = wxPGVariantDataGetClassInfo(v2.GetData());
-
-    wxVariantList list;
-    v = wxVariant(list);
-    wxVariantClassInfo_list = wxPGVariantDataGetClassInfo(v.GetData());
-
-    v << *wxRED;
-    wxVariantClassInfo_wxColour = wxPGVariantDataGetClassInfo(v.GetData());
-
-#if wxUSE_DATETIME
-    v = wxVariant(wxDateTime::Now());
-    wxVariantClassInfo_datetime = wxPGVariantDataGetClassInfo(v.GetData());
-#endif
-
        // Prepare some shared variants
     m_vEmptyString = wxString();
     m_vZero = (long) 0;
@@ -238,6 +209,10 @@ wxPGGlobalVarsClass::wxPGGlobalVarsClass()
     m_vFalse = false;
 
     // Prepare cached string constants
+    m_strstring = wxS("string");
+    m_strlong = wxS("long");
+    m_strbool = wxS("bool");
+    m_strlist = wxS("list");
     m_strMin = wxS("Min");
     m_strMax = wxS("Max");
     m_strUnits = wxS("Units");
@@ -2826,7 +2801,7 @@ bool wxPropertyGrid::PerformValidation( wxPGProperty* p, wxVariant& pendingValue
 
     m_validationInfo.m_failureBehavior = m_permanentValidationFailureBehavior;
 
-    if ( !wxPGIsVariantType(pendingValue, list) )
+    if ( pendingValue.GetType() == wxPG_VARIANT_TYPE_LIST )
     {
         if ( !p->ValidateValue(pendingValue, m_validationInfo) )
             return false;
@@ -2873,7 +2848,7 @@ bool wxPropertyGrid::PerformValidation( wxPGProperty* p, wxVariant& pendingValue
     wxVariant value;
     wxPGProperty* evtChangingProperty = changedProperty;
 
-    if ( !wxPGIsVariantType(*pPendingValue, list) )
+    if ( pPendingValue->GetType() != wxPG_VARIANT_TYPE_LIST )
     {
         value = *pPendingValue;
     }
@@ -2928,7 +2903,7 @@ bool wxPropertyGrid::PerformValidation( wxPGProperty* p, wxVariant& pendingValue
 
     // If changedProperty is not property which value was edited,
     // then call wxPGProperty::ValidateValue() for that as well.
-    if ( p != changedProperty && !wxPGIsVariantType(value, list) )
+    if ( p != changedProperty && value.GetType() != wxPG_VARIANT_TYPE_LIST )
     {
         if ( !changedProperty->ValidateValue(value, m_validationInfo) )
             return false;
@@ -3076,7 +3051,7 @@ bool wxPropertyGrid::DoPropertyChanged( wxPGProperty* p, unsigned int selFlags )
         topPaintedProperty = topPaintedProperty->GetParent();
     }
 
-    changedProperty->SetValue(value, &m_chgInfo_valueList);
+    changedProperty->SetValue(value, &m_chgInfo_valueList, wxPG_SETVAL_BY_USER);
 
     // Set as Modified (not if dragging just began)
     if ( !(p->m_flags & wxPG_PROP_MODIFIED) )
@@ -3422,7 +3397,7 @@ wxSize wxPropertyGrid::GetImageSize( wxPGProperty* p, int item ) const
 
     wxSize cis = p->OnMeasureImage(item);
 
-    int choiceCount = p->GetChoiceCount();
+    int choiceCount = p->m_choices.GetCount();
     int comVals = p->GetDisplayedCommonValueCount();
     if ( item >= choiceCount && comVals > 0 )
     {
@@ -3549,6 +3524,8 @@ void wxPropertyGrid::FreeEditors()
 // Call with NULL to de-select property
 bool wxPropertyGrid::DoSelectProperty( wxPGProperty* p, unsigned int flags )
 {
+    wxPanel* canvas = GetPanel();
+
     /*
     if (p)
         wxLogDebug(wxT("SelectProperty( %s (%s[%i]) )"),p->m_label.c_str(),
@@ -3617,8 +3594,7 @@ bool wxPropertyGrid::DoSelectProperty( wxPGProperty* p, unsigned int flags )
                 }
                 else
                 {
-                    wxScrolledWindow::SetFocus();
-                    m_editorFocused = 0;
+                    SetFocusOnCanvas();
                 }
             }
 
@@ -3723,7 +3699,7 @@ bool wxPropertyGrid::DoSelectProperty( wxPGProperty* p, unsigned int flags )
 
                 if ( m_wndEditor )
                 {
-                    wxASSERT_MSG( m_wndEditor->GetParent() == m_canvas,
+                    wxASSERT_MSG( m_wndEditor->GetParent() == canvas,
                                   wxT("CreateControls must use result of wxPropertyGrid::GetPanel() as parent of controls.") );
 
                     // Set validator, if any
@@ -3791,7 +3767,7 @@ bool wxPropertyGrid::DoSelectProperty( wxPGProperty* p, unsigned int flags )
 
                 if ( m_wndEditor2 )
                 {
-                    wxASSERT_MSG( m_wndEditor2->GetParent() == m_canvas,
+                    wxASSERT_MSG( m_wndEditor2->GetParent() == canvas,
                                   wxT("CreateControls must use result of wxPropertyGrid::GetPanel() as parent of controls.") );
 
                     // Get proper id for wndSecondary
@@ -3836,8 +3812,8 @@ bool wxPropertyGrid::DoSelectProperty( wxPGProperty* p, unsigned int flags )
             }
             else
             {
-                // wxGTK atleast seems to need this (wxMSW not)
-                SetFocus();
+                // Make sure focus is in grid canvas (important for wxGTK, at least)
+                SetFocusOnCanvas();
             }
 
             EditorsValueWasNotModified();
@@ -3857,6 +3833,11 @@ bool wxPropertyGrid::DoSelectProperty( wxPGProperty* p, unsigned int flags )
 
             DrawItems(p, p);
         }
+        else
+        {
+            // Make sure focus is in grid canvas
+            SetFocusOnCanvas();
+        }
 
         ClearInternalFlag(wxPG_FL_IN_SELECT_PROPERTY);
     }
@@ -3924,7 +3905,7 @@ bool wxPropertyGrid::UnfocusEditor()
     if ( !CommitChangesFromEditor(0) )
         return false;
 
-    m_canvas->SetFocusIgnoringChildren();
+    SetFocusOnCanvas();
     DrawItem(m_selected);
 
     return true;
@@ -4245,7 +4226,7 @@ bool wxPropertyGrid::HandleMouseClick( int x, unsigned int y, wxMouseEvent &even
     // Need to set focus?
     if ( !(m_iFlags & wxPG_FL_FOCUSED) )
     {
-        m_canvas->SetFocus();
+        SetFocusOnCanvas();
     }
 
     wxPropertyGridPageState* state = m_pState;
@@ -6327,3 +6308,5 @@ void wxPropertyGridPopulator::ProcessError( const wxString& msg )
 }
 
 // -----------------------------------------------------------------------
+
+#endif  // wxUSE_PROPGRID