]> git.saurik.com Git - wxWidgets.git/blobdiff - src/propgrid/propgridiface.cpp
Fix warnings for the OSX WebKit backend.
[wxWidgets.git] / src / propgrid / propgridiface.cpp
index ff891b9f4fdfcc326dc17dfab69ea1b71671f2b6..5f66781a81ca759ddc80f4e020cd96c12f59bddc 100644 (file)
@@ -6,7 +6,7 @@
 // Created:     2008-08-24
 // RCS-ID:      $Id$
 // Copyright:   (c) Jaakko Salli
 // Created:     2008-08-24
 // RCS-ID:      $Id$
 // Copyright:   (c) Jaakko Salli
-// Licence:     wxWindows license
+// Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 
 // For compilers that support precompilation, includes "wx/wx.h".
 /////////////////////////////////////////////////////////////////////////////
 
 // For compilers that support precompilation, includes "wx/wx.h".
@@ -73,10 +73,8 @@ wxPGProperty* wxPGPropArgCls::GetPtr( wxPropertyGridInterface* iface ) const
         return iface->GetPropertyByNameA(*m_ptr.stringName);
     else if ( m_flags & IsCharPtr )
         return iface->GetPropertyByNameA(m_ptr.charName);
         return iface->GetPropertyByNameA(*m_ptr.stringName);
     else if ( m_flags & IsCharPtr )
         return iface->GetPropertyByNameA(m_ptr.charName);
-#if wxUSE_WCHAR_T
     else if ( m_flags & IsWCharPtr )
         return iface->GetPropertyByNameA(m_ptr.wcharName);
     else if ( m_flags & IsWCharPtr )
         return iface->GetPropertyByNameA(m_ptr.wcharName);
-#endif
 
     return NULL;
 }
 
     return NULL;
 }
@@ -102,7 +100,7 @@ void wxPropertyGridInterface::RefreshGrid( wxPropertyGridPageState* state )
 wxPGProperty* wxPropertyGridInterface::Append( wxPGProperty* property )
 {
     wxPGProperty* retp = m_pState->DoAppend(property);
 wxPGProperty* wxPropertyGridInterface::Append( wxPGProperty* property )
 {
     wxPGProperty* retp = m_pState->DoAppend(property);
-    
+
     wxPropertyGrid* grid = m_pState->GetGrid();
     if ( grid )
         grid->RefreshGrid();
     wxPropertyGrid* grid = m_pState->GetGrid();
     if ( grid )
         grid->RefreshGrid();
@@ -147,10 +145,6 @@ void wxPropertyGridInterface::DeleteProperty( wxPGPropArg id )
     wxPG_PROP_ARG_CALL_PROLOG()
 
     wxPropertyGridPageState* state = p->GetParentState();
     wxPG_PROP_ARG_CALL_PROLOG()
 
     wxPropertyGridPageState* state = p->GetParentState();
-    wxPropertyGrid* grid = state->GetGrid();
-
-    if ( grid->GetState() == state )
-        grid->DoSelectProperty(NULL, wxPG_SEL_DELETING|wxPG_SEL_NOVALIDATE);
 
     state->DoDelete( p, true );
 
 
     state->DoDelete( p, true );
 
@@ -167,20 +161,9 @@ wxPGProperty* wxPropertyGridInterface::RemoveProperty( wxPGPropArg id )
              wxNullProperty);
 
     wxPropertyGridPageState* state = p->GetParentState();
              wxNullProperty);
 
     wxPropertyGridPageState* state = p->GetParentState();
-    wxPropertyGrid* grid = state->GetGrid();
-
-    if ( grid->GetState() == state )
-    {
-        grid->DoSelectProperty(NULL,
-            wxPG_SEL_DELETING|wxPG_SEL_NOVALIDATE);
-    }
 
     state->DoDelete( p, false );
 
 
     state->DoDelete( p, false );
 
-    // Mark the property as 'unattached'
-    p->m_parentState = NULL;
-    p->m_parent = NULL;
-
     RefreshGrid(state);
 
     return p;
     RefreshGrid(state);
 
     return p;
@@ -218,11 +201,29 @@ wxPGProperty* wxPropertyGridInterface::ReplaceProperty( wxPGPropArg id, wxPGProp
 // wxPropertyGridInterface property operations
 // -----------------------------------------------------------------------
 
 // wxPropertyGridInterface property operations
 // -----------------------------------------------------------------------
 
+wxPGProperty* wxPropertyGridInterface::GetSelection() const
+{
+    return m_pState->GetSelection();
+}
+
+// -----------------------------------------------------------------------
+
 bool wxPropertyGridInterface::ClearSelection( bool validation )
 {
 bool wxPropertyGridInterface::ClearSelection( bool validation )
 {
-    int flags = wxPG_SEL_DONT_SEND_EVENT;
+    bool res = DoClearSelection(validation, wxPG_SEL_DONT_SEND_EVENT);
+    wxPropertyGrid* pg = GetPropertyGrid();
+    if ( pg )
+        pg->Refresh();
+    return res;
+}
+
+// -----------------------------------------------------------------------
+
+bool wxPropertyGridInterface::DoClearSelection( bool validation,
+                                                int selFlags )
+{
     if ( !validation )
     if ( !validation )
-        flags |= wxPG_SEL_NOVALIDATE;
+        selFlags |= wxPG_SEL_NOVALIDATE;
 
     wxPropertyGridPageState* state = m_pState;
 
 
     wxPropertyGridPageState* state = m_pState;
 
@@ -230,9 +231,9 @@ bool wxPropertyGridInterface::ClearSelection( bool validation )
     {
         wxPropertyGrid* pg = state->GetGrid();
         if ( pg->GetState() == state )
     {
         wxPropertyGrid* pg = state->GetGrid();
         if ( pg->GetState() == state )
-            return pg->DoSelectProperty(NULL, flags);
+            return pg->DoSelectProperty(NULL, selFlags);
         else
         else
-            state->SetSelection(NULL);
+            state->DoSetSelection(NULL);
     }
 
     return true;
     }
 
     return true;
@@ -263,7 +264,7 @@ bool wxPropertyGridInterface::EnableProperty( wxPGPropArg id, bool enable )
             return false;
 
         // If active, Set active Editor.
             return false;
 
         // If active, Set active Editor.
-        if ( grid->GetState() == state && p == grid->GetSelection() )
+        if ( grid && grid->GetState() == state && p == grid->GetSelection() )
             grid->DoSelectProperty( p, wxPG_SEL_FORCE );
     }
     else
             grid->DoSelectProperty( p, wxPG_SEL_FORCE );
     }
     else
@@ -272,11 +273,11 @@ bool wxPropertyGridInterface::EnableProperty( wxPGPropArg id, bool enable )
             return false;
 
         // If active, Disable as active Editor.
             return false;
 
         // If active, Disable as active Editor.
-        if ( grid->GetState() == state && p == grid->GetSelection() )
+        if ( grid && grid->GetState() == state && p == grid->GetSelection() )
             grid->DoSelectProperty( p, wxPG_SEL_FORCE );
     }
 
             grid->DoSelectProperty( p, wxPG_SEL_FORCE );
     }
 
-    state->DoEnableProperty(p, enable);
+    p->DoEnable(enable);
 
     RefreshProperty( p );
 
 
     RefreshProperty( p );
 
@@ -343,6 +344,7 @@ void wxPropertyGridInterface::ClearModifiedStatus()
         if ( !page ) break;
 
         page->DoGetRoot()->SetFlagRecursively(wxPG_PROP_MODIFIED, false);
         if ( !page ) break;
 
         page->DoGetRoot()->SetFlagRecursively(wxPG_PROP_MODIFIED, false);
+        page->m_anyModified = false;
 
         pageIndex++;
     }
 
         pageIndex++;
     }
@@ -351,6 +353,17 @@ void wxPropertyGridInterface::ClearModifiedStatus()
     GetPropertyGrid()->RefreshEditor();
 }
 
     GetPropertyGrid()->RefreshEditor();
 }
 
+bool wxPropertyGridInterface::SetColumnProportion( unsigned int column,
+                                                   int proportion )
+{
+    wxCHECK(m_pState, false);
+    wxPropertyGrid* pg = m_pState->GetGrid();
+    wxCHECK(pg, false);
+    wxCHECK(pg->HasFlag(wxPG_SPLITTER_AUTO_CENTER), false);
+    m_pState->DoSetColumnProportion(column, proportion);
+    return true;
+}
+
 // -----------------------------------------------------------------------
 // wxPropertyGridInterface property value setting and getting
 // -----------------------------------------------------------------------
 // -----------------------------------------------------------------------
 // wxPropertyGridInterface property value setting and getting
 // -----------------------------------------------------------------------
@@ -579,8 +592,6 @@ void wxPropertyGridInterface::Sort( int flags )
 {
     wxPropertyGrid* pg = GetPropertyGrid();
 
 {
     wxPropertyGrid* pg = GetPropertyGrid();
 
-    pg->DoClearSelection();
-
     unsigned int pageIndex = 0;
 
     for (;;)
     unsigned int pageIndex = 0;
 
     for (;;)
@@ -590,6 +601,10 @@ void wxPropertyGridInterface::Sort( int flags )
         page->DoSort(flags);
         pageIndex++;
     }
         page->DoSort(flags);
         pageIndex++;
     }
+
+    // Fix positions of any open editor controls
+    if ( pg )
+        pg->CorrectEditorWidgetPosY();
 }
 
 // -----------------------------------------------------------------------
 }
 
 // -----------------------------------------------------------------------
@@ -645,22 +660,22 @@ bool wxPropertyGridInterface::SetPropertyMaxLength( wxPGPropArg id, int maxLen )
 void
 wxPropertyGridInterface::SetPropertyBackgroundColour( wxPGPropArg id,
                                                       const wxColour& colour,
 void
 wxPropertyGridInterface::SetPropertyBackgroundColour( wxPGPropArg id,
                                                       const wxColour& colour,
-                                                      bool recursively )
+                                                      int flags )
 {
     wxPG_PROP_ARG_CALL_PROLOG()
 {
     wxPG_PROP_ARG_CALL_PROLOG()
-    p->SetBackgroundColour( colour, recursively );
-    RefreshProperty( p );
+    p->SetBackgroundColour(colour, flags);
+    RefreshProperty(p);
 }
 
 // -----------------------------------------------------------------------
 
 void wxPropertyGridInterface::SetPropertyTextColour( wxPGPropArg id,
                                                      const wxColour& colour,
 }
 
 // -----------------------------------------------------------------------
 
 void wxPropertyGridInterface::SetPropertyTextColour( wxPGPropArg id,
                                                      const wxColour& colour,
-                                                     bool recursively )
+                                                     int flags )
 {
     wxPG_PROP_ARG_CALL_PROLOG()
 {
     wxPG_PROP_ARG_CALL_PROLOG()
-    p->SetTextColour( colour, recursively );
-    RefreshProperty( p );
+    p->SetTextColour(colour, flags);
+    RefreshProperty(p);
 }
 
 // -----------------------------------------------------------------------
 }
 
 // -----------------------------------------------------------------------
@@ -684,7 +699,7 @@ void wxPropertyGridInterface::SetPropertyCell( wxPGPropArg id,
     wxPG_PROP_ARG_CALL_PROLOG()
 
     wxPGCell& cell = p->GetCell(column);
     wxPG_PROP_ARG_CALL_PROLOG()
 
     wxPGCell& cell = p->GetCell(column);
-    if ( text.length() && text != wxPG_LABEL )
+    if ( !text.empty() && text != wxPG_LABEL )
         cell.SetText(text);
     if ( bitmap.IsOk() )
         cell.SetBitmap(bitmap);
         cell.SetText(text);
     if ( bitmap.IsOk() )
         cell.SetBitmap(bitmap);
@@ -857,7 +872,7 @@ wxString wxPropertyGridInterface::SaveEditableState( int includedStates ) const
         if ( includedStates & ExpandedState )
         {
             wxArrayPGProperty ptrs;
         if ( includedStates & ExpandedState )
         {
             wxArrayPGProperty ptrs;
-            wxPropertyGridConstIterator it = 
+            wxPropertyGridConstIterator it =
                 wxPropertyGridConstIterator( pageState,
                                              wxPG_ITERATE_ALL_PARENTS_RECURSIVELY|wxPG_ITERATE_HIDDEN,
                                              wxNullProperty );
                 wxPropertyGridConstIterator( pageState,
                                              wxPG_ITERATE_ALL_PARENTS_RECURSIVELY|wxPG_ITERATE_HIDDEN,
                                              wxNullProperty );
@@ -917,7 +932,7 @@ wxString wxPropertyGridInterface::SaveEditableState( int includedStates ) const
     }
 
     // Remove last '|'
     }
 
     // Remove last '|'
-    if ( result.length() )
+    if ( !result.empty() )
         result.RemoveLast();
 
     return result;
         result.RemoveLast();
 
     return result;
@@ -961,7 +976,7 @@ bool wxPropertyGridInterface::RestoreEditableState( const wxString& src, int res
                 {
                     if ( restoreStates & ExpandedState )
                     {
                 {
                     if ( restoreStates & ExpandedState )
                     {
-                        wxPropertyGridIterator it = 
+                        wxPropertyGridIterator it =
                             wxPropertyGridIterator( pageState,
                                                     wxPG_ITERATE_ALL,
                                                     wxNullProperty );
                             wxPropertyGridIterator( pageState,
                                                     wxPG_ITERATE_ALL,
                                                     wxNullProperty );
@@ -1019,14 +1034,14 @@ bool wxPropertyGridInterface::RestoreEditableState( const wxString& src, int res
                         {
                             if ( pageState->IsDisplayed() )
                             {
                         {
                             if ( pageState->IsDisplayed() )
                             {
-                                if ( values[0].length() )
+                                if ( !values[0].empty() )
                                     newSelection = GetPropertyByName(value);
                                 pgSelectionSet = true;
                             }
                             else
                             {
                                     newSelection = GetPropertyByName(value);
                                 pgSelectionSet = true;
                             }
                             else
                             {
-                                if ( values[0].length() )
-                                    pageState->SetSelection(GetPropertyByName(value));
+                                if ( !values[0].empty() )
+                                    pageState->DoSetSelection(GetPropertyByName(value));
                                 else
                                     pageState->DoClearSelection();
                             }
                                 else
                                     pageState->DoClearSelection();
                             }